AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Vehicle Class Reference

#include "Vehicle.h"

Inheritance diagram for Vehicle:
TransportBase

Public Member Functions

void Install ()
 
void Uninstall ()
 
void Reset (bool evading=false)
 
void InstallAllAccessories (bool evading)
 
void ApplyAllImmunities ()
 
void InstallAccessory (uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime)
 
UnitGetBase () const
 May be called from scripts. More...
 
VehicleEntry const * GetVehicleInfo () const
 
uint32 GetCreatureEntry () const
 
bool HasEmptySeat (int8 seatId) const
 
UnitGetPassenger (int8 seatId) const
 
int8 GetNextEmptySeat (int8 seatId, bool next) const
 
VehicleSeatAddon const * GetSeatAddonForSeatOfPassenger (Unit const *passenger) const
 
uint8 GetAvailableSeatCount () const
 
bool AddPassenger (Unit *passenger, int8 seatId=-1)
 
void EjectPassenger (Unit *passenger, Unit *controller)
 
void RemovePassenger (Unit *passenger)
 
void RelocatePassengers ()
 
void RemoveAllPassengers ()
 
void Dismiss ()
 
bool IsVehicleInUse ()
 
void TeleportVehicle (float x, float y, float z, float ang)
 
VehicleSeatEntry const * GetSeatForPassenger (Unit const *passenger)
 
SeatMap::iterator GetSeatIteratorForPassenger (Unit *passenger)
 
virtual void CalculatePassengerPosition (float &x, float &y, float &z, float *o=nullptr) const =0
 This method transforms supplied transport offsets into global coordinates. More...
 
virtual void CalculatePassengerOffset (float &x, float &y, float &z, float *o=nullptr) const =0
 This method transforms supplied global coordinates into local offsets. More...
 

Public Attributes

SeatMap Seats
 

Protected Member Functions

 Vehicle (Unit *unit, VehicleEntry const *vehInfo, uint32 creatureEntry)
 
 ~Vehicle () override
 
- Protected Member Functions inherited from TransportBase
 TransportBase ()=default
 
virtual ~TransportBase ()=default
 

Private Types

enum  Status {
  STATUS_NONE ,
  STATUS_INSTALLED ,
  STATUS_UNINSTALLING
}
 

Private Member Functions

void InitMovementInfoForBase ()
 
void CalculatePassengerPosition (float &x, float &y, float &z, float *o) const override
 This method transforms supplied transport offsets into global coordinates. More...
 
void CalculatePassengerOffset (float &x, float &y, float &z, float *o) const override
 This method transforms supplied global coordinates into local offsets. More...
 

Private Attributes

Unit_me
 
VehicleEntry const * _vehicleInfo
 
uint32 _usableSeatNum
 
uint32 _creatureEntry
 
Status _status
 

Friends

bool Unit::CreateVehicleKit (uint32 id, uint32 creatureEntry)
 
void Unit::RemoveVehicleKit ()
 

Additional Inherited Members

- Static Protected Member Functions inherited from TransportBase
static void CalculatePassengerPosition (float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
 
static void CalculatePassengerOffset (float &x, float &y, float &z, float *o, float transX, float transY, float transZ, float transO)
 

Detailed Description

Member Enumeration Documentation

◆ Status

enum Vehicle::Status
private
Enumerator
STATUS_NONE 
STATUS_INSTALLED 
STATUS_UNINSTALLING 
69 {
73 };
@ STATUS_INSTALLED
Definition: Vehicle.h:71
@ STATUS_UNINSTALLING
Definition: Vehicle.h:72
@ STATUS_NONE
Definition: Vehicle.h:70

Constructor & Destructor Documentation

◆ Vehicle()

Vehicle::Vehicle ( Unit unit,
VehicleEntry const *  vehInfo,
uint32  creatureEntry 
)
protected
29 :
30 _me(unit), _vehicleInfo(vehInfo), _usableSeatNum(0), _creatureEntry(creatureEntry), _status(STATUS_NONE)
31{
32 for (uint32 i = 0; i < MAX_VEHICLE_SEATS; ++i)
33 {
34 if (uint32 seatId = _vehicleInfo->m_seatID[i])
35 if (VehicleSeatEntry const* veSeat = sVehicleSeatStore.LookupEntry(seatId))
36 {
37 VehicleSeatAddon const* addon = sObjectMgr->GetVehicleSeatAddon(seatId);
38 Seats.insert(std::make_pair(i, VehicleSeat(veSeat, addon)));
39 if (veSeat->CanEnterOrExit())
41 }
42 }
43
44 // Set or remove correct flags based on available seats. Will overwrite db data (if wrong).
47 else
49
51}
std::uint32_t uint32
Definition: Define.h:107
Seats
Definition: boss_flame_leviathan.cpp:167
#define MAX_VEHICLE_SEATS
Definition: DBCStructure.h:2023
#define sObjectMgr
Definition: ObjectMgr.h:1635
@ UNIT_NPC_FLAG_SPELLCLICK
Definition: UnitDefines.h:318
@ UNIT_NPC_FLAG_PLAYER_VEHICLE
Definition: UnitDefines.h:319
DBCStorage< VehicleSeatEntry > sVehicleSeatStore(VehicleSeatEntryfmt)
bool IsPlayer() const
Definition: Object.h:200
void RemoveNpcFlag(NPCFlags flags)
Definition: Unit.h:727
void SetNpcFlag(NPCFlags flags)
Definition: Unit.h:726
uint32 _usableSeatNum
Definition: Vehicle.h:95
void InitMovementInfoForBase()
Definition: Vehicle.cpp:581
uint32 _creatureEntry
Definition: Vehicle.h:96
Status _status
Definition: Vehicle.h:97
Unit * _me
Definition: Vehicle.h:93
VehicleEntry const * _vehicleInfo
Definition: Vehicle.h:94
Definition: VehicleDefines.h:86
Definition: VehicleDefines.h:101
uint32 m_seatID[MAX_VEHICLE_SEATS]
Definition: DBCStructure.h:2033
Definition: DBCStructure.h:2063

References _me, _usableSeatNum, _vehicleInfo, InitMovementInfoForBase(), Object::IsPlayer(), VehicleEntry::m_seatID, MAX_VEHICLE_SEATS, Unit::RemoveNpcFlag(), Unit::SetNpcFlag(), sObjectMgr, sVehicleSeatStore, UNIT_NPC_FLAG_PLAYER_VEHICLE, and UNIT_NPC_FLAG_SPELLCLICK.

◆ ~Vehicle()

Vehicle::~Vehicle ( )
overrideprotected

@Uninstall must be called before this.

54{
57
58 for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
59 if (itr->second.Passenger.Guid)
60 {
61 if (Unit* unit = ObjectAccessor::GetUnit(*_me, itr->second.Passenger.Guid))
62 {
63 LOG_FATAL("vehicles", "Vehicle(), unit: {}, entry: {}, typeid: {}, this_entry: {}, this_typeid: {}!", unit->GetName(), unit->GetEntry(), unit->GetTypeId(), _me ? _me->GetEntry() : 0, _me ? _me->GetTypeId() : 0);
64 unit->_ExitVehicle();
65 }
66 else
67 LOG_FATAL("vehicles", "Vehicle(), unknown guid!");
68 }
69}
#define ASSERT
Definition: Errors.h:68
#define LOG_FATAL(filterType__,...)
Definition: Log.h:153
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:199
TypeID GetTypeId() const
Definition: Object.h:127
uint32 GetEntry() const
Definition: Object.h:115
Definition: Unit.h:630

References _me, _status, ASSERT, Object::GetEntry(), Object::GetTypeId(), ObjectAccessor::GetUnit(), LOG_FATAL, and STATUS_UNINSTALLING.

Member Function Documentation

◆ AddPassenger()

bool Vehicle::AddPassenger ( Unit passenger,
int8  seatId = -1 
)

@Prevent adding passengers when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.)

