Avoid target requirement checks for spells with caster base target selection (self,pet,around). Author: VladimirMangos

This fix cast fail for some spells, mostly triggered or scripted with unexpected prowided explicit tatrget different from caster.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-02 10:03:38 +08:00
parent c1d94ad607
commit a1d5f174be
2 changed files with 29 additions and 4 deletions

View File

@@ -4354,7 +4354,9 @@ SpellCastResult Spell::CheckCast(bool strict)
if(!m_IsTriggeredSpell && target == m_caster && m_spellInfo->AttributesEx & SPELL_ATTR_EX_CANT_TARGET_SELF)
return SPELL_FAILED_BAD_TARGETS;
if(target != m_caster)
bool non_caster_target = target != m_caster && !spellmgr.IsSpellWithCasterSourceTargetsOnly(m_spellInfo);
if(non_caster_target)
{
// target state requirements (apply to non-self only), to allow cast affects to self like Dirty Deeds
if(!m_IsTriggeredSpell && m_spellInfo->TargetAuraState && !target->HasAuraState(AuraState(m_spellInfo->TargetAuraState), m_spellInfo, m_caster))
@@ -4402,7 +4404,7 @@ SpellCastResult Spell::CheckCast(bool strict)
//check creature type
//ignore self casts (including area casts when caster selected as target)
if(target != m_caster)
if(non_caster_target)
{
if(!CheckTargetCreatureType(target))
{
@@ -4415,7 +4417,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// TODO: this check can be applied and for player to prevent cheating when IsPositiveSpell will return always correct result.
// check target for pet/charmed casts (not self targeted), self targeted cast used for area effects and etc
if(m_caster != target && m_caster->GetTypeId() == TYPEID_UNIT && m_caster->GetCharmerOrOwnerGUID())
if(non_caster_target && m_caster->GetTypeId() == TYPEID_UNIT && m_caster->GetCharmerOrOwnerGUID())
{
// check correctness positive/negative cast target (pet cast real check and cheating check)
if(IsPositiveSpell(m_spellInfo->Id))
@@ -4454,7 +4456,7 @@ SpellCastResult Spell::CheckCast(bool strict)
}
// check if target is in combat
if (target != m_caster && (m_spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_IN_COMBAT_TARGET) && target->isInCombat())
if (non_caster_target && (m_spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_IN_COMBAT_TARGET) && target->isInCombat())
return SPELL_FAILED_TARGET_AFFECTING_COMBAT;
}