diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index ebf9156f0..eaf619618 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -1126,6 +1126,15 @@ namespace Game.Entities return $"{base.GetDebugInfo()}\nAIName: {GetAIName()} ScriptName: {GetScriptName()} WaypointPath: {GetWaypointPath()} SpawnId: {GetSpawnId()}"; } + public override void ExitVehicle(Position exitPosition = null) + { + base.ExitVehicle(); + + // if the creature exits a vehicle, set it's home position to the + // exited position so it won't run away (home) and evade if it's hostile + SetHomePosition(GetPosition()); + } + public override bool IsMovementPreventedByCasting() { // first check if currently a movement allowed channel is active and we're not casting diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index 1818bbcf8..999ce42bb 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -999,7 +999,7 @@ namespace Game.Entities rideVehicleEffect.ChangeAmount((seatId < 0 ? GetTransSeat() : seatId) + 1); } - public void ExitVehicle(Position exitPosition = null) + public virtual void ExitVehicle(Position exitPosition = null) { //! This function can be called at upper level code to initialize an exit from the passenger's side. if (m_vehicle == null) diff --git a/Source/Scripts/Spells/Generic.cs b/Source/Scripts/Spells/Generic.cs index 0227e26c1..617db59b6 100644 --- a/Source/Scripts/Spells/Generic.cs +++ b/Source/Scripts/Spells/Generic.cs @@ -3445,6 +3445,34 @@ namespace Scripts.Spells.Generic } } + [Script("spell_gen_eject_passenger_1", 0)] + [Script("spell_gen_eject_passenger_3", 2)] + class spell_gen_eject_passenger_with_seatId : SpellScript + { + sbyte _seatId; + + public spell_gen_eject_passenger_with_seatId(sbyte seatId) + { + _seatId = seatId; + } + + void EjectPassenger(uint effIndex) + { + Vehicle vehicle = GetHitUnit().GetVehicleKit(); + if (vehicle != null) + { + Unit passenger = vehicle.GetPassenger(_seatId); + if (passenger != null) + passenger.ExitVehicle(); + } + } + + public override void Register() + { + OnEffectHitTarget.Add(new EffectHandler(EjectPassenger, 0, SpellEffectName.ScriptEffect)); + } + } + [Script] class spell_gen_gm_freeze : AuraScript {