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

[Plugin] FarmMonkey: Continuous Multi Farm Harvest & Planting Plugin

Defectuous

New Member
Joined
Dec 17, 2014
Messages
238
Reaction score
1
[Plugin Name]
FarmMonkey: Continuous Multi Farm Harvest & Planting Plugin

[Description]
A farm plugin capable of continuous farming over multiple farms.

[Special Thanks]
Voyager92 - For a really Epic Non-Stop Farm/Gathering Base from which I am building this on
imapedarsag - For helping in the current and future development assistance of the code.

[Future Additions ( Plus Notes)]
# Planting Timers ( doodads are messing with my mind )
# Mail Support ( Currently Working in Development, release soon )
# Seed Vendor Support ( Currently Working in Development, release soon )
# Door Support ( Currently Working in Development, release soon )
# Crop Rotation ( rotate seeds on farms )
# Multi Character Support ( Log out and farm on another toon on that account )
# Chest Storage Support ( Waiting on the api )
# Gui Support ( windows forms are my greatest enemy at this time )

[Completed Additions]
# Gps Support - Safe Spot, Death Run & Farm Locations

[Known Issues]
# Seed Count does not update per farm, just at the start of planting
# Ran into a issue with a Mansion where it will stop gathering and plant after two rows. Need to sort out why.

[Instructions]
# Start Scarecrow & Get the Farm ID(s)
# Place the Farm ID's in the
uint[] _farms = { 12345, 54321 }; // Gather Farm ID's wtih scarecrow { 12345, 54321 }

# Add Seed Name
string _seed = "Aloe Seed"; // Seeds to plant

# Add Final Plant Name
string _plant = "Aloe"; // Make sure plant ends up Mature or just the plant name

# Make surey ou have the rather gather command ( on any plant needing more than 1 labor it should be " up to 2,3"
string _gather = "Gathering: Spend 1 Labor to gather materials.";
string _harvest = "Farming: Spend 1 Labor to harvest crops.";

# Compile the Code and start the Plugin.

[Stable Release Source Version 1.1.9.4(.5)]
[HIDE]
Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;

//
// Special Thanks to Voyager92 for a really Epic Non-Stop Farm/Gathering Base from which I am building this on. 
// Thread:  [Plugin] Non-Stop Farm/Gathering for multiple toons/farms and with restart support
//

namespace ArcheAgeFarmMonkey
{
    public class FarmMonkey : Core
    {
        public static string GetPluginAuthor()
        { return "Defectuous"; }
        public static string GetPluginVersion()
        { return "1.1.9.4.5"; }
        public static string GetPluginDescription()
        { return "FarmMonkey: Continuous Multi Farm Harvest & Planting Plugin"; }
        
        // START Universal Config
        
        uint[] _farms = { 12345, 54321 }; // Gather Farm ID's wtih scarecrow { 12345, 54321 }
        int _minlabor = 20;  // Minimum Labor for harvesting.
        string _seed  = "Azalea Seed";
        string _plant = "Azalea"; // Make sure plant ends up Mature or not. 
        
        // Note: You may need to update the Amount of labor needed for Gathering & Harvesting.
        string _gather  = "Gathering: Spend 1 Labor to gather materials.";
        string _harvest = "Farming: Spend 1 Labor to harvest crops.";
        
        // This gps file needs 2 points " Safe " & " Farm "
        string _gpsfile = "\\plugins\\FarmMonkey\\file.db3";
        
        // Set to true if you have a gps file for moving to and from the safe.
        private bool _enablegps = false;
        // Set to true if your gps file has paths from the Nui ( generally not necessary in safe zone farming )
        private bool _deathcheck = false;
        
        // END Universal Config 
        // ( Do Not Edit anything past this line unless you are confident you know what your doing )
        
        // Universal Application Information
        private Gps gps;
        Random random = new Random();
        
