From 9a411858d0879c2a1c97b8e3bc4aadbeb536e007 Mon Sep 17 00:00:00 2001 From: arrai Date: Tue, 30 Dec 2008 19:16:08 +0100 Subject: [PATCH] [6987] Implemented aura dependent creature target prioritization more correctly --- src/game/ThreatManager.cpp | 2 +- src/game/Unit.cpp | 10 ++++++++++ src/game/Unit.h | 1 + src/shared/revision_nr.h | 2 +- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp index 069115493..e3f496133 100644 --- a/src/game/ThreatManager.cpp +++ b/src/game/ThreatManager.cpp @@ -278,7 +278,7 @@ HostilReference* ThreatContainer::selectNextVictim(Creature* pAttacker, HostilRe // some units are prefered in comparison to others if(iter != lastRef && (target->IsImmunedToDamage(pAttacker->GetMeleeDamageSchoolMask(), false) || - target->hasUnitState(UNIT_STAT_CONFUSED | UNIT_STAT_FLEEING) + target->hasNegativeAuraWithInterruptFlag(AURA_INTERRUPT_FLAG_DAMAGE) ) ) { // current victim is a second choice target, so don't compare threat with it below diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0432b8006..f660b341e 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -10279,6 +10279,16 @@ Unit* Unit::SelectNearbyTarget() const return *tcIter; } +bool Unit::hasNegativeAuraWithInterruptFlag(uint32 flag) +{ + for (AuraMap::iterator iter = m_Auras.begin(); iter != m_Auras.end(); ++iter) + { + if (!iter->second->IsPositive() && iter->second->GetSpellProto()->AuraInterruptFlags & flag) + return true; + } + return false; +} + void Unit::ApplyAttackTimePercentMod( WeaponAttackType att,float val, bool apply ) { if(val > 0) diff --git a/src/game/Unit.h b/src/game/Unit.h index 383993c22..c2bc79099 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -824,6 +824,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void CombatStop(bool cast = false); void CombatStopWithPets(bool cast = false); Unit* SelectNearbyTarget() const; + bool hasNegativeAuraWithInterruptFlag(uint32 flag); void addUnitState(uint32 f) { m_state |= f; } bool hasUnitState(const uint32 f) const { return (m_state & f); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8aa81ee4b..4f70bfda4 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6986" + #define REVISION_NR "6987" #endif // __REVISION_NR_H__