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

[Plugin] EzMiner - Looped Above Ground Miner

odotsexy

New Member
Joined
Jun 20, 2015
Messages
18
Reaction score
0
Taken from: http://gamestrats.com/archeage-discussion/(archebuddy)-ezminer-looped-above-ground-miner

Description: Run's around a mine, clears out mobs, then mines the closest ore. Perfect for low level mining zones. Currently for use on a character who can easily handle the mobs in the zone, most low level mining areas are perfect for a 1-32 quest bot.

Setup: Compile to a folder named "EzMiner" inside of your plugins folder. Create a new GPS database inside of this folder named "gps.db3". To setup the points, start your character at the beginning of the mine, or where you want your loop to begin. Load up the GPS plugin. Check the Auto mode and configure the Distance/Angle, I used the values 20.0/15 respectively. Set the mode to Patch. Now run a full loop around where you are mining, this will create a waypoint system so your bot does not run into walls.

Donate: If you find this script useful or want to see updates to it, please find it in your heart to donate me a few dollars! A coffee goes a long way in the coding world!




Code:
using System;
using System.Drawing;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EzMiner
{
    public class EzMiner : Core
    {  
        Gps gps;
        
        public static string GetPluginAuthor()
        {
            return "http://GameStrats.com";
        }

        public static string GetPluginVersion()
        {
            return "1.0.1.0";
        }

        public static string GetPluginDescription()
        {
            return "EzMiner - http://GameStrats.com";
        }
       
        public void PluginRun()
        {
            gps = new Gps(this);
            gps.LoadDataBase(Application.StartupPath + "\\Plugins\\EzMiner\\gps.db3");
            gps.onGpsPreMove += gpsPreMove;
            
            while(me.laborPoints > 100)
            {
                ClearMobs();
                HarvestOre();
            }
            
            PluginStop();
        }
        
        private void gpsPreMove(GpsPoint point)
        {
            List<Creature> aggroMobs = getAggroMobs();
            if (aggroMobs.Count > 0)
                ClearMobs();
        }
       
        public void ClearMobs()
        {
            RoundZone zone = new RoundZone(me.X, me.Y, 50); 
            foreach (Creature mob in getAggroMobs())
            {
                if ( mob.type == BotTypes.Npc && isAttackable(mob) && isAlive(mob) && me.dist(mob) < 15 && zone.ObjInZone(mob) )
                {
                    try
                    {
                        SetTarget(mob);
                        while(isAlive(mob))
                        {
                            if(SkillReady("Flamebolt"))
                            {
                                UseSkillAndWait("Flamebolt");
                            }
                            else if(SkillReady("Mana Stars"))
                            {
                                UseSkillAndWait("Mana Stars");
                            }
                            else if(SkillReady("Endless Arrows"))
                            {
                                UseSkillAndWait("Endless Arrows");
                            }
                            else if(SkillReady("Rapid Strike"))
                            {
                                UseSkillAndWait("Rapid Strike");
                            }
                            else if(SkillReady("Triple Slash"))
                            {
                                UseSkillAndWait("Triple Slash");
                            }
                            else if(SkillReady("Critical Discord"))
                            {
                                UseSkillAndWait("Critical Discord");
                            }                              
                            else if(SkillReady("Shoot Arrow"))
                            {
                                UseSkillAndWait("Shoot Arrow");
                            }
                        }
                    }
                    catch
                    {  
                        
                    }
                    
                }
            }
        }
        
        public bool SkillReady(string skillName) {
            return isSkillLearned(skillName) && (skillCooldown(skillName) == 0);
        }
        
        public void UseSkillAndWait(string skillName, bool selfTarget = false, bool autoRun = true)
        {
            //wait for cooldowns to finish first, before we try to cast skill
            while (me.isCasting || me.isGlobalCooldown)
                Thread.Sleep(50);
            bool success = false;
            if (selfTarget)
                success = UseSkill(skillName, autoRun, selfTarget);
            else if (me.target != null)
                success = UseSkill(skillName, me.target.X, me.target.Y, me.target.Z+2, autoRun);
            
            if (!success)
            {   
                
                if (me.target != null && GetLastError() == LastError.NoLineOfSight)
                {
                    //No line of sight, try come to target.
                    if (dist(me.target) <= 5)
                        ComeTo(me.target, 2, 3);
                    else if (dist(me.target) <= 10)
                        ComeTo(me.target, 3, 5);
                    else if (dist(me.target) < 20)
                        ComeTo(me.target, 8, 10);
                    else
                        ComeTo(me.target, 8, 12);
                }
            }
            //wait for cooldown again, after we start cast skill
            while (me.isCasting || me.isGlobalCooldown)
                Thread.Sleep(50);
        }
        
        public void HarvestOre()
        {   
            RoundZone zone   = new RoundZone(me.X, me.Y, 50);
            DoodadObject ore = FindClosestOre();
            try
            {
                if (ore != null)
                {
                    GpsPoint gpsPoint = gps.GetNearestPoint(ore.X, ore.Y, ore.Z);
                    gps.GpsMove(gpsPoint, 5);
                    MoveTo(ore);
                    switch(ore.name)
                    {
                        case "Fortuna Vein": 
                            UseDoodadSkill("Mining: Spend up to 20 Labor to extract ore.", ore, true, 1.5);
                            break;
                        case "Iron Vein":
                            UseDoodadSkill("Mining: Spend up to 10 Labor to extract ore.", ore, true, 1.5);
                            break;                        
                    }
                }
           }
           catch(Exception)
           {
           }
            
        }
              
        public DoodadObject FindClosestOre()
        {
            DoodadObject fortunaVein = getNearestDoodad("Fortuna Vein");
            DoodadObject ironVein    = getNearestDoodad("Iron Vein");
            
            if (fortunaVein == null && ironVein == null)
            {
                return null;
            }
            
            if (ironVein == null)
                return fortunaVein;
            
            if (fortunaVein == null)
                return ironVein; 
            
            if (me.dist(fortunaVein) < me.dist(ironVein))
            {
                return fortunaVein;
            }
            else
            {
                return ironVein;
            }

        }

        public void PluginStop()
        {
        }
   }
}
 
