O-U-T-D-A-T-E-D-!
Hello! Im Torrent, You may recognise me for my work on updating older Tutorials, more recently my one on the PowerMiner update, which is why some of those words found in the PowerMiner tutorial will be found here, as they are 100% relevant!
Well, Im here now to create one on Woodcutting, I already have a Chopping and Banking Tutorial out there, and this will show you how to take into account the fact you have to walk to the bank, and walk back to the willows.
The original guide by The_Rs_Monkey is found here: http://www.villavu.com/forum/showthread.php?t=16602
If you like this Tutorial, please, Spread the Word, Rep Me, or Rank The Thread!!
Thanks In Advance.
Anyway...
Welcome to the Updated Guide to Making a Woodcutter!
This tutorial will include:
- Walking
- Banking
- Cutting
- Switching Players
- FailSafes
- Main Looping
- The basic part of using BankPins!
- Constants and Variables
- The Necessity of Descriptions!
To Start we should name the the program that we are going to use, calling it something significant to the program you are going to make:
SCAR Code:
program MyFirstWoodCutter;
Then you HAVE to include this part, as it controls everything that we need to use in this script (FindObjCustom, etc.), aswell as Including WoodCutting.scar (Incase we need find axe, find ent, etc. which we wont in this tutorial, but its always a good thing to have)
SCAR Code:
{.include SRL/SRL.scar}
{.include SRL/SRL/Skill/WoodCutting.scar}
The we include our constants. Constants are basically what they say they are, something that is ALWAYS the same, like RockColours, TreeColours, SMART Worlds, etc.
SCAR Code:
const
//-->Loads<--\\
Loads = 10; //How many loads per player before switching
//--->SRL ID<---\\
YourSRLId = '';
YourSRLPassword ='';
//--->Pin - Make same for ALL chars. If no Pin, leave blank<---\\
YourPin = '';
These are our constants, note that we have a description above them, telling our script user what the constant is for, and giving more information next to them if needed. We see that we have Loads, SRLId's and Bank Pins. I will cover all of these later.
Then we have to declare our variables, not variables again explain themselves, something that is a variable, can constantly change. The variables in this case are the x and the y, the co-ordinates on the game screen. It is an "integer" as they are co-ordinates, which are numerical. Tries will be explained later.
SCAR Code:
var x, y, LoadsNum, LoadsNum2: integer;
Then we have to declare our variables, not variables again explain themselves, something that is a variable, can constantly change. The variables in this case are the x and the y, the co-ordinates on the game screen. It is an "integer" as they are co-ordinates, which are numerical. LoadsNum and LoadsNum2 are integers aswell, but these will be explained later on.
Then we have our first procedure. I will explain the procedure after we see the overview.
SCAR Code:
{-------------------------------------------------------
Player Setup
--------------------------------------------------------}
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer:= 0
Players[0].Name := 'Username';
Players[0].Pass := 'Password';
Players[0].Nick := 'erna';
Players[0].Active := True;
end;
{----------------------------Do Not Edit Below This----------------------------}
Procedure DeclarePlayers tells us the name of the procedure that we are using. Begin starts the procedure [Every "Begin" has an "End", Every "Repeat" has an "Until" and Every "If" has a "Then" - Follow this and it should stop "Idenfitifer Expected ]. How Many Players means how many players we are going to use, and Current player tells us which player to start with. Username, Password are pretty basic, but the Nickname HAS to be 3-4 letters of non-capital or without a space of your Username, like mine is. The Active = True tells us if the player is to be run in the script or not. Note again the description, it tells us that we should set up our players here, and then not edit below the next line. We would put our variables under here to be safe, but I introduced them earlier just to be with the constants. In our final script you will see the variables under the "Do Not Edit..." part.
Now we have our AntiBan and AntiRandoms, but again Im not going to go into details about them, as I have written a Tutorial about them found here: http://www.villavu.com/forum/showthread.php?t=27515
SCAR Code:
Procedure AntiRandoms;
begin
If(FindFight)then
RunAway('N', True,1,15000);
FindNormalRandoms;
FindLamp('Woodcutting');
end;
And our AntiBan:
SCAR Code:
procedure AntiBan;
begin
if not LoggedIn then Exit;
case Random(30) of
1: RandomRClick;
2: HoverSkill('Woodcutting', False);
3: RandomMovement;
4: BoredHuman;
5: AlmostLogout;
6: DoEmote(400 +Random(90));
end;
end;
Now onto our actual WoodCutting procedure. This part will be merged with an explanation of Fail Safes:
SCAR Code:
//---------------------------------ChopTree-----------------------------------\\
procedure ChopTree;
var CuttingTime: integer;
Tries: integer;
begin
MarkTime(CuttingTime);
MakeCompass('S');
repeat
if FindObjCustom(x, y, ['Wil', 'low'], [1989969, 3760987, 2844763], 7)) then
begin
Mouse(x,y,0,0,false);
if(IsUpText('Chop'))then
Wait(5000 + (random(150)));
ChooseOption('hop')
AntiBan;
if (not (FindObjCustom(x, y, ['Wil', 'low'], [1989969, 3760987, 2844763], 7))) then
Wait(100+random(100));
Tries := Tries + 1;
if(Tries = 50)then
begin
Writeln ('Willow Logs not found. Switching Players..');
Logout;
NextPlayer(False);
Exit;
end;
end;
until(InvFull) or (TimeFromMark(CuttingTime) > 800000+random(60000));
end;
Now this part looks very daunting. But we can break it down bit by bit.
We have the description at the top, this is for you more than anyone else, so when you need to find your procedure to do some editing, you can find it alot easier! [It is basically a NEED to be neat with scripts, untidy scripts are often less read as people cant be bothered to look through it, as it is alot harder to do.]
We name our procedure, like always.
We then declare two unique variables, as in, they are only used in this procedure, so I dont need to declare them at the top as Global Variables [Right word?]
SCAR Code:
var CuttingTime: integer;
Tries: integer;
These will be explained later on.
SCAR Code:
begin
MarkTime(CuttingTime);
MakeCompass('S');
We begin the procedure, as always, and it Marks the time that the script starts to cut. It makes the compass face South (Needs to in my script..)but you could make it face Notrh, or whatever, or even just take it out.
SCAR Code:
repeat
if FindObjCustom(x, y, ['Wil', 'low'], [1989969, 3760987, 2844763], 7)) then
begin
Mouse(x,y,0,0,false);
if(IsUpText('Chop'))then
Wait(5000 + (random(150)));
ChooseOption('hop')
AntiBan;
Repeat, it repeats the procedure as a whole. If it finds an object called 'Willow' with those 3 colours, and with a tolerance of 7. If it does find it it will move over it, and it the 'Chop' is up in the corner of the screen, it will wait 5-5.15 seconds, and chops it. It will then AntiBan whilst you are chopping.
SCAR Code:
if (not (FindObjCustom(x, y, ['Wil', 'low'], [1989969, 3760987, 2844763], 7))) then
Wait(100+random(100));
Tries := Tries + 1;
if(Tries = 50)then
Writeln ('Willow Logs not found. Switching Players..');
Logout;
NextPlayer(False);
end;
This is our First Failsafe! If it doesnt find the object willow, it waits 0.2 seconds, and adds 1 to the integer Tries. If it tries 50 times then it will write that statement in our debug box, and logout, moving onto the next player but leaving the player inactive, so it will not run this character again. It then ends the part of the procedure.
Then our Final bit. I bet your like? Cutting Time? HUH?
Lets explain it now.
SCAR Code:
until(InvFull) or (TimeFromMark(CuttingTime) > 800000+random(60000));
end;
So, the until part goes with the repeat at the start of the procedure. It will repeat this procedure until it has a Full Inventory, or until it Finds that our Integer "Cutting Time" is about 140-150 minutes. (A bit long I know but you never know how long it could take to get a full inventory?)
Now we move onto our Walk to bank procedure.
SCAR Code:
//----------------------Walking from Willows to Bank--------------------------\\
procedure WalkToBank;
begin
if (not(LoggedIn)) then
Exit;
SymbolAccuracy:= 0.2;
MakeCompass('N');
if (FindSymbol(x, y, 'bank')) then
begin
Mouse(x, y, 2, 2, true);
FFlag(0);
Writeln('Got to bank');
end;
end;
Well, we tell ourselves what our procedure is in the description, and name the procedure. A failsafe first, if we are not logged in, we will exit the script. It gives a SymbolAccuracy of 0.2, so is very accurate. It will make the compass face North, like it has to in my script. If it finds the Bank Symbol on the X and the Y axis, and then it says "FFlag". I took this description straight from the SRL Manual:
procedure FFlag(Distance: Integer);
By: Wizzup? / WT-Fakawi.
Description:
Waits until Flag is within "Distance" distance.
Seeing as my distance is "0", It waits until the Flag has disappeared, but this is useful for walking on roads as a failsafe, as you dont always wait to get to the flag all the time.
It then writes "Got To Bank" in our Debug Box, then ends the part of the procedure, and ends the procedure.
You could use RadialWalking, or anything of the sort, Failsafes with DTM's, but this is for beginners and I dont think it is necissary to get inot too much detail about those at the moment.
Now onto the banking procedure. I took this part out of my Tutorial on Chopping and banking:
SCAR Code:
procedure Banking
begin
if (InvFull) then
begin
MakeCompass('W')
Wait (300 + random(160));
OpenBankQuiet('db');
if (PinScreen) then
InPin(YourPin);
if(FindColorSpiral(x, y, 4155248, 547, 206, 734, 464))then
begin
Mouse(x, y, 4, 3, false);
ChooseOption('All');
Result := True;
if Result = True then
begin
LoadsNum := LoadsNum + 1;
LoadsNum2 := LoadsNum2 + 1;
ReportVars[1] := ReportVars[1] + 1;
SendSRLReport;
end;
end;
CloseBank;
Wait(150 + random (278));
MakeCompass('S');
end;
end;
So! Lets start.
SCAR Code:
procedure Banking
begin
if (InvFull) then
We name our procedure, as par usual. We then begin it [Man this gets harder and harder..] and then it checks if the inventory is full. If it is full...
SCAR Code:
begin
MakeCompass('W')
Wait (300 + random(160));
OpenBankQuiet('db');
...then it begins, makes the compass "West" to face the bank, (in Draynor its West..) and waits 300-460 milliseconds. IT then opens the Bank 'Quiet'. This is a procedure that is a little more laggy, but is omre human like. The 'Db' tells us what bank we are at, so it could be VWB, VEB, Go figure.
SCAR Code:
if (PinScreen) then
InPin(YourPin);
if(FindColorSpiral(x, y, 4155248, 547, 206, 734, 464))then
If the script detects a pin screen it will InPin(YourPin). The YourPin is the constant we set up at the beginning of the script. This could be something like this if we wanted to add it to the declare players:
SCAR Code:
Players[0].Integers[0] := 0000;
Then we could put the InPin(YourPin) as InPin(Players[0].Integers[0]) [I Think??]
And then if it finds the Colour of the Willow Logs (In Mine..) on the X and Y axis, in the coordinate box of the inventory, it will...
SCAR Code:
begin
Mouse(x, y, 4, 3, false);
ChooseOption('All');
Result := True;
if Result = True then
begin
LoadsNum := LoadsNum + 1;
LoadsNum2 := LoadsNum2 + 1;
ReportVars[1] := ReportVars[1] + 1;
SendSRLReport;
end;
end;
CloseBank;
Wait(150 + random (278));
MakeCompass('S');
end;
end;
...begin another part of the procedure. It moves over the Logs, and chooses the option "All" like a player would.
Now, whats that part underneath? Well this is the SRL Stats part. Im not going to go into this part, but I will link you to an indepth tutorial that looks at exactly this, by Hy71194: http://www.villavu.com/forum/showthread.php?t=27772
Now we have the LoadsNum and LoadsNum2. This will come into effect later on in the script when we start on the main loop, so we can ignore this for now.
It then ends this part, closes the Bank, waits about 0.4 seconds, and makes the compass South ready to walk back to our Draynor willows. It then ends the procedure.
Walking back to the willows..
SCAR Code:
procedure WalkToWillow;
begin
if (FindSymbol(x, y, 'fish')) then
begin
Mouse(x, y, 2, 2, true);
FFlag(0);
Writeln('Got to Willows');
end;
end;
Nice and basic :]. We name it, begin it, if it finds the fish symbol, it clicks it, it gets to the flag, makes the compass east, writes Got To Willows in the debug box and ends it. Simple as
NOW.... Onto our Main Loop!
Lets first setup our Script, with a little bit before our main loop, this saves on the size of our main loop.
Lets make it shall we?
SCAR Code:
procedure SetupScript;
begin
SRLId := YourSRLId;
SRLPassword:= YourSRLPassword;
SetupSRL;
ScriptID:= '687';
DeclarePlayers;
end;
Sends your SRL Id/Password, sets up SRL so that it can run faster. And The script ID is covered in Hy's tutorial on SRL Stats. We then Declare our Players and end the Setup.
Now ONTO our Main Loop..
SCAR Code:
begin
SetupScript;
repeat
WalkToWillow;
ChopTree;
AntiBan;
WalkToBank;
Banking;
if (LoadsNum2=Loads) then
begin
NextPlayer(True);
LoadsNum2 := 0;
MakeCompass('S')
Writeln('Players Switched successfully')
end;
until (false)
end.
So, a little more complicated then it seems.
SCAR Code:
begin
SetupScript;
repeat
WalkToWillow;
ChopTree;
AntiBan;
WalkToBank;
Banking;
IT begins by doing SetupScript, then Repeats the WalkToWillow, ChopTree, AntiBanning, Walking to the Bank and Banking.
SCAR Code:
if (LoadsNum2=Loads) then
begin
NextPlayer(True);
LoadsNum2 := 0;
MakeCompass('S')
Writeln('Players Switched successfully')
Now remember earlier I said that we should ignore the LoadsNum2 but for now? Well now we use it. If the LoadsNum2 = The Loads we setup to do at the constants at the start, it will begin by Logging in the Next Player, making sure that this player is True, IE, it will always repeat. It makes the LoadsNum2 = 0 again so that it doesnt logout instantly, and makes the compass south, writing in the Debug box "Players switched sucessfully'"
Now when we compile this whole script together we can finally have our FIRST Script:
SCAR Code:
{/\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
| WoodCutter Tutorial by Torrent of Flame |
| For educational use ONLY |
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\}
program MyFirstWoodCutter;
{.include SRL/SRL.scar}
{.include SRL/SRL/Skill/WoodCutting.scar}
const
//-->Loads<--\\
Loads = 10; //How many loads per player before switching
//--->SRL ID<---\\
YourSRLId = '';
YourSRLPassword ='';
//--->Pin - Make same for ALL chars. If no Pin, leave blank<---\\
YourPin = '';
{-------------------------------------------------------
Player Setup
--------------------------------------------------------}
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer:= 0
Players[0].Name := 'Username';
Players[0].Pass := 'Password';
Players[0].Nick := 'erna';
Players[0].Active := True;
end;
{----------------------------Do Not Edit Below This----------------------------}
var x, y, LoadsNum, LoadsNum2: integer;
//-----------------------------AntiRandoms/AntiBan----------------------------\\
Procedure AntiRandoms;
begin
If(FindFight)then
RunAway('N', True,1,15000);
FindNormalRandoms;
FindLamp('Woodcutting');
end;
procedure AntiBan;
begin
if not LoggedIn then Exit;
case Random(30) of
1: RandomRClick;
2: HoverSkill('Woodcutting', False);
3: RandomMovement;
4: BoredHuman;
5: AlmostLogout;
6: DoEmote(400 +Random(90));
end;
end;
//---------------------------------ChopTree-----------------------------------\\
procedure ChopTree;
var CuttingTime: integer;
Tries: integer;
begin
MarkTime(CuttingTime);
MakeCompass('S');
repeat
if FindObjCustom(x, y, ['Wil', 'low'], [1989969, 3760987, 2844763], 7) then
begin
Mouse(x,y,0,0,false);
if(IsUpText('Chop'))then
Wait(5000 + (random(150)));
ChooseOption('hop')
AntiBan;
if (not (FindObjCustom(x, y, ['Wil', 'low'], [1989969, 3760987, 2844763], 7))) then
Wait(100+random(100));
Tries := Tries + 1;
if(Tries = 50)then
begin
Writeln ('Willow Logs not found. Switching Players..');
Logout;
NextPlayer(False);
Exit;
end;
end;
until(InvFull) or (TimeFromMark(CuttingTime) > 800000+random(60000));
end;
//----------------------Walking from Willows to Bank--------------------------\\
procedure WalkToBank;
begin
if (not(LoggedIn)) then
Exit;
SymbolAccuracy:= 0.2;
MakeCompass('N');
if (FindSymbol(x, y, 'bank')) then
begin
Mouse(x, y, 2, 2, true);
FFlag(0);
Writeln('Got to bank');
end;
end;
//--------------------------------Banking-------------------------------------\\
procedure Banking;
begin
if (InvFull) then
begin
MakeCompass('W')
Wait (300 + random(160));
OpenBankQuiet('db');
if (PinScreen) then
InPin(YourPin);
if(FindColorSpiral(x, y, 4155248, 547, 206, 734, 464))then
begin
Mouse(x, y, 4, 3, false);
ChooseOption('All');
begin
LoadsNum := LoadsNum + 1;
LoadsNum2 := LoadsNum2 + 1;
ReportVars[1] := ReportVars[1] + 1;
SendSRLReport;
end;
end;
CloseBank;
Wait(150 + random (278));
MakeCompass('S');
end;
end;
//Willows to Bank\\
procedure WalkToWillow;
begin
if (FindSymbol(x, y, 'fish')) then
begin
Mouse(x, y, 2, 2, true);
FFlag(0);
Writeln('Got to Willows');
end;
end;
//SetupScript\\
procedure SetupScript;
begin
SRLId := YourSRLId;
SRLPassword:= YourSRLPassword;
SetupSRL;
ScriptID:= '687';
DeclarePlayers;
end;
//THE MAIN LOOPAGE!\\
begin
SetupScript;
repeat
WalkToWillow;
ChopTree;
AntiBan;
WalkToBank;
Banking;
if (LoadsNum2=Loads) then
begin
NextPlayer(True);
LoadsNum2 := 0;
MakeCompass('S')
Writeln('Players Switched successfully')
end;
until (false)
end.
Thanks to Pwnt for the Fix.
Thanks for Reading!!!