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

#include "GameObject.h"

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

Public Member Functions

 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 SetWorldRotationAngles (float z_rot, float y_rot, float x_rot)
 
void SetWorldRotation (G3D::Quat const &rot)
 
void SetTransportPathRotation (float qx, float qy, float qz, float qw)
 
G3D::Quat const & GetWorldRotation () const
 
int64 GetPackedWorldRotation () const
 
G3D::Quat GetFinalWorldRotation () 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)
 
virtual bool LoadFromDB (ObjectGuid::LowType guid, Map *map)
 
virtual bool LoadGameObjectFromDB (ObjectGuid::LowType guid, Map *map, bool addToMap=true)
 
bool IsRespawnCompatibilityMode () const
 
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 *fishLoot, Player *lootOwner, bool junk=false)
 
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 const &playerGuid)
 
bool IsInSkillupList (ObjectGuid const &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 IsInRange2d (float x, float y, float radius) const
 
bool IsInRange3d (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 (Position const &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 IsUpdateNeeded () override
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
 
- Public Member Functions inherited from WorldObject
 ~WorldObject () override
 
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 (Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
Position GetRandomPoint (Position const &srcPos, float distance) const
 
uint32 GetInstanceId () const
 
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)
 
float GetDistance (WorldObject const *obj) const
 
float GetDistance (Position const &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 (Position const *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (Position const *pos, float dist) const
 
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=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 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
 
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)
 
template<typename Worker >
void DoForAllVisiblePlayers (Worker &&worker)
 
template<typename Worker >
void DoForAllVisibleWorldObjects (Worker &&worker)
 
void DestroyForVisiblePlayers ()
 
void SendObjectDeSpawnAnim (ObjectGuid guid)
 
void AddObjectToRemoveList ()
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
virtual float GetSightRange (WorldObject const *target=nullptr) const
 
float GetLeewayBonusRange (Unit const *target) const
 
float GetLeewayBonusRadius () 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, Position const &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)
 
void SummonGameObjectGroup (uint8 group, std::list< GameObject * > *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 GetGameObjectListWithEntryInGrid (std::list< GameObject * > &gameobjectList, std::vector< uint32 > const &entries, float maxSearchRange) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &creatureList, std::vector< uint32 > const &entries, float maxSearchRange) const
 
void GetDeadCreatureListInGrid (std::list< Creature * > &lList, float maxSearchRange, bool alive=false) const
 
virtual void UpdateObjectVisibility (bool forced=true, bool fromUpdate=false)
 
virtual void UpdateObjectVisibilityOnCreate ()
 
void BuildUpdate (UpdateDataMapType &data_map) 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)
 
VisibilityDistanceType GetVisibilityOverrideType () const
 
bool IsVisibilityOverridden () const
 
bool IsZoneWideVisible () const
 
bool IsFarVisible () const
 
float GetVisibilityOverrideDistance () const
 
void SetVisibilityDistanceOverride (VisibilityDistanceType type)
 
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)
 
float GetMapWaterOrGroundLevel (Position pos, float *ground=nullptr) 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.
 
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)
 
bool CanBeAddedToMapUpdateList ()
 
std::string GetDebugInfo () const override
 
ObjectVisibilityContainerGetObjectVisibilityContainer ()
 
ObjectVisibilityContainer const & GetObjectVisibilityContainer () const
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
bool IsInWorld () const
 
ObjectGuid GetGUID () const
 
PackedGuid const & GetPackGUID () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
virtual void SetObjectScale (float scale)
 
bool HasDynamicFlag (uint32 flag) const
 
virtual void SetDynamicFlag (uint32 flag)
 
