mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
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 88c6c61b95)
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -2326,6 +2326,11 @@ void ScriptMgr::OnQuestObjectiveChange(Player* player, Quest const* quest, Quest
|
||||
tmpscript->OnQuestObjectiveChange(player, quest, objective, oldAmount, newAmount);
|
||||
}
|
||||
|
||||
void ScriptMgr::ModifyVehiclePassengerExitPos(Unit* passenger, Vehicle* vehicle, Position& pos)
|
||||
{
|
||||
FOREACH_SCRIPT(UnitScript)->ModifyVehiclePassengerExitPos(passenger, vehicle, pos);
|
||||
}
|
||||
|
||||
SpellScriptLoader::SpellScriptLoader(char const* name)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
|
||||
@@ -71,6 +71,7 @@ struct CreatureTemplate;
|
||||
struct CreatureData;
|
||||
struct ItemTemplate;
|
||||
struct MapEntry;
|
||||
struct Position;
|
||||
struct QuestObjective;
|
||||
struct SceneTemplate;
|
||||
|
||||
@@ -410,6 +411,9 @@ class TC_GAME_API UnitScript : public ScriptObject
|
||||
|
||||
// Called when Spell Damage is being Dealt
|
||||
virtual void ModifySpellDamageTaken(Unit* /*target*/, Unit* /*attacker*/, int32& /*damage*/, SpellInfo const* /*spellInfo*/) { }
|
||||
|
||||
// Called when an unit exits a vehicle
|
||||
virtual void ModifyVehiclePassengerExitPos(Unit* /*passenger*/, Vehicle* /*vehicle*/, Position& /*pos*/) { }
|
||||
};
|
||||
|
||||
class TC_GAME_API CreatureScript : public ScriptObject
|
||||
@@ -1138,6 +1142,7 @@ class TC_GAME_API ScriptMgr
|
||||
void ModifyPeriodicDamageAurasTick(Unit* target, Unit* attacker, uint32& damage);
|
||||
void ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage);
|
||||
void ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage, SpellInfo const* spellInfo);
|
||||
void ModifyVehiclePassengerExitPos(Unit* passenger, Vehicle* vehicle, Position& pos);
|
||||
|
||||
public: /* AreaTriggerEntityScript */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user