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

[Plugin] Another auto farming plugin, now with farmID auto assignment!

amazingnessn

New Member
Joined
May 23, 2014
Messages
69
Reaction score
0
[Plugin] Another auto farming plugin, now with farmID auto assignment and gui!

Code updated 18/8/15. Remade plugin and added gui.
Base of this is from several other farming plugins, specifically ones made by Voyager92 and xact.
This is my second attempt at a Windows Forms application, I've tested it myself to make sure it won't cause archebuddy to crash. May still be some smaller bugs.

Works for multiple farms.
Saves settings for quick startup.
Supports GPS from vendor to farm. MUST label vendor point "Vendor".
Buy Amount - Put how many seeds you want to buy for this plant, will buy enough to equal this number. For example, if number entered is 500 and you already have 250 in inventory, will only buy 250 more to equal the 500.
Note: GPS is off by default, check Gps box if you plan to use it.

Supports auto Farm Id gathering - Takes names entered for your farms (default examples are scarecrow farm, gazebo farm, etc.) Rename your farms in-game if you have multiple with different plants on each.

GnTYYVN.png


Original plugin code here - no gui and requires first-time setup.
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;

namespace YourNamespace {
public class YourClass: Core {

public static string GetPluginAuthor()
{
return "amazingnessn";
}
public static string GetPluginVersion()
{
return "1.1";
}

public static string GetPluginDescription()
{
return "Farming Bot - Auto gather/plant your crops with auto farm ID";
}

// ----------------------------------------------- if you have more/less # of farms, add/comment out what you need --------------------------------
// ------------------------------------------------ Change Farm Names Here ---------------------------------------------------------
private string farm1name = "Gazebo Farm";
private string farm2name = "Thatched Farmhouse";
private string farm3name = "Scarecrow Farm";
//private string farm4name = "FARM NAME HERE";
//private string farm5name = "FARM NAME HERE";

private uint farm1id;
private uint farm2id;
private uint farm3id;
//private uint farm4id;
//private uint farm5id;

// -------------------- Gps Functions, add more functions if you have farms spread out and need gps to go between them --------------------//
private bool gps_on = false; //Set to true if using gps, false if not
private Gps gps;
string _gpsfile = "\\plugins\\Farms\\Farming.db3";
public void MoveToFarm()
{
gps = new Gps(this);
gps.LoadDataBase(Application.StartupPath + _gpsfile);
gps.GpsMove("Farms");
}
public void MoveToVendor()
{
gps = new Gps(this);
gps.LoadDataBase(Application.StartupPath + _gpsfile);
gps.GpsMove("Seed Merchant");
}


public void GetFarmIds()
{

// Don't edit this if you don't know what it does :p
int p = 0;
List<long> farmids = new List<long>();
List<string> farmnames = new List<string>();
List<Creature> farms = getCreatures().Where(x => x.type == BotTypes.Housing).ToList();
List<Creature> farms1 = farms.Where(x => x.ownerUniqId == me.uniqId).ToList();
List<Creature> farmsfam = farms.Where(x => x.ownerUniqId != me.uniqId).ToList();
foreach(var y in farms) {
if (farms1.Count > 0) {
Housing plnt = farms1.First() as Housing;
farmids.Add(plnt.uniqHousingId);
farmnames.Add(plnt.name);
farms1.RemoveAt(0);
}

if (farmsfam.Count > 0) {
Housing plnt1 = farmsfam.First() as Housing;
foreach(var d in me.family.getMembers()){
if (plnt1.ownerName == d.name) {
farmids.Add(plnt1.uniqHousingId);
farmnames.Add(plnt1.name);
farmsfam.RemoveAt(0);
}
}
}
}
foreach(var i in farmnames){
if (farmnames[p] == this.farm1name) { this.farm1id = (uint)farmids[p]; }
if (farmnames[p] == this.farm2name) { this.farm2id = (uint)farmids[p]; }
if (farmnames[p] == this.farm3name) { this.farm3id = (uint)farmids[p]; }
//if (farmnames[p] == this.farm4name) { this.farm4id = (uint)farmids[p]; }
//if (farmnames[p] == this.farm5name) { this.farm5id = (uint)farmids[p]; }
p++;
}
}

public void PluginRun() {
ClearLogs();
Log("Starting Farm Bot...");

// --------------------------------------- stops if under this much labor, change if desired---------------------------------------------------
int laborstop = 200;
// ------------------------------------- put farmID, seed, plant, collect strings here --------------------------------------
//FARM 1
var farm1seed = "SEED NAME HERE";
var farm1plant = "PLANT NAME HERE";
var farm1collect = "TOOLTIP STRING HERE";
//FARM 2
var farm2seed = "SEED NAME HERE";
var farm2plant = "PLANT NAME HERE";
var farm2collect = "TOOLTIP STRING HERE";
//FARM 3
var farm3seed = "SEED NAME HERE";
var farm3plant = "PLANT NAME HERE";
var farm3collect = "TOOLTIP STRING HERE";
/*//FARM 4
var farm4seed = "SEED NAME HERE";
var farm4plant = "PLANT NAME HERE";
var farm4collect = "TOOLTIP STRING HERE";
//FARM 5
var farm5seed = "SEED NAME HERE";
var farm5plant = "PLANT NAME HERE";
var farm5collect = "TOOLTIP STRING HERE"; */

// ----------------------------------------- how many seeds to buy when you get low -----------------------------------------
var farm1seedbuy = 1000;
var farm2seedbuy = 1000;
var farm3seedbuy = 1000;
//var farm4seedbuy = 1000;
//var farm5seedbuy = 1000;



while (true) {
var farm1seedcount = itemCount(farm1seed);
var farm2seedcount = itemCount(farm2seed);
var farm3seedcount = itemCount(farm3seed);
//var farm4seedcount = itemCount(farm4seed);
//var farm5seedcount = itemCount(farm5seed);
//Gather infos
if (gameState == GameState.Ingame){
GetFarmIds();
Log(farm1id.ToString());
Log(farm2id.ToString());
Log(farm3id.ToString());
//get Labor points
int labor = me.laborPoints;
//Start Doin Stuff
//if Labor > 200
if (labor > laborstop) {

if (gps_on == true){
if (farm1seedcount < (farm1seedbuy / 5) | farm2seedcount < (farm2seedbuy / 5) | farm3seedcount < (farm3seedbuy / 5)) {
MoveToVendor();
Thread.Sleep(2000);
if (farm1seedcount < (farm1seedbuy / 5)) {BuyItems(farm1seed, farm1seedbuy);}
if (farm2seedcount < (farm2seedbuy / 5)) {BuyItems(farm2seed, farm2seedbuy);}
if (farm3seedcount < (farm3seedbuy / 5)) {BuyItems(farm3seed, farm3seedbuy);}
//if (farm4seedcount < (farm4seedbuy / 10)) {BuyItems(farm4seed, farm4seedbuy);}
//if (farm5seedcount < (farm5seedbuy / 10)) {BuyItems(farm5seed, farm5seedbuy);}
Thread.Sleep(5000);
MoveToFarm();
}}

//add/remove farms here
//Plant farm 1
SetPlantMotionType(PlantMotionType.Standart); // change motion type if needed
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
PlantItemsAtFarm(farm1seed, farm1id);

//Plant farm 2
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
PlantItemsAtFarm(farm2seed, farm2id);

//Plant farm 3
CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
CollectItemsAtFarm(farm3plant, farm3collect, farm3id);
PlantItemsAtFarm(farm3seed, farm3id);

/*//Plant farm 4
CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
CollectItemsAtFarm(farm4plant, farm4collect, farm4id);
PlantItemsAtFarm(farm4seed, farm4id);

//Plant farm 5
CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
CollectItemsAtFarm(farm5plant, farm5collect, farm5id);
PlantItemsAtFarm(farm5seed, farm5id); */

//if Labor < 200 wait
} else {
PlantItemsAtFarm(farm1seed, farm1id);
PlantItemsAtFarm(farm2seed, farm2id);
PlantItemsAtFarm(farm3seed, farm3id);
//PlantItemsAtFarm(farm4seed, farm4id);
//PlantItemsAtFarm(farm5seed, farm5id);
Log("Labor under 200, waiting to regen");
}

//Generate random time between 3-5 minutes
Random random = new Random();
decimal mseconds = random.Next(180, 300) * 1000;
decimal seconds = mseconds / 1000;
decimal minutes = seconds / 60;
Log("Waiting for " + minutes.ToString() + " minutes");

//sleep for random time
Thread.Sleep((int)mseconds);
}
}
}
//Call on plugin stop
public void PluginStop()
{
Log("Plugin Stopped...");
}
}
}

