Results 1 to 6 of 6

Thread: Run in a direction

  1. #1
    Join Date
    Jul 2010
    Location
    Western US
    Posts
    387
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default Run in a direction

    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.

    Simba Code:
    //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...
    Last edited by EtherFreak; 11-05-2012 at 11:40 PM.
    Of all the things I have lost, I miss my mind the most.
    Current Projects:
    Addy bar miner and superheater

  2. #2
    Join Date
    Dec 2011
    Location
    Nj
    Posts
    2,341
    Mentioned
    1 Post(s)
    Quoted
    18 Post(s)

    Default

    This could come in handy!

    Nice work!

    For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip

  3. #3
    Join Date
    Oct 2006
    Location
    Finland
    Posts
    433
    Mentioned
    1 Post(s)
    Quoted
    8 Post(s)

    Default

    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:

    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;

    Mapwalking.simba

  4. #4
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by DaWu View Post
    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.
    Last edited by Olly; 11-06-2012 at 08:57 PM.

  5. #5
    Join Date
    Oct 2006
    Location
    Finland
    Posts
    433
    Mentioned
    1 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by Ollybest View Post
    //from SRL RunAway
    //reused by etherfreak

    guessing he used that as a base.
    Totally missed that.

  6. #6
    Join Date
    Jul 2010
    Location
    Western US
    Posts
    387
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    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.
    Of all the things I have lost, I miss my mind the most.
    Current Projects:
    Addy bar miner and superheater

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •