fredgsanford
Member
- Joined
- Jan 2, 2015
- Messages
- 552
- Reaction score
- 0
i added a few things to gajda's bot this is 99% his work so give credit to him not me.
Updated to only do iron and fortuna let me know if this part works as i haven't got to test it yet
I added some changeable variables near top and
added to stop at certain labor and goto an afk spot using an auto selected mount which you can edit as one of variables and also one to tell it when to restart
it will use a mount to get to start of mining route at start of the plugin and to go afk. But not while its mining it does not use dash etc either.
Also you can set the random delay between runs with those two variables near top.
still needs named points ie for mining starting at 1 to however many you use and you need to set that variable to but its set to the number of nodes to mine and other named point it needs is afk one.
Checks aggro now while its waiting for the random timer between runs which it didn't do before.
Also added support for a few other skills although that part is untested yet.
Also can set radius around you when your at the node it will mine veins at.
Can't remember what else i changed atm.
Updated to only do iron and fortuna let me know if this part works as i haven't got to test it yet
I added some changeable variables near top and
added to stop at certain labor and goto an afk spot using an auto selected mount which you can edit as one of variables and also one to tell it when to restart
it will use a mount to get to start of mining route at start of the plugin and to go afk. But not while its mining it does not use dash etc either.
Also you can set the random delay between runs with those two variables near top.
still needs named points ie for mining starting at 1 to however many you use and you need to set that variable to but its set to the number of nodes to mine and other named point it needs is afk one.
Checks aggro now while its waiting for the random timer between runs which it didn't do before.
Also added support for a few other skills although that part is untested yet.
Also can set radius around you when your at the node it will mine veins at.
Can't remember what else i changed atm.
Code:
//start
// gajda mining bot to check out with a couple of modifications by fredgsanford
/// IMPORTANT set to use dif skills for agro but yours may not be in here so you can let me know and i can add them or you can
//
/* things i added afk spot,
a variable to set number of nodes near top of file so don't have to look for it. note
a variable to set start and stop labor amounts,
detect mount and use it to goto start from afk spot and to also goto the afk spot
set amount of time for random delay between runs
checks for aggro while you are paused between runs
if anyone can tell me how to set it to it will check for aggro while on gps move that would rock and be appreciated.
all these settings are now near top of file to make it easier to find them.
a variable to set ming radius to mine around each point in your path
*/
using System;
using System.Drawing;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using ArcheBuddy.Bot.Classes;
using System.Windows.Forms;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Text;
using System.ComponentModel;
namespace DefaultNameSpace{
public class DefaultClass : Core
{
// editable variables set these to what you want them to be
// these 1st two are for a random timer that sets the minimum and maximum times to wait before doing each run to allow mining veins to repop.
// note that while its waiting it still checks for agro
const int min_wait = 135; // this is a pause after each full run and this is the minimum time it will wait
const int max_wait = 143; // this is pause after each run and this is the maximum time it will wait
const string _MOUNT_NAME = ""; // if this is left empty ie = "" it will autodetect mount to use. Mount is used to go to and from afk spot only
const int mineradius = 10; // radius around each mining point you want it to grab ore from. ie how far to look around you at each point to grab ore
const int numberofnodes = 28; // set this to the number of nodes in your route ie you you are mining
const int labor_to_stop = 501; // set this to the amount of labor you want the bot to stop mining at it will prob do whatever nodes already seen before doing so.
const int labor_to_restart_at = 1500; // set this to the amount of labor you want the bot to restart mining at.
// do not edit the ones below here
const int nodes = numberofnodes + 1;
string mountName;
public static string GetPluginAuthor()
{
return "Gajda";
}
public static string GetPluginVersion()
{
return "1.3.0";
}
public static string GetPluginDescription()
{
return "mining bot";
}
private Gps gps;
//Call on plugin start
public void PluginRun()
{
ClearLogs();
Log(DateTime.Now.ToLongTimeString() + " : Start");
DetectMountName();
Log("MOUNT SELECTED: " + mountName);
gps = new Gps(this);
gps.LoadDataBase(Application.StartupPath + "\\Plugins\\Mining\\mine.db3");
if (me.laborPoints < labor_to_stop)
{
gotosafespot();
}
movetostart();
DoMineRun();
}
public List<DoodadObject> Sort(List<DoodadObject> tempitems)
{
Log(DateTime.Now.ToLongTimeString() + " : I see " + tempitems.Count + " items");
List<DoodadObject> items = new List<DoodadObject>();
for(int i=0;i<tempitems.Count;i++)
{
if(tempitems[i].name.Contains("ein") && (tempitems[i].dist(me)<mineradius) &! tempitems[i].name.Contains("Remnant") &! tempitems[i].name.Contains("nknown") &! tempitems[i].name.Contains("roken"))
{
items.Add(tempitems[i]);
}
}
Log(DateTime.Now.ToLongTimeString() + " : I see " + items.Count + " usable item(s)");
bool needSort = true;
if(items.Count<2)
needSort = false;
int loop = 1;
while(needSort)
{
Log(DateTime.Now.ToLongTimeString() + " : sorting run " + loop);
bool changed = false;
for(int i=0;i<items.Count-1;i++)
{
if(items[i].dist(me)>items[i+1].dist(me))
{
var tempItem = items[i];
items[i]=items[i+1];
items[i+1]=tempItem;
changed = true;
}
}
if(changed==false)
{
needSort = false;
}
loop++ ;
}
return items;
}
public void DoMineRun()
{
for(int i=1;i<nodes;i++)
{
CheckAggro();
if (me.laborPoints < labor_to_stop)
{
gotosafespot();
}
Log(DateTime.Now.ToLongTimeString() + " : moving to point " + i.ToString());
// UseSkill("Dash");
while(!gps.GpsMove(i.ToString()))
{
Thread.Sleep(100);
}
Log(DateTime.Now.ToLongTimeString() + " : at point " + i.ToString());
CheckAggro();
while(Mine())
{
Thread.Sleep(100);
}
}
CheckAggro();
Log(DateTime.Now.ToLongTimeString() + " : moving to start");
gps.GpsMove("1");
CheckAggro();
Random rnd = new Random();
int wait = rnd.Next(min_wait,max_wait);
wait = wait*1000;
Log(DateTime.Now.ToLongTimeString() + " : wait " + wait.ToString());
Log(DateTime.Now.ToLongTimeString() + " : CheckAggro");
while (wait > 1000)
{
Thread.Sleep(1000);
CheckAggro();
wait = wait - 1000;
}
if (me.laborPoints < labor_to_stop)
{
gotosafespot();
}
DoMineRun();
}
public bool Mine()
{
Log(DateTime.Now.ToLongTimeString() + " : looking for veins");
bool mined = false;
List<DoodadObject> items = Sort(getDoodads());
Log(DateTime.Now.ToLongTimeString() + " : founded " + items.Count);
foreach(var doodad in items)
{
Log(DateTime.Now.ToLongTimeString() + " : " + doodad.name + " " + doodad.dist(me));
}
foreach(var doodad in items)
{
if(doodad.name.Contains("ein") && (doodad.dist(me) < mineradius) &! doodad.name.Contains("Remnant") &! doodad.name.Contains("nknown") &! doodad.name.Contains("roken"))
{
mined = true;
checkfordailyquest();
Log(DateTime.Now.ToLongTimeString() + " : " + doodad.name + " " + doodad.id.ToString() + " " + doodad.dist(me));
var skills = doodad.getUseSkills();
double doodadCastDist = 0;
if (skills.Count > 0)
{
if (doodadCastDist == 0)
{
Thread.Sleep(500);
Log(DateTime.Now.ToLongTimeString() + " : mining");
TurnDirectly(doodad);
UseDoodadSkill(skills[0].id, doodad, true);
}
Thread.Sleep(1000);
}
}
}
return mined;
}
public void CheckAggro()
{
if(getAggroMobs().Count > 0)
{
Log(DateTime.Now.ToLongTimeString() + " : " + getAggroMobs().Count.ToString());
foreach(var obj in getAggroMobs())
{
Log(DateTime.Now.ToLongTimeString() + " : " + obj.name);
SetTarget(obj);
TurnDirectly(me.target);
Log(DateTime.Now.ToLongTimeString() + " : fighting");
while(obj.isAlive())
{
// might put something in here later to check for hp and use potion or heal skill if have them and use them etc
TurnDirectly(me.target);
if(isSkillLearned("Enervate") && skillCooldown("Enervate")==0)
{
Log(DateTime.Now.ToLongTimeString() + " Enervate");
UseSkill("Enervate", false);
Thread.Sleep(100);
}
else if(isSkillLearned("Charge") && skillCooldown("Charge")==0)
{
Log(DateTime.Now.ToLongTimeString() + " Charge");
UseSkill("Charge", false);
Thread.Sleep(100);
}
else if(isSkillLearned("Freezing Arrow") && skillCooldown("Freezing Arrow")==0)
{
Log(DateTime.Now.ToLongTimeString() + " Freezing Arrow");
UseSkill("Freezing Arrow", false);
Thread.Sleep(100);
}
else if(isSkillLearned("Stalker's Mark") && skillCooldown("Stalker's Mark")==0)
{
Log(DateTime.Now.ToLongTimeString() + " Stalker's Mark");
UseSkill("Stalker's Mark", false);
Thread.Sleep(100);
}
// need to find a few more for above for dif classes
else
{
if(isSkillLearned("Critical Discord") && skillCooldown("Critical Discord")==0)
{
Log(DateTime.Now.ToLongTimeString() + " Critical Discord");
UseSkill("Critical Discord",false);
Thread.Sleep(100);
}
else if(isSkillLearned("Flame Bolt") && skillCooldown("Flame Bolt")==0)
{
Log(DateTime.Now.ToLongTimeString() + " Flame Bolt");
UseSkill("Flame Bolt",false);
Thread.Sleep(100);
}
else if(isSkillLearned("Triple Slash") && skillCooldown("Triple Slash")==0)
{
Log(DateTime.Now.ToLongTimeString() + " Triple Slash");
UseSkill("Triple Slash",false);
Thread.Sleep(100);
}
else if(isSkillLearned("Endless Arrows") && skillCooldown("Endless Arrows")==0)
{
Log(DateTime.Now.ToLongTimeString() + " Endless Arrows");
UseSkill("Endless Arrows",false);
Thread.Sleep(100);
}
else
{
Log(DateTime.Now.ToLongTimeString() + " Shoot Arrow - using this as have no other skills");
UseSkill("Shoot Arrow",false);
}
}
if(!obj.inFight)
return;
}
Log(DateTime.Now.ToLongTimeString() + " : fight is over");
}
}
}
public void gotosafespot()
{
Log(DateTime.Now.ToLongTimeString() + " : moving to afk because labor is below set amount");
mountup();
gps.GpsMove("afk");
unmount();
while (me.laborPoints < labor_to_restart_at)
{
Thread.Sleep(5000);
CheckAggro();
}
Log(DateTime.Now.ToLongTimeString() + " : moving to start");
mountup();
gps.GpsMove("1");
unmount();
CheckAggro();
return;
}
// this one detects mount to use if you leave the _MOUNT_NAME blank in variables near top
public void DetectMountName()
{
mountName = _MOUNT_NAME;
if (_MOUNT_NAME != "")
return;
int highestLevel = 0;
List<Item> inventory = getAllInvItems();
foreach (Item item in inventory)
{
if (item.mountLevel > 0 && item.db.useSkill.name == "Summon Mount")
{
if (item.mountLevel > highestLevel)
{
mountName = item.name;
highestLevel = item.mountLevel;
}
}
}
}
public void unmount()
{
if (me.sitOnMount)
{
DespawnMount();
Thread.Sleep(1500);
}
}
public void mountup()
{
if (!me.sitOnMount)
{
if (getMount() == null)
{
Log("Trying to summon our mount");
UseItem(mountName);
Thread.Sleep(1000);
}
if (getMount() != null)
{
if (!getMount().isAlive())
{
Log("Trying to resurrect mount");
ComeTo(getMount(), 1, 1);
if (!RessurectMount(false))
Log("Failed rezzing mount: " + GetLastError());
}
SitToMount();
}
else
Log("Failed to summon or use the mount");
}
}
// adding movetoarea to move to start of mining area from somewhere on the gps route ie afk spot at start of run using mount
public void movetostart()
{
GpsPoint point = gps.GetPoint("1");
// only teleport if we're somewhat far away from the area might need to edit this
if (dist(point.x, point.y, point.z) > 100)
{
mountup();
}
gps.GpsMove("1");
Thread.Sleep(500);
unmount();
Thread.Sleep(1000);
}
public void checkfordailyquest()
{
// quest id for Blue Salt Request: Ore is 6779
}
public void PluginStop()
{
}
}
}
// end
Last edited: