SRL Archive - SRL Archives

Fighting procedures by: RealRune


realrune

2006-05-25 21:47:47

procedure RealEatIfNeeded(foodcolor, eathp : integer; foodlogout : boolean); //modified from my old autofighter
begin
if(GetHp < EatHp)and(FoodColor > 0)then
begin
if(FindColorSpiraltolerance(x, y, foodcolor, 560, 210, 730, 460, 2) = true)then
begin
Mmouse(x + 2, y - 2, 6, 5)
if(IsUpText('Eat') = true)then
begin
GetMousePos(x, y);
mouse(x, y, 3, 2, true);
end;
end
Else
begin
if(FoodLogout = true)then
begin
logout;
Players[CurrentPlayer].Active:= false;
end;
end;
end;
end;

function IsFight : boolean; //results true if you are in a fight.
var
x, y : integer;
begin
result:=false;
if(FindColorSpiral(x, y, GreenStatusColor, 180, 90, 320, 230))then
begin
wait(1000 + random(250));
if(FindColorSpiral(x, y, GreenStatusColor, 180, 90, 320, 230))then
result:=true;
end;
end;

function IsFightAt(x, y : integer) : boolean; //results true if it finds a fight near x,y.
var
xx, yy : integer;
begin
result:=FindColorSpiral(xx, yy, GreenStatusColor, x - 20, y - 20, x + 20, y + 20);
end;

function FindAttackableNpc(color1, color2, color3, tol : integer; npcname : string) : boolean; //finds an npc with the certain colors and name. (makes sure npc isn't already being attacked).
var
rcolor, rnumber, x, y : integer;
begin
result:=false;
rnumber:= random(2);
case rnumber of
0 : rcolor:=color1;
1 : rcolor:=color2;
2 : rcolor:=color3;
end;
if(findcolorspiraltolerance(x, y, rcolor, 218, 118, 282, 186, tol))then
begin
mmouse(x, y, 5, 5);
if(IsFightAt(x, y) = false)and(IsUpText('Attack '+ npcname) = true)then
result := true;
end
Else
if(findcolorspiraltolerance(x, y, rcolor, 9, 9, 511, 333, tol))then
begin
mmouse(x, y, 5, 5);
if(IsFightAt(x, y) = false)and(IsUpText('Attack '+ npcname) = true)then
result := true;
end;
end;

function FindAttackableNpc2(color1, color2, color3, tol : integer) : boolean; //finds an npc with the certain colors and name. (makes sure npc isn't already being attacked).
var
rcolor, rnumber, x, y : integer;
begin
result:=false;
rnumber:= random(2);
case rnumber of
0 : rcolor:=color1;
1 : rcolor:=color2;
2 : rcolor:=color3;
end;
if(findcolorspiraltolerance(x, y, rcolor, 218, 118, 282, 186, tol))then
begin
mmouse(x, y, 5, 5);
if(IsFightAt(x, y) = false)and(IsUpText('At') = true)then
result := true;
end
Else
if(findcolorspiraltolerance(x, y, rcolor, 9, 9, 511, 333, tol))then
begin
mmouse(x, y, 5, 5);
if(IsFightAt(x, y) = false)and(IsUpText('At') = true)then
result := true;
end;
end;

Explanations:

RealEatIfNeeded(foodcolor, eathp : integer; foodlogout : boolean);
- foodcolor is color of food to eat.
- it will only eat if hp is lower then eathp.
- foodlogout, if this is true script will disable char's without food.

Others aren't too hard to figure out FindAttackableNPC just finds an npc to attack, it doesn't click on attack.

Bebe

2006-05-25 21:59:03

Only thing I saw from a brief scan is this:
procedure RealEatIfNeeded(foodcolor, eathp : integer; foodlogout : boolean); //modified from my old autofighter
begin
if(GetHp[B]<= [/B]EatHp)and(FoodColor[B]>= [/B]0)then
begin
if(FindColorSpiraltolerance(x, y, foodcolor, 560, 210, 730, 460, 2) = true)then
begin
MMouse(x + 2, y - 2, 6, 5)
if(IsUpText('Eat') = true)then
begin
GetMousePos(x, y);
mouse(x, y, 3, 2, true);
end;
end
Else
begin
if(FoodLogout = true)then
begin
logout;
Players[CurrentPlayer].Active:= false;
end;
end;
end;
end;

also what is the "GreenStatusColor" found in your procedures/functions?

realrune

2006-05-25 22:04:52

GreenStatusColor is basically the color of the green hp bar. It's the constant used in the srl fighting include part. These are just a few procedures I dug up from my old autofighter and modified so that they may be of some use.

Bebe

2006-05-25 22:08:40

ahah, guess I should look in the skill section more often :p

Ok, they seem good….. Nice work. :)

realrune

2006-05-25 22:19:29

Yeah, I made one lil' mistake though. This should fix it.


procedure RealEatIfNeeded(foodcolor, eathp : integer; foodlogout : boolean); //modified from my old autofighter
begin
if(GetHp<= EatHp)and(FoodColor>= 0)then
begin
GameTab(4);
wait(10 + random(20));
if(FindColorSpiraltolerance(x, y, foodcolor, 560, 210, 730, 460, 2) = true)then
begin
MMouse(x + 2, y - 2, 6, 5)
if(IsUpText('Eat') = true)then
begin
GetMousePos(x, y);
mouse(x, y, 3, 2, true);
end;
end
Else
begin
if(FoodLogout = true)then
begin
logout;
Players[CurrentPlayer].Active:= false;
end;
end;
end;
end;

WhiteShadow

2006-05-25 22:36:28

These look pretty good. Great Job!

Bebe

2006-05-25 22:38:40

You don't need
  if(FindColorSpiraltolerance(x, y, foodcolor, 560, 210, 730, 460, 2) = true)then
you can have it:
  if(FindColorSpiraltolerance(x, y, foodcolor, 560, 210, 730, 460, 2))then


Edit: Added to SRL with modifications by me :)

WhiteShadow

2006-05-25 23:03:14

Does it really matter Bebe? :p