Core/Vehicle: Setting home position of creature passenger on AtEngage (#26482)

Co-authored-by: Edder <d.rosenauer@gmail.com>
(cherry picked from commit fb88a1409f)
This commit is contained in:
Edder
2021-05-11 09:56:32 +02:00
committed by Shauren
parent 9e6def8ae2
commit 4dbacb6985

View File

@@ -3464,8 +3464,20 @@ void Creature::AtEngage(Unit* target)
MovementGeneratorType const movetype = GetMotionMaster()->GetCurrentMovementGeneratorType();
if (movetype == WAYPOINT_MOTION_TYPE || movetype == POINT_MOTION_TYPE || (IsAIEnabled() && AI()->IsEscorted()))
{
SetHomePosition(GetPosition());
// if its a vehicle, set the home positon of every creature passenger at engage
// so that they are in combat range if hostile
if (Vehicle* vehicle = GetVehicleKit())
{
for (auto seat = vehicle->Seats.begin(); seat != vehicle->Seats.end(); ++seat)
if (Unit* passenger = ObjectAccessor::GetUnit(*this, seat->second.Passenger.Guid))
if (Creature* creature = passenger->ToCreature())
creature->SetHomePosition(GetPosition());
}
}
if (CreatureAI* ai = AI())
ai->JustEngagedWith(target);
if (CreatureGroup* formation = GetFormation())