*Fix some bugs about pet spells: such as cannot cast/cannot autocast.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-19 01:23:52 -05:00
parent 833ceee7c5
commit 2a2eff190c
4 changed files with 46 additions and 57 deletions

View File

@@ -4649,28 +4649,25 @@ SpellCastResult Spell::CheckPetCast(Unit* target)
if(m_caster->isInCombat() && IsNonCombatSpell(m_spellInfo))
return SPELL_FAILED_AFFECTING_COMBAT;
if(m_caster->GetTypeId()==TYPEID_UNIT && (((Creature*)m_caster)->isPet() || m_caster->isCharmed()))
{
//dead owner (pets still alive when owners ressed?)
if(m_caster->GetCharmerOrOwner() && !m_caster->GetCharmerOrOwner()->isAlive())
return SPELL_FAILED_CASTER_DEAD;
if(Unit *owner = m_caster->GetCharmerOrOwner())
if(!owner->isAlive())
return SPELL_FAILED_CASTER_DEAD;
if(!target && m_targets.getUnitTarget())
target = m_targets.getUnitTarget();
bool need = false;
for(uint32 i = 0;i<3;i++)
for(uint32 i = 0; i < 3; ++i)
{
if(m_spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ENEMY || m_spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ALLY || m_spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ANY || m_spellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_PARTY || m_spellInfo->EffectImplicitTargetA[i] == TARGET_DST_TARGET_ENEMY)
if(spellmgr.SpellTargetType[m_spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_UNIT_TARGET
|| spellmgr.SpellTargetType[m_spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_DEST_TARGET)
{
need = true;
if(!target)
return SPELL_FAILED_BAD_IMPLICIT_TARGETS;
m_targets.setUnitTarget(target);
break;
}
}
if(need)
m_targets.setUnitTarget(target);
Unit* _target = m_targets.getUnitTarget();
@@ -4685,7 +4682,6 @@ SpellCastResult Spell::CheckPetCast(Unit* target)
//cooldown
if(((Creature*)m_caster)->HasSpellCooldown(m_spellInfo->Id))
return SPELL_FAILED_NOT_READY;
}
return CheckCast(true);
}
@@ -4816,8 +4812,8 @@ bool Spell::CanAutoCast(Unit* target)
}
else if ( IsAreaAuraEffect( m_spellInfo->Effect[j] ))
{
if( target->HasAuraEffect(m_spellInfo->Id, j) )
return false;
if( target->HasAuraEffect(m_spellInfo->Id, j) )
return false;
}
}