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