TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
VehicleJoinEvent Class Reference

#include <Vehicle.h>

Protected Member Functions

 VehicleJoinEvent (Vehicle *v, Unit *u)
 
 ~VehicleJoinEvent ()
 
bool Execute (uint64, uint32) override
 Actually adds the passenger to vehicle . More...
 
void Abort (uint64) override
 Aborts the event. Implies that unit will not be boarding vehicle after all. More...
 

Protected Attributes

VehicleTarget
 
UnitPassenger
 
SeatMap::iterator Seat
 

Friends

class Vehicle
 

Additional Inherited Members

- Public Member Functions inherited from BasicEvent
 BasicEvent ()
 
virtual ~BasicEvent ()
 
virtual bool IsDeletable () const
 
- Public Attributes inherited from BasicEvent
bool to_Abort
 
uint64 m_addTime
 
uint64 m_execTime
 

Constructor & Destructor Documentation

VehicleJoinEvent::VehicleJoinEvent ( Vehicle v,
Unit u 
)
inlineprotected
125 : Target(v), Passenger(u), Seat(Target->Seats.end()) { }
Unit * Passenger
Definition: Vehicle.h:131
SeatMap::iterator Seat
Definition: Vehicle.h:132
Vehicle * Target
Definition: Vehicle.h:130
SeatMap Seats
The collection of all seats on the vehicle. Including vacant ones.
Definition: Vehicle.h:68
VehicleJoinEvent::~VehicleJoinEvent ( )
protected
728 {
729  if (Target)
730  Target->RemovePendingEvent(this);
731 }
Vehicle * Target
Definition: Vehicle.h:130
void RemovePendingEvent(VehicleJoinEvent *e)
Removes objects from pending join event store. This method only removes it after it's executed or ab...
Definition: Vehicle.cpp:665

+ Here is the call graph for this function:

Member Function Documentation

void VehicleJoinEvent::Abort ( uint64  )
overrideprotectedvirtual

Aborts the event. Implies that unit will not be boarding vehicle after all.

Author
Machiavelli
Date
17-2-2013
Parameters
parameter1Unused

Check if the Vehicle was already uninstalled, in which case all auras were removed already

auras can be applied even when the passenger is not (yet) on the vehicle. When this code is triggered it means that something went wrong in ::AddPassenger, and we should remove the aura manually.

Reimplemented from BasicEvent.

843 {
845  if (Target)
846  {
847  TC_LOG_DEBUG("entities.vehicle", "Passenger %s, Entry: %u, board on vehicle %s, Entry: %u SeatId: %d cancelled",
848  Passenger->GetGUID().ToString().c_str(), Passenger->GetEntry(), Target->GetBase()->GetGUID().ToString().c_str(), Target->GetBase()->GetEntry(), (int32)Seat->first);
849 
854  }
855  else
856  TC_LOG_DEBUG("entities.vehicle", "Passenger %s, Entry: %u, board on uninstalled vehicle SeatId: %d cancelled",
857  Passenger->GetGUID().ToString().c_str(), Passenger->GetEntry(), (int32)Seat->first);
858 
861 }
void DespawnOrUnsummon(uint32 msTimeToDespawn=0)
Definition: Creature.cpp:1774
Definition: Unit.h:867
Unit * Passenger
Definition: Vehicle.h:131
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: SpellAuraDefines.h:296
ObjectGuid const & GetGUID() const
Definition: Object.h:105
SeatMap::iterator Seat
Definition: Vehicle.h:132
Creature * ToCreature()
Definition: Object.h:194
int32_t int32
Definition: g3dmath.h:167
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1399
Vehicle * Target
Definition: Vehicle.h:130
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567
uint32 GetEntry() const
Definition: Object.h:107
bool IsInWorld() const
Definition: Object.h:100
std::string ToString() const
Definition: ObjectGuid.cpp:99
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:49

+ Here is the call graph for this function:

bool VehicleJoinEvent::Execute ( uint64  ,
uint32   
)
overrideprotectedvirtual

Actually adds the passenger to vehicle .

Author
Machiavelli
Date
17-2-2013
Parameters
parameter1Unused
parameter2Unused.
Returns
true, cannot fail.

Reimplemented from BasicEvent.

