mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 08:28:32 +01:00
Core/Creature: Implement Mangos GroupAI flags (allows formation without following) (#18733)
This commit is contained in:
4
sql/updates/world/3.3.5/2017_12_18_00_world.sql
Normal file
4
sql/updates/world/3.3.5/2017_12_18_00_world.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
--
|
||||
UPDATE `creature_formations` SET `groupAI`=7 WHERE `groupAI`=2; -- members attack and members follow the leader
|
||||
UPDATE `creature_formations` SET `groupAI`=4 WHERE `groupAI`=0; -- members follow the leader
|
||||
UPDATE `creature_formations` SET `groupAI`=5 WHERE `groupAI`=1; -- The members aggroes if the leader aggroes and members follow the leader
|
||||
@@ -176,9 +176,6 @@ void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
|
||||
if (!groupAI)
|
||||
return;
|
||||
|
||||
if (groupAI == 1 && member != m_leader)
|
||||
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 +193,7 @@ void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
|
||||
if (other->GetVictim())
|
||||
continue;
|
||||
|
||||
if (other->IsValidAttackTarget(target))
|
||||
if (((other != m_leader && groupAI & FLAG_AGGRO_ON_AGGRO) || (other == m_leader && groupAI & FLAG_TO_AGGRO_ON_AGGRO)) && other->IsValidAttackTarget(target))
|
||||
other->AI()->AttackStart(target);
|
||||
}
|
||||
}
|
||||
@@ -229,7 +226,8 @@ void CreatureGroup::LeaderMoveTo(float x, float y, float z)
|
||||
for (CreatureGroupMemberType::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
|
||||
{
|
||||
Creature* member = itr->first;
|
||||
if (member == m_leader || !member->IsAlive() || member->GetVictim())
|
||||
uint8 groupAI = sFormationMgr->CreatureGroupMap[member->GetSpawnId()]->groupAI;
|
||||
if (member == m_leader || !member->IsAlive() || member->GetVictim() || !(groupAI & FLAG_FOLLOW))
|
||||
continue;
|
||||
|
||||
if (itr->second->point_1)
|
||||
|
||||
@@ -23,6 +23,14 @@
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
class Creature;
|
||||
class CreatureGroup;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user