Follower, Follows 1 tile behind leader. I made this because I noticed an issue with trying to follow a target by utilize their coords to move directly to their spot, even with a variance in Accuracy.
procedure MoveTo(Anchor:Cardinal;Distance:Integer;Run:Boolean);
VAR
X,Y : Integer;
begin
if( GetDistance(Anchor)>Distance) then
begin
X:=GetX(Anchor);
Y:=GetY(Anchor);
case GetDirection(Anchor) of
dirNorth : MoveXY(X,Y+1,True,0,Run);
dirNorthEast : MoveXY(X-1,Y+1,True,0,Run);
dirEast : MoveXY(X-1,Y,True,0,Run);
dirSouthEast : MoveXY(X-1,Y-1,True,0,Run);
dirSouth : MoveXY(X,Y-1,True,0,Run);
dirSouthWest : MoveXY(X+1,Y-1,True,0,Run);
dirWest : MoveXY(X+1,Y,True,0,Run);
dirNorthWest : MoveXY(X+1,Y+1,True,0,Run);
end;
ClearBadLocationList;
end;
end;
Example of sub:
MoveTo($Whoever,1,True);
True toggles running on. False would be to walk.