diff options
author | Liberate <none@none> | 2010-09-18 12:33:16 +0200 |
---|---|---|
committer | Liberate <none@none> | 2010-09-18 12:33:16 +0200 |
commit | d036f7726ee4d15cc62aac36075f5f037ddab438 (patch) | |
tree | 58417cc9e64e072038256a7b0e961b36fa654482 /src | |
parent | 49dc1e55de6ec8315abb6e5ee8ab273216a2beb3 (diff) |
Core/PetAI: Implement a more correct way of findng if your pet's target has Crowd Control on it. Stuns like Hammer of Justice will not make your pet stop attacking anymore.
Pet's will only stop attacking if the Crowd Control is casted by the owner of the pet.
Fixes issue #4037
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/AI/CoreAI/PetAI.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 11 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 5 |
3 files changed, 13 insertions, 5 deletions
diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index b9d6ca5a556..cb92977b2a2 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -471,7 +471,7 @@ bool PetAI::_CanAttack(Unit *target) bool PetAI::_CheckTargetCC(Unit *target) { - if (target->HasCrowdControl()) + if (me->GetCharmerOrOwnerGUID() && target->HasNegativeAuraWithAttribute(SPELL_ATTR_BREAKABLE_BY_DAMAGE, me->GetCharmerOrOwnerGUID())) return true; return false; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 9610d567fd0..f9b4d4825fa 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -4641,6 +4641,17 @@ bool Unit::HasNegativeAuraWithInterruptFlag(uint32 flag, uint64 guid) return false; } +bool Unit::HasNegativeAuraWithAttribute(uint32 flag, uint64 guid) +{ + for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();) + { + Aura const *aura = iter->second->GetBase(); + if (!iter->second->IsPositive() && aura->GetSpellProto()->Attributes & flag && (!guid || aura->GetCasterGUID() == guid)) + return true; + } + return false; +} + AuraEffect * Unit::IsScriptOverriden(SpellEntry const * spell, int32 script) const { AuraEffectList const& auras = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 51710d9fe22..f3ee81cc39d 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1640,10 +1640,7 @@ class Unit : public WorldObject bool HasAuraTypeWithAffectMask(AuraType auratype, SpellEntry const * affectedSpell) const; bool HasAuraTypeWithValue(AuraType auratype, int32 value) const; bool HasNegativeAuraWithInterruptFlag(uint32 flag, uint64 guid = 0); - bool HasCrowdControl() { - return (HasAuraType(SPELL_AURA_MOD_CONFUSE) || HasAuraType(SPELL_AURA_MOD_FEAR) || HasAuraType(SPELL_AURA_MOD_STUN) || - HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_TRANSFORM)); - } + bool HasNegativeAuraWithAttribute(uint32 flag, uint64 guid = 0); AuraEffect * IsScriptOverriden(SpellEntry const * spell, int32 script) const; uint32 GetDiseasesByCaster(uint64 casterGUID, bool remove = false); |