Live Help
Membership
You are a guest!

Register Today!

Log In
Reset Password
Game Network
Community Forum

MMO GAME LIST
World of Warcraft
Age of Conan
Anarchy Online
Archlord
Cabal Online
City of Heroes
City of Villains
Dark Age of Camelot
Darkfall Online
Diablo 2
Dungeons and Dragons
Dofus
Eve Online
Everquest 2
Final Fantasy XI
Guild Wars
Hero Online
Knight Online
Lineage 2
Lord of the Rings Online
Maple Story
Ragnarok Online
Runescape 2
Second Life
SilkRoad Online
Star Wars Galaxies
Tibia
Warhammer Online

FPS GAME LIST
Call of Duty
Combat Arms
Counter Strike
Halo

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> WHEAT FARMER TUTORIAL, easy to follow tutorial on how to write wheat farmer.
post Nov 4 2009, 08:49 AM
Post #1

margreg



SCAR Coder
Group Icon

Group: Elite Members
Posts: 92
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


CODE
{
**************** 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

trava_xu = 18; // upper X coordinate of farming area
trava_yu = 85; // upper Y coordinate of farming area
trava_xd = 693; // lower X coordinate of farming area
trava_yd = 451; // lower Y coordinate of farming area

function wheat1 : Boolean;
begin
     if(FindColor(x, y, wheat, trava_xu, trava_yu, trava_xd, trava_yd))then result:= true
end;


function Leveled : Boolean;
begin
  if(FindColor(x, y, levell, trava_xu, trava_yu, trava_xd, trava_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.



Go to the top of the page
 
+Quote Post
post Nov 4 2009, 09:53 PM
Post #2

pakkaman



In Training
Group Icon

Group: Elite Members
Posts: 31
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
Go to the top of the page
 
+Quote Post
post Nov 4 2009, 10:02 PM
Post #3

lilwitte



SCAR Coder
Group Icon

Group: Elite Members
Posts: 246
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]]
Go to the top of the page
 
+Quote Post
post Nov 5 2009, 12:49 PM
Post #4

margreg



SCAR Coder
Group Icon

Group: Elite Members
Posts: 92
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.
Go to the top of the page
 
+Quote Post
post Nov 6 2009, 07:42 PM
Post #5

arsalan



In Training
**

Group: Members
Posts: 7
Joined: 23-August 09
Member No.: 984,538






yo yo pls mn cn u help me i do all tha stuff u said but my char is standin still as a staue
Go to the top of the page
 
+Quote Post
post Nov 8 2009, 06:01 AM
Post #6

margreg



SCAR Coder
Group Icon

Group: Elite Members
Posts: 92
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.

good luck.
Go to the top of the page
 
+Quote Post
post Nov 8 2009, 06:16 PM
Post #7

lilwitte



SCAR Coder
Group Icon

Group: Elite Members
Posts: 246
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]]
Go to the top of the page
 
+Quote Post
post Nov 9 2009, 05:39 AM
Post #8

margreg



SCAR Coder
Group Icon

Group: Elite Members
Posts: 92
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.
Go to the top of the page
 
+Quote Post
post Nov 9 2009, 01:55 PM
Post #9

lilwitte



SCAR Coder
Group Icon

Group: Elite Members
Posts: 246
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]]
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 


> Board Footer
Time is now: 21st November 2009 - 04:52 AM