749 {
753 
756 
758  Seat->second.Passenger.Guid = Passenger->GetGUID();
759  Seat->second.Passenger.IsUnselectable = Passenger->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
760  if (Seat->second.SeatInfo->CanEnterOrExit())
761  {
763  --(Target->UsableSeatNum);
764  if (!Target->UsableSeatNum)
765  {
766  if (Target->GetBase()->GetTypeId() == TYPEID_PLAYER)
768  else
770  }
771  }
772 
775 
776  VehicleSeatEntry const* veSeat = Seat->second.SeatInfo;
777 
778  Player* player = Passenger->ToPlayer();
779  if (player)
780  {
781  // drop flag
782  if (Battleground* bg = player->GetBattleground())
783  bg->EventPlayerDroppedFlag(player);
784 
785  player->StopCastingCharm();
786  player->StopCastingBindSight();
787  player->SendOnCancelExpectedVehicleRideAura();
788  if (!(veSeat->FlagsB & VEHICLE_SEAT_FLAG_B_KEEP_PET))
789  player->UnsummonPetTemporaryIfAny();
790  }
791 
792  if (Seat->second.SeatInfo->Flags & VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE)
794 
800 
802  Seat->second.SeatInfo->Flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
803  ASSERT(Target->GetBase()->SetCharmedBy(Passenger, CHARM_TYPE_VEHICLE)); // SMSG_CLIENT_CONTROL
804 
805  Passenger->SendClearTarget(); // SMSG_BREAK_TARGET
806  Passenger->SetControlled(true, UNIT_STATE_ROOT); // SMSG_FORCE_ROOT - In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures)
807  // also adds MOVEMENTFLAG_ROOT
808 
810  init.DisableTransportPathTransformations();
811  init.MoveTo(veSeat->AttachmentOffset.X, veSeat->AttachmentOffset.Y, veSeat->AttachmentOffset.Z, false, true);
812  init.SetFacing(0.0f);
813  init.SetTransportEnter();
814  init.Launch();
815 
816  if (Creature* creature = Target->GetBase()->ToCreature())
817  {
818  if (creature->IsAIEnabled)
819  creature->AI()->PassengerBoarded(Passenger, Seat->first, true);
820 
821  sScriptMgr->OnAddPassenger(Target, Passenger, Seat->first);
822 
823  // Actually quite a redundant hook. Could just use OnAddPassenger and check for unit typemask inside script.
825  sScriptMgr->OnInstallAccessory(Target, Passenger->ToCreature());
826  }
827 
828  return true;
829 }
Definition: DBCStructure.h:1305
float Z
Definition: DBCEnums.h:36
void SendClearTarget()
Definition: Unit.cpp:15682
Definition: Unit.h:759
float Y
Definition: DBCEnums.h:35
VehicleEntry const * GetVehicleInfo() const
Definition: Vehicle.h:50
bool HasAuraTypeWithCaster(AuraType auratype, ObjectGuid caster) const
Definition: Unit.cpp:4252
uint32 UsableSeatNum
Number of seats that match VehicleSeatEntry::UsableByPlayer, used for proper display flags...
Definition: Vehicle.h:76
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Unit.h:867
Unit * Passenger
Definition: Vehicle.h:131
Definition: ObjectGuid.h:32
Definition: Unit.h:1185
void RemovePendingEventsForSeat(int8 seatId)
Removes any pending events for given seatId. Executed when a ::Execute is called. ...
Definition: Vehicle.cpp:688
Definition: Creature.h:467
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
struct MovementInfo::TransportInfo transport
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
void SetVehicle(Vehicle *vehicle)
Definition: Unit.h:2167
uint32 ID
Definition: DBCStructure.h:1273
void RemovePendingEventsForPassenger(Unit *passenger)
Definition: Vehicle.cpp:713
void Relocate(float x, float y)
Definition: Position.h:67
void SetControlled(bool apply, UnitState state)
Definition: Unit.cpp:13808
Definition: SpellAuraDefines.h:296
Definition: Unit.h:760
Definition: DBCEnums.h:718
Definition: DBCEnums.h:749
uint32 vehicleId
Definition: Object.h:294
int8 seat
Definition: Object.h:291
float X
Definition: DBCEnums.h:34
Position pos
Definition: Object.h:290
ObjectGuid const & GetGUID() const
Definition: Object.h:105
SeatMap::iterator Seat
Definition: Vehicle.h:132
Definition: ObjectGuid.h:33
Definition: UpdateFields.h:109
Creature * ToCreature()
Definition: Object.h:194
DBCPosition3D AttachmentOffset
Definition: DBCStructure.h:1310
Definition: Unit.h:560
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1399
Vehicle * Target
Definition: Vehicle.h:130
#define ASSERT
Definition: Errors.h:55
Definition: UpdateFields.h:135
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567
Definition: Battleground.h:235
ObjectGuid guid
Definition: Object.h:289
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32 time
Definition: Object.h:292
bool IsInWorld() const
Definition: Object.h:100
bool SetCharmedBy(Unit *charmer, CharmType type, AuraApplication const *aurApp=NULL)
Definition: Unit.cpp:14024
Definition: MoveSplineInit.h:52
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
void RemoveFlag64(uint16 index, uint64 oldFlag)
Definition: Object.cpp:1312
uint32 FlagsB
Definition: DBCStructure.h:1349
Definition: Unit.h:698
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:49
Definition: SpellAuraDefines.h:138

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class Vehicle
friend

Member Data Documentation

Unit* VehicleJoinEvent::Passenger
protected
SeatMap::iterator VehicleJoinEvent::Seat
protected
Vehicle* VehicleJoinEvent::Target
protected

The documentation for this class was generated from the following files: