n3ss3s
2008-05-02 04:24:59
Well iBot's worldMap.walkTo came into my mind and I did something small a bit similar, it should work in theory:
Needs SRL…
Procedure RandomizePath(Var Path: TPointArray; MaxOffset: Integer);
Var
I: Integer;
Begin
For I := 0 To High(Path) Do
Begin
Path[i].x := Path[i].x - MaxOffset + Random(MaxOffset * 2);
Path[i].y := Path[i].y - MaxOffset + Random(MaxOffset * 2);
End;
End;
Function WalkTile(TileX, TileY: Integer): Boolean;
Var
X, Y: Integer;
Begin
TileToMinimap(TileX, TileY, X, Y);
If InCircle(X, Y, MMCX, MMCY, 74) Then
Begin
MFNF(X, Y, 2, 2);
FFlag(8);
Result := True;
Wait(25);
End;
End;
Function WalkToWorldTile(TileX, TileY, xMod, yMod: Integer): Boolean;
Var
TPA: TPointArray;
X, Y: Integer;
Begin
GetMyPos(X, Y);
TPA := MidPoints([X, Y, TileX, TileY], 50 + Random(10));
RandomizePath(TPA, (xMod + yMod) / 2);
For I := 0 To High(TPA) Do
If Not WalkTile(TPA[i].x, TPA[i].y) Then Exit;
Result := True;
End;
Needs SRL…