318{
321 {
322 LOG_DEBUG("vehicles", "Passenger {}, attempting to board vehicle {} during uninstall! SeatId: {}",
323 unit->GetGUID().ToString(), _me->GetGUID().ToString(), (int32)seatId);
324 return false;
325 }
326
327 if (unit->GetVehicle() != this)
328 return false;
329
330 SeatMap::iterator seat;
331 if (seatId < 0) // no specific seat requirement
332 {
333 for (seat = Seats.begin(); seat != Seats.end(); ++seat)
334 if (seat->second.IsEmpty() && (seat->second.SeatInfo->CanEnterOrExit() || seat->second.SeatInfo->IsUsableByOverride()))
335 break;
336
337 if (seat == Seats.end()) // no available seat
338 return false;
339 }
340 else
341 {
342 seat = Seats.find(seatId);
343 if (seat == Seats.end())
344 return false;
345
346 if (!seat->second.IsEmpty())
347 {
348 if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger.Guid))
349 passenger->ExitVehicle();
350
351 seat->second.Passenger.Guid.Clear();
352 }
353
354 ASSERT(seat->second.IsEmpty());
355 }
356
357 if (!seat->second.SeatInfo)
358 return false;
359
360 LOG_DEBUG("vehicles", "Unit {} enter vehicle entry {} id {} ({}) seat {}",
361 unit->GetName(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().ToString(), (int32)seat->first);
362
363 seat->second.Passenger.Guid = unit->GetGUID();
364 seat->second.Passenger.IsUnselectable = unit->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
365
366 if (seat->second.SeatInfo->CanEnterOrExit())
367 {
370 if (!_usableSeatNum)
372 else
374 }
375
376 if (!_me || !_me->IsInWorld() || _me->IsDuringRemoveFromWorld())
377 return false;
378
379 // Xinef: moved from unit.cpp, if aura passes seatId == -1 (choose automaticly) we wont get appropriate flags
380 if (unit->IsPlayer() && !(seat->second.SeatInfo->m_flagsB & VEHICLE_SEAT_FLAG_B_KEEP_PET))
381 unit->ToPlayer()->UnsummonPetTemporaryIfAny();
382
383 if (seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE)
384 unit->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
385
386 unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
387 VehicleSeatEntry const* veSeat = seat->second.SeatInfo;
388 VehicleSeatAddon const* veSeatAddon = seat->second.SeatAddon;
389
390 float o = veSeatAddon ? veSeatAddon->SeatOrientationOffset : 0.f;
391 float x = veSeat->m_attachmentOffsetX;
392 float y = veSeat->m_attachmentOffsetY;
393 float z = veSeat->m_attachmentOffsetZ;
394
395 unit->m_movementInfo.transport.pos.Relocate(x, y, z, o);
396 unit->m_movementInfo.transport.time = 0;
397 unit->m_movementInfo.transport.seat = seat->first;
398 unit->m_movementInfo.transport.guid = _me->GetGUID();
399
400 // xinef: removed seat->first == 0 check...
401 if (_me->IsCreature()
402 && unit->IsPlayer()
403 && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
404 {
405 // Removed try catch + ABORT() here, and make it as simple condition check.
407 {
408 // I assume SetCharmedBy should always be true.
409 // If not, let's log some debug info.
410 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). not null: {}", _me ? 1 : 0);
411 if (!_me)
412 return false;
413 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Is: {}!", _me->IsInWorld());
414 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Is2: {}!", _me->IsDuringRemoveFromWorld());
415 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Unit {}!", _me->GetName());
416 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). typeid: {}!", _me->GetTypeId());
417 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Unit {}, typeid: {}, in world: {}, duringremove: {} has wrong CharmType! Charmer {}, typeid: {}, in world: {}, duringremove: {}.", _me->GetName(), _me->GetTypeId(), _me->IsInWorld(), _me->IsDuringRemoveFromWorld(), unit->GetName(), unit->GetTypeId(), unit->IsInWorld(), unit->IsDuringRemoveFromWorld());
418 return false;
419 }
420 }
421
422 if (_me->IsInWorld())
423 {
424 unit->SendClearTarget(); // SMSG_BREAK_TARGET
425 unit->SetControlled(true, UNIT_STATE_ROOT); // SMSG_FORCE_ROOT - In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures)
426 // also adds MOVEMENTFLAG_ROOT
427 Movement::MoveSplineInit init(unit);
428 init.DisableTransportPathTransformations();
429 init.MoveTo(x, y, z, false, true);
430 // Xinef: did not found anything unique in dbc, maybe missed something
431 if (veSeat->m_ID == 3566 || veSeat->m_ID == 3567 || veSeat->m_ID == 3568 || veSeat->m_ID == 3570)
432 {
433 CalculatePassengerPosition(x, y, z, &o);
434 init.SetFacing(_me->GetAngle(x, y));
435 }
436 else
437 {
438 init.SetFacing(o);
439 }
440
441 init.SetTransportEnter();
442 init.Launch();
443
444 if (_me->IsCreature())
445 {
446 if (_me->ToCreature()->IsAIEnabled)
447 _me->ToCreature()->AI()->PassengerBoarded(unit, seat->first, true);
448 }
449 }
450
451 if (GetBase()->IsCreature())
452 sScriptMgr->OnAddPassenger(this, unit, seatId);
453
454 // Remove parachute on vehicle switch
455 unit->RemoveAurasDueToSpell(VEHICLE_SPELL_PARACHUTE);
456 return true;
457}
#define LOG_INFO(filterType__,...)
Definition: Log.h:165
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
std::int32_t int32
Definition: Define.h:103
@ VEHICLE_SEAT_FLAG_CAN_CONTROL
Definition: DBCEnums.h:455
@ VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE
Definition: DBCEnums.h:464
@ VEHICLE_SEAT_FLAG_B_KEEP_PET
Definition: DBCEnums.h:486
@ VEHICLE_SPELL_PARACHUTE
Definition: VehicleDefines.h:53
@ CHARM_TYPE_VEHICLE
Definition: CharmInfo.h:47
@ MOVEMENTFLAG_ONTRANSPORT
Definition: UnitDefines.h:353
@ UNIT_STATE_ROOT
Definition: UnitDefines.h:159
@ UNIT_FLAG_NOT_SELECTABLE
Definition: UnitDefines.h:254
#define sScriptMgr
Definition: ScriptMgr.h:709
virtual void PassengerBoarded(Unit *, int8, bool)
== Fields =======================================
Definition: CreatureAI.h:199
CreatureAI * AI() const
Definition: Creature.h:140
bool IsInWorld() const
Definition: Object.h:107
bool IsCreature() const
Definition: Object.h:204
Creature * ToCreature()
Definition: Object.h:205
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
std::string const & GetName() const
Definition: Object.h:463
std::string ToString() const
Definition: ObjectGuid.cpp:47
float GetAngle(const Position *pos) const
Definition: Position.cpp:78
bool IsDuringRemoveFromWorld() const
Definition: Unit.h:668
bool IsAIEnabled
Definition: Unit.h:1962
bool SetCharmedBy(Unit *charmer, CharmType type, AuraApplication const *aurApp=nullptr)
Definition: Unit.cpp:18350
void ExitVehicle(Position const *exitPosition=nullptr)
Definition: Unit.cpp:19735
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:37
void CalculatePassengerPosition(float &x, float &y, float &z, float *o) const override
This method transforms supplied transport offsets into global coordinates.
Definition: Vehicle.h:78
float SeatOrientationOffset
Definition: VehicleDefines.h:92
Definition: MoveSplineInit.h:71
uint32 m_ID
Definition: DBCStructure.h:2027
float m_attachmentOffsetX
Definition: DBCStructure.h:2067
uint32 m_ID
Definition: DBCStructure.h:2064
float m_attachmentOffsetY
Definition: DBCStructure.h:2068
float m_attachmentOffsetZ
Definition: DBCStructure.h:2069

