Simba Code:
(*
RunAway
~~~~~~~
.. code-block:: pascal
procedure RunAway(dir: string; RunFar: Boolean; Action, WaitTime: Integer);
- Runs away in minimap related direction, based on north.
- Dir can be 'N', 'E', 'S', 'W' or an angle in degrees (145, 93, 180, etc).
- RunFar will run further than normal.
- Action can be either 1, 2 or 3:
1. RunAway + Wait(WaitTime) + RunBack
2. RunAway + Wait(WaitTime)
3. RunBack
.. note::
WaitTime is in milliseconds!
.. note::
by nielsie95 modified by ZephyrsFury
Example:
.. code-block:: pascal
if (FindFight()) then
begin
WriteLn('We are in a fight!');
RunAway('n', True, 1, 2000);
end;
*)
// TODO: Implement constants!
procedure RunAway(dir: variant; RunFar: Boolean; Action, WaitTime: Integer);
var
Rad, T: Integer;
Deg: extended;
begin
if (not LoggedIn) then exit;
if RunFar then
Rad := 63
else
Rad := 30;
Deg := variantToDirection(dir);
if (Action < 3) then
begin
SetRun(True);
MFNF(Trunc(Rad * Sin(Radians(FixD(Rs_GetCompassAngleDegrees + Deg))) + MMCX + Random(5)),
Trunc(-Rad * Cos(Radians(FixD(Rs_GetCompassAngleDegrees + Deg))) + MMCY + Random(5)), 1, 1);
FFlag(0);
Wait(500 + Random(1500));
t := GetSystemTime;
while ((GetSystemTime - t) < WaitTime) and (LoggedIn) do
if (Random(5) = 0) then
IdleTime(2000, 500, 1.0)
else
Wait((WaitTime - (GetSystemTime - t)) div 5);
end;
if (Action = 1) or (Action = 3) then
begin
MFNF(Trunc(Rad * Sin(Radians(FixD(Rs_GetCompassAngleDegrees + (Deg + 180)))) + MMCX - Random(5)),
Trunc(-Rad * Cos(Radians(FixD(Rs_GetCompassAngleDegrees + (Deg + 180)))) + MMCY - Random(5)), 1, 1);
FFlag(0);
Wait(500 + Random(1500));
end;
SetRun(False);
end;