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 Mining
{
public class DefaultClass : Core
{
public static string GetPluginAuthor()
{
return "Alarm";
}
public static string GetPluginVersion()
{
return "1.0";
}
public static string GetPluginDescription()
{
return "Arcum Iris Mining Bot. Thanks to Gajda and Karls, I used some of their codes. As with Gajda's script, you also need to have your own path with points named as numbers.";
}
private const string _MOUNT_NAME = "Grey Donkey";
private Gps gps;
private int minecount;
private int searchradius = 10;
private Thread miner;
private string mountName;
DateTime lastQuickStep, lastRun;
private const bool _USE_QUICK_STEP = true; // use quick step (if available) while on mount
private const bool _USE_RUN = true; // use "Run!" skill from mount
private const uint _QUICKSTEP = 10723;
public void DetectMountName()
{
mountName = _MOUNT_NAME;
int highestLevel = 50;
List<uint> notMounts = new List<uint>() { 144, 139 };
List<Item> inventory = getAllInvItems();
foreach (Item item in inventory)
{
if (item.mountLevel > 0 && !notMounts.Contains(item.categoryId))
{
Log("Possible mount: " + item.name
+ "(level: " + item.mountLevel + " " + (item.mountAlive ? "DEAD" : "ALIVE") + ")"
+ " CatID: " + item.categoryId + " ItemID: " + item.id
);
if ((item.mountLevel < highestLevel) & (!item.name.Contains("Tabby")))
{
mountName = item.name;
highestLevel = item.mountLevel;
}
}
}
Log("MOUNT SELECTED: " + mountName);
}
public void Unmount()
{
if (me.sitOnMount)
{
DespawnMount();
Thread.Sleep(1500);
}
}
void gps_onGpsPreMove(GpsPoint point)
{
if (!me.sitOnMount & (GetGroupStatus("Mount")) & DoodsNearbyCount() < 1)
{
if (getMount() == null)
UseItem(mountName);
if (getMount() != null)
{
if (!getMount().isAlive())
{
Log("Trying to resurrect mount");
ComeTo(getMount(), 1, 1);
if (!RessurectMount(false))
Log("Failed rezzing mount: " + GetLastError());
}
Thread.Sleep(2000);
SitToMount();
//Thread.Sleep(1000);
}
else
Log("Failed to summon or use the mount");
}
else
{
// check for speed buffs
if (_USE_RUN && (DateTime.UtcNow - lastRun).TotalSeconds > 30)
{
Thread.Sleep(3000);
new Task(() => { UseSkill("Run!"); }).Start();
lastRun = DateTime.UtcNow;
}
else if (_USE_QUICK_STEP && (DateTime.UtcNow - lastQuickStep).TotalSeconds > 15)
{
Thread.Sleep(3000);
new Task(() => { UseSkill(_QUICKSTEP); }).Start();
lastQuickStep = DateTime.UtcNow;
}
}
}
public void PluginStop()
{
Log(DateTime.Now.ToLongTimeString() + " : Total mine count is " + minecount);
DelGroupStatus("Mount");
miner.Abort();
}
public void PluginRun()
{
ClearLogs();
DetectMountName();
SetGroupStatus("Mount", false);
minecount = 0;
Log(DateTime.Now.ToLongTimeString() + " : Start");
gps = new Gps(this);
Log("Loading " + Application.StartupPath + "\\Plugins\\Mining\\mine.db3");
gps.LoadDataBase(Application.StartupPath + "\\Plugins\\Mining\\mine.db3");
gps.onGpsPreMove += gps_onGpsPreMove;
miner = new Thread(Mine);
miner.Start();
DoMineRun();
}
public int DoodsNearbyCount()
{
int count = 0;
foreach (var dood in getDoodads())
{
if (me.dist(dood) < searchradius * 2 & !dood.name.Contains("Remnant") & !dood.name.Contains("Unknown") && dood.name.Contains("ein"))
{
count++;
}
}
return count;
}
public DoodadObject NearestDood()
{
DoodadObject d = null;
int dd = 999;
foreach (var dood in getDoodads())
{
if (me.dist(dood) < dd && !dood.name.Contains("Remnant") && !dood.name.Contains("Unknown") && dood.name.Contains("ein") && me.dist(dood) < searchradius)
{
d = dood;
}
}
return d;
}
public void DoMineRun()
{
Log(DateTime.Now.ToLongTimeString() + " : Total mine count is " + minecount);
for (int i = 1; i < 8; i++)
{
Log(DateTime.Now.ToLongTimeString() + " : movint to point " + i.ToString());
if (skillCooldown("Freerunner") > 0)
UseSkill("Dash");
else
UseSkill("Freerunner");
while (!gps.GpsMove(i.ToString()))
{
Thread.Sleep(50);
}
//UseSkill("/salute");
Log(DateTime.Now.ToLongTimeString() + " : at point " + i.ToString() + "; Mine count = " + minecount);
}
DoMineRun();
}
public void Mine()
{
DoodadObject doodad = null;
while (true)
{
doodad = NearestDood();
if (doodad != null)
{
gps.SuspendGpsMove();
if (me.sitOnMount)
StandFromMount();
//Log(DateTime.Now.ToLongTimeString() + " : " + doodad.name + " " + doodad.id.ToString() + " " + doodad.dist(me));
var skills = doodad.getUseSkills();
double doodadCastDist = 0;
if (skills.Count > 0)
{
TurnDirectly(doodad);
if (UseDoodadSkill(skills[0].id, doodad, true))
{
minecount++;
Thread.Sleep(500);
//items = Sort(getDoodads());
}
while (isCasting())
Thread.Sleep(50);
}
}
Thread.Sleep(500);
if (gps.gpsMoveSuspended)
gps.ResumeGpsMove();
Thread.Sleep(100);
}
}
public void CheckAggro()
{
//Log(DateTime.Now.ToLongTimeString() + " : 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())
{
TurnDirectly(me.target);
if (skillCooldown("Freezing Arrow") == 0)
{
Log(DateTime.Now.ToLongTimeString() + " Endless Arrows");
UseSkill("Endless Arrows", false);
Thread.Sleep(100);
}
else
{
if (skillCooldown("Crippling Mire") == 0)
{
Log(DateTime.Now.ToLongTimeString() + " Crippling Mire");
UseSkill("Crippling Mire", false);
Thread.Sleep(100);
}
else
{
if (skillCooldown("Flamebolt") == 0)
{
Log(DateTime.Now.ToLongTimeString() + " Flame Bolt");
UseSkill("Flamebolt", false);
Thread.Sleep(100);
}
}
}
if (!obj.inFight)
return;
}
Log(DateTime.Now.ToLongTimeString() + " : fight is over");
}
}
}
}
}