References _me, _status, _usableSeatNum, _vehicleInfo, Unit::AddUnitMovementFlag(), Creature::AI(), ASSERT, CalculatePassengerPosition(), CHARM_TYPE_VEHICLE, Movement::MoveSplineInit::DisableTransportPathTransformations(), Position::GetAngle(), GetBase(), Object::GetEntry(), Object::GetGUID(), WorldObject::GetName(), Object::GetTypeId(), ObjectAccessor::GetUnit(), Unit::GetVehicle(), MovementInfo::TransportInfo::guid, Unit::HasUnitFlag(), Unit::IsAIEnabled, Object::IsCreature(), Unit::IsDuringRemoveFromWorld(), Object::IsInWorld(), Object::IsPlayer(), Movement::MoveSplineInit::Launch(), LOG_DEBUG, LOG_INFO, VehicleSeatEntry::m_attachmentOffsetX, VehicleSeatEntry::m_attachmentOffsetY, VehicleSeatEntry::m_attachmentOffsetZ, VehicleEntry::m_ID, VehicleSeatEntry::m_ID, WorldObject::m_movementInfo, MOVEMENTFLAG_ONTRANSPORT, Movement::MoveSplineInit::MoveTo(), CreatureAI::PassengerBoarded(), MovementInfo::TransportInfo::pos, Position::Relocate(), Unit::RemoveAurasDueToSpell(), Unit::RemoveNpcFlag(), MovementInfo::TransportInfo::seat, VehicleSeatAddon::SeatOrientationOffset, Unit::SendClearTarget(), Unit::SetCharmedBy(), Unit::SetControlled(), Movement::MoveSplineInit::SetFacing(), Unit::SetNpcFlag(), Movement::MoveSplineInit::SetTransportEnter(), Unit::SetUnitFlag(), sScriptMgr, STATUS_UNINSTALLING, MovementInfo::TransportInfo::time, Object::ToCreature(), Object::ToPlayer(), ObjectGuid::ToString(), MovementInfo::transport, UNIT_FLAG_NOT_SELECTABLE, UNIT_NPC_FLAG_PLAYER_VEHICLE, UNIT_NPC_FLAG_SPELLCLICK, UNIT_STATE_ROOT, Player::UnsummonPetTemporaryIfAny(), VEHICLE_SEAT_FLAG_B_KEEP_PET, VEHICLE_SEAT_FLAG_CAN_CONTROL, VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE, and VEHICLE_SPELL_PARACHUTE.

Referenced by Unit::_EnterVehicle(), and Unit::ChangeSeat().

◆ ApplyAllImmunities()

