*Do not let delayed spell hit dead target. This fix the bug that penance heal dead player and make him stuck. Thanks to Stokrotka.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-20 12:43:08 -05:00
parent 49a39abf8f
commit 0870adb1d2
+11 -11
View File
@@ -1116,22 +1116,21 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target)
if(spellHitTarget) if(spellHitTarget)
{ {
// Call scripted function for AI if this spell is casted upon a creature (except pets) //AI functions
if(IS_CREATURE_GUID(target->targetGUID)) if(spellHitTarget->GetTypeId() == TYPEID_UNIT)
{ {
if(((Creature*)spellHitTarget)->IsAIEnabled)
((Creature*)spellHitTarget)->AI()->SpellHit(m_caster, m_spellInfo);
// cast at creature (or GO) quest objectives update at successful cast finished (+channel finished) // cast at creature (or GO) quest objectives update at successful cast finished (+channel finished)
// ignore pets or autorepeat/melee casts for speed (not exist quest for spells (hm... ) // ignore pets or autorepeat/melee casts for speed (not exist quest for spells (hm... )
if( !((Creature*)unit)->isPet() && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() ) if(!((Creature*)spellHitTarget)->isPet() && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() )
{ {
if ( Player* p = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself() ) if ( Player* p = m_caster->GetCharmerOrOwnerPlayerOrPlayerItself() )
p->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id); p->CastedCreatureOrGO(spellHitTarget->GetEntry(),spellHitTarget->GetGUID(),m_spellInfo->Id);
} }
} }
//AI functions
if(spellHitTarget->GetTypeId() == TYPEID_UNIT && ((Creature*)spellHitTarget)->IsAIEnabled)
((Creature*)spellHitTarget)->AI()->SpellHit(m_caster, m_spellInfo);
if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->IsAIEnabled) if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->IsAIEnabled)
((Creature*)m_caster)->AI()->SpellHitTarget(spellHitTarget, m_spellInfo); ((Creature*)m_caster)->AI()->SpellHitTarget(spellHitTarget, m_spellInfo);
@@ -1146,10 +1145,11 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask)
return SPELL_MISS_EVADE; return SPELL_MISS_EVADE;
// Recheck immune (only for delayed spells) // Recheck immune (only for delayed spells)
if( m_spellInfo->speed && if(m_spellInfo->speed)
(unit->IsImmunedToDamage(m_spellInfo) ||
unit->IsImmunedToSpell(m_spellInfo)))
{ {
if(!unit->isAlive())
return SPELL_MISS_EVADE;
else if(unit->IsImmunedToDamage(m_spellInfo) || unit->IsImmunedToSpell(m_spellInfo))
return SPELL_MISS_IMMUNE; return SPELL_MISS_IMMUNE;
} }