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
 
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 
68 {
72 };
@ STATUS_INSTALLED
Definition: Vehicle.h:70
@ STATUS_UNINSTALLING
Definition: Vehicle.h:71
@ STATUS_NONE
Definition: Vehicle.h:69

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 Seats.insert(std::make_pair(i, VehicleSeat(veSeat)));
38 if (veSeat->CanEnterOrExit())
40 }
41 }
42
43 // Ulduar demolisher
44 if (vehInfo->m_ID == 338)
46
48}
std::uint32_t uint32
Definition: Define.h:107
DBCStorage< VehicleSeatEntry > sVehicleSeatStore(VehicleSeatEntryfmt)
Seats
Definition: boss_flame_leviathan.cpp:167
#define MAX_VEHICLE_SEATS
Definition: DBCStructure.h:2024
uint32 _usableSeatNum
Definition: Vehicle.h:94
void InitMovementInfoForBase()
Definition: Vehicle.cpp:564
uint32 _creatureEntry
Definition: Vehicle.h:95
Status _status
Definition: Vehicle.h:96
Unit * _me
Definition: Vehicle.h:92
VehicleEntry const * _vehicleInfo
Definition: Vehicle.h:93
Definition: VehicleDefines.h:78
uint32 m_seatID[MAX_VEHICLE_SEATS]
Definition: DBCStructure.h:2034
Definition: DBCStructure.h:2064

References _usableSeatNum, _vehicleInfo, InitMovementInfoForBase(), VehicleEntry::m_ID, VehicleEntry::m_seatID, MAX_VEHICLE_SEATS, and sVehicleSeatStore.

◆ ~Vehicle()

Vehicle::~Vehicle ( )
overrideprotected

@Uninstall must be called before this.

51{
54
55 for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
56 if (itr->second.Passenger.Guid)
57 {
58 if (Unit* unit = ObjectAccessor::GetUnit(*_me, itr->second.Passenger.Guid))
59 {
60 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);
61 unit->_ExitVehicle();
62 }
63 else
64 LOG_FATAL("vehicles", "Vehicle(), unknown guid!");
65 }
66}
#define LOG_FATAL(filterType__,...)
Definition: Log.h:152
#define ASSERT
Definition: Errors.h:68
Unit * GetUnit(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:202
TypeID GetTypeId() const
Definition: Object.h:124
uint32 GetEntry() const
Definition: Object.h:112
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.)

