Core/ScriptSystem: AfterHit hook can't modify damage/healing, so log it
- Also added const to getter members
This commit is contained in:
1 parent
afed7f0425
commit
a97171c8c0
2 files changed
+60
-43
No files matched your search
@@ -393,6 +393,22 @@ bool SpellScript::IsInTargetHook() const
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SpellScript::IsInModifiableHook() const
|
||||
{
|
||||
// after hit hook executed after damage/healing is already done
|
||||
// modifying it at this point has no effect
|
||||
switch (m_currentScriptState)
|
||||
{
|
||||
case SPELL_SCRIPT_HOOK_EFFECT_LAUNCH_TARGET:
|
||||
case SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET:
|
||||
case SPELL_SCRIPT_HOOK_BEFORE_HIT:
|
||||
case SPELL_SCRIPT_HOOK_HIT:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SpellScript::IsInHitPhase() const
|
||||
{
|
||||
return (m_currentScriptState >= HOOK_SPELL_HIT_START && m_currentScriptState < HOOK_SPELL_HIT_END);
|
||||
@@ -403,22 +419,22 @@ bool SpellScript::IsInEffectHook() const
|
||||
return (m_currentScriptState >= SPELL_SCRIPT_HOOK_EFFECT_LAUNCH && m_currentScriptState <= SPELL_SCRIPT_HOOK_EFFECT_HIT_TARGET);
|
||||
}
|
||||
|
||||
Unit* SpellScript::GetCaster()
|
||||
Unit* SpellScript::GetCaster() const
|
||||
{
|
||||
return m_spell->GetCaster();
|
||||
}
|
||||
|
||||
Unit* SpellScript::GetOriginalCaster()
|
||||
Unit* SpellScript::GetOriginalCaster() const
|
||||
{
|
||||
return m_spell->GetOriginalCaster();
|
||||
}
|
||||
|
||||
SpellInfo const* SpellScript::GetSpellInfo()
|
||||
SpellInfo const* SpellScript::GetSpellInfo() const
|
||||
{
|
||||
return m_spell->GetSpellInfo();
|
||||
}
|
||||
|
||||
WorldLocation const* SpellScript::GetExplTargetDest()
|
||||
WorldLocation const* SpellScript::GetExplTargetDest() const
|
||||
{
|
||||
if (m_spell->m_targets.HasDst())
|
||||
return m_spell->m_targets.GetDstPos();
|
||||
@@ -430,27 +446,27 @@ void SpellScript::SetExplTargetDest(WorldLocation& loc)
|
||||
m_spell->m_targets.SetDst(loc);
|
||||
}
|
||||
|
||||
WorldObject* SpellScript::GetExplTargetWorldObject()
|
||||
WorldObject* SpellScript::GetExplTargetWorldObject() const
|
||||
{
|
||||
return m_spell->m_targets.GetObjectTarget();
|
||||
}
|
||||
|
||||
Unit* SpellScript::GetExplTargetUnit()
|
||||
Unit* SpellScript::GetExplTargetUnit() const
|
||||
{
|
||||
return m_spell->m_targets.GetUnitTarget();
|
||||
}
|
||||
|
||||
GameObject* SpellScript::GetExplTargetGObj()
|
||||
GameObject* SpellScript::GetExplTargetGObj() const
|
||||
{
|
||||
return m_spell->m_targets.GetGOTarget();
|
||||
}
|
||||
|
||||
Item* SpellScript::GetExplTargetItem()
|
||||
Item* SpellScript::GetExplTargetItem() const
|
||||
{
|
||||
return m_spell->m_targets.GetItemTarget();
|
||||
}
|
||||
|
||||
Unit* SpellScript::GetHitUnit()
|
||||
Unit* SpellScript::GetHitUnit() const
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
{
|
||||
@@ -460,7 +476,7 @@ Unit* SpellScript::GetHitUnit()
|
||||
return m_spell->unitTarget;
|
||||
}
|
||||
|
||||
Creature* SpellScript::GetHitCreature()
|
||||
Creature* SpellScript::GetHitCreature() const
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
{
|
||||
@@ -473,7 +489,7 @@ Creature* SpellScript::GetHitCreature()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Player* SpellScript::GetHitPlayer()
|
||||
Player* SpellScript::GetHitPlayer() const
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
{
|
||||
@@ -486,7 +502,7 @@ Player* SpellScript::GetHitPlayer()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Item* SpellScript::GetHitItem()
|
||||
Item* SpellScript::GetHitItem() const
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
{
|
||||
@@ -496,7 +512,7 @@ Item* SpellScript::GetHitItem()
|
||||
return m_spell->itemTarget;
|
||||
}
|
||||
|
||||
GameObject* SpellScript::GetHitGObj()
|
||||
GameObject* SpellScript::GetHitGObj() const
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
{
|
||||
@@ -506,7 +522,7 @@ GameObject* SpellScript::GetHitGObj()
|
||||
return m_spell->gameObjTarget;
|
||||
}
|
||||
|
||||
WorldLocation* SpellScript::GetHitDest()
|
||||
WorldLocation* SpellScript::GetHitDest() const
|
||||
{
|
||||
if (!IsInEffectHook())
|
||||
{
|
||||
@@ -516,7 +532,7 @@ WorldLocation* SpellScript::GetHitDest()
|
||||
return m_spell->destTarget;
|
||||
}
|
||||
|
||||
int32 SpellScript::GetHitDamage()
|
||||
int32 SpellScript::GetHitDamage() const
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
{
|
||||
@@ -528,7 +544,7 @@ int32 SpellScript::GetHitDamage()
|
||||
|
||||
void SpellScript::SetHitDamage(int32 damage)
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
if (!IsInModifiableHook())
|
||||
{
|
||||
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::SetHitDamage was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
|
||||
return;
|
||||
@@ -536,7 +552,7 @@ void SpellScript::SetHitDamage(int32 damage)
|
||||
m_spell->m_damage = damage;
|
||||
}
|
||||
|
||||
int32 SpellScript::GetHitHeal()
|
||||
int32 SpellScript::GetHitHeal() const
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
{
|
||||
@@ -548,7 +564,7 @@ int32 SpellScript::GetHitHeal()
|
||||
|
||||
void SpellScript::SetHitHeal(int32 heal)
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
if (!IsInModifiableHook())
|
||||
{
|
||||
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::SetHitHeal was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
|
||||
return;
|
||||
@@ -556,7 +572,7 @@ void SpellScript::SetHitHeal(int32 heal)
|
||||
m_spell->m_healing = heal;
|
||||
}
|
||||
|
||||
Aura* SpellScript::GetHitAura()
|
||||
Aura* SpellScript::GetHitAura() const
|
||||
{
|
||||
if (!IsInTargetHook())
|
||||
{
|
||||
@@ -624,7 +640,7 @@ void SpellScript::SetEffectValue(int32 value)
|
||||
m_spell->damage = value;
|
||||
}
|
||||
|
||||
Item* SpellScript::GetCastItem()
|
||||
Item* SpellScript::GetCastItem() const
|
||||
{
|
||||
return m_spell->m_CastItem;
|
||||
}
|
||||
@@ -634,7 +650,7 @@ void SpellScript::CreateItem(uint32 effIndex, uint32 itemId)
|
||||
m_spell->DoCreateItem(effIndex, itemId);
|
||||
}
|
||||
|
||||
SpellInfo const* SpellScript::GetTriggeringSpell()
|
||||
SpellInfo const* SpellScript::GetTriggeringSpell() const
|
||||
{
|
||||
return m_spell->m_triggeredByAuraSpell;
|
||||
}
|
||||
@@ -656,7 +672,7 @@ void SpellScript::SetCustomCastResultMessage(SpellCustomErrors result)
|
||||
m_spell->m_customError = result;
|
||||
}
|
||||
|
||||
SpellValue const* SpellScript::GetSpellValue()
|
||||
SpellValue const* SpellScript::GetSpellValue() const
|
||||
{
|
||||
return m_spell->m_spellValue;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user