From c9fa7d22fcd265ac36d27a97ff280a545adac1fe Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 22 Feb 2022 13:43:52 -0500 Subject: [PATCH] Core/Units: Allow mind controlling non-controllable vehicles (for example players that become vehicle during boss encounters or creatures that only are vehicles to show non standard power type) Port From (https://github.com/TrinityCore/TrinityCore/commit/d56d92fbe7436af00e00b00ca5e7640f852d3485) --- Source/Game/Entities/Unit/Unit.Pets.cs | 2 +- Source/Game/Entities/Vehicle.cs | 9 +++++++++ Source/Game/Spells/Spell.cs | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.Pets.cs b/Source/Game/Entities/Unit/Unit.Pets.cs index 9df031733..76eb66210 100644 --- a/Source/Game/Entities/Unit/Unit.Pets.cs +++ b/Source/Game/Entities/Unit/Unit.Pets.cs @@ -278,7 +278,7 @@ namespace Game.Entities charmer.RemoveAurasByType(AuraType.Mounted); Cypher.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player)); - Cypher.Assert((type == CharmType.Vehicle) == IsVehicle()); + Cypher.Assert((type == CharmType.Vehicle) == (GetVehicleKit() && GetVehicleKit().IsControllableVehicle())); Log.outDebug(LogFilter.Unit, "SetCharmedBy: charmer {0} (GUID {1}), charmed {2} (GUID {3}), type {4}.", charmer.GetEntry(), charmer.GetGUID().ToString(), GetEntry(), GetGUID().ToString(), type); diff --git a/Source/Game/Entities/Vehicle.cs b/Source/Game/Entities/Vehicle.cs index 6dda92c1a..8c84b432d 100644 --- a/Source/Game/Entities/Vehicle.cs +++ b/Source/Game/Entities/Vehicle.cs @@ -434,6 +434,15 @@ namespace Game.Entities return false; } + public bool IsControllableVehicle() + { + foreach (var itr in Seats) + if (itr.Value.SeatInfo.HasFlag(VehicleSeatFlags.CanControl)) + return true; + + return false; + } + void InitMovementInfoForBase() { VehicleFlags vehicleFlags = (VehicleFlags)GetVehicleInfo().Flags; diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 73d240287..22f59001f 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -6786,7 +6786,7 @@ namespace Game.Spells case AuraType.ModCharm: case AuraType.ModPossessPet: case AuraType.AoeCharm: - if (target.IsTypeId(TypeId.Unit) && target.IsVehicle()) + if (target.GetVehicleKit() && target.GetVehicleKit().IsControllableVehicle()) return false; if (target.IsMounted()) return false;