Show
Ignore:
Timestamp:
11/19/08 13:39:45 (17 years ago)
Author:
yumileroy
Message:

[svn] Set target in combat even if spell does not hit target.
Call AI function only when spell hits target.
Move combat check from dealdamge to attackerstateupdate to remove redundant check.

Original author: megamage
Date: 2008-10-31 14:00:49-05:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Spell.cpp

    r139 r140  
    951951        if( m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() ) 
    952952            ((Player*)m_caster)->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id); 
    953  
    954         if(((Creature*)unit)->AI()) 
    955             ((Creature*)unit)->AI()->SpellHit(m_caster ,m_spellInfo); 
    956     } 
    957  
    958     if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->AI()) 
    959         ((Creature*)m_caster)->AI()->SpellHitTarget(unit, m_spellInfo); 
    960  
    961     if(int32 spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id, 1)) 
    962     { 
    963         if(spell_triggered > 0) 
    964             unit->CastSpell(unit, spell_triggered, true/*, 0, 0, m_caster->GetGUID()*/); 
    965         else 
    966             unit->RemoveAurasDueToSpell(-spell_triggered); 
     953    } 
     954 
     955    if( !m_caster->IsFriendlyTo(unit) && !IsPositiveSpell(m_spellInfo->Id)) 
     956    { 
     957        if( !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) ) 
     958        { 
     959            if(!unit->IsStandState() && !unit->hasUnitState(UNIT_STAT_STUNNED)) 
     960                unit->SetStandState(PLAYER_STATE_NONE); 
     961 
     962            if(!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI()) 
     963                ((Creature*)unit)->AI()->AttackStart(m_caster); 
     964 
     965            unit->SetInCombatWith(m_caster); 
     966            m_caster->SetInCombatWith(unit); 
     967 
     968            if(Player *attackedPlayer = unit->GetCharmerOrOwnerPlayerOrPlayerItself()) 
     969                m_caster->SetContestedPvP(attackedPlayer); 
     970        } 
    967971    } 
    968972} 
     
    10011005            } 
    10021006 
    1003             // exclude Arcane Missiles Dummy Aura aura for now (attack on hit) 
    1004             // TODO: find way to not need this? 
    1005             if(!(m_spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && 
    1006                 m_spellInfo->SpellFamilyFlags & 0x800LL)) 
     1007            //if(!IsPositiveSpell(m_spellInfo->Id)) 
    10071008            { 
    10081009                unit->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 
    1009  
    1010                 if( !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) ) 
    1011                 { 
    1012                     if(!unit->IsStandState() && !unit->hasUnitState(UNIT_STAT_STUNNED)) 
    1013                         unit->SetStandState(PLAYER_STATE_NONE); 
    1014  
    1015                     if(!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI()) 
    1016                         ((Creature*)unit)->AI()->AttackStart(m_caster); 
    1017  
    1018                     unit->SetInCombatWith(m_caster); 
    1019                     m_caster->SetInCombatWith(unit); 
    1020  
    1021                     if(Player *attackedPlayer = unit->GetCharmerOrOwnerPlayerOrPlayerItself()) 
    1022                     { 
    1023                         m_caster->SetContestedPvP(attackedPlayer); 
    1024                     } 
    1025                     unit->AddThreat(m_caster, 0.0f); 
    1026                 } 
    10271010            } 
    10281011        } 
     
    10691052            } 
    10701053        } 
     1054    } 
     1055 
     1056    if(unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->AI()) 
     1057        ((Creature*)unit)->AI()->SpellHit(m_caster, m_spellInfo); 
     1058 
     1059    if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->AI()) 
     1060        ((Creature*)m_caster)->AI()->SpellHitTarget(unit, m_spellInfo); 
     1061 
     1062    if(int32 spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id, 1)) 
     1063    { 
     1064        if(spell_triggered > 0) 
     1065            unit->CastSpell(unit, spell_triggered, true, 0, 0, m_caster->GetGUID()); 
     1066        else 
     1067            unit->RemoveAurasDueToSpell(-spell_triggered); 
    10711068    } 
    10721069}