void Vehicle::ApplyAllImmunities ( )
140{
141 // This couldn't be done in DB, because some spells have MECHANIC_NONE
142
143 // Vehicles should be immune on Knockback ...
144 //_me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_KNOCK_BACK, true);
145 //_me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_KNOCK_BACK_DEST, true);
146
147 // Mechanical units & vehicles ( which are not Bosses, they have own immunities in DB ) should be also immune on healing ( exceptions in switch below )
149 {
150 // Heal & dispel ...
156
157 // ... Shield & Immunity grant spells ...
159 //_me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_UNATTACKABLE, true);
164
165 // ... Resistance, Split damage, Change stats ...
170
171 // Taunt
174 }
175
176 // Different immunities for vehicles goes below
177 switch (GetVehicleInfo()->m_ID)
178 {
179 case 160: //Isle of conquest turret
180 case 244: //Wintergrasp turret
181 case 510: // Isle of Conquest
182 case 452: // Isle of Conquest
183 case 543: // Isle of Conquest
184 //_me->SetControlled(true, UNIT_STATE_ROOT);
185 //me->AddUnitMovementFlag(MOVEMENTFLAG_ROOT);
186 //me->SetSpeed(MOVE_TURN_RATE, 0.7f);
187 //me->SetSpeed(MOVE_PITCH_RATE, 0.7f);
188 //me->m_movementInfo.flags2=59;
190 break;
191 // Ulduar vehicles, remove immunities used in flame leviathan spells
192 case 335:
193 case 336:
194 case 338:
197 break;
198 default:
199 break;
200 }
201}
@ SPELL_EFFECT_HEAL
Definition: SharedDefines.h:788
@ SPELL_EFFECT_HEAL_MAX_HEALTH
Definition: SharedDefines.h:845
@ SPELL_EFFECT_DISPEL
Definition: SharedDefines.h:816
@ SPELL_EFFECT_ATTACK_ME
Definition: SharedDefines.h:892
@ SPELL_EFFECT_HEAL_PCT
Definition: SharedDefines.h:914
@ CREATURE_TYPE_MECHANICAL
Definition: SharedDefines.h:2636
@ MECHANIC_IMMUNE_SHIELD
Definition: SharedDefines.h:1354
@ MECHANIC_SHIELD
Definition: SharedDefines.h:1344
@ IMMUNITY_STATE
Definition: SharedDefines.h:1395
@ IMMUNITY_EFFECT
Definition: SharedDefines.h:1394
@ IMMUNITY_MECHANIC
Definition: SharedDefines.h:1399
@ BATTLEFIELD_WG_ZONEID
Definition: BattlefieldWG.h:115
@ SPELL_AURA_DAMAGE_SHIELD
Definition: SpellAuraDefines.h:78
@ SPELL_AURA_MOD_RESISTANCE
Definition: SpellAuraDefines.h:85
@ SPELL_AURA_PERIODIC_HEAL
Definition: SpellAuraDefines.h:71
@ SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN
Definition: SpellAuraDefines.h:150
@ SPELL_AURA_SPLIT_DAMAGE_PCT
Definition: SpellAuraDefines.h:144
@ SPELL_AURA_MOD_STAT
Definition: SpellAuraDefines.h:92
@ SPELL_AURA_SCHOOL_IMMUNITY
Definition: SpellAuraDefines.h:102
@ SPELL_AURA_MOD_TAUNT
Definition: SpellAuraDefines.h:74
@ SPELL_AURA_MOD_DECREASE_SPEED
Definition: SpellAuraDefines.h:96
@ SPELL_AURA_SCHOOL_ABSORB
Definition: SpellAuraDefines.h:132
bool isWorldBoss() const
Definition: Creature.h:120
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:65
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:205
uint32 type
Definition: CreatureData.h:222
Map * FindMap() const
Definition: Object.h:537
uint32 GetZoneId() const
Definition: Object.cpp:3157
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply, SpellImmuneBlockType blockType=SPELL_BLOCK_TYPE_ALL)
Definition: Unit.cpp:13389
VehicleEntry const * GetVehicleInfo() const
Definition: Vehicle.h:38
bool Instanceable() const
Definition: Map.h:445

References _me, Unit::ApplySpellImmune(), BATTLEFIELD_WG_ZONEID, CREATURE_TYPE_MECHANICAL, WorldObject::FindMap(), Creature::GetCreatureTemplate(), Creature::GetSpawnId(), GetVehicleInfo(), WorldObject::GetZoneId(), IMMUNITY_EFFECT, IMMUNITY_MECHANIC, IMMUNITY_STATE, Map::Instanceable(), Creature::isWorldBoss(), MECHANIC_IMMUNE_SHIELD, MECHANIC_SHIELD, SPELL_AURA_DAMAGE_SHIELD, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, SPELL_AURA_MOD_DECREASE_SPEED, SPELL_AURA_MOD_RESISTANCE, SPELL_AURA_MOD_STAT, SPELL_AURA_MOD_TAUNT, SPELL_AURA_PERIODIC_HEAL, SPELL_AURA_SCHOOL_ABSORB, SPELL_AURA_SCHOOL_IMMUNITY, SPELL_AURA_SPLIT_DAMAGE_PCT, SPELL_EFFECT_ATTACK_ME, SPELL_EFFECT_DISPEL, SPELL_EFFECT_HEAL, SPELL_EFFECT_HEAL_MAX_HEALTH, SPELL_EFFECT_HEAL_PCT, Object::ToCreature(), and CreatureTemplate::type.

Referenced by Reset().

◆ CalculatePassengerOffset()

void Vehicle::CalculatePassengerOffset ( float &  x,
float &  y,
float &  z,
float *  o 
) const
inlineoverrideprivatevirtual

This method transforms supplied global coordinates into local offsets.

Implements TransportBase.

87 {
89 GetBase()->GetPositionX(), GetBase()->GetPositionY(),
90 GetBase()->GetPositionZ(), GetBase()->GetOrientation());
91 }
virtual void CalculatePassengerOffset(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied global coordinates into local offsets.

References TransportBase::CalculatePassengerOffset(), and GetBase().

◆ CalculatePassengerPosition()

void Vehicle::CalculatePassengerPosition ( float &  x,
float &  y,
float &  z,
float *  o 
) const
inlineoverrideprivatevirtual

This method transforms supplied transport offsets into global coordinates.

Implements TransportBase.

79 {
81 GetBase()->GetPositionX(), GetBase()->GetPositionY(),
82 GetBase()->GetPositionZ(), GetBase()->GetOrientation());
83 }
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied transport offsets into global coordinates.