virtual void RemoveDynamicFlag (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 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
 
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 void Heartbeat ()
 
template<typename... T>
bool EntryEquals (T... entries) 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 (WorldLocation const &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= (Position const &)=default
 
Positionoperator= (Position &&)=default
 
bool operator== (Position const &a) const
 
bool operator!= (Position const &a)
 
bool operator!= (Position const &a) const
 
 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 (Position const &pos)
 
void Relocate (Position const *pos)
 
void RelocatePolarOffset (float angle, float dist, float z=0.0f)
 
void RelocateOffset (Position const &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 (Position const &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (Position const *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 (Position const *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 (Position const *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (Position const *pos, float dist) const
 
bool IsWithinBox (Position const &center, float xradius, float yradius, float zradius) const
 
bool HasInArc (float arcangle, Position const *pos, float targetRadius=0.0f) const
 
bool HasInLine (Position const *pos, float width) const
 
bool HasInLine (Position const *pos, float objSize, float width) const
 
std::string ToString () const
 
- Public Member Functions inherited from GridObject< GameObject >
bool IsInGrid () const
 
void AddToGrid (GridRefMgr< GameObject > &m)
 
void RemoveFromGrid ()
 

Static Public Member Functions

static void SetGoArtKit (uint8 artkit, GameObject *go, ObjectGuid::LowType lowguid=0)
 
- Static Public Member Functions inherited from WorldObject
static float GetLeewayBonusRangeForTargets (Player const *player, Unit const *target)
 
- 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

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
 
ALEEventProcessor * ALEEvents
 
EventProcessor m_Events
 
- 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

static std::unordered_map< int, goEventFlaggameObjectToEventFlag = { }
 

Protected Types

typedef std::map< uint32, ObjectGuidChairSlotAndUser
 

Protected Member Functions

bool AIM_Initialize ()
 
GameObjectModelCreateModel ()
 
void UpdateModel ()
 
- Protected Member Functions inherited from WorldObject
 WorldObject ()
 
virtual void ProcessPositionDataChanged (PositionFullTerrainStatus const &data)
 
void SetLocationMapId (uint32 _mapId)
 
void SetLocationInstanceId (uint32 _instanceId)
 
virtual bool IsAlwaysDetectableFor (WorldObject const *) const
 
- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
 
void _Create (ObjectGuid guid)
 
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
 
void AddToObjectUpdateIfNeeded ()
 
- Protected Member Functions inherited from MovableMapObject
 MovableMapObject ()=default
 
Cell const & GetCurrentCell () const
 
- Protected Member Functions inherited from UpdatableMapObject
 UpdatableMapObject ()
 

Protected Attributes

bool _respawnCompatibilityMode {true}
 
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.
 
GameObjectTemplate const * m_goInfo
 
GameObjectData const * m_goData
 
GameObjectValue m_goValue
 
bool m_allowModifyDestructibleBuilding
 
int64 m_packedRotation
 
G3D::Quat WorldRotation
 
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
 
VisibilityDistanceType _visibilityDistanceOverrideType
 
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
 

Private Member Functions

void CheckRitualList ()
 
void ClearRitualList ()
 
void RemoveFromOwner ()
 
void SwitchDoorOrButton (bool activate, bool alternative=false)
 
void UpdatePackedRotation ()
 
bool _IsWithinDist (WorldObject const *obj, float dist2compare, bool, bool, bool) const override
 Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size.
 
bool IsWithinSightRange (Position const &pos, float dist) const override
 

Private Attributes

GameObjectAIm_AI
 
bool m_saveStateOnDb = false
 

Additional Inherited Members

- Public Types inherited from UpdatableMapObject
enum  UpdateState : uint8 {
  NotUpdating ,
  PendingAdd ,
  Updating
}
 

Detailed Description

Member Typedef Documentation

◆ ChairSlotAndUser

typedef std::map<uint32, ObjectGuid> GameObject::ChairSlotAndUser
protected

Constructor & Destructor Documentation

◆ GameObject()

GameObject::GameObject ( )
explicit
58 m_model(nullptr), m_goValue(), m_AI(nullptr)
59{
62
64
66 m_respawnTime = 0;
70 m_restockTime = 0s;
72 m_spawnedByDefault = true;
74 m_usetimes = 0;
75 m_spellId = 0;
77 m_goInfo = nullptr;
78 m_goData = nullptr;
80
81 m_spawnId = 0;
82
87
88 ResetLootMode(); // restore default loot mode
90 m_stationaryPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
91}
@ GO_NOT_READY
Definition GameObject.h:110
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:40
@ TYPEMASK_GAMEOBJECT
Definition ObjectGuid.h:54
@ UPDATEFLAG_ROTATION
Definition UpdateData.h:48
@ UPDATEFLAG_POSITION
Definition UpdateData.h:47
@ UPDATEFLAG_LOWGUID
Definition UpdateData.h:43
@ UPDATEFLAG_STATIONARY_POSITION
Definition UpdateData.h:45
@ GAMEOBJECT_END
Definition UpdateFields.h:405
Loot loot
Definition GameObject.h:247
GameObjectValue m_goValue
Definition GameObject.h:396
time_t m_respawnTime
Definition GameObject.h:375
GameObjectData const * m_goData
Definition GameObject.h:395
int64 m_packedRotation
Definition GameObject.h:399
Position m_stationaryPosition
Definition GameObject.h:401
bool m_allowModifyDestructibleBuilding
Definition GameObject.h:397
uint32 m_cooldownTime
Definition GameObject.h:382
uint32 m_spellId
Definition GameObject.h:374
uint32 m_respawnDelayTime
Definition GameObject.h:376
void ResetLootMode()
Definition GameObject.h:233
uint32 m_despawnDelay
Definition GameObject.h:377
Seconds m_despawnRespawnTime
Definition GameObject.h:378
ObjectGuid::LowType m_lootRecipientGroup
Definition GameObject.h:404
GameObjectAI * m_AI
Definition GameObject.h:429
GameObjectModel * m_model
Definition GameObject.h:313
GameObjectTemplate const * m_goInfo
Definition GameObject.h:394
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition GameObject.h:393
uint32 m_groupLootTimer
Definition GameObject.h:255
uint32 lootingGroupLowGUID
Definition GameObject.h:256
bool m_spawnedByDefault
Definition GameObject.h:381
LootState m_lootState
Definition GameObject.h:380
Seconds m_restockTime
Definition GameObject.h:379
uint32 m_usetimes
Definition GameObject.h:388
uint32 m_lootGenerationTime
Definition GameObject.h:406
MovableMapObject()=default
uint16 m_objectType
Definition Object.h:253
uint16 m_valuesCount
Definition Object.h:267
uint16 m_updateFlag
Definition Object.h:256
TypeID m_objectTypeId
Definition Object.h:255
WorldObject()
Definition Object.cpp:1060
GameObject * sourceGameObject
Definition LootMgr.h:331
void Relocate(float x, float y)
Definition Position.h:77

References GAMEOBJECT_END, GO_NOT_READY, loot, lootingGroupLowGUID, m_allowModifyDestructibleBuilding, m_cooldownTime, m_despawnDelay, m_despawnRespawnTime, m_goData, m_goInfo, m_groupLootTimer, m_lootGenerationTime, m_lootRecipientGroup, m_lootState, Object::m_objectType, Object::m_objectTypeId, m_packedRotation, m_respawnDelayTime, m_respawnTime, m_restockTime, m_spawnedByDefault, m_spawnId, m_spellId, m_stationaryPosition, Object::m_updateFlag, m_usetimes, Object::m_valuesCount, Position::Relocate(), ResetLootMode(), Loot::sourceGameObject, TYPEID_GAMEOBJECT, TYPEMASK_GAMEOBJECT, UPDATEFLAG_LOWGUID, UPDATEFLAG_POSITION, UPDATEFLAG_ROTATION, and UPDATEFLAG_STATIONARY_POSITION.

Referenced by Create(), and MotionTransport::CreateGOPassenger().

◆ ~GameObject()

GameObject::~GameObject ( )
override
94{
95 delete m_AI;
96 delete m_model;
97 //if (m_uint32Values) // field array can be not exist if GameOBject not loaded
98 // CleanupsBeforeDelete();
99}

References m_AI, and m_model.

Member Function Documentation

◆ _IsWithinDist()

bool GameObject::_IsWithinDist ( WorldObject const *  obj,
float  dist2compare,
bool  ,
bool  ,
bool   
) const
inlineoverrideprivatevirtual

Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size.

Following check does check 3d distance

Reimplemented from WorldObject.

421 {
423 dist2compare += obj->GetObjectSize();
424 return IsInRange3d(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare);
425 }
bool IsInRange3d(float x, float y, float z, float radius) const
Definition GameObject.cpp:2181

References WorldObject::GetObjectSize(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), and IsInRange3d().

◆ ActivateToQuest()

bool GameObject::ActivateToQuest ( Player target) const
1312{
1313 if (target->HasQuestForGO(GetEntry()))
1314 return true;
1315
1316 if (!GetGOInfo()->IsGameObjectForQuests())
1317 return false;
1318
1319 switch (GetGoType())
1320 {
1322 {
1323 GameObject* go = const_cast<GameObject*>(this);
1324 QuestGiverStatus questStatus = target->GetQuestDialogStatus(go);
1325 if (questStatus > DIALOG_STATUS_UNAVAILABLE)
1326 return true;
1327 break;
1328 }
1330 {
1331 // scan GO chest with loot including quest items
1333 {
1334 //TODO: fix this hack
1335 //look for battlegroundAV for some objects which are only activated after mine gots captured by own team
1337 if (Battleground* bg = target->GetBattleground())
1338 if (bg->GetBgTypeID(true) == BATTLEGROUND_AV && !bg->ToBattlegroundAV()->PlayerCanDoMineQuest(GetEntry(), target->GetTeamId()))
1339 return false;
1340 return true;
1341 }
1342 break;
1343 }
1345 {
1346 if (GetGOInfo()->_generic.questID == -1 || target->GetQuestStatus(GetGOInfo()->_generic.questID) == QUEST_STATUS_INCOMPLETE)
1347 return true;
1348 break;
1349 }
1351 {
1352 if (GetGOInfo()->spellFocus.questID > 0 && target->GetQuestStatus(GetGOInfo()->spellFocus.questID) == QUEST_STATUS_INCOMPLETE)
1353 return true;
1354 break;
1355 }
1357 {
1358 if (GetGOInfo()->goober.questId == -1 || target->GetQuestStatus(GetGOInfo()->goober.questId) == QUEST_STATUS_INCOMPLETE)
1359 return true;
1360 break;
1361 }
1362 default:
1363 break;
1364 }
1365
1366 return false;
1367}
@ BG_AV_OBJECTID_MINE_N
Definition BattlegroundAV.h:156
@ BG_AV_OBJECTID_MINE_S
Definition BattlegroundAV.h:157
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
QuestGiverStatus
Definition QuestDef.h:111
@ DIALOG_STATUS_UNAVAILABLE
Definition QuestDef.h:113
@ QUEST_STATUS_INCOMPLETE
Definition QuestDef.h:103
@ GAMEOBJECT_TYPE_SPELL_FOCUS
Definition SharedDefines.h:1572
@ GAMEOBJECT_TYPE_GENERIC
Definition SharedDefines.h:1569
@ GAMEOBJECT_TYPE_CHEST
Definition SharedDefines.h:1567
@ GAMEOBJECT_TYPE_QUESTGIVER
Definition SharedDefines.h:1566
@ GAMEOBJECT_TYPE_GOOBER
Definition SharedDefines.h:1574
@ BATTLEGROUND_AV
Definition SharedDefines.h:3737
Definition Battleground.h:303
Definition GameObject.h:120
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:136
GameobjectTypes GetGoType() const
Definition GameObject.h:203
bool HaveQuestLootForPlayer(uint32 loot_id, Player const *player) const
Definition LootMgr.cpp:228
uint32 GetEntry() const
Definition Object.h:117
bool HasQuestForGO(int32 GOId) const
Definition Player.cpp:12636
TeamId GetTeamId(bool original=false) const
Definition Player.h:2138
QuestGiverStatus GetQuestDialogStatus(Object *questGiver)
Definition PlayerQuest.cpp:1654
Battleground * GetBattleground(bool create=false) const
Definition Player.cpp:12430
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1489
struct GameObjectTemplate::@236::@245 spellFocus
struct GameObjectTemplate::@236::@247 goober
int32 questID
Definition GameObjectData.h:111
uint32 questId
Definition GameObjectData.h:92
struct GameObjectTemplate::@236::@242 _generic

References GameObjectTemplate::_generic, BATTLEGROUND_AV, BG_AV_OBJECTID_MINE_N, BG_AV_OBJECTID_MINE_S, DIALOG_STATUS_UNAVAILABLE, GAMEOBJECT_TYPE_CHEST, GAMEOBJECT_TYPE_GENERIC, GAMEOBJECT_TYPE_GOOBER, GAMEOBJECT_TYPE_QUESTGIVER, GAMEOBJECT_TYPE_SPELL_FOCUS, Player::GetBattleground(), Object::GetEntry(), GetGOInfo(), GetGoType(), Player::GetQuestDialogStatus(), Player::GetQuestStatus(), Player::GetTeamId(), GameObjectTemplate::goober, Player::HasQuestForGO(), LootStore::HaveQuestLootForPlayer(), LootTemplates_Gameobject, QUEST_STATUS_INCOMPLETE, GameObjectTemplate::questId, GameObjectTemplate::questID, and GameObjectTemplate::spellFocus.

Referenced by BuildValuesUpdate().

◆ AddLootMode()

void GameObject::AddLootMode ( uint16  lootMode)
inline
231{ m_LootMode |= lootMode; }
uint16 m_LootMode
Definition GameObject.h:405

References m_LootMode.

◆ AddToSkillupList()

void GameObject::AddToSkillupList ( ObjectGuid const &  playerGuid)
3096{
3097 int32 timer = GetMap()->IsDungeon() ? -1 : 10 * MINUTE * IN_MILLISECONDS;
3098 m_SkillupList[playerGuid] = timer;
3099}
constexpr auto IN_MILLISECONDS
Definition Common.h:53
constexpr auto MINUTE
Definition Common.h:47
std::int32_t int32
Definition Define.h:103
std::unordered_map< ObjectGuid, int32 > m_SkillupList
Definition GameObject.h:384
bool IsDungeon() const
Definition Map.h:299
Map * GetMap() const
Definition Object.h:631

References WorldObject::GetMap(), IN_MILLISECONDS, Map::IsDungeon(), m_SkillupList, and MINUTE.

Referenced by Spell::EffectOpenLock().

◆ AddToWorld()

void GameObject::AddToWorld ( )
overridevirtual
  • Register the gameobject for guid lookup

Reimplemented from Object.

157{
159 if (!IsInWorld())
160 {
161 if (m_zoneScript)
163
165 if (m_spawnId)
166 GetMap()->GetGameObjectBySpawnIdStore().insert(std::make_pair(m_spawnId, this));
167
168 if (m_model)
169 {
172 }
173
174 EnableCollision(GetGoState() == GO_STATE_READY || IsTransport()); // pussywizard: this startOpen is unneeded here, collision depends entirely on GOState
175
177
179
180 sScriptMgr->OnGameObjectAddWorld(this);
181 }
182}
@ GO_STATE_READY
Definition GameObjectData.h:709
#define sScriptMgr
Definition ScriptMgr.h:743
bool UpdatePosition()
Definition GameObjectModel.cpp:246
GOState GetGoState() const
Definition GameObject.h:205
void EnableCollision(bool enable)
Definition GameObject.cpp:2630
bool IsTransport() const
Definition GameObject.cpp:1210
MapStoredObjectTypesContainer & GetObjectsStore()
Definition Map.h:358
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:364
void InsertGameObjectModel(GameObjectModel const &model)
Definition Map.h:405
bool IsInWorld() const
Definition Object.h:109
ObjectGuid GetGUID() const
Definition Object.h:115
bool Insert(KEY_TYPE const &handle, SPECIFIC_TYPE *obj)
Definition TypeContainer.h:177
void AddToWorld() override
Definition Object.cpp:1218
ZoneScript * m_zoneScript
Definition Object.h:748
virtual void OnGameObjectCreate(GameObject *)
Definition ZoneScript.h:37
ObjectGuid sourceWorldObjectGUID
Definition LootMgr.h:330

References WorldObject::AddToWorld(), EnableCollision(), Map::GetGameObjectBySpawnIdStore(), GetGoState(), Object::GetGUID(), WorldObject::GetMap(), Map::GetObjectsStore(), GO_STATE_READY, TypeUnorderedMapContainer< OBJECT_TYPES, KEY_TYPE >::Insert(), Map::InsertGameObjectModel(), Object::IsInWorld(), IsTransport(), loot, m_model, m_spawnId, WorldObject::m_zoneScript, ZoneScript::OnGameObjectCreate(), Loot::sourceWorldObjectGUID, sScriptMgr, and GameObjectModel::UpdatePosition().

Referenced by Map::AddToMap().

◆ AddUniqueUse()

void GameObject::AddUniqueUse ( Player player)
922{
923 AddUse();
924 m_unique_users.insert(player->GetGUID());
925}
void AddUse()
Definition GameObject.h:239
GuidSet m_unique_users
Definition GameObject.h:387
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114

References AddUse(), Object::GetGUID(), and m_unique_users.

Referenced by Spell::EffectTransmitted(), and Use().

◆ AddUse()

◆ AI()

◆ AIM_Initialize()

bool GameObject::AIM_Initialize ( )
protected
102{
103 if (m_AI)
104 delete m_AI;
105
107
108 if (!m_AI)
109 return false;
110
112 return true;
113}
virtual void InitializeAI()
Definition GameObjectAI.h:43
GameObjectAI * SelectGameObjectAI(GameObject *go)
Definition CreatureAISelector.cpp:102

References GameObjectAI::InitializeAI(), m_AI, and FactorySelector::SelectGameObjectAI().

Referenced by Create(), StaticTransport::Create(), MotionTransport::Update(), and Update().

◆ AllowSaveToDB()

◆ BuildValuesUpdate()

void GameObject::BuildValuesUpdate ( uint8  updateType,
ByteBuffer data,
Player target 
)
overridevirtual

Reimplemented from Object.

2767{
2768 if (!target)
2769 return;
2770
2772 bool targetIsGM = target->IsGameMaster() && target->GetSession()->IsGMAccount();
2773
2774 ByteBuffer fieldBuffer;
2775
2776 UpdateMask updateMask;
2777 updateMask.SetCount(m_valuesCount);
2778
2780 uint32 visibleFlag = UF_FLAG_PUBLIC;
2781 if (GetOwnerGUID() == target->GetGUID())
2782 visibleFlag |= UF_FLAG_OWNER;
2783
2784 for (uint16 index = 0; index < m_valuesCount; ++index)
2785 {
2786 if (_fieldNotifyFlags & flags[index] ||
2787 ((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)) ||
2788 (index == GAMEOBJECT_FLAGS && forcedFlags))
2789 {
2790 updateMask.SetBit(index);
2791
2792 if (index == GAMEOBJECT_DYNAMIC)
2793 {
2794 uint16 dynFlags = 0;
2795 int16 pathProgress = -1;
2796 switch (GetGoType())
2797 {
2799 if (ActivateToQuest(target))
2800 dynFlags |= GO_DYNFLAG_LO_ACTIVATE;
2801 break;
2804 if (ActivateToQuest(target))
2805 {
2806 dynFlags |= GO_DYNFLAG_LO_ACTIVATE;
2807 if (sWorld->getBoolConfig(CONFIG_OBJECT_SPARKLES))
2808 dynFlags |= GO_DYNFLAG_LO_SPARKLE;
2809 }
2810 else if (targetIsGM)
2811 dynFlags |= GO_DYNFLAG_LO_ACTIVATE;
2812 break;
2815 if (ActivateToQuest(target) && sWorld->getBoolConfig(CONFIG_OBJECT_SPARKLES))
2816 dynFlags |= GO_DYNFLAG_LO_SPARKLE;
2817 break;
2819 if (StaticTransport const* t = ToStaticTransport())
2820 if (t->GetPauseTime())
2821 {
2822 if (GetGoState() == GO_STATE_READY)
2823 {
2824 if (t->GetPathProgress() >= t->GetPauseTime()) // if not, send 100% progress
2825 pathProgress = int16(float(t->GetPathProgress() - t->GetPauseTime()) / float(t->GetPeriod() - t->GetPauseTime()) * 65535.0f);
2826 }
2827 else
2828 {
2829 if (t->GetPathProgress() <= t->GetPauseTime()) // if not, send 100% progress
2830 pathProgress = int16(float(t->GetPathProgress()) / float(t->GetPauseTime()) * 65535.0f);
2831 }
2832 }
2833 // else it's ignored
2834 break;
2836 if (MotionTransport const* t = ToMotionTransport())
2837 pathProgress = int16(float(t->GetPathProgress()) / float(t->GetPeriod()) * 65535.0f);
2838 break;
2839 default:
2840 break;
2841 }
2842
2843 fieldBuffer << uint16(dynFlags);
2844 fieldBuffer << int16(pathProgress);
2845 }
2846 else if (index == GAMEOBJECT_FLAGS)
2847 {
2850 {
2852 }
2853
2854 fieldBuffer << goFlags;
2855 }
2856 else
2857 fieldBuffer << m_uint32Values[index]; // other cases
2858 }
2859 }
2860
2861 *data << uint8(updateMask.GetBlockCount());
2862 updateMask.AppendToPacket(data);
2863 data->append(fieldBuffer);
2864}
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
std::uint16_t uint16
Definition Define.h:108
std::int16_t int16
Definition Define.h:104
@ GAMEOBJECT_TYPE_MO_TRANSPORT
Definition SharedDefines.h:1579
@ GAMEOBJECT_TYPE_TRANSPORT
Definition SharedDefines.h:1575
@ GO_DYNFLAG_LO_ACTIVATE
Definition SharedDefines.h:1622
@ GO_DYNFLAG_LO_SPARKLE
Definition SharedDefines.h:1625
@ GO_FLAG_NOT_SELECTABLE
Definition SharedDefines.h:1611
@ GO_FLAG_LOCKED
Definition SharedDefines.h:1608
@ UPDATETYPE_VALUES
Definition UpdateData.h:28
uint32 GameObjectUpdateFieldFlags[GAMEOBJECT_END]
Definition UpdateFieldFlags.cpp:1492
@ UF_FLAG_PUBLIC
Definition UpdateFieldFlags.h:27
@ UF_FLAG_OWNER
Definition UpdateFieldFlags.h:29
@ GAMEOBJECT_DYNAMIC
Definition UpdateFields.h:401
@ GAMEOBJECT_FLAGS
Definition UpdateFields.h:399
@ CONFIG_OBJECT_SPARKLES
Definition WorldConfig.h:139
Definition ByteBuffer.h:70
void append(T value)
Definition ByteBuffer.h:129
MotionTransport * ToMotionTransport()
Definition GameObject.h:328
bool HasLootRecipient() const
Definition GameObject.h:254
ObjectGuid GetOwnerGUID() const
Definition GameObject.h:174
bool ActivateToQuest(Player *target) const
Definition GameObject.cpp:1311
bool IsLootAllowedFor(Player const *player) const
Definition GameObject.cpp:2728
StaticTransport * ToStaticTransport()
Definition GameObject.h:325
Definition Transport.h:51
uint16 _fieldNotifyFlags
Definition Object.h:269
UpdateMask _changesMask
Definition Object.h:265
uint32 * m_uint32Values
Definition Object.h:261
WorldSession * GetSession() const
Definition Player.h:2030
bool IsGameMaster() const
Definition Player.h:1178
Definition Transport.h:120
Definition UpdateMask.h:25
uint32 GetBlockCount() const
Definition UpdateMask.h:62
bool GetBit(uint32 index) const
Definition UpdateMask.h:47
void SetCount(uint32 valuesCount)
Definition UpdateMask.h:65
void SetBit(uint32 index)
Definition UpdateMask.h:45
void AppendToPacket(ByteBuffer *data)
Definition UpdateMask.h:49
bool IsGMAccount() const
Definition WorldSession.cpp:215
#define sWorld
Definition World.h:318
uint32 groupLootRules
Definition GameObjectData.h:99
struct GameObjectTemplate::@236::@241 chest

References Object::_changesMask, Object::_fieldNotifyFlags, ActivateToQuest(), ByteBuffer::append(), UpdateMask::AppendToPacket(), GameObjectTemplate::chest, CONFIG_OBJECT_SPARKLES, GAMEOBJECT_DYNAMIC, GAMEOBJECT_FLAGS, GAMEOBJECT_TYPE_CHEST, GAMEOBJECT_TYPE_GENERIC, GAMEOBJECT_TYPE_GOOBER, GAMEOBJECT_TYPE_MO_TRANSPORT, GAMEOBJECT_TYPE_QUESTGIVER, GAMEOBJECT_TYPE_SPELL_FOCUS, GAMEOBJECT_TYPE_TRANSPORT, GameObjectUpdateFieldFlags, UpdateMask::GetBit(), UpdateMask::GetBlockCount(), GetGOInfo(), GetGoState(), GetGoType(), Object::GetGUID(), GetOwnerGUID(), Player::GetSession(), GO_DYNFLAG_LO_ACTIVATE, GO_DYNFLAG_LO_SPARKLE, GO_FLAG_LOCKED, GO_FLAG_NOT_SELECTABLE, GO_STATE_READY, GameObjectTemplate::groupLootRules, HasLootRecipient(), Player::IsGameMaster(), WorldSession::IsGMAccount(), IsLootAllowedFor(), Object::m_uint32Values, Object::m_valuesCount, UpdateMask::SetBit(), UpdateMask::SetCount(), sWorld, ToMotionTransport(), ToStaticTransport(), UF_FLAG_OWNER, UF_FLAG_PUBLIC, and UPDATETYPE_VALUES.

◆ CastSpell()

void GameObject::CastSpell ( Unit target,
uint32  spell 
)
2084{
2085 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
2086 if (!spellInfo)
2087 return;
2088
2089 bool self = true;
2090 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2091 {
2092 if (spellInfo->Effects[i].TargetA.GetReferenceType() != TARGET_REFERENCE_TYPE_CASTER || spellInfo->Effects[i].TargetB.GetTarget())
2093 {
2094 self = false;
2095 break;
2096 }
2097 }
2098
2099 if (self && target && target->GetGUID() != GetGUID())
2100 {
2101 target->CastSpell(target, spellInfo, true);
2102 return;
2103 }
2104
2105 //summon world trigger
2106 Creature* trigger = SummonTrigger(GetPositionX(), GetPositionY(), GetPositionZ(), 0, spellInfo->CalcCastTime() + 2000, true);
2107 if (!trigger)
2108 return;
2109
2110 if (Unit* owner = GetOwner())
2111 {
2112 trigger->SetLevel(owner->GetLevel(), false);
2113 trigger->SetFaction(owner->GetFaction());
2114 // needed for GO casts for proper target validation checks
2115 trigger->SetOwnerGUID(owner->GetGUID());
2116 // xinef: fixes some duel bugs with traps]
2117 if (owner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
2119 if (owner->IsFFAPvP())
2120 {
2122 {
2123 sScriptMgr->OnFfaPvpStateUpdate(trigger, true);
2125 }
2126
2127 }
2128 // xinef: Remove Immunity flags
2129 trigger->SetImmuneToNPC(false);
2130 // xinef: set proper orientation, fixes cast against stealthed targets
2131 if (target)
2132 trigger->SetInFront(target);
2133 trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, owner->GetGUID());
2134 }
2135 else
2136 {
2137 // xinef: set faction of gameobject, if no faction - assume hostile
2138 trigger->SetFaction(GetTemplateAddon() && GetTemplateAddon()->faction ? GetTemplateAddon()->faction : 14);
2139 // Set owner guid for target if no owner availble - needed by trigger auras
2140 // - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell())
2141 // xinef: set proper orientation, fixes cast against stealthed targets
2142 if (target)
2143 trigger->SetInFront(target);
2144 trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, target ? target->GetGUID() : ObjectGuid::Empty);
2145 }
2146}
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1637
@ TARGET_REFERENCE_TYPE_CASTER
Definition SpellInfo.h:90
#define sSpellMgr
Definition SpellMgr.h:847
@ UNIT_BYTE2_FLAG_FFA_PVP
Definition UnitDefines.h:141
@ UNIT_FLAG_PLAYER_CONTROLLED
Definition UnitDefines.h:260
@ UNIT_FIELD_BYTES_2
Definition UpdateFields.h:161
Definition Creature.h:47
Unit * GetOwner() const
Definition GameObject.cpp:1222
GameObjectTemplateAddon const * GetTemplateAddon() const
Definition GameObject.cpp:906
Definition ObjectGuid.h:121
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
Definition Object.cpp:935
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition Object.cpp:897
Definition SpellInfo.h:340
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:417
uint32 CalcCastTime(Unit *caster=nullptr, Spell *spell=nullptr) const
Definition SpellInfo.cpp:2752
Definition Unit.h:665
void SetFaction(uint32 faction)
Definition Unit.cpp:7117
void SetImmuneToNPC(bool apply, bool keepCombat=false)
Definition Unit.cpp:10652
void SetLevel(uint8 lvl, bool showLevelChange=true)
Definition Unit.cpp:12334
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:1361
void SetOwnerGUID(ObjectGuid owner)
Definition Unit.cpp:7719
void SetUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition Unit.h:749
void SetInFront(WorldObject const *target)
Definition Unit.cpp:16449
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition Object.cpp:2497
float GetPositionZ() const
Definition Position.h:123
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122

References SpellInfo::CalcCastTime(), Unit::CastSpell(), SpellInfo::Effects, ObjectGuid::Empty, GameObjectTemplateAddon::faction, Object::GetGUID(), Object::GetGUID(), GetOwner(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), GetTemplateAddon(), Object::HasByteFlag(), MAX_SPELL_EFFECTS, Object::SetByteFlag(), Unit::SetFaction(), Unit::SetImmuneToNPC(), Unit::SetInFront(), Unit::SetLevel(), Unit::SetOwnerGUID(), Unit::SetUnitFlag(), sScriptMgr, sSpellMgr, WorldObject::SummonTrigger(), TARGET_REFERENCE_TYPE_CASTER, UNIT_BYTE2_FLAG_FFA_PVP, UNIT_FIELD_BYTES_2, and UNIT_FLAG_PLAYER_CONTROLLED.

Referenced by npc_midsummer_ribbon_pole_target::DoFlameCircleChecks(), go_empowering_blood_orb::GossipHello(), instance_onyxias_lair::instance_onyxias_lair_InstanceMapScript::OnGameObjectCreate(), SmartScript::ProcessAction(), go_direbrew_mole_machine::go_direbrew_mole_machineAI::Reset(), go_empowering_blood_orb::SetGUID(), npc_deaths_door_fell_cannon_target_bunny::npc_deaths_door_fell_cannon_target_bunnyAI::SpellHit(), Update(), go_suppression_device::UpdateAI(), go_witherbark_totem_bundle::go_witherbark_totem_bundleAI::UpdateAI(), and Use().

◆ CheckRitualList()

void GameObject::CheckRitualList ( )
private
218{
219 if (m_unique_users.empty())
220 return;
221
223 if (!animSpell)
224 animSpell = GetSpellId();
225
226 for (GuidSet::iterator itr = m_unique_users.begin(); itr != m_unique_users.end();)
227 {
228 if (*itr == GetOwnerGUID())
229 {
230 ++itr;
231 continue;
232 }
233
234 bool erase = true;
235 if (Player* channeler = ObjectAccessor::GetPlayer(*this, *itr))
236 if (Spell* spell = channeler->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
237 if (spell->m_spellInfo->Id == animSpell)
238 erase = false;
239
240 if (erase)
241 m_unique_users.erase(itr++);
242 else
243 ++itr;
244 }
245}
@ CURRENT_CHANNELED_SPELL
Definition Unit.h:558
uint32 GetSpellId() const
Definition GameObject.h:182
Definition Player.h:1086
Definition Spell.h:298
Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:244
struct GameObjectTemplate::@236::@252 summoningRitual
uint32 animSpell
Definition GameObjectData.h:234

References GameObjectTemplate::animSpell, CURRENT_CHANNELED_SPELL, GetGOInfo(), GetOwnerGUID(), ObjectAccessor::GetPlayer(), GetSpellId(), m_unique_users, and GameObjectTemplate::summoningRitual.

Referenced by Update(), and Use().

◆ CleanupsBeforeDelete()

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

Reimplemented from WorldObject.

Reimplemented in MotionTransport, and StaticTransport.

121{
122 if (GetTransport() && !ToTransport())
123 {
125 SetTransport(nullptr);
128 }
129
130 if (IsInWorld())
132
133 if (m_uint32Values) // field array can be not exist if GameOBject not loaded
135}
@ MOVEMENTFLAG_ONTRANSPORT
Definition UnitDefines.h:381
void RemoveFromWorld() override
Definition GameObject.cpp:184
void RemoveFromOwner()
Definition GameObject.cpp:137
Transport * ToTransport()
Definition GameObject.h:322
virtual void RemovePassenger(WorldObject *passenger, bool withAll=false)=0
void SetTransport(Transport *t)
Definition Object.h:702
Transport * GetTransport() const
Definition Object.h:694
MovementInfo m_movementInfo
Definition Object.h:704
void Reset()
Definition Object.h:300
void RemoveMovementFlag(uint32 flag)
Definition Object.h:346
struct MovementInfo::TransportInfo transport

References WorldObject::GetTransport(), Object::IsInWorld(), WorldObject::m_movementInfo, Object::m_uint32Values, MOVEMENTFLAG_ONTRANSPORT, RemoveFromOwner(), RemoveFromWorld(), MovementInfo::RemoveMovementFlag(), Transport::RemovePassenger(), MovementInfo::TransportInfo::Reset(), WorldObject::SetTransport(), ToTransport(), and MovementInfo::transport.

Referenced by MotionTransport::CleanupsBeforeDelete(), and StaticTransport::CleanupsBeforeDelete().

◆ ClearRitualList()

void GameObject::ClearRitualList ( )
private
248{
249 if (m_unique_users.empty())
250 return;
251
253 if (!animSpell)
254 animSpell = GetSpellId();
255
256 for (ObjectGuid const& guid : m_unique_users)
257 {
258 if (Player* channeler = ObjectAccessor::GetPlayer(*this, guid))
259 if (Spell* spell = channeler->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
260 if (spell->m_spellInfo->Id == animSpell)
261 {
262 spell->SendChannelUpdate(0);
263 spell->finish();
264 }
265 }
266
267 m_unique_users.clear();
268}

References GameObjectTemplate::animSpell, CURRENT_CHANNELED_SPELL, GetGOInfo(), ObjectAccessor::GetPlayer(), GetSpellId(), m_unique_users, and GameObjectTemplate::summoningRitual.

Referenced by Delete(), and Update().

◆ Create()

bool GameObject::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 
)
virtual

Reimplemented in StaticTransport.

271{
272 ASSERT(map);
273 SetMap(map);
274
275 Relocate(x, y, z, ang);
276 m_stationaryPosition.Relocate(x, y, z, ang);
277 if (!IsPositionValid())
278 {
279 LOG_ERROR("entities.gameobject", "Gameobject (GUID: {} Entry: {}) not created. Suggested coordinates isn't valid (X: {} Y: {})", guidlow, name_id, x, y);
280 return false;
281 }
282
283 SetPhaseMask(phaseMask, false);
284
286
288 if (m_zoneScript)
289 {
290 name_id = m_zoneScript->GetGameObjectEntry(guidlow, name_id);
291 if (!name_id)
292 return false;
293 }
294
295 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(name_id);
296 if (!goinfo)
297 {
298 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry: {}) not created: non-existing entry in `gameobject_template`. Map: {} (X: {} Y: {} Z: {})", guidlow, name_id, map->GetId(), x, y, z);
299 return false;
300 }
301
302 Object::_Create(guidlow, goinfo->entry, HighGuid::GameObject);
303
304 m_goInfo = goinfo;
305
306 if (goinfo->type >= MAX_GAMEOBJECT_TYPE)
307 {
308 LOG_ERROR("sql.sql", "Gameobject (GUID: {} Entry: {}) not created: non-existing GO type '{}' in `gameobject_template`. It will crash client if created.", guidlow, name_id, goinfo->type);
309 return false;
310 }
311
312 SetWorldRotation(rotation);
313
314 GameObjectAddon const* gameObjectAddon = sObjectMgr->GetGameObjectAddon(GetSpawnId());
315 QuaternionData parentRotation;
316 if (gameObjectAddon)
317 parentRotation = gameObjectAddon->ParentRotation;
318
319 SetTransportPathRotation(parentRotation.x, parentRotation.y, parentRotation.z, parentRotation.w);
320
321 SetObjectScale(goinfo->size);
322
323 if (GameObjectTemplateAddon const* templateAddon = GetTemplateAddon())
324 {
325 SetUInt32Value(GAMEOBJECT_FACTION, templateAddon->faction);
326 ReplaceAllGameObjectFlags((GameObjectFlags)templateAddon->flags);
327 }
328
329 SetEntry(goinfo->entry);
330
331 // set name for logs usage, doesn't affect anything ingame
332 SetName(goinfo->name);
333
334 // GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
336
338 {
339 if (InstanceScript* instance = GetInstanceScript())
340 {
341 switch (uint8 state = instance->GetStoredGameObjectState(GetSpawnId()))
342 {
343 case 0:
345 SwitchDoorOrButton(true);
346 break;
347 case 1:
348 case 2:
349 SetGoState((GOState)state);
350 break;
351 default:
352 SetGoState(go_state);
353 break;
354 }
355 }
356 }
357 else
358 {
359 SetGoState(go_state);
360 }
361
362 SetGoArtKit(artKit);
363
364 SetDisplayId(goinfo->displayId);
365
366 if (!m_model)
368
369 switch (goinfo->type)
370 {
372 SetGoAnimProgress(animprogress);
374 break;
379 break;
382 break;
384 if (GetGOInfo()->trap.stealthed)
385 {
388 }
389
390 if (GetGOInfo()->trap.invisible)
391 {
394 }
395 break;
396 default:
397 SetGoAnimProgress(animprogress);
398 break;
399 }
400
401 if (gameObjectAddon)
402 {
403 if (gameObjectAddon->InvisibilityValue)
404 {
405 m_invisibility.AddFlag(gameObjectAddon->invisibilityType);
406 m_invisibility.AddValue(gameObjectAddon->invisibilityType, gameObjectAddon->InvisibilityValue);
407 }
408 }
409
412
413 if (uint32 linkedEntry = GetGOInfo()->GetLinkedGameObjectEntry())
414 {
415 GameObject* linkedGO = new GameObject();
416 if (linkedGO->Create(map->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, map, phaseMask, x, y, z, ang, rotation, 255, GO_STATE_READY))
417 {
418 SetLinkedTrap(linkedGO);
419 map->AddToMap(linkedGO);
420 }
421 else
422 {
423 delete linkedGO;
424 }
425 }
426
427 // Check if GameObject is Large
428 if (goinfo->IsLargeGameObject())
430
431 // Check if GameObject is Infinite
432 if (goinfo->IsInfiniteGameObject())
434
435 return true;
436}
#define ASSERT
Definition Errors.h:68
GOState
Definition GameObjectData.h:707
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
#define sObjectMgr
Definition ObjectMgr.h:1730
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
GameobjectTypes
Definition SharedDefines.h:1563
@ GAMEOBJECT_TYPE_TRAP
Definition SharedDefines.h:1570
@ GAMEOBJECT_TYPE_FISHINGHOLE
Definition SharedDefines.h:1589
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition SharedDefines.h:1581
@ GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING
Definition SharedDefines.h:1597
@ STEALTH_TRAP
Definition SharedDefines.h:1236
@ INVISIBILITY_TRAP
Definition SharedDefines.h:1246
#define MAX_GAMEOBJECT_TYPE
Definition SharedDefines.h:1602
GameObjectFlags
Definition SharedDefines.h:1606
@ GAMEOBJECT_FACTION
Definition UpdateFields.h:402
void AddFlag(FLAG_TYPE flag)
Definition Object.h:395
void AddValue(FLAG_TYPE flag, T_VALUES value)
Definition Object.h:400
GameObject()
Definition GameObject.cpp:57
void SetGoState(GOState state)
Definition GameObject.cpp:2503
void SetTransportPathRotation(float qx, float qy, float qz, float qw)
Definition GameObject.cpp:2273
void SetGoArtKit(uint8 artkit)
Definition GameObject.cpp:1427
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition GameObject.cpp:2622
void SetGoAnimProgress(uint8 animprogress)
Definition GameObject.h:210
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)
Definition GameObject.cpp:270
GameObjectModel * CreateModel()
Definition GameObject.cpp:2983
void SetGoType(GameobjectTypes type)
Definition GameObject.h:204
void SetLinkedTrap(GameObject *linkedTrap)
Definition GameObject.h:261
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:144
bool AIM_Initialize()
Definition GameObject.cpp:101
virtual uint32 GetScriptId() const
Definition GameObject.cpp:2220
void SetDisplayId(uint32 displayid)
Definition GameObject.cpp:2616
void ReplaceAllGameObjectFlags(GameObjectFlags flags)
Definition GameObject.h:220
bool IsInstanceGameobject() const
Definition GameObject.cpp:2539
void SwitchDoorOrButton(bool activate, bool alternative=false)
Definition GameObject.cpp:1450
void SetWorldRotation(G3D::Quat const &rot)
Definition GameObject.cpp:2261
Definition InstanceScript.h:143
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:528
uint32 GetId() const
Definition Map.h:234
bool AddToMap(T *, bool checkTransport=false)
Definition Map.cpp:307
void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
Definition Object.cpp:123
void SetEntry(uint32 entry)
Definition Object.h:118
virtual void SetObjectScale(float scale)
Definition Object.h:121
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:643
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1242
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibility
Definition Object.h:620
uint32 LastUsedScriptID
Definition Object.h:691
void SetName(std::string const &newname)
Definition Object.h:530
void SetZoneScript()
Definition Object.cpp:2426
virtual void SetMap(Map *map)
Definition Object.cpp:2191
void UpdatePositionData()
Definition Object.cpp:1183
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPES > m_stealth
Definition Object.h:617
void SetVisibilityDistanceOverride(VisibilityDistanceType type)
Definition Object.cpp:1112
virtual uint32 GetGameObjectEntry(ObjectGuid::LowType, uint32 entry)
Definition ZoneScript.h:32
Definition GameObjectData.h:699
QuaternionData ParentRotation
Definition GameObjectData.h:700
uint32 InvisibilityValue
Definition GameObjectData.h:702
InvisibilityType invisibilityType
Definition GameObjectData.h:701
Definition GameObjectData.h:667
Definition GameObjectData.h:32
uint32 intactNumHits
Definition GameObjectData.h:352
uint32 stealthed
Definition GameObjectData.h:125
uint32 type
Definition GameObjectData.h:34
uint32 entry
Definition GameObjectData.h:33
bool IsLargeGameObject() const
Definition GameObjectData.h:594
bool IsInfiniteGameObject() const
Definition GameObjectData.h:619
uint32 minSuccessOpens
Definition GameObjectData.h:88
uint32 invisible
Definition GameObjectData.h:127
uint32 damagedNumHits
Definition GameObjectData.h:357
struct GameObjectTemplate::@236::@264 building
std::string name
Definition GameObjectData.h:36
uint32 maxSuccessOpens
Definition GameObjectData.h:89
float size
Definition GameObjectData.h:40
uint32 displayId
Definition GameObjectData.h:35
bool IsPositionValid() const
Definition Position.cpp:183
Definition GameObjectData.h:683
float w
Definition GameObjectData.h:687
float z
Definition GameObjectData.h:686
float y
Definition GameObjectData.h:685
float x
Definition GameObjectData.h:684
uint32 MaxOpens
Definition GameObject.h:60
struct GameObjectValue::@233 FishingHole
uint32 MaxHealth
Definition GameObject.h:71
struct GameObjectValue::@235 Building
uint32 Health
Definition GameObject.h:70

References Object::_Create(), FlaggedValuesArray32< T_VALUES, T_FLAGS, FLAG_TYPE, ARRAY_SIZE >::AddFlag(), Map::AddToMap(), FlaggedValuesArray32< T_VALUES, T_FLAGS, FLAG_TYPE, ARRAY_SIZE >::AddValue(), AIM_Initialize(), ASSERT, GameObjectValue::Building, GameObjectTemplate::building, Create(), CreateModel(), GameObjectTemplate::damagedNumHits, GameObjectTemplate::displayId, GameObjectTemplate::entry, GameObjectValue::FishingHole, GameObject(), GameObject, GAMEOBJECT_FACTION, GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING, GAMEOBJECT_TYPE_FISHINGHOLE, GAMEOBJECT_TYPE_FISHINGNODE, GAMEOBJECT_TYPE_TRAP, Map::GenerateLowGuid(), ZoneScript::GetGameObjectEntry(), GetGOInfo(), Map::GetId(), WorldObject::GetInstanceScript(), GetScriptId(), GetSpawnId(), GetTemplateAddon(), GO_STATE_READY, GameObjectValue::Health, Infinite, GameObjectTemplate::intactNumHits, INVISIBILITY_TRAP, GameObjectAddon::invisibilityType, GameObjectAddon::InvisibilityValue, GameObjectTemplate::invisible, GameObjectTemplate::IsInfiniteGameObject(), IsInstanceGameobject(), GameObjectTemplate::IsLargeGameObject(), Position::IsPositionValid(), Large, WorldObject::LastUsedScriptID, LOG_ERROR, m_goInfo, m_goValue, WorldObject::m_invisibility, m_model, m_stationaryPosition, WorldObject::m_stealth, WorldObject::m_zoneScript, MAX_GAMEOBJECT_TYPE, GameObjectValue::MaxHealth, GameObjectValue::MaxOpens, GameObjectTemplate::maxSuccessOpens, GameObjectTemplate::minSuccessOpens, GameObjectTemplate::name, GameObjectAddon::ParentRotation, Position::Relocate(), ReplaceAllGameObjectFlags(), SetDisplayId(), Object::SetEntry(), SetGoAnimProgress(), SetGoArtKit(), SetGoState(), SetGoType(), SetLinkedTrap(), WorldObject::SetMap(), WorldObject::SetName(), Object::SetObjectScale(), SetPhaseMask(), SetTransportPathRotation(), Object::SetUInt32Value(), WorldObject::SetVisibilityDistanceOverride(), SetWorldRotation(), WorldObject::SetZoneScript(), GameObjectTemplate::size, sObjectMgr, STEALTH_TRAP, GameObjectTemplate::stealthed, SwitchDoorOrButton(), GameObjectTemplate::type, WorldObject::UpdatePositionData(), urand(), QuaternionData::w, QuaternionData::x, QuaternionData::y, and QuaternionData::z.

Referenced by Battleground::AddObject(), Create(), Spell::EffectDuel(), Spell::EffectSummonObject(), Spell::EffectSummonObjectWild(), Spell::EffectTransmitted(), OutdoorPvPSI::HandleDropFlag(), gobject_commandscript::HandleGameObjectAddCommand(), LoadGameObjectFromDB(), Battlefield::SpawnGameObject(), Map::SummonGameObject(), and WorldObject::SummonGameObject().

◆ CreateModel()

GameObjectModel * GameObject::CreateModel ( )
protected
2984{
2985 return GameObjectModel::Create(std::make_unique<GameObjectModelOwnerImpl>(this), sWorld->GetDataPath());
2986}
static GameObjectModel * Create(std::unique_ptr< GameObjectModelOwnerBase > modelOwner, std::string const &dataPath)
Definition GameObjectModel.cpp:161

References GameObjectModel::Create(), and sWorld.

Referenced by Create(), StaticTransport::Create(), MotionTransport::CreateMoTrans(), and UpdateModel().

◆ Delete()

void GameObject::Delete ( )
977{
980
982
984
985 if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
987
988 // Xinef: if ritual gameobject is removed, clear anim spells
991
992 uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<GameObject>(m_spawnId) : 0;
993 if (poolid)
994 sPoolMgr->UpdatePool<GameObject>(GetMap()->GetPoolData(), poolid, m_spawnId);
995 else
997}
#define sPoolMgr
Definition PoolMgr.h:216
@ GAMEOBJECT_TYPE_SUMMONING_RITUAL
Definition SharedDefines.h:1582
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2468
void ClearRitualList()
Definition GameObject.cpp:247
SpawnedPoolData & GetPoolData()
Definition Map.h:384
void AddObjectToRemoveList()
Definition Object.cpp:2227
void SendObjectDeSpawnAnim(ObjectGuid guid)
Definition Object.cpp:2184

References WorldObject::AddObjectToRemoveList(), ClearRitualList(), GAMEOBJECT_TYPE_SUMMONING_RITUAL, GetGOInfo(), Object::GetGUID(), WorldObject::GetMap(), Map::GetPoolData(), GetTemplateAddon(), GO_NOT_READY, GO_STATE_READY, m_spawnId, RemoveFromOwner(), ReplaceAllGameObjectFlags(), WorldObject::SendObjectDeSpawnAnim(), SetGoState(), SetLootState(), and sPoolMgr.

Referenced by MotionTransport::DelayedTeleportTransport(), OPvPCapturePoint::DelCapturePoint(), OPvPCapturePoint::DelObject(), npc_overlord_drakuru_betrayal::DoAction(), go_ahune_ice_stone::GossipSelect(), OutdoorPvPSI::HandleCustomSpell(), go_empowering_blood_orb::HandleObjectUse(), instance_razorfen_downs::instance_razorfen_downs_InstanceMapScript::OnGameObjectCreate(), Unit::RemoveAllGameObjects(), Unit::RemoveGameObject(), go_razorscale_mole_machine::go_razorscale_mole_machineAI::Reset(), Update(), go_blood_drenched_door::go_blood_drenched_doorAI::UpdateAI(), go_celestial_planetarium_access::go_celestial_planetarium_accessAI::UpdateAI(), and Use().

◆ DeleteFromDB()

void GameObject::DeleteFromDB ( )
1172{
1174 sObjectMgr->DeleteGOData(m_spawnId);
1175
1177 stmt->SetData(0, m_spawnId);
1178 WorldDatabase.Execute(stmt);
1179
1180 stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_EVENT_GAMEOBJECT);
1181 stmt->SetData(0, m_spawnId);
1182 WorldDatabase.Execute(stmt);
1183}
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
@ WORLD_DEL_EVENT_GAMEOBJECT
Definition WorldDatabase.h:39
@ WORLD_DEL_GAMEOBJECT
Definition WorldDatabase.h:38
void RemoveGORespawnTime(ObjectGuid::LowType dbGuid)
Definition Map.cpp:2523
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157

References WorldObject::GetMap(), m_spawnId, Map::RemoveGORespawnTime(), PreparedStatementBase::SetData(), sObjectMgr, WORLD_DEL_EVENT_GAMEOBJECT, WORLD_DEL_GAMEOBJECT, and WorldDatabase.

◆ DespawnOrUnsummon()

void GameObject::DespawnOrUnsummon ( Milliseconds  delay = 0ms,
Seconds  forcedRespawnTime = 0s 
)
928{
929 if (delay > 0ms)
930 {
931 if (!m_despawnDelay || m_despawnDelay > delay.count())
932 {
933 m_despawnDelay = delay.count();
934 m_despawnRespawnTime = forceRespawnTime;
935 }
936 }
937 else
938 {
939 if (m_goData)
940 {
941 int32 const respawnDelay = (forceRespawnTime > 0s) ? forceRespawnTime.count() : m_goData->spawntimesecs;
942 SetRespawnTime(respawnDelay);
943 }
944
945 // Respawn is handled by the gameobject itself.
946 // If we delete it from world, it simply never respawns...
947 // Uncomment this and remove the following lines if dynamic spawn is implemented.
948 // Delete();
949 {
953
954 if (GameObject* trap = GetLinkedTrap())
955 {
956 trap->DespawnOrUnsummon();
957 }
958
959 if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
960 {
962 }
963
964 uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<GameObject>(m_spawnId) : 0;
965
966 // Keep the current pooled gameobject reserved until its respawn timer expires.
967 // GameObject::Update() will update the pool when the object is ready to respawn.
968 if (poolid && !m_respawnTime)
969 {
970 sPoolMgr->UpdatePool<GameObject>(GetMap()->GetPoolData(), poolid, m_spawnId);
971 }
972 }
973 }
974}
@ GO_JUST_DEACTIVATED
Definition GameObject.h:113
GameObject * GetLinkedTrap()
Definition GameObject.cpp:2761
void SetRespawnTime(int32 respawn)
Definition GameObject.cpp:1287
int32 spawntimesecs
Definition GameObjectData.h:719

References Object::GetGUID(), GetLinkedTrap(), WorldObject::GetMap(), Map::GetPoolData(), GetTemplateAddon(), GO_JUST_DEACTIVATED, GO_STATE_READY, m_despawnDelay, m_despawnRespawnTime, m_goData, m_respawnTime, m_spawnId, ReplaceAllGameObjectFlags(), WorldObject::SendObjectDeSpawnAnim(), SetGoState(), SetLootState(), SetRespawnTime(), GameObjectData::spawntimesecs, and sPoolMgr.

Referenced by Spell::EffectActivateObject(), instance_deadmines::instance_deadmines_InstanceMapScript::OnGameObjectCreate(), instance_molten_core::OnGameObjectCreate(), instance_hyjal::instance_mount_hyjal_InstanceMapScript::OnGameObjectCreate(), instance_temple_of_ahnqiraj::instance_temple_of_ahnqiraj_InstanceMapScript::OnGameObjectCreate(), go_strange_pool::OnGossipHello(), go_southfury_moonstone::OnGossipHello(), go_ancient_skull_pile::OnGossipSelect(), SmartScript::ProcessAction(), go_ahune_ice_spear::Reset(), go_skull_pile::SendActionMenu(), go_firework_show::SpawnNextFirework(), npc_midsummer_bonfire::StampOut(), and Update().

◆ EnableCollision()

void GameObject::EnableCollision ( bool  enable)
2631{
2632 if (!m_model)
2633 return;
2634
2635 /*if (enable && !GetMap()->ContainsGameObjectModel(*m_model))
2636 GetMap()->InsertGameObjectModel(*m_model);*/
2637
2638 uint32 phaseMask = 0;
2639 if (enable && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_GO_LOS, GetEntry(), nullptr))
2640 phaseMask = GetPhaseMask();
2641
2642 m_model->enable(phaseMask);
2643}
#define sDisableMgr
Definition DisableMgr.h:88
@ DISABLE_TYPE_GO_LOS
Definition DisableMgr.h:35
void enable(uint32 ph_mask)
Definition GameObjectModel.h:69
uint32 GetPhaseMask() const
Definition Object.h:517

References DISABLE_TYPE_GO_LOS, GameObjectModel::enable(), Object::GetEntry(), WorldObject::GetPhaseMask(), m_model, and sDisableMgr.

Referenced by AddToWorld(), instance_eye_of_eternity::OnGameObjectCreate(), instance_ulduar::instance_ulduar_InstanceMapScript::OnGameObjectCreate(), SetDestructibleState(), SetGoState(), and SetPhaseMask().

◆ EventInform()

void GameObject::EventInform ( uint32  eventId)
2209{
2210 if (!eventId)
2211 return;
2212
2213 if (AI())
2214 AI()->EventInform(eventId);
2215
2216 if (m_zoneScript)
2217 m_zoneScript->ProcessEvent(this, eventId);
2218}
virtual void EventInform(uint32)
Definition GameObjectAI.h:65
GameObjectAI * AI() const
Definition GameObject.h:307
virtual void ProcessEvent(WorldObject *, uint32)
Definition ZoneScript.h:54

References AI(), GameObjectAI::EventInform(), WorldObject::m_zoneScript, and ZoneScript::ProcessEvent().

Referenced by MotionTransport::DoEventIfAny(), SetDestructibleState(), and Use().

◆ GameobjectStateToInt()

uint8 GameObject::GameobjectStateToInt ( GOState state) const
2574{
2575 uint8 m_state = 3;
2576
2577 if (state)
2578 {
2579 switch (*state)
2580 {
2581 case GO_STATE_ACTIVE:
2582 m_state = 0;
2583 return m_state;
2584 case GO_STATE_READY:
2585 m_state = 1;
2586 return m_state;
2588 m_state = 2;
2589 return m_state;
2590 }
2591 }
2592
2593 // Returning any value that is not one of the specified ones
2594 // Which will default into the invalid part of the switch
2595 return m_state;
2596}
@ GO_STATE_ACTIVE
Definition GameObjectData.h:708
@ GO_STATE_ACTIVE_ALTERNATIVE
Definition GameObjectData.h:710

References GO_STATE_ACTIVE, GO_STATE_ACTIVE_ALTERNATIVE, and GO_STATE_READY.

Referenced by SaveStateToDB().

◆ GetAIName()

std::string const & GameObject::GetAIName ( ) const
116{
117 return sObjectMgr->GetGameObjectTemplate(GetEntry())->AIName;
118}

References Object::GetEntry(), and sObjectMgr.

Referenced by GetDebugInfo().

◆ GetDebugInfo()

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

Reimplemented from Object.

Reimplemented in MotionTransport.

3115{
3116 std::stringstream sstr;
3117 sstr << WorldObject::GetDebugInfo() << "\n"
3118 << "SpawnId: " << GetSpawnId() << " GoState: " << std::to_string(GetGoState()) << " ScriptId: " << GetScriptId() << " AIName: " << GetAIName();
3119 return sstr.str();
3120}
std::string const & GetAIName() const
Definition GameObject.cpp:115
std::string GetDebugInfo() const override
Definition Object.cpp:2591

References GetAIName(), WorldObject::GetDebugInfo(), GetGoState(), GetScriptId(), and GetSpawnId().

Referenced by MotionTransport::GetDebugInfo().

◆ GetDestructibleState()

GameObjectDestructibleState GameObject::GetDestructibleState ( ) const
inline
296 {
302 }
@ GO_FLAG_DESTROYED
Definition SharedDefines.h:1615
@ GO_FLAG_DAMAGED
Definition SharedDefines.h:1614
@ GO_DESTRUCTIBLE_DESTROYED
Definition SharedDefines.h:1633
@ GO_DESTRUCTIBLE_INTACT
Definition SharedDefines.h:1631
@ GO_DESTRUCTIBLE_DAMAGED
Definition SharedDefines.h:1632
bool HasGameObjectFlag(GameObjectFlags flags) const
Definition GameObject.h:217

References GO_DESTRUCTIBLE_DAMAGED, GO_DESTRUCTIBLE_DESTROYED, GO_DESTRUCTIBLE_INTACT, GO_FLAG_DAMAGED, GO_FLAG_DESTROYED, and HasGameObjectFlag().

Referenced by ModifyHealth().

◆ GetDisplayId()

uint32 GameObject::GetDisplayId ( ) const
inline
@ GAMEOBJECT_DISPLAYID
Definition UpdateFields.h:398
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:298

References GAMEOBJECT_DISPLAYID, and Object::GetUInt32Value().

Referenced by GameObjectModelOwnerImpl::GetDisplayId(), and spell_zulfarrak_unlocking::HandleOpenLock().

◆ GetDynamicFlags()

uint32 GameObject::GetDynamicFlags ( ) const
inlineoverridevirtual

Reimplemented from Object.

References GAMEOBJECT_DYNAMIC, and Object::GetUInt32Value().

◆ GetFinalWorldRotation()

G3D::Quat GameObject::GetFinalWorldRotation ( ) const
2287{
2288 G3D::Quat worldRotation = GetWorldRotation();
2289 if (Transport* transport = GetTransport())
2290 {
2291 G3D::Quat transportRotation = transport->GetWorldRotation();
2292
2293 G3D::Quat transportRotationQuat(transportRotation.x, transportRotation.y, transportRotation.z, transportRotation.w);
2294 G3D::Quat worldRotationQuat(worldRotation.x, worldRotation.y, worldRotation.z, worldRotation.w);
2295
2296 G3D::Quat resultRotation = worldRotationQuat * transportRotationQuat;
2297
2298 return G3D::Quat(resultRotation.x, resultRotation.y, resultRotation.z, resultRotation.w);
2299 }
2300 return worldRotation;
2301}
G3D::Quat const & GetWorldRotation() const
Definition GameObject.h:150
Definition Transport.h:30

References WorldObject::GetTransport(), and GetWorldRotation().

Referenced by IsAtInteractDistance().

◆ GetFishLoot()

void GameObject::GetFishLoot ( Loot fishLoot,
Player lootOwner,
bool  junk = false 
)
1000{
1001 fishLoot->clear();
1002
1003 uint32 zone, area;
1004 uint32 defaultZone = 1;
1005 GetZoneAndAreaId(zone, area);
1006
1007 uint16 lootMode = junk ? LOOT_MODE_JUNK_FISH : LOOT_MODE_DEFAULT;
1008 // Check to fill loot in the order area - zone - defaultZone.
1009 // This is because area and zone is not set in some places, like Off the coast of Storm Peaks.
1010 uint32 lootZones[] = { area, zone, defaultZone };
1011 for (uint32 fillZone : lootZones)
1012 {
1013 fishLoot->FillLoot(fillZone, LootTemplates_Fishing, lootOwner, true, true, lootMode);
1014
1015 // If the loot is filled and the loot is eligible, then we break out of the loop.
1016 if (!fishLoot->empty() && !fishLoot->isLooted())
1017 break;
1018 }
1019}
LootStore LootTemplates_Fishing("fishing_loot_template", "area id", true)
@ LOOT_MODE_DEFAULT
Definition SharedDefines.h:43
@ LOOT_MODE_JUNK_FISH
Definition SharedDefines.h:48
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition Object.cpp:3182
bool empty() const
Definition LootMgr.h:367
bool isLooted() const
Definition LootMgr.h:368
void clear()
Definition LootMgr.h:343
bool FillLoot(uint32 lootId, LootStore const &store, Player *lootOwner, bool personal, bool noEmptyError=false, uint16 lootMode=LOOT_MODE_DEFAULT, WorldObject *lootSource=nullptr)
Definition LootMgr.cpp:540

References Loot::clear(), Loot::empty(), Loot::FillLoot(), WorldObject::GetZoneAndAreaId(), Loot::isLooted(), LOOT_MODE_DEFAULT, LOOT_MODE_JUNK_FISH, and LootTemplates_Fishing.

Referenced by Player::SendLoot().

◆ GetGameObjectData()

GameObjectData const * GameObject::GetGameObjectData ( ) const
inline

◆ GetGameObjectFlags()

GameObjectFlags GameObject::GetGameObjectFlags ( ) const
inline

◆ GetGoAnimProgress()

uint8 GameObject::GetGoAnimProgress ( ) const
inline
209{ return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
@ GAMEOBJECT_BYTES_1
Definition UpdateFields.h:404
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition Object.cpp:316

References GAMEOBJECT_BYTES_1, and Object::GetByteValue().

Referenced by Spell::EffectDummy(), SaveToDB(), Update(), and Use().

◆ GetGoArtKit()

uint8 GameObject::GetGoArtKit ( ) const
inline
207{ return GetByteValue(GAMEOBJECT_BYTES_1, 2); }

References GAMEOBJECT_BYTES_1, and Object::GetByteValue().

Referenced by SaveToDB().

◆ GetGOInfo()

GameObjectTemplate const * GameObject::GetGOInfo ( ) const
inline
136{ return m_goInfo; }

References m_goInfo.

Referenced by ActivateToQuest(), BuildValuesUpdate(), Spell::CheckCast(), Spell::CheckEffectTarget(), CheckRitualList(), ClearRitualList(), Create(), StaticTransport::Create(), Delete(), WorldSession::DoLootRelease(), Spell::EffectOpenLock(), MotionTransport::EnableMovement(), BattlegroundSA::EventPlayerDamagedGO(), Player::GetDefaultGossipMenuForSource(), GetScriptId(), GetSpellForLock(), GetStationaryO(), GetStationaryX(), GetStationaryY(), GetStationaryZ(), GetTemplateAddon(), go_celestial_planetarium_access::go_celestial_planetarium_accessAI::GossipHello(), WorldSession::HandleAlterAppearance(), OutdoorPvPSI::HandleCustomSpell(), gobject_commandscript::HandleGameObjectMoveCommand(), gobject_commandscript::HandleGameObjectTurnCommand(), OPvPCapturePoint::HandlePlayerEnter(), OPvPCapturePoint::HandlePlayerLeave(), IsAtInteractDistance(), IsAtInteractDistance(), IsDestructibleBuilding(), IsMotionTransport(), IsNeverVisible(), IsStaticTransport(), IsTransport(), LoadGameObjectFromDB(), MotionTransport::LoadStaticPassengers(), ModifyHealth(), instance_naxxramas::OnGameObjectCreate(), instance_naxxramas::OnGameObjectRemove(), icecrown_citadel_teleport::OnGossipHello(), go_simon_cluster::OnGossipHello(), go_apexis_relic::OnGossipHello(), Acore::NearestGameObjectFishingHole::operator()(), Acore::GameObjectInRangeCheck::operator()(), Acore::GameObjectFocusCheck::operator()(), RemoveFromOwner(), Creature::SaveToDB(), SaveToDB(), BfCapturePoint::SendChangePhase(), OPvPCapturePoint::SendChangePhase(), Player::SendLoot(), Spell::SendLoot(), BfCapturePoint::SetCapturePointData(), SetLootState(), ToMotionTransport(), ToMotionTransport(), ToStaticTransport(), ToStaticTransport(), ToTransport(), ToTransport(), BfCapturePoint::Update(), OPvPCapturePoint::Update(), MotionTransport::Update(), OPvPCapturePointNA::Update(), Update(), Use(), and UseDoorOrButton().

◆ GetGoState()

◆ GetGoType()

◆ GetGOValue()

GameObjectValue const * GameObject::GetGOValue ( ) const
inline
139{ return &m_goValue; }

References m_goValue.

Referenced by WorldSession::DoLootRelease(), and Transport::GetPathProgress().

◆ GetInteractionDistance()

float GameObject::GetInteractionDistance ( ) const
2899{
2900 switch (GetGoType())
2901 {
2903 return 0.0f;
2909 return 5.5555553f;
2911 return 10.0f;
2914 return 3.0f;
2916 return 100.0f;
2918 return 20.0f + CONTACT_DISTANCE; // max spell range
2924 return 5.0f;
2925 // Following values are not blizzlike
2928 // Successful mailbox interaction is rather critical to the client, failing it will start a minute-long cooldown until the next mail query may be executed.
2929 // And since movement info update is not sent with mailbox interaction query, server may find the player outside of interaction range. Thus we increase it.
2930 return 10.0f; // 5.0f is blizzlike
2931 default:
2932 return INTERACTION_DISTANCE;
2933 }
2934}
#define INTERACTION_DISTANCE
Definition ObjectDefines.h:24
#define CONTACT_DISTANCE
Definition ObjectDefines.h:23
@ GAMEOBJECT_TYPE_GUILD_BANK
Definition SharedDefines.h:1598
@ GAMEOBJECT_TYPE_MINI_GAME
Definition SharedDefines.h:1591
@ GAMEOBJECT_TYPE_CAMERA
Definition SharedDefines.h:1577
@ GAMEOBJECT_TYPE_MAP_OBJECT
Definition SharedDefines.h:1578
@ GAMEOBJECT_TYPE_FLAGDROP
Definition SharedDefines.h:1590
@ GAMEOBJECT_TYPE_MAILBOX
Definition SharedDefines.h:1583
@ GAMEOBJECT_TYPE_FLAGSTAND
Definition SharedDefines.h:1588
@ GAMEOBJECT_TYPE_CHAIR
Definition SharedDefines.h:1571
@ GAMEOBJECT_TYPE_TEXT
Definition SharedDefines.h:1573
@ GAMEOBJECT_TYPE_DUNGEON_DIFFICULTY
Definition SharedDefines.h:1595
@ GAMEOBJECT_TYPE_AREADAMAGE
Definition SharedDefines.h:1576
@ GAMEOBJECT_TYPE_BARBER_CHAIR
Definition SharedDefines.h:1596
@ GAMEOBJECT_TYPE_DOOR
Definition SharedDefines.h:1564
@ GAMEOBJECT_TYPE_BINDER
Definition SharedDefines.h:1568

References CONTACT_DISTANCE, GAMEOBJECT_TYPE_AREADAMAGE, GAMEOBJECT_TYPE_BARBER_CHAIR, GAMEOBJECT_TYPE_BINDER, GAMEOBJECT_TYPE_CAMERA, GAMEOBJECT_TYPE_CHAIR, GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING, GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_DUNGEON_DIFFICULTY, GAMEOBJECT_TYPE_FISHINGHOLE, GAMEOBJECT_TYPE_FISHINGNODE, GAMEOBJECT_TYPE_FLAGDROP, GAMEOBJECT_TYPE_FLAGSTAND, GAMEOBJECT_TYPE_GUILD_BANK, GAMEOBJECT_TYPE_MAILBOX, GAMEOBJECT_TYPE_MAP_OBJECT, GAMEOBJECT_TYPE_MINI_GAME, GAMEOBJECT_TYPE_QUESTGIVER, GAMEOBJECT_TYPE_TEXT, GetGoType(), and INTERACTION_DISTANCE.

Referenced by IsAtInteractDistance().

◆ getLevelForTarget()

uint8 GameObject::getLevelForTarget ( WorldObject const *  target) const
inlineoverridevirtual

Reimplemented from WorldObject.

277 {
278 if (Unit* owner = GetOwner())
279 return owner->getLevelForTarget(target);
280
281 return 1;
282 }

References GetOwner().

◆ GetLinkedTrap()

GameObject * GameObject::GetLinkedTrap ( )
2762{
2764}
ObjectGuid m_linkedTrap
Definition GameObject.h:408
GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:208

References ObjectAccessor::GetGameObject(), and m_linkedTrap.

Referenced by DespawnOrUnsummon(), Spell::EffectSummonObjectWild(), Spell::EffectTransmitted(), RemoveFromWorld(), go_direbrew_mole_machine::go_direbrew_mole_machineAI::Reset(), TriggeringLinkedGameObject(), and Update().

◆ GetLootGenerationTime()

uint32 GameObject::GetLootGenerationTime ( ) const
inline
258{ return m_lootGenerationTime; }

References m_lootGenerationTime.

Referenced by Player::SendLoot().

◆ GetLootMode()

uint16 GameObject::GetLootMode ( ) const
inline

◆ GetLootRecipient()

Player * GameObject::GetLootRecipient ( ) const
2659{
2660 if (!m_lootRecipient)
2661 return nullptr;
2663}
ObjectGuid m_lootRecipient
Definition GameObject.h:403
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:281

References ObjectAccessor::FindConnectedPlayer(), and m_lootRecipient.

◆ GetLootRecipientGroup()

Group * GameObject::GetLootRecipientGroup ( ) const
2666{
2668 return nullptr;
2669 return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup);
2670}
#define sGroupMgr
Definition GroupMgr.h:51

References m_lootRecipientGroup, and sGroupMgr.

Referenced by IsLootAllowedFor().

◆ getLootState()

◆ GetNameForLocaleIdx()

std::string const & GameObject::GetNameForLocaleIdx ( LocaleConstant  locale_idx) const
overridevirtual

Reimplemented from WorldObject.

2231{
2232 if (loc_idx != DEFAULT_LOCALE)
2233 {
2234 uint8 uloc_idx = uint8(loc_idx);
2235 if (GameObjectLocale const* cl = sObjectMgr->GetGameObjectLocale(GetEntry()))
2236 if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty())
2237 return cl->Name[uloc_idx];
2238 }
2239
2240 return GetName();
2241}
#define DEFAULT_LOCALE
Definition Common.h:139
std::string const & GetName() const
Definition Object.h:529
Definition GameObjectData.h:677

References DEFAULT_LOCALE, Object::GetEntry(), WorldObject::GetName(), and sObjectMgr.

Referenced by gobject_commandscript::HandleGameObjectRespawn().

◆ GetOwner()

Unit * GameObject::GetOwner ( ) const
1223{
1224 return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
1225}
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:223

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

Referenced by CastSpell(), Spell::EffectOpenLock(), getLevelForTarget(), go_soulwell::go_soulwellAI::GossipHello(), IsAlwaysVisibleFor(), TriggeringLinkedGameObject(), Update(), and Use().

◆ GetOwnerGUID()

◆ GetPackedWorldRotation()

int64 GameObject::GetPackedWorldRotation ( ) const
inline
151{ return m_packedRotation; }

References m_packedRotation.

◆ GetRespawnDelay()

uint32 GameObject::GetRespawnDelay ( ) const
inline

◆ GetRespawnPosition()

void GameObject::GetRespawnPosition ( float &  x,
float &  y,
float &  z,
float *  ori = nullptr 
) const
2867{
2868 if (m_spawnId)
2869 {
2870 if (GameObjectData const* data = sObjectMgr->GetGameObjectData(m_spawnId))
2871 {
2872 x = data->posX;
2873 y = data->posY;
2874 z = data->posZ;
2875 if (ori)
2876 *ori = data->orientation;
2877 return;
2878 }
2879 }
2880
2881 x = GetPositionX();
2882 y = GetPositionY();
2883 z = GetPositionZ();
2884 if (ori)
2885 *ori = GetOrientation();
2886}
Definition GameObjectData.h:715
float GetOrientation() const
Definition Position.h:124

References Position::GetOrientation(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), m_spawnId, and sObjectMgr.

◆ GetRespawnTime()

time_t GameObject::GetRespawnTime ( ) const
inline

◆ GetRespawnTimeEx()

time_t GameObject::GetRespawnTimeEx ( ) const
2950{
2951 time_t now = GameTime::GetGameTime().count();
2952 if (m_respawnTime > now)
2953 return m_respawnTime;
2954 else
2955 return now;
2956}
Seconds GetGameTime()
Definition GameTime.cpp:38

References GameTime::GetGameTime(), and m_respawnTime.

Referenced by gobject_commandscript::HandleGameObjectTargetCommand().

◆ GetScriptId()

◆ GetSpawnId()

◆ GetSpellForLock()

SpellInfo const * GameObject::GetSpellForLock ( Player const *  player) const
3036{
3037 if (!player)
3038 {
3039 return nullptr;
3040 }
3041
3042 uint32 lockId = GetGOInfo()->GetLockId();
3043 if (!lockId)
3044 {
3045 return nullptr;
3046 }
3047
3048 LockEntry const* lock = sLockStore.LookupEntry(lockId);
3049 if (!lock)
3050 {
3051 return nullptr;
3052 }
3053
3054 for (uint8 i = 0; i < MAX_LOCK_CASE; ++i)
3055 {
3056 if (!lock->Type[i])
3057 {
3058 continue;
3059 }
3060
3061 if (lock->Type[i] == LOCK_KEY_SPELL)
3062 {
3063 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(lock->Index[i]))
3064 {
3065 return spell;
3066 }
3067 }
3068
3069 if (lock->Type[i] != LOCK_KEY_SKILL)
3070 {
3071 break;
3072 }
3073
3074 for (auto&& playerSpell : player->GetSpellMap())
3075 {
3076 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(playerSpell.first))
3077 {
3078 for (auto&& effect : spell->Effects)
3079 {
3080 if (effect.Effect == SPELL_EFFECT_OPEN_LOCK && ((uint32) effect.MiscValue) == lock->Index[i])
3081 {
3082 if (effect.CalcValue(player) >= int32(lock->Skill[i]))
3083 {
3084 return spell;
3085 }
3086 }
3087 }
3088 }
3089 }
3090 }
3091
3092 return nullptr;
3093}
DBCStorage< LockEntry > sLockStore(LockEntryfmt)
#define MAX_LOCK_CASE
Definition DBCStructure.h:1305
@ SPELL_EFFECT_OPEN_LOCK
Definition SharedDefines.h:799
@ LOCK_KEY_SKILL
Definition SharedDefines.h:2590
@ LOCK_KEY_SPELL
Definition SharedDefines.h:2591
uint32 GetLockId() const
Definition GameObjectData.h:428
Definition DBCStructure.h:1308
uint32 Type[MAX_LOCK_CASE]
Definition DBCStructure.h:1310
uint32 Index[MAX_LOCK_CASE]
Definition DBCStructure.h:1311
uint32 Skill[MAX_LOCK_CASE]
Definition DBCStructure.h:1312

