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:
hondacrx
2021-12-16 12:47:54 -05:00
parent 589d845093
commit 40f6c9a9fd
3 changed files with 20 additions and 8 deletions
+13 -8
View File
@@ -994,18 +994,23 @@ namespace Game.Entities
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);
if (player != null)
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();
MoveSplineInit init = new(this);
@@ -1015,7 +1020,7 @@ namespace Game.Entities
init.SetFall();
init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);
init.SetFacing(GetOrientation());
init.SetFacing(pos.GetOrientation());
init.SetTransportExit();
GetMotionMaster().LaunchMoveSpline(init, EventId.VehicleExit, MovementGeneratorPriority.Highest);
+3
View File
@@ -303,6 +303,9 @@ namespace Game.Scripting
// Called when Spell Damage is being Dealt
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
+4
View File
@@ -1100,6 +1100,10 @@ namespace Game.Scripting
ForEach<UnitScript>(p => p.ModifySpellDamageTaken(target, attacker, ref dmg, spellInfo));
damage = dmg;
}
public void ModifyVehiclePassengerExitPos(Unit passenger, Vehicle vehicle, Position pos)
{
ForEach<UnitScript>(p => p.ModifyVehiclePassengerExitPos(passenger, vehicle, pos));
}
// AreaTriggerEntityScript
public AreaTriggerAI GetAreaTriggerAI(AreaTrigger areaTrigger)