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
This commit is contained in:
Wyrserth authored and Ovahlord committed 2019-10-17 03:45:49 +02:00
1 parent 83c0bb1f93
commit 279a45e23c
3 files changed
+23 -8

No files matched your search

+13 -8
View File
@@ -13546,18 +13546,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);
@@ -13567,7 +13572,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_SLOT_CONTROLLED);