Results 1 to 8 of 8

Thread: ~*~*Checking if in a certain area~*~*

  1. #1
    Join Date
    Dec 2011
    Location
    -bash
    Posts
    515
    Mentioned
    0 Post(s)
    Quoted
    27 Post(s)

    Default ~*~*Checking if in a certain area~*~*

    Okay so I am trying to add something to a script that will check if the character is in a certain area, then it will do the actions in that area. So far this is what I did:


    The 2 points that I chose above {Point(197, 448), Point(423, 258)}, will they form a rectangle like this and the script will check inside this rectangle?



    Also, this is what the code I am using to check this looks like (I am using Mat's InArea function):

    This is the function:
    Simba Code:
    function InArea(Pt1, Pt2: TPoint): Boolean;
    var
    Loc: TPoint;
    Box: TBox;
    begin
      Loc := SPS_GetMyPos;
      Box := PointToBox(Pt1, Pt2);
      if (PointInBox(Loc, Box)) then
        Result := true else
      if NOT (PointInBox(Loc, Box)) then
        Result := false;
    end;

    And this is how I am using it to check the area:
    Code:
    If InArea(Point(197, 448), Point(423, 258)) then
      begin
      if Not(FindBitMapToleranceIn(Ess, px, py, MiX1, MiY1, MiX2, MiY2, 45)) then
      begin
      Runbank;
      end else
      RunAltar;
        FindObstacle;
          CraftingRunes;
            CosmicCount;
              Runbank;
                Inc(Runs);
                  IncEx(CosmicCount, RuneCount);
    What am I doing wrong? Cause everytime I run it, it just sits there and does nothing.

    Also, if you know a better way of doing what I am attempting, please feel free to share
    Last edited by Recursive; 05-15-2012 at 01:30 AM.

  2. #2
    Join Date
    Nov 2011
    Location
    MA
    Posts
    545
    Mentioned
    3 Post(s)
    Quoted
    10 Post(s)

    Default

    The points of the box should be pt1: top left, pt2: bottom right

  3. #3
    Join Date
    Dec 2011
    Location
    -bash
    Posts
    515
    Mentioned
    0 Post(s)
    Quoted
    27 Post(s)

    Default

    Okay so does that mean it will check for your current position inside a box made up of those 2 points kinda like what I attempted to draw above?

  4. #4
    Join Date
    Nov 2011
    Location
    MA
    Posts
    545
    Mentioned
    3 Post(s)
    Quoted
    10 Post(s)

    Default

    That's exactly what it does just switch around the points to a point in top left and bottom right in your function. Also, there's a problem with the second part of your code. You're missing a begin/end after an else

  5. #5
    Join Date
    Dec 2011
    Location
    -bash
    Posts
    515
    Mentioned
    0 Post(s)
    Quoted
    27 Post(s)

    Default

    Thank you so much!

  6. #6
    Join Date
    Oct 2011
    Location
    Australia, Vic
    Posts
    1,517
    Mentioned
    2 Post(s)
    Quoted
    120 Post(s)

    Default

    Note to this, You could just use ObjDTM for area getting, It has proven quite helpful for me .

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

    Default

    Quote Originally Posted by John View Post
    Note to this, You could just use ObjDTM for area getting, It has proven quite helpful for me .
    I would probably use this ^ or SPS.

    This is what I've used to check if my player has been kicked out of the GOP minigame. It also double checks it by counting colors.
    Simba Code:
    function CheckGOPLobby: Boolean;
    var
      MyPos: TPoint;
      GopLobbyBox: TBox;

    begin
      SMART_DrawDotsEx(False, ActionBoxTPA, RGBtoColor(194, 178, 146));
      SMART_DrawText(290, 429, UpChars, 'check if at gop lobby', clWhite);
      GopLobbyBox := IntToBox(39803, 3015, 39863, 3079);
      SPS_Setup(RUNESCAPE_SURFACE, ['99_7']);
      MyPos := SPS_GetMyPos;
      WriteLn('My position is  x: '+inttostr(MyPos.x)+' y: '+inttostr(MyPos.y));
      if MyPos = Point(-1, -1) then
      begin
        Exit;
      end;
      if PointInBox(MyPos, GopLobbyBox) then
        begin
          ColorToleranceSpeed(2);
          SetColorSpeed2Modifiers(0.23, 0.88);
          WriteLn('Blue colors: '+IntToStr(CountColorTolerance(7301651, MMX1, MMY1, MMX2, MMY2, 10))+'');
          if CountColorTolerance(7301651, MMX1, MMY1, MMX2, MMY2, 10) > 2000 then
          begin
            WriteLn('We are at the Gop lobby');
            Result:=True;
          end else
          begin
            WriteLn('We are NOT at the Gop lobby');
            Exit;
          end;
        end else
        begin
          Exit;
        end;
    end;

    You basicly use this
    WriteLn('My position is x: '+inttostr(MyPos.x)+' y: '+inttostr(MyPos.y));
    to determine the box co-ords.

    Then you make a TBox with all the co-ords of the box stored in it. If your position matches a point in the box, you will be in the desired area so the result is true. You don't even need to add failsafe like I did, but I'm using a total of 7 different SPS maps and some times it will think that it is at the GOP lobby even though it isn't. So I added a countcolor function to make sure the player has indeed been kicked. It's not necessary for your script I think :P

    C:\Simba\Includes\SPS\img\runescape_other
    zanaris

    is in there
    Simba Code:
    SPS_Setup(RUNESCAPE_OTHER, [zanaris']);
    is what you have to use

    Simba Code:
    function CheckZanaris: Boolean;
    var
      MyPos: TPoint;
      ZanarisBox: TBox;

    begin
      ZanarisBox := IntToBox(1, 2, 3, 4);
      SPS_Setup(RUNESCAPE_OTHER, ['zanaris']);
      MyPos := SPS_GetMyPos;
      WriteLn('My position is  x: '+inttostr(MyPos.x)+' y: '+inttostr(MyPos.y));
      if MyPos = Point(-1, -1) then
      begin
        Exit;
      end;
      if PointInBox(MyPos, ZanarisBox) then
        begin
          WriteLn('We are at the correct position');
          Result:=True;
        end else
        begin
          WriteLn('We are NOT at the correct position');
          Exit;
        end;
    end;
    ^ that would work if you get the co-ords

    Simba Code:
    if CheckZanaris then
    begin
      *things to do when you are in that box*
    end;
    Last edited by J J; 05-15-2012 at 10:51 AM.

    Script source code available here: Github

  8. #8
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    the easiest way to check if you are in an area is to use FindSymbols--only 1/2 line required the limitation are that there must be symbols in that area (duh) and that u may have to lower SymbolAccuracy in case it gets distorted.

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
  •