SRL Archive - SRL Archives

Some walking stuff...


Wanted

2008-07-27 11:42:08

Pretty basic, but eh, it's somewhat useful for getting rid of repetitive coding and such…

The Boolean result on function WalkTo is resulted true if a flag is found at any point during the function.

{*******************************************************************************
function DFFlag(Distance: Integer): Boolean;
By: IceFire908.
Description: Same as FFlag but waits until flag is present before waiting.
*******************************************************************************}

function DFFlag(Distance: Integer): Boolean;
var
T: LongInt;
begin
MarkTime(T);
while (not ((FlagPresent) or ((TimeFromMark(T)) >= (RandomRange(5000, 7000))))) do
Wait(RandomRange(100, 200));
Result := FFlag(Distance);
end;

{*******************************************************************************
function OnMM(Point: TPoint): Boolean;
By: IceFire908.
Description: Checks if a point is on the mini-map.
*******************************************************************************}

function OnMM(Point: TPoint): Boolean;
begin
Result := InCircle(Point.X, Point.Y, MMCX, MMCY, 73);
end;

{*******************************************************************************
function OnMS(Point: TPoint): Boolean;
By: IceFire908.
Description: Checks if a point is on the main-screen.
*******************************************************************************}

function OnMS(Point: TPoint): Boolean;
begin
Result := PointInBox(Point, IntToBox(MSX1, MSY1, MSX2, MSY2));
end;

{*******************************************************************************
function WalkTo(Point: TPoint): Boolean;
By: IceFire908.
Description: All purpose walking.
*******************************************************************************}

function WalkTo(Point: TPoint): Boolean;
begin
if ((OnMS(Point)) or (OnMM(Point))) then
begin
if (OnMM(Point)) then
Mouse(Point.X, Point.Y, 0, 0, True)
else
begin
Mouse(Point.X, Point.Y, 4, 4, False);
Wait(RandomRange(500, 800));
ChooseOption('alk');
end;
Result := DFFlag(RandomRange(5, 15));
end
else
WriteLn('That point is not on the mini-map or main-screen!');
end;

Wizzup?

2008-07-27 18:37:53

OnMM - rs_OnMiniMap

 
function DFFlag(Distance: Integer): Boolean;
var
T: LongInt;
begin
MarkTime(T);
while (not ((FlagPresent) or ((TimeFromMark(T)) >= (RandomRange(5000, 7000))))) do
Wait(RandomRange(100, 200));
Result := FFlag(Distance);
end;

RandomRange? It doesn't work that way I am afraid, it will very rarely reach the 7000. You do a RandomRange every time you go to the loop.
Get the int once, then use it for the statement in the while.

Wanted

2008-07-27 19:26:45

From: Wizzup?
OnMM - rs_OnMiniMap

 
function DFFlag(Distance: Integer): Boolean;
var
T: LongInt;
begin
MarkTime(T);
while (not ((FlagPresent) or ((TimeFromMark(T)) >= (RandomRange(5000, 7000))))) do
Wait(RandomRange(100, 200));
Result := FFlag(Distance);
end;

RandomRange? It doesn't work that way I am afraid, it will very rarely reach the 7000. You do a RandomRange every time you go to the loop.
Get the int once, then use it for the statement in the while.


Yea I know the result of the function changes every loop but I thought about doing that but then I realized how much It doesn't really matter exactly how long it takes as long as it is somewhat random, I guess if you wanted to:

function DFFlag(Distance: Integer): Boolean;
var
T, MaxWait: LongInt;
begin
MaxWait := RandomRange(5000, 7000);
MarkTime(T);
while (not ((FlagPresent) or ((TimeFromMark(T)) >= MaxWait))) do
Wait(RandomRange(100, 200));
Result := FFlag(Distance);
end;

I didn't feel the need for the extra code though since I already got what I wanted for the most part.

The main purpose of those functions is to support an all purpose standard Walking procedure aka WalkTo.