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

Co-authored-by: Edder <d.rosenauer@gmail.com>
This commit is contained in:
Edder
2021-05-11 09:56:32 +02:00
committed by GitHub
parent 6c12f45f3b
commit fb88a1409f

View File

@@ -3343,8 +3343,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())