What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[PLUGIN] World Farmer - An Open world farm plugin

Biocide

Member
Joined
Jan 15, 2010
Messages
92
Reaction score
2
WORLD FARMER - AN OPEN WORLD FARM PLUGIN

I did this plugin as an learn by doing project.

INFO:
My Patron has run out and I don't feel this game is worth the money. Not right now anyway.
My friends play other games and I will be looking for new titles.
If anyone is interested to keep this World Farmer plugin alive PM me.
Its open code so I guess anyone could just copy it but I feel its better if I give the "rights" to one person,
else there could be more than one plugin on the forum with the same codebase.
Please PM me with some information about your coding knowledge if you are interested.


I want to make it very clear that I don't do this with the intention to make money and I will newer ask for donations, but for you who asked for a donation button I have added one in the bottom of this post.
Now you can buy me a cup of coffee
I have added a setting section to the top of the code that I hope will make it easier for everyone to change crops.


What this plugin does:
This is for open world farming, not scarecrow farms.
Find yourself a quiet place anywhere out in the world and start the plugin.
It plants crops and collects them, again and again and again until you run out of seeds or labor points.

Things to change:
The seeds is set to Azalea Seeds - Change this to whatever you want.
The harvestable crop is Azalea since im farming in Temperate climate if your not in temperate you would change this to "Mature Azalea" - Change this to suit your crop.
The planting zone is set to 10 - Change to what you want.
The farming zone is set to 20 - Change to what you want.


Release Log:

