using ArcheBuddy.Bot.Classes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace YourNamespace
{
public class AutoMine : Core
{
private string sname = "Iron Vein";
private string critname = "Fortuna Vein";
private string sskil = "mining:spend up to 10 labor to extract ore";
private string critskil = "mining:spend up to 20 labor to extract ore";
private int zone = 50; // Выбор руды будет происходить только из тех объектов, у которых растояние от персонажа до руды меньше значения zone
private bool runSuccess;
private DoodadObject Ore;
private double dist;
public static string GetPluginAuthor()
{
return "xxx";
}
public static string GetPluginVersion()
{
return "0.0.1.0";
}
public static string GetPluginDescription()
{
return "Плагин, позволяющий автоматически копать руду.";
}
public void PluginRun()
{
SetGroupStatus("AutoMine", false);
while (true)
{
runSuccess = false;
if (GetGroupStatus("AutoMine"))
{
Ore = FindSome();
if (Ore != null)
{
while (Ore != null && GetGroupStatus("AutoMine"))
{
dist = me.dist(Ore);
// if (dist >= 2)
// {
// Teleport(Ore.X, Ore.Y, Ore.Z);
// }
// if (dist <= 1)
// {
// Mining();
// }
// if (runSuccess)
// {
// Ore = FindSome();
// Thread.Sleep(1500);
// }
}
}
}
Thread.Sleep(100);
}
}
public void Mining()
{
if (Ore.name == sname && Ore != null)
{
UseDoodadSkill(sskil, Ore, true);
runSuccess = true;
Thread.Sleep(1000);
}
else if (Ore.name == critname && Ore != null)
{
UseDoodadSkill(critskil, Ore, true);
runSuccess = true;
}
}
public DoodadObject FindSome()
{
DoodadObject mine = null;
double min = 0;
foreach (var obj in getDoodads().Where(x => x.dist(me) < zone && (x.name == sname || x.name == critname)))
{
if (min == 0)
{
min = me.dist(obj);
mine = obj;
}
else if (me.dist(obj) < min)
{
min = me.dist(obj);
mine = obj;
}
}
return mine;
}
}
}