diff options
| author | Wyrserth <43747507+Wyrserth@users.noreply.github.com> | 2019-05-30 17:35:18 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-12-08 23:51:07 +0100 |
| commit | 1edd93bc0c443cdabc104af9f440e07b6d473a08 (patch) | |
| tree | 0ca0fc83da9b428f92909bb9ae5aeace9e20050c /src/server/game/Entities/Unit | |
| parent | 2cade0e6e3fb35192487882f7c4ada196866f39f (diff) | |
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)
Diffstat (limited to 'src/server/game/Entities/Unit')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
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); |