References TransportBase::CalculatePassengerPosition(), and GetBase().

Referenced by AddPassenger(), and RelocatePassengers().

◆ Dismiss()

void Vehicle::Dismiss ( )
539{
540 if (!GetBase()->IsCreature())
541 return;
542
543 LOG_DEBUG("vehicles", "Vehicle::Dismiss {}", _me->GetGUID().ToString());
544 Uninstall();
546}
void DespawnOrUnsummon(Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer)
Definition: Creature.cpp:2178
void Uninstall()
Definition: Vehicle.cpp:100

References _me, Creature::DespawnOrUnsummon(), GetBase(), Object::GetGUID(), LOG_DEBUG, Object::ToCreature(), ObjectGuid::ToString(), and Uninstall().

Referenced by Unit::_ExitVehicle(), BattlefieldWG::OnPlayerLeaveWar(), and Player::UpdateAreaDependentAuras().

◆ EjectPassenger()

void Vehicle::EjectPassenger ( Unit passenger,
Unit controller 
)

◆ GetAvailableSeatCount()

uint8 Vehicle::GetAvailableSeatCount ( ) const
618{
619 uint8 ret = 0;
620 SeatMap::const_iterator itr;
621 for (itr = Seats.begin(); itr != Seats.end(); ++itr)
622 if (itr->second.IsEmpty() && (itr->second.SeatInfo->CanEnterOrExit() || itr->second.SeatInfo->IsUsableByOverride()))
623 ++ret;
624
625 return ret;
626}
std::uint8_t uint8
Definition: Define.h:109

Referenced by Aura::CanStackWith(), and npc_brunnhildar_prisoner::npc_brunnhildar_prisonerAI::SpellHit().

◆ GetBase()

◆ GetCreatureEntry()

uint32 Vehicle::GetCreatureEntry ( ) const
inline

◆ GetNextEmptySeat()

int8 Vehicle::GetNextEmptySeat ( int8  seatId,
bool  next 
) const
246{
247 SeatMap::const_iterator seat = Seats.find(seatId);
248 if (seat == Seats.end())
249 return -1;
250
251 while (!seat->second.IsEmpty() || (!seat->second.SeatInfo->CanEnterOrExit() && !seat->second.SeatInfo->IsUsableByOverride()))
252 {
253 if (next)
254 {
255 ++seat;
256 if (seat == Seats.end())
257 seat = Seats.begin();
258 }
259 else
260 {
261 if (seat == Seats.begin())
262 seat = Seats.end();
263 --seat;
264 }
265
266 if (seat->first == seatId)
267 return -1; // no available seat
268 }
269
270 return seat->first;
271}

Referenced by Unit::ChangeSeat().

◆ GetPassenger()

Unit * Vehicle::GetPassenger ( int8  seatId) const

◆ GetSeatAddonForSeatOfPassenger()

VehicleSeatAddon const * Vehicle::GetSeatAddonForSeatOfPassenger ( Unit const *  passenger) const
237{
238 for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); itr++)
239 if (!itr->second.IsEmpty() && itr->second.Passenger.Guid == passenger->GetGUID())
240 return itr->second.SeatAddon;
241
242 return nullptr;
243}

References Object::GetGUID().

Referenced by Unit::_ExitVehicle().

◆ GetSeatForPassenger()

VehicleSeatEntry const * Vehicle::GetSeatForPassenger ( Unit const *  passenger)
598{
599 SeatMap::iterator itr;
600 for (itr = Seats.begin(); itr != Seats.end(); ++itr)
601 if (itr->second.Passenger.Guid == passenger->GetGUID())
602 return itr->second.SeatInfo;
603
604 return nullptr;
605}

References Object::GetGUID().

Referenced by Spell::CheckCast(), WorldSession::HandleChangeSeatsOnControlledVehicle(), WorldSession::HandleEjectPassenger(), and Player::ProcessTerrainStatusUpdate().

◆ GetSeatIteratorForPassenger()

SeatMap::iterator Vehicle::GetSeatIteratorForPassenger ( Unit passenger)
608{
609 SeatMap::iterator itr;
610 for (itr = Seats.begin(); itr != Seats.end(); ++itr)
611 if (itr->second.Passenger.Guid == passenger->GetGUID())
612 return itr;
613
614 return Seats.end();
615}

References Object::GetGUID().

Referenced by spell_switch_infragreen_bomber_station::HandleDummy(), and RemovePassenger().

◆ GetVehicleInfo()

◆ HasEmptySeat()

bool Vehicle::HasEmptySeat ( int8  seatId) const
220{
221 SeatMap::const_iterator seat = Seats.find(seatId);
222 if (seat == Seats.end())
223 return false;
224 return seat->second.IsEmpty();
225}

Referenced by Unit::ChangeSeat().

◆ InitMovementInfoForBase()

void Vehicle::InitMovementInfoForBase ( )
private
582{
583 uint32 vehicleFlags = GetVehicleInfo()->m_flags;
584
585 if (vehicleFlags & VEHICLE_FLAG_NO_STRAFE)
587 if (vehicleFlags & VEHICLE_FLAG_NO_JUMPING)
589 if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDTURNING)
591 if (vehicleFlags & VEHICLE_FLAG_ALLOW_PITCHING)
593 if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDPITCHING)
595}
@ VEHICLE_FLAG_NO_JUMPING
Definition: VehicleDefines.h:41
@ VEHICLE_FLAG_NO_STRAFE
Definition: VehicleDefines.h:40
@ VEHICLE_FLAG_FULLSPEEDTURNING
Definition: VehicleDefines.h:42
@ VEHICLE_FLAG_ALLOW_PITCHING
Definition: VehicleDefines.h:43
@ VEHICLE_FLAG_FULLSPEEDPITCHING
Definition: VehicleDefines.h:44
@ MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING
Definition: UnitDefines.h:405
@ MOVEMENTFLAG2_NO_STRAFE
Definition: UnitDefines.h:400
@ MOVEMENTFLAG2_FULL_SPEED_PITCHING
Definition: UnitDefines.h:404
@ MOVEMENTFLAG2_FULL_SPEED_TURNING
Definition: UnitDefines.h:403
@ MOVEMENTFLAG2_NO_JUMPING
Definition: UnitDefines.h:401
void AddExtraUnitMovementFlag(uint16 f)
Definition: Unit.h:740
uint32 m_flags
Definition: DBCStructure.h:2028

