Originally Posted by
Helvetin16
What should I do? I created object, but it is moving so the script missclicks a lot on him. Is there a way to make the script wait untill the npc has stopped moving? Or make the clicks more accurate?
Code:
program new;
//{$DEFINE SMART}
{$i AeroLib/AeroLib.Simba}
var
Guy: TMSObject;
Procedure PlayerSetup;
begin
Me.Active := True;
Me.Name := '';
Me.Pass := '';
Me.Member := True;
Guy.create('Talk', ['-to'], [createCol(2106205, 12, 0.09, 0.33)], 50, 0, 0, 0);
end;
Procedure FindGuy;
var
pnt:tpoint;
begin
if Guy.Find(pnt) then
FastClick(Mouse_left);
end;
begin
initAL;
PlayerSetup;
FindGuy;
end.
GIve this code a try. I have added an explanation to each line. Is untested so not sure if it will work xD
Simba Code:
program new;
{$i AeroLib/AeroLib.Simba}
var
Guy:TMSObject;
function FindTheGuy:boolean;
var
pnts:TpointArray;
i, Col, x, y:integer;
label TryAgain; //Creates a label so we can navigate back to a point if required.
begin
TryAgain: //Is the label that we navigate back to if our NPC is moving so we can try again.
Result := false; // Sets the function result to false, so if we cannot find the NPC it returns false.
if Guy.findAll(10, MSCP, pnts) then //Trying to find all Guy(s) and store them in a TPointArray.
for i := 0 to high(pnts) do //Begin the loop through the Guy(s)
begin
Col := GetColor(pnts[i].x, pnts[i].y); //gets the color of the guy we are looking at.
wait(randomrange(400, 600)); //waits a short period of time.
if FindColor(x, y, Col, pnts[i].x - 3, pnts[i].y - 3, pnts[i].x + 3, pnts[i].y + 3) then //Checks to see if that same color is still found at the co-ordinates (6x6 box)
begin
MissMouse(pnts[i], 3, 3); // If the color was still found, it means the object isnt moving so we now attempt to click.
if WaitUpTextMulti(Guy.UpText, 500) then //wait for the uptext to match.
begin
FastClick(MOUSE_LEFT); //Click him then exit the function, returning a true boolean.
exit(true);
end;
end else
GoTo TryAgain; //The color was no longer found at the co-ordinates, meaning our object had moved, so it tells the script to go back to our label we declared at the beginning of the function.
end;
end;
begin
InitAL;
Guy.create('Talk', ['-to'], [createCol(2106205, 12, 0.09, 0.33)], 50, 0, 0, 0);
if FindTheGuy then
writeln('Found and clicked the guy!');
end.