33 if (veSeat->CanEnterOrExit())
51 for (SeatMap::const_iterator itr =
Seats.begin(); itr !=
Seats.end(); ++itr)
52 ASSERT(itr->second.IsEmpty());
118 for (VehicleAccessoryList::const_iterator itr = accessories->begin(); itr != accessories->end(); ++itr)
119 if (!evading || itr->IsMinion)
138 SF_LOG_ERROR(
"entities.vehicle",
"Vehicle GuidLow: %u, Entry: %u attempts to uninstall, but already has STATUS_UNINSTALLING! "
139 "Check Uninstall/PassengerBoarded script hooks for errors.",
_me->GetGUIDLow(),
_me->GetEntry());
167 SF_LOG_DEBUG(
"entities.vehicle",
"Vehicle::Reset (Entry: %u, GuidLow: %u, DBGuid: %u)",
GetCreatureEntry(),
_me->GetGUIDLow(),
_me->ToCreature()->GetDBTableGUIDLow());
287 SeatMap::const_iterator seat =
Seats.find(seatId);
288 if (seat ==
Seats.end())
290 return seat->second.IsEmpty();
308 SeatMap::const_iterator seat =
Seats.find(seatId);
309 if (seat ==
Seats.end())
331 SeatMap::const_iterator seat =
Seats.find(seatId);
332 if (seat ==
Seats.end())
335 while (!seat->second.IsEmpty() || (!seat->second.SeatInfo->CanEnterOrExit() && !seat->second.SeatInfo->IsUsableByOverride()))
339 if (++seat ==
Seats.end())
340 seat =
Seats.begin();
344 if (seat ==
Seats.begin())
350 if (seat->first == seatId)
379 SF_LOG_ERROR(
"entities.vehicle",
"Vehicle (GuidLow: %u, DB GUID: %u, Entry: %u) attempts to install accessory (Entry: %u) on seat %d with STATUS_UNINSTALLING! "
380 "Check Uninstall/PassengerBoarded script hooks for errors.",
_me->GetGUIDLow(),
385 SF_LOG_DEBUG(
"entities.vehicle",
"Vehicle (GuidLow: %u, DB Guid: %u, Entry %u): installing accessory (Entry: %u) on seat: %d",
387 entry, (
int32)seatId);
395 (void)
_me->HandleSpellClick(accessory, seatId);
420 SF_LOG_ERROR(
"entities.vehicle",
"Passenger GuidLow: %u, Entry: %u, attempting to board vehicle GuidLow: %u, Entry: %u during uninstall! SeatId: %d",
425 SF_LOG_DEBUG(
"entities.vehicle",
"Unit %s scheduling enter vehicle (entry: %u, vehicleId: %u, guid: %u (dbguid: %u) on seat %d",
433 SeatMap::iterator seat;
439 for (seat =
Seats.begin(); seat !=
Seats.end(); ++seat)
440 if (seat->second.IsEmpty() && (seat->second.SeatInfo->CanEnterOrExit() || seat->second.SeatInfo->IsUsableByOverride()))
443 if (seat ==
Seats.end())
454 seat =
Seats.find(seatId);
455 if (seat ==
Seats.end())
463 if (!seat->second.IsEmpty())
470 ASSERT(seat->second.IsEmpty());
495 SF_LOG_DEBUG(
"entities.vehicle",
"Unit %s exit vehicle entry %u id %u dbguid %u seat %d",
498 if (seat->second.SeatInfo->CanEnterOrExit() && ++
UsableSeatNum)
505 seat->second.Passenger.Reset();
508 _me->RemoveCharmedBy(unit);
510 if (
_me->IsInWorld())
518 _me->ToCreature()->AI()->PassengerBoarded(unit, seat->first,
false);
541 for (SeatMap::const_iterator itr =
Seats.begin(); itr !=
Seats.end(); ++itr)
545 ASSERT(passenger->IsInWorld());
547 float px, py, pz, po;
548 passenger->m_movementInfo.transport.pos.GetPosition(px, py, pz, po);
551 passenger->UpdatePosition(px, py, pz, po);
569 for (SeatMap::const_iterator itr =
Seats.begin(); itr !=
Seats.end(); ++itr)
570 if (!itr->second.IsEmpty())
616 for (SeatMap::const_iterator itr =
Seats.begin(); itr !=
Seats.end(); ++itr)
617 if (itr->second.Passenger.Guid == passenger->
GetGUID())
618 return itr->second.SeatInfo;
638 SeatMap::iterator itr;
639 for (itr =
Seats.begin(); itr !=
Seats.end(); ++itr)
640 if (itr->second.Passenger.Guid == passenger->
GetGUID())
660 SeatMap::const_iterator itr;
661 for (itr =
Seats.begin(); itr !=
Seats.end(); ++itr)
662 if (itr->second.IsEmpty() && (itr->second.SeatInfo->CanEnterOrExit() || itr->second.SeatInfo->IsUsableByOverride()))
708 if ((*itr)->Seat->first == seatId)
710 (*itr)->to_Abort =
true;
733 if ((*itr)->Passenger == passenger)
735 (*itr)->to_Abort =
true;
746 Target->RemovePendingEvent(
this);
770 Target->RemovePendingEventsForSeat(
Seat->first);
776 if (
Seat->second.SeatInfo->CanEnterOrExit())
779 --(
Target->UsableSeatNum);
780 if (!
Target->UsableSeatNum)
789 Passenger->InterruptNonMeleeSpells(
false);
797 bg->EventPlayerDroppedFlag(player);
810 Passenger->m_movementInfo.transport.time = 0;
812 Passenger->m_movementInfo.transport.guid =
Target->GetBase()->GetGUID();
832 if (creature->IsAIEnabled)
833 creature->AI()->PassengerBoarded(
Passenger,
Seat->first,
true);
861 SF_LOG_DEBUG(
"entities.vehicle",
"Passenger GuidLow: %u, Entry: %u, board on vehicle GuidLow: %u, Entry: %u SeatId: %d cancelled",
870 SF_LOG_DEBUG(
"entities.vehicle",
"Passenger GuidLow: %u, Entry: %u, board on uninstalled vehicle SeatId: %d cancelled",
874 Passenger->ToCreature()->DespawnOrUnsummon();
@ VEHICLE_SEAT_FLAG_CAN_CONTROL
@ VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE
DBCStorage< VehicleSeatEntry > sVehicleSeatStore(VehicleSeatEntryfmt)
#define MAX_VEHICLE_SEATS
#define SF_LOG_DEBUG(filterType__,...)
#define SF_LOG_ERROR(filterType__,...)
@ SPELL_EFFECT_KNOCK_BACK_DEST
@ SPELL_EFFECT_KNOCK_BACK
@ CREATURE_TYPE_MECHANICAL
@ SPELL_AURA_DAMAGE_SHIELD
@ SPELL_AURA_MOD_RESISTANCE
@ SPELL_AURA_CONTROL_VEHICLE
@ SPELL_AURA_PERIODIC_HEAL
@ SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN
@ SPELL_AURA_SPLIT_DAMAGE_PCT
@ SPELL_AURA_SCHOOL_IMMUNITY
@ SPELL_AURA_MOD_DECREASE_SPEED
@ SPELL_AURA_SCHOOL_ABSORB
@ SPELL_AURA_MOD_UNATTACKABLE
@ UNIT_NPC_FLAG_SPELLCLICK
@ UNIT_NPC_FLAG_PLAYER_VEHICLE
@ MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING
@ MOVEMENTFLAG2_NO_STRAFE
@ MOVEMENTFLAG2_FULL_SPEED_PITCHING
@ MOVEMENTFLAG2_FULL_SPEED_TURNING
@ MOVEMENTFLAG2_NO_JUMPING
@ UNIT_FLAG_NOT_SELECTABLE
@ VEHICLE_SPELL_PARACHUTE
@ VEHICLE_FLAG_NO_JUMPING
@ VEHICLE_FLAG_FULLSPEEDTURNING
@ VEHICLE_FLAG_ALLOW_PITCHING
@ VEHICLE_FLAG_FULLSPEEDPITCHING
std::vector< VehicleAccessory > VehicleAccessoryList
void AddEvent(BasicEvent *Event, uint64 e_time, bool set_addtime=true)
uint64 CalculateTime(uint64 t_offset) const
void DisableTransportPathTransformations()
void SetFacing(float angle)
void MoveTo(const Vector3 &destination, bool generatePath=true, bool forceDestination=false)
static Unit * GetUnit(WorldObject const &, uint64 guid)
uint32 GetGUIDLow() const
void RemoveFlag(uint16 index, uint32 oldFlag)
void SendOnCancelExpectedVehicleRideAura()
void UnsummonPetTemporaryIfAny()
Battleground * GetBattleground() const
void StopCastingBindSight()
Vehicle * GetVehicle() const
void SetVehicle(Vehicle *vehicle)
void AddUnitTypeMask(uint32 mask)
void ExitVehicle(Position const *exitPosition=NULL)
Vehicle(Unit *unit, VehicleEntry const *vehInfo, uint32 creatureEntry)
uint8 GetAvailableSeatCount() const
Gets the available seat count.
Unit * GetBase() const
May be called from scripts.
Unit * GetPassenger(int8 seatId) const
Gets a passenger on specified seat.
void ApplyAllImmunities()
Applies specific immunities that cannot be set in DB.
void RemovePendingEvent(VehicleJoinEvent *e)
Removes @VehicleJoinEvent objects from pending join event store. This method only removes it after it...
SeatMap::iterator GetSeatIteratorForPassenger(Unit *passenger)
Gets seat iterator for specified passenger.
VehicleEntry const * GetVehicleInfo() const
void Reset(bool evading=false)
Reapplies immunities and reinstalls accessories. Only has effect for creatures.
Vehicle * RemovePassenger(Unit *passenger)
Removes the passenger from the vehicle.
void InitMovementInfoForBase()
Sets correct MovementFlags2 based on VehicleFlags from DBC.
bool AddPassenger(Unit *passenger, int8 seatId=-1)
Attempts to add a passenger to the vehicle on 'seatId'.
void CalculatePassengerPosition(float &x, float &y, float &z, float *o) const
This method transforms supplied transport offsets into global coordinates.
uint32 GetCreatureEntry() const
void RemoveAllPassengers()
Removes all current and pending passengers from the vehicle.
void InstallAccessory(uint32 entry, int8 seatId, bool minion, TempSummonType type, uint32 summonTime)
Installs an accessory.
bool IsVehicleInUse() const
Returns information whether the vehicle is currently used by any unit.
uint32 UsableSeatNum
Number of seats that match VehicleSeatEntry::UsableByPlayer, used for proper display flags.
uint32 _creatureEntry
Can be different than the entry of _me in case of players.
Status _status
Internal variable for sanity checks.
void Uninstall()
Removes all passengers and sets status to STATUS_UNINSTALLING. No new passengers can be added to the ...
void RemovePendingEventsForSeat(int8 seatId)
Removes any pending events for given seatId. Executed when a @VehicleJoinEventExecute is called.
Unit * _me
The underlying unit with the vehicle kit. Can be player or creature.
bool HasEmptySeat(int8 seatId) const
Checks if vehicle's seat specified by 'seatId' is empty.
PendingJoinEventContainer _pendingJoinEvents
Collection of delayed join events for prospective passengers.
VehicleSeatEntry const * GetSeatForPassenger(Unit const *passenger) const
Returns information on the seat of specified passenger, represented by the format in VehicleSeat....
void Install()
Initializes power type for vehicle. Nothing more.
void RelocatePassengers()
Relocate passengers. Must be called after m_base::Relocate.
SeatMap Seats
The collection of all seats on the vehicle. Including vacant ones.
SeatMap::const_iterator GetNextEmptySeat(int8 seatId, bool next) const
Gets the next empty seat based on current seat.
friend class VehicleJoinEvent
void RemovePendingEventsForPassenger(Unit *passenger)
VehicleEntry const * _vehicleInfo
DBC data for vehicle.
void InstallAllAccessories(bool evading)
bool Execute(uint64, uint32)
Actually adds the passenger @Passenger to vehicle @Target.
void Abort(uint64)
Aborts the event. Implies that unit @Passenger will not be boarding vehicle @Target after all.
std::string const & GetName() const
MovementInfo m_movementInfo
float m_attachmentOffsetX
float m_attachmentOffsetY
float m_attachmentOffsetZ