References _me, Unit::AddExtraUnitMovementFlag(), GetVehicleInfo(), VehicleEntry::m_flags, MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING, MOVEMENTFLAG2_FULL_SPEED_PITCHING, MOVEMENTFLAG2_FULL_SPEED_TURNING, MOVEMENTFLAG2_NO_JUMPING, MOVEMENTFLAG2_NO_STRAFE, VEHICLE_FLAG_ALLOW_PITCHING, VEHICLE_FLAG_FULLSPEEDPITCHING, VEHICLE_FLAG_FULLSPEEDTURNING, VEHICLE_FLAG_NO_JUMPING, and VEHICLE_FLAG_NO_STRAFE.

Referenced by Vehicle().

◆ Install()

void Vehicle::Install ( )
72{
73 if (_me->IsCreature())
74 {
75 if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(_vehicleInfo->m_powerDisplayId))
76 _me->setPowerType(Powers(powerDisplay->PowerType));
79 }
80
82 if (GetBase()->IsCreature())
83 sScriptMgr->OnInstall(this);
84}
Powers
Definition: SharedDefines.h:268
@ POWER_ENERGY
Definition: SharedDefines.h:272
@ CLASS_ROGUE
Definition: SharedDefines.h:144
@ CLASS_CONTEXT_ABILITY
Definition: UnitDefines.h:213
DBCStorage< PowerDisplayEntry > sPowerDisplayStore(PowerDisplayfmt)
virtual bool IsClass(Classes unitClass, ClassContext context=CLASS_CONTEXT_NONE) const
Definition: Unit.h:801
void setPowerType(Powers power)
Definition: Unit.cpp:9979
Definition: DBCStructure.h:1420
uint32 m_powerDisplayId
Definition: DBCStructure.h:2057

References _me, _status, _vehicleInfo, CLASS_CONTEXT_ABILITY, CLASS_ROGUE, GetBase(), Unit::IsClass(), Object::IsCreature(), VehicleEntry::m_powerDisplayId, POWER_ENERGY, Unit::setPowerType(), sPowerDisplayStore, sScriptMgr, and STATUS_INSTALLED.

Referenced by Creature::AddToWorld().

◆ InstallAccessory()

void Vehicle::InstallAccessory ( uint32  entry,
int8  seatId,
bool  minion,
uint8  type,
uint32  summonTime 
)

@Prevent adding accessories when vehicle is uninstalling. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.)

274{
277 {
278 LOG_ERROR("vehicles", "Vehicle {} attempts to install accessory Entry: {} on seat {} with STATUS_UNINSTALLING! "
279 "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUID().ToString(), entry, (int32)seatId);
280 return;
281 }
282
283 LOG_DEBUG("vehicles", "Vehicle: Installing accessory entry {} on vehicle entry {} (seat:{})", entry, GetCreatureEntry(), seatId);
284 if (Unit* passenger = GetPassenger(seatId))
285 {
286 // already installed
287 if (passenger->GetEntry() == entry)
288 {
289 ASSERT(passenger->IsCreature());
290 if (_me->IsCreature())
291 {
292 if (_me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled)
293 passenger->ToCreature()->AI()->EnterEvadeMode();
294 return;
295 }
296 }
297 else
298 passenger->ExitVehicle(); // this should not happen
299 }
300
301 if (TempSummon* accessory = _me->SummonCreature(entry, *_me, TempSummonType(type), summonTime))
302 {
303 if (minion)
304 accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY);
305
306 if (!_me->HandleSpellClick(accessory, seatId))
307 {
308 accessory->UnSummon();
309 return;
310 }
311
312 if (GetBase()->IsCreature())
313 sScriptMgr->OnInstallAccessory(this, accessory);
314 }
315}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
TempSummonType
Definition: Object.h:45
@ UNIT_MASK_ACCESSORY
Definition: UnitDefines.h:144
bool IsInEvadeMode() const
Definition: Creature.h:134
Definition: TemporarySummon.h:40
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
Definition: Object.cpp:2366
bool HandleSpellClick(Unit *clicker, int8 seatId=-1)
Definition: Unit.cpp:19554
Unit * GetPassenger(int8 seatId) const
Definition: Vehicle.cpp:227
uint32 GetCreatureEntry() const
Definition: Vehicle.h:39

References _me, _status, ASSERT, GetBase(), GetCreatureEntry(), Object::GetGUID(), GetPassenger(), Unit::HandleSpellClick(), Object::IsCreature(), Creature::IsInEvadeMode(), LOG_DEBUG, LOG_ERROR, sScriptMgr, STATUS_UNINSTALLING, WorldObject::SummonCreature(), Object::ToCreature(), ObjectGuid::ToString(), and UNIT_MASK_ACCESSORY.

Referenced by InstallAllAccessories().

◆ InstallAllAccessories()

void Vehicle::InstallAllAccessories ( bool  evading)
87{
88 if (GetBase()->IsPlayer() || !evading)
89 RemoveAllPassengers(); // We might have aura's saved in the DB with now invalid casters - remove
90
91 VehicleAccessoryList const* accessories = sObjectMgr->GetVehicleAccessoryList(this);
92 if (!accessories)
93 return;
94
95 for (VehicleAccessoryList::const_iterator itr = accessories->begin(); itr != accessories->end(); ++itr)
96 if (!evading || itr->IsMinion) // only install minions on evade mode
97 InstallAccessory(itr->AccessoryEntry, itr->SeatId, itr->IsMinion, itr->SummonedType, itr->SummonTime);
98}
std::vector< VehicleAccessory > VehicleAccessoryList
Definition: VehicleDefines.h:125
void RemoveAllPassengers()
Definition: Vehicle.cpp:203
void InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime)
Definition: Vehicle.cpp:273