306{
309 {
310 LOG_DEBUG("vehicles", "Passenger {}, attempting to board vehicle {} during uninstall! SeatId: {}",
311 unit->GetGUID().ToString(), _me->GetGUID().ToString(), (int32)seatId);
312 return false;
313 }
314
315 if (unit->GetVehicle() != this)
316 return false;
317
318 SeatMap::iterator seat;
319 if (seatId < 0) // no specific seat requirement
320 {
321 for (seat = Seats.begin(); seat != Seats.end(); ++seat)
322 if (seat->second.IsEmpty() && (seat->second.SeatInfo->CanEnterOrExit() || seat->second.SeatInfo->IsUsableByOverride()))
323 break;
324
325 if (seat == Seats.end()) // no available seat
326 return false;
327 }
328 else
329 {
330 seat = Seats.find(seatId);
331 if (seat == Seats.end())
332 return false;
333
334 if (!seat->second.IsEmpty())
335 {
336 if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger.Guid))
337 passenger->ExitVehicle();
338
339 seat->second.Passenger.Guid.Clear();
340 }
341
342 ASSERT(seat->second.IsEmpty());
343 }
344
345 if (!seat->second.SeatInfo)
346 return false;
347
348 LOG_DEBUG("vehicles", "Unit {} enter vehicle entry {} id {} ({}) seat {}",
349 unit->GetName(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().ToString(), (int32)seat->first);
350
351 seat->second.Passenger.Guid = unit->GetGUID();
352 seat->second.Passenger.IsUnselectable = unit->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
353
354 if (seat->second.SeatInfo->CanEnterOrExit())
355 {
358 if (!_usableSeatNum)
359 {
360 if (_me->IsPlayer())
362 else
364 }
365 }
366
367 if (!_me || !_me->IsInWorld() || _me->IsDuringRemoveFromWorld())
368 return false;
369
370 // Xinef: moved from unit.cpp, if aura passes seatId == -1 (choose automaticly) we wont get appropriate flags
371 if (unit->IsPlayer() && !(seat->second.SeatInfo->m_flagsB & VEHICLE_SEAT_FLAG_B_KEEP_PET))
372 unit->ToPlayer()->UnsummonPetTemporaryIfAny();
373
374 if (seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE)
375 unit->SetUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
376
377 unit->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
378 VehicleSeatEntry const* veSeat = seat->second.SeatInfo;
379 unit->m_movementInfo.transport.pos.Relocate(veSeat->m_attachmentOffsetX, veSeat->m_attachmentOffsetY, veSeat->m_attachmentOffsetZ);
380 unit->m_movementInfo.transport.time = 0;
381 unit->m_movementInfo.transport.seat = seat->first;
382 unit->m_movementInfo.transport.guid = _me->GetGUID();
383
384 // xinef: removed seat->first == 0 check...
385 if (_me->IsCreature()
386 && unit->IsPlayer()
387 && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
388 {
389 // Removed try catch + ABORT() here, and make it as simple condition check.
391 {
392 // I assume SetCharmedBy should always be true.
393 // If not, let's log some debug info.
394 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). not null: {}", _me ? 1 : 0);
395 if (!_me)
396 return false;
397 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Is: {}!", _me->IsInWorld());
398 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Is2: {}!", _me->IsDuringRemoveFromWorld());
399 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). Unit {}!", _me->GetName());
400 LOG_INFO("vehicles", "Crash recovered in Unit::SetCharmedBy(). typeid: {}!", _me->GetTypeId());
401 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());
402 return false;
403 }
404 }
405
406 if (_me->IsInWorld())
407 {
408 unit->SendClearTarget(); // SMSG_BREAK_TARGET
409 unit->SetControlled(true, UNIT_STATE_ROOT); // SMSG_FORCE_ROOT - In some cases we send SMSG_SPLINE_MOVE_ROOT here (for creatures)
410 // also adds MOVEMENTFLAG_ROOT
411 Movement::MoveSplineInit init(unit);
412 init.DisableTransportPathTransformations();
413 init.MoveTo(veSeat->m_attachmentOffsetX, veSeat->m_attachmentOffsetY, veSeat->m_attachmentOffsetZ);
414 // Xinef: did not found anything unique in dbc, maybe missed something
415 if (veSeat->m_ID == 3566 || veSeat->m_ID == 3567 || veSeat->m_ID == 3568 || veSeat->m_ID == 3570)
416 {
417 float x = veSeat->m_attachmentOffsetX, y = veSeat->m_attachmentOffsetY, z = veSeat->m_attachmentOffsetZ, o;
418 CalculatePassengerPosition(x, y, z, &o);
419 init.SetFacing(_me->GetAngle(x, y));
420 }
421 else
422 init.SetFacing(0.0f);
423
424 init.SetTransportEnter();
425 init.Launch();
426
427 if (_me->IsCreature())
428 {
429 if (_me->ToCreature()->IsAIEnabled)
430 _me->ToCreature()->AI()->PassengerBoarded(unit, seat->first, true);
431 }
432 }
433
434 if (GetBase()->IsCreature())
435 sScriptMgr->OnAddPassenger(this, unit, seatId);
436
437 // Remove parachute on vehicle switch
438 unit->RemoveAurasDueToSpell(VEHICLE_SPELL_PARACHUTE);
439 return true;
440}
#define LOG_INFO(filterType__,...)
Definition: Log.h:164
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
std::int32_t int32
Definition: Define.h:103
#define sScriptMgr
Definition: ScriptMgr.h:708
@ VEHICLE_SPELL_PARACHUTE
Definition: VehicleDefines.h:53
@ CHARM_TYPE_VEHICLE
Definition: CharmInfo.h:46
@ MOVEMENTFLAG_ONTRANSPORT
Definition: UnitDefines.h:353
@ UNIT_NPC_FLAG_SPELLCLICK
Definition: UnitDefines.h:318
@ UNIT_NPC_FLAG_PLAYER_VEHICLE
Definition: UnitDefines.h:319
@ UNIT_STATE_ROOT
Definition: UnitDefines.h:159
@ UNIT_FLAG_NOT_SELECTABLE
Definition: UnitDefines.h:254
@ 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
virtual void PassengerBoarded(Unit *, int8, bool)
== Fields =======================================
Definition: CreatureAI.h:198
CreatureAI * AI() const
Definition: Creature.h:143
bool IsPlayer() const
Definition: Object.h:197
bool IsInWorld() const
Definition: Object.h:104
bool IsCreature() const
Definition: Object.h:201
Creature * ToCreature()
Definition: Object.h:202
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
std::string const & GetName() const
Definition: Object.h:458
std::string ToString() const
Definition: ObjectGuid.cpp:47
float GetAngle(const Position *pos) const
Definition: Position.cpp:77
void RemoveNpcFlag(NPCFlags flags)
Definition: Unit.h:696
bool IsDuringRemoveFromWorld() const
Definition: Unit.h:1712
bool IsAIEnabled
Definition: Unit.h:1801
bool SetCharmedBy(Unit *charmer, CharmType type, AuraApplication const *aurApp=nullptr)
Definition: Unit.cpp:18306
void ExitVehicle(Position const *exitPosition=nullptr)
Definition: Unit.cpp:19681
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:77
Definition: MoveSplineInit.h:71
uint32 m_ID
Definition: DBCStructure.h:2028
float m_attachmentOffsetX
Definition: DBCStructure.h:2068
uint32 m_ID
Definition: DBCStructure.h:2065
float m_attachmentOffsetY
Definition: DBCStructure.h:2069
float m_attachmentOffsetZ
Definition: DBCStructure.h:2070

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, Unit::SendClearTarget(), Unit::SetCharmedBy(), Unit::SetControlled(), Movement::MoveSplineInit::SetFacing(), 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 ( )
137{
138 // This couldn't be done in DB, because some spells have MECHANIC_NONE
139
140 // Vehicles should be immune on Knockback ...
141 //_me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_KNOCK_BACK, true);
142 //_me->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_KNOCK_BACK_DEST, true);
143
144 // Mechanical units & vehicles ( which are not Bosses, they have own immunities in DB ) should be also immune on healing ( exceptions in switch below )
146 {
147 // Heal & dispel ...
153
154 // ... Shield & Immunity grant spells ...
156 //_me->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_UNATTACKABLE, true);
161
162 // ... Resistance, Split damage, Change stats ...
167
168 // Taunt
171 }
172
173 // Different immunities for vehicles goes below
174 switch (GetVehicleInfo()->m_ID)
175 {
176 case 160: //Isle of conquest turret
177 case 244: //Wintergrasp turret
178 case 510: // Isle of Conquest
179 case 452: // Isle of Conquest
180 case 543: // Isle of Conquest
181 //_me->SetControlled(true, UNIT_STATE_ROOT);
182 //me->AddUnitMovementFlag(MOVEMENTFLAG_ROOT);
183 //me->SetSpeed(MOVE_TURN_RATE, 0.7f);
184 //me->SetSpeed(MOVE_PITCH_RATE, 0.7f);
185 //me->m_movementInfo.flags2=59;
187 break;
188 // Ulduar vehicles, remove immunities used in flame leviathan spells
189 case 335:
190 case 336:
191 case 338:
194 break;
195 default:
196 break;
197 }
198}
@ BATTLEFIELD_WG_ZONEID
Definition: BattlefieldWG.h:117
@ 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
@ 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
bool isWorldBoss() const
Definition: Creature.h:123
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:68
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:206
uint32 type
Definition: CreatureData.h:225
Map * FindMap() const
Definition: Object.h:532
uint32 GetZoneId() const
Definition: Object.cpp:3144
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply, SpellImmuneBlockType blockType=SPELL_BLOCK_TYPE_ALL)
Definition: Unit.cpp:13346
VehicleEntry const * GetVehicleInfo() const
Definition: Vehicle.h:38
bool Instanceable() const
Definition: Map.h:447

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.

