diff --git a/src/game/AI/BaseAI/UnitAI.h b/src/game/AI/BaseAI/UnitAI.h index 4acbec1e88f..ba9992ae3c9 100644 --- a/src/game/AI/BaseAI/UnitAI.h +++ b/src/game/AI/BaseAI/UnitAI.h @@ -568,6 +568,10 @@ class UnitAI : public CombatActions virtual void RequestFollow(Unit* /*followee*/) {} virtual void RelinquishFollow(ObjectGuid /*follower*/) {} + // Vehicle Hooks + virtual void OnPassengerRide(Unit* passenger, bool boarded, uint8 seat) {} + virtual void OnVehicleRide(Unit* vehicle, bool boarded, uint8 seat) {} + protected: virtual std::string GetAIName() { return "UnitAI"; } void DespawnGuids(GuidVector& spawns); // despawns all creature guids and clears contents diff --git a/src/game/Entities/Vehicle.cpp b/src/game/Entities/Vehicle.cpp index 0ce2a942fb0..56e522e4459 100644 --- a/src/game/Entities/Vehicle.cpp +++ b/src/game/Entities/Vehicle.cpp @@ -353,6 +353,14 @@ void VehicleInfo::Board(Unit* passenger, uint8 seat) // Apply passenger modifications ApplySeatMods(passenger, seatEntry->m_flags); + + if (Unit* owner = dynamic_cast(m_owner)) + { + if (owner->AI()) + owner->AI()->OnPassengerRide(passenger, true, seat); + if (passenger->AI()) + passenger->AI()->OnVehicleRide(owner, true, seat); + } } void VehicleInfo::ChangeSeat(Unit* passenger, uint8 currentSeat, bool next) @@ -438,6 +446,14 @@ void VehicleInfo::SwitchSeat(Unit* passenger, uint8 seat) // Apply passenger modifications of the new seat ApplySeatMods(passenger, seatEntry->m_flags); + + if (Unit* owner = dynamic_cast(m_owner)) + { + if (owner->AI()) + owner->AI()->OnPassengerRide(passenger, true, seat); + if (passenger->AI()) + passenger->AI()->OnVehicleRide(owner, true, seat); + } } /** @@ -457,7 +473,9 @@ void VehicleInfo::UnBoard(Unit* passenger, bool changeVehicle) DEBUG_LOG("VehicleInfo::Unboard: passenger: %s", passenger->GetGuidStr().c_str()); - VehicleSeatEntry const* seatEntry = GetSeatEntry(itr->second->GetTransportSeat()); + uint8 seat = itr->second->GetTransportSeat(); + + VehicleSeatEntry const* seatEntry = GetSeatEntry(seat); MANGOS_ASSERT(seatEntry); UnBoardPassenger(passenger); // Use TransportBase to remove the passenger from storage list @@ -542,6 +560,14 @@ void VehicleInfo::UnBoard(Unit* passenger, bool changeVehicle) ((Creature*)m_owner)->ForcedDespawn(1000); } } + + if (Unit* owner = dynamic_cast(m_owner)) + { + if (owner->AI()) + owner->AI()->OnPassengerRide(passenger, false, seat); + if (passenger->AI()) + passenger->AI()->OnVehicleRide(owner, false, seat); + } } /**