Core/Script: add script hook to allow overriding of a vehicle passenger's exit position
Port From (https://github.com/TrinityCore/TrinityCore/commit/1edd93bc0c443cdabc104af9f440e07b6d473a08)
This commit is contained in:
@@ -994,18 +994,23 @@ namespace Game.Entities
|
|||||||
|
|
||||||
SetControlled(false, UnitState.Root); // SMSG_MOVE_FORCE_UNROOT, ~MOVEMENTFLAG_ROOT
|
SetControlled(false, UnitState.Root); // SMSG_MOVE_FORCE_UNROOT, ~MOVEMENTFLAG_ROOT
|
||||||
|
|
||||||
Position pos;
|
|
||||||
if (exitPosition == null) // 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(UnitState.Move);
|
AddUnitState(UnitState.Move);
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
player.SetFallInformation(0, GetPositionZ());
|
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 != null)
|
||||||
|
pos = exitPosition;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Set exit position to vehicle position and use the current orientation
|
||||||
|
pos = vehicle.GetBase().GetPosition();
|
||||||
|
pos.SetOrientation(GetOrientation());
|
||||||
|
Global.ScriptMgr.ModifyVehiclePassengerExitPos(this, vehicle, pos);
|
||||||
|
}
|
||||||
|
|
||||||
float height = pos.GetPositionZ() + vehicle.GetBase().GetCollisionHeight();
|
float height = pos.GetPositionZ() + vehicle.GetBase().GetCollisionHeight();
|
||||||
|
|
||||||
MoveSplineInit init = new(this);
|
MoveSplineInit init = new(this);
|
||||||
@@ -1015,7 +1020,7 @@ namespace Game.Entities
|
|||||||
init.SetFall();
|
init.SetFall();
|
||||||
|
|
||||||
init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);
|
init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);
|
||||||
init.SetFacing(GetOrientation());
|
init.SetFacing(pos.GetOrientation());
|
||||||
init.SetTransportExit();
|
init.SetTransportExit();
|
||||||
GetMotionMaster().LaunchMoveSpline(init, EventId.VehicleExit, MovementGeneratorPriority.Highest);
|
GetMotionMaster().LaunchMoveSpline(init, EventId.VehicleExit, MovementGeneratorPriority.Highest);
|
||||||
|
|
||||||
|
|||||||
@@ -303,6 +303,9 @@ namespace Game.Scripting
|
|||||||
|
|
||||||
// Called when Spell Damage is being Dealt
|
// Called when Spell Damage is being Dealt
|
||||||
public virtual void ModifySpellDamageTaken(Unit target, Unit attacker, ref int damage, SpellInfo spellInfo) { }
|
public virtual void ModifySpellDamageTaken(Unit target, Unit attacker, ref int damage, SpellInfo spellInfo) { }
|
||||||
|
|
||||||
|
// Called when an unit exits a vehicle
|
||||||
|
public virtual void ModifyVehiclePassengerExitPos(Unit passenger, Vehicle vehicle, Position pos) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GenericCreatureScript<AI> : CreatureScript where AI : CreatureAI
|
public class GenericCreatureScript<AI> : CreatureScript where AI : CreatureAI
|
||||||
|
|||||||
@@ -1100,6 +1100,10 @@ namespace Game.Scripting
|
|||||||
ForEach<UnitScript>(p => p.ModifySpellDamageTaken(target, attacker, ref dmg, spellInfo));
|
ForEach<UnitScript>(p => p.ModifySpellDamageTaken(target, attacker, ref dmg, spellInfo));
|
||||||
damage = dmg;
|
damage = dmg;
|
||||||
}
|
}
|
||||||
|
public void ModifyVehiclePassengerExitPos(Unit passenger, Vehicle vehicle, Position pos)
|
||||||
|
{
|
||||||
|
ForEach<UnitScript>(p => p.ModifyVehiclePassengerExitPos(passenger, vehicle, pos));
|
||||||
|
}
|
||||||
|
|
||||||
// AreaTriggerEntityScript
|
// AreaTriggerEntityScript
|
||||||
public AreaTriggerAI GetAreaTriggerAI(AreaTrigger areaTrigger)
|
public AreaTriggerAI GetAreaTriggerAI(AreaTrigger areaTrigger)
|
||||||
|
|||||||
Reference in New Issue
Block a user