From 845feebaae6b49fdee7e83d6506a2042964d157b Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Thu, 9 Jul 2020 13:59:55 +0200 Subject: [PATCH] Core/Spells: implement GetHitCorpse() helper --- src/server/game/Spells/SpellScript.cpp | 10 ++++++++++ src/server/game/Spells/SpellScript.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index e207719c188..a5237ef7c96 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -525,6 +525,16 @@ GameObject* SpellScript::GetHitGObj() const return m_spell->gameObjTarget; } +Corpse* SpellScript::GetHitCorpse() const +{ + if (!IsInTargetHook()) + { + TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitCorpse was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId); + return nullptr; + } + return m_spell->corpseTarget; +} + WorldLocation* SpellScript::GetHitDest() const { if (!IsInEffectHook()) diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index 0f2eb30cd75..ea745c99720 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -423,6 +423,8 @@ class TC_GAME_API SpellScript : public _SpellScript Item* GetHitItem() const; // returns: target of current effect if it was GameObject otherwise nullptr GameObject* GetHitGObj() const; + // returns: target of current effect if it was Corpse otherwise nullptr + Corpse* GetHitCorpse() const; // returns: destination of current effect WorldLocation* GetHitDest() const; // setter/getter for for damage done by spell to target of spell hit