Core/Spell: register spell mod owner properly on spell cast
- This fixes pets and totems getting mods from owner
This commit is contained in:
1 parent
2ed7602af2
commit
07a182f1d3
1 file changed
+18
-16
@@ -3216,11 +3216,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();
|
||||
@@ -3235,8 +3236,8 @@ void Spell::_cast(bool skipCheck)
|
||||
SendCastResult(castResult, ¶m1, ¶m2);
|
||||
SendInterrupted(0);
|
||||
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
|
||||
if (modOwner)
|
||||
modOwner->SetSpellModTakingSpell(this, false);
|
||||
|
||||
finish(false);
|
||||
SetExecutedCurrently(false);
|
||||
@@ -3247,9 +3248,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())
|
||||
{
|
||||
@@ -3258,7 +3259,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);
|
||||
@@ -3283,8 +3284,8 @@ void Spell::_cast(bool skipCheck)
|
||||
{
|
||||
SendInterrupted(0);
|
||||
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
|
||||
if (modOwner)
|
||||
modOwner->SetSpellModTakingSpell(this, false);
|
||||
|
||||
finish(false);
|
||||
SetExecutedCurrently(false);
|
||||
@@ -3369,12 +3370,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);
|
||||
}
|
||||
|
||||
@@ -3474,8 +3475,9 @@ uint64 Spell::handle_delayed(uint64 t_offset)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->SetSpellModTakingSpell(this, true);
|
||||
Player* modOwner = m_caster->GetSpellModOwner();
|
||||
if (modOwner)
|
||||
modOwner->SetSpellModTakingSpell(this, true);
|
||||
|
||||
uint64 next_time = 0;
|
||||
|
||||
@@ -3518,8 +3520,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)
|
||||
|
||||
Reference in new issue
Block a user