Core/PlayerAI: perform cast checks on auto ranged attack

Port From (https://github.com/TrinityCore/TrinityCore/commit/b46d899ef16ce15e1f8403be076993545035cddc)
This commit is contained in:
hondacrx
2021-06-23 14:08:27 -04:00
parent 0b0ab3b059
commit 87cc42ee48
+12 -1
View File
@@ -602,7 +602,18 @@ namespace Game.AI
if (rangedAttackSpell == 0) if (rangedAttackSpell == 0)
return; return;
me.CastSpell(victim, rangedAttackSpell, new CastSpellExtraArgs(TriggerCastFlags.CastDirectly)); SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(rangedAttackSpell, me.GetMap().GetDifficultyID());
if (spellInfo == null)
return;
Spell spell = new Spell(me, spellInfo, TriggerCastFlags.CastDirectly);
if (spell.CheckPetCast(victim) != SpellCastResult.SpellCastOk)
return;
SpellCastTargets targets = new();
targets.SetUnitTarget(victim);
spell.Prepare(targets);
me.ResetAttackTimer(WeaponAttackType.RangedAttack); me.ResetAttackTimer(WeaponAttackType.RangedAttack);
} }