blackfire553
2011-06-15 16:50:41
Should i try to avoid recursive calls? I could break this code up into several procedures but it works fine with recursion.
edit: i am going to add some way for it to log out after it fails enough times so it doesnt loop for 24.5 years
procedure GetFight;
var
NPC : TNPC;
NPCPoint : TPoint;
i,j,tries,checkFight : integer;
begin
if not (LoggedIn) then
Exit;
if FindNPC(Players[0].Strings[0],NPC) = false then
begin
writeln('no mobs');
wait(3000);
GetFight;
Exit;
end;
If (NPC.Interacting = -1) then
begin
NPCPoint := TileToMS(NPC.Tile,NPC.Height*3/4);
if (NPCPoint.x <> -1) then
begin
Mouse(NPCPoint.x,NPCPoint.y,3,3,false);
ChooseOption('ttack');
writeln(IntToStr(NPCPoint.x) + ' ' + IntToStr(NPCPoint.y));
writeln(IntToStr(NPC.ID));
writeln(NPC.Name);
wait(3000);
Me := GetMe;
if (Me.Interacting <> -1) then
begin
writeln('Got a fight');
Exit;
end;
GetFight;
Exit;
end;
end;
end; edit: i am going to add some way for it to log out after it fails enough times so it doesnt loop for 24.5 years