Fix an issue that was causing all creature group members to assist each other, even if only one of the aggro flags was set. Also refactor enum values to be readable.
chery pick from 495e161db2f91cd3fa85e7844fd0c7c0027d0265
This commit is contained in:
@@ -179,6 +179,14 @@ void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
|
||||
if (!groupAI)
|
||||
return;
|
||||
|
||||
if (member == m_leader)
|
||||
{
|
||||
if (!(groupAI & FLAG_MEMBERS_ASSIST_LEADER))
|
||||
return;
|
||||
}
|
||||
else if (!(groupAI & FLAG_LEADER_ASSISTS_MEMBER))
|
||||
return;
|
||||
|
||||
for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
|
||||
{
|
||||
if (m_leader) // avoid crash if leader was killed and reset.
|
||||
@@ -196,7 +204,7 @@ void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
|
||||
if (other->GetVictim())
|
||||
continue;
|
||||
|
||||
if (((other != m_leader && groupAI & FLAG_AGGRO_ON_AGGRO) || (other == m_leader && groupAI & FLAG_TO_AGGRO_ON_AGGRO)) && other->IsValidAttackTarget(target))
|
||||
if (((other != m_leader && (groupAI & FLAG_MEMBERS_ASSIST_LEADER)) || (other == m_leader && (groupAI & FLAG_LEADER_ASSISTS_MEMBER))) && other->IsValidAttackTarget(target))
|
||||
other->AI()->AttackStart(target);
|
||||
}
|
||||
}
|
||||
@@ -230,7 +238,7 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z)
|
||||
{
|
||||
Creature* member = itr->first;
|
||||
uint8 groupAI = sFormationMgr->CreatureGroupMap[member->GetSpawnId()]->groupAI;
|
||||
if (member == m_leader || !member->IsAlive() || member->GetVictim() || !(groupAI & FLAG_FOLLOW))
|
||||
if (member == m_leader || !member->IsAlive() || member->GetVictim() || !(groupAI & FLAG_IDLE_IN_FORMATION))
|
||||
continue;
|
||||
|
||||
if (itr->second->point_1)
|
||||
|
||||
@@ -26,10 +26,11 @@
|
||||
|
||||
enum GroupAIFlags
|
||||
{
|
||||
FLAG_AGGRO_NONE = 0, // If any creature from group is attacked, members won't assist and won't follow
|
||||
FLAG_AGGRO_ON_AGGRO = 0x00000001, // The member aggroes if the leader aggroes
|
||||
FLAG_TO_AGGRO_ON_AGGRO = 0x00000002, // The leader aggroes if the member aggroes
|
||||
FLAG_FOLLOW = 0x00000004, // The member will follow the leader
|
||||
FLAG_AGGRO_NONE = 0, // No creature group behavior
|
||||
FLAG_MEMBERS_ASSIST_LEADER = 0x00000001, // The member aggroes if the leader aggroes
|
||||
FLAG_LEADER_ASSISTS_MEMBER = 0x00000002, // The leader aggroes if the member aggroes
|
||||
FLAG_MEMBERS_ASSIST_MEMBER = (FLAG_MEMBERS_ASSIST_LEADER | FLAG_LEADER_ASSISTS_MEMBER), // every member will assist if any member is attacked
|
||||
FLAG_IDLE_IN_FORMATION = 0x00000004, // The member will follow the leader when pathing idly
|
||||
};
|
||||
|
||||
class Creature;
|
||||
|
||||
Reference in New Issue
Block a user