SRL Archive - Help

Distance Help.


P1nky

2012-01-19 19:02:54

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

2012-01-19 19:05:24

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

2012-01-19 19:11:27

From: PatDuffy
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

2012-01-19 19:53:45

From: P1nky
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

2012-02-16 00:33:32

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


What if it's a DDTM?

Runaway

2012-02-16 01:00:35

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.