References GetGOInfo(), GameObjectTemplate::GetLockId(), Player::GetSpellMap(), LockEntry::Index, LOCK_KEY_SKILL, LOCK_KEY_SPELL, MAX_LOCK_CASE, LockEntry::Skill, sLockStore, SPELL_EFFECT_OPEN_LOCK, sSpellMgr, and LockEntry::Type.

Referenced by IsAtInteractDistance().

◆ GetSpellId()

uint32 GameObject::GetSpellId ( ) const
inline

◆ GetStationaryO()

float GameObject::GetStationaryO ( ) const
inlineoverridevirtual

◆ GetStationaryX()

float GameObject::GetStationaryX ( ) const
inlineoverridevirtual

◆ GetStationaryY()

float GameObject::GetStationaryY ( ) const
inlineoverridevirtual

◆ GetStationaryZ()

float GameObject::GetStationaryZ ( ) const
inlineoverridevirtual

◆ GetTemplateAddon()

GameObjectTemplateAddon const * GameObject::GetTemplateAddon ( ) const

◆ GetUniqueUseCount()

uint32 GameObject::GetUniqueUseCount ( ) const
inline
242{ return m_unique_users.size(); }

References m_unique_users.

Referenced by Update(), and Use().

◆ GetUseCount()

uint32 GameObject::GetUseCount ( ) const
inline
241{ return m_usetimes; }

References m_usetimes.

Referenced by WorldSession::DoLootRelease().

◆ GetWorldRotation()

G3D::Quat const & GameObject::GetWorldRotation ( ) const
inline
150{ return WorldRotation; }
G3D::Quat WorldRotation
Definition GameObject.h:400

References WorldRotation.

Referenced by GetFinalWorldRotation().

◆ HasGameObjectFlag()

bool GameObject::HasGameObjectFlag ( GameObjectFlags  flags) const
inline
217{ return HasFlag(GAMEOBJECT_FLAGS, flags) != 0; }
bool HasFlag(uint16 index, uint32 flag) const
Definition Object.cpp:875

References GAMEOBJECT_FLAGS, and Object::HasFlag().

Referenced by GetDestructibleState(), WorldSession::HandleGameobjectReportUse(), and Use().

◆ hasInvolvedQuest()

bool GameObject::hasInvolvedQuest ( uint32  quest_id) const
overridevirtual

Reimplemented from Object.

1200{
1201 QuestRelationBounds qir = sObjectMgr->GetGOQuestInvolvedRelationBounds(GetEntry());
1202 for (QuestRelations::const_iterator itr = qir.first; itr != qir.second; ++itr)
1203 {
1204 if (itr->second == quest_id)
1205 return true;
1206 }
1207 return false;
1208}
std::pair< QuestRelations::const_iterator, QuestRelations::const_iterator > QuestRelationBounds
Definition ObjectMgr.h:531

References Object::GetEntry(), and sObjectMgr.

◆ HasLootMode()

bool GameObject::HasLootMode ( uint16  lootMode) const
inline
229{ return m_LootMode & lootMode; }

References m_LootMode.

◆ HasLootRecipient()

bool GameObject::HasLootRecipient ( ) const
inline

◆ hasQuest()

bool GameObject::hasQuest ( uint32  quest_id) const
overridevirtual

Reimplemented from Object.

1189{
1190 QuestRelationBounds qr = sObjectMgr->GetGOQuestRelationBounds(GetEntry());
1191 for (QuestRelations::const_iterator itr = qr.first; itr != qr.second; ++itr)
1192 {
1193 if (itr->second == quest_id)
1194 return true;
1195 }
1196 return false;
1197}

