Core/Vehicle: Added RideSpellID field to override npc_spellclick_spells

Port From (https://github.com/TrinityCore/TrinityCore/commit/46251b56553b610588eea89b83b4b4e8b88e47da)
This commit is contained in:
Hondacrx
2025-06-08 18:18:22 -04:00
parent fe4781722f
commit af8a76387c
3 changed files with 139 additions and 88 deletions
+21 -16
View File
@@ -42,7 +42,7 @@ namespace Game.Entities
// Set or remove correct flags based on available seats. Will overwrite db data (if wrong).
if (UsableSeatNum != 0)
_me.SetNpcFlag(_me.IsTypeId(TypeId.Player) ? NPCFlags.PlayerVehicle : NPCFlags.SpellClick);
else if(unit.m_unitData.InteractSpellID == 0)
else if (unit.m_unitData.InteractSpellID == 0)
_me.RemoveNpcFlag(_me.IsTypeId(TypeId.Player) ? NPCFlags.PlayerVehicle : NPCFlags.SpellClick);
InitMovementInfoForBase();
@@ -74,7 +74,7 @@ namespace Game.Entities
foreach (var acc in accessories)
if (!evading || acc.IsMinion) // only install minions on evade mode
InstallAccessory(acc.AccessoryEntry, acc.SeatId, acc.IsMinion, acc.SummonedType, acc.SummonTime);
InstallAccessory(acc.AccessoryEntry, acc.SeatId, acc.IsMinion, acc.SummonedType, acc.SummonTime, acc.RideSpellID);
}
public void Uninstall()
@@ -260,11 +260,11 @@ namespace Game.Entities
return null;
}
void InstallAccessory(uint entry, sbyte seatId, bool minion, byte type, uint summonTime)
void InstallAccessory(uint entry, sbyte seatId, bool minion, byte type, uint summonTime, uint? rideSpellId = null)
{
// @Prevent adding accessories when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.)
if (_status == Status.UnInstalling)
{
Log.outError(LogFilter.Vehicle, "Vehicle ({0}, Entry: {1}) attempts to install accessory (Entry: {2}) on seat {3} with STATUS_UNINSTALLING! " +
@@ -280,7 +280,10 @@ namespace Game.Entities
if (minion)
accessory.AddUnitTypeMask(UnitTypeMask.Accessory);
_me.HandleSpellClick(accessory, seatId);
if (rideSpellId.HasValue)
_me.HandleSpellClick(accessory, seatId, rideSpellId.Value);
else
_me.HandleSpellClick(accessory, seatId);
// If for some reason adding accessory to vehicle fails it will unsummon in
// @VehicleJoinEvent.Abort
@@ -362,7 +365,7 @@ namespace Game.Entities
var seat = GetSeatKeyValuePairForPassenger(unit);
Cypher.Assert(seat.Value != null);
Log.outDebug( LogFilter.Vehicle, "Unit {0} exit vehicle entry {1} id {2} dbguid {3} seat {4}",
Log.outDebug(LogFilter.Vehicle, "Unit {0} exit vehicle entry {1} id {2} dbguid {3} seat {4}",
unit.GetName(), _me.GetEntry(), _vehicleInfo.Id, _me.GetGUID().ToString(), seat.Key);
if (seat.Value.SeatInfo.CanEnterOrExit() && ++UsableSeatNum != 0)
@@ -392,7 +395,7 @@ namespace Game.Entities
_me.ToCreature().GetAI().PassengerBoarded(unit, seat.Key, false);
if (GetBase().IsTypeId(TypeId.Unit))
Global.ScriptMgr.OnRemovePassenger(this, unit);
Global.ScriptMgr.OnRemovePassenger(this, unit);
unit.SetVehicle(null);
return this;
@@ -441,7 +444,7 @@ namespace Game.Entities
return false;
}
void InitMovementInfoForBase()
{
VehicleFlags vehicleFlags = (VehicleFlags)GetVehicleInfo().Flags;
@@ -491,11 +494,11 @@ namespace Game.Entities
public float GetTransportOrientation() { return GetBase().GetOrientation(); }
public void AddPassenger(WorldObject passenger) { Log.outFatal(LogFilter.Vehicle, "Vehicle cannot directly gain passengers without auras"); }
public void CalculatePassengerPosition(ref float x, ref float y, ref float z, ref float o)
{
ITransport.CalculatePassengerPosition(ref x, ref y, ref z, ref o,
GetBase().GetPositionX(), GetBase().GetPositionY(),
ITransport.CalculatePassengerPosition(ref x, ref y, ref z, ref o,
GetBase().GetPositionX(), GetBase().GetPositionY(),
GetBase().GetPositionZ(), GetBase().GetOrientation());
}
@@ -507,7 +510,7 @@ namespace Game.Entities
}
public int GetMapIdForSpawning() { return (int)GetBase().GetMapId(); }
public void RemovePendingEvent(VehicleJoinEvent e)
{
foreach (var Event in _pendingJoinEvents)
@@ -535,7 +538,7 @@ namespace Game.Entities
public void RemovePendingEventsForPassenger(Unit passenger)
{
for (var i = 0; i< _pendingJoinEvents.Count; ++i)
for (var i = 0; i < _pendingJoinEvents.Count; ++i)
{
var joinEvent = _pendingJoinEvents[i];
if (joinEvent.Passenger == passenger)
@@ -556,7 +559,7 @@ namespace Game.Entities
}
return false;
}
public TimeSpan GetDespawnDelay()
{
VehicleTemplate vehicleTemplate = Global.ObjectMgr.GetVehicleTemplate(this);
@@ -797,19 +800,21 @@ namespace Game.Entities
public struct VehicleAccessory
{
public VehicleAccessory(uint entry, sbyte seatId, bool isMinion, byte summonType, uint summonTime)
public VehicleAccessory(uint entry, sbyte seatId, bool isMinion, byte summonType, uint summonTime, uint? rideSpellID)
{
AccessoryEntry = entry;
IsMinion = isMinion;
SummonTime = summonTime;
SeatId = seatId;
SummonedType = summonType;
RideSpellID = rideSpellID;
}
public uint AccessoryEntry;
public bool IsMinion;
public uint SummonTime;
public sbyte SeatId;
public byte SummonedType;
public uint? RideSpellID;
}
public class VehicleTemplate