diff --git a/Framework/Constants/CreatureConst.cs b/Framework/Constants/CreatureConst.cs index 73f7c8888..7d170cc27 100644 --- a/Framework/Constants/CreatureConst.cs +++ b/Framework/Constants/CreatureConst.cs @@ -335,4 +335,12 @@ namespace Framework.Constants SequenceBreak, // this is a boss and the pre-requisite encounters for engaging it are not defeated yet Other } + + public enum GroupAIFlags + { + None = 0, // If any creature from group is attacked, members won't assist and won't follow + LeaderAggro = 0x00000001, // The member aggroes if the leader aggroes + MemberAggro = 0x00000002, // The leader aggroes if the member aggroes + Follow = 0x00000004, // The member will follow the leader + } } diff --git a/Game/Entities/Creature/CreatureGroups.cs b/Game/Entities/Creature/CreatureGroups.cs index afe08fe0c..4956250fd 100644 --- a/Game/Entities/Creature/CreatureGroups.cs +++ b/Game/Entities/Creature/CreatureGroups.cs @@ -19,6 +19,7 @@ using Framework.Database; using Game.Maps; using System; using System.Collections.Generic; +using Framework.Constants; namespace Game.Entities { @@ -173,13 +174,10 @@ namespace Game.Entities public void MemberAttackStart(Creature member, Unit target) { - byte groupAI = FormationMgr.CreatureGroupMap[member.GetSpawnId()].groupAI; + GroupAIFlags groupAI = (GroupAIFlags)FormationMgr.CreatureGroupMap[member.GetSpawnId()].groupAI; if (groupAI == 0) return; - if (groupAI == 1 && member != m_leader) - return; - foreach (var pair in m_members) { if (m_leader) // avoid crash if leader was killed and reset. @@ -197,7 +195,7 @@ namespace Game.Entities if (other.GetVictim()) continue; - if (other.IsValidAttackTarget(target)) + if (((other != m_leader && groupAI.HasAnyFlag(GroupAIFlags.LeaderAggro)) || (other == m_leader && groupAI.HasAnyFlag(GroupAIFlags.MemberAggro))) && other.IsValidAttackTarget(target)) other.GetAI().AttackStart(target); } } @@ -230,7 +228,8 @@ namespace Game.Entities foreach (var pair in m_members) { Creature member = pair.Key; - if (member == m_leader || !member.IsAlive() || member.GetVictim()) + GroupAIFlags groupAI = (GroupAIFlags)FormationMgr.CreatureGroupMap[member.GetSpawnId()].groupAI; + if (member == m_leader || !member.IsAlive() || member.GetVictim() || !groupAI.HasAnyFlag(GroupAIFlags.Follow)) continue; if (pair.Value.point_1 != 0) diff --git a/Game/Entities/Unit/Unit.Spells.cs b/Game/Entities/Unit/Unit.Spells.cs index 314ea42a5..8944dd25d 100644 --- a/Game/Entities/Unit/Unit.Spells.cs +++ b/Game/Entities/Unit/Unit.Spells.cs @@ -4123,9 +4123,9 @@ namespace Game.Entities } uint spellId = aura.GetId(); - var range = m_ownedAuras.Where(p => p.Key == spellId); - foreach (var pair in range) + var range = m_ownedAuras.Where(p => p.Key == spellId); + foreach (var pair in range.ToList()) { if (pair.Value == aura) { @@ -4235,9 +4235,9 @@ namespace Game.Entities return; uint spellId = aurApp.GetBase().GetId(); - var range = m_appliedAuras.Where(p => p.Key == spellId); - foreach (var pair in range) + var range = m_appliedAuras.Where(p => p.Key == spellId); + foreach (var pair in range.ToList()) { if (aurApp == pair.Value) {