References Object::GetEntry(), and sObjectMgr.

◆ IsAllowedToSaveToDB()

bool GameObject::IsAllowedToSaveToDB ( ) const
inline
357{ return m_saveStateOnDb; };

References m_saveStateOnDb.

Referenced by SetGoState().

◆ IsAlwaysVisibleFor()

bool GameObject::IsAlwaysVisibleFor ( WorldObject const *  seer) const
overridevirtual

Reimplemented from WorldObject.

1248{
1250 return true;
1251
1253 return true;
1254
1255 if (!seer)
1256 return false;
1257
1258 // Always seen by owner and friendly units
1259 if (ObjectGuid guid = GetOwnerGUID())
1260 {
1261 if (seer->GetGUID() == guid)
1262 return true;
1263
1264 Unit* owner = GetOwner();
1265 if (owner)
1266 {
1267 if (seer->IsUnit() && owner->IsFriendlyTo(seer->ToUnit()))
1268 return true;
1269 }
1270 }
1271
1272 return false;
1273}
bool IsDestructibleBuilding() const
Definition GameObject.cpp:1215
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:7302
virtual bool IsAlwaysVisibleFor(WorldObject const *) const
Definition Object.h:768

References Object::GetGUID(), GetOwner(), GetOwnerGUID(), WorldObject::IsAlwaysVisibleFor(), IsDestructibleBuilding(), Unit::IsFriendlyTo(), IsTransport(), Object::IsUnit(), and Object::ToUnit().

◆ IsAtInteractDistance() [1/2]

bool GameObject::IsAtInteractDistance ( Player const *  player,
SpellInfo const *  spell = nullptr 
) const
2989{
2990 if (spell || (spell = GetSpellForLock(player)))
2991 {
2992 float maxRange = spell->GetMaxRange(spell->IsPositive());
2993
2995 {
2996 return maxRange * maxRange >= GetExactDistSq(player);
2997 }
2998
2999 if (sGameObjectDisplayInfoStore.LookupEntry(GetGOInfo()->displayId))
3000 {
3001 return IsAtInteractDistance(*player, maxRange);
3002 }
3003 }
3004
3006}
DBCStorage< GameObjectDisplayInfoEntry > sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt)
bool IsAtInteractDistance(Position const &pos, float radius) const
Definition GameObject.cpp:3008
SpellInfo const * GetSpellForLock(Player const *player) const
Definition GameObject.cpp:3035
float GetInteractionDistance() const
Definition GameObject.cpp:2898
float GetExactDistSq(float x, float y, float z) const
Definition Position.h:174

References GAMEOBJECT_TYPE_SPELL_FOCUS, Position::GetExactDistSq(), GetGOInfo(), GetGoType(), GetInteractionDistance(), SpellInfo::GetMaxRange(), GetSpellForLock(), IsAtInteractDistance(), SpellInfo::IsPositive(), and sGameObjectDisplayInfoStore.

◆ IsAtInteractDistance() [2/2]

bool GameObject::IsAtInteractDistance ( Position const &  pos,
float  radius 
) const
3009{
3010 if (GameObjectDisplayInfoEntry const* displayInfo = sGameObjectDisplayInfoStore.LookupEntry(GetGOInfo()->displayId))
3011 {
3012 float scale = GetObjectScale();
3013
3014 float minX = displayInfo->minX * scale - radius;
3015 float minY = displayInfo->minY * scale - radius;
3016 float minZ = displayInfo->minZ * scale - radius;
3017 float maxX = displayInfo->maxX * scale + radius;
3018 float maxY = displayInfo->maxY * scale + radius;
3019 float maxZ = displayInfo->maxZ * scale + radius;
3020
3021 G3D::Quat finalRotation = GetFinalWorldRotation();
3022 G3D::Quat finalRotationQuat(finalRotation.x, finalRotation.y, finalRotation.z, finalRotation.w);
3023
3024 return G3D::CoordinateFrame {{finalRotationQuat}, {GetPositionX(), GetPositionY(), GetPositionZ()}}.toWorldSpace(G3D::Box {{minX, minY, minZ}, {maxX, maxY, maxZ}}).contains({pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()});
3025 }
3026
3027 return GetExactDist(&pos) <= radius;
3028}
G3D::Quat GetFinalWorldRotation() const
Definition GameObject.cpp:2286
float GetObjectScale() const
Definition Object.h:120
Definition DBCStructure.h:1003
float GetExactDist(float x, float y, float z) const
Definition Position.h:182

References Position::GetExactDist(), GetFinalWorldRotation(), GetGOInfo(), Object::GetObjectScale(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), and sGameObjectDisplayInfoStore.

Referenced by IsAtInteractDistance(), and IsWithinDistInMap().

◆ IsDestructibleBuilding()

bool GameObject::IsDestructibleBuilding ( ) const
1216{
1217 GameObjectTemplate const* gInfo = GetGOInfo();
1218 if (!gInfo) return false;
1220}

References GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING, GetGOInfo(), and GameObjectTemplate::type.

Referenced by IsAlwaysVisibleFor(), and ModifyHealth().

◆ IsInRange2d()

bool GameObject::IsInRange2d ( float  x,
float  y,
float  radius 
) const

Check if the distance between the 2 objects is 0, can happen if both objects are on the same position. The code below this check wont crash if dist is 0 because 0/0 in float operations is valid, and returns infinite

2157{
2159 if (!info)
2160 return IsWithinDist2d(x, y, radius);
2161
2162 float sinA = std::sin(GetOrientation());
2163 float cosA = cos(GetOrientation());
2164 float dx = x - GetPositionX();
2165 float dy = y - GetPositionY();
2166 float dist = std::sqrt(dx * dx + dy * dy);
2169 if (G3D::fuzzyEq(dist, 0.0f))
2170 return true;
2171
2172 float scale = GetObjectScale();
2173 float sinB = dx / dist;
2174 float cosB = dy / dist;
2175 dx = dist * (cosA * cosB + sinA * sinB);
2176 dy = dist * (cosA * sinB - sinA * cosB);
2177 return dx < (info->maxX * scale) + radius && dx >(info->minX * scale) - radius
2178 && dy < (info->maxY * scale) + radius && dy >(info->minY * scale) - radius;
2179}
bool IsWithinDist2d(float x, float y, float dist) const
Definition Object.cpp:1359
float maxX
Definition DBCStructure.h:1010
float maxY
Definition DBCStructure.h:1011
float minY
Definition DBCStructure.h:1008
float minX
Definition DBCStructure.h:1007

References GameObjectTemplate::displayId, Object::GetObjectScale(), Position::GetOrientation(), Position::GetPositionX(), Position::GetPositionY(), WorldObject::IsWithinDist2d(), m_goInfo, GameObjectDisplayInfoEntry::maxX, GameObjectDisplayInfoEntry::maxY, GameObjectDisplayInfoEntry::minX, GameObjectDisplayInfoEntry::minY, and sGameObjectDisplayInfoStore.

Referenced by IsWithinSightRange().

◆ IsInRange3d()

bool GameObject::IsInRange3d ( float  x,
float  y,
float  z,
float  radius 
) const

Check if the distance between the 2 objects is 0, can happen if both objects are on the same position. The code below this check wont crash if dist is 0 because 0/0 in float operations is valid, and returns infinite

2182{
2184 if (!info)
2185 return IsWithinDist3d(x, y, z, radius);
2186
2187 float sinA = std::sin(GetOrientation());
2188 float cosA = cos(GetOrientation());
2189 float dx = x - GetPositionX();
2190 float dy = y - GetPositionY();
2191 float dz = z - GetPositionZ();
2192 float dist = std::sqrt(dx * dx + dy * dy);
2195 if (G3D::fuzzyEq(dist, 0.0f))
2196 return true;
2197
2198 float scale = GetObjectScale();
2199 float sinB = dx / dist;
2200 float cosB = dy / dist;
2201 dx = dist * (cosA * cosB + sinA * sinB);
2202 dy = dist * (cosA * sinB - sinA * cosB);
2203 return dx < (info->maxX * scale) + radius && dx > (info->minX * scale) - radius
2204 && dy < (info->maxY * scale) + radius && dy > (info->minY * scale) - radius
2205 && dz < (info->maxZ * scale) + radius && dz > (info->minZ * scale) - radius;
2206}
bool IsWithinDist3d(float x, float y, float z, float dist) const
Definition Object.cpp:1349
float minZ
Definition DBCStructure.h:1009
float maxZ
Definition DBCStructure.h:1012

References GameObjectTemplate::displayId, Object::GetObjectScale(), Position::GetOrientation(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), WorldObject::IsWithinDist3d(), m_goInfo, GameObjectDisplayInfoEntry::maxX, GameObjectDisplayInfoEntry::maxY, GameObjectDisplayInfoEntry::maxZ, GameObjectDisplayInfoEntry::minX, GameObjectDisplayInfoEntry::minY, GameObjectDisplayInfoEntry::minZ, and sGameObjectDisplayInfoStore.

Referenced by _IsWithinDist(), Acore::GameObjectInRangeCheck::operator()(), Acore::AnyPlayerExactPositionInGameObjectRangeCheck::operator()(), and Acore::WorldObjectSpellAreaTargetCheck::operator()().

◆ IsInSkillupList()

bool GameObject::IsInSkillupList ( ObjectGuid const &  playerGuid) const
3102{
3103 for (auto const& itr : m_SkillupList)
3104 {
3105 if (itr.first == playerGuid)
3106 {
3107 return true;
3108 }
3109 }
3110
3111 return false;
3112}

References m_SkillupList.

Referenced by Spell::EffectOpenLock().

◆ IsInstanceGameobject()

bool GameObject::IsInstanceGameobject ( ) const
2540{
2541 // Avoid checking for unecessary gameobjects whose
2542 // states don't matter for the dungeon progression
2544 {
2545 return false;
2546 }
2547
2548 if (auto* map = FindMap())
2549 {
2550 if (map->IsDungeon() || map->IsRaid())
2551 {
2552 return true;
2553 }
2554 }
2555 return false;
2556}
bool ValidateGameobjectType() const
Definition GameObject.cpp:2558
Map * FindMap() const
Definition Object.h:632

References WorldObject::FindMap(), and ValidateGameobjectType().

Referenced by Create(), SaveStateToDB(), and SetGoState().

◆ IsInvisibleDueToDespawn()

bool GameObject::IsInvisibleDueToDespawn ( ) const
overridevirtual

Reimplemented from WorldObject.

1276{
1278 return true;
1279
1280 // Despawned
1281 if (!isSpawned())
1282 return true;
1283
1284 return false;
1285}
bool isSpawned() const
Definition GameObject.h:190
virtual bool IsInvisibleDueToDespawn() const
Definition Object.h:769

References WorldObject::IsInvisibleDueToDespawn(), and isSpawned().

◆ IsLootAllowedFor()

bool GameObject::IsLootAllowedFor ( Player const *  player) const
2729{
2731 {
2732 return true;
2733 }
2734
2735 if (player->GetGUID() == m_lootRecipient)
2736 {
2737 return true;
2738 }
2739
2740 if (player->HasPendingBind())
2741 {
2742 return false;
2743 }
2744
2745 // if we dont have a group we arent the recipient
2746 // if go doesnt have group bound it means it was solo killed by someone else
2747 Group const* playerGroup = player->GetGroup();
2748 if (!playerGroup || playerGroup != GetLootRecipientGroup())
2749 {
2750 return false;
2751 }
2752
2753 if (!HasAllowedLooter(player->GetGUID()))
2754 {
2755 return false;
2756 }
2757
2758 return true;
2759}
Group * GetLootRecipientGroup() const
Definition GameObject.cpp:2665
Definition Group.h:177
bool HasAllowedLooter(ObjectGuid guid) const
Definition Object.cpp:3222

References Player::GetGroup(), Object::GetGUID(), GetLootRecipientGroup(), WorldObject::HasAllowedLooter(), Player::HasPendingBind(), m_lootRecipient, and m_lootRecipientGroup.

Referenced by BuildValuesUpdate().

◆ IsMotionTransport()

bool GameObject::IsMotionTransport ( ) const
inline

◆ IsNeverVisible()

bool GameObject::IsNeverVisible ( ) const
overridevirtual

Reimplemented from WorldObject.

1237{
1239 return true;
1240
1241 if (GetGoType() == GAMEOBJECT_TYPE_SPELL_FOCUS && GetGOInfo()->spellFocus.serverOnly == 1)
1242 return true;
1243
1244 return false;
1245}
virtual bool IsNeverVisible() const
Definition Object.h:767
uint32 serverOnly
Definition GameObjectData.h:108

References GAMEOBJECT_TYPE_SPELL_FOCUS, GetGOInfo(), GetGoType(), WorldObject::IsNeverVisible(), and GameObjectTemplate::serverOnly.

◆ IsRespawnCompatibilityMode()

bool GameObject::IsRespawnCompatibilityMode ( ) const
inline
bool _respawnCompatibilityMode
Definition GameObject.h:373

References _respawnCompatibilityMode.

◆ isSpawned()

◆ isSpawnedByDefault()

bool GameObject::isSpawnedByDefault ( ) const
inline

◆ IsStaticTransport()

bool GameObject::IsStaticTransport ( ) const
inline

◆ IsTransport()

◆ IsUpdateNeeded()

bool GameObject::IsUpdateNeeded ( )
overridevirtual

Reimplemented from WorldObject.

3124{
3126 return true;
3127
3128 if (GetMap()->isCellMarked(GetCurrentCell().GetCellCoord().GetId()))
3129 return true;
3130
3131 if (!GetObjectVisibilityContainer().GetVisiblePlayersMap().empty())
3132 return true;
3133
3134 if (IsTransport())
3135 return true;
3136
3137 return false;
3138}
Cell const & GetCurrentCell() const
Definition Object.h:423
virtual bool IsUpdateNeeded()
Definition Object.cpp:3242
ObjectVisibilityContainer & GetObjectVisibilityContainer()
Definition Object.h:737

References MovableMapObject::GetCurrentCell(), WorldObject::GetMap(), WorldObject::GetObjectVisibilityContainer(), IsTransport(), and WorldObject::IsUpdateNeeded().

◆ IsWithinDistInMap() [1/2]

bool GameObject::IsWithinDistInMap ( Player const *  player) const

◆ IsWithinDistInMap() [2/2]

bool WorldObject::IsWithinDistInMap ( WorldObject const *  obj,
float  dist2compare,
bool  is3D = true,
bool  incOwnRadius = true,
bool  incTargetRadius = true 
) const
1382{
1383 return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D, incOwnRadius, incTargetRadius);
1384}
bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool, bool, bool) const override
Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size...
Definition GameObject.h:420

◆ IsWithinSightRange()

bool GameObject::IsWithinSightRange ( Position const &  pos,
float  dist 
) const
overrideprivatevirtual

Reimplemented from WorldObject.

2257{
2258 return IsInRange2d(pos.GetPositionX(), pos.GetPositionY(), dist);
2259}
bool IsInRange2d(float x, float y, float radius) const
Definition GameObject.cpp:2156

References Position::GetPositionX(), Position::GetPositionY(), and IsInRange2d().

◆ LoadFromDB()

virtual bool GameObject::LoadFromDB ( ObjectGuid::LowType  guid,
Map map 
)
inlinevirtual

Reimplemented in StaticTransport.

159{ return LoadGameObjectFromDB(guid, map, false); }
virtual bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true)
Definition GameObject.cpp:1102

References LoadGameObjectFromDB().

Referenced by GridObjectLoader::LoadGameObjects().

◆ LoadGameObjectFromDB()

bool GameObject::LoadGameObjectFromDB ( ObjectGuid::LowType  guid,
Map map,
bool  addToMap = true 
)
virtual

Reimplemented in StaticTransport.

1103{
1104 GameObjectData const* data = sObjectMgr->GetGameObjectData(spawnId);
1105
1106 if (!data)
1107 {
1108 LOG_ERROR("sql.sql", "Gameobject (GUID: {}) not found in table `gameobject`, can't load. ", spawnId);
1109 return false;
1110 }
1111
1112 uint32 entry = data->id;
1113 //uint32 map_id = data->mapid; // already used before call
1114 uint32 phaseMask = data->phaseMask;
1115 float x = data->posX;
1116 float y = data->posY;
1117 float z = data->posZ;
1118 float ang = data->orientation;
1119
1120 uint32 animprogress = data->animprogress;
1121 GOState go_state = data->go_state;
1122 uint32 artKit = data->artKit;
1123
1124 m_goData = data;
1125 m_spawnId = spawnId;
1126
1127 // Set respawn compatibility mode based on spawn group flags
1128 SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(data->spawnGroupId);
1130 || !groupData || (groupData->flags & SPAWNGROUP_FLAG_COMPATIBILITY_MODE);
1131
1132 if (!Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state, artKit))
1133 return false;
1134
1135 if (data->spawntimesecs >= 0)
1136 {
1137 m_spawnedByDefault = true;
1138
1140 {
1143 m_respawnTime = 0;
1144 }
1145 else
1146 {
1149
1150 // ready to respawn
1152 {
1153 m_respawnTime = 0;
1155 }
1156 }
1157 }
1158 else
1159 {
1160 m_spawnedByDefault = false;
1162 m_respawnTime = 0;
1163 }
1164
1165 if (addToMap && !GetMap()->AddToMap(this))
1166 return false;
1167
1168 return true;
1169}
@ GO_FLAG_NODESPAWN
Definition SharedDefines.h:1612
@ SPAWNGROUP_FLAG_COMPATIBILITY_MODE
Definition SpawnData.h:45
@ CONFIG_RESPAWN_FORCE_COMPATIBILITY_MODE
Definition WorldConfig.h:404
void SetGameObjectFlag(GameObjectFlags flags)
Definition GameObject.h:218
time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const
Definition Map.h:425
uint8 artKit
Definition GameObjectData.h:722
G3D::Quat rotation
Definition GameObjectData.h:718
uint32 animprogress
Definition GameObjectData.h:720
uint32 id
Definition GameObjectData.h:717
GOState go_state
Definition GameObjectData.h:721
bool IsDespawnAtAction() const
Definition GameObjectData.h:398
bool GetDespawnPossibility() const
Definition GameObjectData.h:459
float posX
Definition SpawnData.h:71
float posY
Definition SpawnData.h:72
uint32 phaseMask
Definition SpawnData.h:70
float orientation
Definition SpawnData.h:74
uint32 spawnGroupId
Definition SpawnData.h:78
float posZ
Definition SpawnData.h:73
Definition SpawnData.h:58
SpawnGroupFlags flags
Definition SpawnData.h:62

References _respawnCompatibilityMode, GameObjectData::animprogress, GameObjectData::artKit, CONFIG_RESPAWN_FORCE_COMPATIBILITY_MODE, Create(), SpawnGroupTemplateData::flags, GameObject, Map::GenerateLowGuid(), GameObjectTemplate::GetDespawnPossibility(), GameTime::GetGameTime(), GetGOInfo(), Map::GetGORespawnTime(), WorldObject::GetMap(), GO_FLAG_NODESPAWN, GameObjectData::go_state, GameObjectData::id, GameObjectTemplate::IsDespawnAtAction(), LOG_ERROR, m_goData, m_respawnDelayTime, m_respawnTime, m_spawnedByDefault, m_spawnId, SpawnData::orientation, SpawnData::phaseMask, SpawnData::posX, SpawnData::posY, SpawnData::posZ, Map::RemoveGORespawnTime(), GameObjectData::rotation, SetGameObjectFlag(), sObjectMgr, SPAWNGROUP_FLAG_COMPATIBILITY_MODE, SpawnData::spawnGroupId, GameObjectData::spawntimesecs, and sWorld.

Referenced by ObjectMgr::AddGOData(), MotionTransport::CreateGOPassenger(), GameEventMgr::GameEventSpawn(), gobject_commandscript::HandleGameObjectAddCommand(), gobject_commandscript::HandleGameObjectLoadCommand(), gobject_commandscript::HandleGameObjectMoveCommand(), gobject_commandscript::HandleGameObjectTurnCommand(), LoadFromDB(), Map::ProcessGameObjectRespawn(), and Map::SpawnGroupSpawn().

◆ LookupFishingHoleAround()

GameObject * GameObject::LookupFishingHoleAround ( float  range)
1393{
1394 GameObject* ok = nullptr;
1395
1396 Acore::NearestGameObjectFishingHole u_check(*this, range);
1398
1399 Cell::VisitObjects(this, checker, range);
1400 return ok;
1401}
Definition GridNotifiers.h:705
Definition GridNotifiers.h:342
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165

References Cell::VisitObjects().

Referenced by Use().

◆ ModifyHealth()

void GameObject::ModifyHealth ( int32  change,
Unit attackerOrHealer = nullptr,
uint32  spellId = 0 
)
Todo:
: is there any packet for healing?
2304{
2306 return;
2307
2308 // if this building doesn't have health, return
2310 return;
2311
2312 sScriptMgr->OnGameObjectModifyHealth(this, attackerOrHealer, change, sSpellMgr->GetSpellInfo(spellId));
2313
2314 // if the health isn't being changed, return
2315 if (!change)
2316 return;
2317
2319 change = 0;
2320
2321 // prevent double destructions of the same object
2322 if (change < 0 && !m_goValue.Building.Health)
2323 return;
2324
2325 if (int32(m_goValue.Building.Health) + change <= 0)
2329 else
2330 m_goValue.Building.Health += change;
2331
2332 // Set the health bar, value = 255 * healthPct;
2334
2335 Player* player = attackerOrHealer->GetCharmerOrOwnerPlayerOrPlayerItself();
2336
2337 // dealing damage, send packet
2339 if (player)
2340 {
2341 WorldPacket data(SMSG_DESTRUCTIBLE_BUILDING_DAMAGE, 8 + 8 + 8 + 4 + 4);
2342 data << GetPackGUID();
2343 data << attackerOrHealer->GetPackGUID();
2344 data << player->GetPackGUID();
2345 data << uint32(-change); // change < 0 triggers SPELL_BUILDING_HEAL combat log event
2346 // change >= 0 triggers SPELL_BUILDING_DAMAGE event
2347 data << uint32(spellId);
2348 player->SendDirectMessage(&data);
2349 }
2350
2352
2354 newState = GO_DESTRUCTIBLE_DESTROYED;
2355 else if (m_goValue.Building.Health <= GetGOInfo()->building.damagedNumHits)
2356 newState = GO_DESTRUCTIBLE_DAMAGED;
2358 newState = GO_DESTRUCTIBLE_INTACT;
2359
2360 if (newState == GetDestructibleState())
2361 return;
2362
2363 SetDestructibleState(newState, player, false);
2364}
GameObjectDestructibleState
Definition SharedDefines.h:1630
void SetDestructibleState(GameObjectDestructibleState state, Player *eventInvoker=nullptr, bool setHealth=false)
Definition GameObject.cpp:2366
GameObjectDestructibleState GetDestructibleState() const
Definition GameObject.h:295
PackedGuid const & GetPackGUID() const
Definition Object.h:116
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5852
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition Unit.cpp:7762
Definition WorldPacket.h:26
@ SMSG_DESTRUCTIBLE_BUILDING_DAMAGE
Definition Opcodes.h:80

References GameObjectValue::Building, GameObjectTemplate::damagedNumHits, Unit::GetCharmerOrOwnerPlayerOrPlayerItself(), GetDestructibleState(), GetGOInfo(), Object::GetPackGUID(), GO_DESTRUCTIBLE_DAMAGED, GO_DESTRUCTIBLE_DESTROYED, GO_DESTRUCTIBLE_INTACT, GameObjectValue::Health, IsDestructibleBuilding(), m_allowModifyDestructibleBuilding, m_goValue, GameObjectValue::MaxHealth, Player::SendDirectMessage(), SetDestructibleState(), SetGoAnimProgress(), SMSG_DESTRUCTIBLE_BUILDING_DAMAGE, sScriptMgr, and sSpellMgr.

Referenced by Spell::EffectGameObjectDamage(), and Spell::EffectGameObjectRepair().

◆ Refresh()

void GameObject::Refresh ( )
912{
913 // not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway)
915 return;
916
917 if (isSpawned())
918 GetMap()->AddToMap(this);
919}

References Map::AddToMap(), WorldObject::GetMap(), isSpawned(), m_respawnTime, and m_spawnedByDefault.

Referenced by BattlegroundSA::ResetObjs().

◆ RemoveFromOwner()

