Results 1 to 14 of 14

Thread: Guide to checking if your in a area

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Guide to checking if your in a area

    Guide on how to check if your in a area!





    Here is a cool guide on how to check if you are in a specific area, such as inside of a bank, or outside of a bank. Beleive it or not, you don't need nooby injection to get the current tile your in, you can use Symbol Finding This method is pretty reliable, I have recently find out about it myself!

    -What you need to know before reading this tutorial-

    -How to make a DTM
    -Basic pascal knowledge
    -Basic Function knowledge
    -Taking a American 8th-9th grade math class or more advanced would help you understand the math being used(Just know the distance formula)



    -Basics-

    For my example, I am going to want to check if I am inside of the Seers bank or not which is in these red lines:



    Now, you might be wondering, how are we going to do that? the answer is: We are going to be using the minimap symbols to get our location!

    -How to get distance-

    Now, first off, the symbols in the Minimap are not always in the same place, BUT they are always close to the same area, so they calculations can always be close. BUT your character square on the minimap is ALWAYS in the same exact coordinate spot which is (643,83) on Runescape 2007. what we will be doing is, finding the distance between your square on the minimap and the DTM's of the symbols that you choose on the minimap, here are the ones I have:



    Once you have picked the Symbols you want to use, make a DTM of each of them, and declare them in the script, BUT store the co-coords to each of them to different Variables. For example:

    Simba Code:
    FindDTM(DTM_Bank, x, y, 524, 3, 762, 168)
      FindDTM(DTM_House, c, b, 524, 3, 762, 168)
      FindDTM(DTM_Smith, t, u, 524, 3, 762, 168)

    As you can see, I stored them in different variables. Next We make a function that searches for the DTM's and stores them in the variables:

    Simba Code:
    function IsInBank(): boolean;
    var
       Dist_To_Symbol,c,b,t,u,Dist_To_House,Dist_To_Smith:Integer;
    Begin
      Result := false;
      FindDTM(DTM_Bank, x, y, 524, 3, 762, 168)
      FindDTM(DTM_House, c, b, 524, 3, 762, 168)
      FindDTM(DTM_Smith, t, u, 524, 3, 762, 168)
    End;

    Next, we use the simba function "Distance" to find the distance between (643,83) Which is your player's square, and the DTM's:

    Simba Code:
    Dist_To_Symbol := Distance(X,Y,643,83);
      Dist_To_House := Distance(c,b,643,83);
      Dist_To_Smith := Distance(t,u,643,83);

    you can Debug this by doing a Writeln:

    Simba Code:
    Writeln('Current Distance from Bank symbol:' + ToStr(Dist_To_Symbol))
      Writeln('Current Distance from House symbol:' + ToStr(Dist_To_House))
      Writeln('Current Distance from Smithing symbol:' + ToStr(Dist_To_Smith))

    Now, you go to each corner of the bank, and find the least distance from the symbols while your still in the bank, and the most distance. Now make some constraints that define whether you are in the bank BUT do not make them exactly like the results you got, for example, if you have to be no more then 10 pixels from the bank symbol, and 40 pixels from the smithing symbol, and 50 pixels from the house symbol, do not make them like:

    Simba Code:
    If (Dist_To_Symbol <= 10) And
      (Dist_To_House <= 40) And
      (Dist_To_Smith <= 50) Then

    Otherwise when you re-log they will not work because the symbols end up in a different area! Always increase the distance a little bit.

    -Putting it all together-

    Now that you have your constraints, you can now finish the function, mine are:

    Simba Code:
    If (Dist_To_Symbol <= 30) And
      (Dist_To_House <= 90) And
      (Dist_To_Smith <= 90) Then

    So if these are met:

    Simba Code:
    Begin
        Status := 'Inside of the Bank'
        Result := true;
      End;

    So my final function looks like:

    Simba Code:
    function IsInBank(): boolean;
    var
       Dist_To_Symbol,c,b,t,u,Dist_To_House,Dist_To_Smith:Integer;
    Begin
      Status := 'Outside of the bank'
      Result := false;
      FindDTM(DTM_Bank, x, y, 524, 3, 762, 168)
      FindDTM(DTM_House, c, b, 524, 3, 762, 168)
      FindDTM(DTM_Smith, t, u, 524, 3, 762, 168)
      Dist_To_Symbol := Distance(X,Y,643,83);
      Dist_To_House := Distance(c,b,643,83);
      Dist_To_Smith := Distance(t,u,643,83);
      //Writeln('Current Distance from Bank symbol:' + ToStr(Dist_To_Symbol))
      //Writeln('Current Distance from House symbol:' + ToStr(Dist_To_House))
      //Writeln('Current Distance from Smithing symbol:' + ToStr(Dist_To_Smith))
      If (Dist_To_Symbol <= 30) And
      (Dist_To_House <= 90) And
      (Dist_To_Smith <= 90) Then
      Begin
        Status := 'Inside of the Bank'
        Result := true;
      End;
    End;


    So my whole Program looks like this (if you want to tweak it)

    Simba Code:
    {$i srl/srl.simba}
    Var
      X,Y,DTM_House,DTM_Bank,DTM_Smith:Integer;
      //IsInBank:Boolean;
      Status:String;
    Procedure WriteStatus;
    Begin
      Wait(400);
      ClearDebug;
      Writeln('Status:' + status);
    End;
    Procedure FreeMem;
    Begin
      FreeDTM(DTM_Bank);
      FreeDTM(DTM_House);
      FreeDTM(DTM_Smith);
    End;
    Procedure LoadDTM;
    Begin
      DTM_Bank := DTMFromString('mQwAAAHicY2ZgYEhgYmBIAeJwIE4D8jOBOBmI31xMYGBmFAVjfiAfhhmRMBAAANchBNY=');
      DTM_House := DTMFromString('mWAAAAHicY2FgYOhnYmCYDMSdQDwViIOBYr5A7A/EYUDMzCiKgvmBYsiYEQ2DAAAaywQ2');
      DTM_Smith := DTMFromString('mrAAAAHic42BgYHBgYmBwB2JHKHYDYlcgdgFiOyC2ZYBgFyA2A2IrIHYCYnMgdgWx7YIYmBlFseK8nGQGfqAafJiRAIYBADx3B0A=');
    End;
    function IsInBank(): boolean;
    var
       Dist_To_Symbol,c,b,t,u,Dist_To_House,Dist_To_Smith:Integer;
    Begin
      Status := 'Outside of the bank'
      Result := false;
      FindDTM(DTM_Bank, x, y, 524, 3, 762, 168)
      FindDTM(DTM_House, c, b, 524, 3, 762, 168)
      FindDTM(DTM_Smith, t, u, 524, 3, 762, 168)
      Dist_To_Symbol := Distance(X,Y,643,83);
      Dist_To_House := Distance(c,b,643,83);
      Dist_To_Smith := Distance(t,u,643,83);
      //Writeln('Current Distance from Bank symbol:' + ToStr(Dist_To_Symbol))
      //Writeln('Current Distance from House symbol:' + ToStr(Dist_To_House))
      //Writeln('Current Distance from Smithing symbol:' + ToStr(Dist_To_Smith))
      If (Dist_To_Symbol <= 30) And
      (Dist_To_House <= 700) And
      (Dist_To_Smith <= 700) Then
      Begin
        Status := 'Inside of the Bank'
        Result := true;
      End;
    End;
    Begin
      LoadDTM;
      Repeat
      IsInBank;
      WriteStatus;
      Until False;
      AddOnTerminate('FreeMem');
    End.
    Now you are done!


    If you have any questons, feel free to post them here. If you have a suggestion for me to explain my thoughts better PLEASE post them, because I am not the best tutorial writer out there

  2. #2
    Join Date
    Aug 2007
    Location
    Oregon, USA
    Posts
    4
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Oo, I like this method. Bookmarked for later use!

  3. #3
    Join Date
    Nov 2011
    Location
    Sacramento, California
    Posts
    366
    Mentioned
    4 Post(s)
    Quoted
    85 Post(s)

    Default

    I was trying to figuire out yesterday how to do this. Thanks for the guide!

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

    Default

    What about using the NPCs? Since they don't move, or if they do I assume it would be less than the symbols. Just a suggestion! Either or like I said in the other topic I like this function. Gonna play with it and post some results.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  5. #5
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Element17 View Post
    What about using the NPCs? Since they don't move, or if they do I assume it would be less than the symbols. Just a suggestion! Either or like I said in the other topic I like this function. Gonna play with it and post some results.
    There's more then 1 NPC dot and it might give you unwanted results by giving you the distance to a dot that you don't want

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

    Default

    Ahhh good point.
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  7. #7
    Join Date
    Feb 2013
    Posts
    303
    Mentioned
    4 Post(s)
    Quoted
    124 Post(s)

    Default

    Thiss will help me out For Sure Thanks

  8. #8
    Join Date
    Feb 2012
    Location
    Discord
    Posts
    3,114
    Mentioned
    37 Post(s)
    Quoted
    538 Post(s)

    Default

    You could use symbol finding functions instead of having to make a dtm

  9. #9
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,164
    Mentioned
    26 Post(s)
    Quoted
    433 Post(s)

    Default

    This is awesome! I will make sure that i use this the next time that i need to make a script that involves a lot of walking.

  10. #10
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by The Killer View Post
    You could use symbol finding functions instead of having to make a dtm
    I'm so used to making my own DTM's

  11. #11
    Join Date
    Feb 2012
    Location
    Discord
    Posts
    3,114
    Mentioned
    37 Post(s)
    Quoted
    538 Post(s)

    Default

    Quote Originally Posted by RJJ95 View Post
    I'm so used to making my own DTM's
    Yeah fair enough, I'm just saying it's something you could add

  12. #12
    Join Date
    Dec 2011
    Posts
    170
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Nice and useful guide!
    Will make use of this in my next script probably.

  13. #13
    Join Date
    Jun 2007
    Location
    south park
    Posts
    1,160
    Mentioned
    0 Post(s)
    Quoted
    62 Post(s)

    Default

    Could I use this in rogues den when theres only one symbol and that's the bank?
    http://www.youtube.com/user/YoHoJoSRL
    Good scripting guides on youtube
    Formerly known as (djcheater)

  14. #14
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by randy marsh View Post
    Could I use this in rogues den when theres only one symbol and that's the bank?
    Yes.

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
  •