Results 1 to 3 of 3

Thread: findFramedObjectsSpiralTolerancesHSL

  1. #1
    Join Date
    Sep 2014
    Location
    C:\Simba\
    Posts
    565
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Post findFramedObjectsSpiralTolerancesHSL

    An object based finder function I've been working on a for a while.

    Searches for multiple colors as objects.
    For best results place the color of which the middlepoint is closest to the center.
    This is similar to doing findColors... And findColors... And (and so on), but some perks include:
    * Searches for colors object wise, (does not search for colors in the background)
    * Takes a T2DPointArray, instead of just coordinates for 1.
    * Looks Cleaner to use.


    Simba Code:
    (*
    findFramedObjectsSpiralTolerancesHSL
    ~~~~~~~~~~~~~~~~

    .. code-block:: pascal

        Function findFramedObjectsSpiralTolerancesHSL(var X, Y : Integer; SearchBox : TBox; Colours, Tols : TIntegerArray; HueMods, SatMods : Array of Extended; ObjWidth, ObjHeight, MaxPixelDist, minCount: Integer; out ResultATPA : T2DPointArray) : Boolean;

    Searches for multiple colors and replaces the T2DPointArray
    with TPointArrays in which all the given colors are found in.
    For best results place the most center located color first.

    .. note::

        - by Joopi
        - Last Updated: 19 September 2015 by Joopi

    Example:

    .. code-block:: pascal

        //Hovers the mouse over the first Alkharid banker in the T2DPointArray on Oldschool Runescape using the AeroLib include.

        SearchBox := IntToBox(MSX1, MSY1, MSX2, MSY2);
        If FindFramedObjectsSpiralTolerancesHSL(X, Y, SearchBox, [6711151, 278343, 4285836], [6, 6, 7], [0.31, 0.34,0.05], [0.09, 1.78,0.18], 15, 20, 10, 20, ATPA) Then
          Mouse(MiddleTPA(ATPA[0]), RandomRange(-3, 4), RandomRange(-2, 5), MOUSE_MOVE);
    *)

    Note: It should work for any include as long as you set the params correct.
    ACA is a useful tool to get the colors with tolerance and HSL settings. You can find it here

    Simba Code:
    Function findFramedObjectsSpiralTolerancesHSL(var X, Y : Integer; SearchBox : TBox; Colours, Tols : TIntegerArray; HueMods, SatMods : Array of Extended; ObjWidth, ObjHeight, MaxPixelDist, minCount: Integer; out ResultATPA : T2DPointArray) : Boolean;
    Var
      i, Counter, ii, z, ClientX2, ClientY2 : Integer;
      ATPA : T2DPointArray;
      TPA : TPointArray;
      MPoint : TPoint;

    Begin
      SetColorToleranceSpeed(2);
      SetToleranceSpeed2Modifiers(HueMods[0], SatMods[0]);
      GetClientDimensions(ClientX2, ClientY2);

      If FindColorsSpiralTolerance(x, y, TPA, Colours[0], SearchBox.X1, SearchBox.Y1, (SearchBox.X2 -1), (SearchBox.Y2 -1), Tols[0]) Then
      Begin
        ATPA := ClusterTPA(TPA, MaxPixelDist);
        FilterTPAsBetween(ATPA, 0, MinCount);
        For i := 0 To (Length(ATPA) -1) Do
        Begin
          MPoint := MiddleTPA(ATPA[i]);
          Z := 0;
          For ii := 1 To (Length(Colours) -1) Do
          Begin
            SetToleranceSpeed2Modifiers(HueMods[ii], SatMods[ii]);
            If (Round(MPoint.X - (ObjWidth / 2)) >= 0) And (Round(MPoint.Y - (ObjHeight / 2)) >= 0) And (Round(MPoint.X + (ObjWidth / 2)) <= (ClientX2 - 1)) And (Round(MPoint.Y + (ObjHeight / 2)) <= (ClientY2 - 1)) Then
              If FindColorSpiralTolerance(x, y, Colours[ii],  Round(MPoint.x - (ObjWidth / 2)), Round(MPoint.y - (ObjHeight / 2)), Round(MPoint.x + (ObjWidth / 2)), Round(MPoint.y + (ObjHeight / 2)), Tols[ii]) Then
                Z := Z + 1;
          End;
          If Z = (Length(Colours) -1) Then
          Begin
            Counter := Counter + 1;
            SetLength(ResultATPA, Counter);
            ResultATPA[(Counter - 1)] := ATPA[i];
          End;
        End;
        If Length(ResultATPA) > 0 Then
          Result := True;
      End;
    End;

    This graphically displays how the basics of it works. This is not the same as the blue example, since that will use all the bankers.
    Example.png

    Extras:
    * ObjWidth & ObjHeigth: Length from first to last point found left to right & top to bottom.
    * SearchBox: A TBox in which it will search for the first color.
    * MaxPixelDist: An Integer for the maximum distance between points if they are not connected. In this example between the headpiece and the torsopiece of the clothing.
    * MinCount: An integer for the minimum amount of points found in the first colours array.

    Thanks to:
    * @KeepBotting
    * @R0b0t1

    Update Log:
    19.9.2015: Rewrote it so it searches for the rest of the colors inside the first points centerpoint +- ObjWidth and ObjHeigth


    PS: If anyone finds this useful and wants to place it in an include, then feel free to do so but credit me .
    Last edited by Joopi; 11-10-2015 at 02:36 PM.

  2. #2
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Very cool, I saw some sneak peeks of this in production on IRC.

    I'm glad to see it released
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  3. #3
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    THis is nice and it's more or less how the new SRL banking works. You could look into TColorData / T2ColorData if you want to avoid messing with CTS values.

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
  •