aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Spells/Spell.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index e14fc60e78e..e93a7770180 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -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, &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);
@@ -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)