I'll try to help with issues users might have.

Main reason I made this is for the auto farm ID support that other plugins lacked.

View attachment Farm.zip - Use dll included or compile 'Farm' in ArcheBuddy plugin editor.
 
Last edited:
so this plugin does support multiple farms with diffrent location?
 
Well I got the same problem as with your plugin Defectuous. I create a GPS path between farms but it ignores it completely and run in straight line. How do I call my farm points in GPS? Same as I called them in this plugin correct? Done it this way and it doesn't work for me, no idea where I make a mistake
 
well i cant figure this out how to make it with gps .. it does not work for me at all, can u help somehow?
did u test it with gps ?
 
Well I got the same problem as with your plugin Defectuous. I create a GPS path between farms but it ignores it completely and run in straight line. How do I call my farm points in GPS? Same as I called them in this plugin correct? Done it this way and it doesn't work for me, no idea where I make a mistake

Ok, so you for multiple farm locations you will need to make the gps path have a different name for each farm. From the PM you sent me I think you've done this already.
For those who are reading this for their own issues, instead of naming gps point "farms", name it the name of each farm for simplicity (ie. Scarecrow Farm, Gazebo Farm, etc.)

You'll need to add a GPS function for each additional farm as I only had one general "farms" location in mind when I made this. But it's very simple to do.