References GetBase(), InstallAccessory(), RemoveAllPassengers(), and sObjectMgr.

Referenced by boss_flame_leviathan_seat::boss_flame_leviathan_seatAI::EnterEvadeMode(), Unit::Mount(), Reset(), and npc_hyldsmeet_protodrake::npc_hyldsmeet_protodrakeAI::UpdateAI().

◆ IsVehicleInUse()

bool Vehicle::IsVehicleInUse ( )
549{
550 for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
551 if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger.Guid))
552 {
553 if (passenger->IsPlayer())
554 return true;
555 else if (passenger->IsCreature() && passenger->GetVehicleKit() && passenger->GetVehicleKit()->IsVehicleInUse())
556 return true;
557 }
558
559 return false;
560}

References GetBase(), and ObjectAccessor::GetUnit().

Referenced by VehicleAI::OnCharmed().

◆ RelocatePassengers()

void Vehicle::RelocatePassengers ( )
514{
515 ASSERT(_me->GetMap());
516
517 std::vector<std::pair<Unit*, Position>> seatRelocation;
518 seatRelocation.reserve(Seats.size());
519
520 // not sure that absolute position calculation is correct, it must depend on vehicle pitch angle
521 for (auto const& itr : Seats)
522 {
523 if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr.second.Passenger.Guid))
524 {
525 ASSERT(passenger->IsInWorld());
526
527 float px, py, pz, po;
528 passenger->m_movementInfo.transport.pos.GetPosition(px, py, pz, po);
529 CalculatePassengerPosition(px, py, pz, &po);
530 seatRelocation.emplace_back(passenger, Position(px, py, pz, po));
531 }
532 }
533
534 for (auto const& pair : seatRelocation)
535 pair.first->UpdatePosition(pair.second);
536}
Map * GetMap() const
Definition: Object.h:536
Definition: Position.h:27

References _me, ASSERT, CalculatePassengerPosition(), GetBase(), WorldObject::GetMap(), and ObjectAccessor::GetUnit().

Referenced by Map::CreatureRelocation(), Map::PlayerRelocation(), Unit::UpdateHeight(), and Unit::UpdateOrientation().

◆ RemoveAllPassengers()

void Vehicle::RemoveAllPassengers ( )
204{
205 LOG_DEBUG("vehicles", "Vehicle::RemoveAllPassengers. {}", _me->GetGUID().ToString());
206
207 // Passengers always cast an aura with SPELL_AURA_CONTROL_VEHICLE on the vehicle
208 // We just remove the aura and the unapply handler will make the target leave the vehicle.
209 // We don't need to iterate over Seats
211
212 // Following the above logic, this assertion should NEVER fail.
213 // Even in 'hacky' cases, there should at least be VEHICLE_SPELL_RIDE_HARDCODED on us.
214 // SeatMap::const_iterator itr;
215 // for (itr = Seats.begin(); itr != Seats.end(); ++itr)
216 // ASSERT(!itr->second.passenger.Guid);
217}
@ SPELL_AURA_CONTROL_VEHICLE
Definition: SpellAuraDefines.h:299
void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID=ObjectGuid::Empty, Aura *except=nullptr, bool negative=true, bool positive=true)
Definition: Unit.cpp:5110

References _me, Object::GetGUID(), LOG_DEBUG, Unit::RemoveAurasByType(), SPELL_AURA_CONTROL_VEHICLE, and ObjectGuid::ToString().

Referenced by InstallAllAccessories(), and Uninstall().

◆ RemovePassenger()

