mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 10:05:32 +01:00
Core/Spell: register spell mod owner properly on spell cast
- This fixes pets and totems getting mods from owner
This commit is contained in:
@@ -3115,11 +3115,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();
|
||||
@@ -3134,8 +3135,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);
|
||||
@@ -3146,9 +3147,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())
|
||||
{
|
||||
@@ -3157,7 +3158,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);
|
||||
@@ -3182,8 +3183,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);
|
||||
@@ -3268,12 +3269,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);
|
||||
}
|
||||
|
||||
@@ -3373,8 +3374,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;
|
||||
|
||||
@@ -3417,8 +3419,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