Group: Elite Members
Posts: 183
Joined: 26-April 09
Member No.: 893,649
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 that
CODE
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 that
CODE
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 this
**** 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);
Group: Members
Posts: 41
Joined: 26-October 09
Member No.: 1,030,840
Hi, Nice Guide. Just Wondering If Theres A Way To Make The Script Run Between Maps, Ive Been Trying Lately But Cant Seem To Get It To Work, If You Could Help That Would Be Great :D
--------------------
I wouldnt put your IGN here you'll probs get banned I will tell you that im on rushu and f you wanna meet up let me know :D
Group: Elite Members
Posts: 318
Joined: 22-June 09
From: Deep in my Coding Cave. But don't feel bad! After all, it's on the darkside, and we have cookies!
Member No.: 934,937
Well, there are many ways pakkaman. We could spend a bit of brains into making a "super" version that covers automatic detection and map changing. OR, we could hardcode in some specific locations for you, or help you to do that much. If you need an example I'll get to you after my fisher is finished, just had it finished and the file corrupted somehow and I have to restart it from my last hard backup.
The point is, there are many ways to accomplish one task, the way we accomplish it is dependant on how it has to work for you!
--------------------
SCAR Coder
DofusBaseV1 [||||||||||]
Want to make progress bars like me?
CODE
use this base one as an example! [[color="#00FF00"]|[/color][color="#FF0000"]|||||||||[/color]]
Group: Elite Members
Posts: 183
Joined: 26-April 09
Member No.: 893,649
QUOTE(pakkaman @ Nov 4 2009, 09:53 PM)
Hi, Nice Guide. Just Wondering If Theres A Way To Make The Script Run Between Maps, Ive Been Trying Lately But Cant Seem To Get It To Work, If You Could Help That Would Be Great :D
On how to move between maps you may see in my Incarnum wheat farmer in elite section of this forum. When character dies there he runs to farm location, so you may learn on how to write it right. If you want your character to detect map change points 7/11 you have to specify exact location of this point of each map you run through and just blindly click on it in script, otherwise you have to collect all ancama color changes shading during night-morning time and implement it to your script. Good luck.
Group: Elite Members
Posts: 183
Joined: 26-April 09
Member No.: 893,649
QUOTE(arsalan @ Nov 6 2009, 07:42 PM)
yo yo pls mn cn u help me i do all tha stuff u said but my char is standin still as a staue
If your character is standing still, it doesn't find any wheat color. check the following: 1. your dofus resolution on LOW. 2. you didn't make apropriate color picking on wheat color, you should pick wheat color again.
Group: Elite Members
Posts: 318
Joined: 22-June 09
From: Deep in my Coding Cave. But don't feel bad! After all, it's on the darkside, and we have cookies!
Member No.: 934,937
QUOTE(margreg @ Nov 8 2009, 12:01 AM)
If your character is standing still, it doesn't find any wheat color. check the following: 1. your dofus resolution on LOW. 2. you didn't make apropriate color picking on wheat color, you should pick wheat color again.
good luck.
dont forget the mouse COULD be moving to the correct colors, it just may not be clicking there, which is the "no click error" which requires some adjustment of some option in the SCAR client
--------------------
SCAR Coder
DofusBaseV1 [||||||||||]
Want to make progress bars like me?
CODE
use this base one as an example! [[color="#00FF00"]|[/color][color="#FF0000"]|||||||||[/color]]
Group: Elite Members
Posts: 183
Joined: 26-April 09
Member No.: 893,649
QUOTE(lilwitte @ Nov 8 2009, 06:16 PM)
dont forget the mouse COULD be moving to the correct colors, it just may not be clicking there, which is the "no click error" which requires some adjustment of some option in the SCAR client
If he took my script, the adjustment been already implemented in there. The character just runs to some position on the map and then repeat farming, so this isn't the issue.
Group: Elite Members
Posts: 318
Joined: 22-June 09
From: Deep in my Coding Cave. But don't feel bad! After all, it's on the darkside, and we have cookies!
Member No.: 934,937
actually it is, this option CANNOT be set by a script, and is set in and actual (where file... edit, and view drop downs usually are) menu of the SCAR client/program and not the scripts
--------------------
SCAR Coder
DofusBaseV1 [||||||||||]
Want to make progress bars like me?
CODE
use this base one as an example! [[color="#00FF00"]|[/color][color="#FF0000"]|||||||||[/color]]
Group: Members
Posts: 4
Joined: 19-November 09
Member No.: 1,047,925
I create my script and i think this is much better thant it, so here it is:
CODE
var x, y: integer;
function Targetwheat1 : Boolean; begin if(FindColor(x, y, 1232117, 0, 0, 800, 600))then result:= true //<--- copy color number over 1232117 end;
function Targetwheat2 : Boolean; begin if(FindColor(x, y, 679825, 0, 0, 800, 600))then result:= true end;
function Nextwheat1 : Boolean; begin if(FindColor(x, y, 708332, 0, 0, 800, 600))then result:= true end;
function Nextwheat2 : Boolean; begin if(FindColor(x, y, 1061237, 0, 0, 800, 600))then result:= true end;
Procedure Harvest; begin if (Targetwheat1)or(Targetwheat2) then MoveMouseSmooth(x, y); Wait(100+random(200)); HoldMouse(x, y, true); Wait(20+random(50)); ReleaseMouse(x, y, true); Wait(100+random(200)); MoveMouseSmooth(x+27, y+38);
Wait(100+random(200)); HoldMouse(x+27, y+38, true); Wait(20+random(50)); ReleaseMouse(x+27, y+38, true); Wait(3000+random(500)); Wait(10000); //<--- However long it takes you to chop wheat! end;
function nowheat : Boolean; begin if(FindColor(x, y, 1683891, 0, 0, 800, 600))then result:= false end;
begin harvest; repeat if (nowheat) then harvest; if(nextwheat1)or(nextwheat2)then harvest; until(false); 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.
This post has been edited by webcataha: Nov 23 2009, 11:30 AM
Group: Elite Members
Posts: 318
Joined: 22-June 09
From: Deep in my Coding Cave. But don't feel bad! After all, it's on the darkside, and we have cookies!
Member No.: 934,937
Ha, no, margreg's script is meant to teach you to make a simple one, his scripts in elite are just as or more advanced than anything i write myself, I specialize in creating commands, he specializes in making great ideas come to life, and very well i may add
--------------------
SCAR Coder
DofusBaseV1 [||||||||||]
Want to make progress bars like me?
CODE
use this base one as an example! [[color="#00FF00"]|[/color][color="#FF0000"]|||||||||[/color]]
Group: Members
Posts: 19
Joined: 24-January 10
Member No.: 1,097,048
Ok well i am like totally noob at this and i have no idea what i am doing. I see the cript and i pasted it in the scar tab and it works, it says it is sucessfully compiled. But, my guy doesnt do anything. What am i doing wrong? =<
Group: Elite Members
Posts: 183
Joined: 26-April 09
Member No.: 893,649
For your character to farm you have to make some preperations before starting scar: 1. don't change dofus default window size. 2. dofus game client is 1.29 not 2.0 3. display resolution is on low in dofus. 4. your character is on wheat field. 5. mark dofus as a client by scar ( the target like button in scar ). 6. Enjoy.
Group: Elite Members
Posts: 183
Joined: 26-April 09
Member No.: 893,649
QUOTE(matt61095 @ Feb 1 2010, 03:53 PM)
Ok, not that works and my mouse starts to go over a wheat but it does not click on the wheat.
Question: Do you have vista or windows 7 installed ? If you do, then run SCAR client as administrator then your mouse will click on the wheat. (Right click on your scar icon on the computer then choose " run as administrator" ).