diff options
author | megamage <none@none> | 2008-10-31 14:00:49 -0500 |
---|---|---|
committer | megamage <none@none> | 2008-10-31 14:00:49 -0500 |
commit | 1c3d4c40c3fef1eec9d1c8438254e97cdcef063a (patch) | |
tree | bd02e444f8638bab7cd7d64ad4e46b38700677e5 /src | |
parent | 67b86d636b9903f3fa0b53bff114c1f00bb39cc1 (diff) |
[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.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Spell.cpp | 63 | ||||
-rw-r--r-- | src/game/Unit.cpp | 21 |
2 files changed, 39 insertions, 45 deletions
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index f81454e0cc0..a39b6cfcdf8 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -950,20 +950,24 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) // ignore autorepeat/melee casts for speed (not exist quest for spells (hm... ) if( m_caster->GetTypeId() == TYPEID_PLAYER && !IsAutoRepeat() && !IsNextMeleeSwingSpell() && !IsChannelActive() ) ((Player*)m_caster)->CastedCreatureOrGO(unit->GetEntry(),unit->GetGUID(),m_spellInfo->Id); - - if(((Creature*)unit)->AI()) - ((Creature*)unit)->AI()->SpellHit(m_caster ,m_spellInfo); } - if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->AI()) - ((Creature*)m_caster)->AI()->SpellHitTarget(unit, m_spellInfo); - - if(int32 spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id, 1)) + if( !m_caster->IsFriendlyTo(unit) && !IsPositiveSpell(m_spellInfo->Id)) { - if(spell_triggered > 0) - unit->CastSpell(unit, spell_triggered, true/*, 0, 0, m_caster->GetGUID()*/); - else - unit->RemoveAurasDueToSpell(-spell_triggered); + if( !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) ) + { + if(!unit->IsStandState() && !unit->hasUnitState(UNIT_STAT_STUNNED)) + unit->SetStandState(PLAYER_STATE_NONE); + + if(!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI()) + ((Creature*)unit)->AI()->AttackStart(m_caster); + + unit->SetInCombatWith(m_caster); + m_caster->SetInCombatWith(unit); + + if(Player *attackedPlayer = unit->GetCharmerOrOwnerPlayerOrPlayerItself()) + m_caster->SetContestedPvP(attackedPlayer); + } } } @@ -1000,30 +1004,9 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) return; } - // exclude Arcane Missiles Dummy Aura aura for now (attack on hit) - // TODO: find way to not need this? - if(!(m_spellInfo->SpellFamilyName == SPELLFAMILY_MAGE && - m_spellInfo->SpellFamilyFlags & 0x800LL)) + //if(!IsPositiveSpell(m_spellInfo->Id)) { unit->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); - - if( !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) ) - { - if(!unit->IsStandState() && !unit->hasUnitState(UNIT_STAT_STUNNED)) - unit->SetStandState(PLAYER_STATE_NONE); - - if(!unit->isInCombat() && unit->GetTypeId() != TYPEID_PLAYER && ((Creature*)unit)->AI()) - ((Creature*)unit)->AI()->AttackStart(m_caster); - - unit->SetInCombatWith(m_caster); - m_caster->SetInCombatWith(unit); - - if(Player *attackedPlayer = unit->GetCharmerOrOwnerPlayerOrPlayerItself()) - { - m_caster->SetContestedPvP(attackedPlayer); - } - unit->AddThreat(m_caster, 0.0f); - } } } else @@ -1069,6 +1052,20 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) } } } + + if(unit->GetTypeId() == TYPEID_UNIT && ((Creature*)unit)->AI()) + ((Creature*)unit)->AI()->SpellHit(m_caster, m_spellInfo); + + if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->AI()) + ((Creature*)m_caster)->AI()->SpellHitTarget(unit, m_spellInfo); + + if(int32 spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id, 1)) + { + if(spell_triggered > 0) + unit->CastSpell(unit, spell_triggered, true, 0, 0, m_caster->GetGUID()); + else + unit->RemoveAurasDueToSpell(-spell_triggered); + } } void Spell::DoAllEffectOnTarget(GOTargetInfo *target) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 8427c22b677..5660f8a561b 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -519,9 +519,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa return damage; } - - if(!pVictim->isInCombat() && ((Creature*)pVictim)->AI()) - ((Creature*)pVictim)->AI()->AttackStart(this); } DEBUG_LOG("DealDamageStart"); @@ -539,15 +536,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa duel_hasEnded = true; } - //Get in CombatState - if(pVictim != this && damagetype != DOT) - { - SetInCombatWith(pVictim); - pVictim->SetInCombatWith(this); - - if(Player* attackedPlayer = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself()) - SetContestedPvP(attackedPlayer); - } // Rage from Damage made (only from direct weapon damage) if( cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && GetTypeId() == TYPEID_PLAYER && (getPowerType() == POWER_RAGE)) @@ -2151,6 +2139,15 @@ void Unit::AttackerStateUpdate (Unit *pVictim, WeaponAttackType attType, bool ex if(IsNonMeleeSpellCasted(false)) return; + if(!pVictim->isInCombat() && pVictim->GetTypeId() != TYPEID_PLAYER && ((Creature*)pVictim)->AI()) + ((Creature*)pVictim)->AI()->AttackStart(this); + + SetInCombatWith(pVictim); + pVictim->SetInCombatWith(this); + + if(Player* attackedPlayer = pVictim->GetCharmerOrOwnerPlayerOrPlayerItself()) + SetContestedPvP(attackedPlayer); + uint32 hitInfo; if (attType == BASE_ATTACK) hitInfo = HITINFO_NORMALSWING2; |