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

Co-authored-by: Edder <[email protected]>
(cherry picked from commit fb88a1409ff60343edb0c539d406a961724fcc4e)
This commit is contained in:
Edder
2022-03-09 14:55:40 +01:00
committed by Shauren
parent 9e6def8ae2
commit 4dbacb6985
@@ -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())