        //Call on plugin start
        public void PluginRun()
        {
            ClearLogs();
            Log(Time() + "FarmMonkey: Plugin Started");
            
            while (true) {
                if (gameState == GameState.Ingame){
                    Log(Time() + "Time to Farm");
                    
                    // Death Check ( Am i really dead ? )
                    if ( _enablegps == true && _deathcheck == true && !me.isAlive()){
                        Log(Time() + "[ WARNING: We have died, there must be a reason for this check into that would you ]");
                            
                        // Res timer is Buggy due to continued deaths raises the time
                        Log(Time() + "INFO: Waiting 18 Seconds to resurection");
                        Thread.Sleep(18000);
                        Log(Time() +  "INFO: Time to Ressurect");               
                        ResToRespoint();
                        while (!me.isAlive()){ 
                            Log(Time() + "INFO: Crap Your Still Dead. Waiting 10 seconds and trying again.");
                            Log(Time() + "INFO: Also Check your Res Timer & note how long.");
                            Thread.Sleep(10000);
                            ResToRespoint();
                        }
                        Log(Time() +  "INFO: Thread Waiting 120 Seconds (2 Minutes) In case of long load times.");               
                        Thread.Sleep(120000);
                        DeathRun();
                        }
                    
                    // Lets get back to the Farms
                    if ( _enablegps == true && me.isAlive()){ MoveToFarm(); }
                    
                    // Time to Harvest plants
                    Harvesting();
                    // Lets fill that field with seeds
                    Planting();
                    
                    // Time to head back to the safe spot
                    if ( _enablegps == true){ MoveToSafe(); }
                    
                    
                    //  Temporary Sleep to prevent to many checks
                    var mseconds = random.Next(240, 300) * 1000;
                    var seconds  = mseconds / 1000;
                    Log(Time() +  "Waiting " + seconds.ToString() + " seconds to check seeds");
                    Thread.Sleep(mseconds);

                }
            }
        }

        // Moving Routines
        public void MoveToFarm()        
        {         
           gps = new Gps(this); 
           gps.LoadDataBase(Application.StartupPath + _gpsfile); 
           gps.GpsMove("Farm");                
         }
        
       public void MoveToSafe()        
        {         
           gps = new Gps(this); 
           gps.LoadDataBase(Application.StartupPath + _gpsfile); 
           gps.GpsMove("Safe");                
         }
       
       public void DeathRun()
       {
           gps = new Gps(this); 
           gps.LoadDataBase(Application.StartupPath + _gpsfile);
            Log("Lets Get Moving");
           gps.GpsMove("Safe");                
       }
       
       // Farming Routines
        public void Harvesting()
        {
            var _labor = me.laborPoints;
            if (_labor > _minlabor){
                Log("Current Labor:" + _labor);
                foreach (uint farm in _farms){
                    Log(Time() + "Harvesting " + _plant + "(s) on FarmID: " + farm);
                    CollectItemsAtFarm(_plant, _gather, farm);
                    CollectItemsAtFarm(_plant, _harvest, farm);
                    } 
            }
        }

        public void Planting()
        {
            var seedcount = itemCount(_seed);
            if ( seedcount == 0){
                Log(Time() + "Seed Count:" + seedcount + _seed);
                Log(Time() + "You have no seeds!");
                } else{
                    foreach (uint farm in _farms)
                    {
                        Log(Time() + "Seed Count: " + seedcount + _seed);
                        Log(Time() +  "Planting" + _seed + "(s) on FarmID: " + farm);
                        PlantItemsAtFarm(_seed, farm);
                    }
                }
        }
        
        // Utility Stuff
        public string Time()
        {
            string A = DateTime.Now.ToString("[hh:mm:ss] ");
            return A;
        }
        
        //Call on plugin stop
        public void PluginStop()
        {

        }
    }
}
[/HIDE]

Code:
Revision 1.1.9.4.5
Fixed Death Run Issue ( Compiles Successfully this time round )

Revision: 1.1.9.4
gps features functional, but they have been disabled by default

Safe & Farm Locations supported in GPS
Death Check & Walk: Checks if your dead and resurrects you

Revision: 1.0.0.0
Inital Functional Release

[Plugins That Make This Plugin Better]
Move While Planting - Set both config options to 2 and you look very human to the casual eye

[Cost = FREE]
I have been asked by several people in game that use this. Why I don't charge for this and I have told them that it will NEVER happen. My hope is to get this to a point where I feel it ready to be added to the store as a FREE item and will always be FREE.
 
Last edited:
At the moment, nothing new, just the same script. Works stably. Waiting for updates, thank you.
 
At the moment, nothing new, just the same script. Works stably. Waiting for updates, thank you.

Thank you, the gps is what i'm working on atm, but need to get the plant timers done so it works properly.
 
Tested, work fine and stably. Plant, wait, harvest, plant, and repeat :)

Waiting updates ^^
 
I've added the basic gps update to github as it's not complete, but is functional as I need to add death spawn & door support, but it will go into a safe spot after planting and move back after the timer to check the farm(s).

The following will be added to the main post once all the GPS features are in place.

Code:
How to make a gps file

START GPS\gps.dll
Run the GPS editor.exe file in your updater folder

