fix(Core/Unit): adds in formation not attacking when leader killed (#7412)

Co-authored-by: John Smith <mostdefinitelyanagger@outlook.com>
This commit is contained in:
jestermaniac
2021-08-22 13:32:27 +02:00
committed by GitHub
parent e8d8050330
commit 5f6780532f
3 changed files with 16 additions and 9 deletions

View File

@@ -933,7 +933,7 @@ void Creature::Motion_Initialize()
GetMotionMaster()->Initialize();
else if (m_formation->getLeader() == this)
{
m_formation->FormationReset(false);
m_formation->FormationReset(false, true);
GetMotionMaster()->Initialize();
}
else if (m_formation->isFormed())
@@ -1759,7 +1759,7 @@ void Creature::setDeathState(DeathState s, bool despawn)
//Dismiss group if is leader
if (m_formation && m_formation->getLeader() == this)
m_formation->FormationReset(true);
m_formation->FormationReset(true, false);
bool needsFalling = !despawn && (IsFlying() || IsHovering()) && !IsUnderWater();
SetHover(false);

View File

@@ -186,7 +186,7 @@ void CreatureGroup::MemberAttackStart(Creature* member, Unit* target)
}
}
void CreatureGroup::FormationReset(bool dismiss)
void CreatureGroup::FormationReset(bool dismiss, bool initMotionMaster)
{
if (m_members.size() && m_members.begin()->second->groupAI == 5)
return;
@@ -195,11 +195,18 @@ void CreatureGroup::FormationReset(bool dismiss)
{
if (itr->first != m_leader && itr->first->IsAlive())
{
if (dismiss)
itr->first->GetMotionMaster()->Initialize();
else
itr->first->GetMotionMaster()->MoveIdle();
LOG_DEBUG("entities.unit", "Set %s movement for member %s", dismiss ? "default" : "idle", itr->first->GetGUID().ToString().c_str());
if (initMotionMaster)
{
if (dismiss)
{
itr->first->GetMotionMaster()->Initialize();
}
else
{
itr->first->GetMotionMaster()->MoveIdle();
}
LOG_DEBUG("entities.unit", "Set %s movement for member %s", dismiss ? "default" : "idle", itr->first->GetGUID().ToString().c_str());
}
}
}
m_Formed = !dismiss;

View File

@@ -59,7 +59,7 @@ public:
void AddMember(Creature* member);
void RemoveMember(Creature* member);
void FormationReset(bool dismiss);
void FormationReset(bool dismiss, bool initMotionMaster);
void LeaderMoveTo(float x, float y, float z, bool run);
void MemberAttackStart(Creature* member, Unit* target);