Results 1 to 10 of 10

Thread: OpenGE

  1. #1
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default OpenGE

    TPA function for opening the grand exchange.
    Input the string for whatever option you'd like to choose in the GE

    Examples are:
    - Talk-to
    - Exchange
    - History
    - Sets

    Simba Code:
    function OpenGE(Option: String): Boolean;
    var
      Options: TStringArray;
      Colors, NPCArray :TPointArray;
      ATPA: T2DPointArray;
      MSNPC, NPCPoint :TPoint;
      CTS, ii, i :Integer;
      NPCBox: TBox;
    begin
      //
      case Lowercase(Option) of
        'talk': Options := ['to G', 'alk', 'k-to'];
        'exchange': Options := ['ge G'];
        'history': Options := ['istory', 'ry G'];
        'sets': Options := ['ets', 'ts G'];
        else
        begin
          Writeln('Please choose a valid option!');
          Exit;
        end;
      end;
      //
      SetAngle(SRL_ANGLE_LOW);
      NPCArray := GetMinimapDots('NPC');

      if Length(NPCArray) < 1 then
        Exit;

      SortTPAFrom(NPCArray, Point(MMCX, MMCY));

      for i := 0 to High(NPCArray) do
      begin
        NPCPoint := MMToMS(NPCArray[i])
        if NPCPoint = Point(-1, -1) then
          Continue;

        CTS := GetColorToleranceSpeed;
        ColorToleranceSpeed(2);
        SetColorSpeed2Modifiers(0.63, 0.11);

        NPCBox := IntToBox(Max(NPCPoint.X - 40, MSX1), Max(NPCPoint.Y - 40, MSY1), Min(NPCPoint.X + 40, MSX2), Min(NPCPoint.Y + 40, MSY2));

        if FindColorsSpiralTolerance(NPCPoint.x, NPCPoint.y, Colors, 2891041, NPCBox.x1, NPCBox.y1, NPCBox.x2, NPCBox.y2, 5) then
        begin
          SetColorSpeed2Modifiers(0.2, 0.2);
          ColorToleranceSpeed(CTS);

          ATPA := TPAToATPAEx(Colors, 15, 20);
          SortATPASize(ATPA, True);

          for ii := 0 to High(ATPA) do
          begin
            MSNPC := MiddleTPA(ATPA[ii]);
            MMouse(MSNPC.X, MSNPC.Y, 3, 3);

            if WaitUpTextMulti(['rand', 'xcha', 'change'], 200) then
            begin
              ClickMouse2(mouse_Right);
              Result := WaitOptionMulti(Options, 600);
              if Result then
                Exit;
            end;
          end;
        end;
      end;
    end;
    Edited with Runaway's addition
    Last edited by P1ng; 08-29-2012 at 02:20 AM.

  2. #2
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Good job with this Looks very clean and efficient. Perhaps you could use a case for the options though?

    Simba Code:
    function OpenGE(Option: String): Boolean;
    var
      Options: TStringArray;
      Colors, NPCArray :TPointArray;
      ATPA: T2DPointArray;
      MSNPC, NPCPoint :TPoint;
      CTS, ii, i :Integer;
      NPCBox: TBox;
    begin
      //
      case Lowercase(Option) of
        'talk': Options := ['to G', 'alk', 'k-to'];
        'exchange': Options := ['ge G'];
        'history': Options := ['istory', 'ry G'];
        'sets': Options := ['ets', 'ts G'];
        else
        begin
          Writeln('Please choose a valid option!');
          Exit;
        end;
      end;
      //
      SetAngle(SRL_ANGLE_LOW);
      NPCArray := GetMinimapDots('NPC');

      if Length(NPCArray) < 1 then
        Exit;

      SortTPAFrom(NPCArray, Point(MMCX, MMCY));

      for i := 0 to High(NPCArray) do
      begin
        NPCPoint := MMToMS(NPCArray[i])
        if NPCPoint = Point(-1, -1) then
          Continue;

        CTS := GetColorToleranceSpeed;
        ColorToleranceSpeed(2);
        SetColorSpeed2Modifiers(0.63, 0.11);

        NPCBox := IntToBox(Max(NPCPoint.X - 40, MSX1), Max(NPCPoint.Y - 40, MSY1), Min(NPCPoint.X + 40, MSX2), Min(NPCPoint.Y + 40, MSY2));

        if FindColorsSpiralTolerance(NPCPoint.x, NPCPoint.y, Colors, 2891041, NPCBox.x1, NPCBox.y1, NPCBox.x2, NPCBox.y2, 5) then
        begin
          SetColorSpeed2Modifiers(0.2, 0.2);
          ColorToleranceSpeed(CTS);

          ATPA := TPAToATPAEx(Colors, 15, 20);
          SortATPASize(ATPA, True);

          for ii := 0 to High(ATPA) do
          begin
            MSNPC := MiddleTPA(ATPA[ii]);
            MMouse(MSNPC.X, MSNPC.Y, 3, 3);

            if WaitUpTextMulti(['rand', 'xcha', 'change'], 200) then
            begin
              ClickMouse2(mouse_Right);
              Result := WaitOptionMulti(Options, 600);
              if Result then
                Exit;
            end;
          end;
        end;
      end;
    end;

    Something along those lines.

  3. #3
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Like Runaway's edition so much I added it to the OP

    Makes the function that little bit more user-friendly and doesn't rely on their ability to pick good text

  4. #4
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    Definitely useful in my eyes.

    Will use in future scripts

  5. #5
    Join Date
    Jul 2011
    Location
    /home/litoris
    Posts
    2,226
    Mentioned
    0 Post(s)
    Quoted
    159 Post(s)

    Default

    Get this moved to suggestions? It'd be useful.
    Miner & Urn Crafter & 07 Chicken Killer
    SPS BlindWalk Tutorial

    Working on: Nothing

    teacher in every art, brought the fire that hath proved to mortals a means to mighty ends

  6. #6
    Join Date
    Feb 2012
    Location
    UK
    Posts
    909
    Mentioned
    10 Post(s)
    Quoted
    191 Post(s)

    Default

    This looks quite useful.
    I have a question though, if someone was to use this in a script which they then use to apply for SRL membership, even if credit was given to P1ng, would the script be refused?
    I'm not close to being able to submit a decent enough script for membership yet, I'm just curious. Thanks.
    Last edited by Solar; 08-29-2012 at 03:11 PM.
    Solar from RiD.

  7. #7
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    They wont refuse you because of parts not made by you, they will simply ignore it, and pretend its not there. Dont use too many functions made by other people though!
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  8. #8
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    You may certainly use this in any scripts you write, crediting me would be nice But, I put it up here for others to use.

    If you use this in an SRL member's application you would definitely need to credit me and I advise you don't use too many other people's functions.

    If you are applying for members we generally expect you have the ability to make something similar to this function, on your own.

    E: If people think there would be a genuine demand/use for this in the include then I will PM a mod and see if I can get it moved to suggestions
    Last edited by P1ng; 08-29-2012 at 03:48 PM.

  9. #9
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well if there is nothing like this in the include, and it works perfectly, it could definetly be added to the include! Im still wondering what type of script would need to use the GE though...
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  10. #10
    Join Date
    Dec 2009
    Posts
    380
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by Footy View Post
    Well if there is nothing like this in the include, and it works perfectly, it could definetly be added to the include! Im still wondering what type of script would need to use the GE though...
    A script that would require purchasing more supplies to run indefinitely?

    At least that's what I'm going to try to use this for. Thank you for this function!
    Currently: Playing OSRS legit until I get bored

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
  •