Results 1 to 13 of 13

Thread: How to make an area

  1. #1
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default How to make an area

    Alright, for my next script, I need an area, and if it strays from that area, to return to it. Could I use SPS to accomplish this or what?

  2. #2
    Join Date
    Jan 2012
    Location
    Calgary, AB, Canada
    Posts
    1,819
    Mentioned
    5 Post(s)
    Quoted
    120 Post(s)

    Default

    ODTM would be your best bet for this since you can set a polygon area and use ObjDTM_InArea to remain in it abu_jwka has a nice tut on it
    Current Project: Retired

  3. #3
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    ^^ That and I think you can use a DTM as well think its called an anchor or something like that.

  4. #4
    Join Date
    Jan 2012
    Location
    Long Island, NY
    Posts
    413
    Mentioned
    5 Post(s)
    Quoted
    95 Post(s)

    Default

    This link might have some info about those ODTMs that could help you,
    http://villavu.com/forum/showthread.php?p=891218

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

    Default

    Quote Originally Posted by Brotein View Post
    This link might have some info about those ODTMs that could help you,
    http://villavu.com/forum/showthread.php?p=891218
    From that guide:
    Quote Originally Posted by euphemism View Post
    Positioning, Location Checking, and Other Uses

    Reserved, coming soon.

    There's nothing on using ObjectDTM's for areas yet.

  6. #6
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Easier is to use SPS ,but it's low accuracy. Also you can use ODTM ,something like this:

    Simba Code:
    if not(ObjDTM_find(ODTM,x,y,True)) then
          begin
            writeln('Cannot find position');
          end else
            if ((x>MMCX-30)and(x<MMCX+30)and(y>MMCY-30)and(y<MMCX+30)) then
         writeln('You are in area')
        else
        writeln('You are not in area');

    or use TPAs to find borders of area (for example fence).

  7. #7
    Join Date
    Mar 2012
    Posts
    426
    Mentioned
    0 Post(s)
    Quoted
    9 Post(s)

    Default

    http://villavu.com/forum/showthread.php?t=78905

    If you read through Abu's tutorial on Object DTMs near the end he talks about areas. I think that would be the easiest. I almost always use object dtm areas as part of my fail safes when walking.

  8. #8
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    So no objects are needed to be clicked to make the polygon?

  9. #9
    Join Date
    Jun 2008
    Location
    United States
    Posts
    818
    Mentioned
    60 Post(s)
    Quoted
    90 Post(s)

    Default

    Quote Originally Posted by beginner5 View Post
    Easier is to use SPS ,but it's low accuracy. Also you can use ODTM ,something like this:

    -snip

    or use TPAs to find borders of area (for example fence).
    You can define an area for an Object DTM that exactly matches the contours of a fence and call 'ObjDTM_InArea' to check if your character is within it.

    Quote Originally Posted by NKN View Post
    So no objects are needed to be clicked to make the polygon?
    You need objects to make the Object DTM, but the vertices of the area polygon do not need to be objects. I will attempt to fill out the third section of my tutorial in the next few days.
    [10/14/13:19:03] <BenLand100> this is special relatively, just cleverly disguised with yachts

  10. #10
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    So in order to have it check for in area, I have to have objects. Hrmmm.....

  11. #11
    Join Date
    Dec 2007
    Posts
    289
    Mentioned
    4 Post(s)
    Quoted
    86 Post(s)

    Default

    Quote Originally Posted by beginner5 View Post
    Easier is to use SPS ,but it's low accuracy. Also you can use ODTM ,something like this:

    Simba Code:
    if not(ObjDTM_find(ODTM,x,y,True)) then
          begin
            writeln('Cannot find position');
          end else
            if ((x>MMCX-30)and(x<MMCX+30)and(y>MMCY-30)and(y<MMCX+30)) then
         writeln('You are in area')
        else
        writeln('You are not in area');

    or use TPAs to find borders of area (for example fence).
    Or just use
    Simba Code:
    (*******************************************************************************
    function ObjDTM_InArea(DTMToCheck: String; GroundLevel: Boolean): Boolean;
    By: euphemism
    Last Edit: 19 Dec 2011 -- euphemism
    Description: Calls 'ObjDTM_InAreaEx', uses the area of 'DTMToCheck' to
                 see if the player is within the area.  Because the area is
                 specified by a concave/convex polygon, it can be tailored to
                 fit a very specific area.  Returns true if the player is
                 within the area.
    *******************************************************************************)


  12. #12
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Testing ObjDTM_InArea right now.

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

    Default

    Taken from my tutorial and edited:

    Defining Locations

    You're probably wondering what I mean by this. Basically - it's marking out a location - such as a Bank, Altar or a Shop. To define a location you simply make an ObjectDTM as normal - but give it a much larger area which goes around your location. For example, here is how you would make an ObjectDTM to define the location of the Varrock West Bank:

    See how the area goes around the bank?

    To define a location, there is only one function you need to know:
    Simba Code:
    ObjDTM_InArea(DTMToCheck: String; GroundLevel: Boolean): Boolean;
    How to use it?
    - ObjDTM_InArea: Simply put in your ObjectDTM followed by True if it is a Ground Level of False if it isn't.

    What use is defining locations? Well simple, I could name the area of the bank 'IsAtBank' and then use it as a failsafe such as:
    Simba Code:
    if not IsAtBank then
      WalktoBank;
    You could also put this location at the end of paths as the result, thus chaning the paths from procedures into functions. Here is a smaller example from a really old version of script of mine on how this works:
    Simba Code:
    //-- Bank Location --\\
    function IsAtBank: Boolean;
    begin
      Result := ObjDTM_InArea('80:80:7:10:7:58:75:10:7:101:55:10:7:101:47:10:7:58:59:10:7:58:51:10:7:58:67:10:7:101:63:4:58:25:60:99:104:98:101:25', True);
    end;

    //-- WalkToBank --\\
    function WalkToBank: Boolean;
    begin
      Antiban;
          ObjDTM_Walk('57:112:6:10:7:39:75:10:7:39:66:10:7:39:57:10:7:88:53:10:7:88:44:10:7:39:97:4:40:104:42:119:95:118:95:104', 0, 100, 80, True);
          ObjDTM_Walk('37:95:5:10:7:54:70:10:7:54:58:1:7:34:76:10:7:98:32:10:7:99:24:5:43:78:11:78:15:105:56:104:66:80', 0, 100, 80, True);
          ObjDTM_Walk('34:103:5:1:7:78:63:1:7:47:102:10:7:97:59:10:7:97:47:10:7:97:40:4:18:90:23:124:57:108:57:78', 0, 100, 80, True);
          ObjDTM_Walk('26:107:4:1:7:70:99:1:7:94:82:1:7:58:111:1:7:106:103:5:13:91:19:122:47:122:54:106:43:80', 0, 100, 80, True);
          ObjDTM_Walk('40:116:5:1:7:66:63:1:7:46:67:1:7:42:99:1:7:114:83:5:7:57:46:5:24:100:27:132:56:132:64:99:50:81', 0, 100, 80, True);
          ObjDTM_Walk('80:80:2:1:7:91:103:3:7:101:83:4:74:77:73:98:92:97:91:77', 0, 100, 80, True);
     
      Result := IsAtBank; //here's where I've used it!!!
    end;
    I could also place it at the start of a function. So if I wanted to walk from the bank to somewhere else, I could put: if not IsAtBank then Exit; that way if the player isn't at the bank to start the path, it will exit the function.

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
  •