33#include <G3D/Vector3.h>
36 _transportInfo(nullptr), _isMoving(true), _pendingStop(false),
37 _triggeredArrivalEvent(false), _triggeredDepartureEvent(false),
38 _passengerTeleportItr(_passengers.begin()), _delayedAddModel(false), _delayedTeleport(false)
55 TC_LOG_ERROR(
"entities.transport",
"Transport (GUID: {}) not created. Suggested coordinates isn't valid (X: {} Y: {})",
65 TC_LOG_ERROR(
"sql.sql",
"Transport not created: entry in `gameobject_template` not found, guidlow: {} map: {} (X: {} Y: {} Z: {}) ang: {}", guidlow, mapid, x, y, z, ang);
75 TC_LOG_ERROR(
"sql.sql",
"Transport {} (name: {}) will not be created, missing `transport_template` entry.", entry, goinfo->
name);
123 uint32 const positionUpdateDelay = 200;
128 TC_LOG_ERROR(
"entities.transport",
"Could not initialize GameObjectAI for Transport");
137 bool justStopped =
false;
153 if (timer < _currentFrame->DepartureTime)
181 if (timer >=
_currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)
212 G3D::Vector3 pos, dir;
217 else if (justStopped)
271 PassengerSet::iterator itr =
_passengers.find(passenger);
294 plr->SetFallInformation(0, plr->GetPositionZ());
307 if (!creature->
LoadFromDB(guid, map,
false,
false))
343 sScriptMgr->OnAddCreaturePassenger(
this, creature);
414 switch (properties->
Title)
433 if (properties->
Flags & 512)
452 summon =
new TempSummon(properties, summoner,
false);
455 summon =
new Guardian(properties, summoner,
false);
458 summon =
new Puppet(properties, summoner);
461 summon =
new Totem(properties, summoner);
464 summon =
new Minion(properties, summoner,
false);
543 for (
auto const& [cellId, guids] : *cells)
591 float segmentPos, dist;
595 if (timeSinceStop < timeUntilStop)
597 if (timeSinceStop < accelTime)
598 dist = 0.5f * accel * timeSinceStop * timeSinceStop;
600 dist = accelDist + (timeSinceStop - accelTime) * speed;
605 if (timeUntilStop < _transportInfo->accelTime)
606 dist = 0.5f * accel * timeUntilStop * timeUntilStop;
608 dist = accelDist + (timeUntilStop - accelTime) * speed;
619 if (oldMap->
GetId() != newMapid)
634 if (veh->GetTransport() ==
this)
637 float destX, destY, destZ, destO;
638 (*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
641 (*itr)->ToPlayer()->TeleportTo(newMapid, destX, destY, destZ, destO,
670 float destX, destY, destZ, destO;
695 for (PassengerSet::iterator itr = passengers.begin(); itr != passengers.end(); ++itr)
705 if (unit->GetVehicle())
744 if (
Vehicle* vehicle = unit->GetVehicleKit())
745 vehicle->RelocatePassengers();
773 std::stringstream sstr;
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
ScriptMapMap sEventScripts
std::unordered_map< uint32, CellObjectGuids > CellObjectGuidsMap
std::unordered_map< Player *, UpdateData > UpdateDataMapType
@ TELE_TO_TRANSPORT_TELEPORT
@ TELE_TO_NOT_LEAVE_COMBAT
@ TELE_TO_NOT_UNSUMMON_PET
@ TELE_TO_NOT_LEAVE_TRANSPORT
@ GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT
@ SUMMON_CATEGORY_VEHICLE
@ MOVEMENTFLAG_ONTRANSPORT
@ UNIT_STATE_IGNORE_PATHFINDING
@ UPDATEFLAG_STATIONARY_POSITION
void SetHomePosition(float x, float y, float z, float o)
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool allowDuplicate)
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
void SetTransportHomePosition(float x, float y, float z, float o)
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 entry, Position const &pos, CreatureData const *data=nullptr, uint32 vehId=0, bool dynamic=false)
virtual void UpdateAI(uint32)
void SetGoState(GOState state)
GameObjectValue m_goValue
GameObjectTemplate const * GetGOInfo() const
GOState GetGoState() const
std::string GetDebugInfo() const override
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool=true)
void ReplaceAllFlags(GameObjectFlags flags)
void SetGoAnimProgress(uint8 animprogress)
GameObjectAI * AI() const
void SetGoType(GameobjectTypes type)
void SetLocalRotation(float qx, float qy, float qz, float qw)
GameObjectTemplateAddon const * m_goTemplateAddon
GameObjectModel * m_model
void UpdateModelPosition()
void RelocateStationaryPosition(float x, float y, float z, float o)
void SetDisplayId(uint32 displayid)
GameObjectTemplate const * m_goInfo
void CleanupsBeforeDelete(bool finalCleanup=true) override
GameObjectOverride const * GetGameObjectOverride() const
void SetParentRotation(QuaternionData const &rotation)
void EventInform(uint32 eventId, WorldObject *invoker=nullptr)
void SetFaction(uint32 faction) override
void DynamicObjectRelocation(DynamicObject *go, float x, float y, float z, float orientation)
void GameObjectRelocation(GameObject *go, float x, float y, float z, float orientation, bool respawnRelocationOnFail=true)
void CreatureRelocation(Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
void ScriptsStart(std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
Put scripts in the execution queue.
ObjectGuid::LowType GenerateLowGuid()
time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const
void InsertGameObjectModel(GameObjectModel const &model)
bool IsGridLoaded(uint32 gridId) const
void RemoveFromMap(T *, bool)
PlayerList const & GetPlayers() const
void PlayerRelocation(Player *, float x, float y, float z, float orientation)
std::string ToString() const
void BuildFieldsUpdate(Player *, UpdateDataMapType &) const
static Creature * ToCreature(Object *o)
static Unit * ToUnit(Object *o)
static GameObject * ToGameObject(Object *o)
void ClearUpdateMask(bool remove)
void _Create(ObjectGuid const &guid)
static ObjectGuid GetGUID(Object const *o)
void SetEntry(uint32 entry)
virtual void SetObjectScale(float scale)
ObjectGuid GetGUID() const
static DynamicObject * ToDynObject(Object *o)
static Player * ToPlayer(Object *o)
void SetFallInformation(uint32 time, float z)
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0)
bool IsBeingTeleported() const
virtual void InitSummon()
void SetTempSummonType(TempSummonType type)
virtual void InitStats(uint32 lifetime)
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied transport offsets into global coordinates.
void UpdatePosition(float x, float y, float z, float o)
void SetPeriod(uint32 period)
void UpdatePassengerPositions(PassengerSet &passengers)
void LoadStaticPassengers()
Needed when transport moves from inactive to active grid.
bool _triggeredArrivalEvent
These are needed to properly control events triggering only once for each frame.
uint32 GetTransportPeriod() const override
KeyFrameVec::const_iterator _currentFrame
void Update(uint32 diff) override
void BuildUpdate(UpdateDataMapType &data_map) override
void DoEventIfAny(KeyFrame const &node, bool departure)
void EnableMovement(bool enabled)
TempSummon * SummonPassenger(uint32 entry, Position const &pos, TempSummonType summonType, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, Unit *summoner=nullptr, uint32 spellId=0, uint32 vehId=0)
Temporarily summons a creature as passenger on this transport.
float CalculateSegmentPos(float perc)
void RemovePassenger(WorldObject *passenger)
void UnloadStaticPassengers()
Needed when transport enters inactive grid.
std::string GetDebugInfo() const override
PassengerSet _staticPassengers
KeyFrameVec const & GetKeyFrames() const
void DelayedTeleportTransport()
TimeTracker _positionChangeTimer
bool _triggeredDepartureEvent
Creature * CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const *data)
PassengerSet::iterator _passengerTeleportItr
GameObject * CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const *data)
std::set< WorldObject * > PassengerSet
bool Create(ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress)
KeyFrameVec::const_iterator _nextFrame
TransportTemplate const * _transportInfo
void MoveToNextWaypoint()
void AddPassenger(WorldObject *passenger)
void DelayedUpdate(uint32 diff)
bool IsMoving() const
Helpers to know if stop frame was reached.
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const override
This method transforms supplied transport offsets into global coordinates.
bool TeleportTransport(uint32 newMapid, float x, float y, float z, float o)
void CleanupsBeforeDelete(bool finalCleanup=true) override
Unit * GetVehicleBase() const
void SetCreatedBySpell(int32 spellId)
void AddUnitState(uint32 f)
void AddUnitMovementFlag(uint32 f)
uint32 GetPhaseMask() const
void SetTransport(Transport *t)
std::string const & GetName() const
virtual void SetMap(Map *map)
void AddObjectToRemoveList()
void SetName(std::string newname)
MovementInfo m_movementInfo
bool DiffGrid(Cell const &cell) const
struct GameObjectTemplate::@191::@206 moTransport
TaxiPathNodeEntry const * Node
void RemoveMovementFlag(uint32 flag)
struct MovementInfo::TransportInfo transport
void AddMovementFlag(uint32 flag)
float GetPositionZ() const
float GetOrientation() const
bool IsPositionValid() const
float GetPositionX() const
void GetPosition(float &x, float &y) const
float GetPositionY() const
void Relocate(float x, float y)
struct GameObjectValue::@187 Transport