Log in

View Full Version : Distance Help.



P1nky
01-20-2012, 12:02 AM
I would want to like to learn how to make my character get back to the path, just in case it goes out of track.

Such as the Void Knight in Pest Control, if my character starts running after a monster but totally away from the Knight, how would I get it to find out that?

I kinda remember how I did it in Reflection using the Tile system.

PatDuffy
01-20-2012, 12:05 AM
If there is a specific color on the minimap you could find the color then if the distance is so far away in pixels make it walk back.

I would scribble up some code but I'm on my phone.

P1nky
01-20-2012, 12:11 AM
If there is a specific color on the minimap you could find the color then if the distance is so far away in pixels make it walk back.

I would scribble up some code but I'm on my phone.

Can't I do something like this, I am just spitting out something so y'all can get the idea.

if VoidKnight < 20 then // "20" = distance
Begin
WalkBack;
end;

KingKong
01-20-2012, 12:53 AM
Can't I do something like this, I am just spitting out something so y'all can get the idea.

if VoidKnight < 20 then // "20" = distance
Begin
WalkBack;
end;

Yes, as long as the function 'VoidKnight' is something along the lines of what Pat said.

P1nky
02-16-2012, 05:33 AM
Yes, as long as the function 'VoidKnight' is something along the lines of what Pat said.

What if it's a DDTM?

Runaway
02-16-2012, 06:00 AM
Would something like this work?


var
MoveX, MoveY: array of integer;
TotalMoves, DistMoved: integer;

function MeasureFlagPath: Boolean;
var
bx, by, MMFlag: integer;
begin
If not LoggedIn then Exit;
MMFlag := BitmapFromString(3, 3, 'meJzjZv/ExXDRTFQFSHIxbAUyOBmKgSQQAQBYRQWy');
if FindBitmapToleranceIn(MMFlag, bx, by, MMX1, MMY1, MMX2, MMY2, 1) then
begin
DistMoved := Abs(Sqr(((bx-MMCX)*2)+(((by-MMCY)*2)-6)))
if (DistMoved > 5) then
begin
Inc(TotalMoves);
SetArrayLength(MoveX, (TotalMoves + 1));
SetArrayLength(MoveY, (TotalMoves + 1));
MoveX[TotalMoves] := (bx - MMCX)
MoveY[TotalMoves] := ((by - MMCY) - 6)
Result := True;
end;
end;
FreeBitmap(MMFlag);
end;


Then to return to the original position you just sum the MoveX and MoveY arrays, give them a negative value, and click at the coordinate that far from the center of the MM.

It's a tad primitive but I think it might be able to get the job done.