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

#include "Transport.h"

Inheritance diagram for MotionTransport:
Transport GameObject TransportBase WorldObject GridObject< GameObject > MovableMapObject Object WorldLocation Position

Public Member Functions

 ~MotionTransport () override
 
bool CreateMoTrans (ObjectGuid::LowType guidlow, uint32 entry, uint32 mapid, float x, float y, float z, float ang, uint32 animprogress)
 
void CleanupsBeforeDelete (bool finalCleanup=true) override
 
void BuildUpdate (UpdateDataMapType &data_map, UpdatePlayerSet &) override
 
void Update (uint32 diff) override
 
void DelayedUpdate (uint32 diff)
 
void UpdatePosition (float x, float y, float z, float o)
 
void AddPassenger (WorldObject *passenger, bool withAll=false) override
 
void RemovePassenger (WorldObject *passenger, bool withAll=false) override
 
CreatureCreateNPCPassenger (ObjectGuid::LowType guid, CreatureData const *data)
 
GameObjectCreateGOPassenger (ObjectGuid::LowType guid, GameObjectData const *data)
 
void LoadStaticPassengers ()
 
PassengerSet const & GetStaticPassengers () const
 
void UnloadStaticPassengers ()
 
void UnloadNonStaticPassengers ()
 
void SetPassengersLoaded (bool loaded)
 
bool PassengersLoaded () const
 
KeyFrameVec const & GetKeyFrames () const
 
void EnableMovement (bool enabled)
 
TransportTemplate const * GetTransportTemplate () const
 
uint32 GetPeriod () const
 
void SetPeriod (uint32 period)
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Transport
 Transport ()
 
void CalculatePassengerPosition (float &x, float &y, float &z, float *o=nullptr) const override
 This method transforms supplied transport offsets into global coordinates. More...
 
void CalculatePassengerOffset (float &x, float &y, float &z, float *o=nullptr) const override
 This method transforms supplied global coordinates into local offsets. More...
 
virtual void AddPassenger (WorldObject *passenger, bool withAll=false)=0
 
virtual void RemovePassenger (WorldObject *passenger, bool withAll=false)=0
 
PassengerSet const & GetPassengers () const
 
uint32 GetPathProgress () const
 
void SetPathProgress (uint32 val)
 
- Public Member Functions inherited from GameObject
 GameObject ()
 
 ~GameObject () override
 
void BuildValuesUpdate (uint8 updateType, ByteBuffer *data, Player *target) override
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void CleanupsBeforeDelete (bool finalCleanup=true) override
 
uint32 GetDynamicFlags () const override
 
void ReplaceAllDynamicFlags (uint32 flag) override
 
virtual bool Create (ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const &rotation, uint32 animprogress, GOState go_state, uint32 artKit=0)
 
void Update (uint32 p_time) override
 
GameObjectTemplate const * GetGOInfo () const
 
GameObjectTemplateAddon const * GetTemplateAddon () const
 
GameObjectData const * GetGameObjectData () const
 
GameObjectValue const * GetGOValue () const
 
bool IsTransport () const
 
bool IsDestructibleBuilding () const
 
ObjectGuid::LowType GetSpawnId () const
 
void SetLocalRotationAngles (float z_rot, float y_rot, float x_rot)
 
void SetLocalRotation (G3D::Quat const &rot)
 
void SetTransportPathRotation (float qx, float qy, float qz, float qw)
 
G3D::Quat const & GetLocalRotation () const
 
int64 GetPackedLocalRotation () const
 
G3D::Quat GetWorldRotation () const
 
std::string const & GetNameForLocaleIdx (LocaleConstant locale_idx) const override
 
void SaveToDB (bool saveAddon=false)
 
void SaveToDB (uint32 mapid, uint8 spawnMask, uint32 phaseMask, bool saveAddon=false)
 
bool LoadFromDB (ObjectGuid::LowType guid, Map *map)
 
bool LoadGameObjectFromDB (ObjectGuid::LowType guid, Map *map, bool addToMap=true)
 
void DeleteFromDB ()
 
void SetOwnerGUID (ObjectGuid owner)
 
ObjectGuid GetOwnerGUID () const
 
UnitGetOwner () const
 
void SetSpellId (uint32 id)
 
uint32 GetSpellId () const
 
time_t GetRespawnTime () const
 
time_t GetRespawnTimeEx () const
 
void SetRespawnTime (int32 respawn)
 
void SetRespawnDelay (int32 respawn)
 
void Respawn ()
 
bool isSpawned () const
 
bool isSpawnedByDefault () const
 
void SetSpawnedByDefault (bool b)
 
uint32 GetRespawnDelay () const
 
void Refresh ()
 
void DespawnOrUnsummon (Milliseconds delay=0ms, Seconds forcedRespawnTime=0s)
 
void Delete ()
 
void GetFishLoot (Loot *loot, Player *loot_owner)
 
void GetFishLootJunk (Loot *loot, Player *loot_owner)
 
GameobjectTypes GetGoType () const
 
void SetGoType (GameobjectTypes type)
 
GOState GetGoState () const
 
void SetGoState (GOState state)
 
uint8 GetGoArtKit () const
 
void SetGoArtKit (uint8 artkit)
 
uint8 GetGoAnimProgress () const
 
void SetGoAnimProgress (uint8 animprogress)
 
void SetPhaseMask (uint32 newPhaseMask, bool update) override
 
void EnableCollision (bool enable)
 
GameObjectFlags GetGameObjectFlags () const
 
bool HasGameObjectFlag (GameObjectFlags flags) const
 
void SetGameObjectFlag (GameObjectFlags flags)
 
void RemoveGameObjectFlag (GameObjectFlags flags)
 
void ReplaceAllGameObjectFlags (GameObjectFlags flags)
 
void Use (Unit *user)
 
LootState getLootState () const
 
void SetLootState (LootState s, Unit *unit=nullptr)
 
uint16 GetLootMode () const
 
bool HasLootMode (uint16 lootMode) const
 
void SetLootMode (uint16 lootMode)
 
void AddLootMode (uint16 lootMode)
 
void RemoveLootMode (uint16 lootMode)
 
void ResetLootMode ()
 
void AddToSkillupList (ObjectGuid playerGuid)
 
bool IsInSkillupList (ObjectGuid playerGuid) const
 
void AddUniqueUse (Player *player)
 
void AddUse ()
 
uint32 GetUseCount () const
 
uint32 GetUniqueUseCount () const
 
void SaveRespawnTime () override
 
void SaveRespawnTime (uint32 forceDelay)
 
PlayerGetLootRecipient () const
 
GroupGetLootRecipientGroup () const
 
void SetLootRecipient (Creature *creature)
 
void SetLootRecipient (Map *map)
 
bool IsLootAllowedFor (Player const *player) const
 
bool HasLootRecipient () const
 
void SetLootGenerationTime ()
 
uint32 GetLootGenerationTime () const
 
GameObjectGetLinkedTrap ()
 
void SetLinkedTrap (GameObject *linkedTrap)
 
bool hasQuest (uint32 quest_id) const override
 
bool hasInvolvedQuest (uint32 quest_id) const override
 
bool ActivateToQuest (Player *target) const
 
void UseDoorOrButton (uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
 
void ResetDoorOrButton ()
 
void TriggeringLinkedGameObject (uint32 trapEntry, Unit *target)
 
bool IsNeverVisible () const override
 
bool IsAlwaysVisibleFor (WorldObject const *seer) const override
 
bool IsInvisibleDueToDespawn () const override
 
uint8 getLevelForTarget (WorldObject const *target) const override
 
GameObjectLookupFishingHoleAround (float range)
 
void CastSpell (Unit *target, uint32 spell)
 
void SendCustomAnim (uint32 anim)
 
bool IsInRange (float x, float y, float z, float radius) const
 
void ModifyHealth (int32 change, Unit *attackerOrHealer=nullptr, uint32 spellId=0)
 
void SetDestructibleBuildingModifyState (bool allow)
 
void SetDestructibleState (GameObjectDestructibleState state, Player *eventInvoker=nullptr, bool setHealth=false)
 
GameObjectDestructibleState GetDestructibleState () const
 
void EventInform (uint32 eventId)
 
virtual uint32 GetScriptId () const
 
GameObjectAIAI () const
 
std::string const & GetAIName () const
 
void SetDisplayId (uint32 displayid)
 
uint32 GetDisplayId () const
 
void GetRespawnPosition (float &x, float &y, float &z, float *ori=nullptr) const
 
void SetPosition (float x, float y, float z, float o)
 
void SetPosition (const Position &pos)
 
bool IsStaticTransport () const
 
bool IsMotionTransport () const
 
TransportToTransport ()
 
Transport const * ToTransport () const
 
StaticTransportToStaticTransport ()
 
StaticTransport const * ToStaticTransport () const
 
MotionTransportToMotionTransport ()
 
MotionTransport const * ToMotionTransport () const
 
float GetStationaryX () const override
 
float GetStationaryY () const override
 
float GetStationaryZ () const override
 
float GetStationaryO () const override
 
float GetInteractionDistance () const
 
void UpdateModelPosition ()
 
bool IsAtInteractDistance (Position const &pos, float radius) const
 
bool IsAtInteractDistance (Player const *player, SpellInfo const *spell=nullptr) const
 
bool IsWithinDistInMap (Player const *player) const
 
SpellInfo const * GetSpellForLock (Player const *player) const
 
bool ValidateGameobjectType () const
 
bool IsInstanceGameobject () const
 
uint8 GameobjectStateToInt (GOState *state) const
 
bool IsAllowedToSaveToDB () const
 
void AllowSaveToDB (bool enable)
 
void SaveStateToDB ()
 
std::string GetDebugInfo () const override
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
 
- Public Member Functions inherited from WorldObject
 ~WorldObject () override
 
virtual void Update (uint32)
 
void _Create (ObjectGuid::LowType guidlow, HighGuid guidhigh, uint32 phaseMask)
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void GetNearPoint2D (WorldObject const *searcher, float &x, float &y, float distance, float absAngle, Position const *startPos=nullptr) const
 
void GetNearPoint2D (float &x, float &y, float distance, float absAngle, Position const *startPos=nullptr) const
 
void GetNearPoint (WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle, float controlZ=0, Position const *startPos=nullptr) const
 
void GetVoidClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float relAngle=0, float controlZ=0) const
 