Version 0.4 = Redone code. It works better for seeds. since they are 1 skill doodas. For trees and animals it uses the first skill. I will soon post a test version with skill priorities. (Now to be found in post #84)

Verision 0.3
= Found a few mistakes in the code. I have corrected them but still having an issue in the loop. Make sure you match everything in the Settings to names in game.

Version: 0.2 = Added a checkbox [Plant]
If its checked it will plant crops. Its good to have the options to just gather or if you want to close the bot after all crops is gathered.

Version: 0.1 = Release

Code:
using System;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;
namespace YourNamespace
{
    public class YourClass : Core
    {
        public static string GetPluginAuthor()
        {
            return "Biocide";
        }
        public static string GetPluginVersion()
        {
            return "0.4";
        }
        public static string GetPluginDescription()
        {
            return "World Farmer";
        }
        //----------------SETTINGS------------------------------------------------------------------
   ///////////////////////////////////////////////////////////////////////////////////////////////
  //    NAME OF THE SEED YOU WANT TO PLANT. THIS MUST BE EXACTLY AS YOU SE IT IN GAME.         //
 ///////////////////////////////////////////////////////////////////////////////////////////////     
        public string seedchoice = "Azalea Seed";
        public int Garea = 25; // size of Gathering area
        public int Parea = 6;  // size of planting area

//---------------DONT CHANGE ANYTHING BELOW THIS LINE---------------------------------------------


     public uint skill;
     public int gtime;   
     public string descr;
     public string name;  
            
        public DoodadObject GetBestNearestdood(Zone zone)
        {
            DoodadObject dood = null;
            double dist       = 999999;            
            foreach (var Obj in getDoodads())
            {      
                //If there is any Doodads that we looking for in this zone
                if (Obj.uniqOwnerId == me.uniqId)
                {
                    if (Obj.growthTime < 1)
                    {                                                         
                        dood  = Obj;
                        dist  = me.dist(Obj);
                        gtime = Obj.growthTime;
                    }
                 }
              }          
            return dood;
        }

        public void PluginRun()
        {
            RoundZone Gzone = new RoundZone(me.X, me.Y, Garea); //Make new gather zone.
            RoundZone Pzone = new RoundZone(me.X, me.Y, Parea); //Make new plant zone.
            SetGroupStatus("Farm", false); //Add checkbox to our character widget     
            while (true)
            {  
                if (GetGroupStatus("Farm"))
                {               
                    DoodadObject bestdood = null;
                    bestdood              = GetBestNearestdood(Gzone);
                    if (bestdood != null)
                    {
                        while (GetGroupStatus("Farm") && bestdood != null)
                        {
                            var skills = bestdood.getUseSkills();
                            if (skills.Count > 0)
                            {
                                skill = skills[0].id;
                                descr = skills[0].desc;
                                name  = skills[0].name;
                                CollectItemsInZone(bestdood.name, skill, Gzone);
                                bestdood              = GetBestNearestdood(Gzone);
                                }
                            Thread.Sleep(50);
                            }
                        Thread.Sleep(50);
                        }
                    PlantItemsInZone(seedchoice, Pzone);
                    Thread.Sleep(50);
                    }              
                Thread.Sleep(50);
            }
            Thread.Sleep(50);
        }        
    }
}




If you want to buy me a cup of coffee:
Or something to keep my wife away from the computer
 
Last edited:
WORLD FARMER - AN OPEN WORLD FARM PLUGIN

I did this plugin as an learn by doing project.

Use it if you want.

Things to change:
The seeds is set to Azalea Seeds - Change this to whatever you want.
The harvestable crop is Azalea since im farming in Temperate climate - Change this to suit your crop.
The planting zone is set to 7 - Change to what you want.
The farming zone is set to 20 - Change to what you want.

To start the plugin:
Start it in the plugin manager.
Click the checkbox named Farm on the widget.

Code:
using System;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;
namespace YourNamespace
{
    public class YourClass : Core
    {
        public static string GetPluginAuthor()
        {
            return "Biocide";
        }
        public static string GetPluginVersion()
        {
            return "0.1";
        }
        public static string GetPluginDescription()
        {
            return "World Farmer";
        }
        
        //Try to find Doodad in farm zone.
        public DoodadObject GetBestNearestdood(Zone zone)
        {
            DoodadObject dood = null;
            double dist       = 999999;
            foreach (var Obj in getDoodads())
            {      
                //If there is any Doodads that we looking for in this zone
                if (Obj.name == "Azalea")
                {
                    dood = Obj;
                    dist = me.dist(Obj);
                }
            }
            return dood;
        }
        
        
        public void PluginRun()
        {   
            RoundZone Gzone = new RoundZone(me.X, me.Y, 20); //Make new gather zone.
            RoundZone Pzone = new RoundZone(me.X, me.Y, 7); //Make new plant zone.
            SetGroupStatus("Farm", false); //Add checkbox to our character widget
            while (true)
            {   
                //If Farm checkbox is enabled
                if (GetGroupStatus("Farm"))
                {
                    DoodadObject bestdood = null;
                    bestdood              = GetBestNearestdood(Gzone);    
                    if (bestdood != null) 
                    {   
                        try
                        {
                            //while there is any desired Doodads in zone and checkbox in widget enabled
                            while (bestdood != null && GetGroupStatus("Farm"))
                            {
                                Log("Distance: " +me.dist(bestdood)+ "m");
                                  CollectItemsInZone("Azalea", "Gathering: Spend 1 Labor to gather materials.", Gzone);
                            }                           
                        } 
                        catch {}  
                    }
                    else
                    {
                        PlantItemsInZone("Azalea Seed", Pzone);
                    }
                }
                // Processor delay
                Thread.Sleep(10);
            }
        }
    }
}

what if i wan to use for chicken/goose farming? how should i set it up? >.<
 
what if i wan to use for chicken/goose farming? how should i set it up? >.<

I haven't tried this with any animal but

Here is code For Turkey. I think you understand how to change it to suit other animals. If you don't just ask.
Code:
[U]Change:
[/U][COLOR=#ff0000]if (Obj.name == "Azalea")[/COLOR]
[B]to
[/B][COLOR=#006400]if (Obj.name == "Turkey")[/COLOR]

[U]And change:
[/U][COLOR=#ff0000]CollectItemsInZone("Azalea", "Gathering: Spend 1 Labor to gather materials.", Gzone);[/COLOR]
[B]to[/B]
[COLOR=#006400]// There is no code in this plugin to handle feeding or treating sick animals but you can try to uncomment lines under this line
// CollectItemsInZone("Small Turkey Chick","Husbandry: Spend 1 Labor and 1 Ground Grain to feed livestock.","Gzone");
// CollectItemsInZone("Turkey","Husbandry: Spend 3 Labor and 1 Livestock Supplement to treat sick livestock.","Gzone");
CollectItemsInZone("Turkey","Husbandry: Spend up to 15 Labor to butcher an animal.", Gzone);
[/COLOR]
[U]Last thing to change:[/U]
[COLOR=#ff0000]PlantItemsInZone("Azalea Seed", Pzone);[/COLOR]
[B]to[/B]
[COLOR=#006400]PlantItemsInZone("Turkey Chick", Pzone);[/COLOR]
 
Last edited:
Thy! Can you explain to me
The planting zone is set to 7 - Change to what you want.
The farming zone is set to 20 - Change to what you want.

what do you mean planting zone, and farming zone?
 
Thy! Can you explain to me
The planting zone is set to 7 - Change to what you want.
The farming zone is set to 20 - Change to what you want.

what do you mean planting zone, and farming zone?

Plantzone is the zone where you will plant your crops. It is set to 7meter from center (you) to edges in a circular zone.

Farming zone is the zone where you will look for crops that are ready for harvest. 20 meters from center (you) to the edges in a circular zone.
 
Last edited:
will this work on plants that have been put in public places and not in farms? sometimes i plant 100-300 saplings in a quiet area and it takes forever to farm them all later
 
will this work on plants that have been put in public places and not in farms? sometimes i plant 100-300 saplings in a quiet area and it takes forever to farm them all later

That's exactly what this plugin does. It plants them and collects them again and again and again until you run out of seeds or labor points.
 
Version: 0.2 = Added a checkbox [Plant]
If its checked it will plant crops. Its good to have the options to just gather or if you want to close the bot after all crops is gathered.
 
It's planting like a champ! But it's not Gathering =( No errors or anything, just doesn't harvest.
 
trying to use this with azalea, but no luck, i am new to this, only copy paste and compile it? and then check the boxes in widget?
 
I haven't tried this with any animal but

Here is code For Turkey. I think you understand how to change it to suit other animals. If you don't just ask.
Code:
[U]Change:
[/U][COLOR=#ff0000]if (Obj.name == "Azalea")[/COLOR]
[B]to
[/B][COLOR=#006400]if (Obj.name == "Turkey")[/COLOR]

[U]And change:
[/U][COLOR=#ff0000]CollectItemsInZone("Azalea", "Gathering: Spend 1 Labor to gather materials.", Gzone);[/COLOR]
[B]to[/B]
[COLOR=#006400]// There is no code in this plugin to handle feeding or treating sick animals but you can try to uncomment lines under this line
// CollectItemsInZone("Small Turkey Chick","Husbandry: Spend 1 Labor and 1 Ground Grain to feed livestock.","Gzone");
// CollectItemsInZone("Turkey","Husbandry: Spend 3 Labor and 1 Livestock Supplement to treat sick livestock.","Gzone");
CollectItemsInZone("Turkey","Husbandry: Spend up to 15 Labor to butcher an animal.", Gzone);
[/COLOR]
[U]Last thing to change:[/U]
[COLOR=#ff0000]PlantItemsInZone("Azalea Seed", Pzone);[/COLOR]
[B]to[/B]
[COLOR=#006400]PlantItemsInZone("Turkey Chick", Pzone);[/COLOR]

oh okay..tqvm :)
 
Mine is dont even start...
I got the 6:52:19: X:\X\X\X\X\Plugins\farm\farm.dllUnknown executing error, or plugin was forcibly unloaded.
I opend the plugin editor, copy paste, save compile and run, and nothing. Any idea?

Edit: interesting.. i changed the for "true" and the bot just work, i dont know if it gather or only plant but its somthing finally
SetGroupStatus("Farm", false); //Add checkbox to our character widget
SetGroupStatus("Plant", false); //Add checkbox to our character widget


Edit: working but if i stop i get the same error message.
 
Last edited:
for the item wouldi put the full name to gather e.g. Nonnative Fruited Grapevine or just put Grapevine. Also how big of an area is set by default ? i seen the number on the previous page but is that number the same as the farm numbers like 16x16 farms ect ?
 
Last edited:
It's planting like a champ! But it's not Gathering =( No errors or anything, just doesn't harvest.
Just realized I hadn't changed Farming To Gathering in my last release.
Copy/paste the code again

trying to use this with azalea, but no luck, i am new to this, only copy paste and compile it? and then check the boxes in widget?
Copy/paste the code again. And give me more information what's not working.

What are people farming anyway?
Whatever sell on AH. Or the things you need for stuff, like trade packs.

Mine is dont even start...
Edit: Just plant but not farm.
Same here.
Copy/paste the code again.
for the item wouldi put the full name to gather e.g. Nonnative Fruited Grapevine or just put Grapevine. Also how big of an area is set by default ? i seen the number on the previous page but is that number the same as the farm numbers like 16x16 farms ect ?
When you have a plant that is ready to harvest.
Mouse over it and look at the information you'll get.
Make sure the information match the information you have here:
if (Obj.name == "Azalea")
CollectItemsInZone("Azalea", "Gathering: Spend 1 Labor to gather materials.
 
Last edited:
i copy/paste the code, the farm/plant appear in widget, check plant and nothing happens.
 
Back
Top