86 {
88 GetBase()->GetPositionX(), GetBase()->GetPositionY(),
89 GetBase()->GetPositionZ(), GetBase()->GetOrientation());
90 }
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.

78 {
80 GetBase()->GetPositionX(), GetBase()->GetPositionY(),
81 GetBase()->GetPositionZ(), GetBase()->GetOrientation());
82 }
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 ( )
522{
523 if (!GetBase()->IsCreature())
524 return;
525
526 LOG_DEBUG("vehicles", "Vehicle::Dismiss {}", _me->GetGUID().ToString());
527 Uninstall();
529}
void DespawnOrUnsummon(Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer)
Definition: Creature.cpp:2173
void Uninstall()
Definition: Vehicle.cpp:97

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
601{
602 uint8 ret = 0;
603 SeatMap::const_iterator itr;
604 for (itr = Seats.begin(); itr != Seats.end(); ++itr)
605 if (itr->second.IsEmpty() && (itr->second.SeatInfo->CanEnterOrExit() || itr->second.SeatInfo->IsUsableByOverride()))
606 ++ret;
607
608 return ret;
609}
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
234{
235 SeatMap::const_iterator seat = Seats.find(seatId);
236 if (seat == Seats.end())
237 return -1;
238
239 while (!seat->second.IsEmpty() || (!seat->second.SeatInfo->CanEnterOrExit() && !seat->second.SeatInfo->IsUsableByOverride()))
240 {
241 if (next)
242 {
243 ++seat;
244 if (seat == Seats.end())
245 seat = Seats.begin();
246 }
247 else
248 {
249 if (seat == Seats.begin())
250 seat = Seats.end();
251 --seat;
252 }
253
254 if (seat->first == seatId)
255 return -1; // no available seat
256 }
257
258 return seat->first;
259}

