Results 1 to 15 of 15

Thread: SetupPlayer instead of MakeCompass/SetRun/

  1. #1
    Join Date
    May 2007
    Location
    Everywhere
    Posts
    1,428
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default SetupPlayer instead of MakeCompass/SetRun/

    Simba Code:
    procedure SetupPlayer (Angle: Boolean; CompassDirection: TVariant; Run: Boolean);
    begin
      SetAngle(Angle);
      MakeCompass (CompassDirection);
      SetRun(Run);
    end;

    Is there a function for what I've proposed above? I seem to be on a hot-streak for recommending existent things
    Doesn't quite have to be called this and can be fail-safed of course.
    Also, I do agree that this is uber minor. No need to remind me
    Last edited by Cstrike; 11-30-2010 at 02:48 AM.

  2. #2
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    This would save some time, and ease the setup. I say yes for this.
    There used to be something meaningful here.

  3. #3
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    I don't see a use for it, honestly.

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  4. #4
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    No reason to add this to SRL, imo. Just have it in your script if you so please; things like this will eventually lead to "CookFish;" in SRL. :/

  5. #5
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    No reason to add this to SRL, imo. Just have it in your script if you so please; things like this will eventually lead to "CookFish;" in SRL. :/
    IMO totally different situation, this isnt skill specific.
    There used to be something meaningful here.

  6. #6
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    The idea is the same though.. package a bundle of different things to one function. CookFish would just be a FindFish, ClickFire, basically, and wait, so really I think it would lead to things like that.

  7. #7
    Join Date
    Dec 2009
    Location
    Newcastle, Australia
    Posts
    888
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    think about this though, when you start your player, do move camera up, and then change the rotation? no, you do both at the same time. perhaps a function which does both at the same time?

    Current Script Project
    Pot of flour gatherer - 95% done

    Can't get Simba to work? Click here for a tutorial

  8. #8
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Bad Boy JH View Post
    think about this though, when you start your player, do move camera up, and then change the rotation? no, you do both at the same time. perhaps a function which does both at the same time?
    Now THAT would be useful. Actually I see great potential in this. All directional could be set with one function. I would leave SetRun separate though.

    Edit: I made it, looks SOO much better doing both at same time:
    Simba Code:
    Function SetCamera(CompassDirection: Variant; HighestAngle: Variant): Boolean;
    var
      StartAngle, Angle, DirectionDeg, i: Extended;
      Left, SetCompass, SetAng, Highest, Set0, Set1: Boolean;
      Mark, TimeOut: Integer;
    Begin
      Result := False;

      if Not LoggedIn then
        Exit;

      if varType(HighestAngle) = varBoolean then
      begin
        SetAng := true;
        Highest := HighestAngle;
      end;

      case VarType(CompassDirection) of
        varInteger, varDouble: begin
                                 StartAngle := (rs_GetCompassAngleDegrees);
                                 DirectionDeg := FixD(CompassDirection + 0.0);
                               end;
        varString: begin
                     StartAngle := (rs_GetCompassAngleDegrees);
                     i := StrToFloatDef(CompassDirection,-1337);
                     if i = -1337 then
                     begin
                       case LowerCase(CompassDirection) of
                          'n': DirectionDeg := 0;
                          'w': DirectionDeg := 270;
                          's': DirectionDeg := 180;
                          'e': DirectionDeg := 90;
                          'random', 'rand': DirectionDeg := RandomRange(0, 360);
                       end;
                     end else
                       DirectionDeg := FixD(i);
                   end;
      end;

      SetCompass := (StartAngle > -1) and (DirectionDeg > -1);

      i := 0.0;
      if (MinE(Abs(StartAngle - DirectionDeg), MinE(Abs(StartAngle - (DirectionDeg + 360)), Abs((StartAngle + 360) - DirectionDeg)))) <= 8.0 then
        SetCompass := False;

      Set0 := not SetCompass;
      Set1 := not SetAng;

      if SetCompass then
      begin
        Left := (Round((360 - StartAngle) + DirectionDeg) mod 360 <= Round((StartAngle + 360) - DirectionDeg) mod 360);
        KeyDown((Integer(not Left) * 2) + 37);
      end;

      if SetAng then
      begin
        KeyDown((Integer(not Highest) * 2) + 38);
        TimeOut := 1000 + Random(300);
      end;

      MarkTime(Mark);

      repeat
        wait(1);

        if SetCompass then
        begin
          Angle:= rs_GetCompassAngleDegrees;
          if ((TimeFromMark(Mark) > 6000)  and (i < 1.0)) or
             ((TimeFromMark(Mark) > 10000) and (i < 2.0)) or
             ((TimeFromMark(Mark) > 14000) and (i < 3.0)) then
            i := i + 1.0;
          if ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
           or (TimeFromMark(Mark) > 14000)
           or (Angle < 0) then
           begin
             if Left then
               KeyUp(VK_Left)
             else
               KeyUp(VK_Right);
             Set0 := true;
           end;
        end;

        if SetAng then
          if (TimeFromMark(Mark) >= TimeOut) then
          begin
            KeyUp((Integer(not Highest) * 2) + 38);
            Set1 := true;
          end;

      until (Set0 and Set1) or (TimeFromMark(Mark) > 14000);

      if SetCompass then
        Result := ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
      else
        Result := not SetCompass;
    end;

    Note HighestAngle is a variant this way you can put 0 or w/e besides a boolean so it doesn't try to set the Angle.
    Last edited by Narcle; 11-30-2010 at 08:00 AM.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  9. #9
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Now thats the shit!
    There used to be something meaningful here.

  10. #10
    Join Date
    Dec 2009
    Location
    Newcastle, Australia
    Posts
    888
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yes, yes it is, I am working on a cooker, and that would make it insanely human like...

    Current Script Project
    Pot of flour gatherer - 95% done

    Can't get Simba to work? Click here for a tutorial

  11. #11
    Join Date
    May 2007
    Location
    Everywhere
    Posts
    1,428
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    I officially want Narcle's suggestion instead of mine.

  12. #12
    Join Date
    Nov 2010
    Posts
    17
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well I think SetAngle should be automatically initiated to true (not asked in the initialization function), that's about it, since I don't walk to put in a bunch of arguments for SRL setup when I don't even need them.

  13. #13
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Is AngleDir still in SRL?

  14. #14
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Boreas View Post
    Is AngleDir still in SRL?
    I don't see it in there. I've improved my function a bit too:

    Simba Code:
    Function SetCamera(CompassDirection: Variant; HighestAngle: Variant): Boolean;
    var
      StartAngle, Angle, DirectionDeg, i: Extended;
      Left, SetCompass, SetHeight, Highest, Set0, Set1: Boolean;
      Mark, TimeOut, k: Integer;
    Begin
      Result := False;
      if not LoggedIn then
        Exit;
      if varType(HighestAngle) = varBoolean then
      begin
        SetHeight := true;
        Highest := HighestAngle;
      end;
      case VarType(CompassDirection) of
        varInteger, varDouble: begin
                                 StartAngle := (rs_GetCompassAngleDegrees);
                                 DirectionDeg := FixD(CompassDirection + 0.0);
                               end;
        varString: begin
                     StartAngle := (rs_GetCompassAngleDegrees);
                     i := StrToFloatDef(CompassDirection,-1337);
                     if i = -1337 then
                     begin
                       case LowerCase(CompassDirection) of
                          'n': DirectionDeg := 0;
                          'w': DirectionDeg := 270;
                          's': DirectionDeg := 180;
                          'e': DirectionDeg := 90;
                          'random', 'rand': DirectionDeg := RandomRange(0, 360);
                       end;
                     end else
                       DirectionDeg := FixD(i);
                   end;
      end;
      SetCompass := (StartAngle > -1) and (DirectionDeg > -1);
      if SetCompass then
        if (MinE(Abs(StartAngle - DirectionDeg), MinE(Abs(StartAngle - (DirectionDeg + 360)), Abs((StartAngle + 360) - DirectionDeg)))) <= 8.0 then
          SetCompass := False;
      if SetCompass then
      begin
        i := 0.0;
        Left := (Round((360 - StartAngle) + DirectionDeg) mod 360 <= Round((StartAngle + 360) - DirectionDeg) mod 360);
        KeyDown((Integer(not Left) * 2) + 37);
      end else
        Set0 := true;//to break out of loop
      if SetHeight then
      begin
        KeyDown((Integer(not Highest) * 2) + 38);
        TimeOut := 1000 + Random(300);
      end else
        Set1 := true;
      MarkTime(Mark);
      repeat
        wait(1);
        if SetCompass and (not Set0) then
        begin
          Angle:= rs_GetCompassAngleDegrees;
          if ((TimeFromMark(Mark) > 6000)  and (i < 1.0)) or
             ((TimeFromMark(Mark) > 10000) and (i < 2.0)) or
             ((TimeFromMark(Mark) > 14000) and (i < 3.0)) then
            i := i + 1.0;
          if ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
           or (TimeFromMark(Mark) > 14000)
           or (Angle < 0) then
           begin
             KeyUp(Integer(not Left)*2+37);
             Set0 := true;
           end;
        end;
        if SetHeight and (not Set1) then
          if (TimeFromMark(Mark) >= TimeOut) then
          begin
            KeyUp((Integer(not Highest) * 2) + 38);
            Set1 := true;
          end;
      until (Set0 and Set1) or (TimeFromMark(Mark) > 14000);
      for k := 37 to 40 do
      begin
        KeyDown(k);
        KeyUp(k);
      end;//sometimes doesn't release keys, this makes sure they are all reset
      if SetCompass then
        Result := ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
      else
        Result := not SetCompass;
    end;

    Edit: Updated it again. For some reason the keys will stick randomly, so I added a loop to push and release them all at the end, this seems to solve it.
    Last edited by Narcle; 11-30-2010 at 10:13 PM.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  15. #15
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    That looks great Narcle o.O

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

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
  •