Last edited:
Updated: Smarter mob clearing, cleans up mobs that agro while running the loop, and only attacks mobs that are agro.
 
Hi odotsexy
i have test this script, it works but it has a small issu (not really).
When the char ended to mining an "Iron Vein" and a "Fortuna Vein" spawn up, the char move to the next nearest "Iron Vein".

Actual sequence is:
> Find Iron Vein/ Fortuna Vein spot -> Minging Iron Vein/ Fortuna Vein -> Next spot Iron Vein/ Fortuna Vein -> (Loop)
That means, instead to do Iron Vein + Fortuna Vein ( if(Fortuna Vein) is up), it did Iron Vein, Go next spot, Go back for Iron Vein or Fortuna Vein

The right sequence would rather like:
> Find Iron Vein -> Minging Iron Vein
Wait, Check if Fortuna Vein will pop:
If Yes -> Minging Fortuna Vein -> Next Spot (loop)
If No -> -> Next Spot (loop)

Have found the solution:
Code:
                    switch(ore.name)
                    {
                        case "Fortuna Vein": 
                            UseDoodadSkill("Mining: Spend up to 20 Labor to extract ore.", ore, true, 1.5);
                         break;

                        case "Iron Vein":
                            UseDoodadSkill("Mining: Spend up to 10 Labor to extract ore.", ore, true, 1.5);
                           break;                        
                    }

Replace by
Code:
                     switch(ore.name)
                    {
                        case "Fortuna Vein": 
                            UseDoodadSkill("Mining: Spend up to 20 Labor to extract ore.", ore, true, 1.5);
                         break;

                        case "Iron Vein":
                            UseDoodadSkill("Mining: Spend up to 10 Labor to extract ore.", ore, true, 1.5);
                            Thread.Sleep(300);
                            UseDoodadSkill("Mining: Spend up to 20 Labor to extract ore.", ore, true, 1.5);
                         break;                        
                    }
 
Last edited:
Hm, does not work for me.
After creating gps.db3 and starting EzMiner it loads the route:
Success load 10 points and 9 links + and 0 polygons.
And then the plugin ends without moving / doing anything.
 
Ops...
Code:
while(me.laborPoints > 100)
I will report back when I am above those ^^
 
How do I get this to not reach out for ore greater than the distance around my character. It is having a problem picking up ore far away and overriding the ore around me.
 
Last edited:
How do I get this to not reach out for ore greater than the distance around my character. It is having a problem picking up ore far away and overriding the ore around me.

public void HarvestOre()
{
RoundZone zone = new RoundZone(me.X, me.Y, 50); // change this 50 to a smaller number but make sure your gps points are close enough to the ore for it to see them. At least i think thats all you need to do.
 
Updated: Smarter mob clearing, cleans up mobs that agro while running the loop, and only attacks mobs that are agro.
Любезный, расскажите подробно как запустить ваш плагин с GPS, как назвать точки GPS что бы он ходил. Kind and tell us in detail how to run your plugin with GPS, how to GPS point name that he went.
 
odotsexy a question you use
RoundZone zone = new RoundZone(me.X, me.Y, 50);
but what in the rest of code makes it only look in that roundzone for ore or mobs?
Darkstar what i said above won't help from what i can see as it doesn't really use that roundzone to search for ore in so not sure how you could get it to do what you want without modding the code some
 
The plugin does not follow the route, goes against the walls, left without undermining ores, goes on areas that are not on the road ... But the rest works well. And thanks for Orion42 correction code.
 
i am not sure poster of this is the actual author since he shows a link to another place?
Anyway i have found this to go way off path as it is not using the roundzone to mine from because i set it to five and he still wanders way off that to gather ore that there is no way it would do if it was using that zone only.anyway just what i have noticed about this one is it goes far and wide to get veins that are no where near route or zone.
I am checking out gajda mining can set distance from you that it will actually get ore from on your route points default is 20 but you can find where in code to change that.
 
Back
Top