SRL Archive - Reflection Development

PathWalking Functions


Metagen

2008-08-31 20:03:10

Here are some functions from my private flesh killer script for walking, cheers.

The concept i thought of is instead of making a point for every dot you want to walk to, just make 50 dots to walk the area of about 10 :D. So using 50 dots it will pick a good next dot out of the bunch and walk to that dot :p so its more like walking a reflection line



// Finds the closest tile in the in the array of tiles to the player
Function FindClosestTile(TPA : TPointArray) : Integer;
var i, Dist, MinDist, MinIndex : Integer;
MyPos : TPoint;
begin
MinDist := 65535;
MyPos := GetMyPos
for i := 0 to high(TPA) do
begin
Dist := Distance(TPA[i].x, TPA[i].y, MyPos.x, MyPos.y);
if Dist < MinDist then
begin
MinIndex := i;
MinDist := Dist;
end;
end;
result := MinIndex;
Writeln('Closest Tile Is: ' + IntToStr(Result));
end;

//Returns in a TPoint:
//x as: The tile the player is closest to
//y as: The last tile in the array that can be sequentially seen.
Function TileRange(TPA : TPointArray) : TPoint;
var CTile, i : Integer;
MyPos : Integer;
begin
CTile := FindClosestTile(TPA);
result.x := CTile;
for i := CTile to high(TPA) do
begin
if not TileOnMM(TPA[i]) then
begin
if i = CTile then
begin
Writeln('Could Not Find The Path');
Logout;
Exit;
end;
result.y := Max(i-1, Result.x);
WriteLn('TileRange is: ' + inttostr(result.x) + ', ' + IntToStr(result.y));
exit;
end;
end;
WriteLn('Can See All Remaining Points');
result.y := High(TPA);
WriteLn('TileRange is: ' + inttostr(result.x) + ', ' + IntToStr(result.y));
end;


// Picks a good human-like next point in the array to walk to and returns
// the array index
Function GenerateNextPathPoint(TPA : TPointArray) : Integer;
var PathRange : TPoint;
Variance : Integer;
begin
PathRange := TileRange(TPA);
Variance := (((PathRange.y - PathRange.x)) / 4);
WriteLn('Variance Is: ' + IntToStr(Variance));
Result := PathRange.y - ((PathRange.y - PathRange.x)/4) - Random(Variance);
Writeln('Next Path Point: ' + IntToStr(Result));
end;


// an example of an implimentation :D
Procedure WalkPath(ToBank: Boolean);
var Path : TPointArray;
MyPos, MMTile : TPoint;
NextStep, i : Integer;
begin
Writeln('Begining Path Walk');
wait(2000);
Path := LoadBankPath; //LoadBankPath would be a function that returns the path in a TPA
if not ToBank then InvertTPA(Path);
Repeat
NextStep := GenerateNextPathPoint(Path);
MMTile := TileToMM(Path[NextStep]);
Mouse(MMTile.x, MMTile.y, 5, 5, true);
FFlag(random(4)*random(4));
i := i + 1;
Until (i > 20) or (not LoggedIn) or (NextStep = High(Path))
end;


Scaper

2008-08-31 20:10:04

wow very nice dude good thinking

Rubix

2008-08-31 20:56:59

i got lost on line 5 :D

Bobarkinator

2008-08-31 21:32:00

From: Rubix
i got lost on line 5 :D


*looks at line 5*

var i, Dist, MinDist, MinIndex : Integer;

You got lost on that? :p

MylesMadness

2008-09-01 10:55:12

From: your sig
Reflection Sucks. Don't use it unless you're dumb. - Dan's The Man
But still you make a refection thing.

Metagen

2008-09-02 07:36:13

That's dans sig :D

- and maybe im dumb :D

Nava2

2008-09-02 17:07:56

YOU TOLD ME REFLECTION BLOWS!

Btw, I created a similar function, but mine doesnt work yet. :(

Metagen

2008-09-02 23:13:22

I just wanted a headstart on you! JK :p. Well i mean, i might as well get with the cool stuff, and theres development to be done here! so why not pitch in!