Referenced by Unit::ChangeSeat().

◆ GetPassenger()

Unit * Vehicle::GetPassenger ( int8  seatId) const
225{
226 SeatMap::const_iterator seat = Seats.find(seatId);
227 if (seat == Seats.end())
228 return nullptr;
229
230 return ObjectAccessor::GetUnit(*GetBase(), seat->second.Passenger.Guid);
231}

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

Referenced by boss_xt002::boss_xt002AI::AttachHeart(), Aura::CanStackWith(), spell_demolisher_ride_vehicle::CheckCast(), npc_orb_carrier::npc_orb_carrierAI::DoAction(), boss_skadi_grauf::boss_skadi_graufAI::DoAction(), SmartScript::GetTargets(), spell_switch_infragreen_bomber_station::HandleDummy(), spell_fight_fire_bomber::HandleDummy(), spell_q13280_13283_plant_battle_standard::HandleDummy(), spell_auto_repair::HandleScript(), spell_q12919_gymers_throw::HandleScript(), InstallAccessory(), boss_flame_leviathan_overload_device::boss_flame_leviathan_overload_deviceAI::OnSpellClick(), boss_flame_leviathan_seat::boss_flame_leviathan_seatAI::PassengerBoarded(), boss_skadi_grauf::boss_skadi_graufAI::RemoveSkadi(), Spell::SelectImplicitCasterObjectTargets(), npc_vics_flying_machine::npc_vics_flying_machineAI::SpellHit(), npc_infra_green_bomber_generic::npc_infra_green_bomber_genericAI::SpreadFire(), npc_toc5_player_vehicle::npc_toc5_player_vehicleAI::UpdateAI(), npc_vortex_ride::npc_vortex_rideAI::UpdateAI(), npc_oculus_drake::npc_oculus_drakeAI::UpdateAI(), boss_flame_leviathan::boss_flame_leviathanAI::UpdateAI(), boss_xt002::boss_xt002AI::UpdateAI(), npc_q24545_lich_king::npc_q24545_lich_kingAI::UpdateAI(), and npc_freed_protodrake::npc_freed_protodrakeAI::UpdateAI().

◆ GetSeatForPassenger()

VehicleSeatEntry const * Vehicle::GetSeatForPassenger ( Unit const *  passenger)
581{
582 SeatMap::iterator itr;
583 for (itr = Seats.begin(); itr != Seats.end(); ++itr)
584 if (itr->second.Passenger.Guid == passenger->GetGUID())
585 return itr->second.SeatInfo;
586
587 return nullptr;
588}

References Object::GetGUID().

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

◆ GetSeatIteratorForPassenger()

