public static void RunRotation(List <RotationStep> rotation) { float globalCd = GetGlobalCooldown(); bool gcdEnabled = globalCd != 0; IsCast = Me.IsCast || Me.IsCasting(); if (_slowRotation) { if (IsCast) { var temp = Me.CastingTimeLeft; RotationLogger.Fight($"Slow rotation - still casting! Wait for {temp + 100}"); Thread.Sleep(temp + 100); } //if no spell was executed successfully, we are assuming to still be on GCD and sleep the thread until the GCD ends //this prevents the rotation from re-checking if a no-gcd spell like Vanish, Judgement etc is ready else if (gcdEnabled) { RotationLogger.Fight($"No spell casted, waiting for {(globalCd * 1000 + 100)} for global cooldown to end!"); Thread.Sleep((int)(globalCd * 1000 + 100)); } } var watch = System.Diagnostics.Stopwatch.StartNew(); if (_framelock) { RunInFrameLock(rotation, gcdEnabled); } else { RunInLock(rotation, gcdEnabled); } watch.Stop(); if (watch.ElapsedMilliseconds > 150) { RotationLogger.Fight("Iteration took " + watch.ElapsedMilliseconds + "ms"); } }
public static bool CastSpell(RotationSpell spell, WoWUnit unit, bool force = false) { // still waiting to make sure last spell was casted successfully, this can be interrupted // by interrupting the current cast to cast something else (which will clear the verification) if (RotationSpellVerifier.IsWaitingForVerification() && !force) { return(false); } // no need to check for spell availability // already wanding, don't turn it on again! if (spell.Spell.Name == "Shoot" && IsAutoRepeating("Shoot")) { return(true); } // targetfinder function already checks that they are in LoS and RotationStep takes care of the range check if (unit != null && spell.IsKnown() && spell.CanCast()) { Lua.LuaDoString("if IsMounted() then Dismount() end"); if (spell.Spell.CastTime > 0) { if (spell.Verification != RotationSpell.VerificationType.NONE) { //setting this for delegates, so we don't miss events //SetFocusGuid(unit.Guid); RotationSpellVerifier.QueueVerification(spell.Spell.Name, unit, spell.Verification); } //force iscast so we don't have to wait for client updates RotationFramework.IsCast = true; //ObjectManager.Me.ForceIsCast = true; } if (AreaSpells.Contains(spell.Spell.Name)) { SpellManager.CastSpellByIDAndPosition(spell.Spell.Id, unit.Position); } else { if (unit.Guid != RotationFramework.Me.Guid && unit.Guid != RotationFramework.Target.Guid) { MovementManager.Face(unit); } ExecuteActionOnUnit <object>(unit, (luaUnitId => { RotationLogger.Fight($"Casting {spell.FullName()} ({spell.Spell.Name} on {luaUnitId} with guid {unit.Guid}"); //MovementManager.StopMoveTo(false, (int) spell.CastTime()); Lua.LuaDoString($@" if {force.ToString().ToLower()} then SpellStopCasting() end CastSpellByName(""{spell.FullName()}"", ""{luaUnitId}""); --CombatTextSetActiveUnit(""{luaUnitId}""); FocusUnit(""{luaUnitId}""); " ); return(null); })); } return(true); } return(false); }