SRL Archive - Reflection Development

MMWalk.scar


Sir R. M8gic1an

2009-04-01 08:25:52


{*******************************************************************************
function R_FlagDistance: integer;
By: Rasta Magician
Description: Returns the distance of the flag
*******************************************************************************}
Function R_FlagDistance: integer;
var F, M : TPoint;
begin
GetFlag(F);
M := GetMyPos;
Result := Round(Sqrt(Sqr(F.x - M.x) + Sqr(F.y - M.y)) *4);
end;


{*******************************************************************************
function R_FlagStuck: boolean;
By: Rasta Magician
Description: Returns true if the flag is stuck on unwalkable territory
*******************************************************************************}
Function R_FlagStuck: boolean;
var
dist, Time: integer;
P : TPoint;
begin
dist := R_FlagDistance;

if dist <= 0 then
begin
Result := false;
exit;
end;

Time := GetSystemTime;
while (GetSystemTime - Time < 10000) do
if R_FlagDistance <> dist then
begin
Result := false;
break;
end;

if FlagDistance = dist then
Result := true;
end;

{*******************************************************************************
procedure R_FFlag(Distance: Integer);
By: ZephyrsFury
Description: Similar to the original except it uses Reflection.
*******************************************************************************}
procedure R_FFlag(Dist: Integer);

var
Tx, Ty, m, d1, d2: Integer;
P, D: TPoint;

begin
while (GetFlag(D)) do
begin
P := GetMyPos;
d1 := Round(Sqrt(Sqr(D.x - P.x) + Sqr(D.y - P.y)) * 4);
if (d1 > Dist) then
begin
Inc(m);
Wait(100);

if SRL_Procs[SRL_AntiBan] <> nil then
SRL_Procs[SRL_AntiBan]();

if (Random(100) = 0) then IdleTime(500, 1000, 0.01);

if (m mod 100 = 0) then

if (d1 = d2) then
begin
if (FindColor(Tx, Ty, 255, MMX1, MMY1, MMX2, MMY2)) then
Mouse(Tx, Ty + 14, 0, 0, True)
else
Mouse(MMCX, MMCY, 0, 0, True);
if FlagStuck then break;
end else d2 := d1;
end else Break;
end;
end;


to avoid a flag stuck in an unwalkable place.

i'm not sure about that *4 in R_FlagDistance, but i saw zephyr had it in R_FFlag so i just assumed it's some side of reflection i don't know about :p


~RM

ZephyrsFury

2009-04-01 08:51:26

From: Rasta Magician
i'm not sure about that *4 in R_FlagDistance, but i saw zephyr had it in R_FFlag so i just assumed it's some side of reflection i don't know about :p


Each tile is 4x4 pixels.

Nava2

2009-04-01 09:08:24

There is a IsWalkableTile in the hooks.

If someone reminds me, I can look into it tonight. By the way, change the P := GetMyPos to M := GetMyPos. ;)