WHEAT FARMER TUTORIAL
This is a tutorial on writing simple SCAR scripts.
As an example I show you how to write simple wheat farmer with an explanations on each part of the script,
so novice scripters will have the basycs on SCAR scripting.
Every SCAR script must start with a name, then we have to declare on some parameters we use in our script.
It is easy to find color with SCAR so the commands we will use will find that color code and the position where it was
found they write into variables. Each position on our monitor will have the X and Y parameter
so we will declare them in a variable section of our script, and the part of the code will looks like thatCODE
program wheat_farmer;
var
x, y: integer;
Second part of our script will be constants.
It is much easy to declare constants and then use them in the script,
so you have to change each parameter only once in a script.
Our constants will be farming time of our character, color code of level up pop up window,
color code of wheat, upper and lower X and Y coordinates of farming area and trade/challenge pop up window coordinates.
To change numbers in constant part of the script use color picker button in SCAR and then change the numbers.
Constant part of our script will look like thatCODE
const
farm_time = 13000; // farming time in milliseconds(13 seconds)
levell = 25087; // level up window color
wheat = 24985; // wheat color
ignore_x = 100; // X coordinate of ignore player line in trade/challenge/invite guild window
ignore_y = 100; // Y coordinate of ignore player line in trade/challenge/invite guild window
area_xu = 18; // upper X coordinate of farming area
area_yu = 85; // upper Y coordinate of farming area
area_xd = 693; // lower X coordinate of farming area
area_yd = 451; // lower Y coordinate of farming area
Third part of our script will be functions.
We use functions to make some actions in our scripts, like find wheat color or pop up level up window color and more.
In our script we will use functions to find wheat and level up/trade/challenge/invite guild pop up window.
Our functions are boolean meaning it will be true if we find what we need and false if not.CODE
function wheat1 : Boolean;
begin
if(FindColor(x, y, wheat, area_xu, area_yu, area_xd, area_yd))then result:= true
end;
function Leveled : Boolean;
begin
if(FindColor(x, y, levell, area_xu, area_yu, area_xd, area_yd))then result:= true
end;
Next part of our script will be procedures.
Procedures are programs inside program.
It helps to cut much larger scripts into smaller one and helps to easy manipulate with script.
Procedure we use in this script actually farms wheat.
What this procedure do is use function to find wheat, if it is true then it clicks on X and Y parameter of wheat and harvest it.
To avoid problem of being stucked in one place and do nothing when script finds wheat behind our character,
the procedure force our character run to some location on the map after it harvest the wheat.CODE
Procedure harvest;
begin
if (wheat1)then
begin
wait(500+random(100));
clickmouse(x+5, y, true);
wait(1000+random(200));
movemousesmooth(x+10, y+30);
wait(1000+random(100));
clickmouse(x+10, y+30, true);
wait(farm_time +random(200)); // farming time. may change during leveling.
movemousesmooth(106,457); // running to some location on map avoiding fail-clicking on wheat
wait(100+random(200));
holdmouse(106,457,true);
wait(20+random(50));
releasemouse(106,457,true);
wait(500+random(100));
end;
end;
Now we came to the body of our script.
Here we check if level up window appears and we run harvest procedure.
The code is infinite and it will stop only if we push the stop script button on SCAR client.CODE
begin
repeat
//---------- gathering wheat and checking profession level up ------------------------
if(leveled) then
begin
clickmouse(ignore_x, ignore_y, true); // if we got trade/challenge/guild invite window then ignore that player
wait(1000);
clickmouse(x, y, true);
wait(1000);
end;
wait(10);
harvest;
until(false);
end.
It is very important to not change default window size of DOFUS client, so your parameters
won't change every time you start your script.
Before starting script mark DOFUS as a client by SCAR using marker button ( looks like target button on SCAR ).
Ok, so we finish our script and if you did it right your script should be like thisCODE
{
**************** INSTRUCTIONS *****************************************
**** IMPORTANT: DO NOT CHANGE DOFUS DEFAULT WINDOW SIZE !!! ****
1. Select dofus as a client by scar.
2. Make apropriate changes in constant part of script.
3. Run script.
4. Enjoy.
}
program wheat_farmer;
var
x, y: integer;
const
farm_time = 13000; // farming time in milliseconds
levell = 25087; // level up window color
wheat = 24985; // wheat color
ignore_x = 100; // X coordinate of ignore player line in trade/challenge/invite guild window
ignore_y = 100; // Y coordinate of ignore player line in trade/challenge/invite guild window
area_xu = 18; // upper X coordinate of farming area
area_yu = 85; // upper Y coordinate of farming area
area_xd = 693; // lower X coordinate of farming area
area_yd = 451; // lower Y coordinate of farming area
function wheat1 : Boolean;
begin
if(FindColor(x, y, wheat, area_xu, area_yu, area_xd, area_yd))then result:= true
end;
function Leveled : Boolean;
begin
if(FindColor(x, y, levell, area_xu, area_yu, area_xd, area_yd))then result:= true // searching for level up window
end;
Procedure harvest;
begin
if (wheat1)then
begin
wait(500+random(100));
clickmouse(x+5, y, true);
wait(1000+random(200));
movemousesmooth(x+10, y+30);
wait(1000+random(100));
clickmouse(x+10, y+30, true);
wait(farm_time +random(200)); // farming time. may change during leveling.
movemousesmooth(106,457); // running to some location on map avoiding fail-clicking on wheat
wait(100+random(200));
holdmouse(106,457,true);
wait(20+random(50));
releasemouse(106,457,true);
wait(500+random(100));
end;
end;
begin
repeat
//---------- gathering wheat and checking profession level up ------------------------
if(leveled) then
begin
clickmouse(ignore_x, ignore_y, true); // if we got trade/challenge/guild invite window then ignore that player
wait(1000);
clickmouse(x, y, true);
wait(1000);
end;
wait(10);
harvest;
until(false);
end.