From a29847bf8490833ba219f01fba1441d6c8f1b7a3 Mon Sep 17 00:00:00 2001 From: krz Date: Tue, 2 Jun 2009 20:59:13 +0200 Subject: Fix for some combat log errors. Only Vanish and Invisibility auras will now prevent from taking damage if target is not visible for caster. --HG-- branch : trunk --- src/game/Spell.cpp | 9 ++++++--- src/game/Unit.cpp | 11 +++++++++++ src/game/Unit.h | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index b43a57f9334..82756ad118f 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1150,14 +1150,17 @@ void Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask) } if( !m_caster->IsFriendlyTo(unit) ) { + // reset damage to 0 if target has Invisibility or Vanish aura (_only_ vanish, not stealth) and isn't visible for caster + bool isVisibleForHit = ( (unit->HasAuraType(SPELL_AURA_MOD_INVISIBILITY) || unit->HasAuraTypeWithFamilyFlags(SPELL_AURA_MOD_STEALTH, SPELLFAMILY_ROGUE ,SPELLFAMILYFLAG_ROGUE_VANISH)) && !unit->isVisibleForOrDetect(m_caster, true)) ? false : true; + // for delayed spells ignore not visible explicit target - if(m_spellInfo->speed > 0.0f && unit==m_targets.getUnitTarget() && !unit->isVisibleForOrDetect(m_caster,false)) + if(m_spellInfo->speed > 0.0f && unit==m_targets.getUnitTarget() && !isVisibleForHit) { - m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE); + // that was causing CombatLog errors + //m_caster->SendSpellMiss(unit, m_spellInfo->Id, SPELL_MISS_EVADE); m_damage = 0; return; } - unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_HITBYSPELL); if(m_customAttr & SPELL_ATTR_CU_AURA_CC) unit->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CC); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 6f248b75161..2ec904dd865 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -616,6 +616,17 @@ bool Unit::HasAuraType(AuraType auraType) const return (!m_modAuras[auraType].empty()); } +bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName ,uint64 familyFlags) const +{ + if(!HasAuraType(auraType)) return false; + AuraList const &auras = GetAurasByType(auraType); + for(AuraList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr) + if(SpellEntry const *iterSpellProto = (*itr)->GetSpellProto()) + if(iterSpellProto->SpellFamilyName == familyName && iterSpellProto->SpellFamilyFlags & familyFlags) + return true; + return false; +} + /* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */ void Unit::RemoveSpellbyDamageTaken(uint32 damage, uint32 spell) { diff --git a/src/game/Unit.h b/src/game/Unit.h index 5eb4530113c..9929c173206 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1018,6 +1018,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject uint32 GetCombatTimer() const { return m_CombatTimer; } bool HasAuraType(AuraType auraType) const; + bool HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint64 familyFlags) const; bool HasAura(uint32 spellId, uint32 effIndex) const { return m_Auras.find(spellEffectPair(spellId, effIndex)) != m_Auras.end(); } -- cgit v1.2.3