bool GetClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float angle=0, WorldObject const *forWho=nullptr, bool force=false) const
 
void MovePosition (Position &pos, float dist, float angle)
 
Position GetNearPosition (float dist, float angle)
 
void MovePositionToFirstCollision (Position &pos, float dist, float angle)
 
Position GetFirstCollisionPosition (float startX, float startY, float startZ, float destX, float destY)
 
Position GetFirstCollisionPosition (float destX, float destY, float destZ)
 
Position GetFirstCollisionPosition (float dist, float angle)
 
Position GetRandomNearPosition (float radius)
 
void GetContactPoint (WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
void GetChargeContactPoint (WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
float GetObjectSize () const
 
virtual float GetCombatReach () const
 
void UpdateGroundPositionZ (float x, float y, float &z) const
 
void UpdateAllowedPositionZ (float x, float y, float &z, float *groundZ=nullptr) const
 
void GetRandomPoint (const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
Position GetRandomPoint (const Position &srcPos, float distance) const
 
uint32 GetInstanceId () const
 
virtual void SetPhaseMask (uint32 newPhaseMask, bool update)
 
uint32 GetPhaseMask () const
 
bool InSamePhase (WorldObject const *obj) const
 
bool InSamePhase (uint32 phasemask) const
 
uint32 GetZoneId () const
 
uint32 GetAreaId () const
 
void GetZoneAndAreaId (uint32 &zoneid, uint32 &areaid) const
 
bool IsOutdoors () const
 
LiquidData const & GetLiquidData () const
 
InstanceScriptGetInstanceScript () const
 
std::string const & GetName () const
 
void SetName (std::string const &newname)
 
virtual std::string const & GetNameForLocaleIdx (LocaleConstant) const
 
float GetDistance (WorldObject const *obj) const
 
float GetDistance (const Position &pos) const
 
float GetDistance (float x, float y, float z) const
 
float GetDistance2d (WorldObject const *obj) const
 
float GetDistance2d (float x, float y) const
 
float GetDistanceZ (WorldObject const *obj) const
 
bool IsSelfOrInSameMap (WorldObject const *obj) const
 
bool IsInMap (WorldObject const *obj) const
 
bool IsWithinDist3d (float x, float y, float z, float dist) const
 
bool IsWithinDist3d (const Position *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (const Position *pos, float dist) const
 
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
 
bool IsWithinLOS (float x, float y, float z, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS) const
 
bool IsWithinLOSInMap (WorldObject const *obj, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
 
Position GetHitSpherePointFor (Position const &dest, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
 
void GetHitSpherePointFor (Position const &dest, float &x, float &y, float &z, Optional< float > collisionHeight={ }, Optional< float > combatReach={ }) const
 
bool GetDistanceOrder (WorldObject const *obj1, WorldObject const *obj2, bool is3D=true) const
 
bool IsInRange (WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
 
bool IsInRange2d (float x, float y, float minRange, float maxRange) const
 
bool IsInRange3d (float x, float y, float z, float minRange, float maxRange) const
 
bool isInFront (WorldObject const *target, float arc=M_PI) const
 
bool isInBack (WorldObject const *target, float arc=M_PI) const
 
bool IsInBetween (WorldObject const *obj1, WorldObject const *obj2, float size=0) const
 
virtual void CleanupsBeforeDelete (bool finalCleanup=true)
 
virtual void SendMessageToSet (WorldPacket const *data, bool self) const
 
virtual void SendMessageToSetInRange (WorldPacket const *data, float dist, bool self) const
 
virtual void SendMessageToSet (WorldPacket const *data, Player const *skipped_rcvr) const
 
virtual uint8 getLevelForTarget (WorldObject const *) const
 
void PlayDistanceSound (uint32 sound_id, Player *target=nullptr)
 
void PlayDirectSound (uint32 sound_id, Player *target=nullptr)
 
void PlayRadiusSound (uint32 sound_id, float radius)
 
void PlayDirectMusic (uint32 music_id, Player *target=nullptr)
 
void PlayRadiusMusic (uint32 music_id, float radius)
 
void SendObjectDeSpawnAnim (ObjectGuid guid)
 
virtual void SaveRespawnTime ()
 
void AddObjectToRemoveList ()
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
virtual float GetSightRange (WorldObject const *target=nullptr) const
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
void SendPlayMusic (uint32 Music, bool OnlySelf)
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
void SetZoneScript ()
 
void ClearZoneScript ()
 
ZoneScriptGetZoneScript () const
 
TempSummonSummonCreature (uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
 
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang=0, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport=true, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
 
CreatureSummonTrigger (float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=nullptr)
 
CreatureFindNearestCreature (uint32 entry, float range, bool alive=true) const
 
GameObjectFindNearestGameObject (uint32 entry, float range, bool onlySpawned=false) const
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
PlayerSelectNearestPlayer (float distance=0) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetDeadCreatureListInGrid (std::list< Creature * > &lList, float maxSearchRange, bool alive=false) const
 
void DestroyForNearbyPlayers ()
 
virtual void UpdateObjectVisibility (bool forced=true, bool fromUpdate=false)
 
void BuildUpdate (UpdateDataMapType &data_map, UpdatePlayerSet &player_set) override
 
void GetCreaturesWithEntryInRange (std::list< Creature * > &creatureList, float radius, uint32 entry)
 
void SetPositionDataUpdate ()
 
void UpdatePositionData ()
 
void AddToObjectUpdate () override
 
void RemoveFromObjectUpdate () override
 
void AddToNotify (uint16 f)
 
void RemoveFromNotify (uint16 f)
 
bool isNeedNotify (uint16 f) const
 
uint16 GetNotifyFlags () const
 
bool NotifyExecuted (uint16 f) const
 
void SetNotified (uint16 f)
 
void ResetAllNotifies ()
 
bool isActiveObject () const
 
void setActive (bool isActiveObject)
 
bool IsFarVisible () const
 
bool IsVisibilityOverridden () const
 
void SetVisibilityDistanceOverride (VisibilityDistanceType type)
 
void SetWorldObject (bool apply)
 
bool IsPermanentWorldObject () const
 
bool IsWorldObject () const
 
bool IsInWintergrasp () const
 
TransportGetTransport () const
 
float GetTransOffsetX () const
 
float GetTransOffsetY () const
 
float GetTransOffsetZ () const
 
float GetTransOffsetO () const
 
uint32 GetTransTime () const
 
int8 GetTransSeat () const
 
virtual ObjectGuid GetTransGUID () const
 
void SetTransport (Transport *t)
 
virtual float GetStationaryX () const
 
virtual float GetStationaryY () const
 
virtual float GetStationaryZ () const
 
virtual float GetStationaryO () const
 
float GetMapWaterOrGroundLevel (float x, float y, float z, float *ground=nullptr) const
 
float GetMapHeight (float x, float y, float z, bool vmap=true, float distanceToSearch=50.0f) const
 
float GetFloorZ () const
 
float GetMinHeightInWater () const
 Get the minimum height of a object that should be in water to start floating/swim. More...
 
virtual float GetCollisionHeight () const
 
virtual float GetCollisionWidth () const
 
virtual float GetCollisionRadius () const
 
void AddAllowedLooter (ObjectGuid guid)
 
void ResetAllowedLooters ()
 
void SetAllowedLooters (GuidUnorderedSet const looters)
 
bool HasAllowedLooter (ObjectGuid guid) const
 
GuidUnorderedSet const & GetAllowedLooters () const
 
void RemoveAllowedLooter (ObjectGuid guid)
 
std::string GetDebugInfo () const override
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
bool IsInWorld () const
 
virtual void AddToWorld ()
 
virtual void RemoveFromWorld ()
 
ObjectGuid GetGUID () const
 
PackedGuid const & GetPackGUID () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
virtual void SetObjectScale (float scale)
 
virtual uint32 GetDynamicFlags () const
 
bool HasDynamicFlag (uint32 flag) const
 
virtual void SetDynamicFlag (uint32 flag)
 
virtual void RemoveDynamicFlag (uint32 flag)
 
virtual void ReplaceAllDynamicFlags (uint32 flag)
 
TypeID GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target)
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target)
 
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
 
void BuildMovementUpdateBlock (UpdateData *data, uint32 flags=0) const
 
virtual void DestroyForPlayer (Player *target, bool onDeath=false) const
 
int32 GetInt32Value (uint16 index) const
 
uint32 GetUInt32Value (uint16 index) const
 
uint64 GetUInt64Value (uint16 index) const
 
float GetFloatValue (uint16 index) const
 
uint8 GetByteValue (uint16 index, uint8 offset) const
 
uint16 GetUInt16Value (uint16 index, uint8 offset) const
 
ObjectGuid GetGuidValue (uint16 index) const
 
void SetInt32Value (uint16 index, int32 value)
 
void SetUInt32Value (uint16 index, uint32 value)
 
void UpdateUInt32Value (uint16 index, uint32 value)
 
void SetUInt64Value (uint16 index, uint64 value)
 
void SetFloatValue (uint16 index, float value)
 
void SetByteValue (uint16 index, uint8 offset, uint8 value)
 
void SetUInt16Value (uint16 index, uint8 offset, uint16 value)
 
void SetInt16Value (uint16 index, uint8 offset, int16 value)
 
void SetGuidValue (uint16 index, ObjectGuid value)
 
void SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddGuidValue (uint16 index, ObjectGuid value)
 
bool RemoveGuidValue (uint16 index, ObjectGuid value)
 
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModUInt64Value (uint16 index, int32 val, bool apply)
 
void ApplyModPositiveFloatValue (uint16 index, float val, bool apply)
 
void ApplyModSignedFloatValue (uint16 index, float val, bool apply)
 
void ApplyPercentModFloatValue (uint16 index, float val, bool apply)
 
void SetFlag (uint16 index, uint32 newFlag)
 
void RemoveFlag (uint16 index, uint32 oldFlag)
 
void ToggleFlag (uint16 index, uint32 flag)
 
bool HasFlag (uint16 index, uint32 flag) const
 
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void SetFlag64 (uint16 index, uint64 newFlag)
 
void RemoveFlag64 (uint16 index, uint64 oldFlag)
 
void ToggleFlag64 (uint16 index, uint64 flag)
 
bool HasFlag64 (uint16 index, uint64 flag) const
 
void ApplyModFlag64 (uint16 index, uint64 flag, bool apply)
 
void ClearUpdateMask (bool remove)
 
uint16 GetValuesCount () const
 
virtual bool hasQuest (uint32) const
 
virtual bool hasInvolvedQuest (uint32) const
 
virtual void BuildUpdate (UpdateDataMapType &, UpdatePlayerSet &)
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &)
 
void SetFieldNotifyFlag (uint16 flag)
 
void RemoveFieldNotifyFlag (uint16 flag)
 
void ForceValuesUpdateAtIndex (uint32)
 
bool IsPlayer () const
 
PlayerToPlayer ()
 
Player const * ToPlayer () const
 
bool IsCreature () const
 
CreatureToCreature ()
 
Creature const * ToCreature () const
 
bool IsUnit () const
 
UnitToUnit ()
 
Unit const * ToUnit () const
 
bool IsGameObject () const
 
GameObjectToGameObject ()
 
GameObject const * ToGameObject () const
 
bool IsCorpse () const
 
CorpseToCorpse ()
 
Corpse const * ToCorpse () const
 
bool IsDynamicObject () const
 
DynamicObjectToDynObject ()
 
DynamicObject const * ToDynObject () const
 
bool IsItem () const
 
virtual std::string GetDebugInfo () const
 
- Public Member Functions inherited from WorldLocation
 WorldLocation (uint32 _mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
 WorldLocation (uint32 mapId, Position const &position)
 
void WorldRelocate (const WorldLocation &loc)
 
void WorldRelocate (uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
void SetMapId (uint32 mapId)
 
uint32 GetMapId () const
 
void GetWorldLocation (uint32 &mapId, float &x, float &y) const
 
void GetWorldLocation (uint32 &mapId, float &x, float &y, float &z) const
 
void GetWorldLocation (uint32 &mapId, float &x, float &y, float &z, float &o) const
 
void GetWorldLocation (WorldLocation *location) const
 
WorldLocation GetWorldLocation () const
 
std::string GetDebugInfo () const
 
- Public Member Functions inherited from Position
 Position (float x=0, float y=0, float z=0, float o=0)
 
 Position (Position const &loc)
 
 Position (Position &&)=default
 
Positionoperator= (const Position &)=default
 
Positionoperator= (Position &&)=default
 
bool operator== (Position const &a) const
 
bool operator!= (Position const &a)
 
 operator G3D::Vector3 () const
 
void Relocate (float x, float y)
 
void Relocate (float x, float y, float z)
 
void Relocate (float x, float y, float z, float orientation)
 
void Relocate (const Position &pos)
 
void Relocate (const Position *pos)
 
void RelocatePolarOffset (float angle, float dist, float z=0.0f)
 
void RelocateOffset (const Position &offset)
 
void SetOrientation (float orientation)
 
float GetPositionX () const
 
float GetPositionY () const
 
float GetPositionZ () const
 
float GetOrientation () const
 
void GetPosition (float &x, float &y) const
 
void GetPosition (float &x, float &y, float &z) const
 
void GetPosition (float &x, float &y, float &z, float &o) const
 
Position GetPosition () const
 
Position::PositionXYZStreamer PositionXYZStream ()
 
Position::PositionXYZOStreamer PositionXYZOStream ()
 
bool IsPositionValid () const
 
float GetExactDist2dSq (const float x, const float y) const
 
float GetExactDist2dSq (Position const &pos) const
 
float GetExactDist2dSq (Position const *pos) const
 
float GetExactDist2d (const float x, const float y) const
 
float GetExactDist2d (Position const &pos) const
 
float GetExactDist2d (Position const *pos) const
 
float GetExactDistSq (float x, float y, float z) const
 
float GetExactDistSq (Position const &pos) const
 
float GetExactDistSq (Position const *pos) const
 
float GetExactDist (float x, float y, float z) const
 
float GetExactDist (Position const &pos) const
 
float GetExactDist (Position const *pos) const
 
void GetPositionOffsetTo (const Position &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (const Position *pos) const
 
float GetAngle (float x, float y) const
 
float GetAbsoluteAngle (float x, float y) const
 
float GetAbsoluteAngle (Position const &pos) const
 
float GetAbsoluteAngle (Position const *pos) const
 
float GetRelativeAngle (const Position *pos) const
 
float GetRelativeAngle (float x, float y) const
 
float ToAbsoluteAngle (float relAngle) const
 
void GetSinCos (float x, float y, float &vsin, float &vcos) const
 
bool IsInDist2d (float x, float y, float dist) const
 
bool IsInDist2d (const Position *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (const Position *pos, float dist) const
 
bool IsWithinBox (const Position &center, float xradius, float yradius, float zradius) const
 
bool HasInArc (float arcangle, const Position *pos, float targetRadius=0.0f) const
 
bool HasInLine (Position const *pos, float width) const
 
std::string ToString () const
 
- Public Member Functions inherited from GridObject< GameObject >
bool IsInGrid () const
 
void AddToGrid (GridRefMgr< GameObject > &m)
 
void RemoveFromGrid ()
 
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...
 

Private Member Functions

 MotionTransport ()
 
void MoveToNextWaypoint ()
 
float CalculateSegmentPos (float perc)
 
bool TeleportTransport (uint32 newMapid, float x, float y, float z, float o)
 
void DelayedTeleportTransport ()
 
void UpdatePassengerPositions (PassengerSet &passengers)
 
void DoEventIfAny (KeyFrame const &node, bool departure)
 
bool IsMoving () const
 Helpers to know if stop frame was reached. More...
 
void SetMoving (bool val)
 

Private Attributes

TransportTemplate const * _transportInfo
 
KeyFrameVec::const_iterator _currentFrame
 
KeyFrameVec::const_iterator _nextFrame
 
TimeTrackerSmall _positionChangeTimer
 
bool _isMoving
 
bool _pendingStop
 
bool _triggeredArrivalEvent
 These are needed to properly control events triggering only once for each frame. More...
 
bool _triggeredDepartureEvent
 
PassengerSet _staticPassengers
 
std::mutex Lock
 
bool _passengersLoaded
 
bool _delayedTeleport
 

Friends

MotionTransportTransportMgr::CreateTransport (uint32, ObjectGuid::LowType, Map *)
 

Additional Inherited Members

- Public Types inherited from Transport
typedef std::set< WorldObject * > PassengerSet
 
- Static Public Member Functions inherited from GameObject
static void SetGoArtKit (uint8 artkit, GameObject *go, ObjectGuid::LowType lowguid=0)
 
- Static Public Member Functions inherited from Object
static ObjectGuid GetGUID (Object const *o)
 
- Static Public Member Functions inherited from Position
static float NormalizeOrientation (float o)
 
- Public Attributes inherited from GameObject
Loot loot
 
uint32 m_groupLootTimer
 
uint32 lootingGroupLowGUID
 
GameObjectModelm_model
 
- Public Attributes inherited from WorldObject
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealth
 
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealthDetect
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibility
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibilityDetect
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibility
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibilityDetect
 
uint32 LastUsedScriptID
 
MovementInfo m_movementInfo
 
ElunaEventProcessor * elunaEvents
 
- Public Attributes inherited from Object
DataMap CustomData
 
- Public Attributes inherited from WorldLocation
uint32 m_mapId
 
- Public Attributes inherited from Position
float m_positionX = 0
 
float m_positionY = 0
 
float m_positionZ = 0
 
float m_orientation = 0
 
- Static Public Attributes inherited from GameObject
static std::unordered_map< int, goEventFlaggameObjectToEventFlag = { }
 
- Protected Types inherited from GameObject
typedef std::map< uint32, ObjectGuidChairSlotAndUser
 
- Protected Member Functions inherited from GameObject
bool AIM_Initialize ()
 
GameObjectModelCreateModel ()
 
void UpdateModel ()
 
- Protected Member Functions inherited from WorldObject
 WorldObject (bool isWorldObject)
 
virtual void ProcessPositionDataChanged (PositionFullTerrainStatus const &data)
 
void SetLocationMapId (uint32 _mapId)
 
void SetLocationInstanceId (uint32 _instanceId)
 
virtual bool IsNeverVisible () const
 
virtual bool IsAlwaysVisibleFor (WorldObject const *) const
 
virtual bool IsInvisibleDueToDespawn () const
 
virtual bool IsAlwaysDetectableFor (WorldObject const *) const
 
- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
 
std::string _ConcatFields (uint16 startIndex, uint16 size) const
 
bool _LoadIntoDataField (std::string const &data, uint32 startOffset, uint32 count)
 
uint32 GetUpdateFieldData (Player const *target, uint32 *&flags) const
 
void BuildMovementUpdate (ByteBuffer *data, uint16 flags) const
 
virtual void BuildValuesUpdate (uint8 updateType, ByteBuffer *data, Player *target)
 
virtual void AddToObjectUpdate ()=0
 
virtual void RemoveFromObjectUpdate ()=0
 
void AddToObjectUpdateIfNeeded ()
 
- Protected Member Functions inherited from MovableMapObject
 MovableMapObject ()=default
 
- Protected Member Functions inherited from TransportBase
 TransportBase ()=default
 
virtual ~TransportBase ()=default
 
- 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)
 
- Protected Attributes inherited from Transport
PassengerSet _passengers
 
- Protected Attributes inherited from GameObject
uint32 m_spellId
 
time_t m_respawnTime
 
uint32 m_respawnDelayTime
 
uint32 m_despawnDelay
 
Seconds m_despawnRespawnTime
 
Seconds m_restockTime
 
LootState m_lootState
 
bool m_spawnedByDefault
 
uint32 m_cooldownTime
 
std::unordered_map< ObjectGuid, int32m_SkillupList
 
ObjectGuid m_ritualOwnerGUID
 
GuidSet m_unique_users
 
uint32 m_usetimes
 
ChairSlotAndUser ChairListSlots
 
ObjectGuid::LowType m_spawnId
 For new or temporary gameobjects is 0 for saved it is lowguid. More...
 
GameObjectTemplate const * m_goInfo
 
GameObjectData const * m_goData
 
GameObjectValue m_goValue
 
bool m_allowModifyDestructibleBuilding
 
int64 m_packedRotation
 
G3D::Quat m_localRotation
 
Position m_stationaryPosition
 
ObjectGuid m_lootRecipient
 
ObjectGuid::LowType m_lootRecipientGroup
 
uint16 m_LootMode
 
uint32 m_lootGenerationTime
 
ObjectGuid m_linkedTrap
 
ObjectGuid _lootStateUnitGUID
 
- Protected Attributes inherited from WorldObject
std::string m_name
 
bool m_isActive
 
bool m_isFarVisible
 
Optional< float > m_visibilityDistanceOverride
 
const bool m_isWorldObject
 
ZoneScriptm_zoneScript
 
uint32 _zoneId
 
uint32 _areaId
 
float _floorZ
 
bool _outdoors
 
LiquidData _liquidData
 
bool _updatePositionData
 
Transportm_transport
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
TypeID m_objectTypeId
 
uint16 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
UpdateMask _changesMask
 
uint16 m_valuesCount
 
uint16 _fieldNotifyFlags
 
bool m_objectUpdated
 

Detailed Description

Constructor & Destructor Documentation

◆ MotionTransport()

MotionTransport::MotionTransport ( )
private
35{
37}
@ UPDATEFLAG_ROTATION
Definition: UpdateData.h:48
@ UPDATEFLAG_LOWGUID
Definition: UpdateData.h:43
@ UPDATEFLAG_TRANSPORT
Definition: UpdateData.h:40
@ UPDATEFLAG_STATIONARY_POSITION
Definition: UpdateData.h:45
uint16 m_updateFlag
Definition: Object.h:243
Transport()
Definition: Transport.h:31
bool _triggeredArrivalEvent
These are needed to properly control events triggering only once for each frame.
Definition: Transport.h:102
bool _delayedTeleport
Definition: Transport.h:108
bool _isMoving
Definition: Transport.h:98
bool _pendingStop
Definition: Transport.h:99
TransportTemplate const * _transportInfo
Definition: Transport.h:94
bool _passengersLoaded
Definition: Transport.h:107
bool _triggeredDepartureEvent
Definition: Transport.h:103

References Object::m_updateFlag, UPDATEFLAG_LOWGUID, UPDATEFLAG_ROTATION, UPDATEFLAG_STATIONARY_POSITION, and UPDATEFLAG_TRANSPORT.

◆ ~MotionTransport()

MotionTransport::~MotionTransport ( )
override
40{
42
43 ASSERT(_passengers.empty());
45}
#define ASSERT
Definition: Errors.h:68
PassengerSet _passengers
Definition: Transport.h:44
void UnloadStaticPassengers()
Definition: Transport.cpp:431
static void Remove(T *o)
Definition: ObjectAccessor.cpp:48

References Transport::_passengers, ASSERT, HashMapHolder< T >::Remove(), and UnloadStaticPassengers().

Member Function Documentation

◆ AddPassenger()

void MotionTransport::AddPassenger ( WorldObject passenger,
bool  withAll = false 
)
overridevirtual

Implements Transport.

265{
266 std::lock_guard<std::mutex> guard(Lock);
267 if (_passengers.insert(passenger).second)
268 {
269 if (Player* plr = passenger->ToPlayer())
270 sScriptMgr->OnAddPassenger(ToTransport(), plr);
271
272 if (withAll)
273 {
274 if (Transport* t = passenger->GetTransport()) // SHOULD NEVER HAPPEN
275 t->RemovePassenger(passenger, false);
276
277 float x, y, z, o;
278 passenger->GetPosition(x, y, z, o);
279 CalculatePassengerOffset(x, y, z, &o);
280
281 passenger->SetTransport(this);
283 passenger->m_movementInfo.transport.guid = GetGUID();
284 passenger->m_movementInfo.transport.pos.Relocate(x, y, z, o);
285 if (passenger->ToUnit())
286 {
288 }
289 }
290 }
291}
#define sScriptMgr
Definition: ScriptMgr.h:708
@ MOVEMENTFLAG_ONTRANSPORT
Definition: UnitDefines.h:353
@ UNIT_STATE_IGNORE_PATHFINDING
Definition: UnitDefines.h:176
Transport * ToTransport()
Definition: GameObject.h:322
Player * ToPlayer()
Definition: Object.h:198
ObjectGuid GetGUID() const
Definition: Object.h:110
Unit * ToUnit()
Definition: Object.h:206
uint32 flags
Definition: Object.h:279
struct MovementInfo::TransportInfo transport
ObjectGuid guid
Definition: Object.h:296
Position pos
Definition: Object.h:297
void SetTransport(Transport *t)
Definition: Object.h:607
Transport * GetTransport() const
Definition: Object.h:599
MovementInfo m_movementInfo
Definition: Object.h:609
void GetPosition(float &x, float &y) const
Definition: Position.h:122
void Relocate(float x, float y)
Definition: Position.h:73
Definition: Player.h:1064
Definition: Transport.h:29
void CalculatePassengerOffset(float &x, float &y, float &z, float *o=nullptr) const override
This method transforms supplied global coordinates into local offsets.
Definition: Transport.h:33
std::mutex Lock
Definition: Transport.h:106
void AddUnitState(uint32 f)
Definition: Unit.h:672

References Transport::_passengers, Unit::AddUnitState(), Transport::CalculatePassengerOffset(), MovementInfo::flags, Object::GetGUID(), Position::GetPosition(), WorldObject::GetTransport(), MovementInfo::TransportInfo::guid, Lock, WorldObject::m_movementInfo, MOVEMENTFLAG_ONTRANSPORT, MovementInfo::TransportInfo::pos, Position::Relocate(), WorldObject::SetTransport(), sScriptMgr, Object::ToPlayer(), GameObject::ToTransport(), Object::ToUnit(), MovementInfo::transport, and UNIT_STATE_IGNORE_PATHFINDING.

Referenced by Battleground::AddCreature(), and PassengerController::SummonCreatures().

◆ BuildUpdate()

void MotionTransport::BuildUpdate ( UpdateDataMapType data_map,
UpdatePlayerSet  
)
overridevirtual

Reimplemented from WorldObject.

127{
128 Map::PlayerList const& players = GetMap()->GetPlayers();
129 if (players.IsEmpty())
130 return;
131
132 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
133 BuildFieldsUpdate(itr->GetSource(), data_map);
134
135 ClearUpdateMask(true);
136}
bool IsEmpty() const
Definition: LinkedList.h:97
Definition: LinkedList.h:139
void BuildFieldsUpdate(Player *, UpdateDataMapType &)
Definition: Object.cpp:545
void ClearUpdateMask(bool remove)
Definition: Object.cpp:533
Map * GetMap() const
Definition: Object.h:531
PlayerList const & GetPlayers() const
Definition: Map.h:486
Definition: MapRefMgr.h:26
iterator begin()
Definition: MapRefMgr.h:36
iterator end()
Definition: MapRefMgr.h:37

References MapRefMgr::begin(), Object::BuildFieldsUpdate(), Object::ClearUpdateMask(), MapRefMgr::end(), WorldObject::GetMap(), Map::GetPlayers(), and LinkedListHead::IsEmpty().

◆ CalculateSegmentPos()

float MotionTransport::CalculateSegmentPos ( float  perc)
private
476{
477 KeyFrame const& frame = *_currentFrame;
478 const float speed = float(m_goInfo->moTransport.moveSpeed);
479 const float accel = float(m_goInfo->moTransport.accelRate);
480 float timeSinceStop = frame.TimeFrom + (now - (1.0f / IN_MILLISECONDS) * frame.DepartureTime);
481 float timeUntilStop = frame.TimeTo - (now - (1.0f / IN_MILLISECONDS) * frame.DepartureTime);
482 float segmentPos, dist;
483 float accelTime = _transportInfo->accelTime;
484 float accelDist = _transportInfo->accelDist;
485 // calculate from nearest stop, less confusing calculation...
486 if (timeSinceStop < timeUntilStop)
487 {
488 if (timeSinceStop < accelTime)
489 dist = 0.5f * accel * timeSinceStop * timeSinceStop;
490 else
491 dist = accelDist + (timeSinceStop - accelTime) * speed;
492 segmentPos = dist - frame.DistSinceStop;
493 }
494 else
495 {
496 if (timeUntilStop < _transportInfo->accelTime)
497 dist = 0.5f * accel * timeUntilStop * timeUntilStop;
498 else
499 dist = accelDist + (timeUntilStop - accelTime) * speed;
500 segmentPos = frame.DistUntilStop - dist;
501 }
502
503 return segmentPos / frame.NextDistFromPrev;
504}
constexpr auto IN_MILLISECONDS
Definition: Common.h:53
GameObjectTemplate const * m_goInfo
Definition: GameObject.h:391
uint32 moveSpeed
Definition: GameObjectData.h:218
struct GameObjectTemplate::@227::@242 moTransport
uint32 accelRate
Definition: GameObjectData.h:219
KeyFrameVec::const_iterator _currentFrame
Definition: Transport.h:95
Definition: TransportMgr.h:42
float DistUntilStop
Definition: TransportMgr.h:53
float NextDistFromPrev
Definition: TransportMgr.h:63
float DistSinceStop
Definition: TransportMgr.h:52
uint32 DepartureTime
Definition: TransportMgr.h:59
float TimeFrom
Definition: TransportMgr.h:55
float TimeTo
Definition: TransportMgr.h:56
float accelDist
Definition: TransportMgr.h:80
float accelTime
Definition: TransportMgr.h:79

References _currentFrame, _transportInfo, TransportTemplate::accelDist, GameObjectTemplate::accelRate, TransportTemplate::accelTime, KeyFrame::DepartureTime, KeyFrame::DistSinceStop, KeyFrame::DistUntilStop, IN_MILLISECONDS, GameObject::m_goInfo, GameObjectTemplate::moTransport, GameObjectTemplate::moveSpeed, KeyFrame::NextDistFromPrev, KeyFrame::TimeFrom, and KeyFrame::TimeTo.

Referenced by Update().

◆ CleanupsBeforeDelete()

void MotionTransport::CleanupsBeforeDelete ( bool  finalCleanup = true)
overridevirtual

Reimplemented from GameObject.

112{
114 while (!_passengers.empty())
115 {
116 WorldObject* obj = *_passengers.begin();
117 RemovePassenger(obj);
118 obj->SetTransport(nullptr);
121 }
122
124}
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: GameObject.cpp:104
void RemoveMovementFlag(uint32 flag)
Definition: Object.h:333
void Reset()
Definition: Object.h:287
Definition: Object.h:405
void RemovePassenger(WorldObject *passenger, bool withAll=false) override
Definition: Transport.cpp:293

References Transport::_passengers, GameObject::CleanupsBeforeDelete(), WorldObject::m_movementInfo, MOVEMENTFLAG_ONTRANSPORT, MovementInfo::RemoveMovementFlag(), RemovePassenger(), MovementInfo::TransportInfo::Reset(), WorldObject::SetTransport(), MovementInfo::transport, and UnloadStaticPassengers().

◆ CreateGOPassenger()

GameObject * MotionTransport::CreateGOPassenger ( ObjectGuid::LowType  guid,
GameObjectData const *  data 
)
367{
368 Map* map = GetMap();
369 GameObject* go = new GameObject();
370 ASSERT(!sObjectMgr->IsGameObjectStaticTransport(data->id));
371
372 if (!go->LoadGameObjectFromDB(guid, map, false))
373 {
374 delete go;
375 return nullptr;
376 }
377
378 float x = data->posX;
379 float y = data->posY;
380 float z = data->posZ;
381 float o = data->orientation;
382
383 go->SetTransport(this);
385 go->m_movementInfo.transport.pos.Relocate(x, y, z, o);
386 CalculatePassengerPosition(x, y, z, &o);
387 go->Relocate(x, y, z, o);
388
389 if (!go->IsPositionValid())
390 {
391 LOG_ERROR("entities.transport", "GameObject ({}) not created. Suggested coordinates aren't valid (X: {} Y: {})",
392 go->GetGUID().ToString(), go->GetPositionX(), go->GetPositionY());
393 delete go;
394 return nullptr;
395 }
396
397 if (!map->AddToMap(go))
398 {
399 delete go;
400 return nullptr;
401 }
402
403 _staticPassengers.insert(go);
404 return go;
405}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
#define sObjectMgr
Definition: ObjectMgr.h:1623
Definition: GameObject.h:121
GameObject()
Definition: GameObject.cpp:41
bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true)
Definition: GameObject.cpp:1123
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
std::string ToString() const
Definition: ObjectGuid.cpp:47
bool IsPositionValid() const
Definition: Position.cpp:175
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const override
This method transforms supplied transport offsets into global coordinates.
Definition: Transport.h:32
PassengerSet _staticPassengers
Definition: Transport.h:105
Definition: Map.h:313
bool AddToMap(T *, bool checkTransport=false)
Definition: Map.cpp:555

References _staticPassengers, Map::AddToMap(), ASSERT, Transport::CalculatePassengerPosition(), GameObject::GameObject(), Object::GetGUID(), WorldObject::GetMap(), Position::GetPositionX(), Position::GetPositionY(), MovementInfo::TransportInfo::guid, GameObjectData::id, Position::IsPositionValid(), GameObject::LoadGameObjectFromDB(), LOG_ERROR, WorldObject::m_movementInfo, GameObjectData::orientation, MovementInfo::TransportInfo::pos, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, Position::Relocate(), WorldObject::SetTransport(), sObjectMgr, ObjectGuid::ToString(), and MovementInfo::transport.

Referenced by LoadStaticPassengers().

◆ CreateMoTrans()

bool MotionTransport::CreateMoTrans ( ObjectGuid::LowType  guidlow,
uint32  entry,
uint32  mapid,
float  x,
float  y,
float  z,
float  ang,
uint32  animprogress 
)
48{
49 Relocate(x, y, z, ang);
50
51 if (!IsPositionValid())
52 {
53 LOG_ERROR("entities.transport", "Transport (GUID: {}) not created. Suggested coordinates isn't valid (X: {} Y: {})",
54 guidlow, x, y);
55 return false;
56 }
57
58 Object::_Create(guidlow, 0, HighGuid::Mo_Transport);
59
60 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
61
62 if (!goinfo)
63 {
64 LOG_ERROR("entities.transport", "Transport not created: entry in `gameobject_template` not found, guidlow: {} map: {} (X: {} Y: {} Z: {}) ang: {}", guidlow, mapid, x, y, z, ang);
65 return false;
66 }
67
68 m_goInfo = goinfo;
69
70 TransportTemplate const* tInfo = sTransportMgr->GetTransportTemplate(entry);
71 if (!tInfo)
72 {
73 LOG_ERROR("entities.transport", "Transport {} (name: {}) will not be created, missing `transport_template` entry.", entry, goinfo->name);
74 return false;
75 }
76
77 _transportInfo = tInfo;
78
79 // initialize waypoints
80 _nextFrame = tInfo->keyFrames.begin();
84
85 if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
86 {
87 SetUInt32Value(GAMEOBJECT_FACTION, addon->faction);
89 }
90
91 SetObjectScale(goinfo->size);
93 SetPeriod(tInfo->pathTime);
94 SetEntry(goinfo->entry);
95 SetDisplayId(goinfo->displayId);
98 SetGoAnimProgress(animprogress);
99 SetName(goinfo->name);
100
101 // pussywizard: no WorldRotation for MotionTransports
102 SetLocalRotation(G3D::Quat());
103 // pussywizard: no PathRotation for MotionTransports
104 SetTransportPathRotation(0.0f, 0.0f, 0.0f, 1.0f);
105
107
108 return true;
109}
#define sTransportMgr
Definition: TransportMgr.h:163
@ GAMEOBJECT_FACTION
Definition: UpdateFields.h:402
@ GO_STATE_READY
Definition: GameObjectData.h:691
@ GO_STATE_ACTIVE
Definition: GameObjectData.h:690
@ GAMEOBJECT_TYPE_MO_TRANSPORT
Definition: SharedDefines.h:1575
GameObjectFlags
Definition: SharedDefines.h:1602
void SetGoState(GOState state)
Definition: GameObject.cpp:2477
void SetTransportPathRotation(float qx, float qy, float qz, float qw)
Definition: GameObject.cpp:2247
void SetLocalRotation(G3D::Quat const &rot)
Definition: GameObject.cpp:2233
void SetGoAnimProgress(uint8 animprogress)
Definition: GameObject.h:211
GameObjectModel * CreateModel()
Definition: GameObject.cpp:2956
void SetGoType(GameobjectTypes type)
Definition: GameObject.h:205
GameObjectModel * m_model
Definition: GameObject.h:313
GameObjectTemplateAddon const * GetTemplateAddon() const
Definition: GameObject.cpp:912
void SetDisplayId(uint32 displayid)
Definition: GameObject.cpp:2590
void ReplaceAllGameObjectFlags(GameObjectFlags flags)
Definition: GameObject.h:221
Definition: GameObjectData.h:32
uint32 entry
Definition: GameObjectData.h:33
uint32 canBeStopped
Definition: GameObjectData.h:225
std::string name
Definition: GameObjectData.h:36
float size
Definition: GameObjectData.h:40
uint32 displayId
Definition: GameObjectData.h:35
Definition: GameObjectData.h:665
void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:134
void SetEntry(uint32 entry)
Definition: Object.h:113
virtual void SetObjectScale(float scale)
Definition: Object.h:116
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650
void SetName(std::string const &newname)
Definition: Object.h:459
void SetPathProgress(uint32 val)
Definition: Transport.h:41
void SetPeriod(uint32 period)
Definition: Transport.h:79
KeyFrameVec::const_iterator _nextFrame
Definition: Transport.h:96
Definition: TransportMgr.h:71
uint32 pathTime
Definition: TransportMgr.h:77
KeyFrameVec keyFrames
Definition: TransportMgr.h:78

References Object::_Create(), _currentFrame, _nextFrame, _transportInfo, _triggeredArrivalEvent, _triggeredDepartureEvent, GameObjectTemplate::canBeStopped, GameObject::CreateModel(), GameObjectTemplate::displayId, GameObjectTemplate::entry, GAMEOBJECT_FACTION, GAMEOBJECT_TYPE_MO_TRANSPORT, GameObject::GetTemplateAddon(), GO_STATE_ACTIVE, GO_STATE_READY, Position::IsPositionValid(), TransportTemplate::keyFrames, LOG_ERROR, GameObject::m_goInfo, GameObject::m_model, GameObjectTemplate::moTransport, GameObjectTemplate::name, TransportTemplate::pathTime, Position::Relocate(), GameObject::ReplaceAllGameObjectFlags(), GameObject::SetDisplayId(), Object::SetEntry(), GameObject::SetGoAnimProgress(), GameObject::SetGoState(), GameObject::SetGoType(), GameObject::SetLocalRotation(), WorldObject::SetName(), Object::SetObjectScale(), Transport::SetPathProgress(), SetPeriod(), GameObject::SetTransportPathRotation(), Object::SetUInt32Value(), GameObjectTemplate::size, sObjectMgr, and sTransportMgr.

Referenced by TransportMgr::CreateTransport().

◆ CreateNPCPassenger()

Creature * MotionTransport::CreateNPCPassenger ( ObjectGuid::LowType  guid,
CreatureData const *  data 
)

@HACK - transport models are not added to map's dynamic LoS calculations because the current GameObjectModel cannot be moved without recreating

319{
320 Map* map = GetMap();
321 Creature* creature = new Creature();
322
323 if (!creature->LoadCreatureFromDB(guid, map, false))
324 {
325 delete creature;
326 return nullptr;
327 }
328
329 float x = data->posX;
330 float y = data->posY;
331 float z = data->posZ;
332 float o = data->orientation;
333
334 creature->SetTransport(this);
336 creature->m_movementInfo.transport.guid = GetGUID();
337 creature->m_movementInfo.transport.pos.Relocate(x, y, z, o);
338 CalculatePassengerPosition(x, y, z, &o);
339 creature->Relocate(x, y, z, o);
340 creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());
342
346
347 if (!creature->IsPositionValid())
348 {
349 LOG_ERROR("entities.transport", "Creature ({}) not created. Suggested coordinates aren't valid (X: {} Y: {})",
350 creature->GetGUID().ToString(), creature->GetPositionX(), creature->GetPositionY());
351 delete creature;
352 return nullptr;
353 }
354
355 if (!map->AddToMap(creature))
356 {
357 delete creature;
358 return nullptr;
359 }
360
361 _staticPassengers.insert(creature);
362 sScriptMgr->OnAddCreaturePassenger(this, creature);
363 return creature;
364}
Definition: Creature.h:46
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:337
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition: Creature.cpp:1687
void SetTransportHomePosition(float x, float y, float z, float o)
Definition: Creature.h:342
float GetPositionZ() const
Definition: Position.h:119
float GetOrientation() const
Definition: Position.h:120
void AddUnitMovementFlag(uint32 f)
Definition: Unit.h:1611

References _staticPassengers, Map::AddToMap(), Unit::AddUnitMovementFlag(), Unit::AddUnitState(), Transport::CalculatePassengerPosition(), Object::GetGUID(), WorldObject::GetMap(), Position::GetOrientation(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), MovementInfo::TransportInfo::guid, Position::IsPositionValid(), Creature::LoadCreatureFromDB(), LOG_ERROR, WorldObject::m_movementInfo, MOVEMENTFLAG_ONTRANSPORT, CreatureData::orientation, MovementInfo::TransportInfo::pos, CreatureData::posX, CreatureData::posY, CreatureData::posZ, Position::Relocate(), Creature::SetHomePosition(), WorldObject::SetTransport(), Creature::SetTransportHomePosition(), sScriptMgr, ObjectGuid::ToString(), MovementInfo::transport, and UNIT_STATE_IGNORE_PATHFINDING.

Referenced by LoadStaticPassengers().

◆ DelayedTeleportTransport()

void MotionTransport::DelayedTeleportTransport ( )
private
537{
538 if (!_delayedTeleport)
539 return;
540
541 _delayedTeleport = false;
542
543 uint32 newMapId = _nextFrame->Node->mapid;
544 float x = _nextFrame->Node->x,
545 y = _nextFrame->Node->y,
546 z = _nextFrame->Node->z,
547 o = _nextFrame->InitialOrientation;
548
549 PassengerSet _passengersCopy = _passengers;
550 for (PassengerSet::iterator itr = _passengersCopy.begin(); itr != _passengersCopy.end(); )
551 {
552 WorldObject* obj = (*itr++);
553
554 if (_passengers.find(obj) == _passengers.end())
555 continue;
556
557 switch (obj->GetTypeId())
558 {
559 case TYPEID_UNIT:
560 _passengers.erase(obj);
561 if (!obj->ToCreature()->IsPet())
563 break;
565 _passengers.erase(obj);
566 obj->ToGameObject()->Delete();
567 break;
569 _passengers.erase(obj);
570 if (Unit* caster = obj->ToDynObject()->GetCaster())
571 if (Spell* s = caster->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
572 if (obj->ToDynObject()->GetSpellId() == s->GetSpellInfo()->Id)
573 {
574 s->SendChannelUpdate(0);
575 s->SendInterrupted(0);
576 caster->RemoveOwnedAura(s->GetSpellInfo()->Id, caster->GetGUID());
577 }
579 break;
580 case TYPEID_PLAYER:
581 {
582 float destX, destY, destZ, destO;
583 obj->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
584 TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
585 if (!obj->ToPlayer()->TeleportTo(newMapId, destX, destY, destZ, destO, TELE_TO_NOT_LEAVE_TRANSPORT))
586 _passengers.erase(obj);
587 }
588 break;
589 default:
590 break;
591 }
592 }
593
594 Map* newMap = sMapMgr->CreateBaseMap(newMapId);
595 GetMap()->RemoveFromMap<MotionTransport>(this, false);
596 newMap->LoadGrid(x, y); // xinef: load before adding passengers to new map
597 SetMap(newMap);
598
599 Relocate(x, y, z, o);
601
603}
std::uint32_t uint32
Definition: Define.h:107
#define sMapMgr
Definition: MapMgr.h:221
@ CURRENT_CHANNELED_SPELL
Definition: Unit.h:539
@ TYPEID_DYNAMICOBJECT
Definition: ObjectGuid.h:38
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:37
@ TYPEID_UNIT
Definition: ObjectGuid.h:35
@ TYPEID_PLAYER
Definition: ObjectGuid.h:36
@ TELE_TO_NOT_LEAVE_TRANSPORT
Definition: Player.h:822
void DespawnOrUnsummon(Milliseconds msTimeToDespawn, Seconds forcedRespawnTimer)
Definition: Creature.cpp:2173
Unit * GetCaster() const
Definition: DynamicObject.h:55
uint32 GetSpellId() const
Definition: DynamicObject.h:58
void Delete()
Definition: GameObject.cpp:979
DynamicObject * ToDynObject()
Definition: Object.h:218
TypeID GetTypeId() const
Definition: Object.h:124
GameObject * ToGameObject()
Definition: Object.h:210
Creature * ToCreature()
Definition: Object.h:202
virtual void SetMap(Map *map)
Definition: Object.cpp:2105
void AddObjectToRemoveList()
Definition: Object.cpp:2149
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1330
std::set< WorldObject * > PassengerSet
Definition: Transport.h:35
Definition: Transport.h:48
void LoadStaticPassengers()
Definition: Transport.cpp:407
Definition: Unit.h:630
bool IsPet() const
Definition: Unit.h:710
virtual void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const =0
This method transforms supplied transport offsets into global coordinates.
void LoadGrid(float x, float y)
Definition: Map.cpp:492
void RemoveFromMap(T *, bool)
Definition: Map.cpp:939
Definition: Spell.h:284

References _delayedTeleport, _nextFrame, Transport::_passengers, WorldObject::AddObjectToRemoveList(), Map::AddToMap(), TransportBase::CalculatePassengerPosition(), CURRENT_CHANNELED_SPELL, GameObject::Delete(), Creature::DespawnOrUnsummon(), DynamicObject::GetCaster(), WorldObject::GetMap(), Position::GetPosition(), DynamicObject::GetSpellId(), Object::GetTypeId(), Unit::IsPet(), Map::LoadGrid(), LoadStaticPassengers(), WorldObject::m_movementInfo, MovementInfo::TransportInfo::pos, Position::Relocate(), Map::RemoveFromMap(), WorldObject::SetMap(), sMapMgr, TELE_TO_NOT_LEAVE_TRANSPORT, Player::TeleportTo(), Object::ToCreature(), Object::ToDynObject(), Object::ToGameObject(), Object::ToPlayer(), MovementInfo::transport, TYPEID_DYNAMICOBJECT, TYPEID_GAMEOBJECT, TYPEID_PLAYER, and TYPEID_UNIT.

Referenced by DelayedUpdate().

◆ DelayedUpdate()

void MotionTransport::DelayedUpdate ( uint32  diff)
241{
242 if (GetKeyFrames().size() <= 1)
243 return;
244
246}
KeyFrameVec const & GetKeyFrames() const
Definition: Transport.h:74
void DelayedTeleportTransport()
Definition: Transport.cpp:536

References DelayedTeleportTransport(), and GetKeyFrames().

Referenced by Map::DelayedUpdate().

◆ DoEventIfAny()

void MotionTransport::DoEventIfAny ( KeyFrame const &  node,
bool  departure 
)
private
657{
658 if (uint32 eventid = departure ? node.Node->departureEventID : node.Node->arrivalEventID)
659 {
660 //LOG_DEBUG("maps.script", "Taxi {} event {} of node {} of {} path", departure ? "departure" : "arrival", eventid, node.Node->index, GetName());
661 GetMap()->ScriptsStart(sEventScripts, eventid, this, this);
662 EventInform(eventid);
663 }
664}
ScriptMapMap sEventScripts
Definition: ObjectMgr.cpp:58
void EventInform(uint32 eventId)
Definition: GameObject.cpp:2185
void ScriptsStart(std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
Put scripts in the execution queue.
Definition: MapScripts.cpp:33

References TaxiPathNodeEntry::arrivalEventID, TaxiPathNodeEntry::departureEventID, GameObject::EventInform(), WorldObject::GetMap(), KeyFrame::Node, Map::ScriptsStart(), and sEventScripts.

Referenced by Update().

◆ EnableMovement()

◆ GetDebugInfo()

std::string MotionTransport::GetDebugInfo ( ) const
overridevirtual

Reimplemented from GameObject.

1010{
1011 std::stringstream sstr;
1012 sstr << GameObject::GetDebugInfo();
1013 return sstr.str();
1014}
std::string GetDebugInfo() const override
Definition: GameObject.cpp:3087

References GameObject::GetDebugInfo().

◆ GetKeyFrames()

KeyFrameVec const & MotionTransport::GetKeyFrames ( ) const
inline

◆ GetPeriod()

uint32 MotionTransport::GetPeriod ( ) const
inline
@ GAMEOBJECT_LEVEL
Definition: UpdateFields.h:403
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305

References GAMEOBJECT_LEVEL, and Object::GetUInt32Value().

Referenced by Update().

◆ GetStaticPassengers()

PassengerSet const & MotionTransport::GetStaticPassengers ( ) const
inline
68{ return _staticPassengers; }

References _staticPassengers.

◆ GetTransportTemplate()

TransportTemplate const * MotionTransport::GetTransportTemplate ( ) const
inline
76{ return _transportInfo; }

References _transportInfo.

◆ IsMoving()

bool MotionTransport::IsMoving ( ) const
inlineprivate

Helpers to know if stop frame was reached.

91{ return _isMoving; }

References _isMoving.

Referenced by Update().

◆ LoadStaticPassengers()

void MotionTransport::LoadStaticPassengers ( )
408{
409 if (PassengersLoaded())
410 return;
412 if (uint32 mapId = GetGOInfo()->moTransport.mapID)
413 {
414 CellObjectGuidsMap const& cells = sObjectMgr->GetMapObjectGuids(mapId, GetMap()->GetSpawnMode());
415 CellGuidSet::const_iterator guidEnd;
416 for (CellObjectGuidsMap::const_iterator cellItr = cells.begin(); cellItr != cells.end(); ++cellItr)
417 {
418 // Creatures on transport
419 guidEnd = cellItr->second.creatures.end();
420 for (CellGuidSet::const_iterator guidItr = cellItr->second.creatures.begin(); guidItr != guidEnd; ++guidItr)
421 CreateNPCPassenger(*guidItr, sObjectMgr->GetCreatureData(*guidItr));
422
423 // GameObjects on transport
424 guidEnd = cellItr->second.gameobjects.end();
425 for (CellGuidSet::const_iterator guidItr = cellItr->second.gameobjects.begin(); guidItr != guidEnd; ++guidItr)
426 CreateGOPassenger(*guidItr, sObjectMgr->GetGameObjectData(*guidItr));
427 }
428 }
429}
std::unordered_map< uint32, CellObjectGuids > CellObjectGuidsMap
Definition: ObjectMgr.h:484
uint32 mapID
Definition: GameObjectData.h:223
bool PassengersLoaded() const
Definition: Transport.h:72
Creature * CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData const *data)
Definition: Transport.cpp:318
GameObject * CreateGOPassenger(ObjectGuid::LowType guid, GameObjectData const *data)
Definition: Transport.cpp:366
void SetPassengersLoaded(bool loaded)
Definition: Transport.h:71

References CreateGOPassenger(), CreateNPCPassenger(), GameObject::GetGOInfo(), WorldObject::GetMap(), GameObjectTemplate::mapID, PassengersLoaded(), SetPassengersLoaded(), and sObjectMgr.

Referenced by DelayedTeleportTransport(), Update(), and UpdatePosition().

◆ MoveToNextWaypoint()

void MotionTransport::MoveToNextWaypoint ( )
private
464{
465 // Clear events flagging
468
469 // Set frames
471 if (_nextFrame == GetKeyFrames().end())
472 _nextFrame = GetKeyFrames().begin();
473}

References _currentFrame, _nextFrame, _triggeredArrivalEvent, _triggeredDepartureEvent, and GetKeyFrames().

Referenced by Update().

◆ PassengersLoaded()

bool MotionTransport::PassengersLoaded ( ) const
inline
72{ return _passengersLoaded; }

References _passengersLoaded.

Referenced by LoadStaticPassengers().

◆ RemovePassenger()

void MotionTransport::RemovePassenger ( WorldObject passenger,
bool  withAll = false 
)
overridevirtual

Implements Transport.

294{
295 std::lock_guard<std::mutex> guard(Lock);
296 if (_passengers.erase(passenger) || _staticPassengers.erase(passenger))
297 {
298 if (Player* plr = passenger->ToPlayer())
299 {
300 sScriptMgr->OnRemovePassenger(ToTransport(), plr);
301 plr->SetFallInformation(GameTime::GetGameTime().count(), plr->GetPositionZ());
302 }
303
304 if (withAll)
305 {
306 passenger->SetTransport(nullptr);
307 passenger->m_movementInfo.flags &= ~MOVEMENTFLAG_ONTRANSPORT;
308 passenger->m_movementInfo.transport.guid.Clear();
309 passenger->m_movementInfo.transport.pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
310 if (passenger->ToUnit())
311 {
313 }
314 }
315 }
316}
Seconds GetGameTime()
Definition: GameTime.cpp:38
void Clear()
Definition: ObjectGuid.h:138
void ClearUnitState(uint32 f)
Definition: Unit.h:674

References Transport::_passengers, _staticPassengers, ObjectGuid::Clear(), Unit::ClearUnitState(), MovementInfo::flags, GameTime::GetGameTime(), MovementInfo::TransportInfo::guid, Lock, WorldObject::m_movementInfo, MovementInfo::TransportInfo::pos, Position::Relocate(), WorldObject::SetTransport(), sScriptMgr, Object::ToPlayer(), GameObject::ToTransport(), Object::ToUnit(), MovementInfo::transport, and UNIT_STATE_IGNORE_PATHFINDING.

Referenced by CleanupsBeforeDelete().

◆ SetMoving()

void MotionTransport::SetMoving ( bool  val)
inlineprivate
92{ _isMoving = val; }

References _isMoving.

Referenced by Update().

◆ SetPassengersLoaded()

void MotionTransport::SetPassengersLoaded ( bool  loaded)
inline

◆ SetPeriod()

void MotionTransport::SetPeriod ( uint32  period)
inline

◆ TeleportTransport()

bool MotionTransport::TeleportTransport ( uint32  newMapid,
float  x,
float  y,
float  z,
float  o 
)
private
507{
508 Map const* oldMap = GetMap();
509
510 if (oldMap->GetId() != newMapid)
511 {
512 _delayedTeleport = true;
514 return true;
515 }
516 else
517 {
518 // Teleport players, they need to know it
519 for (PassengerSet::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr)
520 {
521 if ((*itr)->IsPlayer())
522 {
523 float destX, destY, destZ, destO;
524 (*itr)->m_movementInfo.transport.pos.GetPosition(destX, destY, destZ, destO);
525 TransportBase::CalculatePassengerPosition(destX, destY, destZ, &destO, x, y, z, o);
526
527 (*itr)->ToUnit()->NearTeleportTo(destX, destY, destZ, destO);
528 }
529 }
530
531 UpdatePosition(x, y, z, o);
532 return false;
533 }
534}
void UpdatePosition(float x, float y, float z, float o)
Definition: Transport.cpp:248
uint32 GetId() const
Definition: Map.h:379

References _delayedTeleport, Transport::_passengers, TransportBase::CalculatePassengerPosition(), Map::GetId(), WorldObject::GetMap(), UnloadStaticPassengers(), and UpdatePosition().

Referenced by Update().

◆ UnloadNonStaticPassengers()

void MotionTransport::UnloadNonStaticPassengers ( )
442{
443 for (PassengerSet::iterator itr = _passengers.begin(); itr != _passengers.end(); )
444 {
445 if ((*itr)->IsPlayer())
446 {
447 ++itr;
448 continue;
449 }
450 PassengerSet::iterator itr2 = itr++;
451 (*itr2)->AddObjectToRemoveList();
452 }
453}

References Transport::_passengers.

Referenced by ResetEncounterEvent::Execute().

◆ UnloadStaticPassengers()

void MotionTransport::UnloadStaticPassengers ( )
432{
433 SetPassengersLoaded(false);
434 while (!_staticPassengers.empty())
435 {
436 WorldObject* obj = *_staticPassengers.begin();
437 obj->AddObjectToRemoveList(); // also removes from _staticPassengers
438 }
439}

References _staticPassengers, WorldObject::AddObjectToRemoveList(), and SetPassengersLoaded().

Referenced by CleanupsBeforeDelete(), TeleportTransport(), and ~MotionTransport().

◆ Update()

void MotionTransport::Update ( uint32  diff)
overridevirtual

Reimplemented from GameObject.

139{
140 uint32 const positionUpdateDelay = 1;
141
142 if (AI())
143 AI()->UpdateAI(diff);
144 else if (!AIM_Initialize())
145 LOG_ERROR("entities.transport", "Could not initialize GameObjectAI for Transport");
146
147 if (GetKeyFrames().size() <= 1)
148 return;
149
150 if (IsMoving() || !_pendingStop)
152
153 uint32 timer = GetPathProgress() % GetPeriod();
154
155 // Set current waypoint
156 // Desired outcome: _currentFrame->DepartureTime < timer < _nextFrame->ArriveTime
157 // ... arrive | ... delay ... | departure
158 // event / event /
159 for (;;)
160 {
161 if (timer >= _currentFrame->ArriveTime)
162 {
164 {
167 }
168
169 if (timer < _currentFrame->DepartureTime)
170 {
171 SetMoving(false);
173 {
178 }
179 break; // its a stop frame and we are waiting
180 }
181 }
182
183 if (timer >= _currentFrame->DepartureTime && !_triggeredDepartureEvent)
184 {
185 DoEventIfAny(*_currentFrame, true); // departure event
187 }
188
189 // not waiting anymore
190 SetMoving(true);
191
192 // Enable movement
193 if (GetGOInfo()->moTransport.canBeStopped)
195
196 if (timer >= _currentFrame->DepartureTime && timer < _currentFrame->NextArriveTime)
197 break; // found current waypoint
198
200
201 sScriptMgr->OnRelocate(this, _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);
202
203 //LOG_DEBUG("entities.transport", "Transport {} ({}) moved to node {} {} {} {} {}", GetEntry(), GetName(), _currentFrame->Node->index, _currentFrame->Node->mapid, _currentFrame->Node->x, _currentFrame->Node->y, _currentFrame->Node->z);
204
205 // Departure event
206 if (_currentFrame->IsTeleportFrame())
207 if (TeleportTransport(_nextFrame->Node->mapid, _nextFrame->Node->x, _nextFrame->Node->y, _nextFrame->Node->z, _nextFrame->InitialOrientation))
208 return; // Update more in new map thread
209 }
210
211 // Set position
214 {
215 _positionChangeTimer.Reset(positionUpdateDelay);
216 if (IsMoving())
217 {
218 float t = CalculateSegmentPos(float(timer) * 0.001f);
219 G3D::Vector3 pos, dir;
220 _currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
221 _currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
222 UpdatePosition(pos.x, pos.y, pos.z, NormalizeOrientation(std::atan2(dir.y, dir.x) + M_PI));
223 }
224 else
225 {
226 /* There are four possible scenarios that trigger loading/unloading passengers:
227 1. transport moves from inactive to active grid
228 2. the grid that transport is currently in becomes active
229 3. transport moves from active to inactive grid
230 4. the grid that transport is currently in unloads
231 */
232 if (_staticPassengers.empty() && GetMap()->IsGridLoaded(GetPositionX(), GetPositionY())) // 2.
234 }
235 }
236
237 sScriptMgr->OnTransportUpdate(this, diff);
238}
void Update(int32 diff)
Definition: Timer.h:239
void Reset(int32 interval)
Definition: Timer.h:249
bool Passed() const
Definition: Timer.h:244
virtual void UpdateAI(uint32)
Definition: GameObjectAI.h:42
GOState GetGoState() const
Definition: GameObject.h:206
GameObjectAI * AI() const
Definition: GameObject.h:307
bool AIM_Initialize()
Definition: GameObject.cpp:85
static float NormalizeOrientation(float o)
Definition: Position.h:233
uint32 GetPathProgress() const
Definition: Transport.h:40
bool IsMoving() const
Helpers to know if stop frame was reached.
Definition: Transport.h:91
void MoveToNextWaypoint()
Definition: Transport.cpp:463
float CalculateSegmentPos(float perc)
Definition: Transport.cpp:475
uint32 GetPeriod() const
Definition: Transport.h:78
TimeTrackerSmall _positionChangeTimer
Definition: Transport.h:97
void DoEventIfAny(KeyFrame const &node, bool departure)
Definition: Transport.cpp:656
void SetMoving(bool val)
Definition: Transport.h:92
bool TeleportTransport(uint32 newMapid, float x, float y, float z, float o)
Definition: Transport.cpp:506

References _currentFrame, _nextFrame, _pendingStop, _positionChangeTimer, _staticPassengers, _triggeredArrivalEvent, _triggeredDepartureEvent, GameObject::AI(), GameObject::AIM_Initialize(), CalculateSegmentPos(), GameObjectTemplate::canBeStopped, DoEventIfAny(), GameObject::GetGOInfo(), GameObject::GetGoState(), GetKeyFrames(), WorldObject::GetMap(), Transport::GetPathProgress(), GetPeriod(), Position::GetPositionX(), Position::GetPositionY(), GO_STATE_ACTIVE, GO_STATE_READY, IsMoving(), LoadStaticPassengers(), LOG_ERROR, MoveToNextWaypoint(), Position::NormalizeOrientation(), TimeTrackerSmall::Passed(), TimeTrackerSmall::Reset(), GameObject::SetGoState(), SetMoving(), Transport::SetPathProgress(), sScriptMgr, TeleportTransport(), TimeTrackerSmall::Update(), GameObjectAI::UpdateAI(), and UpdatePosition().

Referenced by Map::Update().

◆ UpdatePassengerPositions()

void MotionTransport::UpdatePassengerPositions ( PassengerSet passengers)
private
606{
607 for (PassengerSet::iterator itr = passengers.begin(); itr != passengers.end(); ++itr)
608 {
609 WorldObject* passenger = *itr;
610 // transport teleported but passenger not yet (can happen for players)
611 if (passenger->GetMap() != GetMap())
612 continue;
613
614 // if passenger is on vehicle we have to assume the vehicle is also on transport and its the vehicle that will be updating its passengers
615 if (Unit* unit = passenger->ToUnit())
616 if (unit->GetVehicle())
617 continue;
618
619 // Do not use Unit::UpdatePosition here, we don't want to remove auras as if regular movement occurred
620 float x, y, z, o;
621 passenger->m_movementInfo.transport.pos.GetPosition(x, y, z, o);
622 CalculatePassengerPosition(x, y, z, &o);
623
624 // check if position is valid
625 if (!Acore::IsValidMapCoord(x, y, z))
626 continue;
627
628 switch (passenger->GetTypeId())
629 {
630 case TYPEID_UNIT:
631 {
632 Creature* creature = passenger->ToCreature();
633 GetMap()->CreatureRelocation(creature, x, y, z, o);
634
635 creature->GetTransportHomePosition(x, y, z, o);
636 CalculatePassengerPosition(x, y, z, &o);
637 creature->SetHomePosition(x, y, z, o);
638 }
639 break;
640 case TYPEID_PLAYER:
641 if (passenger->IsInWorld())
642 GetMap()->PlayerRelocation(passenger->ToPlayer(), x, y, z, o);
643 break;
645 GetMap()->GameObjectRelocation(passenger->ToGameObject(), x, y, z, o);
646 break;
648 GetMap()->DynamicObjectRelocation(passenger->ToDynObject(), x, y, z, o);
649 break;
650 default:
651 break;
652 }
653 }
654}
bool IsValidMapCoord(float c)
Definition: GridDefines.h:216
void GetTransportHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:344
bool IsInWorld() const
Definition: Object.h:104
void PlayerRelocation(Player *, float x, float y, float z, float o)
Definition: Map.cpp:1000
void GameObjectRelocation(GameObject *go, float x, float y, float z, float o)
Definition: Map.cpp:1044
void CreatureRelocation(Creature *creature, float x, float y, float z, float o)
Definition: Map.cpp:1022
void DynamicObjectRelocation(DynamicObject *go, float x, float y, float z, float o)
Definition: Map.cpp:1065

References Transport::CalculatePassengerPosition(), Map::CreatureRelocation(), Map::DynamicObjectRelocation(), Map::GameObjectRelocation(), WorldObject::GetMap(), Position::GetPosition(), Creature::GetTransportHomePosition(), Object::GetTypeId(), Object::IsInWorld(), Acore::IsValidMapCoord(), WorldObject::m_movementInfo, Map::PlayerRelocation(), MovementInfo::TransportInfo::pos, Creature::SetHomePosition(), Object::ToCreature(), Object::ToDynObject(), Object::ToGameObject(), Object::ToPlayer(), Object::ToUnit(), MovementInfo::transport, TYPEID_DYNAMICOBJECT, TYPEID_GAMEOBJECT, TYPEID_PLAYER, and TYPEID_UNIT.

Referenced by UpdatePosition().

◆ UpdatePosition()

void MotionTransport::UpdatePosition ( float  x,
float  y,
float  z,
float  o 
)
249{
250 if (!GetMap()->IsGridLoaded(x, y)) // pussywizard: should not happen, but just in case
251 GetMap()->LoadGrid(x, y);
252
253 Relocate(x, y, z, o);
255
257
258 if (_staticPassengers.empty())
260 else
262}
void UpdateModelPosition()
Definition: GameObject.cpp:2910
void UpdatePassengerPositions(PassengerSet &passengers)
Definition: Transport.cpp:605

References Transport::_passengers, _staticPassengers, WorldObject::GetMap(), Map::LoadGrid(), LoadStaticPassengers(), Position::Relocate(), GameObject::UpdateModelPosition(), and UpdatePassengerPositions().

Referenced by TeleportTransport(), and Update().

Friends And Related Function Documentation

◆ TransportMgr::CreateTransport

Member Data Documentation

◆ _currentFrame

KeyFrameVec::const_iterator MotionTransport::_currentFrame
private

◆ _delayedTeleport

bool MotionTransport::_delayedTeleport
private

◆ _isMoving

bool MotionTransport::_isMoving
private

Referenced by IsMoving(), and SetMoving().

◆ _nextFrame

KeyFrameVec::const_iterator MotionTransport::_nextFrame
private

◆ _passengersLoaded

bool MotionTransport::_passengersLoaded
private

◆ _pendingStop

bool MotionTransport::_pendingStop
private

Referenced by EnableMovement(), and Update().

◆ _positionChangeTimer

TimeTrackerSmall MotionTransport::_positionChangeTimer
private

Referenced by Update().

◆ _staticPassengers

◆ _transportInfo

TransportTemplate const* MotionTransport::_transportInfo
private

◆ _triggeredArrivalEvent

bool MotionTransport::_triggeredArrivalEvent
private

These are needed to properly control events triggering only once for each frame.

Referenced by CreateMoTrans(), MoveToNextWaypoint(), and Update().

◆ _triggeredDepartureEvent

bool MotionTransport::_triggeredDepartureEvent
private

◆ Lock

std::mutex MotionTransport::Lock
mutableprivate

Referenced by AddPassenger(), and RemovePassenger().