mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-01 18:13:48 +00:00
feat(Scripting/Spell): Add new hooks for Spell (OnSpellCast, OnSpellPrepare, OnSpellCancel) (#21149)
This commit is contained in:
@@ -84,6 +84,21 @@ void ScriptMgr::OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex
|
||||
CALL_ENABLED_HOOKS(AllSpellScript, ALLSPELLHOOK_ON_DUMMY_EFFECT_ITEM, script->OnDummyEffect(caster, spellID, effIndex, itemTarget));
|
||||
}
|
||||
|
||||
void ScriptMgr::OnSpellCastCancel(Spell* spell, Unit* caster, SpellInfo const* spellInfo, bool bySelf)
|
||||
{
|
||||
CALL_ENABLED_HOOKS(AllSpellScript, ALLSPELLHOOK_ON_CAST_CANCEL, script->OnSpellCastCancel(spell, caster, spellInfo, bySelf));
|
||||
}
|
||||
|
||||
void ScriptMgr::OnSpellCast(Spell* spell, Unit* caster, SpellInfo const* spellInfo, bool skipCheck)
|
||||
{
|
||||
CALL_ENABLED_HOOKS(AllSpellScript, ALLSPELLHOOK_ON_CAST, script->OnSpellCast(spell, caster, spellInfo, skipCheck));
|
||||
}
|
||||
|
||||
void ScriptMgr::OnSpellPrepare(Spell* spell, Unit* caster, SpellInfo const* spellInfo)
|
||||
{
|
||||
CALL_ENABLED_HOOKS(AllSpellScript, ALLSPELLHOOK_ON_PREPARE, script->OnSpellPrepare(spell, caster, spellInfo));
|
||||
}
|
||||
|
||||
AllSpellScript::AllSpellScript(char const* name, std::vector<uint16> enabledHooks)
|
||||
: ScriptObject(name, ALLSPELLHOOK_END)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,9 @@ enum AllSpellHook
|
||||
ALLSPELLHOOK_ON_DUMMY_EFFECT_GAMEOBJECT,
|
||||
ALLSPELLHOOK_ON_DUMMY_EFFECT_CREATURE,
|
||||
ALLSPELLHOOK_ON_DUMMY_EFFECT_ITEM,
|
||||
ALLSPELLHOOK_ON_CAST_CANCEL,
|
||||
ALLSPELLHOOK_ON_CAST,
|
||||
ALLSPELLHOOK_ON_PREPARE,
|
||||
ALLSPELLHOOK_END
|
||||
};
|
||||
|
||||
@@ -100,6 +103,12 @@ public:
|
||||
* @param itemTarget Contains information about the Item
|
||||
*/
|
||||
virtual void OnDummyEffect(WorldObject* /*caster*/, uint32 /*spellID*/, SpellEffIndex /*effIndex*/, Item* /*itemTarget*/) { }
|
||||
|
||||
virtual void OnSpellCastCancel(Spell* /*spell*/, Unit* /*caster*/, SpellInfo const* /*spellInfo*/, bool /*bySelf*/) { }
|
||||
|
||||
virtual void OnSpellCast(Spell* /*spell*/, Unit* /*caster*/, SpellInfo const* /*spellInfo*/, bool /*skipCheck*/) { }
|
||||
|
||||
virtual void OnSpellPrepare(Spell* /*spell*/, Unit* /*caster*/, SpellInfo const* /*spellInfo*/) { }
|
||||
};
|
||||
|
||||
// Compatibility for old scripts
|
||||
|
||||
@@ -615,6 +615,9 @@ public: /* SpellSC */
|
||||
void OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, GameObject* gameObjTarget);
|
||||
void OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Creature* creatureTarget);
|
||||
void OnDummyEffect(WorldObject* caster, uint32 spellID, SpellEffIndex effIndex, Item* itemTarget);
|
||||
void OnSpellCastCancel(Spell* spell, Unit* caster, SpellInfo const* spellInfo, bool bySelf);
|
||||
void OnSpellCast(Spell* spell, Unit* caster, SpellInfo const* spellInfo, bool skipCheck);
|
||||
void OnSpellPrepare(Spell* spell, Unit* caster, SpellInfo const* spellInfo);
|
||||
|
||||
public: /* GameEventScript */
|
||||
void OnGameEventStart(uint16 EventID);
|
||||
|
||||
@@ -3717,6 +3717,8 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const
|
||||
TriggerGlobalCooldown();
|
||||
}
|
||||
|
||||
sScriptMgr->OnSpellPrepare(this, m_caster, m_spellInfo);
|
||||
|
||||
return SPELL_CAST_OK;
|
||||
}
|
||||
|
||||
@@ -3788,6 +3790,8 @@ void Spell::cancel(bool bySelf)
|
||||
//set state back so finish will be processed
|
||||
m_spellState = oldState;
|
||||
|
||||
sScriptMgr->OnSpellCastCancel(this, m_caster, m_spellInfo, bySelf);
|
||||
|
||||
finish(false);
|
||||
}
|
||||
|
||||
@@ -4114,6 +4118,8 @@ void Spell::_cast(bool skipCheck)
|
||||
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
|
||||
m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true);
|
||||
|
||||
sScriptMgr->OnSpellCast(this, m_caster, m_spellInfo, skipCheck);
|
||||
|
||||
SetExecutedCurrently(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user