In the gps section, in the MoveToFarm() function, you need to change "Farms" to "FARMNAME" where FARMNAME = your farm name. Then copy/paste this entire function, rename it, and repeat with second farm name. Repeat for multiple farms.

So instead of this from original code:
Code:
public void MoveToFarm()        
        {         
           gps = new Gps(this); 
           gps.LoadDataBase(Application.StartupPath + _gpsfile); 
           gps.GpsMove("Farms");                
         }
It should look like this for your multiple farm setup:
Code:
public void MoveToFarm()        
        {         
           gps = new Gps(this); 
           gps.LoadDataBase(Application.StartupPath + _gpsfile); 
           gps.GpsMove("FARM 1 NAME");                
         }
public void MoveToFarm2()        
        {         
           gps = new Gps(this); 
           gps.LoadDataBase(Application.StartupPath + _gpsfile); 
           gps.GpsMove("FARM 2 NAME");                
         }

You'll also have to call these functions before you plant/gather or it will attempt to run straight to farm instead of using gps. For this you copy/paste MoveToFarm(); right after the comment section //plant farm 1 and MoveToFarm2(); after //plant farm 2. This is down in Collect/Plant Items section of the code.
 
Last edited:
After having it like this

//add/remove farms here
//Plant farm 1
MoveToFarm1();
SetPlantMotionType(PlantMotionType.Standart); // change motion type if needed
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
PlantItemsAtFarm(farm1seed, farm1id);

//Plant farm 2
MoveToFarm2();
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
PlantItemsAtFarm(farm2seed, farm2id);

I get this when compiling:
21:26:21: c:\Gry\buddy\Plugins\Farms\Farms.cs(62,17) : warning CS0219: The variable 'farm4name' is assigned but its value is never used
21:26:21: c:\Gry\buddy\Plugins\Farms\Farms.cs(63,17) : warning CS0219: The variable 'farm5name' is assigned but its value is never used
21:26:21: c:\Gry\buddy\Plugins\Farms\Farms.cs(164,21) : error CS0103: The name 'MoveToFarm1' does not exist in the current context
 
After having it like this

//add/remove farms here
//Plant farm 1
MoveToFarm1();
SetPlantMotionType(PlantMotionType.Standart); // change motion type if needed
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
PlantItemsAtFarm(farm1seed, farm1id);

//Plant farm 2
MoveToFarm2();
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
PlantItemsAtFarm(farm2seed, farm2id);

