aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/Spell.cpp26
-rw-r--r--src/game/Unit.cpp10
2 files changed, 21 insertions, 15 deletions
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 77fbf5e3380..6f98508fd1d 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -408,13 +408,6 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
}
}
- if(!m_targets.getUnitTargetGUID() && m_spellInfo->Targets & TARGET_FLAG_UNIT)
- {
- if(Unit *target = ObjectAccessor::GetUnit(*m_caster, m_caster->GetUInt64Value(UNIT_FIELD_TARGET)))
- if(IsValidSingleTargetSpell(target))
- m_targets.setUnitTarget(target);
- }
-
CleanupTargetList();
}
@@ -2011,6 +2004,13 @@ void Spell::prepare(SpellCastTargets const* targets, Aura* triggeredByAura)
m_targets = *targets;
+ if(!m_targets.getUnitTargetGUID() && m_spellInfo->Targets & TARGET_FLAG_UNIT)
+ {
+ if(Unit *target = ObjectAccessor::GetUnit(*m_caster, m_caster->GetUInt64Value(UNIT_FIELD_TARGET)))
+ if(IsValidSingleTargetSpell(target))
+ m_targets.setUnitTarget(target);
+ }
+
m_spellState = SPELL_STATE_PREPARING;
m_caster->GetPosition(m_castPositionX, m_castPositionY, m_castPositionZ);
@@ -2100,8 +2100,11 @@ void Spell::cancel()
if(m_spellState == SPELL_STATE_FINISHED)
return;
+ uint32 oldState = m_spellState;
+ m_spellState = SPELL_STATE_FINISHED;
+
m_autoRepeat = false;
- switch (m_spellState)
+ switch (oldState)
{
case SPELL_STATE_PREPARING:
case SPELL_STATE_DELAYED:
@@ -2133,10 +2136,13 @@ void Spell::cancel()
} break;
}
- finish(false);
-
m_caster->RemoveDynObject(m_spellInfo->Id);
m_caster->RemoveGameObject(m_spellInfo->Id,true);
+
+ //set state back so finish will be processed
+ m_spellState = oldState;
+
+ finish(false);
}
void Spell::cast(bool skipCheck)
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 6df058fbc36..3a2af7e8d3f 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -4194,13 +4194,10 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
if(!caster) // can be already located for IsSingleTargetSpell case
caster = Aur->GetCaster();
- if(caster)
+ if(caster && caster->isAlive())
{
- if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE)
- statue = ((Totem*)caster);
-
// stop caster chanelling state
- else if(caster->m_currentSpells[CURRENT_CHANNELED_SPELL]
+ if(caster->m_currentSpells[CURRENT_CHANNELED_SPELL]
//prevent recurential call
&& caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->getState() != SPELL_STATE_FINISHED)
{
@@ -4215,6 +4212,9 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
caster->m_currentSpells[CURRENT_CHANNELED_SPELL]->cancel();
}
}
+
+ if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE)
+ statue = ((Totem*)caster);
}
// Unsummon summon as possessed creatures on spell cancel