Log in

View Full Version : Function that isn't looping Please help.



Nemesis3X
02-23-2012, 04:30 AM
Hello Everyone, so I got a new Fresh Working Script, but it got only one problem that I am going to Explain and Need Help to Fix since I can't figure out How to Fix it. Basicaly, I am Walking to Zamorak the Mage to Teleport To Abyss. This NPC Move a Lot and My First Problem was that sometime, when I was Reaching him, He wasn't in my Screen and The function was Ignored, so I was Stuck. I came with the Idea to make My character move if it doesn't find any array, but if I get a Miss Click after Moving, The function won't loop and Try again to Click and Teleport to Abyss Even When I have my FailSafe to Force Repeating it until my FailSafe is no more visible on Minimap. Can someone Tell me What's going wrong in My Code, Thanks

Procedure MovingToFindMage;
var WhereToClick : integer;
begin
case random(2) of
0 : WhereToClick := 1;
1 : WhereToClick := 2;
end
if (WhereToClick = 1) then
begin
if FindDTMRotated(Path6, x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
Mouse(x, y, 3, 3, True);
FFlag(6);
Wait(2000 + random(1000));
end;
end;

if (WhereToClick = 2) then
begin
if FindDTMRotated(Path7, x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
Mouse(x, y, 3, 3, True);
FFlag(6);
Wait(2000 + random(1000));
end;
end;
end;

function TalkingToMages: boolean; // 2
var
MyTPA : TPointArray;
MyPoint : TPoint;
x, y, i, Tries: Integer;
begin
x := MSCx;
y := MSCy;
FindColorsSpiralTolerance(x, y, MyTPA, 2304113, MSx1, MSy1, MSx2, MSy2, 18);
if Length(MyTPA) = 0 then FindColorsSpiralTolerance(MSCx, MSCy, MyTPA, 1185082, MSX1, MSY1, MSX2, MSY2, 13);
for i := 0 to High(MyTPA) do
begin
inc(Tries);
Writeln('Trying to find Mage');
MyPoint := MyTPA[i]
MMouse (MyPoint.x, MyPoint.y, 0, 0);
if (IsUpTextMultiCustom(['alk', 'orak'])) then
begin
GetMousePos(x, y);
mouse(x,y,0,0,false);
wait(300 + random(250));
ChooseOption('ele');
wait(5000 + random(1000));
FindNormalRandoms;
Result := true;
break;
end;
if (Tries = 5) then
begin
Writeln('We are Not Inside');
MovingToFindMage;
TalkingToMages;
end;
Wait(100 + random(50));
end;
end;

Procedure TalkToMages;
begin
TalkingToMages;
if FindDTMRotated(FailSafe, x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
Writeln('We are not inside');
MovingToFindMage;
TalkingToMages;
end;
end;

Caotom
02-23-2012, 05:18 AM
I take it that your miss click is due to you moving while the bot is trying to click.
You could possibly try somehting on the lines of
While IsMoving do
Wait(50);

You could also try allowing it to loop a couple of times before triggering the failsafe.

~Caotom

Ashaman88
02-23-2012, 05:22 AM
When you say misclicks, do you mean when it tries to right click the mage it misses him and clicks somewhere else? If thats the case you could just turn that choose option 'ele' into an if statement and it it doesn't exist (ie misclicked) it would start movingtofindmage and talkingtomages again. If you need example simba code I can do that

Nemesis3X
02-23-2012, 12:09 PM
No, it was not that caotom, but Thanks ashaman88, since it is working now. I never though about making a If statement with a ChoseOption. I was thinking about a solution that was way harder than that to archive,but you did simplified My life :-)

Ashaman88
02-23-2012, 03:30 PM
No, it was not that caotom, but Thanks ashaman88, since it is working now. I never though about making a If statement with a ChoseOption. I was thinking about a solution that was way harder than that to archive,but you did simplified My life :-)

You're welcome! I only came across that solution awhile ago myself from someone else's script. Looking at other people's scripts really gives you ideas on better ways to do your functions!