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 = "Bugge";
private string farm2name = "Buggeone";
private string farm3name = "Buggetwo";
private string farm4name = "Buggetree";
//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

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 Bugge = "corn seed";
var Bugge = "corn";
var Bugge = "corn";
//FARM 2
var Buggeone = "corn seed";
var Buggeone = "corn";
var Buggeone = "corn";
//FARM 3
var Buggetwo = "corn seed";
var Buggetwo = "corn";
var Buggetwo = "corn";
//FARM 4
var Buggetree = "corn seed";
var Buggetree = "corn";
var Buggetree = "corn";
//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...");
}
}
}