Results 1 to 7 of 7

Thread: StrangePlant handler

  1. #1
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default StrangePlant handler

    While it's not easy to determine if a strange plant is ours or not (this can actually be accomplished in the script but not universally) we can still make a detection & handling system if one comes within distance of our player. So here's a basic Strangeplant finder & handler that will work in all scripts.

    -Global declaration-
    Declare this as a global variable:
    Simba Code:
    Var
      SP_coolDownTimer: Integer;

    -Finding the plant-
    Simba Code:
    Function foundStrangePlant(out Pnt: TPoint): Boolean;
    var
      cts: Integer;
      tpa: TPointArray;
    begin
      cts    := getToleranceSpeed;

      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.34, 1.17);
      FindColorsSpiralTolerance(MSCX, MSCY, tpa, 612431, MSCx-100, MSCy-100, MSCx+100, MSCy+100, 4);
      SetColorSpeed2Modifiers(0.02, 0.02);
      ColorToleranceSpeed(CTS);

      result := (length(tpa) > 50);
      if Result then
        Pnt := Point(MedianTPA(tpa).x, MedianTPA(tpa).y);
    end;
    As you can tell it's pretty primitive, searching just within a 200x200 size box of the middle of the screen (presumed where our player is located) for a unique color to the strange plant. Then simply the amount of color is counted, if the size is high enough it's considered a strange plant.

    -Handling the plant-
    Simba Code:
    Function HandleStrangePlant: Boolean;
    var
      t: Integer;
      Pnt: TPoint;
    begin
    // To prevent spam-clicking a strange plant
      if (GetTimeRunning-SP_coolDownTimer) < 20000 then  // 20 seconds
        Exit;
      if not foundStrangePlant(Pnt) then
        Exit;

      t := getTimeRunning;
      repeat
        if not LoggedIn then
          Exit;

        //FindCustomRandoms;
        FindNormalRandoms;
        if not foundStrangePlant(Pnt) then
          break;

        if (FindBlackChatMessage('ou pick') or FindBlackChatMessage('unable to')) then
        begin
          Result := True;
          break;
        end;

        MMouse(Pnt.X, Pnt.Y, 5, 5);
        if waitUptextMulti(['Pick','ick St'], 200) then
        begin
          Clickmouse2(mouse_right);
          chooseOptionMulti(['Pick','ck St']);
          Flag;
          Wait(RandomRange(1500,2400));
        end else if waitUptextMulti(['ttack','ack Str'], 200) then
        begin
          Result := True;
          break;
        end;
      until((getTimeRunning-t) > 15000)

      if Result then
        SP_coolDownTimer := GetTimeRunning;
    end;

    If we successfully interacted with the plant (either pick the fruit or determine it's not after our player) then the global "SP_coolDownTimer" is, once again, reset, so we won't start looking for a strange plant until 20 seconds after the previous one.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  2. #2
    Join Date
    Sep 2012
    Location
    Australia.
    Posts
    839
    Mentioned
    16 Post(s)
    Quoted
    225 Post(s)

  3. #3
    Join Date
    May 2012
    Location
    Wisconsin, USA
    Posts
    105
    Mentioned
    1 Post(s)
    Quoted
    47 Post(s)

    Default

    @Flight, please explain the purpose of the "out" in the function declaration:

    Simba Code:
    Function foundStrangePlant(out Pnt: TPoint): Boolean;

    What is the difference between 'var Pnt' and 'out Pnt' since both need to be declared variables passed to the the function? Is an 'out' parameter a pointer? I've seen 'out' used in FindDTMRotated in the form of out aFound: Extended, even though I cannot seem to make any use of it there.

  4. #4
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    Quote Originally Posted by loragnor View Post
    @Flight, please explain the purpose of the "out" in the function declaration:

    Simba Code:
    Function foundStrangePlant(out Pnt: TPoint): Boolean;

    What is the difference between 'var Pnt' and 'out Pnt' since both need to be declared variables passed to the the function? Is an 'out' parameter a pointer? I've seen 'out' used in FindDTMRotated in the form of out aFound: Extended, even though I cannot seem to make any use of it there.
    if it's found at for example: Point(156,78); then Pnt will be stored as Pnt := Point(156,78);

    edit: nvm didn't read your question properly
    Last edited by Sjoe; 07-28-2013 at 01:36 AM.

    Creds to DannyRS for this wonderful sig!

  5. #5
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by loragnor View Post
    @Flight, please explain the purpose of the "out" in the function declaration:

    Simba Code:
    Function foundStrangePlant(out Pnt: TPoint): Boolean;

    What is the difference between 'var Pnt' and 'out Pnt' since both need to be declared variables passed to the the function? Is an 'out' parameter a pointer? I've seen 'out' used in FindDTMRotated in the form of out aFound: Extended, even though I cannot seem to make any use of it there.
    Honestly I'm not sure what the difference between the two would be. If I really had to guess I'd say that if it was was set up as "Var Pnt" then whatever variable was used to catch that returned variable could have still been <> 0, while maybe if you're catching an out (for lack of better terminology) it would have to be empty. But chances are I'm completely wrong in this theory. If you want to replace it with "Var Pnt: TPoint" then I don't see any problem with that. As far as I'm concerned the same thing is accomplished.

    @Chris!: Thank you.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  6. #6
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by loragnor View Post
    @Flight, please explain the purpose of the "out" in the function declaration:

    Simba Code:
    Function foundStrangePlant(out Pnt: TPoint): Boolean;

    What is the difference between 'var Pnt' and 'out Pnt' since both need to be declared variables passed to the the function? Is an 'out' parameter a pointer? I've seen 'out' used in FindDTMRotated in the form of out aFound: Extended, even though I cannot seem to make any use of it there.
    There are several argument keywords you can use in Simba's PascalScript/Lape:
    • const - Indicates that the argument passed to the method is read-only and cannot be modified (i.e. a value can be passed into the method and it can be read).
    • out - Indicates that the argument passed to the method is write-only at first and can be modified (i.e. an empty/nil variable is passed into the method so it can be changed by the method).
    • var - Indicates that the argument passed to the method is read/write and can be modified (i.e. its initial value can be read, and be modified by the method).
    • default (i.e. nothing) - assume const.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  7. #7
    Join Date
    May 2012
    Location
    Wisconsin, USA
    Posts
    105
    Mentioned
    1 Post(s)
    Quoted
    47 Post(s)

    Default

    Quote Originally Posted by Daniel View Post
    There are several argument keywords you can use in Simba's PascalScript/Lape:
    • const - Indicates that the argument passed to the method is read-only and cannot be modified (i.e. a value can be passed into the method and it can be read).
    • out - Indicates that the argument passed to the method is write-only at first and can be modified (i.e. an empty/nil variable is passed into the method so it can be changed by the method).
    • var - Indicates that the argument passed to the method is read/write and can be modified (i.e. its initial value can be read, and be modified by the method).
    • default (i.e. nothing) - assume const.
    Thank you. I'm glad to finally have an explanation about this.

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
  •