Cstrike
2010-12-01 13:32:58
Here's two functions side-by-side
Problems with Walkpath:
- No customization
- Limited to a randomness of 1 (detectable)
- Runs an infinite loop if you get stuck (yes this has happened to me multiple times
Some of these are solved, with big parameter names.
Do you think this would be a good implementation? WalkPath works great most (to all) of the time.
{*******************************************************************************
function WalkPath(Tiles: TTileArray): boolean;
By: Drags111
Description: Walks the tile path. Looks like an ugly function, but it works
Beautifully.
*******************************************************************************}
function WalkPath(Tiles: TTileArray): boolean;
var
i, t, attempts: integer;
P: TPoint;
next: boolean;
label
ProcStart;
begin
Inc(attempts);
ProcStart:
i := -1;
Result := false;
if(DistanceFrom(Tiles[High(Tiles)]) < 6)then
begin
Result := true;
Exit;
end;
//Getting the starting index.
for i := High(Tiles) downto 0 do
if(TileOnMM(Tiles[i]))then
begin
i := i;
Break;
end;
if(i = -1)then
Exit;
//Walk remainder of the path.
for i := i to High(Tiles) do
begin
next := false;
if not(TileOnMM(Tiles[i]))then
begin
Writeln('Tile not on MM.');
break;
end;
P := TileToMM(Tiles[i]);
Mouse(P.x, P.y, 1, 1, true);
while(DistanceFromFlag <> 0)do
begin
if not WaitToMove(3000)then
begin
MarkTime(t);
while(TimeFromMark(t) < 7000)do
if(WaitToMove(1000))then break;
if(TimeFromMark(t) >= 7000)then
begin
Writeln('***Didn''t move for 10 seconds. Exiting***');
next := false;
break;
end;
end;
if(i < High(Tiles))then
begin
if(TileOnMM(Tiles[i+1]))then
begin
next := true;
break;
end;
end;
end;
if(i < High(Tiles))then
if(TileOnMM(Tiles[i+1]))then
next := true;
if not next then
break;
end;
Result := DistanceFrom(Tiles[High(Tiles)]) <= 5;
if not Result then
begin
if(attempts > 7)then
begin
Writeln('Failed more than ten attempts.');
Exit;
end;
While(GetSpeed > 0)do wait(100+Random(100));
goto ProcStart;
end;
While(GetSpeed > 0)do wait(100+Random(100));
end;
{*******************************************************************************
function R_WalkPathEx(Tiles: TTileArray; MouseRandomness, TimeoutMs, AcceptableDistanceFromLastTile: Integer; ExitIfTimeout : Boolean): Boolean;
By: Drags111/Cstrike
Description: Walks the tile path. Looks like an ugly function, but it works
Beautifully. Modded by Cstrike to be less bannable/no infinite loops. Also added
prevention from crashing if you enter a high = 0 TTA. If we're <= AcceptableDist
FromLastTile then function returns true
*******************************************************************************}
function R_WalkPathEx(Tiles: TTileArray; MouseRandomness, TimeoutMs, AcceptableDistanceFromLastTile: Integer; ExitIfTimeout : Boolean): Boolean;
var
i, t, attempts: integer;
P: TPoint;
next: boolean;
label
ProcStart;
begin
Inc(attempts);
ProcStart:
i := -1;
Result := false;
if high(Tiles) < 0 then
begin
Writeln ('[Reflection] Empty tile array, exiting R_WalkPath');
Exit;
end;
if(DistanceFrom(Tiles[High(Tiles)]) <= AcceptableDistanceFromLastTile)then
begin
Result := true;
Exit;
end;
//Getting the starting index.
for i := High(Tiles) downto 0 do
if(TileOnMM(Tiles[i]))then
begin
i := i;
Break;
end;
if(i = -1)then
Exit;
//Walk remainder of the path.
for i := i to High(Tiles) do
begin
next := false;
if not(TileOnMM(Tiles[i]))then
begin
Writeln('[Reflection] Tile not on MM.');
break;
end;
P := TileToMM(Tiles[i]);
Mouse(P.x, P.y, MouseRandomness, MouseRandomness, true);
while(DistanceFromFlag <> 0)do
begin
if not WaitToMove(3000)then
begin
MarkTime(t);
while(TimeFromMark(t) < 7000)do
if(WaitToMove(1000))then break;
if(TimeFromMark(t) >= 7000)then
begin
Writeln('[Reflection] Warning: Didn''t move for '+ToStr(TimeoutMs));
next := false;
if ExitIfTimeout then
begin
Writeln ('[Reflection] Exiting path walking procedure');
Exit;
end;
break;
end;
end;
if(i < High(Tiles))then
begin
if(TileOnMM(Tiles[i+1]))then
begin
next := true;
break;
end;
end;
end;
if(i < High(Tiles))then
if(TileOnMM(Tiles[i+1]))then
next := true;
if not next then
break;
end;
Result := DistanceFrom(Tiles[High(Tiles)]) <= AcceptableDistanceFromLastTile;
if not Result then
begin
if(attempts > 7)then
begin
Writeln('Failed more than ten attempts.');
Exit;
end;
While(GetSpeed > 0)do wait(100+Random(100));
goto ProcStart;
end;
While(GetSpeed > 0)do wait(100+Random(100));
end; Problems with Walkpath:
- No customization
- Limited to a randomness of 1 (detectable)
- Runs an infinite loop if you get stuck (yes this has happened to me multiple times
Some of these are solved, with big parameter names.
Do you think this would be a good implementation? WalkPath works great most (to all) of the time.