SeatMap::iterator Vehicle::GetSeatIteratorForPassenger ( Unit passenger)
591{
592 SeatMap::iterator itr;
593 for (itr = Seats.begin(); itr != Seats.end(); ++itr)
594 if (itr->second.Passenger.Guid == passenger->GetGUID())
595 return itr;
596
597 return Seats.end();
598}

References Object::GetGUID().

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

◆ GetVehicleInfo()

◆ HasEmptySeat()

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

Referenced by Unit::ChangeSeat().

◆ InitMovementInfoForBase()

void Vehicle::InitMovementInfoForBase ( )
private
565{
566 uint32 vehicleFlags = GetVehicleInfo()->m_flags;
567
568 if (vehicleFlags & VEHICLE_FLAG_NO_STRAFE)
570 if (vehicleFlags & VEHICLE_FLAG_NO_JUMPING)
572 if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDTURNING)
574 if (vehicleFlags & VEHICLE_FLAG_ALLOW_PITCHING)
576 if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDPITCHING)
578}
@ 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:1617
uint32 m_flags
Definition: DBCStructure.h:2029

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 ( )
69{
70 if (_me->IsCreature())
71 {
72 if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(_vehicleInfo->m_powerDisplayId))
73 _me->setPowerType(Powers(powerDisplay->PowerType));
76 }
77
79 if (GetBase()->IsCreature())
80 sScriptMgr->OnInstall(this);
81}
DBCStorage< PowerDisplayEntry > sPowerDisplayStore(PowerDisplayfmt)
@ CLASS_CONTEXT_ABILITY
Definition: UnitDefines.h:213
Powers
Definition: SharedDefines.h:268
@ POWER_ENERGY
Definition: SharedDefines.h:272
@ CLASS_ROGUE
Definition: SharedDefines.h:144
virtual bool IsClass(Classes unitClass, ClassContext context=CLASS_CONTEXT_NONE) const
Definition: Unit.h:748
void setPowerType(Powers power)
Definition: Unit.cpp:9941
Definition: DBCStructure.h:1421
uint32 m_powerDisplayId
Definition: DBCStructure.h:2058

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.)

262{
265 {
266 LOG_ERROR("vehicles", "Vehicle {} attempts to install accessory Entry: {} on seat {} with STATUS_UNINSTALLING! "
267 "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUID().ToString(), entry, (int32)seatId);
268 return;
269 }
270
271 LOG_DEBUG("vehicles", "Vehicle: Installing accessory entry {} on vehicle entry {} (seat:{})", entry, GetCreatureEntry(), seatId);
272 if (Unit* passenger = GetPassenger(seatId))
273 {
274 // already installed
275 if (passenger->GetEntry() == entry)
276 {
277 ASSERT(passenger->IsCreature());
278 if (_me->IsCreature())
279 {
280 if (_me->ToCreature()->IsInEvadeMode() && passenger->ToCreature()->IsAIEnabled)
281 passenger->ToCreature()->AI()->EnterEvadeMode();
282 return;
283 }
284 }
285 else
286 passenger->ExitVehicle(); // this should not happen
287 }
288
289 if (TempSummon* accessory = _me->SummonCreature(entry, *_me, TempSummonType(type), summonTime))
290 {
291 if (minion)
292 accessory->AddUnitTypeMask(UNIT_MASK_ACCESSORY);
293
294 if (!_me->HandleSpellClick(accessory, seatId))
295 {
296 accessory->UnSummon();
297 return;
298 }
299
300 if (GetBase()->IsCreature())
301 sScriptMgr->OnInstallAccessory(this, accessory);
302 }
303}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
@ UNIT_MASK_ACCESSORY
Definition: UnitDefines.h:144
TempSummonType
Definition: Object.h:44
bool IsInEvadeMode() const
Definition: Creature.h:137
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:2355
bool HandleSpellClick(Unit *clicker, int8 seatId=-1)
Definition: Unit.cpp:19500
Unit * GetPassenger(int8 seatId) const
Definition: Vehicle.cpp:224
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)
84{
85 if (GetBase()->IsPlayer() || !evading)
86 RemoveAllPassengers(); // We might have aura's saved in the DB with now invalid casters - remove
87
88 VehicleAccessoryList const* accessories = sObjectMgr->GetVehicleAccessoryList(this);
89 if (!accessories)
90 return;
91
92 for (VehicleAccessoryList::const_iterator itr = accessories->begin(); itr != accessories->end(); ++itr)
93 if (!evading || itr->IsMinion) // only install minions on evade mode
94 InstallAccessory(itr->AccessoryEntry, itr->SeatId, itr->IsMinion, itr->SummonedType, itr->SummonTime);
95}
#define sObjectMgr
Definition: ObjectMgr.h:1623
std::vector< VehicleAccessory > VehicleAccessoryList
Definition: VehicleDefines.h:101
void RemoveAllPassengers()
Definition: Vehicle.cpp:200
void InstallAccessory(uint32 entry, int8 seatId, bool minion, uint8 type, uint32 summonTime)
Definition: Vehicle.cpp:261

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 ( )
532{
533 for (SeatMap::const_iterator itr = Seats.begin(); itr != Seats.end(); ++itr)
534 if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr->second.Passenger.Guid))
535 {
536 if (passenger->IsPlayer())
537 return true;
538 else if (passenger->IsCreature() && passenger->GetVehicleKit() && passenger->GetVehicleKit()->IsVehicleInUse())
539 return true;
540 }
541
542 return false;
543}

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