void Vehicle::RemovePassenger ( Unit passenger)
460{
461 if (unit->GetVehicle() != this)
462 return;
463
464 SeatMap::iterator seat = GetSeatIteratorForPassenger(unit);
465 // it can happen that unit enters vehicle and removes owner passenger
466 // then vehicles is dissmised and removes all existing passengers, even the unit (vehicle has aura of unit)
467 // but the unit is not on the vehicles seat yet, thus crashing at ASSERT(seat != Seats.end());
468 // ASSERT(seat != Seats.end());
469 if (seat == Seats.end())
470 {
471 LOG_ERROR("vehicles", "Vehicle::RemovePassenger: Vehicle entry ({}) id ({}) is dissmised and removed all existing passangers, but the unit ({}) was not on the vehicle!",
472 _me->GetEntry(), _vehicleInfo->m_ID, unit->GetName());
473 return;
474 }
475
476 LOG_DEBUG("vehicles", "Unit {} exit vehicle entry {} id {} ({}) seat {}",
477 unit->GetName(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().ToString(), (int32)seat->first);
478
479 if (seat->second.SeatInfo->CanEnterOrExit() && ++_usableSeatNum)
481
482 // Remove UNIT_FLAG_NOT_SELECTABLE if passenger did not have it before entering vehicle
483 if (seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE && !seat->second.Passenger.IsUnselectable)
484 unit->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
485
486 seat->second.Passenger.Reset();
487
488 if (_me->IsCreature() && unit->IsPlayer() && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
489 _me->RemoveCharmedBy(unit);
490
491 if (_me->IsInWorld())
492 {
493 if (!_me->GetTransport())
494 {
495 unit->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
496 unit->m_movementInfo.transport.Reset();
497 }
498 else
499 unit->m_movementInfo.transport = _me->m_movementInfo.transport;
500 }
501
502 // only for flyable vehicles
503 if (_me->IsFlying() && !_me->GetInstanceId() && unit->IsPlayer() && !(unit->ToPlayer()->GetDelayedOperations() & DELAYED_VEHICLE_TELEPORT) && _me->GetEntry() != 30275 /*NPC_WILD_WYRM*/)
505
506 if (_me->IsCreature())
507 sScriptMgr->OnRemovePassenger(this, unit);
508
510 _me->ToCreature()->AI()->PassengerBoarded(unit, seat->first, false);
511}
@ DELAYED_VEHICLE_TELEPORT
Definition: Player.h:914
struct MovementInfo::TransportInfo transport
uint32 GetInstanceId() const
Definition: Object.h:448
Transport * GetTransport() const
Definition: Object.h:604
MovementInfo m_movementInfo
Definition: Object.h:614
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1167
void RemoveCharmedBy(Unit *charmer)
Definition: Unit.cpp:18552
bool IsFlying() const
Definition: Unit.h:1580
SeatMap::iterator GetSeatIteratorForPassenger(Unit *passenger)
Definition: Vehicle.cpp:607

References _me, _usableSeatNum, _vehicleInfo, Creature::AI(), Unit::CastSpell(), DELAYED_VEHICLE_TELEPORT, Player::GetDelayedOperations(), Object::GetEntry(), Object::GetGUID(), WorldObject::GetInstanceId(), WorldObject::GetName(), GetSeatIteratorForPassenger(), WorldObject::GetTransport(), Unit::GetVehicle(), Unit::IsAIEnabled, Object::IsCreature(), Unit::IsFlying(), Object::IsInWorld(), Object::IsPlayer(), LOG_DEBUG, LOG_ERROR, VehicleEntry::m_ID, WorldObject::m_movementInfo, MOVEMENTFLAG_ONTRANSPORT, CreatureAI::PassengerBoarded(), Unit::RemoveCharmedBy(), Unit::RemoveUnitFlag(), Unit::RemoveUnitMovementFlag(), MovementInfo::TransportInfo::Reset(), Unit::SetNpcFlag(), sScriptMgr, Object::ToCreature(), Object::ToPlayer(), ObjectGuid::ToString(), MovementInfo::transport, UNIT_FLAG_NOT_SELECTABLE, UNIT_NPC_FLAG_PLAYER_VEHICLE, UNIT_NPC_FLAG_SPELLCLICK, VEHICLE_SEAT_FLAG_CAN_CONTROL, VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE, and VEHICLE_SPELL_PARACHUTE.

Referenced by Unit::_ExitVehicle(), and Unit::ChangeSeat().

◆ Reset()

void Vehicle::Reset ( bool  evading = false)
120{
121 LOG_DEBUG("vehicles", "Vehicle::Reset: {}", _me->GetGUID().ToString());
122 if (_me->IsPlayer())
123 {
124 if (_usableSeatNum)
126 }
127 else
128 {
130 InstallAllAccessories(evading);
131 if (_usableSeatNum)
133 }
134
135 if (GetBase()->IsCreature())
136 sScriptMgr->OnReset(this);
137}
void ApplyAllImmunities()
Definition: Vehicle.cpp:139
void InstallAllAccessories(bool evading)
Definition: Vehicle.cpp:86

References _me, _usableSeatNum, ApplyAllImmunities(), GetBase(), Object::GetGUID(), InstallAllAccessories(), Object::IsPlayer(), LOG_DEBUG, Unit::SetNpcFlag(), sScriptMgr, ObjectGuid::ToString(), UNIT_NPC_FLAG_PLAYER_VEHICLE, and UNIT_NPC_FLAG_SPELLCLICK.

Referenced by Creature::AIM_Initialize(), CreatureAI::EnterEvadeMode(), Unit::Mount(), and Creature::Update().

◆ TeleportVehicle()

void Vehicle::TeleportVehicle ( float  x,
float  y,
float  z,
float  ang 
)
563{
564 _me->GetMap()->LoadGrid(x, y);
565 _me->NearTeleportTo(x, y, z, ang, true);
566
567 for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
568 if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger.Guid))
569 {
570 if (passenger->IsPlayer())
571 {
572 passenger->ToPlayer()->SetMover(passenger);
573 passenger->NearTeleportTo(x, y, z, ang, false, true);
574 passenger->ToPlayer()->ScheduleDelayedOperation(DELAYED_VEHICLE_TELEPORT);
575 }
576 else if (passenger->IsCreature() && passenger->GetVehicleKit())
577 passenger->GetVehicleKit()->TeleportVehicle(x, y, z, ang);
578 }
579}
void NearTeleportTo(Position &pos, bool casting=false, bool vehicleTeleport=false, bool withPet=false, bool removeTransport=false)
Definition: Unit.cpp:19979
void LoadGrid(float x, float y)
Definition: Map.cpp:495

References _me, DELAYED_VEHICLE_TELEPORT, GetBase(), WorldObject::GetMap(), ObjectAccessor::GetUnit(), Map::LoadGrid(), and Unit::NearTeleportTo().

Referenced by Spell::EffectTeleportUnits().

◆ Uninstall()

void Vehicle::Uninstall ( )

@Prevent recursive uninstall call. (Bad script in OnUninstall/OnRemovePassenger/PassengerBoarded hook.)

101{
103 if (_status == STATUS_UNINSTALLING && !GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
104 {
105 LOG_ERROR("vehicles", "Vehicle {} attempts to uninstall, but already has STATUS_UNINSTALLING! "
106 "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUID().ToString());
107 return;
108 }
110 LOG_DEBUG("vehicles", "Vehicle::Uninstall {}", _me->GetGUID().ToString());
112
113 if (_me && _me->IsCreature())
114 {
115 sScriptMgr->OnUninstall(this);
116 }
117}
@ UNIT_MASK_MINION
Definition: UnitDefines.h:136

References _me, _status, GetBase(), Object::GetGUID(), Object::IsCreature(), LOG_DEBUG, LOG_ERROR, RemoveAllPassengers(), sScriptMgr, STATUS_UNINSTALLING, ObjectGuid::ToString(), and UNIT_MASK_MINION.

Referenced by Unit::_ExitVehicle(), Dismiss(), and Unit::RemoveVehicleKit().

Friends And Related Function Documentation

◆ Unit::CreateVehicleKit

bool Unit::CreateVehicleKit ( uint32  id,
uint32  creatureEntry 
)
friend

◆ Unit::RemoveVehicleKit

void Unit::RemoveVehicleKit ( )
friend

Member Data Documentation

◆ _creatureEntry

uint32 Vehicle::_creatureEntry
private

Referenced by GetCreatureEntry().

◆ _me

◆ _status

Status Vehicle::_status
private

◆ _usableSeatNum

uint32 Vehicle::_usableSeatNum
private

◆ _vehicleInfo

VehicleEntry const* Vehicle::_vehicleInfo
private

◆ Seats