Its time to learn more than just the basics of SCAR! Everything in this post shouldn't be hard to learn so sit back and get ready to learn.
Useful SRL Constants to Know
In the SRL include, there are some usefull constants for you to know. There's constants like the mainscreen center coordinates, the centre of the mainscreen coordinates, etc.
Useful Constants:
- MSX1 - The X coordinate of the top-left corner of the RuneScape mainscreen
- MSY1 - The Y coordinate of the top-left corner of the RuneScape mainscreen
- MSX2 - The X coordinate of the bottom-right corner of the RuneScape mainscreen
- MSY2 - The Y coordinate of the bottom-right corner of the RuneScape mainscreen
- MSCX - The X coordinate of the centre of the RuneScape mainscreen
- MSCY - The Y coordinate of the centre of the RuneScape mainscreen
- MMX1 - The X coordinate of the top-left corner of the RuneScape minimap
- MMY1 - The Y coordinate of the top-left corner of the RuneScape minimap
- MMX2 - The X coordinate of the bottom-right corner of the RuneScape minimap
- MMY2 - The Y coordinate of the bottom-right corner of the RuneScape minimap
- MMCX - The X coordinate of the centre of the RuneScape minimap
- MMCY - The Y coordinate of the centre of the RuneScape minimap
- MCX1 - The X coordinate of the top-left corner of the RuneScape chat box
- MCY1 - The Y coordinate of the top-left corner of the RuneScape chat box
- MCX2 - The X coordinate of the bottom-right corner of the RuneScape chat box
- MCY2 - The Y coordinate of the bottom-right corner of the RuneScape chat box
- MCCX - The X coordinate of the centre of the RuneScape chat box
- MCCY - The Y coordinate of the centre of the RuneScape chat box
Cases
A case is a structured equivalent to a sequence of "if" statements on the same variable. A lot of "if" statements will make a script go slow. Using cases makes scripts go faster without checking every "if" statement and will make scripts cleaner and neater.
Here is an example:
SCAR Code:
if (LastLineText = 'hello') or (LastLineText = 'hey') or (LastLineText = 'hi') then SayHey else
if (LastLineText = 'wc?') then SayWc else
if (LastLineText = 'mining?') then SayMining else
if (LastLineText = 'smithing?') then SaySmithing else
if (LastLineText = 'strength?') then SayStrength;
Now lets transform all of those "if" statements into a case!
SCAR Code:
case LastLineText of
'hello', 'hey', 'hi': SayHey;
'wc?': SayWC;
'mining?': SayMining;
'smithing?': SaySmithing;
'strength?': SayStrength;
end;
Cleaner and more efficient!
Now it's time for me to explain.
"case" would be saying to SCAR that you are starting a case. LastLineText is the variable.
"of" would be make SCAR start checking if the variable matches any of the possible cases.
"'hello', 'hey', 'hey'" are 3 of the possibilities of the variable.
":" tells SCAR what to do if any of the cases match the variable.
"SayHey;" would be what SCAR does if any of the cases match the variable.
"end;" tells SCAR that you are ending the case.
Cases (aka Possibilities as I sometimes call them) can be alone or joined with a coma. If the variable is an integer, you could join cases with a "..". Ex:
SCAR Code:
case Number of
0..100: Writeln(IntToStr(Number));
end;
The above would be "if the variable "number" is anything from 0 to 100 then write the variable "number"".
Loops
Almost every RuneScape scripts need loops! Loops will let you repeat functions / procedures over and over again until you want to stop looping.
There are 3 ways of making loops. Using "repeat...until", "while do", "for...to...do".
Using "repeat...untill"...
This is the most common loop out there. Using this will repeat until a it is told to stop.
Example:
SCAR Code:
repeat
Wait(100);
until False;
The "until False" part of the loop means the loop will never stop. You can change "False" with a condition of your own like "(not LoggedIn)" or "(i = 10)".
Using "while...do":
Using this will repeat while the condition is what you want to repeat to.
Example:
SCAR Code:
while IsMoving do
begin
Wait(1000);
Writeln('We are still moving');
end;
If there is only one action, just removing the "begin" and "end;".
Using "for...to...do":
Using this will repeat will be like "for an integer to another integer do this".
Example where I is an integer:
SCAR Code:
for I := 0 to 10 do Writeln(IntToStr(I));
You could also go from a larger number downto a smaller number by replacing "to" with "downto".
SCAR Code:
for I := 10 downto 0 do Writeln(IntToStr(I));
Why don't you give it a try? Put everything together that you know so far into a script that counts!
Remember that all loops keep repeating until they are done or or told to stop repeating.
Using "Break;" will break out of the loop.
Using "Exit;" will break out of the loop and exit out of the function or procedure that is being used.
Using "Continue;" will stop the loop wherever it is and go to the beginning of the loop.
I hope you now have a basic understanding of loops. Its time to move on.
AntiBan and AntiRandoms
Every script needs AntiBan and AntiRandoms! If you don't know what those are then I'll tell you. AntiBan are a set of random human like procedures / functions. AntiBan will make your script less detectable.
Here is a basic AntiBan procedure put together by me!
SCAR Code:
procedure AntiBan;
begin
if (not T_LoggedIn) then Exit;
AutoRespond;
FindNormalRandoms;
case Random(20) of //Chooses a random procedure to do below
0: HoverSkill('random'); //Hovers a random skill
1: PickupMouse; //Simulates a human picking up their mouse
2: RandomRClick; //Does a random right click
3: ExamineInv;
4:
begin
DoEmote(Random(20)+1); //Does an emote
Wait(RandomRange(1000, 1500));
end;
5: GameTab(tab_Friends); //Goes to the friends game tab
//If the random number is greater than 5, then SCAR won't do anything
//If SCAR does something every time this was called, it might look like a bot
end;
end;
To find more AntiBan functions go to "includes\SRL\SRL\core\AntiBan.scar".
Make sure you call AntiBan every so often.
AntiRandoms makes SCAR / SRL find if you are in a random event then will attempt to solve it if you are in one.
Just call "FindNormalRandoms;" to check for randoms!
Declare Players
Before you try to make a RuneScape script, you must know about the "DeclarePlayers" procedure. It is a procedure that loads your RuneScape characters to be used in the script.
Be sure to put your "DeclarePlayers" procedure near the top of the script so the user doesn't have to search your script for it.
Here is a basic "DeclarePlayers" procedure:
SCAR Code:
procedure DeclarePlayers;
begin
HowManyPlayers := 1; //How many players to be ran in the script
NumberOfPlayers(HowManyPlayers); //Tells SRL how many players are to be ran
CurrentPlayer := 0; //The first player to load up
Players[0].Name :='Zezima'; //Character Name
Players[0].Pass :='myPassword'; //Character Pass
Players[0].Nick :='ima'; //Nickname 3 - 4 Letter's of char name
Players[0].Active := True; //To be ran in the script?
end;
Failsafes
Every RuneScape script needs to have fail safes. If you don't know already, failsafes are used if a function has failed to do its task. If the function fails, the failsafe will begin so that the character doesn't get stuck somewhere.
How would you use a failsafe? Here is an example:
SCAR Code:
if DTMRotated(DDTMWalk(1),x,y,MMX1,MMY1,MMX2,MMY2) then
begin
Mouse(x,y,0,0,true);
Flag;
Wait(500+Random(250));
end else
if RadialRoadWalk(FindWallColor, 304, 330, 62, -1, 0) then
begin
Flag;
Wait(500+Random(250));
end;
That code segment will try to walk to a wall using a DDTM that is allowed to be rotated. If the script can't find the DDTM, the failsafe will kick in and the script will try to "RadialRoadWalk".
Everything after the "else" is the failsafe.
Color Finding
Since SCAR is a color finding program, you will absolutely need to learn how to find colors! Don't you worry though, color finding is a breeze.
The main color finding functions are: FindColor, FindColorSpiral, FindColorSpiralTolerance and FindColorTolerance.
FindColor just finds a color like reading a book. Searching left to right then moving a pixel down and searching left to right and... you get the drift.
Once the function finds the first color, the result will be that color's coordinates.
FindColorSpiral finds a color by moving in a spiral motion from the center of your screen.
Once the function finds the first color, the result will be that color's coordinates.
By adding "Tolerance" to the end of the function name for both of those functions, you can make those functions find a color with tolerance. Tolerance is the amount of pixels the color can be off while searching for a color.
Since RuneScape colors are dynamic, it would be best if you set a tolerance from 2-20. You shouldn't set the tolerance too high because if you do, you'll get colors that you don't want. If you set the tolerance to 255 (the max tolerance for CTS (color tolerance speed) 1), every pixel on the RuneScape client will become a result when color finding.
Low down of the functions:
SCAR Code:
FindColor(var x, y: Integer; Color, xs, ys, xe, ye: Integer): Boolean;
FindColorTolerance(var x, y: Integer; Color, xs, ys, xe, ye, Tol: Integer): Boolean;
FindColorSpiral(var x, y: Integer; Color, xs, ys, xe, ye: Integer): Boolean;
FindColorSpiralTolerance(var x, y: Integer; Color, xs, ys, xe, ye: Integer; Tolerance: Integer): Boolean;
X stands for what variable the "x" coordinate is being stored to.
Y stand for what variable the "y" coordinate is being stored to.
Color is the color you want to find (integer form).
XS is "x start" which I like to call it.
YS is "s start" which I like to call it.
XE is "x end" which I like to call it.
YE is "y end" which I like to call it.
XS, XY, XE and YE should make a rectangle for SCAR to search for the color in.
Tol and Tolerance stands for tolerance.
Object Finding
Color finding and clicking isn't very accurate in RuneScape. You must know how to find objects, which I'm going to show you how to do in this section of the tutorial.
There are many ways / functions to find objects but I'm going to tell you the way I think you shouldn't ever forget. This object finding way moves the mouse over a color and checks if the "uptext" is the object name. This object finding way is mainly used with TPAs which I will explain somewhere more into this tutorial, that is why this object finding way is a must!
How would you do it? First, if you find a certain color then move the mouse over that color and wait for the "uptext" you want. If you don't know what "uptext" is; it's the text in the top left corner in RuneScape when there is an action able to be performed. Next, if the "uptext" is the uptext you want then click where the color was found.
What would that look like?
SCAR Code:
if FindColorTolerance(x, y, 5016396, MSX1, MSY1, MSX2, MSY2) then
if WaitUpText('tree', 1000) then //Waits 1000 ms for the uptext to be "tree"
Mouse(x, y, 10, 10, True);
end;
If you don't know anything about the "Mouse" function, then I'll give you a brief summary. What it does is clicks at a point; either left or right click, depending on if you set "left" to true or false. The two 3rd and 4th integers is the randomness. The 1st and 2nd integers (x, y) is the point to click.
There are some object finding functions in the SRL include if you wish to use them.
I will explain the object finding function I mostly used when I was a beginner. If you wish to know all of the object finding functions, go to Object.scar found in the core folder of the SRL include.
The function I mostly used while I was a beginner was FindObjCustom. It was pretty easy to use so you should get the hang of it.
Here is how you would cut a tree:
SCAR Code:
if FindObjCustom(x, y, ['tre', 'ree'], [4676298, 8741368], 5) then
begin
Mouse(x, y, 3, 3, True);
end;
X and y are the variables that the function stores the coordinates of the first found color to.
['tre', 'ree'] are 2 uptexts that the function will be trying to find and match to the colors.
[4676298, 8741368] are 2 colors that the function is trying to find.
5 is the tolerance.
There you have it, you now know how to find objects!
Adding a Progress Report
Adding a progress report is a very simple thing to do. You just have to use the "Writeln" function and variables, maybe some math too.
First, make a new procedure and call it something like "ProgressReport."
Second, you have to make SCAR write the name of your script and space it out with everything else from your progress report.
Here is an example:
SCAR Code:
Writeln('*****************************************************************************');
Writeln('Cow Fighter v3.1 [SMART] by TRiLeZ');
Writeln('*****************************************************************************');
Next, you'll have to make SCAR write variables and their values. First, start a "Writeln" starting with the variable name or what the variable means. After that, you have to add the variable value after that using a "+" after the name of the variable. Remember to close off the variable name before adding the "+". You may have to use the "IntToStr" function in the variable is an integer.
Ex:
SCAR Code:
Writeln('Logs Cut: ' + IntToStr(Logs));
Do that with every variable you want and there will be your progress report!
I would just like to tell you one more thing, there is a function called " TimeRunning" that will give a result as a string of how long the script has been running.
This is pretty much it for beginners. Study all of this material and play around with SCAR. Why don't you try making your first RuneScape script?