From 1edd93bc0c443cdabc104af9f440e07b6d473a08 Mon Sep 17 00:00:00 2001 From: Wyrserth <43747507+Wyrserth@users.noreply.github.com> Date: Thu, 30 May 2019 17:35:18 +0200 Subject: Core/Script: add script hook to allow overriding of a vehicle passenger's exit position (#23322) * Core/Script: add script hook to allow overriding of a vehicle passenger's exit position. * Allow to change orientation, and fix nopch. * Keep original orientation, thanks jackpoz! * Update Unit.cpp Code cleanup * Update Unit.cpp (cherry picked from commit 88c6c61b95ac2b2f911b519136770479d31de27d) --- src/server/game/Entities/Unit/Unit.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/server/game/Entities/Unit') diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index c4a62aecb66..c3e98c114c4 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -11906,18 +11906,23 @@ void Unit::_ExitVehicle(Position const* exitPosition) SetControlled(false, UNIT_STATE_ROOT); // SMSG_MOVE_FORCE_UNROOT, ~MOVEMENTFLAG_ROOT - Position pos; - if (!exitPosition) // Exit position not specified - pos = vehicle->GetBase()->GetPosition(); // This should use passenger's current position, leaving it as it is now - // because we calculate positions incorrect (sometimes under map) - else - pos = *exitPosition; - AddUnitState(UNIT_STATE_MOVE); if (player) player->SetFallInformation(0, GetPositionZ()); + Position pos; + // If we ask for a specific exit position, use that one. Otherwise allow scripts to modify it + if (exitPosition) + pos = *exitPosition; + else + { + // Set exit position to vehicle position and use the current orientation + pos = vehicle->GetBase()->GetPosition(); + pos.SetOrientation(GetOrientation()); + sScriptMgr->ModifyVehiclePassengerExitPos(this, vehicle, pos); + } + float height = pos.GetPositionZ() + vehicle->GetBase()->GetCollisionHeight(); Movement::MoveSplineInit init(this); @@ -11927,7 +11932,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) init.SetFall(); init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false); - init.SetFacing(GetOrientation()); + init.SetFacing(pos.GetOrientation()); init.SetTransportExit(); GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_EXIT, MOTION_PRIORITY_HIGHEST); -- cgit v1.2.3