Results 1 to 5 of 5

Thread: Leaving out an area to search in // Finding different monsters

  1. #1
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default Leaving out an area to search in // Finding different monsters

    Hi.

    I'm working on a combat script and I'm currently trying to figure out what would be the best way to locate a second monster. The monsters I'm fighting have a quite annoying death animation. I can save around 5 seconds by not waiting for the animation.

    However, when I loop my script the first monster it will attack is the monster it's fighting that's in the death animation. So I figured I could search for a specific area but leaving out an area like this:



    Leaving out the white area.

    What's the best way to do this? I was thinking about these ways:

    Option #1
    (0, 250, 515, 337) = Bottom area
    (0, 0, 515, 90) = Top area
    (0, 0, 150, 337) = Left area
    (380, 0, 515, 90) = Right area

    This would leave the white part out but search in 4 different parts.

    FindColorSpiralTolerance(X, Y, {monster color} , a, b, c, d, {tolerance});
    -->
    if FindColorSpiralTolerance(X, Y, {monster color} , 0, 250, 515, 337, {tolerance}) or FindColorSpiralTolerance(X, Y, {monster color} , 0, 0, 515, 90, {tolerance}) or FindColorSpiralTolerance(X, Y, {monster color} , 0, 0, 150, 337, {tolerance}) or FindColorSpiralTolerance(X, Y, {monster color}, 380, 0, 515, 90, {tolerance}) then


    Option #2
    Doing something with MSX1, MSY1, MSX2, MSY1 and leaving out a box with the co-ords of the white part. Not sure if this is possible




    Any tips?

    Script source code available here: Github

  2. #2
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If this is melee, then an easy way is to process the distance from MSCX and MSCY. Filter if it is in melee distance.

    But this is a very makeshift hack and won't work for range/mage or other strange things.
    Current activity: Recovering from vacation
    - Nulla pars vitae vacare officio potest -
    SRL membership? Can I buy that?
    Scripts - AGS - SWF - WAR - EMS - W100S-EM
    If you need scripting help, you can pm me. Remember, if you need help you have to ask for it properly though

  3. #3
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    Use RemoveDistTPointArray.

    Quote Originally Posted by Naum View Post
    RemoveDistTPointArray

    PHP Code:
    {*******************************************************************************
    function 
    RemoveDistTPointArray(xydistIntegerThePointsTPointArrayRemoveHigherBoolean): TPointArray;
    DescriptionRemoves the points that are inside or outside the distance Dist
    from the point 
    (xyfrom the TPointArray ThePoints.
    *******************************************************************************} 
    RemoveDistTPointArray, will make a circle of radius 'Dist' with it's center points being situated at cordinates 'x' and 'y'. The 'RemoveHigher' parameter of data type Boolean will remove points inside or outside of the circle.

    RemoveHigher is True - Points removed outside the circle of radius 'Dist', points are kept within circle of radius 'Dist'

    RemoveHigher is False - Points are kept outside the circle of radius 'Dist', points are removed within circle of radius 'Dist'.

    Remember that this is a function so a data type of TPointArray must be assigned to it. It can be used as such:

    SCAR Code:
    program New;
    {.Include SRL/SRL.Scar}
    {.include srl/srl/misc/debug.scar}
    Var x, y : Integer;
        tpa : array of tpoint;
    Begin
      SetupSRL;
      FindColorsTolerance(TPA, 7048347, msx1, msy1, msx2, msy2, 10);
      MiddleTPAEx(TPA, x, y);
      TPA := RemoveDistTPointArray(x, y, 20, TPA, true); // here
      DebugTPA(tpa, '');
    End.

    What that script will do is find occurances of the color '7048347' in the mainscreen of runescape and find the middle of all those points. It then makes a circle of radius 20 (Dist) around the cordinates x and y of the TPointArray 'TPA'. The last parameter is true, so it will remove the points within the circle, and leave the ones outside of the circle untouched.

    More will be explained in due time, in the next section.

  4. #4
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Nebula View Post
    Use RemoveDistTPointArray.

    He isn't really using tpa, but he should.

    I think the tpa solution should filter out the area in search or the colors. Tha should be quite easy because I think wizzy plugin has a few functions for that
    Current activity: Recovering from vacation
    - Nulla pars vitae vacare officio potest -
    SRL membership? Can I buy that?
    Scripts - AGS - SWF - WAR - EMS - W100S-EM
    If you need scripting help, you can pm me. Remember, if you need help you have to ask for it properly though

  5. #5
    Join Date
    Mar 2008
    Posts
    30
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    This should sort through a ATPA and return the closest middle point that isn't in the defined box. Its messy just made it quite quickly but the logic behind it should work.

    Code:
    function PointInTBox(TBox:TBox;TPoint:TPoint):Boolean;
    
    var
      x,y:Integer;
    begin
      x:=TPoint.x;
      y:=Tpoint.y;
      if((x>TBox.X1)and (x<TBox.X2) and (y>TBox.Y1) and (y>TBox.Y2)) then
         Result:= True;
    end;
    
    function GetClosestPointIgnoreBox(TBox:TBox;ATPA :Array of TPointArray): TPoint;
    
    var
      I:Integer;
      Dist,TDist:Extended;
      Best,Temp:TPoint;
    
    begin
      for I:=0 to High(ATPA) do
        begin
          Temp:=MiddleTPA(ATPA[I]);
          if(PointInTBox(TBox,Temp))then
            Continue;
          TDist := Sqr(pow(Temp.x-MSCX,2)+pow(Temp.y-MSCY,2));
          if(Best.x=0) then
            begin
              Best:=Temp;
              Dist:=TDist;
            end
          else if (TDist<Dist) then
            begin
              Best:=Temp;
              Dist:=TDist;
            end
        end;
        Result:=Best;
    end;
    Last edited by greent; 03-22-2012 at 11:30 AM.

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
  •