public static void CastBuff(RotationSpell buff, WoWUnit target) { if (buff.Spell.Name == "Power Word: Fortitude" && target.HasBuff("Prayer of Fortitude")) { return; } if (buff.Spell.Name == "Mark of the Wild" && target.HasBuff("Gift of the Wild")) { return; } if (buff.Spell.Name == "Divine Spirit" && target.HasBuff("Prayer of Spirit")) { return; } if (buff.Spell.Name == "Blessing of Kings" && target.HasBuff("Greater Blessing of Kings")) { return; } if (buff.IsKnown() && buff.CanCast() && !target.HasBuff(buff.Spell.Name)) { CastSpell(buff, target); } }
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); }