mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Spells: Expose number of targets selected for each spell effect to scripts to allow implementing spells that do something depending on number of targets hit
This commit is contained in:
@@ -413,6 +413,15 @@ bool SpellScript::IsInCheckCastHook() const
|
||||
{
|
||||
return m_currentScriptState == SPELL_SCRIPT_HOOK_CHECK_CAST;
|
||||
}
|
||||
|
||||
bool SpellScript::IsAfterTargetSelectionPhase() const
|
||||
{
|
||||
return IsInHitPhase()
|
||||
|| m_currentScriptState == SPELL_SCRIPT_HOOK_ON_CAST
|
||||
|| m_currentScriptState == SPELL_SCRIPT_HOOK_AFTER_CAST
|
||||
|| m_currentScriptState == SPELL_SCRIPT_HOOK_CALC_CRIT_CHANCE;
|
||||
}
|
||||
|
||||
bool SpellScript::IsInTargetHook() const
|
||||
{
|
||||
switch (m_currentScriptState)
|
||||
@@ -485,6 +494,39 @@ Item* SpellScript::GetExplTargetItem() const
|
||||
return m_spell->m_targets.GetItemTarget();
|
||||
}
|
||||
|
||||
int64 SpellScript::GetUnitTargetCountForEffect(SpellEffIndex effect) const
|
||||
{
|
||||
if (!IsAfterTargetSelectionPhase())
|
||||
{
|
||||
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetUnitTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
|
||||
m_scriptName->c_str(), m_scriptSpellId);
|
||||
return 0;
|
||||
}
|
||||
return m_spell->GetUnitTargetCountForEffect(effect);
|
||||
}
|
||||
|
||||
int64 SpellScript::GetGameObjectTargetCountForEffect(SpellEffIndex effect) const
|
||||
{
|
||||
if (!IsAfterTargetSelectionPhase())
|
||||
{
|
||||
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetGameObjectTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
|
||||
m_scriptName->c_str(), m_scriptSpellId);
|
||||
return 0;
|
||||
}
|
||||
return m_spell->GetGameObjectTargetCountForEffect(effect);
|
||||
}
|
||||
|
||||
int64 SpellScript::GetItemTargetCountForEffect(SpellEffIndex effect) const
|
||||
{
|
||||
if (!IsAfterTargetSelectionPhase())
|
||||
{
|
||||
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetItemTargetCountForEffect was called, but function has no effect in current hook! (spell has not selected targets yet)",
|
||||
m_scriptName->c_str(), m_scriptSpellId);
|
||||
return 0;
|
||||
}
|
||||
return m_spell->GetItemTargetCountForEffect(effect);
|
||||
}
|
||||
|
||||
Unit* SpellScript::GetHitUnit() const
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
|
||||
Reference in New Issue
Block a user