I get this when compiling:
21:26:21: c:\Gry\buddy\Plugins\Farms\Farms.cs(62,17) : warning CS0219: The variable 'farm4name' is assigned but its value is never used
21:26:21: c:\Gry\buddy\Plugins\Farms\Farms.cs(63,17) : warning CS0219: The variable 'farm5name' is assigned but its value is never used
21:26:21: c:\Gry\buddy\Plugins\Farms\Farms.cs(164,21) : error CS0103: The name 'MoveToFarm1' does not exist in the current context

That's my bad, should be MoveToFarm(); instead of MoveToFarm1();
 
Nevermind I got that covered, in public void you wrote MoveToFarm() and then later in a code told to copy paste MoveToFarm1(); so I had to change it into MoveToFarm1(); in public void section and then later somewhere in a code and that was about it. Now its not ignoring my GPS path and move using it. Right now I just launched it and it went there to plant seeds, will report how it works when I make it a little bit more complex (4 farms, different sizes, different plants, different grow times etcetc). Big Thanks!
 
Last edited:
Nevermind I got that covered, in public void you wrote MoveToFarm() and then later in a code told to copy paste MoveToFarm1(); so I had to change it into MoveToFarm1(); in public void section and then later somewhere in a code and that was about it. Now its not ignoring my GPS path and move using it. Right now I just launched it and it went there to plant seeds, will report how it works when I make it a little bit more complex (4 farms, different sizes, different plants, different grow times etcetc). Big Thanks!
Thanks for testing!

Out of curiosity, how far apart are your farms? I'm working on altering parts of this to support farms in different areas.
 
I like what you did there,


Wouldn't it be easier to add the gps before the farming point like this and make the farming action a loop to handle multiple farms smoothly ( in the works on something similar to mine )

Code:
gps.GpsMove("FARM 1 NAME");
SetPlantMotionType(PlantMotionType.Standart);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id); 
CollectItemsAtFarm(farm1plant, farm1collect, farm1id); 
PlantItemsAtFarm(farm1seed, farm1id);
 
I like what you did there,


Wouldn't it be easier to add the gps before the farming point like this and make the farming action a loop to handle multiple farms smoothly ( in the works on something similar to mine )

Code:
gps.GpsMove("FARM 1 NAME");
SetPlantMotionType(PlantMotionType.Standart);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id); 
CollectItemsAtFarm(farm1plant, farm1collect, farm1id); 
PlantItemsAtFarm(farm1seed, farm1id);
I'm about to leave for work so I don't have time to test this right now, but I think that would throw out an error because it doesn't find the gps file path.
You would need to load the database at some point, but once you do that I think it would work just fine.
 
My farms are like 50-60 away from eachother right now but i ran into other problem right now, it moves between them and vendor with GPS but it just plants, it doesn't harvest, I made a test using potato and rice (potato farm1, rice farm2. When I started plugin it ran to vendor to refill stock using my quantity settings, planted potatos, ran to farm2 planted rice then it just stood on farm2 and waited so I thought it would wait for approx 10minutes + random 3-5 minutes and go harvest potatos, instead it ran again to vendor even tho I had more than enough seeds so it shouldn't really go there, but it didn't anything which is good (uff) then it went back to farm1, watched over fully grown potatos for 10 seconds and went to farm2 without harvesting. From this point on it just repeats the same.
 
My farms are like 50-60 away from eachother right now but i ran into other problem right now, it moves between them and vendor with GPS but it just plants, it doesn't harvest, I made a test using potato and rice (potato farm1, rice farm2. When I started plugin it ran to vendor to refill stock using my quantity settings, planted potatos, ran to farm2 planted rice then it just stood on farm2 and waited so I thought it would wait for approx 10minutes + random 3-5 minutes and go harvest potatos, instead it ran again to vendor even tho I had more than enough seeds so it shouldn't really go there, but it didn't anything which is good (uff) then it went back to farm1, watched over fully grown potatos for 10 seconds and went to farm2 without harvesting. From this point on it just repeats the same.

If your gps file only has a path from farm1 -> seed vendor -> farm2 it will always follow that route. To go straight between farm1 -> farm2 you would need to make another link between the two, and gps should automatically choose shortest route.

Does it harvest rice at farm2? Sounds like it might be a typo issue, check spelling for what you set as the 'collect' variable. Any slight typo will result in not harvesting, to check you go up to fully grown potato/rice/whatever and mouseover the icon the pops up in the center of your screen. Type your collect variable EXACTLY as shows here.


