Jump to content
Bixby Sayz

Detect if character has moved

Recommended Posts

Got my flax picker/spinner working pretty flawlessly now (except for a huge wrinkle with trial members, but that is a story for another day).

 

But it could be better. When it finds a flax plant it continues to pick that plant until it is gone (to avoid the slowdown of searching for every pick). Which works fine except when the act of picking that plant for the first time causes the character to move to the plant. In this case my coords to click are now off by however many pixels the character moved.

 

Not a big deal. The script will realize this and simply search again once it fails to pick. But it would be nice to figure out if/how much exactly the character has moved to adjust the mouse coords.

Link to comment
Share on other sites

function follow(var x, y: Integer): Boolean;
var
 TPA: TPointArray;
 bounds: TBox;
 t: Integer;
begin
 result := False;

 SetColorToleranceSpeed(2);
 SetToleranceSpeed2Modifiers(HUE, SAT);

 t := GetSystemTime;
 while GetSystemTime - t < 1000 do
 begin
   if GetSystemTime - t > 500 then
     //IF DETECT PIXEL CHANGE AROUND THE CHAR MINIMAP
       t := GetSystemTime;

   bounds := constrainBounds(IntToBox(x - 15, y - 15, x + 15, y + 15));
   with bounds do
     FindColorsSpiralTolerance(x, y, TPA, COLOR, x1, y1, x2, y2, 0);
   if Length(TPA) > 0 then
     MiddleTPAEx(TPA, x, y)
   else
   begin
     SetColorToleranceSpeed(1);
     Exit;
   end;
 end;

 result := Distance(x, y, MSCX, MSCY) < 60;

 SetColorToleranceSpeed(1);
end; 

 

Something like this may work if your search box is small enough...will have to test it out

Link to comment
Share on other sites

Something like this may work if your search box is small enough...will have to test it out
I'll give it a go. Was thinking along the lines of something like this. The tricky part is figuring out what to track. The nearby flax plants can disappear if others are picking, the npcs move around, the fence can be obscured by others walking by, and your character itself can be obscured by those damn npcs bopping around.

 

Have you tried using SPS in the GMRL include? It can determine your char position within a few pixels. When I ported all the functions over, I did alot of testing and was pretty amazed how accurate it was 98% of the time.

 

Give it a whirl

I was thinking of adding SPS later as an optional walking method.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...