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

[Plugin] NotPanda'sFarmer

NotPanda

New Member
Joined
Jun 12, 2015
Messages
33
Reaction score
0
//////////////////////////////////////////
//////NotPanda's Farmer
//////////////////////////////////////////
//////////////////////////////////////////
//////Description
//////////////////////////////////////////
  • My goal for this plugin is to create a plugin with very little to no input. Currently a W.I.P.
  • To use the plugin grab the seeds you want to use, stand near/on your farms and press start
//////////////////////////////////////////
//////Features
//////////////////////////////////////////
  • Multi Seed/Animal/Tree
  • MultiFarm
  • Auto Populate Farm List (Any farm in the area that is owned by a family member and set to guild/family)
  • Auto Populate Seed/Animal/Tree
  • Retrieve Mail
//////////////////////////////////////////
//////Future Features
//////////////////////////////////////////
  • Death Check/Death Run
  • Water Plants
//////////////////////////////////////////
//////Known Issues
//////////////////////////////////////////
  • Too close to other objects when planting
    Pretty sure this is something to do with how the PlantItemsAtFarm method works.​
//////////////////////////////////////////
//////To Do
//////////////////////////////////////////
  • Sort Doodad list
  • Find a way to check if you are currently casting to avoid skipping over plants

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 NotPandaFarmer{
    public class Farmer : Core
    {
        public static string GetPluginAuthor()
        {
            return "NotPanda";
        }
        
        public static string GetPluginVersion()
        {
            return "1.0.0.0";
        }
        
        public static string GetPluginDescription()
        {
            return "NotPanda's Farmer";
        }
        
        uint[] _farmGroups = { 8, 21, 47, 48, 49, 51, 52, 53, 55 };   
        uint[] _badSkillId = { 16828, 18025, 13789, 16768, 13166, 19383};
        List<Housing> farms = new List<Housing>();
        int minLabour    = 5;  //Min labour to harvest
        //Call on plugin start
        public void PluginRun()
        {
            ClearLogs();     
            Log("[INFO] Start"); 
            while(true){      
                GetFarms();
                GetMail();                
                Harvest();   
                Plant();      
                Log("[INFO] Sleep 5 minutes");
                Thread.Sleep(300000);
            }
        }  
        public void GetMail(){ 
            RequestMailList();
            Thread.Sleep(1000);
            foreach (var mail in getMails()){
                mail.OpenMail();    
                if (!mail.isSent){
                    mail.ReceiveGoldFromMail();
                    Log("[INFO] Collecting gold.");
                    foreach (var item in mail.getItems())
                        mail.ReceiveItemFromMail(item);
                    mail.DeleteMail();
                }
                Thread.Sleep(1000);
            }
        }    
        public void GetFarms(){
            List<Creature> creatureList = getCreatures().Where(x => x.type == BotTypes.Housing).ToList();
            foreach(var farm in creatureList){
                Housing _farm = farm as Housing;
                foreach(var x in me.family.getMembers()){
                    if(_farm.ownerName == x.name && ((int)_farm.access == 1 || (int)_farm.access == 3)){  
                        farms.Add(_farm);
                    }
                }
            }
        }                                                                                                             
        public void Harvest(){  
            var labour = me.laborPoints;
            Log("[INFO] Current labour is " + labour);
            if( labour > minLabour ){
                foreach(var farm in farms){  
                    Log("[INFO] Harvensting on farm " + farm.name + " : " + farm.uniqId);
                    foreach(var _doodad in getDoodads()){   
                        if(_doodad.plantZoneId == farm.plantZoneId && _doodad.growthTime == 0){   
                            List<Skill> _skill = _doodad.getUseSkills();  
                            foreach(var skillName in _skill){ 
                                if(!_badSkillId.Contains(skillName.id)){ 
                                    // Log(_doodad.name + "");
                                    // Log(skillName.desc + "");
                                    // Log(skillName.id + "");   
                                    UseDoodadSkill(skillName.id,_doodad, true, 1); 
                                    Thread.Sleep(100);
                                } 
                            }
                            Thread.Sleep(25);
                        }
                    }
                }
            }
        }
        
        public void Plant(){  
            foreach(var farm in farms){   
                Log("[INFO] Planting on farm " + farm.name + " : " + farm.uniqId);
                foreach (var item in sqlCore.sqlItems)
                {      
                    if(_farmGroups.Contains(item.Value.itemCategorie.id) && itemCount(item.Value.id) > 0 && item.Value.implId == 9){   
                        var seedCount = itemCount(item.Value.id);
                        Log("[INFO] Seed Count: " + item.Value.name + " - " + seedCount); 
                        PlantItemsAtFarm(item.Value.id, farm.uniqId); 
                    }
                }
            } 
            
        }
        //Call on plugin stop
        public void PluginStop()
        {
        }
    }
}

Please let me know what works and doesn't work. In the process of testing it.
Post any improvements or suggestions.
 
Last edited:
The problem with auto population is the ability to limit which farms to plant on.
Don't get me wrong, I've taken this issue myself and have decided that a Gui & or config file is required to resolve this.
Take that into consideration as you further develop this.

Also nice clean code that is easy to understand is nice. Keep up the good work.
 
The problem with auto population is the ability to limit which farms to plant on.
Don't get me wrong, I've taken this issue myself and have decided that a Gui & or config file is required to resolve this.
Take that into consideration as you further develop this.

Also nice clean code that is easy to understand is nice. Keep up the good work.

Thanks for the input.
I'll try to think of ways around this.
My way of thinking is, if I don't want to plant on every farm and want to choose what farms I want to plant on then I should just use Scarecrow.
 
Back
Top