Log in

View Full Version : Why is the constantly looping?



rj
11-28-2012, 09:17 PM
In my script, the bot checks for combat, when the hp bar disapears it starts the looting procedure:
procedure PickUp;
var
X, Y: Integer;
begin
Wait(500 + Random(1200));
WriteLn('Looking for bones...');
if FindColorTolerance(X, Y, loot, 223, 114, 388, 290, 15) then
begin
WriteLn('Found bones!');
MouseSpeed:=40;
mmouse(x, y,1,1);
Wait(120 + Random(80));
ClickMouse(x, y, mouse_Right);
WriteLn('Looking for charm...');
Wait(1100);
FindBitmapToleranceIn(charm, X, Y,161, 86, 420, 252, 95)
MouseSpeed:=40;
mmouse(x, y,1,1);
WriteLn('Found charm!');
Wait(500);
ClickMouse(X, Y, mouse_Left);
Wait(1820 + Random(80));
end;
end;

After its done with this it is supposed to go back to attacking Skeletons but it won't. In a older version the method was:
procedure PickUp;
var
X, Y: Integer;
begin
Wait(1700 + Random(1200));
WriteLn('Looking for bones...');
if FindColorTolerance(X, Y, loot, 223, 114, 388, 290, 15) then
begin
WriteLn('Found bones!');
MouseSpeed:=40;
mmouse(x, y,1,1);
Wait(120 + Random(80));
ClickMouse(x, y, mouse_Right);
end;
WriteLn('Looking for charm...');
Wait(1100);
if FindBitmapToleranceIn(charm, X, Y,161, 86, 420, 252, 85) then
begin
MouseSpeed:=40;
mmouse(x, y,1,1);
WriteLn('Found charm!');
Wait(500);
ClickMouse(X, Y, mouse_Left);
Wait(1820 + Random(80));
end;
end;
But it proved to be to buggy so i re-did it.

footballjds
11-28-2012, 09:22 PM
show us your loop, not the procedure's you call in your loop... lol

rj
11-28-2012, 09:28 PM
// fill out const's
Program autofight;
{$i srl/srl.simba}
const
NPC = 1121869;
loot = 14079706;
tolerence = 12;
time = 1; // in seconds
rwait = 1000;
tleft = 41;
tright = 44;
bleft = 426;
bright = 280;

var
charm: Integer;
Skeleton:TPoint;

procedure PickUp;
var
X, Y: Integer;
begin
Wait(500 + Random(1200));
WriteLn('Looking for bones...');
if FindColorTolerance(X, Y, loot, 223, 114, 388, 290, 15) then
begin
WriteLn('Found bones!');
MouseSpeed:=40;
mmouse(x, y,1,1);
Wait(120 + Random(80));
ClickMouse(x, y, mouse_Right);
WriteLn('Looking for charm...');
Wait(1100);
FindBitmapToleranceIn(charm, X, Y,161, 86, 420, 252, 95)
MouseSpeed:=40;
mmouse(x, y,1,1);
WriteLn('Found charm!');
Wait(500);
ClickMouse(X, Y, mouse_Left);
Wait(1820 + Random(80));
end;
end;

procedure CheckCombat;
var
X, Y: Integer;
begin
if FindColorTolerance(X, Y,49499,241, 115, 291, 179, 17) then
begin
Wait(700 + Random(250));
WriteLn('Waiting to get out of combat . . .');
CheckCombat;
end;
Pickup
end;

procedure ClickNPC;
var
X, Y: Integer;
begin // kill npc
WriteLn('Attacking skeleton...');
if FindColorTolerance(X, Y, NPC, tleft, tright, bleft, bright, tolerence) then
begin
MouseSpeed:=25;
mmouse(x, y,1,1);
Wait(20 + Random(50));
ClickMouse(X, Y, Mouse_Left);
WriteLn('Attacked skeleton!');
Wait(3000 + Random(150));
CheckCombat;
end;
end;

begin
charm := BitmapFromString(44, 12, 'meJzFU9sNgCAMZBD+/XAJR/THXZ' +
'jAtdTYpClH2xQJkfSDXvo4zjMva/4j0ns+t2/7xREsjuNxAvSKyBy' +
'uD+JdBIKSzuMw3iLxo5yMP3cOf6DqB9UnLQdZRjiLSasptWhA o1xn' +
'+QQ4wCt4lBQB+PjCyrTrDhzUD8GCTOJg+UGudtxu6TzIAWj4t mxNB' +
'bIArkoHnsz1P57qY9GwalRcTWXZDd+RiMw=');
repeat
ClearDebug;
ClickNPC;
until False;
FreeBitmap(charm);
end.

CRASH_OVERRIDE
12-01-2012, 11:10 PM
Im not 100% sure why it isn't working im only new here...

But i do suggest adding a procedure that actually enables/opens the HP bar, if your ever going to release it.

I notice your adding the next procedure in the procedures:/ Anyways:

*in ClickNPC it attacks the skeleton and then does CheckCombat;.
*in CheckCombat it waits until its out of combat and then you tell it to CheckCombat; again? Maybe remove this? or add a repeat instead... and instead of having "Pickup" change it to "Pickup;" I believe thats the issue?