public override bool Do() { bool hide; int minutes = 0; GUnit Player = null; Player = GetClosestPlayer(); if (Player != null && Player.DistanceToSelf < AvoidRange) { GSpellTimer WaitAfterLeave = new GSpellTimer(10 * 1000); // wait an exta 10 s GSpellTimer SpamTimer = new GSpellTimer(60 * 1000); // Spam every 1 min System.Media.SoundPlayer sp = new System.Media.SoundPlayer("PlayerNear.wav"); WaitAfterLeave.Reset(); SpamTimer.Reset(); try { if (PlaySound) { sp.Load(); sp.Play(); } } catch { } do { if (Me.IsInCombat) { PPather.WriteLine("AvoidPlayers: I was attacked while hiding"); return(false); } if (Me.IsDead) { PPather.WriteLine("AvoidPlayers: I died while hiding"); return(false); } hide = false; if (WaitUntilClear == true && GetClosestPlayer() != null) { hide = true; } else if (WaitUntilClear != true && GetClosestPlayer().DistanceToSelf < AvoidRange) { hide = true; } if (hide) { WaitAfterLeave.Reset(); } if (Me.PlayerClass.ToString() == "Rogue" && StealthWhileHiding == true && !GPlayerSelf.Me.IsStealth) { GContext.Main.CastSpell(StealthKey); } if (Me.PlayerClass.ToString() == "Druid" && StealthWhileHiding == true && !GPlayerSelf.Me.IsStealth) { if (!Me.HasWellKnownBuff("CatForm")) { GContext.Main.CastSpell(CatFormKey, true, false); // if we aren't in cat form, then switch before trying to stealth } GContext.Main.CastSpell(StealthKey, true, false); } if (SpamTimer.IsReady) { SpamTimer.Reset(); minutes++; PPather.WriteLine("AvoidPlayers: Waited " + minutes.ToString() + "minutes for players to leave."); if (PlaySound) { sp.Play(); } if (minutes >= TimeUntilExit) { PPather.WriteLine("AvoidPlayers: Time to log out"); GContext.Main.HearthAndExit(); return(false); } } Thread.Sleep(1000); } while (!WaitAfterLeave.IsReady); return(true); } return(false); }