Core/Spell: register spell mod owner properly on spell cast

- This fixes pets and totems getting mods from owner

(cherry picked from commit 8b52cf902b)
This commit is contained in:
ariel-
2017-04-15 15:58:56 -03:00
committed by funjoker
parent 677df56d2d
commit 71c2fda113
+16 -14
View File
@@ -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)