mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Core/Vehicle: prevent creature vehicles from following their old movement generator when a player enters them in some cases.
Closes #21731 and #22368.
This commit is contained in:
@@ -13457,6 +13457,20 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a
|
||||
vehicle->GetBase()->RemoveAura(const_cast<AuraApplication*>(aurApp));
|
||||
return;
|
||||
}
|
||||
|
||||
if (vehicle->GetBase()->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
// If a player entered a vehicle that is part of a formation, remove it from said formation and replace current movement generator with MoveIdle (no movement)
|
||||
if (CreatureGroup* creatureGroup = vehicle->GetBase()->ToCreature()->GetFormation())
|
||||
{
|
||||
creatureGroup->RemoveMember(vehicle->GetBase()->ToCreature());
|
||||
vehicle->GetBase()->GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
|
||||
// If the vehicle has the random movement generator active, replace it with MoveIdle (no movement) so it won't override player control
|
||||
if (vehicle->GetBase()->GetMotionMaster()->GetCurrentMovementGeneratorType() == RANDOM_MOTION_TYPE)
|
||||
vehicle->GetBase()->GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
}
|
||||
|
||||
// If vehicle flag for fixed position set (cannons), or if the following hardcoded units, then set state rooted
|
||||
@@ -13565,8 +13579,14 @@ void Unit::_ExitVehicle(Position const* exitPosition)
|
||||
GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_EXIT, MOTION_SLOT_CONTROLLED);
|
||||
|
||||
if (player)
|
||||
{
|
||||
player->ResummonPetTemporaryUnSummonedIfAny();
|
||||
|
||||
// When a player exits a creature vehicle, restore its default motion generator (if any)
|
||||
if (vehicle->GetBase()->GetTypeId() == TYPEID_UNIT)
|
||||
vehicle->GetBase()->GetMotionMaster()->InitializeDefault();
|
||||
}
|
||||
|
||||
if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION) && vehicle->GetBase()->GetTypeId() == TYPEID_UNIT)
|
||||
if (((Minion*)vehicle->GetBase())->GetOwner() == this)
|
||||
vehicle->GetBase()->ToCreature()->DespawnOrUnsummon(1);
|
||||
|
||||
Reference in New Issue
Block a user