in the GPS editor click file then down to new ( ctrl+n)
Move to your plugins folder then FarmMonkey\Path\ ( if you don't have a Path folder make it )
in the file name section just call the gps file " file " then click save.

Move to your " Safe" spot 
Put in your Point name of Safe and Click Add point

In the auto: section
Check Auto
Set distance from 20.0 to 2.5
Leave the rest alone
Move to the center of your farm(s)
Put in your Point name of " Farm " and Click Add link

I would double check all the links are in place if not connect the links

in the GPS editor click file then down to save ( ctrl+s)


########################

To enable gps support set the following to true
private bool _enablegps = false;

if you decide to not use the gps feature, set it back to false.

########################

update your farm ID's your seed id's

click (Green Arrow) and watch the magic.
 
Last edited:
Hi Defectuous,

if I want to use this plugin in the open world and not on a specific farm, what would I have to change to the script ?
 
Hey,

When farming something that requires more then 1 labor do i write instead of.
// Note: You may need to update the Amount of labor needed for Gathering & Harvesting.
string _gather = "Gathering: Spend 1 Labor to gather materials.";
string _harvest = "Farming: Spend 1 Labor to harvest crops.";

Do i need to change it to
// Note: You may need to update the Amount of labor needed for Gathering & Harvesting.
string _gather = "Gathering: Spend up to 5 Labor to gather materials.";
string _harvest = "Farming: Spend up to 5 Labor to harvest crops.";

Or do i change it to
// Note: You may need to update the Amount of labor needed for Gathering & Harvesting.
string _gather = "Gathering: Spend 5 Labor to gather materials.";
string _harvest = "Farming: Spend 5 Labor to harvest crops.";

Also is there a way to have the seed/end product name coded by ID instead of name, and with this i mean use the ID's that are available at AAdatabase site.

Thanks
 
Honestly try i've been growing rice, corn, barley, with it and havn't had any issues, but if you do have issues try " Spend 5 Labor " first on a seed and if it works awesome, if not change it to "Spend up to 5 Labor"

As for seeds it's
Code:
change
        string _seed  = "Barley Seed";
        string _plant = "Barley"; // Make sure plant ends up Mature or not. 
to
        int _seed  = "12345";
        int _plant = "54321";

But I would make sure there isn't a separate id for Rice and Mature Rice
 
Last edited:
Revision: 1.1.9.4 has been released
gps features functional, but they have been disabled by default
Safe & Farm Locations supported in gps
Death Check & Walk: Checks if your dead and resurrects you

Revision 1.2.x.x
Additional support for gps including door & chair/bed/etc... ( if i can sits It fits )
Proper Plant Timers ( find last planted doodad time before leaving add ( random seconds ) the come back after the time )
Possible Gui support, depends on if i can actually get the windows forms to work for me.

#####
If anyone has any source I could review to understand doodad and their information ( Am already reading in depth in the API information ).
 
Revision: 1.1.9.7 has been added to github it includes support for seed purchasing

I am not certain I like the buy process but it seems to be functional will work on
If enabled it will buy seeds if you hit under _minseed and stops at _maxseed values
it also has a gold limited to stop buying at if gold is at or lower than set amount.
 
Are the implications of allowing this to farm more than 1 type of plant at a time severe?

Also the seed purchasing is not function correctly for me. I have a seed point on my path, it will move to vendor and claims it buys seeds but it doesn't. The character has over 50g so that isn't problem either.

Log Shows:
[04:24:50] Seed Stock: 0
[04:24:50] Seed Purchase Completed
[04:24:50] Seed Count:0Corn Seed
[04:24:50] You have no seeds!

Goes to sleep after this

Planting, Gathering, Gps all seem to be functioning as intended though =D
 
Last edited:
Are the implications of allowing this to farm more than 1 type of plant at a time severe?

Also the seed purchasing is not function correctly for me. I have a seed point on my path, it will move to vendor and claims it buys seeds but it doesn't. The character has over 50g so that isn't problem either.

Log Shows:
[04:24:50] Seed Stock: 0
[04:24:50] Seed Purchase Completed
[04:24:50] Seed Count:0Corn Seed
[04:24:50] You have no seeds!

Goes to sleep after this

Planting, Gathering, Gps all seem to be functioning as intended though =D

Thank you for this input, My goal for this week was to re-write the buy functionality, and work on planting timers. So hopefully I will have an update in the next couple of days.

Also Multi Farm Crop rotation is on my todo list, but I need to work out the bugs on a single crop before I set down those functions on more than just a white board.

eep can you stand in front of the seed merchant and run this and copy paste the log as a response.
Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;

namespace DefaultNameSpace{
    public class DefaultClass : Core
    {
        public static string GetPluginAuthor()
        { return "Defectuous"; }
        public static string GetPluginVersion()
        { return "1.0.0.0"; }
        public static string GetPluginDescription()
        { return "Function(s) Testing Application"; }
       
        private bool _enablebuyseed = true; // To buy Seeds you need a gps point called Seed

        string _seed    = "Potato Eyes"; // Seeds to plant
        string _plant   = "Potato"; // Make sure plant ends up Mature or just the plant name
        string _gpsfile = "\\plugins\\FarmMonkey\\Path\\file.db3";
        private Gps gps;
        Random random = new Random();
        
        int _buyseedamt = 100; // Do not raise this above 100
        int _mingold    = 40000;   // 50000 = 5Gold 00Silver 00Copper
        int _minseed    = 50; // Minimum Seed Count before purchasing more
        int _maxseed    = 100; // Maximum number of seeds to have at a time        
        
        //Call on plugin start
        public void PluginRun()
        {
            if ( _enablebuyseed == true){ 
                ClearLogs();
                Log(Time() + "Starting Process");
                BuySeeds();
                } else { Log(Time() + "Buy Seeds is set to false"); }
            
        }
       
        public void BuySeeds()
        {
            while (true){
                
                var _mygold   = me.goldCount;
                var seedcount = itemCount(_seed);
                if (_mygold <= _mingold){ 
                    Log(Time() + "Unable to Purchase due to lack of funds"); 
                    Log(Time() + "######################################");
                    break;
                    } else {
                        Log(Time() + "######################################");
                        Log(Time() + "Lets go buy seeds");
                        //gps = new Gps(this); 
                        //gps.LoadDataBase(Application.StartupPath + _gpsfile); 
                        //gps.GpsMove("Seed");
                        Log(Time() + "######################################");
                        Log(Time() + "Seed Stock: " + seedcount);
                        if ( seedcount <= _minseed && seedcount <= _maxseed){
                            BuyItems(_seed, _buyseedamt);
                            var seedcount2 = itemCount(_seed);
                            Log(Time() + "Updated Seed Cound: " + seedcount2);
                            
                            var mseconds = random.Next(50, 300);
                            var seconds  = mseconds / 1000;
                            Log(Time() +  "Checking seed stock");
                            Thread.Sleep(mseconds);
                        
                        } else {
                            Log(Time() + "Seed Purchase Completed");
                            Log(Time() + "######################################");
                            break;
                    }
                }
            }
        }
            
        public string Time()
        {
            string A = DateTime.Now.ToString("[hh:mm:ss] ");
            return A;
        }
       
       //Call on plugin stop
       public void PluginStop()
       {
       }
   }
}               

///
//  growthTime
//  tempGrowthTime
///
 
Last edited:
A nice feature would be the option to logout while waiting for seeds to grow. Maybe a logout timer (randomized a bit of course) and after it gets to 0 it logs in and harvests seeds.

The above will be nice as they are added 10/10 labor regen for offline characters also and sitting next to your farm will look suspicious now.
 
As it stands I currently a, running 2 gazebo's with a thatched attached. ( goal is 8 gazebo's 1 thatched in a 3x3 property setup. )

