mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-17 08:00:48 +01:00
Core/ScriptSystem: Add a PlayerScript::OnSpellCast(Player *player, Spell *spell, bool skipCheck) function.
Requested by Zor. --HG-- branch : trunk
This commit is contained in:
@@ -1132,6 +1132,11 @@ void ScriptMgr::OnPlayerTextEmote(Player* player, uint32 text_emote, uint32 emot
|
||||
FOREACH_SCRIPT(PlayerScript)->OnTextEmote(player, text_emote, emoteNum, guid);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerSpellCast(Player *player, Spell *spell, bool skipCheck)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnSpellCast(player, spell, skipCheck);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGuildAddMember(Guild *guild, Player *player, uint32& plRank)
|
||||
{
|
||||
FOREACH_SCRIPT(GuildScript)->OnAddMember(guild, player, plRank);
|
||||
|
||||
@@ -688,6 +688,9 @@ public:
|
||||
// Both of the below are called on emote opcodes
|
||||
virtual void OnEmote(Player* /*player*/, uint32 /*emote*/) { }
|
||||
virtual void OnTextEmote(Player* /*player*/, uint32 /*text_emote*/, uint32 /*emoteNum*/, uint64 /*guid*/) { }
|
||||
|
||||
// Called in Spell::cast
|
||||
virtual void OnSpellCast(Player *player, Spell *spell, bool skipCheck) { }
|
||||
};
|
||||
|
||||
class GuildScript : public ScriptObject
|
||||
@@ -887,6 +890,7 @@ class ScriptMgr
|
||||
void OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string msg, void* param = NULL);
|
||||
void OnPlayerEmote(Player* player, uint32 emote);
|
||||
void OnPlayerTextEmote(Player* player, uint32 text_emote, uint32 emoteNum, uint64 guid);
|
||||
void OnPlayerSpellCast(Player *player, Spell *spell, bool skipCheck);
|
||||
|
||||
public: /* GuildScript */
|
||||
void OnGuildAddMember(Guild *guild, Player *player, uint32& plRank);
|
||||
|
||||
@@ -3133,6 +3133,11 @@ void Spell::cast(bool skipCheck)
|
||||
}
|
||||
}
|
||||
|
||||
// now that we've done the basic check, now run the scripts
|
||||
// should be done before the spell is actually executed
|
||||
if (Player *playerCaster = m_caster->ToPlayer())
|
||||
sScriptMgr.OnPlayerSpellCast(playerCaster, this, skipCheck);
|
||||
|
||||
SetExecutedCurrently(true);
|
||||
|
||||
if (m_caster->GetTypeId() != TYPEID_PLAYER && m_targets.getUnitTarget() && m_targets.getUnitTarget() != m_caster)
|
||||
|
||||
Reference in New Issue
Block a user