void GameObject::RemoveFromOwner ( )
private
138{
139 ObjectGuid ownerGUID = GetOwnerGUID();
140 if (!ownerGUID)
141 return;
142
143 if (Unit* owner = ObjectAccessor::GetUnit(*this, ownerGUID))
144 {
145 owner->RemoveGameObject(this, false);
147 return;
148 }
149
150 LOG_DEBUG("entities.gameobject", "Delete GameObject ({} Entry: {} SpellId {} LinkedGO {}) that lost references to owner {} GO list.",
151 GetGUID().ToString(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString());
152
154}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
void SetOwnerGUID(ObjectGuid owner)
Definition GameObject.h:164
static ObjectGuid const Empty
Definition ObjectGuid.h:123
std::string ToString() const
Definition ObjectGuid.cpp:48
std::string ToString() const
Definition Position.cpp:59

References ASSERT, ObjectGuid::Empty, GetGOInfo(), Object::GetGUID(), GetOwnerGUID(), ObjectAccessor::GetUnit(), LOG_DEBUG, m_spellId, SetOwnerGUID(), ObjectGuid::ToString(), and Position::ToString().

Referenced by CleanupsBeforeDelete(), Delete(), and RemoveFromWorld().

◆ RemoveFromWorld()

void GameObject::RemoveFromWorld ( )
overridevirtual
  • Remove the gameobject from the accessor

Reimplemented from Object.

185{
187 if (IsInWorld())
188 {
189 sScriptMgr->OnGameObjectRemoveWorld(this);
190
191 if (m_zoneScript)
193
195
196 if (m_model)
197 if (GetMap()->ContainsGameObjectModel(*m_model))
199
200 if (Transport* transport = GetTransport())
201 transport->RemovePassenger(this, true);
202
203 // If linked trap exists, despawn it
204 if (GameObject* linkedTrap = GetLinkedTrap())
205 {
206 linkedTrap->Delete();
207 }
208
210
211 if (m_spawnId)
212 Acore::Containers::MultimapErasePair(GetMap()->GetGameObjectBySpawnIdStore(), m_spawnId, this);
214 }
215}
void RemoveGameObjectModel(GameObjectModel const &model)
Definition Map.h:404
bool Remove(KEY_TYPE const &handle)
Definition TypeContainer.h:183
void RemoveFromWorld() override
Definition Object.cpp:1228
virtual void OnGameObjectRemove(GameObject *)
Definition ZoneScript.h:38
void MultimapErasePair(M< K, V, Rest... > &multimap, K const &key, V const &value)
Definition Containers.h:236

References Object::GetGUID(), GetLinkedTrap(), WorldObject::GetMap(), Map::GetObjectsStore(), WorldObject::GetTransport(), Object::IsInWorld(), m_model, m_spawnId, WorldObject::m_zoneScript, Acore::Containers::MultimapErasePair(), ZoneScript::OnGameObjectRemove(), TypeUnorderedMapContainer< OBJECT_TYPES, KEY_TYPE >::Remove(), RemoveFromOwner(), WorldObject::RemoveFromWorld(), Map::RemoveGameObjectModel(), and sScriptMgr.

Referenced by CleanupsBeforeDelete(), BattlegroundIC::PostUpdateImpl(), Map::RemoveFromMap(), and go_bear_trap::go_bear_trapAI::UpdateAI().

◆ RemoveGameObjectFlag()

◆ RemoveLootMode()

void GameObject::RemoveLootMode ( uint16  lootMode)
inline
232{ m_LootMode &= ~lootMode; }

References m_LootMode.

◆ ReplaceAllDynamicFlags()

void GameObject::ReplaceAllDynamicFlags ( uint32  flag)
inlineoverridevirtual

Reimplemented from Object.

References GAMEOBJECT_DYNAMIC, and Object::SetUInt32Value().

◆ ReplaceAllGameObjectFlags()

◆ ResetDoorOrButton()

◆ ResetLootMode()

void GameObject::ResetLootMode ( )
inline

References LOOT_MODE_DEFAULT, and m_LootMode.

Referenced by GameObject().

◆ Respawn()

◆ SaveRespawnTime() [1/2]

void GameObject::SaveRespawnTime ( )
inlineoverridevirtual

Reimplemented from WorldObject.

244{ SaveRespawnTime(0); }
void SaveRespawnTime() override
Definition GameObject.h:244

References SaveRespawnTime().

Referenced by go_strange_pool::OnGossipHello(), Map::RemoveFromMap(), SaveRespawnTime(), and Update().

◆ SaveRespawnTime() [2/2]

void GameObject::SaveRespawnTime ( uint32  forceDelay)
1228{
1229 if (m_goData && m_goData->dbData && (forceDelay || m_respawnTime > GameTime::GetGameTime().count()) && m_spawnedByDefault)
1230 {
1231 time_t respawnTime = forceDelay ? GameTime::GetGameTime().count() + forceDelay : m_respawnTime;
1232 GetMap()->SaveGORespawnTime(m_spawnId, respawnTime);
1233 }
1234}
void SaveGORespawnTime(ObjectGuid::LowType dbGuid, time_t &respawnTime)
Definition Map.cpp:2494
bool dbData
Definition SpawnData.h:77

References SpawnData::dbData, GameTime::GetGameTime(), WorldObject::GetMap(), m_goData, m_respawnTime, m_spawnedByDefault, m_spawnId, and Map::SaveGORespawnTime().

◆ SaveStateToDB()

void GameObject::SaveStateToDB ( )
2599{
2601 {
2602 if (InstanceScript* instance = GetInstanceScript())
2603 {
2604 GOState param = GetGoState();
2605 instance->StoreGameObjectState(GetSpawnId(), GameobjectStateToInt(&param));
2606
2608 stmt->SetData(0, GetInstanceId());
2609 stmt->SetData(1, GetSpawnId());
2610 stmt->SetData(2, GameobjectStateToInt(&param));
2611 CharacterDatabase.Execute(stmt);
2612 }
2613 }
2614}
@ CHAR_INSERT_INSTANCE_SAVED_DATA
Definition CharacterDatabase.h:541
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
uint8 GameobjectStateToInt(GOState *state) const
Definition GameObject.cpp:2573
uint32 GetInstanceId() const
Definition Object.h:514

References CHAR_INSERT_INSTANCE_SAVED_DATA, CharacterDatabase, GameobjectStateToInt(), GetGoState(), WorldObject::GetInstanceId(), WorldObject::GetInstanceScript(), GetSpawnId(), IsInstanceGameobject(), and PreparedStatementBase::SetData().

Referenced by SetGoState().

◆ SaveToDB() [1/2]

void GameObject::SaveToDB ( bool  saveAddon = false)
1022{
1023 // this should only be used when the gameobject has already been loaded
1024 // preferably after adding to map, because mapid may not be valid otherwise
1025 GameObjectData const* data = sObjectMgr->GetGameObjectData(m_spawnId);
1026 if (!data)
1027 {
1028 LOG_ERROR("entities.gameobject", "GameObject::SaveToDB failed, cannot get gameobject data!");
1029 return;
1030 }
1031
1032 SaveToDB(GetMapId(), data->spawnMask, data->phaseMask, saveAddon);
1033}
void SaveToDB(bool saveAddon=false)
Definition GameObject.cpp:1021
uint32 GetMapId() const
Definition Position.h:281
uint8 spawnMask
Definition SpawnData.h:75

References WorldLocation::GetMapId(), LOG_ERROR, m_spawnId, SpawnData::phaseMask, SaveToDB(), sObjectMgr, and SpawnData::spawnMask.

Referenced by SaveToDB().

◆ SaveToDB() [2/2]

void GameObject::SaveToDB ( uint32  mapid,
uint8  spawnMask,
uint32  phaseMask,
bool  saveAddon = false 
)
1036{
1037 GameObjectTemplate const* goI = GetGOInfo();
1038
1039 if (!goI)
1040 return;
1041
1042 if (!m_spawnId)
1043 m_spawnId = sObjectMgr->GenerateGameObjectSpawnId();
1044
1045 // update in loaded data (changing data only in this place)
1046 GameObjectData& data = sObjectMgr->NewGOData(m_spawnId);
1047
1048 data.id = GetEntry();
1049 data.mapid = mapid;
1050 data.phaseMask = phaseMask;
1051 data.posX = GetPositionX();
1052 data.posY = GetPositionY();
1053 data.posZ = GetPositionZ();
1054 data.orientation = GetOrientation();
1055 data.rotation = WorldRotation;
1058 data.go_state = GetGoState();
1059 data.spawnMask = spawnMask;
1060 data.artKit = GetGoArtKit();
1061
1062 // Update in DB
1063 WorldDatabaseTransaction trans = WorldDatabase.BeginTransaction();
1064
1065 uint8 index = 0;
1066
1068 stmt->SetData(0, m_spawnId);
1069 trans->Append(stmt);
1070
1071 stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT);
1072 stmt->SetData(index++, m_spawnId);
1073 stmt->SetData(index++, GetEntry());
1074 stmt->SetData(index++, uint16(mapid));
1075 stmt->SetData(index++, spawnMask);
1076 stmt->SetData(index++, GetPhaseMask());
1077 stmt->SetData(index++, GetPositionX());
1078 stmt->SetData(index++, GetPositionY());
1079 stmt->SetData(index++, GetPositionZ());
1080 stmt->SetData(index++, GetOrientation());
1081 stmt->SetData(index++, WorldRotation.x);
1082 stmt->SetData(index++, WorldRotation.y);
1083 stmt->SetData(index++, WorldRotation.z);
1084 stmt->SetData(index++, WorldRotation.w);
1085 stmt->SetData(index++, int32(m_respawnDelayTime));
1086 stmt->SetData(index++, GetGoAnimProgress());
1087 stmt->SetData(index++, uint8(GetGoState()));
1088 trans->Append(stmt);
1089
1090 if (saveAddon && !sObjectMgr->GetGameObjectAddon(m_spawnId))
1091 {
1092 index = 0;
1093 stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT_ADDON);
1094 stmt->SetData(index++, m_spawnId);
1095 trans->Append(stmt);
1096 }
1097
1098 WorldDatabase.CommitTransaction(trans);
1099 sScriptMgr->OnGameObjectSaveToDB(this);
1100}
SQLTransaction< WorldDatabaseConnection > WorldDatabaseTransaction
Definition DatabaseEnvFwd.h:71
@ WORLD_INS_GAMEOBJECT
Definition WorldDatabase.h:112
@ WORLD_INS_GAMEOBJECT_ADDON
Definition WorldDatabase.h:119
uint8 GetGoAnimProgress() const
Definition GameObject.h:209
uint8 GetGoArtKit() const
Definition GameObject.h:207
uint16 mapid
Definition SpawnData.h:69

References GameObjectData::animprogress, GameObjectData::artKit, Object::GetEntry(), GetGoAnimProgress(), GetGoArtKit(), GetGOInfo(), GetGoState(), Position::GetOrientation(), WorldObject::GetPhaseMask(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), GameObjectData::go_state, GameObjectData::id, m_respawnDelayTime, m_spawnedByDefault, m_spawnId, SpawnData::mapid, SpawnData::orientation, SpawnData::phaseMask, SpawnData::posX, SpawnData::posY, SpawnData::posZ, GameObjectData::rotation, PreparedStatementBase::SetData(), sObjectMgr, SpawnData::spawnMask, GameObjectData::spawntimesecs, sScriptMgr, WORLD_DEL_GAMEOBJECT, WORLD_INS_GAMEOBJECT, WORLD_INS_GAMEOBJECT_ADDON, WorldDatabase, and WorldRotation.

◆ SendCustomAnim()

void GameObject::SendCustomAnim ( uint32  anim)
2149{
2151 data << GetGUID();
2152 data << uint32(anim);
2153 SendMessageToSet(&data, true);
2154}
virtual void SendMessageToSet(WorldPacket const *data, bool self) const
Definition Object.cpp:2166
@ SMSG_GAMEOBJECT_CUSTOM_ANIM
Definition Opcodes.h:209

References Object::GetGUID(), WorldObject::SendMessageToSet(), and SMSG_GAMEOBJECT_CUSTOM_ANIM.

Referenced by Spell::EffectActivateObject(), Spell::EffectDummy(), go_gong_of_bethekk::OnGossipHello(), brann_bronzebeard::SwitchHeadVisual(), Update(), go_suppression_device::UpdateAI(), and Use().

◆ SetDestructibleBuildingModifyState()

void GameObject::SetDestructibleBuildingModifyState ( bool  allow)
inline

◆ SetDestructibleState()

void GameObject::SetDestructibleState ( GameObjectDestructibleState  state,
Player eventInvoker = nullptr,
bool  setHealth = false 
)
2367{
2368 // the user calling this must know he is already operating on destructible gameobject
2370
2371 switch (state)
2372 {
2376 if (setHealth)
2377 {
2379 SetGoAnimProgress(255);
2380 }
2381 EnableCollision(true);
2382 break;
2384 {
2386
2387 sScriptMgr->OnGameObjectDamaged(this, eventInvoker);
2388
2389 if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
2390 if (Battleground* bg = bgMap->GetBG())
2391 bg->EventPlayerDamagedGO(eventInvoker, this, m_goInfo->building.damagedEvent);
2392
2395
2398 if (modelData->DamagedDisplayId)
2399 modelId = modelData->DamagedDisplayId;
2400 SetDisplayId(modelId);
2401
2402 if (setHealth)
2403 {
2405 uint32 maxHealth = m_goValue.Building.MaxHealth;
2406 // in this case current health is 0 anyway so just prevent crashing here
2407 if (!maxHealth)
2408 maxHealth = 1;
2409 SetGoAnimProgress(m_goValue.Building.Health * 255 / maxHealth);
2410 }
2411 break;
2412 }
2414 {
2415 sScriptMgr->OnGameObjectDestroyed(this, eventInvoker);
2416
2418
2419 if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
2420 {
2421 if (Battleground* bg = bgMap->GetBG())
2422 {
2423 bg->EventPlayerDamagedGO(eventInvoker, this, m_goInfo->building.destroyedEvent);
2424 bg->DestroyGate(eventInvoker, this);
2425 }
2426 }
2427
2430
2433 if (modelData->DestroyedDisplayId)
2434 modelId = modelData->DestroyedDisplayId;
2435 SetDisplayId(modelId);
2436
2437 if (setHealth)
2438 {
2441 }
2442 EnableCollision(false);
2443 break;
2444 }
2446 {
2449
2450 uint32 modelId = m_goInfo->displayId;
2452 if (modelData->RebuildingDisplayId)
2453 modelId = modelData->RebuildingDisplayId;
2454 SetDisplayId(modelId);
2455
2456 // restores to full health
2457 if (setHealth)
2458 {
2460 SetGoAnimProgress(255);
2461 }
2462 EnableCollision(true);
2463 break;
2464 }
2465 }
2466}
DBCStorage< DestructibleModelDataEntry > sDestructibleModelDataStore(DestructibleModelDatafmt)
@ GO_DESTRUCTIBLE_REBUILDING
Definition SharedDefines.h:1634
Definition Map.h:758
void RemoveGameObjectFlag(GameObjectFlags flags)
Definition GameObject.h:219
void EventInform(uint32 eventId)
Definition GameObject.cpp:2208
Definition DBCStructure.h:843
uint32 destructibleData
Definition GameObjectData.h:370
uint32 rebuildingEvent
Definition GameObjectData.h:371
uint32 destroyedEvent
Definition GameObjectData.h:366
uint32 damagedDisplayId
Definition GameObjectData.h:356
uint32 destroyedDisplayId
Definition GameObjectData.h:362
uint32 damagedEvent
Definition GameObjectData.h:361

References ASSERT, GameObjectValue::Building, GameObjectTemplate::building, GameObjectTemplate::damagedDisplayId, GameObjectTemplate::damagedEvent, GameObjectTemplate::damagedNumHits, GameObjectTemplate::destroyedDisplayId, GameObjectTemplate::destroyedEvent, GameObjectTemplate::destructibleData, GameObjectTemplate::displayId, EnableCollision(), EventInform(), GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING, GetGoType(), WorldObject::GetMap(), GO_DESTRUCTIBLE_DAMAGED, GO_DESTRUCTIBLE_DESTROYED, GO_DESTRUCTIBLE_INTACT, GO_DESTRUCTIBLE_REBUILDING, GO_FLAG_DAMAGED, GO_FLAG_DESTROYED, GameObjectValue::Health, m_goInfo, m_goValue, GameObjectValue::MaxHealth, GameObjectTemplate::rebuildingEvent, RemoveGameObjectFlag(), sDestructibleModelDataStore, SetDisplayId(), SetGameObjectFlag(), SetGoAnimProgress(), and sScriptMgr.