The current in house version goes inside and sits down and waits till the timer is up. I still have door issues working on that.
The live version goes to whatever safe spot you designate ( no chair support )

Right now other than bug fixes I am focusing on getting plant timers to be the proper wait timer rather than just waiting around. I was thinking of adding a stopgap of base timer to the growth timer in a config. We'll see how that pans out. I hope to add chest support as well as the ability to do crop rotations. Also to get a gui made so that it can give more information than the log.

With that said it is possible to log out at that point. It will be a proper threaded process hopefully by then to keep multiple farms timed properly and make it should be possible for a planter account and a harvester accounts to work in unison. Again this is only on my whiteboard and not in code.

With that said I welcome anyone to throw improvements at this if you have some. Adding a few notes to this program.
 
Revision: 1.1.10.3 has been added to github it includes door support & updates to buy support

Door support requires you to make a GPS points on the outside called Door0 & on the inside Door1
Both points must be able to interact with the door for it to work.

So for a Full GPS file with all the Bells and whistles
Farm, Safe, Door0, Door1, Seed

Buy support from my testing is more stable and buying all the time. ( 80g later lol )
My full focus atm is to finsih the proper plant timers and any bugs that come up in the mean time.
 
Last edited:
Gm detection would be nice :D

I would have to look into what other GM detentions are out there as I am uncertain as t o how i would accomplish this, but I agree this is considered a high priority request to be reviewed.
 
Back
Top