Results 1 to 7 of 7

Thread: Help with Findobj

  1. #1
    Join Date
    Feb 2015
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default Help with Findobj

    what can i do, if i need to find an object but there is to much similar colors in the area? any better way?

  2. #2
    Join Date
    Oct 2011
    Location
    England
    Posts
    401
    Mentioned
    10 Post(s)
    Quoted
    176 Post(s)

    Default

    Quote Originally Posted by runeslide View Post
    what can i do, if i need to find an object but there is to much similar colors in the area? any better way?
    First of all, I'm assuming you're using AutoColourAid. If not, you probably want to grab it from here: https://villavu.com/forum/showthread.php?t=26944

    Fire it up with your RS client for the colours you want to grab, and then select CTS2 in the bottom right hand corner. Then, grab some of the colours that you want, preferably checking each colour for matching likeness. You probably want around 3-10 colours. When you're done click show best colour, which should give you colour, tolerance, hue and saturation outputs.

    If you're using this FindObject:
    Code:
    function findObject(COL, TOL, PIXELS: Integer; HUE, SAT: Extended): Boolean;
    var
    WhatEver: TColEx; //declaring TColEx
    TPA: TPointArray;
    ATPA: T2DPointArray;
    I: Integer;
    box: TBox;
    x, y: Integer;
    begin
    WhatEver.Create(Col, Tol, Hue, Sat); //Creating it
    if not WhatEver.FindAllIn(Area_MS, TPA) then //Finding the colours and it returning a TPA
    Exit(False); //If it finds no pixels with the matching colours it exits out returning false
    ATPA := ClusterTPA(TPA, 10);
    SortATPAFromMidPoint(ATPA, Point(MSCX, MSCY));
    if (length(ATPA) <= 0) then
    begin
    result := False;
    exit;
    end;
      //os_smart.__Graphics.DrawATPA(ATPA); for debugging purposes
      for I := 0 to high(ATPA) do
      begin
       if (length(ATPA[I]) >= PIXELS) then
        begin
          //os_smart.__Graphics.DrawTPA(ATPA[I], 255); also for debugging purposes
          box := intToBox(ATPA[I].getBounds().X1, ATPA[I].getBounds().Y1 - 25, ATPA[I].getBounds().X2, ATPA[I].getBounds().Y2);
          if (box.x1 < 0) then
            box.x1 := 0;
          if (box.y1 < 0) then
            box.y1 := 0;
          pnt := MiddleTPA(ATPA[I]);
          result := True;
          exit;
        end;
      end;
      result := False;
    end;
    You want to call it like this:

    Code:
    procedure findWhatever;
    begin
      if(findObject(2213233, 21, 5, 0.04, 0.13)) then // (colour, tolerance, pixels, hue, saturation)
      begin
        WriteLn('Found Whatever');
        begin
          custommouse(Point);
          if waituptext('hatever', randomrange(20, 50)) then
          fastClick(mouse_Right);
          chooseoptionmulti(['hatever']);
         end;
        end;
      end;
    Just an example from one of mine, but yeah, should work!
    Yer a wizard, 'oopi

  3. #3
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Quote Originally Posted by anth_ View Post
    First of all, I'm assuming you're using AutoColourAid. If not, you probably want to grab it from here: https://villavu.com/forum/showthread.php?t=26944

    Fire it up with your RS client for the colours you want to grab, and then select CTS2 in the bottom right hand corner. Then, grab some of the colours that you want, preferably checking each colour for matching likeness. You probably want around 3-10 colours. When you're done click show best colour, which should give you colour, tolerance, hue and saturation outputs.

    If you're using this FindObject:
    Code:
    function findObject(COL, TOL, PIXELS: Integer; HUE, SAT: Extended): Boolean;
    var
    WhatEver: TColEx; //declaring TColEx
    TPA: TPointArray;
    ATPA: T2DPointArray;
    I: Integer;
    box: TBox;
    x, y: Integer;
    begin
    WhatEver.Create(Col, Tol, Hue, Sat); //Creating it
    if not WhatEver.FindAllIn(Area_MS, TPA) then //Finding the colours and it returning a TPA
    Exit(False); //If it finds no pixels with the matching colours it exits out returning false
    ATPA := ClusterTPA(TPA, 10);
    SortATPAFromMidPoint(ATPA, Point(MSCX, MSCY));
    if (length(ATPA) <= 0) then
    begin
    result := False;
    exit;
    end;
      //os_smart.__Graphics.DrawATPA(ATPA); for debugging purposes
      for I := 0 to high(ATPA) do
      begin
       if (length(ATPA[I]) >= PIXELS) then
        begin
          //os_smart.__Graphics.DrawTPA(ATPA[I], 255); also for debugging purposes
          box := intToBox(ATPA[I].getBounds().X1, ATPA[I].getBounds().Y1 - 25, ATPA[I].getBounds().X2, ATPA[I].getBounds().Y2);
          if (box.x1 < 0) then
            box.x1 := 0;
          if (box.y1 < 0) then
            box.y1 := 0;
          pnt := MiddleTPA(ATPA[I]);
          result := True;
          exit;
        end;
      end;
      result := False;
    end;
    You want to call it like this:

    Code:
    procedure findWhatever;
    begin
      if(findObject(2213233, 21, 5, 0.04, 0.13)) then // (colour, tolerance, pixels, hue, saturation)
      begin
        WriteLn('Found Whatever');
        begin
          custommouse(Point);
          if waituptext('hatever', randomrange(20, 50)) then
          fastClick(mouse_Right);
          chooseoptionmulti(['hatever']);
         end;
        end;
      end;
    Just an example from one of mine, but yeah, should work!
    Pretty much this, also if you are going to use a custom mouse instead of built in humanmmouse don't forget to include it above the find obj procedure

  4. #4
    Join Date
    Oct 2011
    Location
    England
    Posts
    401
    Mentioned
    10 Post(s)
    Quoted
    176 Post(s)

    Default

    Quote Originally Posted by jstemper View Post
    Pretty much this, also if you are going to use a custom mouse instead of built in humanmmouse don't forget to include it above the find obj procedure
    Oops, forgot about that!

    Code:
    procedure customMouse(point: TPoint);
    begin
      case random(0, 6) of
        0..2: BrakeMMouse(point, random(5), random(5), true);
        3: BrakeMMouse(point, random(5), random(5), false);
        4..5: MissMouse(point, random(5), random(5));
        6: HumanMMouse(point, random(5), random(5));
      end;
    end;
    Yer a wizard, 'oopi

  5. #5
    Join Date
    Feb 2015
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    yes sweet ty but i checked srl 5 documents, and theres nothing i can find to easy find my health or prayer? or do i have to make it check for low health ETC myself?

  6. #6
    Join Date
    Feb 2015
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    and i get unknown declaration with TColEX

  7. #7
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by runeslide View Post
    yes sweet ty but i checked srl 5 documents, and theres nothing i can find to easy find my health or prayer? or do i have to make it check for low health ETC myself?
    I believe your looking for a combination of the following..

    From core/globals/
    Simba Code:
    (*
    GetFightBarTPA
    ~~~~~~~~~~~

    .. code-block:: pascal

        Function GetFightBarTPA(SearchArea: TBox): TPointArray;

    Used in various fighting functions, including srl_InFight

    .. note::

        by Narcle

    Example:

    .. code-block:: pascal


    *)

    Function GetFightBarTPA(SearchArea: TBox): TPointArray;
    var
      T: TPoint;
      H, I: integer;
      Colors: TIntegerArray;
      ATPA: T2DPointArray;
    begin
      Colors := [HP_BAR_COLOR1, HP_BAR_COLOR2];
      H := High(Colors);
      SetArrayLength(ATPA, H+1);
      T := point((MFBox.x2+MFBox.x1) div 2,(MFBox.y2+MFBox.y1) div 2);
      for i := 0 to H do
        with SearchArea do
          FindColorsSpiralTolerance(T.x, T.y, ATPA[i], Colors[i], X1, Y1, X2, Y2, 2);
      Result := MergeATPA(ATPA);
    end;

    (*
    srl_InFight
    ~~~~~~~~~~~

    .. code-block:: pascal

        function srl_InFight: Boolean;

    Checks whether player currently is in a fight, using mainscreen
    HP bar presence detection. Returns True if Player's HP bar is detected.
    Idea for improvement: Also check using PixelShift(); to see whether Player
    is performing fighting animations to further improve the certainty of results.

    .. note::

        by Narcle

    Example:

    .. code-block:: pascal

        while srl_InFight do
        begin
          CheckHP;
          EatFood;
        end;

    *)

    Function srl_InFight: Boolean;
    begin
      Result := InRange(Length(GetFightBarTPA(MFBox)), 30, 240);
    end;
    from gametab.simba
    Simba Code:
    SkillCoords
    ~~~~~~~~~~~

    .. code-block:: pascal

        function SkillCoords(Row, Column: Integer): TPoint;

    Returns Coords of Skill's Row and Column (Used for GetSkill functions)

    .. note::

        by NaumanAkhlaQ

    Example:

    .. code-block:: pascal

    *)
    function SkillCoords(Row, Column : ShortInt): TPoint;
    begin
      Result := Point(576 + (62 * (Column - 1)), 213 + (28 * (Row - 1)));
    end;

    (*

    SkillToCoords
    ~~~~~~~~~~~~~

    .. code-block:: pascal

        function SkillToCoords(Skill: Variant): TPoint;

    Turns skill string into TPoint.
    If Scroll returns true then you must scroll down.

    .. note::

        by Masquerader et. al.

    Example:

    .. code-block:: pascal

    *)
    function SkillToCoords(Skill: Variant): TPoint;
    var
      SkillArr: TStringArray;
      skNo: Integer;
      SkillS: string;
      SkillPT : TPoint; //Row/Column
    begin
      if (not LoggedIn) then exit;

      if VariantIsInteger(Skill) then
        skNo := Skill
      else
      begin;
        SkillS := Lowercase(Skill);
        case Lowercase(SkillS) of
          '
    hp', 'constitution': SkillS := 'hitpoints';
          '
    ranged': SkillS := 'range';
          '
    hunter': SkillS := 'hunting';
          '
    dung'  : skillS := 'dungeoneering';
        end;

        SkillArr := ['
    attack', 'defence', 'strength', 'hitpoints', 'range',
                     '
    prayer', 'magic', 'cooking', 'woodcutting', 'fletching',
                     '
    fishing', 'firemaking', 'crafting', 'smithing', 'mining',
                     '
    herblore',  'agility', 'thieving', 'slayer', 'farming',
                     '
    runecrafting', 'hunting', 'construction', 'summoning',
                     '
    dungeoneering'];
        if (not InStrArrEx(SkillS, SkillArr, skNo)) then
        begin
          srl_Warn('
    SkillToCoords',
                   '
    Invalid Skill Name/Number: ''' + string(Skill) + '''',
                   warn_AllVersions);
          Exit;
        end;
      end;
      case skNo of
        Skill_Attack        : SkillPT := Point(1,1);
        Skill_Strength      : SkillPT := Point(1,2);
        Skill_Defence       : SkillPT := Point(1,3);
        Skill_Range         : SkillPT := Point(1,4);
        Skill_Prayer        : SkillPT := Point(1,5);
        Skill_Magic         : SkillPT := Point(1,6);
        Skill_RuneCrafting  : SkillPT := Point(1,7);
        Skill_Construction  : SkillPT := Point(1,8);
        Skill_Dungeoneering : SkillPT := Point(1,9);
        Skill_Hitpoints     : SkillPT := Point(2,1);
        Skill_Agility       : SkillPT := Point(2,2);
        Skill_Herblore      : SkillPT := Point(2,3);
        Skill_Thieving      : SkillPT := Point(2,4);
        Skill_Crafting      : SkillPT := Point(2,5);
        Skill_Fletching     : SkillPT := Point(2,6);
        Skill_Slayer        : SkillPT := Point(2,7);
        Skill_Hunter        : SkillPT := Point(2,8);
        Skill_Mining        : SkillPT := Point(3,1);
        Skill_Smithing      : SkillPT := Point(3,2);
        Skill_Fishing       : SkillPT := Point(3,3);
        Skill_Cooking       : SkillPT := Point(3,4);
        Skill_FireMaking    : SkillPT := Point(3,5);
        Skill_WoodCutting   : SkillPT := Point(3,6);
        Skill_Farming       : SkillPT := Point(3,7);
        Skill_Summoning     : SkillPT := Point(3,8);
      else
        begin
          srl_Warn('
    SkillToCoords', 'Invalid Skill Number: ''' + inttostr(skNo) + '''', warn_AllVersions);
          exit;
        end;
      end;
      Result := SkillCoords(SkillPT.y,SkillPT.x);
    end;

    (*
    GetSkillInfo
    ~~~~~~~~~~~~

    .. code-block:: pascal

        function GetSkillInfo(Skill: Variant; Amount : Boolean): Integer;

    Gets the amount / level of a skill.
    E.G.
    0/15
    Amount = True will return 0.
    Amount = False will return 15 (The actual level).
    Returns -1 if the level couln'
    t be grabbed succesfully

    .. note::

        by Raymond

    Example:

    .. code-block:: pascal
    *)
    function GetSkillInfo(Skill: Variant; Amount : Boolean): Integer;
    var
      TP: TPoint;
      Box : TBox;
      TPA : TPointArray;
      Cts : Integer;

    begin
      Result := -1;
      GameTab(tab_Stats);
      TP := SkillToCoords(Skill);
      if (not(Amount)) then
        TP := Point(TP.x + 15,TP.y + 12);
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(0);
      if not FindColors(TPA, 36095, TP.x - 2, TP.y - 2, TP.x + 15, TP.y + 15) then
      begin
        ColorToleranceSpeed(CTS);
        exit;
      end;
      Box := GetTPABounds(TPA);
      Result := StrToIntDef(GetNumbers(GetTextAtEx(Box.x1 - 2, Box.y1 -1, 100,
        StatChars, False, True, 0, 3, 36095, 3, True, tr_Digits)), -1);
      ColorToleranceSpeed(CTS);
    end;
    not sure what you intend to do with it as it's SRL5 code, but, it's there for ideas at the very least.


    I would imagine aeroLib offers something like this? Haven't done any osrs scripting since coming back, yet.

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
  •