Referenced by Spell::EffectGameObjectSetDestructionState(), BfWGGameObjectBuilding::Init(), ModifyHealth(), instance_eye_of_eternity::OnGameObjectCreate(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::OnGameObjectCreate(), FrozenThroneResetWorker::operator()(), BattlegroundIC::PostUpdateImpl(), and BfWGGameObjectBuilding::Rebuild().

◆ SetDisplayId()

void GameObject::SetDisplayId ( uint32  displayid)

◆ SetGameObjectFlag()

void GameObject::SetGameObjectFlag ( GameObjectFlags  flags)
inline
218{ SetFlag(GAMEOBJECT_FLAGS, flags); }
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:831

References GAMEOBJECT_FLAGS, and Object::SetFlag().

Referenced by go_suppression_device::Deactivate(), go_chromaggus_lever::GossipHello(), go_gilded_brazier::go_gilded_brazierAI::GossipHello(), go_blood_drenched_door::go_blood_drenched_doorAI::GossipHello(), go_celestial_planetarium_access::go_celestial_planetarium_accessAI::GossipHello(), go_empowering_blood_orb::HandleObjectUse(), go_magtheridons_head::InitializeAI(), LoadGameObjectFromDB(), BattlefieldWG::OnBattleStart(), instance_uldaman::instance_uldaman_InstanceMapScript::OnGameObjectCreate(), instance_blackfathom_deeps::instance_blackfathom_deeps_InstanceMapScript::OnGameObjectCreate(), instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::OnGameObjectCreate(), instance_razorfen_downs::instance_razorfen_downs_InstanceMapScript::OnGameObjectCreate(), instance_ulduar::instance_ulduar_InstanceMapScript::OnGameObjectCreate(), instance_karazhan::instance_karazhan_InstanceMapScript::OnGameObjectCreate(), instance_zulgurub::instance_zulgurub_InstanceMapScript::OnGameObjectCreate(), instance_ahnkahet::instance_ahnkahet_InstanceScript::OnGameObjectCreate(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnGameObjectCreate(), instance_violet_hold::instance_violet_hold_InstanceMapScript::OnGameObjectCreate(), go_gong_of_bethekk::OnGossipHello(), go_elune_fire::OnGossipHello(), go_razorscale_harpoon::OnGossipHello(), go_palehoof_sphere::OnGossipHello(), go_main_chambers_access_panel::OnGossipHello(), go_razorscale_mole_machine::go_razorscale_mole_machineAI::Reset(), SetDestructibleState(), SwitchDoorOrButton(), and Use().

◆ SetGoAnimProgress()

void GameObject::SetGoAnimProgress ( uint8  animprogress)
inline
210{ SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition Object.cpp:743

References GAMEOBJECT_BYTES_1, and Object::SetByteValue().

Referenced by Create(), StaticTransport::Create(), MotionTransport::CreateMoTrans(), go_empowering_blood_orb::HandleObjectUse(), ModifyHealth(), and SetDestructibleState().

◆ SetGoArtKit() [1/2]

void GameObject::SetGoArtKit ( uint8  artkit)
1428{
1430 GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGameObjectData(m_spawnId));
1431 if (data)
1432 data->artKit = kit;
1433}

References GameObjectData::artKit, GAMEOBJECT_BYTES_1, m_spawnId, Object::SetByteValue(), and sObjectMgr.

Referenced by Create(), StaticTransport::Create(), Spell::EffectActivateObject(), and SetGoArtKit().

◆ SetGoArtKit() [2/2]

void GameObject::SetGoArtKit ( uint8  artkit,
GameObject go,
ObjectGuid::LowType  lowguid = 0 
)
static
1436{
1437 GameObjectData const* data = nullptr;
1438 if (go)
1439 {
1440 go->SetGoArtKit(artkit);
1441 data = go->GetGameObjectData();
1442 }
1443 else if (lowguid)
1444 data = sObjectMgr->GetGameObjectData(lowguid);
1445
1446 if (data)
1447 const_cast<GameObjectData*>(data)->artKit = artkit;
1448}

References GetGameObjectData(), SetGoArtKit(), and sObjectMgr.

◆ SetGoState()

void GameObject::SetGoState ( GOState  state)
2504{
2506
2507 sScriptMgr->OnGameObjectStateChanged(this, state);
2508
2509 if (m_model)
2510 {
2511 if (!IsInWorld())
2512 return;
2513
2514 // pussywizard: this startOpen is unneeded here, collision depends entirely on current GOState
2516 // pussywizard: commented out everything below
2517
2518 // startOpen determines whether we are going to add or remove the LoS on activation
2519 /*bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
2520
2521 if (GetGameObjectData() && GetGameObjectData()->go_state == GO_STATE_READY)
2522 startOpen = !startOpen;
2523
2524 if (state == GO_STATE_ACTIVE || state == GO_STATE_ACTIVE_ALTERNATIVE)
2525 EnableCollision(startOpen);
2526 else if (state == GO_STATE_READY)
2527 EnableCollision(!startOpen);*/
2528 }
2529 /* Whenever a gameobject inside an instance changes
2530 * save it's state on the database to be loaded properly
2531 * on server restart or crash.
2532 */
2534 {
2535 SaveStateToDB();
2536 }
2537}
bool IsAllowedToSaveToDB() const
Definition GameObject.h:357
void SaveStateToDB()
Definition GameObject.cpp:2598

References EnableCollision(), GAMEOBJECT_BYTES_1, GO_STATE_READY, IsAllowedToSaveToDB(), IsInstanceGameobject(), Object::IsInWorld(), IsTransport(), m_model, SaveStateToDB(), Object::SetByteValue(), and sScriptMgr.

Referenced by go_suppression_device::Activate(), instance_naxxramas::ActivateWingPortal(), boss_thorim::CloseDoors(), Create(), StaticTransport::Create(), MotionTransport::CreateMoTrans(), boss_thorim::DamageTaken(), go_suppression_device::Deactivate(), Delete(), DespawnOrUnsummon(), go_chromaggus_lever::GossipHello(), InstanceScript::HandleGameObject(), go_empowering_blood_orb::HandleObjectUse(), npc_midsummer_bonfire::Ignite(), go_magtheridons_head::InitializeAI(), instance_sunken_temple::instance_sunken_temple_InstanceMapScript::OnGameObjectCreate(), instance_blackfathom_deeps::instance_blackfathom_deeps_InstanceMapScript::OnGameObjectCreate(), instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::OnGameObjectCreate(), instance_dire_maul::instance_dire_maul_InstanceMapScript::OnGameObjectCreate(), instance_gundrak::instance_gundrak_InstanceMapScript::OnGameObjectCreate(), instance_ulduar::instance_ulduar_InstanceMapScript::OnGameObjectCreate(), instance_karazhan::instance_karazhan_InstanceMapScript::OnGameObjectCreate(), instance_stratholme::instance_stratholme_InstanceMapScript::OnGameObjectCreate(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::OnGameObjectCreate(), instance_ahnkahet::instance_ahnkahet_InstanceScript::OnGameObjectCreate(), instance_pit_of_saron::instance_pit_of_saron_InstanceScript::OnGameObjectCreate(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnGameObjectCreate(), instance_naxxramas::OnGameObjectCreate(), instance_halls_of_stone::instance_halls_of_stone_InstanceMapScript::OnGameObjectCreate(), go_palehoof_sphere::OnGossipHello(), go_bristlelimb_cage::OnGossipHello(), instance_ulduar::instance_ulduar_InstanceMapScript::OpenIfDone(), FrozenThroneResetWorker::operator()(), npc_wounded_blood_elf::npc_wounded_blood_elfAI::Reset(), instance_halls_of_stone::instance_halls_of_stone_InstanceMapScript::SetData(), BattlegroundIC::StartingEventOpenDoors(), SwitchDoorOrButton(), brann_bronzebeard::SwitchHeadVisual(), boss_flame_leviathan::TurnGates(), MotionTransport::Update(), Update(), InstanceScript::UpdateDoorState(), BattlegroundRV::UpdatePillars(), Use(), and npc_wounded_blood_elf::npc_wounded_blood_elfAI::WaypointReached().

◆ SetGoType()

void GameObject::SetGoType ( GameobjectTypes  type)
inline

◆ SetLinkedTrap()

void GameObject::SetLinkedTrap ( GameObject linkedTrap)
inline
261{ m_linkedTrap = linkedTrap->GetGUID(); }

References Object::GetGUID(), and m_linkedTrap.

Referenced by Create().

◆ SetLootGenerationTime()

void GameObject::SetLootGenerationTime ( )
2959{
2961}

References GameTime::GetGameTime(), and m_lootGenerationTime.

Referenced by Player::SendLoot().

◆ SetLootMode()

void GameObject::SetLootMode ( uint16  lootMode)
inline

◆ SetLootRecipient() [1/2]

void GameObject::SetLootRecipient ( Creature creature)
2673{
2674 // set the player whose group should receive the right
2675 // to loot the creature after it dies
2676 // should be set to nullptr after the loot disappears
2677 if (!creature)
2678 {
2682 return;
2683 }
2684
2688}
ObjectGuid GetLootRecipientGUID() const
Definition Creature.h:232
ObjectGuid::LowType GetLootRecipientGroupGUID() const
Definition Creature.h:234
void Clear()
Definition ObjectGuid.h:141
void ResetAllowedLooters()
Definition Object.cpp:3217
void SetAllowedLooters(GuidUnorderedSet const looters)
Definition Object.cpp:3212
GuidUnorderedSet const & GetAllowedLooters() const
Definition Object.cpp:3232

References ObjectGuid::Clear(), WorldObject::GetAllowedLooters(), Creature::GetLootRecipientGroupGUID(), Creature::GetLootRecipientGUID(), m_lootRecipient, m_lootRecipientGroup, WorldObject::ResetAllowedLooters(), and WorldObject::SetAllowedLooters().

Referenced by boss_thorim::DamageTaken(), instance_ulduar::instance_ulduar_InstanceMapScript::OnGameObjectCreate(), and instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnGameObjectCreate().

◆ SetLootRecipient() [2/2]

void GameObject::SetLootRecipient ( Map map)
2691{
2692 Group* group = nullptr;
2693 Map::PlayerList const& PlayerList = map->GetPlayers();
2694 for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
2695 {
2696 if (Player* groupMember = i->GetSource())
2697 {
2698 if (groupMember->IsGameMaster() || groupMember->IsSpectator())
2699 {
2700 continue;
2701 }
2702
2703 if (!m_lootRecipient)
2704 {
2705 m_lootRecipient = groupMember->GetGUID();
2706 }
2707
2708 Group* memberGroup = groupMember->GetGroup();
2709 if (memberGroup && !group)
2710 {
2711 group = memberGroup;
2713 }
2714
2715 if (memberGroup == group)
2716 {
2717 AddAllowedLooter(groupMember->GetGUID());
2718 }
2719 }
2720 }
2721
2722 if (!group)
2723 {
2725 }
2726}
ObjectGuid GetGUID() const
Definition Group.cpp:2512
Definition LinkedList.h:139
Definition MapRefMgr.h:26
iterator begin()
Definition MapRefMgr.h:36
iterator end()
Definition MapRefMgr.h:37
PlayerList const & GetPlayers() const
Definition Map.h:335
LowType GetCounter() const
Definition ObjectGuid.h:149
void AddAllowedLooter(ObjectGuid guid)
Definition Object.cpp:3207

References WorldObject::AddAllowedLooter(), MapRefMgr::begin(), MapRefMgr::end(), ObjectGuid::GetCounter(), Group::GetGUID(), Map::GetPlayers(), m_lootRecipient, and m_lootRecipientGroup.

◆ SetLootState()

void GameObject::SetLootState ( LootState  s,
Unit unit = nullptr 
)
2469{
2470 m_lootState = state;
2471
2472 if (unit)
2473 _lootStateUnitGUID = unit->GetGUID();
2474 else
2476
2477 AI()->OnStateChanged(state, unit);
2478 sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
2479
2480 // Start restock timer if the chest is partially looted or not looted at all
2481 if (GetGoType() == GAMEOBJECT_TYPE_CHEST && state == GO_ACTIVATED && GetGOInfo()->chest.chestRestockTime > 0 && m_restockTime == 0s)
2482 {
2484 }
2485
2486 // pussywizard: lootState has nothing to do with collision, it depends entirely on GOState. Loot state is for timed close/open door and respawning, which then sets GOState
2487 /*if (m_model)
2488 {
2489 // startOpen determines whether we are going to add or remove the LoS on activation
2490 bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
2491
2492 // Use the current go state
2493 if (GetGoState() == GO_STATE_ACTIVE)
2494 startOpen = !startOpen;
2495
2496 if (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED)
2497 EnableCollision(startOpen);
2498 else if (state == GO_READY)
2499 EnableCollision(!startOpen);
2500 }*/
2501}
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:30
@ GO_ACTIVATED
Definition GameObject.h:112
virtual void OnStateChanged(uint32, Unit *)
Definition GameObjectAI.h:64
ObjectGuid _lootStateUnitGUID
Definition GameObject.h:410
uint32 chestRestockTime
Definition GameObjectData.h:86

References _lootStateUnitGUID, AI(), GameObjectTemplate::chestRestockTime, ObjectGuid::Clear(), GAMEOBJECT_TYPE_CHEST, GameTime::GetGameTime(), GetGOInfo(), GetGoType(), Object::GetGUID(), GO_ACTIVATED, m_lootState, m_restockTime, GameObjectAI::OnStateChanged(), and sScriptMgr.

Referenced by go_suppression_device::Activate(), Delete(), DespawnOrUnsummon(), WorldSession::DoLootRelease(), Spell::EffectOpenLock(), spell_q9452_cast_net::HandleActiveObject(), spell_q10612_10613_the_fel_and_the_furious::HandleScriptEffect(), go_eredar_twins_blaze::InitializeAI(), instance_deadmines::instance_deadmines_InstanceMapScript::OnGameObjectCreate(), instance_oculus::instance_oculus_InstanceMapScript::OnGameObjectCreate(), go_massive_seaforium_charge::OnGossipHello(), SmartScript::ProcessAction(), go_direbrew_mole_machine::go_direbrew_mole_machineAI::Reset(), ResetDoorOrButton(), Map::ScriptsProcess(), Player::SendLoot(), boss_flame_leviathan::TurnHealStations(), Update(), Use(), and UseDoorOrButton().

◆ SetOwnerGUID()

void GameObject::SetOwnerGUID ( ObjectGuid  owner)
inline
165 {
166 // Owner already found and different than expected owner - remove object from old owner
167 if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
168 {
169 ABORT();
170 }
171 m_spawnedByDefault = false; // all object with owner is despawned after delay
173 }
#define ABORT
Definition Errors.h:76
void SetGuidValue(uint16 index, ObjectGuid value)
Definition Object.cpp:716

References ABORT, GetOwnerGUID(), m_spawnedByDefault, OBJECT_FIELD_CREATED_BY, and Object::SetGuidValue().

Referenced by Unit::AddGameObject(), Spell::EffectTransmitted(), go_eredar_twins_blaze::InitializeAI(), Unit::RemoveAllGameObjects(), RemoveFromOwner(), and Unit::RemoveGameObject().

◆ SetPhaseMask()

void GameObject::SetPhaseMask ( uint32  newPhaseMask,
bool  update 
)
overridevirtual

◆ SetPosition() [1/2]

void GameObject::SetPosition ( float  x,
float  y,
float  z,
float  o 
)
2889{
2890 // pussywizard: do not call for MotionTransport and other gobjects not in grid
2891
2892 if (!Acore::IsValidMapCoord(x, y, z, o))
2893 return;
2894
2895 GetMap()->GameObjectRelocation(this, x, y, z, o);
2896}
void GameObjectRelocation(GameObject *go, float x, float y, float z, float o)
Definition Map.cpp:848
bool IsValidMapCoord(float c)
Definition GridDefines.h:210

References Map::GameObjectRelocation(), WorldObject::GetMap(), and Acore::IsValidMapCoord().

Referenced by instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnGameObjectCreate().

◆ SetPosition() [2/2]

void GameObject::SetPosition ( Position const &  pos)
inline
317{ SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
void SetPosition(float x, float y, float z, float o)
Definition GameObject.cpp:2888

References Position::GetOrientation(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), and SetPosition().

Referenced by SetPosition().

◆ SetRespawnDelay()

void GameObject::SetRespawnDelay ( int32  respawn)
1298{
1299 m_respawnDelayTime = respawn > 0 ? respawn : 0;
1300}

References m_respawnDelayTime.

Referenced by go_strange_pool::OnGossipHello(), and SetRespawnTime().

◆ SetRespawnTime()

◆ SetSpawnedByDefault()

void GameObject::SetSpawnedByDefault ( bool  b)
inline

◆ SetSpellId()

void GameObject::SetSpellId ( uint32  id)
inline

◆ SetTransportPathRotation()

void GameObject::SetTransportPathRotation ( float  qx,
float  qy,
float  qz,
float  qw 
)
2274{
2279}
@ GAMEOBJECT_PARENTROTATION
Definition UpdateFields.h:400
void SetFloatValue(uint16 index, float value)
Definition Object.cpp:730

References GAMEOBJECT_PARENTROTATION, and Object::SetFloatValue().

Referenced by Create(), StaticTransport::Create(), MotionTransport::CreateMoTrans(), and BattlegroundSA::ResetObjs().

◆ SetWorldRotation()

void GameObject::SetWorldRotation ( G3D::Quat const &  rot)
2262{
2263 G3D::Quat rotation = rot;
2264 // If the quaternion is zero (e.g. dynamically spawned GOs with no rotation),
2265 // fall back to computing rotation from orientation to avoid NaN from unitize()
2266 if (G3D::fuzzyEq(rotation.magnitude(), 0.0f))
2267 rotation = G3D::Quat::fromAxisAngleRotation(G3D::Vector3::unitZ(), GetOrientation());
2268 rotation.unitize();
2269 WorldRotation = rotation;
2271}
void UpdatePackedRotation()
Definition GameObject.cpp:2243

References Position::GetOrientation(), UpdatePackedRotation(), and WorldRotation.

Referenced by Create(), MotionTransport::CreateMoTrans(), and SetWorldRotationAngles().

◆ SetWorldRotationAngles()

void GameObject::SetWorldRotationAngles ( float  z_rot,
float  y_rot,
float  x_rot 
)
2282{
2283 SetWorldRotation(G3D::Quat(G3D::Matrix3::fromEulerAnglesZYX(z_rot, y_rot, x_rot)));
2284}

References SetWorldRotation().

Referenced by StaticTransport::Create().

◆ SwitchDoorOrButton()

void GameObject::SwitchDoorOrButton ( bool  activate,
bool  alternative = false 
)
private
1451{
1452 if (activate)
1454 else
1456
1457 if (GetGoState() == GO_STATE_READY) //if closed -> open
1459 else //if open -> close
1461}
@ GO_FLAG_IN_USE
Definition SharedDefines.h:1607

References GetGoState(), GO_FLAG_IN_USE, GO_STATE_ACTIVE, GO_STATE_ACTIVE_ALTERNATIVE, GO_STATE_READY, RemoveGameObjectFlag(), SetGameObjectFlag(), and SetGoState().

Referenced by Create(), ResetDoorOrButton(), and UseDoorOrButton().

◆ ToMotionTransport() [1/2]

◆ ToMotionTransport() [2/2]

MotionTransport const * GameObject::ToMotionTransport ( ) const
inline
329{ if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<MotionTransport const*>(this); else return nullptr; }

References GAMEOBJECT_TYPE_MO_TRANSPORT, and GetGOInfo().

◆ ToStaticTransport() [1/2]

◆ ToStaticTransport() [2/2]

StaticTransport const * GameObject::ToStaticTransport ( ) const
inline
326{ if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<StaticTransport const*>(this); else return nullptr; }

References GAMEOBJECT_TYPE_TRANSPORT, and GetGOInfo().

◆ ToTransport() [1/2]

◆ ToTransport() [2/2]

Transport const * GameObject::ToTransport ( ) const
inline
323{ if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT || GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<Transport const*>(this); else return nullptr; }

References GAMEOBJECT_TYPE_MO_TRANSPORT, GAMEOBJECT_TYPE_TRANSPORT, and GetGOInfo().

◆ TriggeringLinkedGameObject()

void GameObject::TriggeringLinkedGameObject ( uint32  trapEntry,
Unit target 
)
1370{
1371 GameObjectTemplate const* trapInfo = sObjectMgr->GetGameObjectTemplate(trapEntry);
1372 if (!trapInfo || trapInfo->type != GAMEOBJECT_TYPE_TRAP)
1373 return;
1374
1375 SpellInfo const* trapSpell = sSpellMgr->GetSpellInfo(trapInfo->trap.spellId);
1376 if (!trapSpell) // checked at load already
1377 return;
1378
1379 // xinef: many spells have range 0 but radius > 0
1380 float range = float(target->GetSpellMaxRangeForTarget(GetOwner(), trapSpell));
1381 if (range < 1.0f)
1382 range = 5.0f;
1383
1384 // found correct GO
1385 // xinef: we should use the trap (checks for despawn type)
1386 if (GameObject* trapGO = GetLinkedTrap())
1387 {
1388 trapGO->Use(target); // trapGO->CastSpell(target, trapInfo->trap.spellId);
1389 }
1390}
float GetSpellMaxRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition Unit.cpp:11891
uint32 spellId
Definition GameObjectData.h:119
struct GameObjectTemplate::@236::@243 trap

References GAMEOBJECT_TYPE_TRAP, GetLinkedTrap(), GetOwner(), Unit::GetSpellMaxRangeForTarget(), sObjectMgr, GameObjectTemplate::spellId, sSpellMgr, GameObjectTemplate::trap, and GameObjectTemplate::type.

Referenced by Spell::SendLoot(), and Use().

◆ Update()

void GameObject::Update ( uint32  p_time)
overridevirtual
Todo:
This is activation radius. Casting radius must be selected from spell data.
Todo:
Todo:
Move activated state code to GO_ACTIVATED, in this place just check for activation and set state.

Reimplemented from WorldObject.

Reimplemented in MotionTransport, and StaticTransport.

439{
441
442 if (AI())
443 AI()->UpdateAI(diff);
444 else if (!AIM_Initialize())
445 LOG_ERROR("entities.gameobject", "Could not initialize GameObjectAI");
446
447 if (m_despawnDelay)
448 {
449 if (m_despawnDelay > diff)
450 {
451 m_despawnDelay -= diff;
452 }
453 else
454 {
455 m_despawnDelay = 0;
457 }
458 }
459
460 for (std::unordered_map<ObjectGuid, int32>::iterator itr = m_SkillupList.begin(); itr != m_SkillupList.end();)
461 {
462 if (itr->second > 0)
463 {
464 if (itr->second > static_cast<int32>(diff))
465 {
466 itr->second -= static_cast<int32>(diff);
467 ++itr;
468 }
469 else
470 {
471 itr = m_SkillupList.erase(itr);
472 }
473 }
474 else
475 {
476 ++itr;
477 }
478 }
479
480 switch (m_lootState)
481 {
482 case GO_NOT_READY:
483 {
484 switch (GetGoType())
485 {
487 {
488 // Arming Time for GAMEOBJECT_TYPE_TRAP (6)
489 GameObjectTemplate const* goInfo = GetGOInfo();
490 // Bombs
491 if (goInfo->trap.type == 2)
492 m_cooldownTime = GameTime::GetGameTimeMS().count() + 10 * IN_MILLISECONDS; // Hardcoded tooltip value
493 else if (GetOwner())
495
497 break;
498 }
500 {
501 // fishing code (bobber ready)
503 {
504 // splash bobber (bobber ready now)
505 Unit* caster = GetOwner();
506 if (caster && caster->IsPlayer())
507 {
510
511 UpdateData udata;
512 WorldPacket packet;
513 BuildValuesUpdateBlockForPlayer(&udata, caster->ToPlayer());
514 udata.BuildPacket(packet);
515 caster->ToPlayer()->SendDirectMessage(&packet);
516
518 }
519
520 m_lootState = GO_READY; // can be successfully open with some chance
521 }
522 return;
523 }
525 {
527 return;
528 GameObjectTemplate const* info = GetGOInfo();
529
531
533 {
535 return;
536 }
537
538 Unit* owner = GetOwner();
539 Unit* spellCaster = owner ? owner : ObjectAccessor::GetPlayer(*this, m_ritualOwnerGUID);
540 if (!spellCaster)
541 {
543 return;
544 }
545
546 uint32 spellId = info->summoningRitual.spellId;
547
548 if (spellId == 62330) // GO store nonexistent spell, replace by expected
549 {
550 // spell have reagent and mana cost but it not expected use its
551 // it triggered spell in fact casted at currently channeled GO
552 spellId = 61993;
553 }
554
555 // Cast casterTargetSpell at a random GO user
556 // on the current DB there is only one gameobject that uses this (Ritual of Doom)
557 // and its required target number is 1 (outter for loop will run once)
558 if (info->summoningRitual.casterTargetSpell && info->summoningRitual.casterTargetSpell != 1) // No idea why this field is a bool in some cases
559 for (uint32 i = 0; i < info->summoningRitual.casterTargetSpellTargets; i++)
560 // m_unique_users can contain only player GUIDs
562 spellCaster->CastSpell(target, info->summoningRitual.casterTargetSpell, true);
563
564 // finish owners spell
565 // xinef: properly process event cooldowns
566 if (owner)
567 {
568 if (Spell* spell = owner->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
569 {
570 spell->SendChannelUpdate(0);
571 spell->finish(false);
572 }
573 }
574
575 // can be deleted now
578 else
580
582 spellCaster->CastSpell(spellCaster, spellId, true);
583 return;
584 }
587 {
588 return;
589 }
590 // If there is no restock timer, or if the restock timer passed, the chest becomes ready to loot
591 m_restockTime = 0s;
594 break;
595 default:
596 m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY
597 break;
598 }
599 [[fallthrough]];
600 }
601 case GO_READY:
602 {
603 if (m_respawnTime > 0) // timer on
604 {
605 time_t now = GameTime::GetGameTime().count();
606 if (m_respawnTime <= now) // timer expired
607 {
608 ObjectGuid dbtableHighGuid = ObjectGuid::Create<HighGuid::GameObject>(GetEntry(), m_spawnId);
609 time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
610 if (linkedRespawntime) // Can't respawn, the master is dead
611 {
612 ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
613 if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
615 else
616 m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little
617 SaveRespawnTime(); // also save to DB immediately
618 return;
619 }
620
621 m_respawnTime = 0;
622 m_SkillupList.clear();
623 m_usetimes = 0;
624
625 switch (GetGoType())
626 {
627 case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
628 {
629 Unit* caster = GetOwner();
630 if (caster && caster->IsPlayer())
631 {
632 caster->ToPlayer()->RemoveGameObject(this, false);
633
635 caster->ToPlayer()->SendDirectMessage(&data);
636 }
637 // can be deleted
639 return;
640 }
643 //we need to open doors if they are closed (add there another condition if this code breaks some usage, but it need to be here for battlegrounds)
644 if (GetGoState() != GO_STATE_READY)
646 break;
648 // Initialize a new max fish count on respawn
650 break;
651 default:
652 break;
653 }
654
655 if (!m_spawnedByDefault) // despawn timer
656 {
657 // can be despawned or destroyed
659 return;
660 }
661
662 // Xinef: Call AI Reset (required for example in SmartAI to clear one time events)
663 if (AI())
664 AI()->Reset();
665
666 // respawn timer
667 uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<GameObject>(m_spawnId) : 0;
668 if (poolid)
669 sPoolMgr->UpdatePool<GameObject>(GetMap()->GetPoolData(), poolid, m_spawnId);
670 else
671 GetMap()->AddToMap(this);
672 }
673 }
674
675 if (isSpawned())
676 {
677 // traps can have time and can not have
678 GameObjectTemplate const* goInfo = GetGOInfo();
679 if (goInfo->type == GAMEOBJECT_TYPE_TRAP)
680 {
682 break;
683
684 // Type 2 - Bomb (will go away after casting it's spell)
685 if (goInfo->trap.type == 2)
686 {
688 break;
689 }
690
693 float radius = float(goInfo->trap.diameter) * 0.5f;
694 if (!goInfo->trap.diameter)
695 {
696 // Cast in other case (at some triggering/linked go/etc explicit call)
697 if (goInfo->trap.cooldown != 3 || m_respawnTime > 0)
698 {
699 break;
700 }
701
702 radius = 3.f;
703 }
704
705 // Type 0 and 1 - trap (type 0 will not get removed after casting a spell)
706 Unit* owner = GetOwner();
707 Unit* target = nullptr; // pointer to appropriate target if found any
708
709 // Note: this hack with search required until GO casting not implemented
710 // search unfriendly creature
711 if (owner && goInfo->trap.autoCloseTime != -1) // hunter trap
712 {
715 Cell::VisitObjects(this, searcher, radius);
716 }
717 else // environmental trap
718 {
719 // environmental damage spells already have around enemies targeting but this not help in case not existed GO casting support
720 // affect only players
721 Player* player = nullptr;
722 Acore::AnyPlayerInObjectRangeCheck checker(this, radius, true, true);
723 Acore::PlayerSearcher<Acore::AnyPlayerInObjectRangeCheck> searcher(this, player, checker);
724 Cell::VisitObjects(this, searcher, radius);
725 target = player;
726 }
727
728 if (target)
729 {
730 SetLootState(GO_ACTIVATED, target);
731 }
732 }
733 else if (uint32 max_charges = goInfo->GetCharges())
734 {
735 if (m_usetimes >= max_charges)
736 {
737 m_usetimes = 0;
738 SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed
739 }
740 }
741 }
742
743 break;
744 }
745 case GO_ACTIVATED:
746 {
747 switch (GetGoType())
748 {
751 if (GetGOInfo()->GetAutoCloseTime() && GameTime::GetGameTimeMS().count() >= m_cooldownTime)
753 break;
756 {
758
760 }
761 break;
764 {
765 if (m_groupLootTimer <= diff)
766 {
767 Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID);
768 if (group)
769 group->EndRoll(&loot);
772 }
773 else
774 {
775 m_groupLootTimer -= diff;
776 }
777 }
778
779 // Non-consumable chest was partially looted and restock time passed, restock all loot now
781 {
782 m_restockTime = 0s;
785 }
786 break;
788 {
789 GameObjectTemplate const* goInfo = GetGOInfo();
790 if (goInfo->trap.type == 2)
791 {
792 if (goInfo->trap.spellId)
793 CastSpell(nullptr, goInfo->trap.spellId); // FIXME: null target won't work for target type 1
795 }
796 else if (Unit* target = ObjectAccessor::GetUnit(*this, _lootStateUnitGUID))
797 {
798 if (goInfo->trap.spellId)
799 CastSpell(target, goInfo->trap.spellId);
800
801 m_cooldownTime = GameTime::GetGameTimeMS().count() + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)) * IN_MILLISECONDS; // template or 4 seconds
802
803 if (goInfo->trap.type == 1)
805 else if (!goInfo->trap.type)
807
808 // Battleground gameobjects have data2 == 0 && data5 == 3
809 if (!goInfo->trap.diameter && goInfo->trap.cooldown == 3)
810 if (Player* player = target->ToPlayer())
811 if (Battleground* bg = player->GetBattleground())
812 bg->HandleTriggerBuff(this);
813 }
814 break;
815 }
816 default:
817 break;
818 }
819 break;
820 }
822 {
823 // If nearby linked trap exists, despawn it
824 if (GameObject* linkedTrap = GetLinkedTrap())
825 {
826 linkedTrap->DespawnOrUnsummon();
827 }
828
829 //if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
831 {
833
834 //any return here in case battleground traps
835 // Xinef: Do not return here for summoned gos that should be deleted few lines below
836 // Xinef: Battleground objects are treated as spawned by default
837 if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
838 if ((addon->flags & GO_FLAG_NODESPAWN) && isSpawnedByDefault())
839 return;
840 }
841
842 loot.clear();
843
844 // Do not delete chests or goobers that are not consumed on loot, while still allowing them to despawn when they expire if summoned
845 bool isSummonedAndExpired = (GetOwner() || GetSpellId()) && m_respawnTime == 0;
846 if ((GetGoType() == GAMEOBJECT_TYPE_CHEST || GetGoType() == GAMEOBJECT_TYPE_GOOBER) && !GetGOInfo()->IsDespawnAtAction() && !isSummonedAndExpired)
847 {
849 {
850 // Start restock timer when the chest is fully looted
854 }
855 else
856 {
858 }
859
861 return;
862 }
863 else if (GetOwnerGUID() || GetSpellId())
864 {
866 Delete();
867 return;
868 }
869
871
872 //burning flags in some battlegrounds, if you find better condition, just add it
873 if (GetGOInfo()->IsDespawnAtAction() || GetGoAnimProgress() > 0)
874 {
876 //reset flags
877 if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
879 }
880
882 return;
883
885 {
886 m_respawnTime = 0;
887 DestroyForVisiblePlayers(); // xinef: old UpdateObjectVisibility();
888 return;
889 }
890
891 uint32 dynamicRespawnDelay = GetMap()->ApplyDynamicModeRespawnScaling(this, m_respawnDelayTime);
892 m_respawnTime = GameTime::GetGameTime().count() + dynamicRespawnDelay;
893
894 // if option not set then object will be saved at grid unload
895 if (GetMap()->IsDungeon())
897
898 DestroyForVisiblePlayers(); // xinef: old UpdateObjectVisibility();
899 break;
900 }
901 }
902
903 sScriptMgr->OnGameObjectUpdate(this, diff);
904}
constexpr auto DAY
Definition Common.h:49
#define FISHING_BOBBER_READY_TIME
Definition GameObject.h:117
@ GAMEOBJECT_TYPE_BUTTON
Definition SharedDefines.h:1565
Definition GridNotifiers.h:1380
virtual void UpdateAI(uint32)
Definition GameObjectAI.h:41
virtual void Reset()
Definition GameObjectAI.h:45
void CheckRitualList()
Definition GameObject.cpp:217
void Delete()
Definition GameObject.cpp:976
uint32 GetUniqueUseCount() const
Definition GameObject.h:242
bool isSpawnedByDefault() const
Definition GameObject.h:196
void SendCustomAnim(uint32 anim)
Definition GameObject.cpp:2148
void ResetDoorOrButton()
Definition GameObject.cpp:1403
void DespawnOrUnsummon(Milliseconds delay=0ms, Seconds forcedRespawnTime=0s)
Definition GameObject.cpp:927
void CastSpell(Unit *target, uint32 spell)
Definition GameObject.cpp:2083
ObjectGuid m_ritualOwnerGUID
Definition GameObject.h:386
void EndRoll(Loot *loot)
Definition Group.cpp:1545
time_t GetLinkedRespawnTime(ObjectGuid guid) const
Definition Map.cpp:3028
uint32 ApplyDynamicModeRespawnScaling(WorldObject const *obj, uint32 respawnDelay) const
Definition Map.cpp:1730
void BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target)
Definition Object.cpp:250
bool IsPlayer() const
Definition Object.h:201
Player * ToPlayer()
Definition Object.h:202
void AddToObjectUpdateIfNeeded()
Definition Object.cpp:517
void RemoveGameObject(GameObject *gameObj, bool del)
Definition Unit.cpp:6601
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition Unit.h:1577
Definition UpdateData.h:52
bool BuildPacket(WorldPacket &packet)
Definition UpdateData.cpp:48
void DestroyForVisiblePlayers()
Definition Object.cpp:3050
virtual void Update(uint32 diff)
Definition Object.cpp:1072
@ SMSG_FISH_ESCAPED
Definition Opcodes.h:487
auto SelectRandomContainerElement(C const &container) -> typename std::add_const< decltype(*std::begin(container))>::type &
Definition Containers.h:133
Milliseconds GetGameTimeMS()
Definition GameTime.cpp:43
Definition GridNotifiers.h:533
Definition GridNotifiers.h:412
uint32 startDelay
Definition GameObjectData.h:123
uint32 casterTargetSpell
Definition GameObjectData.h:236
uint32 GetCharges() const
Definition GameObjectData.h:480
uint32 reqParticipants
Definition GameObjectData.h:232
uint32 consumable
Definition GameObjectData.h:87
uint32 cooldown
Definition GameObjectData.h:121
uint32 ritualPersistent
Definition GameObjectData.h:235
uint32 autoCloseTime
Definition GameObjectData.h:48
uint32 casterTargetSpellTargets
Definition GameObjectData.h:237
uint32 diameter
Definition GameObjectData.h:118

References _lootStateUnitGUID, Map::AddToMap(), Object::AddToObjectUpdateIfNeeded(), AI(), AIM_Initialize(), Map::ApplyDynamicModeRespawnScaling(), GameObjectTemplate::autoCloseTime, UpdateData::BuildPacket(), Object::BuildValuesUpdateBlockForPlayer(), GameObjectTemplate::casterTargetSpell, GameObjectTemplate::casterTargetSpellTargets, Unit::CastSpell(), CastSpell(), CheckRitualList(), GameObjectTemplate::chest, GameObjectTemplate::chestRestockTime, Loot::clear(), ClearRitualList(), GameObjectTemplate::consumable, GameObjectTemplate::cooldown, CURRENT_CHANNELED_SPELL, DAY, Delete(), DespawnOrUnsummon(), WorldObject::DestroyForVisiblePlayers(), GameObjectTemplate::diameter, Group::EndRoll(), FISHING_BOBBER_READY_TIME, GameObjectValue::FishingHole, GAMEOBJECT_TYPE_BUTTON, GAMEOBJECT_TYPE_CHEST, GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_FISHINGHOLE, GAMEOBJECT_TYPE_FISHINGNODE, GAMEOBJECT_TYPE_GOOBER, GAMEOBJECT_TYPE_SUMMONING_RITUAL, GAMEOBJECT_TYPE_TRAP, GameObjectTemplate::GetCharges(), Unit::GetCurrentSpell(), Object::GetEntry(), GameTime::GetGameTime(), GameTime::GetGameTimeMS(), GetGoAnimProgress(), GetGOInfo(), GetGoState(), GetGoType(), Object::GetGUID(), Map::GetLinkedRespawnTime(), GetLinkedTrap(), WorldObject::GetMap(), GetOwner(), GetOwnerGUID(), ObjectAccessor::GetPlayer(), Map::GetPoolData(), GetSpellId(), GetTemplateAddon(), GetUniqueUseCount(), ObjectAccessor::GetUnit(), GO_ACTIVATED, GO_FLAG_IN_USE, GO_FLAG_NODESPAWN, GO_JUST_DEACTIVATED, GO_NOT_READY, GO_READY, GO_STATE_ACTIVE, GO_STATE_READY, IN_MILLISECONDS, GameObjectTemplate::IsDespawnAtAction(), Object::IsPlayer(), isSpawned(), isSpawnedByDefault(), LOG_ERROR, loot, lootingGroupLowGUID, m_cooldownTime, m_despawnDelay, m_despawnRespawnTime, m_goValue, m_groupLootTimer, m_lootState, m_respawnDelayTime, m_respawnTime, m_restockTime, m_ritualOwnerGUID, m_SkillupList, m_spawnedByDefault, m_spawnId, m_unique_users, m_usetimes, GameObjectValue::MaxOpens, GameObjectTemplate::maxSuccessOpens, GameObjectTemplate::minSuccessOpens, MINUTE, Unit::RemoveGameObject(), RemoveGameObjectFlag(), ReplaceAllGameObjectFlags(), GameObjectTemplate::reqParticipants, GameObjectAI::Reset(), ResetDoorOrButton(), GameObjectTemplate::ritualPersistent, SaveRespawnTime(), Acore::Containers::SelectRandomContainerElement(), SendCustomAnim(), Player::SendDirectMessage(), WorldObject::SendObjectDeSpawnAnim(), SetGoState(), SetLootState(), SetRespawnTime(), sGroupMgr, SMSG_FISH_ESCAPED, sObjectMgr, GameObjectTemplate::spellId, sPoolMgr, sScriptMgr, GameObjectTemplate::startDelay, GameObjectTemplate::summoningRitual, Object::ToPlayer(), GameObjectTemplate::trap, GameObjectTemplate::type, WorldObject::Update(), GameObjectAI::UpdateAI(), WorldObject::UpdateObjectVisibility(), urand(), and Cell::VisitObjects().

Referenced by StaticTransport::Update().

◆ UpdateModel()

void GameObject::UpdateModel ( )
protected
2646{
2647 if (!IsInWorld())
2648 return;
2649 if (m_model)
2650 if (GetMap()->ContainsGameObjectModel(*m_model))
2652 delete m_model;
2653 m_model = CreateModel();
2654 if (m_model)
2656}

References CreateModel(), WorldObject::GetMap(), Map::InsertGameObjectModel(), Object::IsInWorld(), m_model, and Map::RemoveGameObjectModel().

Referenced by SetDisplayId().

◆ UpdateModelPosition()

void GameObject::UpdateModelPosition ( )

◆ UpdatePackedRotation()

void GameObject::UpdatePackedRotation ( )
private
2244{
2245 static const int32 PACK_YZ = 1 << 20;
2246 static const int32 PACK_X = PACK_YZ << 1;
2247 static const int32 PACK_YZ_MASK = (PACK_YZ << 1) - 1;
2248 static const int32 PACK_X_MASK = (PACK_X << 1) - 1;
2249 int8 w_sign = (WorldRotation.w >= 0.f ? 1 : -1);
2250 int64 x = int32(WorldRotation.x * PACK_X) * w_sign & PACK_X_MASK;
2251 int64 y = int32(WorldRotation.y * PACK_YZ) * w_sign & PACK_YZ_MASK;
2252 int64 z = int32(WorldRotation.z * PACK_YZ) * w_sign & PACK_YZ_MASK;
2253 m_packedRotation = z | (y << 21) | (x << 42);
2254}
std::int8_t int8
Definition Define.h:105
std::int64_t int64
Definition Define.h:102

References m_packedRotation, and WorldRotation.

Referenced by SetWorldRotation().

◆ Use()

void GameObject::Use ( Unit user)
1464{
1465 // Xinef: we cannot use go with not selectable flags
1467 return;
1468
1469 // by default spell caster is user
1470 Unit* spellCaster = user;
1471 uint32 spellId = 0;
1472 uint32 triggeredFlags = TRIGGERED_NONE;
1473
1474 if (Player* playerUser = user->ToPlayer())
1475 {
1476 if (sScriptMgr->OnGossipHello(playerUser, this))
1477 return;
1478
1479 if (AI()->GossipHello(playerUser, false))
1480 return;
1481 }
1482
1483 // If cooldown data present in template
1484 if (uint32 cooldown = GetGOInfo()->GetCooldown())
1485 {
1487 return;
1488
1490 }
1491
1492 if (user->IsPlayer() && GetGoType() != GAMEOBJECT_TYPE_TRAP) // workaround for GO casting
1493 if (!m_goInfo->IsUsableMounted())
1495
1496 switch (GetGoType())
1497 {
1498 case GAMEOBJECT_TYPE_DOOR: //0
1499 //doors/buttons never really despawn, only reset to default state/flags
1500 UseDoorOrButton(0, false, user);
1501 return;
1502 case GAMEOBJECT_TYPE_BUTTON: //1
1503 //doors/buttons never really despawn, only reset to default state/flags
1504 UseDoorOrButton(0, false, user);
1505
1506 // Xinef: properly link possible traps
1507 if (uint32 trapEntry = GetGOInfo()->button.linkedTrap)
1508 TriggeringLinkedGameObject(trapEntry, user);
1509 return;
1511 {
1512 if (!user->IsPlayer())
1513 return;
1514
1515 Player* player = user->ToPlayer();
1516
1517 player->PrepareGossipMenu(this, GetGOInfo()->questgiver.gossipID, true);
1518 player->SendPreparedGossip(this);
1519 return;
1520 }
1521 case GAMEOBJECT_TYPE_TRAP: //6
1522 {
1523 GameObjectTemplate const* goInfo = GetGOInfo();
1524 if (goInfo->trap.spellId)
1525 CastSpell(user, goInfo->trap.spellId);
1526
1527 m_cooldownTime = GameTime::GetGameTimeMS().count() + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)) * IN_MILLISECONDS; // template or 4 seconds
1528
1529 if (goInfo->trap.type == 1) // Deactivate after trigger
1531
1532 return;
1533 }
1534 //Sitting: Wooden bench, chairs enzz
1535 case GAMEOBJECT_TYPE_CHAIR: //7
1536 {
1537 GameObjectTemplate const* info = GetGOInfo();
1538 if (!info)
1539 return;
1540
1541 if (!user->IsPlayer())
1542 return;
1543
1544 if (ChairListSlots.empty()) // this is called once at first chair use to make list of available slots
1545 {
1546 if (info->chair.slots > 0) // sometimes chairs in DB have error in fields and we dont know number of slots
1547 for (uint32 i = 0; i < info->chair.slots; ++i)
1548 ChairListSlots[i].Clear(); // Last user of current slot set to 0 (none sit here yet)
1549 else
1550 ChairListSlots[0].Clear(); // error in DB, make one default slot
1551 }
1552
1553 Player* player = user->ToPlayer();
1554
1555 // a chair may have n slots. we have to calculate their positions and teleport the player to the nearest one
1556
1557 float lowestDist = DEFAULT_VISIBILITY_DISTANCE;
1558
1559 uint32 nearest_slot = 0;
1560 float x_lowest = GetPositionX();
1561 float y_lowest = GetPositionY();
1562
1563 // the object orientation + 1/2 pi
1564 // every slot will be on that straight line
1565 float orthogonalOrientation = GetOrientation() + M_PI * 0.5f;
1566 // find nearest slot
1567 bool found_free_slot = false;
1568 for (ChairSlotAndUser::iterator itr = ChairListSlots.begin(); itr != ChairListSlots.end(); ++itr)
1569 {
1570 // the distance between this slot and the center of the go - imagine a 1D space
1571 float relativeDistance = (info->size * itr->first) - (info->size * (info->chair.slots - 1) / 2.0f);
1572
1573 float x_i = GetPositionX() + relativeDistance * cos(orthogonalOrientation);
1574 float y_i = GetPositionY() + relativeDistance * std::sin(orthogonalOrientation);
1575
1576 if (itr->second)
1577 {
1578 if (Player* ChairUser = ObjectAccessor::GetPlayer(*this, itr->second))
1579 {
1580 if (ChairUser->IsSitState() && ChairUser->getStandState() != UNIT_STAND_STATE_SIT && ChairUser->GetExactDist2d(x_i, y_i) < 0.1f)
1581 continue; // This seat is already occupied by ChairUser. NOTE: Not sure if the ChairUser->getStandState() != UNIT_STAND_STATE_SIT check is required.
1582 else
1583 itr->second.Clear(); // This seat is unoccupied.
1584 }
1585 else
1586 itr->second.Clear(); // The seat may of had an occupant, but they're offline.
1587 }
1588
1589 found_free_slot = true;
1590
1591 // calculate the distance between the player and this slot
1592 float thisDistance = player->GetDistance2d(x_i, y_i);
1593
1594 if (thisDistance <= lowestDist)
1595 {
1596 nearest_slot = itr->first;
1597 lowestDist = thisDistance;
1598 x_lowest = x_i;
1599 y_lowest = y_i;
1600 }
1601 }
1602
1603 if (found_free_slot)
1604 {
1605 ChairSlotAndUser::iterator itr = ChairListSlots.find(nearest_slot);
1606 if (itr != ChairListSlots.end())
1607 {
1608 itr->second = player->GetGUID(); //this slot in now used by player
1611 return;
1612 }
1613 }
1614
1615 return;
1616 }
1617 //big gun, its a spell/aura
1618 case GAMEOBJECT_TYPE_GOOBER: //10
1619 {
1620 GameObjectTemplate const* info = GetGOInfo();
1621
1622 // xinef: Goober cannot be used with this flag, skip
1624 return;
1625
1626 if (user->IsPlayer())
1627 {
1628 Player* player = user->ToPlayer();
1629
1630 if (info->goober.pageId) // show page...
1631 {
1633 data << GetGUID();
1634 player->SendDirectMessage(&data);
1635 }
1636 else if (info->goober.gossipID)
1637 {
1638 player->PrepareGossipMenu(this, info->goober.gossipID);
1639 player->SendPreparedGossip(this);
1640 }
1641
1642 if (info->goober.eventId)
1643 {
1644 LOG_DEBUG("maps.script", "Goober ScriptStart id {} for GO entry {} (spawnId {}).", info->goober.eventId, GetEntry(), m_spawnId);
1645 GetMap()->ScriptsStart(sEventScripts, info->goober.eventId, player, this);
1646 EventInform(info->goober.eventId);
1647 }
1648
1649 // possible quest objective for active quests
1650 if (info->goober.questId && sObjectMgr->GetQuestTemplate(info->goober.questId))
1651 {
1652 //Quest require to be active for GO using
1654 break;
1655 }
1656
1657 if (Battleground* bg = player->GetBattleground())
1658 bg->EventPlayerUsedGO(player, this);
1659
1660 if (Group* group = player->GetGroup())
1661 {
1662 for (GroupReference const* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
1663 {
1664 if (Player* member = itr->GetSource())
1665 {
1666 if (member->IsAtGroupRewardDistance(this))
1667 {
1668 member->KillCreditGO(info->entry, GetGUID());
1669 }
1670 }
1671 }
1672 }
1673 else
1674 {
1675 player->KillCreditGO(info->entry, GetGUID());
1676 }
1677 }
1678
1679 if (uint32 trapEntry = info->goober.linkedTrapId)
1680 TriggeringLinkedGameObject(trapEntry, user);
1681
1682 if (info->GetAutoCloseTime())
1683 {
1686 if (!info->goober.customAnim)
1688 }
1689
1690 // this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
1691 if (info->goober.customAnim)
1693
1695
1696 // cast this spell later if provided
1697 spellId = info->goober.spellId;
1698 spellCaster = user;
1699
1700 break;
1701 }
1702 case GAMEOBJECT_TYPE_CAMERA: //13
1703 {
1704 GameObjectTemplate const* info = GetGOInfo();
1705 if (!info)
1706 return;
1707
1708 if (!user->IsPlayer())
1709 return;
1710
1711 Player* player = user->ToPlayer();
1712
1713 if (info->camera.cinematicId)
1715
1716 if (info->camera.eventID)
1717 {
1718 GetMap()->ScriptsStart(sEventScripts, info->camera.eventID, player, this);
1719 EventInform(info->camera.eventID);
1720 }
1721
1722 return;
1723 }
1724 //fishing bobber
1726 {
1727 Player* player = user->ToPlayer();
1728 if (!player)
1729 return;
1730
1731 if (player->GetGUID() != GetOwnerGUID())
1732 return;
1733
1734 switch (getLootState())
1735 {
1736 case GO_READY: // ready for loot
1737 {
1738 uint32 zone, subzone;
1739 GetZoneAndAreaId(zone, subzone);
1740
1741 int32 zoneSkill = sObjectMgr->GetFishingBaseSkillLevel(subzone);
1742 if (!zoneSkill)
1743 zoneSkill = sObjectMgr->GetFishingBaseSkillLevel(zone);
1744
1745 //provide error, no fishable zone or area should be 0
1746 if (!zoneSkill)
1747 LOG_ERROR("sql.sql", "Fishable areaId {} are not properly defined in `skill_fishing_base_level`.", subzone);
1748
1749 // no miss skill is zone skill + 95 since at least patch 2.1
1750 int32 const noMissSkill = zoneSkill + 95;
1751
1752 int32 const skill = player->GetSkillValue(SKILL_FISHING);
1753
1754 int32 chance;
1755 // fishing pool catches are 100%
1756 //TODO: find reasonable value for fishing hole search
1757 GameObject* fishingHole = LookupFishingHoleAround(20.0f + CONTACT_DISTANCE);
1758 if (fishingHole)
1759 chance = 100;
1760 else if (skill < noMissSkill)
1761 {
1762 chance = int32(pow((double)skill / noMissSkill, 2) * 100);
1763 if (chance < 1)
1764 chance = 1;
1765 }
1766 else
1767 chance = 100;
1768
1769 int32 const roll = irand(1, 100);
1770
1771 LOG_DEBUG("entities.gameobject", "Fishing check (skill: {} zone min skill: {} no-miss skill: {} chance {} roll: {})", skill, zoneSkill, noMissSkill, chance, roll);
1772
1773 if (sScriptMgr->OnPlayerUpdateFishingSkill(player, skill, zoneSkill, chance, roll))
1774 player->UpdateFishingSkill();
1775 // but you will likely cause junk in areas that require a high fishing skill (not yet implemented)
1776 if (chance >= roll)
1777 {
1778 // Keep the bobber owned while loot is open, but clear the
1779 // spell id so finishing the fishing channel does not delete it.
1780 SetSpellId(0); // prevent removing unintended auras at Unit::RemoveGameObject
1781
1782 // fishing pool catch
1783 if (fishingHole)
1784 {
1785 fishingHole->Use(player);
1787 }
1788 else
1789 player->SendLoot(GetGUID(), LOOT_FISHING);
1790 }
1791 else // else: junk
1793 break;
1794 }
1795 case GO_JUST_DEACTIVATED: // nothing to do, will be deleted at next update
1796 break;
1797 default:
1798 {
1800
1802 player->SendDirectMessage(&data);
1803 break;
1804 }
1805 }
1806 player->FinishSpell(CURRENT_CHANNELED_SPELL, true);
1807 return;
1808 }
1809
1811 {
1812 if (!user->IsPlayer())
1813 return;
1814
1815 Player* player = user->ToPlayer();
1816 Unit* owner = GetOwner();
1817 GameObjectTemplate const* info = GetGOInfo();
1818
1819 // ritual owner is set for GO's without owner (not summoned)
1820 if (!m_ritualOwnerGUID && !owner)
1821 m_ritualOwnerGUID = player->GetGUID();
1822
1823 if (owner)
1824 {
1825 if (!owner->IsPlayer())
1826 return;
1827
1828 // accept only use by player from same group as owner, excluding owner itself (unique use already added in spell effect)
1829 if (player == owner->ToPlayer() || (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(owner->ToPlayer())))
1830 return;
1831
1832 // expect owner to already be channeling, so if not...
1834 return;
1835 }
1836 else
1837 {
1838 Player* ritualOwner = ObjectAccessor::GetPlayer(*this, m_ritualOwnerGUID);
1839 if (!ritualOwner)
1840 return;
1841 if (player != ritualOwner && (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(ritualOwner)))
1842 return;
1843 }
1844
1846
1848 return;
1849
1850 SpellCastResult castResult;
1851 if (info->summoningRitual.animSpell)
1852 castResult = player->CastSpell(player, info->summoningRitual.animSpell, true);
1853 else
1854 castResult = player->CastSpell(player, GetSpellId(),
1859
1860 if (castResult != SPELL_CAST_OK)
1861 return;
1862
1863 AddUniqueUse(player);
1864
1865 // full amount unique participants including original summoner
1867 {
1869
1870 // channel ready, maintain this
1872 }
1873
1874 return;
1875 }
1877 {
1878 GameObjectTemplate const* info = GetGOInfo();
1879 if (!info)
1880 return;
1881
1882 if (info->spellcaster.partyOnly)
1883 {
1884 if (!user->IsPlayer())
1885 return;
1886 if (ObjectGuid ownerGuid = GetOwnerGUID())
1887 {
1888 if (user->GetGUID() != ownerGuid)
1889 {
1890 Group* group = user->ToPlayer()->GetGroup();
1891 if (!group)
1892 return;
1893 if (!group->IsMember(ownerGuid))
1894 return;
1895 }
1896 }
1897 }
1898
1899 spellId = info->spellcaster.spellId;
1900 break;
1901 }
1903 {
1904 GameObjectTemplate const* info = GetGOInfo();
1905
1906 if (!user->IsPlayer())
1907 return;
1908
1909 Player* player = user->ToPlayer();
1910
1911 Player* targetPlayer = ObjectAccessor::FindPlayer(player->GetTarget());
1912
1913 // accept only use by player from same raid as caster
1914 if (!targetPlayer || !targetPlayer->IsInSameRaidWith(player))
1915 return;
1916
1917 //required lvl checks!
1918 uint8 level = player->GetLevel();
1919 if (level < info->meetingstone.minLevel)
1920 return;
1921 level = targetPlayer->GetLevel();
1922 if (level < info->meetingstone.minLevel)
1923 return;
1924
1925 spellId = 23598; // Meeting Stone Summon
1926
1927 break;
1928 }
1929
1930 case GAMEOBJECT_TYPE_FLAGSTAND: // 24
1931 {
1932 if (!user->IsPlayer())
1933 return;
1934
1935 Player* player = user->ToPlayer();
1936
1937 if (player->CanUseBattlegroundObject(this))
1938 {
1939 // in battleground check
1940 Battleground* bg = player->GetBattleground();
1941 if (!bg)
1942 return;
1943
1944 if (player->GetVehicle())
1945 return;
1946
1949 // BG flag click
1950 // AB:
1951 // 15001
1952 // 15002
1953 // 15003
1954 // 15004
1955 // 15005
1956 bg->EventPlayerClickedOnFlag(player, this);
1957 return; //we don;t need to delete flag ... it is despawned!
1958 }
1959 break;
1960 }
1961
1962 case GAMEOBJECT_TYPE_FISHINGHOLE: // 25
1963 {
1964 if (!user->IsPlayer())
1965 return;
1966
1967 Player* player = user->ToPlayer();
1968
1969 player->SendLoot(GetGUID(), LOOT_FISHINGHOLE);
1971 return;
1972 }
1973
1974 case GAMEOBJECT_TYPE_FLAGDROP: // 26
1975 {
1976 if (!user->IsPlayer())
1977 return;
1978
1979 Player* player = user->ToPlayer();
1980
1981 if (player->CanUseBattlegroundObject(this))
1982 {
1983 // in battleground check
1984 Battleground* bg = player->GetBattleground();
1985 if (!bg)
1986 return;
1987
1988 if (player->GetVehicle())
1989 return;
1990
1993 // BG flag dropped
1994 // WS:
1995 // 179785 - Silverwing Flag
1996 // 179786 - Warsong Flag
1997 // EotS:
1998 // 184142 - Netherstorm Flag
1999 GameObjectTemplate const* info = GetGOInfo();
2000 if (info)
2001 {
2003 {
2004 GameObject::gameObjectToEventFlag[info->entry](player, this, bg);
2005 }
2006 else
2007 {
2008 switch (info->entry)
2009 {
2010 case 179785: // Silverwing Flag
2011 case 179786: // Warsong Flag
2012 if (bg->GetBgTypeID(true) == BATTLEGROUND_WS)
2013 bg->EventPlayerClickedOnFlag(player, this);
2014 break;
2015 case 184142: // Netherstorm Flag
2016 if (bg->GetBgTypeID(true) == BATTLEGROUND_EY)
2017 bg->EventPlayerClickedOnFlag(player, this);
2018 break;
2019 }
2020 }
2021 }
2022 //this cause to call return, all flags must be deleted here!!
2023 spellId = 0;
2024 Delete();
2025 }
2026 break;
2027 }
2029 {
2030 GameObjectTemplate const* info = GetGOInfo();
2031 if (!info)
2032 return;
2033
2034 if (!user->IsPlayer())
2035 return;
2036
2037 Player* player = user->ToPlayer();
2038
2039 // fallback, will always work
2041
2043 player->SendDirectMessage(&data);
2044
2046 return;
2047 }
2048 default:
2050 LOG_ERROR("entities.gameobject", "GameObject::Use(): unit ({}, name: {}) tries to use object ({}, name: {}) of unknown type ({})",
2051 user->GetGUID().ToString(), user->GetName(), GetGUID().ToString(), GetGOInfo()->name, GetGoType());
2052 break;
2053 }
2054
2055 if (!spellId)
2056 return;
2057
2058 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
2059 if (!spellInfo)
2060 {
2061 if (!user->IsPlayer() || !sOutdoorPvPMgr->HandleCustomSpell(user->ToPlayer(), spellId, this))
2062 LOG_ERROR("entities.gameobject", "WORLD: unknown spell id {} at use action for gameobject (Entry: {} GoType: {})", spellId, GetEntry(), GetGoType());
2063 else
2064 LOG_DEBUG("outdoorpvp", "WORLD: {} non-dbc spell was handled by OutdoorPvP", spellId);
2065 return;
2066 }
2067
2070
2071 if (Player* player = user->ToPlayer())
2072 sOutdoorPvPMgr->HandleCustomSpell(player, spellId, this);
2073
2074 if (spellCaster)
2075 {
2076 if ((spellCaster->CastSpell(user, spellInfo, TriggerCastFlags(triggeredFlags)) == SPELL_CAST_OK) && GetGoType() == GAMEOBJECT_TYPE_SPELLCASTER)
2077 AddUse();
2078 }
2079 else
2080 CastSpell(user, spellId);
2081}
@ ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT
Definition DBCEnums.h:183
@ LOOT_FISHING_JUNK
Definition LootMgr.h:91
@ LOOT_FISHING
Definition LootMgr.h:82
@ LOOT_FISHINGHOLE
Definition LootMgr.h:89
#define DEFAULT_VISIBILITY_DISTANCE
Definition ObjectDefines.h:39
ScriptMapMap sEventScripts
Definition ObjectMgr.cpp:61
#define sOutdoorPvPMgr
Definition OutdoorPvPMgr.h:102
@ TELE_TO_NOT_LEAVE_COMBAT
Definition Player.h:817
@ TELE_TO_NOT_UNSUMMON_PET
Definition Player.h:818
@ TELE_TO_NOT_LEAVE_TRANSPORT
Definition Player.h:816
int32 irand(int32 min, int32 max)
Definition Random.cpp:37
@ GAMEOBJECT_TYPE_MEETINGSTONE
Definition SharedDefines.h:1587
@ GAMEOBJECT_TYPE_SPELLCASTER
Definition SharedDefines.h:1586
@ BATTLEGROUND_WS
Definition SharedDefines.h:3738
@ BATTLEGROUND_EY
Definition SharedDefines.h:3743
SpellCastResult
Definition SharedDefines.h:936
@ SPELL_CAST_OK
Definition SharedDefines.h:1126
@ SKILL_FISHING
Definition SharedDefines.h:3190
@ SPELL_AURA_MOD_INVISIBILITY
Definition SpellAuraDefines.h:81
@ SPELL_AURA_MOUNTED
Definition SpellAuraDefines.h:141
@ SPELL_AURA_MOD_STEALTH
Definition SpellAuraDefines.h:79
TriggerCastFlags
Definition SpellDefines.h:132
@ TRIGGERED_IGNORE_POWER_AND_REAGENT_COST
Will ignore Spell and Category cooldowns.
Definition SpellDefines.h:136
@ TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD
Will ignore GCD.
Definition SpellDefines.h:135
@ TRIGGERED_CAST_DIRECTLY
Will ignore combo point requirement.
Definition SpellDefines.h:141
@ TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE
Will ignore caster aura states including combat requirements and death state.
Definition SpellDefines.h:146
@ TRIGGERED_IGNORE_EFFECTS
Periodic aura tick wont be reset on override.
Definition SpellDefines.h:153
@ TRIGGERED_NONE
Definition SpellDefines.h:133
@ UNIT_STAND_STATE_SIT_LOW_CHAIR
Definition UnitDefines.h:39
@ UNIT_STAND_STATE_SIT
Definition UnitDefines.h:36
virtual void EventPlayerClickedOnFlag(Player *, GameObject *)
Definition Battleground.h:520
BattlegroundTypeId GetBgTypeID(bool GetRandom=false) const
Definition Battleground.h:329
void StartCinematic(uint32 const cinematicSequenceId)
Definition CinematicMgr.cpp:31
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
Definition GameObject.cpp:1413
static std::unordered_map< int, goEventFlag > gameObjectToEventFlag
Definition GameObject.h:2963
LootState getLootState() const
Definition GameObject.h:224
ChairSlotAndUser ChairListSlots
Definition GameObject.h:391
void TriggeringLinkedGameObject(uint32 trapEntry, Unit *target)
Definition GameObject.cpp:1369
GameObject * LookupFishingHoleAround(float range)
Definition GameObject.cpp:1392
void Use(Unit *user)
Definition GameObject.cpp:1463
void AddUniqueUse(Player *player)
Definition GameObject.cpp:921
void SetSpellId(uint32 id)
Definition GameObject.h:177
Definition GroupReference.h:27
bool IsMember(ObjectGuid guid) const
Definition Group.cpp:2542
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:31
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, Unit *unit=nullptr)
Definition PlayerUpdates.cpp:2181
bool IsInSameRaidWith(Player const *p) const
Definition Player.h:1913
bool UpdateFishingSkill()
Definition PlayerUpdates.cpp:891
uint16 GetSkillValue(uint32 skill) const
Definition Player.cpp:5610
bool CanUseBattlegroundObject(GameObject *gameobject) const
Definition Player.cpp:13527
CinematicMgr & GetCinematicMgr()
Definition Player.h:1403
void SendPreparedGossip(WorldObject *source)
Definition PlayerGossip.cpp:214
void SendLoot(ObjectGuid guid, LootType loot_type)
Definition Player.cpp:7973
Group * GetGroup()
Definition Player.h:2516
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1399
void KillCreditGO(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
Definition PlayerQuest.cpp:2115
void PrepareGossipMenu(WorldObject *source, uint32 menuId=0, bool showQuests=false)
Definition PlayerGossip.cpp:32
Vehicle * GetVehicle() const
Definition Unit.h:1926
void FinishSpell(CurrentSpellTypes spellType, bool ok=true)
Definition Unit.cpp:4270
void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID=ObjectGuid::Empty, Aura *except=nullptr, bool negative=true, bool positive=true)
Definition Unit.cpp:5397
void SetStandState(uint8 state)
Definition Unit.cpp:13126
ObjectGuid GetTarget() const
Definition Unit.h:862
uint8 GetLevel() const
Definition Unit.h:1104
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:1317
@ SMSG_GAMEOBJECT_PAGETEXT
Definition Opcodes.h:509
@ SMSG_ENABLE_BARBER_SHOP
Definition Opcodes.h:1093
@ SMSG_FISH_NOT_HOOKED
Definition Opcodes.h:486
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:269
uint32 castersGrouped
Definition GameObjectData.h:238
struct GameObjectTemplate::@236::@263 barberChair
struct GameObjectTemplate::@236::@250 camera
uint32 height
Definition GameObjectData.h:136
uint32 gossipID
Definition GameObjectData.h:73
uint32 GetAutoCloseTime() const
Definition GameObjectData.h:511
uint32 linkedTrap
Definition GameObjectData.h:60
uint32 slots
Definition GameObjectData.h:135
bool IsUsableMounted() const
Definition GameObjectData.h:411
uint32 partyOnly
Definition GameObjectData.h:254
struct GameObjectTemplate::@236::@254 spellcaster
struct GameObjectTemplate::@236::@244 chair
uint32 chairheight
Definition GameObjectData.h:346
uint32 eventId
Definition GameObjectData.h:90
uint32 pageId
Definition GameObjectData.h:169
uint32 eventID
Definition GameObjectData.h:210
uint32 cinematicId
Definition GameObjectData.h:209
uint32 customAnim
Definition GameObjectData.h:74
uint32 linkedTrapId
Definition GameObjectData.h:91

References ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT, AddUniqueUse(), AddUse(), AI(), GameObjectTemplate::animSpell, GameObjectTemplate::barberChair, BATTLEGROUND_EY, BATTLEGROUND_WS, GameObjectTemplate::camera, Player::CanUseBattlegroundObject(), GameObjectTemplate::castersGrouped, Unit::CastSpell(), CastSpell(), GameObjectTemplate::chair, GameObjectTemplate::chairheight, ChairListSlots, CheckRitualList(), GameObjectTemplate::cinematicId, CONTACT_DISTANCE, GameObjectTemplate::cooldown, CURRENT_CHANNELED_SPELL, GameObjectTemplate::customAnim, DEFAULT_VISIBILITY_DISTANCE, Delete(), GameObjectTemplate::entry, GameObjectTemplate::eventId, GameObjectTemplate::eventID, EventInform(), Battleground::EventPlayerClickedOnFlag(), ObjectAccessor::FindPlayer(), Unit::FinishSpell(), GAMEOBJECT_TYPE_BARBER_CHAIR, GAMEOBJECT_TYPE_BUTTON, GAMEOBJECT_TYPE_CAMERA, GAMEOBJECT_TYPE_CHAIR, GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_FISHINGHOLE, GAMEOBJECT_TYPE_FISHINGNODE, GAMEOBJECT_TYPE_FLAGDROP, GAMEOBJECT_TYPE_FLAGSTAND, GAMEOBJECT_TYPE_GOOBER, GAMEOBJECT_TYPE_MEETINGSTONE, GAMEOBJECT_TYPE_QUESTGIVER, GAMEOBJECT_TYPE_SPELLCASTER, GAMEOBJECT_TYPE_SUMMONING_RITUAL, GAMEOBJECT_TYPE_TRAP, gameObjectToEventFlag, GameObjectTemplate::GetAutoCloseTime(), Player::GetBattleground(), Battleground::GetBgTypeID(), Player::GetCinematicMgr(), Unit::GetCurrentSpell(), WorldObject::GetDistance2d(), Object::GetEntry(), GameTime::GetGameTimeMS(), GetGoAnimProgress(), GetGOInfo(), GetGoType(), Player::GetGroup(), Object::GetGUID(), Object::GetGUID(), Unit::GetLevel(), getLootState(), WorldObject::GetMap(), WorldLocation::GetMapId(), WorldObject::GetName(), Position::GetOrientation(), GetOwner(), GetOwnerGUID(), ObjectAccessor::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Player::GetQuestStatus(), Player::GetSkillValue(), GetSpellId(), Unit::GetTarget(), GetUniqueUseCount(), Unit::GetVehicle(), WorldObject::GetZoneAndAreaId(), GO_ACTIVATED, GO_FLAG_IN_USE, GO_FLAG_NOT_SELECTABLE, GO_JUST_DEACTIVATED, GO_NOT_READY, GO_READY, GO_STATE_ACTIVE, GameObjectTemplate::goober, GameObjectTemplate::gossipID, HasGameObjectFlag(), GameObjectTemplate::height, IN_MILLISECONDS, irand(), Player::IsInSameRaidWith(), Group::IsMember(), Object::IsPlayer(), GameObjectTemplate::IsUsableMounted(), Player::KillCreditGO(), GameObjectTemplate::linkedTrap, GameObjectTemplate::linkedTrapId, LOG_DEBUG, LOG_ERROR, LookupFishingHoleAround(), LOOT_FISHING, LOOT_FISHING_JUNK, LOOT_FISHINGHOLE, m_cooldownTime, m_goInfo, m_ritualOwnerGUID, m_spawnId, MAX_GAMEOBJECT_TYPE, GameObjectTemplate::pageId, GameObjectTemplate::partyOnly, Player::PrepareGossipMenu(), QUEST_STATUS_INCOMPLETE, GameObjectTemplate::questId, Unit::RemoveAurasByType(), GameObjectTemplate::reqParticipants, Map::ScriptsStart(), SendCustomAnim(), Player::SendDirectMessage(), Player::SendLoot(), Player::SendPreparedGossip(), SetGameObjectFlag(), SetGoState(), SetLootState(), SetSpellId(), Unit::SetStandState(), sEventScripts, GameObjectTemplate::size, SKILL_FISHING, GameObjectTemplate::slots, SMSG_ENABLE_BARBER_SHOP, SMSG_FISH_NOT_HOOKED, SMSG_GAMEOBJECT_PAGETEXT, sObjectMgr, sOutdoorPvPMgr, SPELL_AURA_MOD_INVISIBILITY, SPELL_AURA_MOD_STEALTH, SPELL_AURA_MOUNTED, SPELL_CAST_OK, GameObjectTemplate::spellcaster, GameObjectTemplate::spellId, sScriptMgr, sSpellMgr, CinematicMgr::StartCinematic(), GameObjectTemplate::summoningRitual, TELE_TO_NOT_LEAVE_COMBAT, TELE_TO_NOT_LEAVE_TRANSPORT, TELE_TO_NOT_UNSUMMON_PET, Player::TeleportTo(), Object::ToPlayer(), ObjectGuid::ToString(), Position::ToString(), GameObjectTemplate::trap, TRIGGERED_CAST_DIRECTLY, TRIGGERED_IGNORE_CASTER_MOUNTED_OR_ON_VEHICLE, TRIGGERED_IGNORE_EFFECTS, TRIGGERED_IGNORE_POWER_AND_REAGENT_COST, TRIGGERED_IGNORE_SPELL_AND_CATEGORY_CD, TRIGGERED_NONE, TriggeringLinkedGameObject(), GameObjectTemplate::type, UNIT_STAND_STATE_SIT, UNIT_STAND_STATE_SIT_LOW_CHAIR, Player::UpdateAchievementCriteria(), Player::UpdateFishingSkill(), Use(), and UseDoorOrButton().

Referenced by Spell::EffectActivateObject(), spell_q9452_cast_net::HandleActiveObject(), go_sand_trap::Reset(), Spell::SendLoot(), npc_valiance_keep_cannoneer::npc_valiance_keep_cannoneerAI::UpdateAI(), and Use().

◆ UseDoorOrButton()

◆ ValidateGameobjectType()

bool GameObject::ValidateGameobjectType ( ) const
2559{
2560 switch (m_goInfo->type)
2561 {
2567 return true;
2568 default:
2569 return false;
2570 }
2571}
@ GAMEOBJECT_TYPE_TRAPDOOR
Definition SharedDefines.h:1599

References GAMEOBJECT_TYPE_BUTTON, GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING, GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_TRAP, GAMEOBJECT_TYPE_TRAPDOOR, m_goInfo, and GameObjectTemplate::type.

Referenced by IsInstanceGameobject().

Member Data Documentation

◆ _lootStateUnitGUID

ObjectGuid GameObject::_lootStateUnitGUID
protected

Referenced by SetLootState(), and Update().

◆ _respawnCompatibilityMode

bool GameObject::_respawnCompatibilityMode {true}
protected
373{true};

Referenced by IsRespawnCompatibilityMode(), and LoadGameObjectFromDB().

◆ ChairListSlots

ChairSlotAndUser GameObject::ChairListSlots
protected

Referenced by Use().

◆ gameObjectToEventFlag

std::unordered_map< int, goEventFlag > GameObject::gameObjectToEventFlag = { }
static
3012{
3013 //11 GAMEOBJECT_TYPE_TRANSPORT
3014 struct
3015 {
3016 uint32 PathProgress;
3017 TransportAnimation const* AnimationInfo;
3018 } Transport;
3019 //25 GAMEOBJECT_TYPE_FISHINGHOLE
3020 struct
3021 {
3022 uint32 MaxOpens;
3023 } FishingHole;
3024 //29 GAMEOBJECT_TYPE_CAPTURE_POINT
3025 struct
3026 {
3027 OPvPCapturePoint* OPvPObj;
3028 } CapturePoint;
3029 //33 GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING
3030 struct
3031 {
3032 uint32 Health;
3033 uint32 MaxHealth;
3034 } Building;
3035};
3036
3037enum class GameObjectActions : uint32
3038{
3039 // Name from client executable // Comments
3040 None, // -NONE-
3041 AnimateCustom0, // Animate Custom0
3042 AnimateCustom1, // Animate Custom1
3043 AnimateCustom2, // Animate Custom2
3044 AnimateCustom3, // Animate Custom3
3045 Disturb, // Disturb // Triggers trap
3046 Unlock, // Unlock // Resets GO_FLAG_LOCKED
3047 Lock, // Lock // Sets GO_FLAG_LOCKED
3048 Open, // Open // Sets GO_STATE_ACTIVE
3049 OpenAndUnlock, // Open + Unlock // Sets GO_STATE_ACTIVE and resets GO_FLAG_LOCKED
3050 Close, // Close // Sets GO_STATE_READY
3051 ToggleOpen, // Toggle Open
3052 Destroy, // Destroy // Sets GO_STATE_DESTROYED
3053 Rebuild, // Rebuild // Resets from GO_STATE_DESTROYED
3054 Creation, // Creation
3055 Despawn, // Despawn
3056 MakeInert, // Make Inert // Disables interactions
3057 MakeActive, // Make Active // Enables interactions
3058 CloseAndLock, // Close + Lock // Sets GO_STATE_READY and sets GO_FLAG_LOCKED
3059 UseArtKit0, // Use ArtKit0 // 46904: 121
3060 UseArtKit1, // Use ArtKit1 // 36639: 81, 46903: 122
3061 UseArtKit2, // Use ArtKit2
3062 UseArtKit3, // Use ArtKit3
3063 SetTapList, // Set Tap List
3064};
3065
3066// For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ...
3067// For bobber: GO_NOT_READY ->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-><deleted>
3068// For door(closed):[GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY(close) -> ...
3069// For door(open): [GO_NOT_READY]->GO_READY (open) ->GO_ACTIVATED (close)->GO_JUST_DEACTIVATED->GO_READY(open) -> ...
3070enum LootState
3071{
3073 GO_READY, // can be ready but despawned, and then not possible activate until spawn
3076};
3077
3078// 5 sec for bobber catch
3079#define FISHING_BOBBER_READY_TIME 5
3080
3081class GameObject : public WorldObject, public GridObject<GameObject>, public MovableMapObject, public UpdatableMapObject
3082{
3083public:
3084 explicit GameObject();
3085 ~GameObject() override;
3086
3087 void BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) override;
3088
3089 void AddToWorld() override;
3090 void RemoveFromWorld() override;
3091 void CleanupsBeforeDelete(bool finalCleanup = true) override;
3092
3093 uint32 GetDynamicFlags() const override { return GetUInt32Value(GAMEOBJECT_DYNAMIC); }
3094 void ReplaceAllDynamicFlags(uint32 flag) override { SetUInt32Value(GAMEOBJECT_DYNAMIC, flag); }
3095
3096 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);
3097 void Update(uint32 p_time) override;
3098 [[nodiscard]] GameObjectTemplate const* GetGOInfo() const { return m_goInfo; }
3099 [[nodiscard]] GameObjectTemplateAddon const* GetTemplateAddon() const;
3100 [[nodiscard]] GameObjectData const* GetGameObjectData() const { return m_goData; }
3101 [[nodiscard]] GameObjectValue const* GetGOValue() const { return &m_goValue; }
3102
3103 [[nodiscard]] bool IsTransport() const;
3104 [[nodiscard]] bool IsDestructibleBuilding() const;
3105
3106 [[nodiscard]] ObjectGuid::LowType GetSpawnId() const { return m_spawnId; }
3107
3108 // z_rot, y_rot, x_rot - rotation angles around z, y and x axes
3109 void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot);
3110 void SetWorldRotation(G3D::Quat const& rot);
3111 void SetTransportPathRotation(float qx, float qy, float qz, float qw);
3112 [[nodiscard]] G3D::Quat const& GetWorldRotation() const { return WorldRotation; }
3113 [[nodiscard]] int64 GetPackedWorldRotation() const { return m_packedRotation; }
3114 [[nodiscard]] G3D::Quat GetFinalWorldRotation() const;
3115
3116 // overwrite WorldObject function for proper name localization
3117 [[nodiscard]] std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override;
3118
3119 void SaveToDB(bool saveAddon = false);
3120 void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask, bool saveAddon = false);
3121 virtual bool LoadFromDB(ObjectGuid::LowType guid, Map* map) { return LoadGameObjectFromDB(guid, map, false); }
3122 virtual bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map* map, bool addToMap = true);
3123 [[nodiscard]] bool IsRespawnCompatibilityMode() const { return _respawnCompatibilityMode; }
3124 void DeleteFromDB();
3125
3126 void SetOwnerGUID(ObjectGuid owner)
3127 {
3128 // Owner already found and different than expected owner - remove object from old owner
3129 if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
3130 {
3131 ABORT();
3132 }
3133 m_spawnedByDefault = false; // all object with owner is despawned after delay
3135 }
3136 [[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(OBJECT_FIELD_CREATED_BY); }
3137 [[nodiscard]] Unit* GetOwner() const;
3138
3139 void SetSpellId(uint32 id)
3140 {
3141 m_spawnedByDefault = false; // all summoned object is despawned after delay
3142 m_spellId = id;
3143 }
3144 [[nodiscard]] uint32 GetSpellId() const { return m_spellId;}
3145
3146 [[nodiscard]] time_t GetRespawnTime() const { return m_respawnTime; }
3147 [[nodiscard]] time_t GetRespawnTimeEx() const;
3148
3149 void SetRespawnTime(int32 respawn);
3150 void SetRespawnDelay(int32 respawn);
3151 void Respawn();
3152 [[nodiscard]] bool isSpawned() const
3153 {
3154 return m_respawnDelayTime == 0 ||
3157 }
3158 [[nodiscard]] bool isSpawnedByDefault() const { return m_spawnedByDefault; }
3159 void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; }
3160 [[nodiscard]] uint32 GetRespawnDelay() const { return m_respawnDelayTime; }
3161 void Refresh();
3162 void DespawnOrUnsummon(Milliseconds delay = 0ms, Seconds forcedRespawnTime = 0s);
3163 void Delete();
3164 void GetFishLoot(Loot* fishLoot, Player* lootOwner, bool junk = false);
3165 [[nodiscard]] GameobjectTypes GetGoType() const { return GameobjectTypes(GetByteValue(GAMEOBJECT_BYTES_1, 1)); }
3167 [[nodiscard]] GOState GetGoState() const { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
3168 void SetGoState(GOState state);
3169 [[nodiscard]] uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
3170 void SetGoArtKit(uint8 artkit);
3171 [[nodiscard]] uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
3172 void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
3173 static void SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid = 0);
3174
3175 void SetPhaseMask(uint32 newPhaseMask, bool update) override;
3176 void EnableCollision(bool enable);
3177
3179 bool HasGameObjectFlag(GameObjectFlags flags) const { return HasFlag(GAMEOBJECT_FLAGS, flags) != 0; }
3183
3184 void Use(Unit* user);
3185
3186 [[nodiscard]] LootState getLootState() const { return m_lootState; }
3187 // Note: unit is only used when s = GO_ACTIVATED
3188 void SetLootState(LootState s, Unit* unit = nullptr);
3189
3190 [[nodiscard]] uint16 GetLootMode() const { return m_LootMode; }
3191 [[nodiscard]] bool HasLootMode(uint16 lootMode) const { return m_LootMode & lootMode; }
3192 void SetLootMode(uint16 lootMode) { m_LootMode = lootMode; }
3193 void AddLootMode(uint16 lootMode) { m_LootMode |= lootMode; }
3194 void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
3196
3197 void AddToSkillupList(ObjectGuid const& playerGuid);
3198 [[nodiscard]] bool IsInSkillupList(ObjectGuid const& playerGuid) const;
3199
3200 void AddUniqueUse(Player* player);
3201 void AddUse() { ++m_usetimes; }
3202
3203 [[nodiscard]] uint32 GetUseCount() const { return m_usetimes; }
3204 [[nodiscard]] uint32 GetUniqueUseCount() const { return m_unique_users.size(); }
3205
3206 void SaveRespawnTime() override { SaveRespawnTime(0); }
3207 void SaveRespawnTime(uint32 forceDelay);
3208
3209 Loot loot;
3210
3211 [[nodiscard]] Player* GetLootRecipient() const;
3212 [[nodiscard]] Group* GetLootRecipientGroup() const;
3213 void SetLootRecipient(Creature* creature);
3214 void SetLootRecipient(Map* map);
3215 bool IsLootAllowedFor(Player const* player) const;
3216 [[nodiscard]] bool HasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
3217 uint32 m_groupLootTimer; // (msecs)timer used for group loot
3218 uint32 lootingGroupLowGUID; // used to find group which is looting
3219 void SetLootGenerationTime();
3220 [[nodiscard]] uint32 GetLootGenerationTime() const { return m_lootGenerationTime; }
3221
3222 [[nodiscard]] GameObject* GetLinkedTrap();
3223 void SetLinkedTrap(GameObject* linkedTrap) { m_linkedTrap = linkedTrap->GetGUID(); }
3224
3225 [[nodiscard]] bool hasQuest(uint32 quest_id) const override;
3226 [[nodiscard]] bool hasInvolvedQuest(uint32 quest_id) const override;
3227 bool ActivateToQuest(Player* target) const;
3228 void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false, Unit* user = nullptr);
3229 // 0 = use `gameobject`.`spawntimesecs`
3230 void ResetDoorOrButton();
3231
3232 void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target);
3233
3234 [[nodiscard]] bool IsNeverVisible() const override;
3235 bool IsAlwaysVisibleFor(WorldObject const* seer) const override;
3236 [[nodiscard]] bool IsInvisibleDueToDespawn() const override;
3237
3238 uint8 getLevelForTarget(WorldObject const* target) const override
3239 {
3240 if (Unit* owner = GetOwner())
3241 return owner->getLevelForTarget(target);
3242
3243 return 1;
3244 }
3245
3246 GameObject* LookupFishingHoleAround(float range);
3247
3248 void CastSpell(Unit* target, uint32 spell);
3249 void SendCustomAnim(uint32 anim);
3250 bool IsInRange2d(float x, float y, float radius) const;
3251 bool IsInRange3d(float x, float y, float z, float radius) const;
3252
3253 void ModifyHealth(int32 change, Unit* attackerOrHealer = nullptr, uint32 spellId = 0);
3255 // sets GameObject type 33 destruction flags and optionally default health for that state
3256 void SetDestructibleState(GameObjectDestructibleState state, Player* eventInvoker = nullptr, bool setHealth = false);
3258 {
3264 }
3265
3266 void EventInform(uint32 eventId);
3267
3268 [[nodiscard]] virtual uint32 GetScriptId() const;
3269 [[nodiscard]] GameObjectAI* AI() const { return m_AI; }
3270
3271 [[nodiscard]] std::string const& GetAIName() const;
3272 void SetDisplayId(uint32 displayid);
3273 [[nodiscard]] uint32 GetDisplayId() const { return GetUInt32Value(GAMEOBJECT_DISPLAYID); }
3274
3276 void GetRespawnPosition(float& x, float& y, float& z, float* ori = nullptr) const;
3277
3278 void SetPosition(float x, float y, float z, float o);
3279 void SetPosition(Position const& pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
3280
3281 [[nodiscard]] bool IsStaticTransport() const { return GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT; }
3282 [[nodiscard]] bool IsMotionTransport() const { return GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT; }
3283
3284 Transport* ToTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT || GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<Transport*>(this); else return nullptr; }
3285 [[nodiscard]] Transport const* ToTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT || GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<Transport const*>(this); else return nullptr; }
3286
3287 StaticTransport* ToStaticTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<StaticTransport*>(this); else return nullptr; }
3288 [[nodiscard]] StaticTransport const* ToStaticTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<StaticTransport const*>(this); else return nullptr; }
3289
3290 MotionTransport* ToMotionTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<MotionTransport*>(this); else return nullptr; }
3291 [[nodiscard]] MotionTransport const* ToMotionTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<MotionTransport const*>(this); else return nullptr; }
3292
3293 [[nodiscard]] float GetStationaryX() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionX(); return GetPositionX(); }
3294 [[nodiscard]] float GetStationaryY() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionY(); return GetPositionY(); }
3295 [[nodiscard]] float GetStationaryZ() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionZ(); return GetPositionZ(); }
3296 [[nodiscard]] float GetStationaryO() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetOrientation(); return GetOrientation(); }
3297
3298 [[nodiscard]] float GetInteractionDistance() const;
3299
3300 void UpdateModelPosition();
3301
3302 [[nodiscard]] bool IsAtInteractDistance(Position const& pos, float radius) const;
3303 [[nodiscard]] bool IsAtInteractDistance(Player const* player, SpellInfo const* spell = nullptr) const;
3304
3305 [[nodiscard]] bool IsWithinDistInMap(Player const* player) const;
3307
3308 [[nodiscard]] SpellInfo const* GetSpellForLock(Player const* player) const;
3309
3310 static std::unordered_map<int, goEventFlag> gameObjectToEventFlag; // Gameobject -> event flag
3311
3312 [[nodiscard]] bool ValidateGameobjectType() const;
3313 [[nodiscard]] bool IsInstanceGameobject() const;
3314 [[nodiscard]] uint8 GameobjectStateToInt(GOState* state) const;
3315
3316 /* A check to verify if this object is available to be saved on the DB when
3317 * a state change occurs
3318 */
3319 [[nodiscard]] bool IsAllowedToSaveToDB() const { return m_saveStateOnDb; };
3320
3321 /* Enable or Disable the ability to save on the database this gameobject's state
3322 * whenever it changes
3323 */
3324 void AllowSaveToDB(bool enable) { m_saveStateOnDb = enable; };
3325
3326 void SaveStateToDB();
3327
3328 std::string GetDebugInfo() const override;
3329
3330 bool IsUpdateNeeded() override;
3331protected:
3332 bool AIM_Initialize();
3334 void UpdateModel(); // updates model in case displayId were changed
3335 bool _respawnCompatibilityMode{true};
3337 time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()),
3338 uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer
3340 Seconds m_despawnRespawnTime; // override respawn time after delayed despawn
3343 bool m_spawnedByDefault;
3344 uint32 m_cooldownTime; // used as internal reaction delay time store (not state change reaction).
3345 // For traps this: spell casting cooldown, for doors/buttons: reset time.
3346 std::unordered_map<ObjectGuid, int32> m_SkillupList;
3347
3348 ObjectGuid m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
3351
3352 typedef std::map<uint32, ObjectGuid> ChairSlotAndUser;
3354
3357 GameObjectData const* m_goData;
3360
3362 G3D::Quat WorldRotation;
3364
3367 uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
3369
3371
3373
3374private:
3375 void CheckRitualList();
3376 void ClearRitualList();
3377 void RemoveFromOwner();
3378 void SwitchDoorOrButton(bool activate, bool alternative = false);
3379 void UpdatePackedRotation();
3380
3382 bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/, bool /*incOwnRadius = true*/, bool /*incTargetRadius = true*/) const override
3383 {
3385 dist2compare += obj->GetObjectSize();
3386 return IsInRange3d(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare);
3387 }
3388
3389 bool IsWithinSightRange(Position const& pos, float dist) const override;
3390
3392
3393 bool m_saveStateOnDb = false;
3394};
3395#endif
LocaleConstant
Definition Common.h:125
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:27
LootState
Definition GameObject.h:109
GameObjectActions
Definition GameObject.h:76
std::set< ObjectGuid > GuidSet
Definition ObjectGuid.h:257
Definition GameObjectAI.h:33
Definition GameObjectModel.h:55
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr) const
Definition GameObject.cpp:2866
uint32 GetRespawnDelay() const
Definition GameObject.h:198
bool IsWithinDistInMap(Player const *player) const
Definition GameObject.cpp:3030
bool IsRespawnCompatibilityMode() const
Definition GameObject.h:161
void AddLootMode(uint16 lootMode)
Definition GameObject.h:231
~GameObject() override
Definition GameObject.cpp:93
bool IsUpdateNeeded() override
Definition GameObject.cpp:3123
void DeleteFromDB()
Definition GameObject.cpp:1171
std::string GetDebugInfo() const override
Definition GameObject.cpp:3114
bool hasInvolvedQuest(uint32 quest_id) const override
Definition GameObject.cpp:1199
float GetStationaryZ() const override
Definition GameObject.h:333
uint32 GetDynamicFlags() const override
Definition GameObject.h:131
uint8 getLevelForTarget(WorldObject const *target) const override
Definition GameObject.h:276
float GetStationaryY() const override
Definition GameObject.h:332
void GetFishLoot(Loot *fishLoot, Player *lootOwner, bool junk=false)
Definition GameObject.cpp:999
bool HasLootMode(uint16 lootMode) const
Definition GameObject.h:229
GameObjectValue const * GetGOValue() const
Definition GameObject.h:139
Player * GetLootRecipient() const
Definition GameObject.cpp:2658
bool IsAlwaysVisibleFor(WorldObject const *seer) const override
Definition GameObject.cpp:1247
time_t GetRespawnTime() const
Definition GameObject.h:184
uint32 GetLootGenerationTime() const
Definition GameObject.h:258
float GetStationaryX() const override
Definition GameObject.h:331
void RemoveLootMode(uint16 lootMode)
Definition GameObject.h:232
void SetSpawnedByDefault(bool b)
Definition GameObject.h:197
bool IsInSkillupList(ObjectGuid const &playerGuid) const
Definition GameObject.cpp:3101
void SetLootRecipient(Creature *creature)
Definition GameObject.cpp:2672
int64 GetPackedWorldRotation() const
Definition GameObject.h:151
void SetDestructibleBuildingModifyState(bool allow)
Definition GameObject.h:292
bool IsMotionTransport() const
Definition GameObject.h:320
bool IsWithinSightRange(Position const &pos, float dist) const override
Definition GameObject.cpp:2256
void Respawn()
Definition GameObject.cpp:1302
void Refresh()
Definition GameObject.cpp:911
time_t GetRespawnTimeEx() const
Definition GameObject.cpp:2949
bool hasQuest(uint32 quest_id) const override
Definition GameObject.cpp:1188
GameObjectFlags GetGameObjectFlags() const
Definition GameObject.h:216
uint32 GetDisplayId() const
Definition GameObject.h:311
void UpdateModelPosition()
Definition GameObject.cpp:2936
bool IsStaticTransport() const
Definition GameObject.h:319
void SetLootMode(uint16 lootMode)
Definition GameObject.h:230
uint32 GetUseCount() const
Definition GameObject.h:241
void SetWorldRotationAngles(float z_rot, float y_rot, float x_rot)
Definition GameObject.cpp:2281
void SetLootGenerationTime()
Definition GameObject.cpp:2958
std::map< uint32, ObjectGuid > ChairSlotAndUser
Definition GameObject.h:390
bool IsNeverVisible() const override
Definition GameObject.cpp:1236
virtual bool LoadFromDB(ObjectGuid::LowType guid, Map *map)
Definition GameObject.h:159
std::string const & GetNameForLocaleIdx(LocaleConstant locale_idx) const override
Definition GameObject.cpp:2230
void BuildValuesUpdate(uint8 updateType, ByteBuffer *data, Player *target) override
Definition GameObject.cpp:2766
void AddToSkillupList(ObjectGuid const &playerGuid)
Definition GameObject.cpp:3095
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition GameObject.cpp:120
uint16 GetLootMode() const
Definition GameObject.h:228
bool IsInvisibleDueToDespawn() const override
Definition GameObject.cpp:1275
void AddToWorld() override
Definition GameObject.cpp:156
void Update(uint32 p_time) override
Definition GameObject.cpp:438
float GetStationaryO() const override
Definition GameObject.h:334
void ModifyHealth(int32 change, Unit *attackerOrHealer=nullptr, uint32 spellId=0)
Definition GameObject.cpp:2303
void AllowSaveToDB(bool enable)
Definition GameObject.h:362
void ReplaceAllDynamicFlags(uint32 flag) override
Definition GameObject.h:132
Definition Object.h:363
Definition Map.h:168
Definition Object.h:415
Definition OutdoorPvP.h:91
uint32 LowType
Definition ObjectGuid.h:125
Definition Object.h:433
Definition Object.h:476
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1381
float GetObjectSize() const
Definition Object.cpp:2892
Definition LootMgr.h:313
Definition Position.h:27
Definition TransportMgr.h:88
Definition GameObject.h:50

