<CustomBehavior File="RunCode" Type="Definition"><![CDATA[
public static class StuckDetection
{
public static Vector3 LastPoint = new Vector3(0f,0f,0f);
public static bool IsStuck()
{
if (!StyxWoW.Me.IsValid) return false;
if (StyxWoW.Me.IsDead) return false;
if (StyxWoW.Me.IsActuallyInCombat) return false;
if (StyxWoW.Me.HasAura("Resurrection Sickness")) return false;
var currentPoint = StyxWoW.Me.Location;
var isStuck = currentPoint.DistanceSqr(LastPoint) < 10f * 10f;
LastPoint = currentPoint;
return isStuck;
}
}
]]>
</CustomBehavior>
<CustomBehavior File="RunCode" Code="StuckDetection.LastPoint = new Vector3(0f,0f,0f);" /> <!-- Clean out stale data in case the user stop/starts the bot. -->
<CustomBehavior File="Hooks\DoWhen" ActivityName="DoWhen_StuckDetector" AllowUseWhileMounted="true" LogExecution="false" UseAtInterval="210000" >
<If Condition="StuckDetection.IsStuck() && HasItem(6948)" >
<CustomBehavior File="RunCode"><![CDATA[
Logging.Write(System.Windows.Media.Colors.DeepSkyBlue, "[ProfileBase]: Stuck detection activated!");
await CommonCoroutines.StopMoving();
await CommonCoroutines.LandAndDismount();
WoWItem hearthstoneItem = StyxWoW.Me.BagItems.FirstOrDefault(x => x.Entry == 6948);
if (hearthstoneItem.CooldownTimeLeft != TimeSpan.Zero) {
Logging.Write(System.Windows.Media.Colors.DeepSkyBlue, "[ProfileBase]: Awaiting Hearthstone cooldown before attempting hearth!");
await Coroutine.Wait(1800000, () => hearthstoneItem.CooldownTimeLeft == TimeSpan.Zero);
}
hearthstoneItem.Interact();
await Coroutine.Sleep(11500);
Logging.Write(System.Windows.Media.Colors.DeepSkyBlue, "[ProfileBase]: Reloading profile.");
ProfileManager.LoadNew(ProfileManager.XmlLocation);
]]>
</CustomBehavior>
</If>
</CustomBehavior>