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
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;