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;
|
||||
}
|
||||
|
||||
@@ -276,6 +276,7 @@ class TC_GAME_API SpellScript : public _SpellScript
|
||||
void _FinishScriptCall();
|
||||
bool IsInCheckCastHook() const;
|
||||
bool IsInTargetHook() const;
|
||||
bool IsInModifiableHook() const;
|
||||
bool IsInHitPhase() const;
|
||||
bool IsInEffectHook() const;
|
||||
private:
|
||||
@@ -356,10 +357,10 @@ class TC_GAME_API SpellScript : public _SpellScript
|
||||
// methods allowing interaction with Spell object
|
||||
//
|
||||
// methods useable during all spell handling phases
|
||||
Unit* GetCaster();
|
||||
Unit* GetOriginalCaster();
|
||||
SpellInfo const* GetSpellInfo();
|
||||
SpellValue const* GetSpellValue();
|
||||
Unit* GetCaster() const;
|
||||
Unit* GetOriginalCaster() const;
|
||||
SpellInfo const* GetSpellInfo() const;
|
||||
SpellValue const* GetSpellValue() const;
|
||||
|
||||
// methods useable after spell is prepared
|
||||
// accessors to the explicit targets of the spell
|
||||
@@ -373,48 +374,48 @@ class TC_GAME_API SpellScript : public _SpellScript
|
||||
// - ImplicitTargetXX set to TARGET_XXX_TARGET_YYY, _TARGET_ here means that explicit target is used by the effect, so spell needs one too
|
||||
|
||||
// returns: WorldLocation which was selected as a spell destination or NULL
|
||||
WorldLocation const* GetExplTargetDest();
|
||||
WorldLocation const* GetExplTargetDest() const;
|
||||
|
||||
void SetExplTargetDest(WorldLocation& loc);
|
||||
|
||||
// returns: WorldObject which was selected as an explicit spell target or NULL if there's no target
|
||||
WorldObject* GetExplTargetWorldObject();
|
||||
WorldObject* GetExplTargetWorldObject() const;
|
||||
|
||||
// returns: Unit which was selected as an explicit spell target or NULL if there's no target
|
||||
Unit* GetExplTargetUnit();
|
||||
Unit* GetExplTargetUnit() const;
|
||||
|
||||
// returns: GameObject which was selected as an explicit spell target or NULL if there's no target
|
||||
GameObject* GetExplTargetGObj();
|
||||
GameObject* GetExplTargetGObj() const;
|
||||
|
||||
// returns: Item which was selected as an explicit spell target or NULL if there's no target
|
||||
Item* GetExplTargetItem();
|
||||
Item* GetExplTargetItem() const;
|
||||
|
||||
// methods useable only during spell hit on target, or during spell launch on target:
|
||||
// returns: target of current effect if it was Unit otherwise NULL
|
||||
Unit* GetHitUnit();
|
||||
Unit* GetHitUnit() const;
|
||||
// returns: target of current effect if it was Creature otherwise NULL
|
||||
Creature* GetHitCreature();
|
||||
Creature* GetHitCreature() const;
|
||||
// returns: target of current effect if it was Player otherwise NULL
|
||||
Player* GetHitPlayer();
|
||||
Player* GetHitPlayer() const;
|
||||
// returns: target of current effect if it was Item otherwise NULL
|
||||
Item* GetHitItem();
|
||||
Item* GetHitItem() const;
|
||||
// returns: target of current effect if it was GameObject otherwise NULL
|
||||
GameObject* GetHitGObj();
|
||||
GameObject* GetHitGObj() const;
|
||||
// returns: destination of current effect
|
||||
WorldLocation* GetHitDest();
|
||||
WorldLocation* GetHitDest() const;
|
||||
// setter/getter for for damage done by spell to target of spell hit
|
||||
// returns damage calculated before hit, and real dmg done after hit
|
||||
int32 GetHitDamage();
|
||||
int32 GetHitDamage() const;
|
||||
void SetHitDamage(int32 damage);
|
||||
void PreventHitDamage() { SetHitDamage(0); }
|
||||
// setter/getter for for heal done by spell to target of spell hit
|
||||
// returns healing calculated before hit, and real dmg done after hit
|
||||
int32 GetHitHeal();
|
||||
int32 GetHitHeal() const;
|
||||
void SetHitHeal(int32 heal);
|
||||
void PreventHitHeal() { SetHitHeal(0); }
|
||||
Spell* GetSpell() { return m_spell; }
|
||||
Spell* GetSpell() const { return m_spell; }
|
||||
// returns current spell hit target aura
|
||||
Aura* GetHitAura();
|
||||
Aura* GetHitAura() const;
|
||||
// prevents applying aura on current spell hit target
|
||||
void PreventHitAura();
|
||||
|
||||
@@ -434,13 +435,13 @@ class TC_GAME_API SpellScript : public _SpellScript
|
||||
void SetEffectValue(int32 value);
|
||||
|
||||
// returns: cast item if present.
|
||||
Item* GetCastItem();
|
||||
Item* GetCastItem() const;
|
||||
|
||||
// Creates item. Calls Spell::DoCreateItem method.
|
||||
void CreateItem(uint32 effIndex, uint32 itemId);
|
||||
|
||||
// Returns SpellInfo from the spell that triggered the current one
|
||||
SpellInfo const* GetTriggeringSpell();
|
||||
SpellInfo const* GetTriggeringSpell() const;
|
||||
|
||||
// finishes spellcast prematurely with selected error message
|
||||
void FinishCast(SpellCastResult result, uint32* param1 = nullptr, uint32* param2 = nullptr);
|
||||
|
||||
Reference in new issue
Block a user