SRL Archive - SRL Suggestions

Run in a direction


EtherFreak

2012-11-05 18:36:45

So a while back, I was having issues with radial walk, and SPS was down/not functioning. and I wanted to walk/run somewhere. The closest that srl had was the radial walk, but that still required a color. I wanted to be able to walk north, and did not care about colors, but just wanted to walk north, of a known radius. I threw the following together, and figured I would share it here, as it could be incorporated, and would be great for those times that you just wanted to walk in a direction.

//from SRL RunAway
//reused by etherfreak
//runs in a specified direction and a specified distance. direction is 0-360 degrees, with 0 being N
//rads is the radius from the character. try to keep this between 20-70.
//also, no randoms incorperated, so use your own randoms!
procedure RunDir(dir: variant; Rads: Integer);
var
Deg: extended;
begin
if (not LoggedIn) then exit;
Deg := variantToDirection(dir);
Deg := Deg + Random(2);
SetRun(True);
MFNF(Trunc(Rads * Sin(Radians(FixD(Rs_GetCompassAngleDegrees + Deg))) + MMCX + Random(5)),
Trunc(-Rads * Cos(Radians(FixD(Rs_GetCompassAngleDegrees + Deg))) + MMCY + Random(5)), 1, 1);
FFlag(0);
Wait(500 + Random(1500));
end;



Edit
As an afterthough, we could add an option to runaway that would not enable disable the run option and achive the same result…

Rezozo

2012-11-05 18:38:41

This could come in handy!

Nice work!

DaWu

2012-11-06 01:24:22

I could swear there was something like this in SRL. Something that was used way back with the old random events that simply attacked you and you had to run away.

E:

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

Mapwalking.simba

Olly

2012-11-06 15:54:08

From: DaWu
I could swear there was something like this in SRL. Something that was used way back with the old random events that simply attacked you and you had to run away.


//from SRL RunAway
//reused by etherfreak

guessing he used that as a base.

DaWu

2012-11-06 16:25:58

From: Ollybest
//from SRL RunAway
//reused by etherfreak

guessing he used that as a base.


Totally missed that.

EtherFreak

2012-11-06 18:24:55

The problem with srl runaway is that it clicks the run enable, runs, then clicks the run disable. thus it is not very good for a walking/running substitute. I suppose I could just add to the srl runaway an option to not keep enabling/disabling run…but you would not be able to specify the radius you wanted.