aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-04-15 15:58:56 -0300
committerfunjoker <funjoker109@gmail.com>2020-04-27 14:51:36 +0200
commit71c2fda1132d5fba3864f133d0e3ee4e81de508f (patch)
tree4a10c71ae8c24e20394efe43c6e91942ed822d56
parent677df56d2da9eb5ae997537c9cc952ac86c8f8db (diff)
Core/Spell: register spell mod owner properly on spell cast
- This fixes pets and totems getting mods from owner (cherry picked from commit 8b52cf902bf98a05197efa4e96ddd6188eb1a178)
-rw-r--r--src/server/game/Spells/Spell.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 4c2468cc3bc..337ca5e1423 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -3125,11 +3125,12 @@ void Spell::_cast(bool skipCheck)
m_caster->SetInFront(m_targets.GetObjectTarget());
// Should this be done for original caster?
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
+ Player* modOwner = m_caster->GetSpellModOwner();
+ if (modOwner)
{
// Set spell which will drop charges for triggered cast spells
// if not successfully cast, will be remove in finish(false)
- m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
+ modOwner->SetSpellModTakingSpell(this, true);
}
CallScriptBeforeCastHandlers();
@@ -3144,8 +3145,8 @@ void Spell::_cast(bool skipCheck)
SendCastResult(castResult, &param1, &param2);
SendInterrupted(0);
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
- m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
+ if (modOwner)
+ modOwner->SetSpellModTakingSpell(this, false);
finish(false);
SetExecutedCurrently(false);
@@ -3156,9 +3157,9 @@ void Spell::_cast(bool skipCheck)
// if trade not complete then remember it in trade data
if (m_targets.GetTargetMask() & TARGET_FLAG_TRADE_ITEM)
{
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
+ if (modOwner)
{
- if (TradeData* my_trade = m_caster->ToPlayer()->GetTradeData())
+ if (TradeData* my_trade = modOwner->GetTradeData())
{
if (!my_trade->IsInAcceptProcess())
{
@@ -3167,7 +3168,7 @@ void Spell::_cast(bool skipCheck)
SendCastResult(SPELL_FAILED_DONT_REPORT);
SendInterrupted(0);
- m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
+ modOwner->SetSpellModTakingSpell(this, false);
finish(false);
SetExecutedCurrently(false);
@@ -3284,12 +3285,12 @@ void Spell::_cast(bool skipCheck)
m_caster->CastSpell(m_targets.GetUnitTarget() ? m_targets.GetUnitTarget() : m_caster, *i, true);
}
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
+ if (modOwner)
{
- m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
+ modOwner->SetSpellModTakingSpell(this, false);
//Clear spell cooldowns after every spell is cast if .cheat cooldown is enabled.
- if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
+ if (modOwner->GetCommandStatus(CHEAT_COOLDOWN))
{
m_caster->GetSpellHistory()->ResetCooldown(m_spellInfo->Id, true);
m_caster->GetSpellHistory()->RestoreCharge(m_spellInfo->ChargeCategoryId);
@@ -3420,8 +3421,9 @@ uint64 Spell::handle_delayed(uint64 t_offset)
if (single_missile && !t_offset)
return m_delayMoment;
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
- m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
+ Player* modOwner = m_caster->GetSpellModOwner();
+ if (modOwner)
+ modOwner->SetSpellModTakingSpell(this, true);
PrepareTargetProcessing();
@@ -3460,8 +3462,8 @@ uint64 Spell::handle_delayed(uint64 t_offset)
FinishTargetProcessing();
- if (m_caster->GetTypeId() == TYPEID_PLAYER)
- m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
+ if (modOwner)
+ modOwner->SetSpellModTakingSpell(this, false);
// All targets passed - need finish phase
if (next_time == 0)