Referenced by VehicleAI::OnCharmed().

◆ RelocatePassengers()

void Vehicle::RelocatePassengers ( )
497{
498 ASSERT(_me->GetMap());
499
500 std::vector<std::pair<Unit*, Position>> seatRelocation;
501 seatRelocation.reserve(Seats.size());
502
503 // not sure that absolute position calculation is correct, it must depend on vehicle pitch angle
504 for (auto const& itr : Seats)
505 {
506 if (Unit* passenger = ObjectAccessor::GetUnit(*GetBase(), itr.second.Passenger.Guid))
507 {
508 ASSERT(passenger->IsInWorld());
509
510 float px, py, pz, po;
511 passenger->m_movementInfo.transport.pos.GetPosition(px, py, pz, po);
512 CalculatePassengerPosition(px, py, pz, &po);
513 seatRelocation.emplace_back(passenger, Position(px, py, pz, po));
514 }
515 }
516
517 for (auto const& pair : seatRelocation)
518 pair.first->UpdatePosition(pair.second);
519}
Map * GetMap() const
Definition: Object.h:531
Definition: Position.h:28

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 ( )
201{
202 LOG_DEBUG("vehicles", "Vehicle::RemoveAllPassengers. {}", _me->GetGUID().ToString());
203
204 // Passengers always cast an aura with SPELL_AURA_CONTROL_VEHICLE on the vehicle
205 // We just remove the aura and the unapply handler will make the target leave the vehicle.
206 // We don't need to iterate over Seats
208
209 // Following the above logic, this assertion should NEVER fail.
210 // Even in 'hacky' cases, there should at least be VEHICLE_SPELL_RIDE_HARDCODED on us.
211 // SeatMap::const_iterator itr;
212 // for (itr = Seats.begin(); itr != Seats.end(); ++itr)
213 // ASSERT(!itr->second.passenger.Guid);
214}
@ 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:5081

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)
443{
444 if (unit->GetVehicle() != this)
445 return;
446
447 SeatMap::iterator seat = GetSeatIteratorForPassenger(unit);
448 // it can happen that unit enters vehicle and removes owner passenger
449 // then vehicles is dissmised and removes all existing passengers, even the unit (vehicle has aura of unit)
450 // but the unit is not on the vehicles seat yet, thus crashing at ASSERT(seat != Seats.end());
451 // ASSERT(seat != Seats.end());
452 if (seat == Seats.end())
453 {
454 LOG_ERROR("vehicles", "Vehicle::RemovePassenger: Vehicle entry ({}) id ({}) is dissmised and removed all existing passangers, but the unit ({}) was not on the vehicle!",
455 _me->GetEntry(), _vehicleInfo->m_ID, unit->GetName());
456 return;
457 }
458
459 LOG_DEBUG("vehicles", "Unit {} exit vehicle entry {} id {} ({}) seat {}",
460 unit->GetName(), _me->GetEntry(), _vehicleInfo->m_ID, _me->GetGUID().ToString(), (int32)seat->first);
461
462 if (seat->second.SeatInfo->CanEnterOrExit() && ++_usableSeatNum)
464
465 // Remove UNIT_FLAG_NOT_SELECTABLE if passenger did not have it before entering vehicle
466 if (seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_PASSENGER_NOT_SELECTABLE && !seat->second.Passenger.IsUnselectable)
467 unit->RemoveUnitFlag(UNIT_FLAG_NOT_SELECTABLE);
468
469 seat->second.Passenger.Reset();
470
471 if (_me->IsCreature() && unit->IsPlayer() && seat->second.SeatInfo->m_flags & VEHICLE_SEAT_FLAG_CAN_CONTROL)
472 _me->RemoveCharmedBy(unit);
473
474 if (_me->IsInWorld())
475 {
476 if (!_me->GetTransport())
477 {
478 unit->RemoveUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
479 unit->m_movementInfo.transport.Reset();
480 }
481 else
482 unit->m_movementInfo.transport = _me->m_movementInfo.transport;
483 }
484
485 // only for flyable vehicles
486 if (_me->IsFlying() && !_me->GetInstanceId() && unit->IsPlayer() && !(unit->ToPlayer()->GetDelayedOperations() & DELAYED_VEHICLE_TELEPORT) && _me->GetEntry() != 30275 /*NPC_WILD_WYRM*/)
488
489 if (_me->IsCreature())
490 sScriptMgr->OnRemovePassenger(this, unit);
491
493 _me->ToCreature()->AI()->PassengerBoarded(unit, seat->first, false);
494}
@ DELAYED_VEHICLE_TELEPORT
Definition: Player.h:909
struct MovementInfo::TransportInfo transport
uint32 GetInstanceId() const
Definition: Object.h:443
Transport * GetTransport() const
Definition: Object.h:599
MovementInfo m_movementInfo
Definition: Object.h:609
void SetNpcFlag(NPCFlags flags)
Definition: Unit.h:695
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:1168
void RemoveCharmedBy(Unit *charmer)
Definition: Unit.cpp:18508
bool IsFlying() const
Definition: Unit.h:1701
SeatMap::iterator GetSeatIteratorForPassenger(Unit *passenger)
Definition: Vehicle.cpp:590

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)
117{
118 LOG_DEBUG("vehicles", "Vehicle::Reset: {}", _me->GetGUID().ToString());
119 if (_me->IsPlayer())
120 {
121 if (_usableSeatNum)
123 }
124 else
125 {
127 InstallAllAccessories(evading);
128 if (_usableSeatNum)
130 }
131
132 if (GetBase()->IsCreature())
133 sScriptMgr->OnReset(this);
134}
void ApplyAllImmunities()
Definition: Vehicle.cpp:136
void InstallAllAccessories(bool evading)
Definition: Vehicle.cpp:83

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 
)
546{
547 _me->GetMap()->LoadGrid(x, y);
548 _me->NearTeleportTo(x, y, z, ang, true);
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 {
555 passenger->ToPlayer()->SetMover(passenger);
556 passenger->NearTeleportTo(x, y, z, ang, false, true);
557 passenger->ToPlayer()->ScheduleDelayedOperation(DELAYED_VEHICLE_TELEPORT);
558 }
559 else if (passenger->IsCreature() && passenger->GetVehicleKit())
560 passenger->GetVehicleKit()->TeleportVehicle(x, y, z, ang);
561 }
562}
void NearTeleportTo(Position &pos, bool casting=false, bool vehicleTeleport=false, bool withPet=false, bool removeTransport=false)
Definition: Unit.cpp:19937
void LoadGrid(float x, float y)
Definition: Map.cpp:492

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.)

98{
100 if (_status == STATUS_UNINSTALLING && !GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
101 {
102 LOG_ERROR("vehicles", "Vehicle {} attempts to uninstall, but already has STATUS_UNINSTALLING! "
103 "Check Uninstall/PassengerBoarded script hooks for errors.", _me->GetGUID().ToString());
104 return;
105 }
107 LOG_DEBUG("vehicles", "Vehicle::Uninstall {}", _me->GetGUID().ToString());
109
110 if (_me && _me->IsCreature())
111 {
112 sScriptMgr->OnUninstall(this);
113 }
114}
@ 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