using System;
using System.Diagnostics;
using System.Linq;
using log4net;
using Loki.Game;
using Loki.Utilities;
using Loki.Utilities.Plugins;
namespace AvoidBaddies
{
/// <summary> </summary>
public class AvoidBaddies
: IPlugin
{
#region Implementation of IEquatable<IPlugin>
/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
/// <returns>
/// true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.
/// </returns>
/// <param name="other">An object to compare with this object.</param>
public bool Equals(IPlugin other)
{
return Name.Equals(other.Name);
}
#endregion
private static readonly ILog Log = Logger.GetLoggerInstanceForType();
#region Implementation of IPlugin
/// <summary> </summary>
public string Author { get { return "pushedx"; } }
/// <summary> </summary>
public Version Version { get { return new Version(0, 1, 0, 0); } }
/// <summary> </summary>
public string Name { get { return "AvoidBaddies"; } }
/// <summary> </summary>
public string Description { get { return "This plugin shows an example of bailing out on a bot run when a dangerous mob is detected."; } }
/// <summary> Executes the start action. This is called when the bot starts. </summary>
public void OnStart()
{
}
/// <summary> Executes the stop action. This is called when the bot is stopped. </summary>
public void OnStop()
{
}
private static string[] NamesToProcess =
{
// Invasion Bosses
"Alpha Paradisae",
"Balus Stoneskull",
"Bladeback Guardian",
"Bladetooth",
"Blood Morpher",
"Blood Stasis",
"Cintiq, the Inescapable",
"Coniraya, Shadow of Malice",
"Corpsestitch",
"Corrector Draconides",
"Droolscar",
"Evocata Apocalyptica",
"Genesis Paradisae",
"Glassmaul",
"Granitecrush",
"Grath",
"Guardian of the Mound",
"Harbinger of Elements",
"Haviri, Vaal Metalsmith",
"Inti of the Blood Moon",
"Jikeji",
"Judgement Apparatus",
"Junglemare",
"Kall Foxfly",
"Konu, Maker of Wind",
"Kutec, Vaal Fleshsmith",
"M'gaska, the Living Pyre",
"Mammothcage",
"Mother of the Swarm",
"Nighteater",
"Ossecati, Boneshaper",
"Pewterfang",
"Rancor",
"Rima, Deep Temptress",
"Sheaq, Maker of Floods",
"Shivershell",
"Spinesnap",
"Strangledrift",
"Tailsinger",
"The Bolt Juggler",
"The Book Burner",
"The Duchess",
"The Firestarter",
"The Raging Mask",
"The Revenant",
"Thornrunner",
"Wiraqucha, Ancient Guardian",
"Wonderwalker",
"Ch'aska, Maker of Rain",
"Kamaq, Soilmaker",
// Rogue Exiles
"Antalie Napora",
"Armios Bell",
"Ash Lessard",
"Damoi Tui",
"Eoin Greyfur",
"Igna Phoenix",
"Ion Darkshroud",
"Jonah Unchained",
"Minara Anemina",
"Orra Greengate",
"Thena Moga",
"Tinevin Highdove",
"Torr Olgosso",
"Xandro Blooddrinker",
};
private static Stopwatch baddieCheckStopwatch = Stopwatch.StartNew();
/// <summary> Executes the pulse action. This is called every "tick" of the bot. </summary>
public void OnPulse()
{
if (LokiPoe.ObjectManager.Me.IsInTown)
return;
if (baddieCheckStopwatch.ElapsedMilliseconds > 1000)
{
baddieCheckStopwatch.Restart();
// Check to see if any of the baddie names are found.
if (LokiPoe.ObjectManager.Objects.Any(o => NamesToProcess.Contains(o.Name)))
{
// This will request the bot abandon the current bot run. However, it must finish combat, and
// a few other things first. It's possible you can combat chain your way into the boss you're
// trying to avoid, so logging out might be the better approach for Hardcore.
//Registry.AbandonCurrentBotRun();
// Alternatively, you can chicken out which will ensure you don't get close to it at all.
// We check the return value, because we can't force the client to logout at times.
if (LokiPoe.Gui.Logout(false)) // pass false to logout to login screen (much safer!)
{
// Force the bot logic to start over.
throw new Exception("Abandoning the current bot run.");
}
}
}
}
/// <summary>
/// Executes the initialize action. This is called at initial bot startup. (When the bot itself is started, not
/// when Start() is called)
/// </summary>
public void OnInitialize()
{
}
/// <summary> Executes the shutdown action. This is called when the bot is shutting down. (Not when Stop() is called) </summary>
public void OnShutdown()
{
}
/// <summary> Executes the enabled action. This is called when the user has enabled this specific plugin via the GUI. </summary>
public void OnEnabled()
{
}
/// <summary> Executes the disabled action. This is called whent he user has disabled this specific plugin via the GUI. </summary>
public void OnDisabled()
{
}
/// <summary> Executes the config action. This is called when the user clicks on the config button.</summary>
public void OnConfig()
{
}
#endregion
}
}