Referenced by Use().

◆ loot

◆ lootingGroupLowGUID

uint32 GameObject::lootingGroupLowGUID

Referenced by GameObject(), and Update().

◆ m_AI

GameObjectAI* GameObject::m_AI
private

Referenced by AI(), AIM_Initialize(), and ~GameObject().

◆ m_allowModifyDestructibleBuilding

bool GameObject::m_allowModifyDestructibleBuilding
protected

◆ m_cooldownTime

uint32 GameObject::m_cooldownTime
protected

◆ m_despawnDelay

uint32 GameObject::m_despawnDelay
protected

◆ m_despawnRespawnTime

Seconds GameObject::m_despawnRespawnTime
protected

◆ m_goData

◆ m_goInfo

◆ m_goValue

◆ m_groupLootTimer

uint32 GameObject::m_groupLootTimer

Referenced by GameObject(), and Update().

◆ m_linkedTrap

ObjectGuid GameObject::m_linkedTrap
protected

Referenced by GetLinkedTrap(), and SetLinkedTrap().

◆ m_lootGenerationTime

uint32 GameObject::m_lootGenerationTime
protected

◆ m_LootMode

uint16 GameObject::m_LootMode
protected

◆ m_lootRecipient

ObjectGuid GameObject::m_lootRecipient
protected

◆ m_lootRecipientGroup

◆ m_lootState

LootState GameObject::m_lootState
protected

◆ m_model

◆ m_packedRotation

int64 GameObject::m_packedRotation
protected

◆ m_respawnDelayTime

uint32 GameObject::m_respawnDelayTime
protected

◆ m_respawnTime

◆ m_restockTime

Seconds GameObject::m_restockTime
protected

Referenced by GameObject(), SetLootState(), and Update().

◆ m_ritualOwnerGUID

ObjectGuid GameObject::m_ritualOwnerGUID
protected

Referenced by Update(), and Use().

◆ m_saveStateOnDb

bool GameObject::m_saveStateOnDb = false
private

◆ m_SkillupList

std::unordered_map<ObjectGuid, int32> GameObject::m_SkillupList
protected

◆ m_spawnedByDefault

◆ m_spawnId

◆ m_spellId

uint32 GameObject::m_spellId
protected

◆ m_stationaryPosition

◆ m_unique_users

GuidSet GameObject::m_unique_users
protected

◆ m_usetimes

uint32 GameObject::m_usetimes
protected

◆ WorldRotation

G3D::Quat GameObject::WorldRotation
protected

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