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 =
{
"Hailrake", // Just an example
// Add lines for each name, spelling and case matters!
};
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
}
}
Now logging out to Login Screen.
Exception while pulsing plugin AvoidBaddies: System.Exception: Abandoning the current bot run.
at AvoidBaddies.AvoidBaddies.OnPulse()
at Loki.Utilities.Plugins.PluginManager.PulsePlugin(IPlugin plugin)
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",
// 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",
};
Looks good, thanks clandestine! I'll include that in a future guide when we get some time to consolidate all these small features that were added, but lost due to the recent forum issues.
Ok Il see if i can add the option for the settings... As i said im not the original coder for this Ive just added it all tougher.
None the less i should be able to change it.
^ That line is reponsible for logging you to login screen, while this might be more "suspicious" it is also safer whilst its instant (i think pushedx explained it as that a terminate packet is sent so you DC instantly) compared to the instance where it hops into the character select screen, that takes some time since you re not terminating the connection and can naturally cause death depending on your pc and other factors.if (LokiPoe.Gui.Logout(false)) // pass false to logout to login screen (much safer!)
The hell are you on about ? :-x This literally requires you to change one parameter in the function call , in this case a boolean .
^ That line is reponsible for logging you to login screen, while this might be more "suspicious" it is also safer whilst its instant (i think pushedx explained it as that a terminate packet is sent so you DC instantly) compared to the instance where it hops into the character select screen, that takes some time since you re not terminating the connection and can naturally cause death depending on your pc and other factors.
The hell are you on about ? :-x This literally requires you to change one parameter in the function call , in this case a boolean .
^ That line is reponsible for logging you to login screen, while this might be more "suspicious" it is also safer whilst its instant (i think pushedx explained it as that a terminate packet is sent so you DC instantly) compared to the instance where it hops into the character select screen, that takes some time since you re not terminating the connection and can naturally cause death depending on your pc and other factors.
private static string[] NamesToProcess =
{
// Invasion Bosses
"Alpha Paradisae",
"Atziri's Pride",
"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",
"Perquil the Lucky",
"Pewterfang",
"Rancor",
"Rima, Deep Temptress",
"Sheaq, Maker of Floods",
"Shivershell",
"Simi, the Nature Touched",
"Spinesnap",
"Strangledrift",
"Tailsinger",
"The Bolt Juggler",
"The Book Burner",
"The Duchess",
"The Firestarter",
"The Raging Mask",
"The Revenant",
"Thornrunner",
"Wiraqucha, Ancient Guardian",
"Wonderwalker",
// 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",
};