I have to leave now, if you still have issues post back and I will check when I get home tonight.
 
var farm1seed = "Potato Eyes";
var farm1plant = "Potato";
var farm1collect = "Gathering: Spend 1 Labor to gather materials.";
//label
var farm2seed = "Rice Seed";
var farm2plant = "Rice";
var farm2collect = "Gathering: Spend 1 Labor to gather materials.";
-
-
-
-
//Plant farm 1
MoveToFarm1();
SetPlantMotionType(PlantMotionType.Standart); // change motion type if needed
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
PlantItemsAtFarm(farm1seed, farm1id);

//Plant farm 2
MoveToFarm2();
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
PlantItemsAtFarm(farm2seed, farm2id);

It moves between them, plants, doesn't gather
Should farm1collect be called "Potato" etc also? or just "Spend 1 labor blabla..."?

Edit1: No it neither harvest Rice, it seems that moving between farms is its priority now so its like
1) Go to farm
2) if its empty plant
3) go to next
4) if its empty plant
5) run back to farm 1
6) its grown but wait a second, im told to move to farm2, take care plants cya later
7) go to farm 2 again

Rinse Repeat
 
Last edited:
var farm1seed = "Potato Eyes";
var farm1plant = "Potato";
var farm1collect = "Gathering: Spend 1 Labor to gather materials.";
//label
var farm2seed = "Rice Seed";
var farm2plant = "Rice";
var farm2collect = "Gathering: Spend 1 Labor to gather materials.";
-
-
-
-
//Plant farm 1
MoveToFarm1();
SetPlantMotionType(PlantMotionType.Standart); // change motion type if needed
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
CollectItemsAtFarm(farm1plant, farm1collect, farm1id);
PlantItemsAtFarm(farm1seed, farm1id);

//Plant farm 2
MoveToFarm2();
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
CollectItemsAtFarm(farm2plant, farm2collect, farm2id);
PlantItemsAtFarm(farm2seed, farm2id);

It moves between them, plants, doesn't gather
Should farm1collect be called "Potato" etc also? or just "Spend 1 labor blabla..."?

Edit1: No it neither harvest Rice, it seems that moving between farms is its priority now so its like
1) Go to farm
2) if its empty plant
3) go to next
4) if its empty plant
5) run back to farm 1
6) its grown but wait a second, im told to move to farm2, take care plants cya later
7) go to farm 2 again

Rinse Repeat

Did you try looking for the tooltip? If you go up to a grown plant that's ready to harvest it will give you an icon. If you mouseover the icon it reads what you need to put in the collect variable.
You left it at the default, but I'm pretty sure potatos are farming, not gathering, not sure what rice is.
 
I'll check it out in a moment, yea it would make sense tho, keeping my thumbs up
Edit1: Ok that was the case, it has to be proper collect formula, for me it is farming: spend 1 labor to harvest crops, as you said any slight mistake renders it not functioning, for example at first i just typed farming: spend 1 labor to gather resources instead harvest crops... bam not working. I eyed again over tooltip and was like "really? would it make such a difference?? rly??" :D then I typed it as it stands in tooltip and it works now.
 
Last edited:
Ok so now that this is covered, is there a way, to differentiate wait times between farms? for example lets say i got 2x 16x16 and 2 8x8. I plant rice on 16x16's and potato on 8x8's. Potato grow time is 10 minutes and rice is 2 hours so I would rather move between 8x8's more often as they need some action more often and visit 16's on longer interval but count them as a pair so that once I get to 1st 16 and harvest, replant I dont have to wait like 30 minutes but go to next 16 harvest, replant then go back to 8x8's and work on them in 5 minute interval few times and then when time comes go to 16's again to harvest, replant them. In other words, any way to link specific farms into pairs or any other random setup and set different timers to them?

p.s JOKE TIME!! as a matter of fact i'd like this plugin to plant my 16x16 with lavender to form sentence "NOT A BOT" and then surround this sentence with rice plants, this function seems mandatory to me for avoiding getting banned. Or I dunno "GM! Check Savannah"
 
Last edited:
Back
Top