aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/Spell.cpp
diff options
context:
space:
mode:
authoroffl <11556157+offl@users.noreply.github.com>2022-02-18 19:14:44 +0200
committerShauren <shauren.trinity@gmail.com>2022-03-26 15:15:46 +0100
commit050f55b62fded4cc73b76e42d56d98ea950cc26a (patch)
treec68bc4d938bd6b5298986dfeac578f4ba6d6028c /src/server/game/Spells/Spell.cpp
parentbb18bd47e52dc4d53623496e42d9cef96f819468 (diff)
Core/AI: OnSpellCast, OnSpellFailed, OnSpellStart hooks (#27704)
(cherry picked from commit 3dca705acc953d20e4a43d4c2b3c97a84e5ab346)
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
-rw-r--r--src/server/game/Spells/Spell.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 53656861b92..3f3b7cc9694 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -3341,6 +3341,11 @@ SpellCastResult Spell::prepare(SpellCastTargets const& targets, AuraEffect const
if (!(_triggeredCastFlags & TRIGGERED_IGNORE_GCD))
TriggerGlobalCooldown();
+ // Call CreatureAI hook OnSpellStart
+ if (Creature* caster = m_originalCaster->ToCreature())
+ if (caster->IsAIEnabled())
+ caster->AI()->OnSpellStart(GetSpellInfo());
+
if (willCastDirectly)
cast(true);
}
@@ -3707,10 +3712,10 @@ void Spell::_cast(bool skipCheck)
Unit::ProcSkillsAndAuras(m_originalCaster, nullptr, procAttacker, PROC_FLAG_NONE, PROC_SPELL_TYPE_MASK_ALL, PROC_SPELL_PHASE_CAST, hitMask, this, nullptr, nullptr);
- // Call CreatureAI hook OnSpellCastFinished
+ // Call CreatureAI hook OnSpellCast
if (Creature* caster = m_originalCaster->ToCreature())
if (caster->IsAIEnabled())
- caster->AI()->OnSpellCastFinished(GetSpellInfo(), SPELL_FINISHED_SUCCESSFUL_CAST);
+ caster->AI()->OnSpellCast(GetSpellInfo());
}
template <class Container>
@@ -4068,7 +4073,7 @@ void Spell::update(uint32 difftime)
// We call the hook here instead of in Spell::finish because we only want to call it for completed channeling. Everything else is handled by interrupts
if (Creature* creatureCaster = m_caster->ToCreature())
if (creatureCaster->IsAIEnabled())
- creatureCaster->AI()->OnSpellCastFinished(m_spellInfo, SPELL_FINISHED_CHANNELING_COMPLETE);
+ creatureCaster->AI()->OnChannelFinished(m_spellInfo);
}
break;
}