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 SetLocalRotationAngles (float z_rot, float y_rot, float x_rot)
 
void SetLocalRotation (G3D::Quat const &rot)
 
void SetTransportPathRotation (float qx, float qy, float qz, float qw)
 
G3D::Quat const & GetLocalRotation () const
 
int64 GetPackedLocalRotation () const
 
G3D::Quat GetWorldRotation () const
 
std::string const & GetNameForLocaleIdx (LocaleConstant locale_idx) const override
 
void SaveToDB (bool saveAddon=false)
 
void SaveToDB (uint32 mapid, uint8 spawnMask, uint32 phaseMask, bool saveAddon=false)
 
virtual bool LoadFromDB (ObjectGuid::LowType guid, Map *map)
 
virtual bool LoadGameObjectFromDB (ObjectGuid::LowType guid, Map *map, bool addToMap=true)
 
void DeleteFromDB ()
 
void SetOwnerGUID (ObjectGuid owner)
 
ObjectGuid GetOwnerGUID () const
 
UnitGetOwner () const
 
void SetSpellId (uint32 id)
 
uint32 GetSpellId () const
 
time_t GetRespawnTime () const
 
time_t GetRespawnTimeEx () const
 
void SetRespawnTime (int32 respawn)
 
void SetRespawnDelay (int32 respawn)
 
void Respawn ()
 
bool isSpawned () const
 
bool isSpawnedByDefault () const
 
void SetSpawnedByDefault (bool b)
 
uint32 GetRespawnDelay () const
 
void Refresh ()
 
void DespawnOrUnsummon (Milliseconds delay=0ms, Seconds forcedRespawnTime=0s)
 
void Delete ()
 
void GetFishLoot (Loot *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 IsInRange (float x, float y, float z, float radius) const
 
void ModifyHealth (int32 change, Unit *attackerOrHealer=nullptr, uint32 spellId=0)
 
void SetDestructibleBuildingModifyState (bool allow)
 
void SetDestructibleState (GameObjectDestructibleState state, Player *eventInvoker=nullptr, bool setHealth=false)
 
GameObjectDestructibleState GetDestructibleState () const
 
void EventInform (uint32 eventId)
 
virtual uint32 GetScriptId () const
 
GameObjectAIAI () const
 
std::string const & GetAIName () const
 
void SetDisplayId (uint32 displayid)
 
uint32 GetDisplayId () const
 
void GetRespawnPosition (float &x, float &y, float &z, float *ori=nullptr) const
 
void SetPosition (float x, float y, float z, float o)
 
void SetPosition (const Position &pos)
 
bool IsStaticTransport () const
 
bool IsMotionTransport () const
 
TransportToTransport ()
 
Transport const * ToTransport () const
 
StaticTransportToStaticTransport ()
 
StaticTransport const * ToStaticTransport () const
 
MotionTransportToMotionTransport ()
 
MotionTransport const * ToMotionTransport () const
 
float GetStationaryX () const override
 
float GetStationaryY () const override
 
float GetStationaryZ () const override
 
float GetStationaryO () const override
 
float GetInteractionDistance () const
 
void UpdateModelPosition ()
 
bool IsAtInteractDistance (Position const &pos, float radius) const
 
bool IsAtInteractDistance (Player const *player, SpellInfo const *spell=nullptr) const
 
bool IsWithinDistInMap (Player const *player) const
 
SpellInfo const * GetSpellForLock (Player const *player) const
 
bool ValidateGameobjectType () const
 
bool IsInstanceGameobject () const
 
uint8 GameobjectStateToInt (GOState *state) const
 
bool IsAllowedToSaveToDB () const
 
void AllowSaveToDB (bool enable)
 
void SaveStateToDB ()
 
std::string GetDebugInfo () const override
 
bool 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 (const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
Position GetRandomPoint (const Position &srcPos, float distance) const
 
uint32 GetInstanceId () const
 
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 (const Position &pos) const
 
float GetDistance (float x, float y, float z) const
 
float GetDistance2d (WorldObject const *obj) const
 
float GetDistance2d (float x, float y) const
 
float GetDistanceZ (WorldObject const *obj) const
 
bool IsSelfOrInSameMap (WorldObject const *obj) const
 
bool IsInMap (WorldObject const *obj) const
 
bool IsWithinDist3d (float x, float y, float z, float dist) const
 
bool IsWithinDist3d (const Position *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (const Position *pos, float dist) const
 
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true, bool 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
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
void SendPlayMusic (uint32 Music, bool OnlySelf)
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
void SetZoneScript ()
 
void ClearZoneScript ()
 
ZoneScriptGetZoneScript () const
 
TempSummonSummonCreature (uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
 
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang=0, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport=true, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
 
CreatureSummonTrigger (float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=nullptr)
 
CreatureFindNearestCreature (uint32 entry, float range, bool alive=true) const
 
GameObjectFindNearestGameObject (uint32 entry, float range, bool onlySpawned=false) const
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
PlayerSelectNearestPlayer (float distance=0) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void 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 ApplyPercentModFloatValue (uint16 index, float val, bool apply)
 
void SetFlag (uint16 index, uint32 newFlag)
 
void RemoveFlag (uint16 index, uint32 oldFlag)
 
void ToggleFlag (uint16 index, uint32 flag)
 
bool HasFlag (uint16 index, uint32 flag) const
 
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void SetFlag64 (uint16 index, uint64 newFlag)
 
void RemoveFlag64 (uint16 index, uint64 oldFlag)
 
void ToggleFlag64 (uint16 index, uint64 flag)
 
bool HasFlag64 (uint16 index, uint64 flag) const
 
void ApplyModFlag64 (uint16 index, uint64 flag, bool apply)
 
void ClearUpdateMask (bool remove)
 
uint16 GetValuesCount () const
 
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 (const WorldLocation &loc)
 
void WorldRelocate (uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
void SetMapId (uint32 mapId)
 
uint32 GetMapId () const
 
void GetWorldLocation (uint32 &mapId, float &x, float &y) const
 
void GetWorldLocation (uint32 &mapId, float &x, float &y, float &z) const
 
void GetWorldLocation (uint32 &mapId, float &x, float &y, float &z, float &o) const
 
void GetWorldLocation (WorldLocation *location) const
 
WorldLocation GetWorldLocation () const
 
std::string GetDebugInfo () const
 
- Public Member Functions inherited from Position
 Position (float x=0, float y=0, float z=0, float o=0)
 
 Position (Position const &loc)
 
 Position (Position &&)=default
 
Positionoperator= (const Position &)=default
 
Positionoperator= (Position &&)=default
 
bool operator== (Position const &a) const
 
bool operator!= (Position const &a)
 
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 (const Position &pos)
 
void Relocate (const Position *pos)
 
void RelocatePolarOffset (float angle, float dist, float z=0.0f)
 
void RelocateOffset (const Position &offset)
 
void SetOrientation (float orientation)
 
float GetPositionX () const
 
float GetPositionY () const
 
float GetPositionZ () const
 
float GetOrientation () const
 
void GetPosition (float &x, float &y) const
 
void GetPosition (float &x, float &y, float &z) const
 
void GetPosition (float &x, float &y, float &z, float &o) const
 
Position GetPosition () const
 
Position::PositionXYZStreamer PositionXYZStream ()
 
Position::PositionXYZOStreamer PositionXYZOStream ()
 
bool IsPositionValid () const
 
float GetExactDist2dSq (const float x, const float y) const
 
float GetExactDist2dSq (Position const &pos) const
 
float GetExactDist2dSq (Position const *pos) const
 
float GetExactDist2d (const float x, const float y) const
 
float GetExactDist2d (Position const &pos) const
 
float GetExactDist2d (Position const *pos) const
 
float GetExactDistSq (float x, float y, float z) const
 
float GetExactDistSq (Position const &pos) const
 
float GetExactDistSq (Position const *pos) const
 
float GetExactDist (float x, float y, float z) const
 
float GetExactDist (Position const &pos) const
 
float GetExactDist (Position const *pos) const
 
void GetPositionOffsetTo (const Position &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (const Position *pos) const
 
float GetAngle (float x, float y) const
 
float GetAbsoluteAngle (float x, float y) const
 
float GetAbsoluteAngle (Position const &pos) const
 
float GetAbsoluteAngle (Position const *pos) const
 
float GetRelativeAngle (const Position *pos) const
 
float GetRelativeAngle (float x, float y) const
 
float ToAbsoluteAngle (float relAngle) const
 
void GetSinCos (float x, float y, float &vsin, float &vcos) const
 
bool IsInDist2d (float x, float y, float dist) const
 
bool IsInDist2d (const Position *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (const Position *pos, float dist) const
 
bool IsWithinBox (const Position &center, float xradius, float yradius, float zradius) const
 
bool HasInArc (float arcangle, const Position *pos, float targetRadius=0.0f) const
 
bool HasInLine (Position const *pos, float width) const
 
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 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)
 
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

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 m_localRotation
 
Position m_stationaryPosition
 
ObjectGuid m_lootRecipient
 
ObjectGuid::LowType m_lootRecipientGroup
 
uint16 m_LootMode
 
uint32 m_lootGenerationTime
 
ObjectGuid m_linkedTrap
 
ObjectGuid _lootStateUnitGUID
 
- Protected Attributes inherited from WorldObject
std::string m_name
 
bool m_isActive
 
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.
 

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
42 m_model(nullptr), m_goValue(), m_AI(nullptr)
43{
46
48
50 m_respawnTime = 0;
54 m_restockTime = 0s;
56 m_spawnedByDefault = true;
58 m_usetimes = 0;
59 m_spellId = 0;
61 m_goInfo = nullptr;
62 m_goData = nullptr;
64
65 m_spawnId = 0;
66
71
72 ResetLootMode(); // restore default loot mode
74 m_stationaryPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
75}
@ GO_NOT_READY
Definition GameObject.h:110
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEMASK_GAMEOBJECT
Definition ObjectGuid.h:51
@ 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:246
GameObjectValue m_goValue
Definition GameObject.h:393
time_t m_respawnTime
Definition GameObject.h:372
GameObjectData const * m_goData
Definition GameObject.h:392
int64 m_packedRotation
Definition GameObject.h:396
Position m_stationaryPosition
Definition GameObject.h:398
bool m_allowModifyDestructibleBuilding
Definition GameObject.h:394
uint32 m_cooldownTime
Definition GameObject.h:379
uint32 m_spellId
Definition GameObject.h:371
uint32 m_respawnDelayTime
Definition GameObject.h:373
void ResetLootMode()
Definition GameObject.h:232
uint32 m_despawnDelay
Definition GameObject.h:374
Seconds m_despawnRespawnTime
Definition GameObject.h:375
ObjectGuid::LowType m_lootRecipientGroup
Definition GameObject.h:401
GameObjectAI * m_AI
Definition GameObject.h:423
GameObjectModel * m_model
Definition GameObject.h:311
GameObjectTemplate const * m_goInfo
Definition GameObject.h:391
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition GameObject.h:390
uint32 m_groupLootTimer
Definition GameObject.h:254
uint32 lootingGroupLowGUID
Definition GameObject.h:255
bool m_spawnedByDefault
Definition GameObject.h:378
LootState m_lootState
Definition GameObject.h:377
Seconds m_restockTime
Definition GameObject.h:376
uint32 m_usetimes
Definition GameObject.h:385
uint32 m_lootGenerationTime
Definition GameObject.h:403
MovableMapObject()=default
uint16 m_objectType
Definition Object.h:252
uint16 m_valuesCount
Definition Object.h:266
uint16 m_updateFlag
Definition Object.h:255
TypeID m_objectTypeId
Definition Object.h:254
WorldObject()
Definition Object.cpp:1039
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
78{
79 delete m_AI;
80 delete m_model;
81 //if (m_uint32Values) // field array can be not exist if GameOBject not loaded
82 // CleanupsBeforeDelete();
83}

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.

418 {
420 dist2compare += obj->GetObjectSize();
421 return IsInRange(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare);
422 }
bool IsInRange(float x, float y, float z, float radius) const
Definition GameObject.cpp:2150

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

◆ ActivateToQuest()

bool GameObject::ActivateToQuest ( Player target) const
1309{
1310 if (target->HasQuestForGO(GetEntry()))
1311 return true;
1312
1313 if (!GetGOInfo()->IsGameObjectForQuests())
1314 return false;
1315
1316 switch (GetGoType())
1317 {
1319 {
1320 GameObject* go = const_cast<GameObject*>(this);
1321 QuestGiverStatus questStatus = target->GetQuestDialogStatus(go);
1322 if (questStatus > DIALOG_STATUS_UNAVAILABLE)
1323 return true;
1324 break;
1325 }
1327 {
1328 // scan GO chest with loot including quest items
1330 {
1331 //TODO: fix this hack
1332 //look for battlegroundAV for some objects which are only activated after mine gots captured by own team
1334 if (Battleground* bg = target->GetBattleground())
1335 if (bg->GetBgTypeID(true) == BATTLEGROUND_AV && !bg->ToBattlegroundAV()->PlayerCanDoMineQuest(GetEntry(), target->GetTeamId()))
1336 return false;
1337 return true;
1338 }
1339 break;
1340 }
1342 {
1343 if (GetGOInfo()->_generic.questID == -1 || target->GetQuestStatus(GetGOInfo()->_generic.questID) == QUEST_STATUS_INCOMPLETE)
1344 return true;
1345 break;
1346 }
1348 {
1349 if (GetGOInfo()->spellFocus.questID > 0 && target->GetQuestStatus(GetGOInfo()->spellFocus.questID) == QUEST_STATUS_INCOMPLETE)
1350 return true;
1351 break;
1352 }
1354 {
1355 if (GetGOInfo()->goober.questId == -1 || target->GetQuestStatus(GetGOInfo()->goober.questId) == QUEST_STATUS_INCOMPLETE)
1356 return true;
1357 break;
1358 }
1359 default:
1360 break;
1361 }
1362
1363 return false;
1364}
@ 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:1579
@ GAMEOBJECT_TYPE_GENERIC
Definition SharedDefines.h:1576
@ GAMEOBJECT_TYPE_CHEST
Definition SharedDefines.h:1574
@ GAMEOBJECT_TYPE_QUESTGIVER
Definition SharedDefines.h:1573
@ GAMEOBJECT_TYPE_GOOBER
Definition SharedDefines.h:1581
@ BATTLEGROUND_AV
Definition SharedDefines.h:3747
Definition Battleground.h:294
Definition GameObject.h:120
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:136
GameobjectTypes GetGoType() const
Definition GameObject.h:202
bool HaveQuestLootForPlayer(uint32 loot_id, Player const *player) const
Definition LootMgr.cpp:228
uint32 GetEntry() const
Definition Object.h:116
bool HasQuestForGO(int32 GOId) const
Definition Player.cpp:12432
TeamId GetTeamId(bool original=false) const
Definition Player.h:2108
QuestGiverStatus GetQuestDialogStatus(Object *questGiver)
Definition PlayerQuest.cpp:1595
Battleground * GetBattleground(bool create=false) const
Definition Player.cpp:12246
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1430
struct GameObjectTemplate::@232::@243 goober
struct GameObjectTemplate::@232::@241 spellFocus
int32 questID
Definition GameObjectData.h:110
struct GameObjectTemplate::@232::@238 _generic
uint32 questId
Definition GameObjectData.h:91

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
230{ m_LootMode |= lootMode; }
uint16 m_LootMode
Definition GameObject.h:402

References m_LootMode.

◆ AddToSkillupList()

void GameObject::AddToSkillupList ( ObjectGuid const &  playerGuid)
3061{
3062 int32 timer = GetMap()->IsDungeon() ? -1 : 10 * MINUTE * IN_MILLISECONDS;
3063 m_SkillupList[playerGuid] = timer;
3064}
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:381
bool IsDungeon() const
Definition Map.h:295
Map * GetMap() const
Definition Object.h:621

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.

141{
143 if (!IsInWorld())
144 {
145 if (m_zoneScript)
147
149 if (m_spawnId)
150 GetMap()->GetGameObjectBySpawnIdStore().insert(std::make_pair(m_spawnId, this));
151
152 if (m_model)
153 {
156 }
157
158 EnableCollision(GetGoState() == GO_STATE_READY || IsTransport()); // pussywizard: this startOpen is unneeded here, collision depends entirely on GOState
159
161
163
164 sScriptMgr->OnGameObjectAddWorld(this);
165 }
166}
@ GO_STATE_READY
Definition GameObjectData.h:692
#define sScriptMgr
Definition ScriptMgr.h:728
bool UpdatePosition()
Definition GameObjectModel.cpp:250
GOState GetGoState() const
Definition GameObject.h:204
void EnableCollision(bool enable)
Definition GameObject.cpp:2596
bool IsTransport() const
Definition GameObject.cpp:1207
MapStoredObjectTypesContainer & GetObjectsStore()
Definition Map.h:348
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:354
void InsertGameObjectModel(const GameObjectModel &model)
Definition Map.h:392
bool IsInWorld() const
Definition Object.h:108
ObjectGuid GetGUID() const
Definition Object.h:114
bool Insert(KEY_TYPE const &handle, SPECIFIC_TYPE *obj)
Definition TypeContainer.h:177
void AddToWorld() override
Definition Object.cpp:1197
ZoneScript * m_zoneScript
Definition Object.h:737
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)
927{
928 AddUse();
929 m_unique_users.insert(player->GetGUID());
930}
void AddUse()
Definition GameObject.h:238
GuidSet m_unique_users
Definition GameObject.h:384
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113

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

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

◆ AddUse()

◆ AI()

◆ AIM_Initialize()

bool GameObject::AIM_Initialize ( )
protected
86{
87 if (m_AI)
88 delete m_AI;
89
91
92 if (!m_AI)
93 return false;
94
96 return true;
97}
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.

2733{
2734 if (!target)
2735 return;
2736
2738 bool targetIsGM = target->IsGameMaster() && target->GetSession()->IsGMAccount();
2739
2740 ByteBuffer fieldBuffer;
2741
2742 UpdateMask updateMask;
2743 updateMask.SetCount(m_valuesCount);
2744
2746 uint32 visibleFlag = UF_FLAG_PUBLIC;
2747 if (GetOwnerGUID() == target->GetGUID())
2748 visibleFlag |= UF_FLAG_OWNER;
2749
2750 for (uint16 index = 0; index < m_valuesCount; ++index)
2751 {
2752 if (_fieldNotifyFlags & flags[index] ||
2753 ((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)) ||
2754 (index == GAMEOBJECT_FLAGS && forcedFlags))
2755 {
2756 updateMask.SetBit(index);
2757
2758 if (index == GAMEOBJECT_DYNAMIC)
2759 {
2760 uint16 dynFlags = 0;
2761 int16 pathProgress = -1;
2762 switch (GetGoType())
2763 {
2765 if (ActivateToQuest(target))
2766 dynFlags |= GO_DYNFLAG_LO_ACTIVATE;
2767 break;
2770 if (ActivateToQuest(target))
2771 {
2772 dynFlags |= GO_DYNFLAG_LO_ACTIVATE;
2773 if (sWorld->getBoolConfig(CONFIG_OBJECT_SPARKLES))
2774 dynFlags |= GO_DYNFLAG_LO_SPARKLE;
2775 }
2776 else if (targetIsGM)
2777 dynFlags |= GO_DYNFLAG_LO_ACTIVATE;
2778 break;
2781 if (ActivateToQuest(target) && sWorld->getBoolConfig(CONFIG_OBJECT_SPARKLES))
2782 dynFlags |= GO_DYNFLAG_LO_SPARKLE;
2783 break;
2785 if (const StaticTransport* t = ToStaticTransport())
2786 if (t->GetPauseTime())
2787 {
2788 if (GetGoState() == GO_STATE_READY)
2789 {
2790 if (t->GetPathProgress() >= t->GetPauseTime()) // if not, send 100% progress
2791 pathProgress = int16(float(t->GetPathProgress() - t->GetPauseTime()) / float(t->GetPeriod() - t->GetPauseTime()) * 65535.0f);
2792 }
2793 else
2794 {
2795 if (t->GetPathProgress() <= t->GetPauseTime()) // if not, send 100% progress
2796 pathProgress = int16(float(t->GetPathProgress()) / float(t->GetPauseTime()) * 65535.0f);
2797 }
2798 }
2799 // else it's ignored
2800 break;
2802 if (const MotionTransport* t = ToMotionTransport())
2803 pathProgress = int16(float(t->GetPathProgress()) / float(t->GetPeriod()) * 65535.0f);
2804 break;
2805 default:
2806 break;
2807 }
2808
2809 fieldBuffer << uint16(dynFlags);
2810 fieldBuffer << int16(pathProgress);
2811 }
2812 else if (index == GAMEOBJECT_FLAGS)
2813 {
2816 {
2818 }
2819
2820 fieldBuffer << goFlags;
2821 }
2822 else
2823 fieldBuffer << m_uint32Values[index]; // other cases
2824 }
2825 }
2826
2827 *data << uint8(updateMask.GetBlockCount());
2828 updateMask.AppendToPacket(data);
2829 data->append(fieldBuffer);
2830}
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:1586
@ GAMEOBJECT_TYPE_TRANSPORT
Definition SharedDefines.h:1582
@ GO_DYNFLAG_LO_ACTIVATE
Definition SharedDefines.h:1629
@ GO_DYNFLAG_LO_SPARKLE
Definition SharedDefines.h:1632
@ GO_FLAG_NOT_SELECTABLE
Definition SharedDefines.h:1618
@ GO_FLAG_LOCKED
Definition SharedDefines.h:1615
@ 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:137
Definition ByteBuffer.h:70
void append(T value)
Definition ByteBuffer.h:129
MotionTransport * ToMotionTransport()
Definition GameObject.h:326
bool HasLootRecipient() const
Definition GameObject.h:253
ObjectGuid GetOwnerGUID() const
Definition GameObject.h:173
bool ActivateToQuest(Player *target) const
Definition GameObject.cpp:1308
bool IsLootAllowedFor(Player const *player) const
Definition GameObject.cpp:2694
StaticTransport * ToStaticTransport()
Definition GameObject.h:323
Definition Transport.h:51
uint16 _fieldNotifyFlags
Definition Object.h:268
UpdateMask _changesMask
Definition Object.h:264
uint32 * m_uint32Values
Definition Object.h:260
WorldSession * GetSession() const
Definition Player.h:1998
bool IsGameMaster() const
Definition Player.h:1161
Definition Transport.h:115
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:206
#define sWorld
Definition World.h:316
struct GameObjectTemplate::@232::@237 chest
uint32 groupLootRules
Definition GameObjectData.h:98

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 
)
2078{
2079 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
2080 if (!spellInfo)
2081 return;
2082
2083 bool self = true;
2084 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
2085 {
2086 if (spellInfo->Effects[i].TargetA.GetReferenceType() != TARGET_REFERENCE_TYPE_CASTER || spellInfo->Effects[i].TargetB.GetTarget())
2087 {
2088 self = false;
2089 break;
2090 }
2091 }
2092
2093 if (self && target && target->GetGUID() != GetGUID())
2094 {
2095 target->CastSpell(target, spellInfo, true);
2096 return;
2097 }
2098
2099 //summon world trigger
2100 Creature* trigger = SummonTrigger(GetPositionX(), GetPositionY(), GetPositionZ(), 0, spellInfo->CalcCastTime() + 2000, true);
2101 if (!trigger)
2102 return;
2103
2104 if (Unit* owner = GetOwner())
2105 {
2106 trigger->SetLevel(owner->GetLevel(), false);
2107 trigger->SetFaction(owner->GetFaction());
2108 // needed for GO casts for proper target validation checks
2109 trigger->SetOwnerGUID(owner->GetGUID());
2110 // xinef: fixes some duel bugs with traps]
2111 if (owner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
2113 if (owner->IsFFAPvP())
2114 {
2116 {
2117 sScriptMgr->OnFfaPvpStateUpdate(trigger, true);
2119 }
2120
2121 }
2122 // xinef: Remove Immunity flags
2123 trigger->SetImmuneToNPC(false);
2124 // xinef: set proper orientation, fixes cast against stealthed targets
2125 if (target)
2126 trigger->SetInFront(target);
2127 trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, owner->GetGUID());
2128 }
2129 else
2130 {
2131 // xinef: set faction of gameobject, if no faction - assume hostile
2132 trigger->SetFaction(GetTemplateAddon() && GetTemplateAddon()->faction ? GetTemplateAddon()->faction : 14);
2133 // Set owner guid for target if no owner availble - needed by trigger auras
2134 // - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell())
2135 // xinef: set proper orientation, fixes cast against stealthed targets
2136 if (target)
2137 trigger->SetInFront(target);
2138 trigger->CastSpell(target ? target : trigger, spellInfo, true, 0, 0, target ? target->GetGUID() : ObjectGuid::Empty);
2139 }
2140}
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1638
@ TARGET_REFERENCE_TYPE_CASTER
Definition SpellInfo.h:89
#define sSpellMgr
Definition SpellMgr.h:825
@ UNIT_BYTE2_FLAG_FFA_PVP
Definition UnitDefines.h:138
@ UNIT_FLAG_PLAYER_CONTROLLED
Definition UnitDefines.h:257
@ UNIT_FIELD_BYTES_2
Definition UpdateFields.h:161
Definition Creature.h:47
Unit * GetOwner() const
Definition GameObject.cpp:1219
GameObjectTemplateAddon const * GetTemplateAddon() const
Definition GameObject.cpp:911
Definition ObjectGuid.h:118
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
Definition Object.cpp:938
void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition Object.cpp:900
Definition SpellInfo.h:316
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:393
uint32 CalcCastTime(Unit *caster=nullptr, Spell *spell=nullptr) const
Definition SpellInfo.cpp:2364
Definition Unit.h:650
void SetFaction(uint32 faction)
Definition Unit.cpp:10107
void SetImmuneToNPC(bool apply, bool keepCombat=false)
Definition Unit.cpp:13698
void SetLevel(uint8 lvl, bool showLevelChange=true)
Definition Unit.cpp:15489
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:1194
void SetOwnerGUID(ObjectGuid owner)
Definition Unit.cpp:10649
void SetUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition Unit.h:733
void SetInFront(WorldObject const *target)
Definition Unit.cpp:20274
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition Object.cpp:2408
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(), instance_onyxias_lair::instance_onyxias_lair_InstanceMapScript::OnGameObjectCreate(), go_harpoon_canon::OnGossipHello(), SmartScript::ProcessAction(), go_direbrew_mole_machine::go_direbrew_mole_machineAI::Reset(), npc_deaths_door_fell_cannon_target_bunny::npc_deaths_door_fell_cannon_target_bunnyAI::SpellHit(), Update(), go_suppression_device::go_suppression_deviceAI::UpdateAI(), go_witherbark_totem_bundle::go_witherbark_totem_bundleAI::UpdateAI(), and Use().

◆ CheckRitualList()

void GameObject::CheckRitualList ( )
private
202{
203 if (m_unique_users.empty())
204 return;
205
207 if (!animSpell)
208 animSpell = GetSpellId();
209
210 for (GuidSet::iterator itr = m_unique_users.begin(); itr != m_unique_users.end();)
211 {
212 if (*itr == GetOwnerGUID())
213 {
214 ++itr;
215 continue;
216 }
217
218 bool erase = true;
219 if (Player* channeler = ObjectAccessor::GetPlayer(*this, *itr))
220 if (Spell* spell = channeler->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
221 if (spell->m_spellInfo->Id == animSpell)
222 erase = false;
223
224 if (erase)
225 m_unique_users.erase(itr++);
226 else
227 ++itr;
228 }
229}
@ CURRENT_CHANNELED_SPELL
Definition Unit.h:541
uint32 GetSpellId() const
Definition GameObject.h:181
Definition Player.h:1071
Definition Spell.h:295
Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:220
uint32 animSpell
Definition GameObjectData.h:233
struct GameObjectTemplate::@232::@248 summoningRitual

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.

105{
106 if (GetTransport() && !ToTransport())
107 {
109 SetTransport(nullptr);
112 }
113
114 if (IsInWorld())
116
117 if (m_uint32Values) // field array can be not exist if GameOBject not loaded
119}
@ MOVEMENTFLAG_ONTRANSPORT
Definition UnitDefines.h:378
void RemoveFromWorld() override
Definition GameObject.cpp:168
void RemoveFromOwner()
Definition GameObject.cpp:121
Transport * ToTransport()
Definition GameObject.h:320
virtual void RemovePassenger(WorldObject *passenger, bool withAll=false)=0
void SetTransport(Transport *t)
Definition Object.h:691
Transport * GetTransport() const
Definition Object.h:683
MovementInfo m_movementInfo
Definition Object.h:693
void Reset()
Definition Object.h:299
void RemoveMovementFlag(uint32 flag)
Definition Object.h:345
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
232{
233 if (m_unique_users.empty())
234 return;
235
237 if (!animSpell)
238 animSpell = GetSpellId();
239
240 for (ObjectGuid const& guid : m_unique_users)
241 {
242 if (Player* channeler = ObjectAccessor::GetPlayer(*this, guid))
243 if (Spell* spell = channeler->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
244 if (spell->m_spellInfo->Id == animSpell)
245 {
246 spell->SendChannelUpdate(0);
247 spell->finish();
248 }
249 }
250
251 m_unique_users.clear();
252}

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.

255{
256 ASSERT(map);
257 SetMap(map);
258
259 Relocate(x, y, z, ang);
260 m_stationaryPosition.Relocate(x, y, z, ang);
261 if (!IsPositionValid())
262 {
263 LOG_ERROR("entities.gameobject", "Gameobject (GUID: {} Entry: {}) not created. Suggested coordinates isn't valid (X: {} Y: {})", guidlow, name_id, x, y);
264 return false;
265 }
266
267 SetPhaseMask(phaseMask, false);
268
270
272 if (m_zoneScript)
273 {
274 name_id = m_zoneScript->GetGameObjectEntry(guidlow, name_id);
275 if (!name_id)
276 return false;
277 }
278
279 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(name_id);
280 if (!goinfo)
281 {
282 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);
283 return false;
284 }
285
286 Object::_Create(guidlow, goinfo->entry, HighGuid::GameObject);
287
288 m_goInfo = goinfo;
289
290 if (goinfo->type >= MAX_GAMEOBJECT_TYPE)
291 {
292 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);
293 return false;
294 }
295
296 GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(GetSpawnId());
297
298 // hackfix for the hackfix down below
299 switch (goinfo->entry)
300 {
301 // excluded ids from the hackfix below
302 // used switch since there should be more
303 case 181233: // maexxna portal effect
304 case 181575: // maexxna portal
305 case 20992: // theramore black shield
306 case 21042: // theramore guard badge
307 SetLocalRotation(rotation);
308 break;
309 default:
310 // xinef: hackfix - but make it possible to use original WorldRotation (using special gameobject addon data)
311 // pussywizard: temporarily calculate WorldRotation from orientation, do so until values in db are correct
312 if (addon && addon->invisibilityType == INVISIBILITY_GENERAL && addon->InvisibilityValue == 0)
313 {
314 SetLocalRotation(rotation);
315 }
316 else
317 {
319 }
320 break;
321 }
322
323 // pussywizard: no PathRotation for normal gameobjects
324 SetTransportPathRotation(0.0f, 0.0f, 0.0f, 1.0f);
325
326 SetObjectScale(goinfo->size);
327
328 if (GameObjectTemplateAddon const* templateAddon = GetTemplateAddon())
329 {
330 SetUInt32Value(GAMEOBJECT_FACTION, templateAddon->faction);
331 ReplaceAllGameObjectFlags((GameObjectFlags)templateAddon->flags);
332 }
333
334 SetEntry(goinfo->entry);
335
336 // set name for logs usage, doesn't affect anything ingame
337 SetName(goinfo->name);
338
339 // GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
341
343 {
344 if (InstanceScript* instance = GetInstanceScript())
345 {
346 switch (uint8 state = instance->GetStoredGameObjectState(GetSpawnId()))
347 {
348 case 0:
350 SwitchDoorOrButton(true);
351 break;
352 case 1:
353 case 2:
354 SetGoState((GOState)state);
355 break;
356 default:
357 SetGoState(go_state);
358 break;
359 }
360 }
361 }
362 else
363 {
364 SetGoState(go_state);
365 }
366
367 SetGoArtKit(artKit);
368
369 SetDisplayId(goinfo->displayId);
370
371 if (!m_model)
373
374 switch (goinfo->type)
375 {
377 SetGoAnimProgress(animprogress);
379 break;
384 break;
387 break;
389 if (GetGOInfo()->trap.stealthed)
390 {
393 }
394
395 if (GetGOInfo()->trap.invisible)
396 {
399 }
400 break;
401 default:
402 SetGoAnimProgress(animprogress);
403 break;
404 }
405
406 if (addon)
407 {
408 if (addon->InvisibilityValue)
409 {
412 }
413 }
414
417
418 if (uint32 linkedEntry = GetGOInfo()->GetLinkedGameObjectEntry())
419 {
420 GameObject* linkedGO = new GameObject();
421 if (linkedGO->Create(map->GenerateLowGuid<HighGuid::GameObject>(), linkedEntry, map, phaseMask, x, y, z, ang, rotation, 255, GO_STATE_READY))
422 {
423 SetLinkedTrap(linkedGO);
424 map->AddToMap(linkedGO);
425 }
426 else
427 {
428 delete linkedGO;
429 }
430 }
431
432 // Check if GameObject is Large
433 if (goinfo->IsLargeGameObject())
435
436 // Check if GameObject is Infinite
437 if (goinfo->IsInfiniteGameObject())
439
440 return true;
441}
#define ASSERT
Definition Errors.h:68
GOState
Definition GameObjectData.h:690
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
#define sObjectMgr
Definition ObjectMgr.h:1650
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
GameobjectTypes
Definition SharedDefines.h:1570
@ GAMEOBJECT_TYPE_TRAP
Definition SharedDefines.h:1577
@ GAMEOBJECT_TYPE_FISHINGHOLE
Definition SharedDefines.h:1596
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition SharedDefines.h:1588
@ GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING
Definition SharedDefines.h:1604
@ STEALTH_TRAP
Definition SharedDefines.h:1259
@ INVISIBILITY_GENERAL
Definition SharedDefines.h:1266
@ INVISIBILITY_TRAP
Definition SharedDefines.h:1269
#define MAX_GAMEOBJECT_TYPE
Definition SharedDefines.h:1609
GameObjectFlags
Definition SharedDefines.h:1613
@ GAMEOBJECT_FACTION
Definition UpdateFields.h:402
void AddFlag(FLAG_TYPE flag)
Definition Object.h:391
void AddValue(FLAG_TYPE flag, T_VALUES value)
Definition Object.h:396
void SetLocalRotationAngles(float z_rot, float y_rot, float x_rot)
Definition GameObject.cpp:2247
GameObject()
Definition GameObject.cpp:41
void SetGoState(GOState state)
Definition GameObject.cpp:2469
void SetTransportPathRotation(float qx, float qy, float qz, float qw)
Definition GameObject.cpp:2239
void SetGoArtKit(uint8 artkit)
Definition GameObject.cpp:1424
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition GameObject.cpp:2588
void SetLocalRotation(G3D::Quat const &rot)
Definition GameObject.cpp:2225
void SetGoAnimProgress(uint8 animprogress)
Definition GameObject.h:209
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:254
GameObjectModel * CreateModel()
Definition GameObject.cpp:2948
void SetGoType(GameobjectTypes type)
Definition GameObject.h:203
void SetLinkedTrap(GameObject *linkedTrap)
Definition GameObject.h:260
ObjectGuid::LowType GetSpawnId() const
Definition GameObject.h:144
bool AIM_Initialize()
Definition GameObject.cpp:85
virtual uint32 GetScriptId() const
Definition GameObject.cpp:2189
void SetDisplayId(uint32 displayid)
Definition GameObject.cpp:2582
void ReplaceAllGameObjectFlags(GameObjectFlags flags)
Definition GameObject.h:219
bool IsInstanceGameobject() const
Definition GameObject.cpp:2505
void SwitchDoorOrButton(bool activate, bool alternative=false)
Definition GameObject.cpp:1447
Definition InstanceScript.h:143
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:480
uint32 GetId() const
Definition Map.h:229
bool AddToMap(T *, bool checkTransport=false)
Definition Map.cpp:305
void _Create(ObjectGuid::LowType guidlow, uint32 entry, HighGuid guidhigh)
Definition Object.cpp:123
void SetEntry(uint32 entry)
Definition Object.h:117
virtual void SetObjectScale(float scale)
Definition Object.h:120
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:639
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1221
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibility
Definition Object.h:610
uint32 LastUsedScriptID
Definition Object.h:680
void SetName(std::string const &newname)
Definition Object.h:526
void SetZoneScript()
Definition Object.cpp:2337
virtual void SetMap(Map *map)
Definition Object.cpp:2115
void UpdatePositionData()
Definition Object.cpp:1162
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPES > m_stealth
Definition Object.h:607
void SetVisibilityDistanceOverride(VisibilityDistanceType type)
Definition Object.cpp:1091
virtual uint32 GetGameObjectEntry(ObjectGuid::LowType, uint32 entry)
Definition ZoneScript.h:32
Definition GameObjectData.h:683
uint32 InvisibilityValue
Definition GameObjectData.h:685
InvisibilityType invisibilityType
Definition GameObjectData.h:684
Definition GameObjectData.h:666
Definition GameObjectData.h:31
uint32 intactNumHits
Definition GameObjectData.h:351
uint32 stealthed
Definition GameObjectData.h:124
uint32 type
Definition GameObjectData.h:33
uint32 entry
Definition GameObjectData.h:32
bool IsLargeGameObject() const
Definition GameObjectData.h:593
bool IsInfiniteGameObject() const
Definition GameObjectData.h:618
uint32 minSuccessOpens
Definition GameObjectData.h:87
uint32 invisible
Definition GameObjectData.h:126
uint32 damagedNumHits
Definition GameObjectData.h:356
std::string name
Definition GameObjectData.h:35
uint32 maxSuccessOpens
Definition GameObjectData.h:88
struct GameObjectTemplate::@232::@260 building
float size
Definition GameObjectData.h:39
uint32 displayId
Definition GameObjectData.h:34
static float NormalizeOrientation(float o)
Definition Position.h:238
float GetOrientation() const
Definition Position.h:124
bool IsPositionValid() const
Definition Position.cpp:183
uint32 MaxOpens
Definition GameObject.h:60
struct GameObjectValue::@231 Building
struct GameObjectValue::@229 FishingHole
uint32 MaxHealth
Definition GameObject.h:71
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(), Position::GetOrientation(), GetScriptId(), GetSpawnId(), GetTemplateAddon(), GO_STATE_READY, GameObjectValue::Health, Infinite, GameObjectTemplate::intactNumHits, INVISIBILITY_GENERAL, 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, Position::NormalizeOrientation(), Position::Relocate(), ReplaceAllGameObjectFlags(), SetDisplayId(), Object::SetEntry(), SetGoAnimProgress(), SetGoArtKit(), SetGoState(), SetGoType(), SetLinkedTrap(), SetLocalRotation(), SetLocalRotationAngles(), WorldObject::SetMap(), WorldObject::SetName(), Object::SetObjectScale(), SetPhaseMask(), SetTransportPathRotation(), Object::SetUInt32Value(), WorldObject::SetVisibilityDistanceOverride(), WorldObject::SetZoneScript(), GameObjectTemplate::size, sObjectMgr, STEALTH_TRAP, GameObjectTemplate::stealthed, SwitchDoorOrButton(), GameObjectTemplate::type, WorldObject::UpdatePositionData(), and urand().

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
2949{
2950 return GameObjectModel::Create(std::make_unique<GameObjectModelOwnerImpl>(this), sWorld->GetDataPath());
2951}
static GameObjectModel * Create(std::unique_ptr< GameObjectModelOwnerBase > modelOwner, std::string const &dataPath)
Definition GameObjectModel.cpp:168

References GameObjectModel::Create(), and sWorld.

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

◆ Delete()

void GameObject::Delete ( )
979{
982
984
986
987 if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
989
990 // Xinef: if ritual gameobject is removed, clear anim spells
993
994 uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<GameObject>(m_spawnId) : 0;
995 if (poolid)
996 sPoolMgr->UpdatePool<GameObject>(poolid, m_spawnId);
997 else
999}
#define sPoolMgr
Definition PoolMgr.h:163
@ GAMEOBJECT_TYPE_SUMMONING_RITUAL
Definition SharedDefines.h:1589
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2434
void ClearRitualList()
Definition GameObject.cpp:231
void AddObjectToRemoveList()
Definition Object.cpp:2151
void SendObjectDeSpawnAnim(ObjectGuid guid)
Definition Object.cpp:2108

References WorldObject::AddObjectToRemoveList(), ClearRitualList(), GAMEOBJECT_TYPE_SUMMONING_RITUAL, GetGOInfo(), Object::GetGUID(), 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(), instance_razorfen_downs::instance_razorfen_downs_InstanceMapScript::OnGameObjectCreate(), go_ulduar_working_harpoon::OnGossipHello(), Unit::RemoveAllGameObjects(), Unit::RemoveGameObject(), 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 ( )
1169{
1171 sObjectMgr->DeleteGOData(m_spawnId);
1172
1174 stmt->SetData(0, m_spawnId);
1175 WorldDatabase.Execute(stmt);
1176
1177 stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_EVENT_GAMEOBJECT);
1178 stmt->SetData(0, m_spawnId);
1179 WorldDatabase.Execute(stmt);
1180}
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
@ WORLD_DEL_EVENT_GAMEOBJECT
Definition WorldDatabase.h:38
@ WORLD_DEL_GAMEOBJECT
Definition WorldDatabase.h:37
void RemoveGORespawnTime(ObjectGuid::LowType dbGuid)
Definition Map.cpp:2449
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 
)
933{
934 if (delay > 0ms)
935 {
936 if (!m_despawnDelay || m_despawnDelay > delay.count())
937 {
938 m_despawnDelay = delay.count();
939 m_despawnRespawnTime = forceRespawnTime;
940 }
941 }
942 else
943 {
944 if (m_goData)
945 {
946 int32 const respawnDelay = (forceRespawnTime > 0s) ? forceRespawnTime.count() : m_goData->spawntimesecs;
947 SetRespawnTime(respawnDelay);
948 }
949
950 // Respawn is handled by the gameobject itself.
951 // If we delete it from world, it simply never respawns...
952 // Uncomment this and remove the following lines if dynamic spawn is implemented.
953 // Delete();
954 {
958
959 if (GameObject* trap = GetLinkedTrap())
960 {
961 trap->DespawnOrUnsummon();
962 }
963
964 if (GameObjectTemplateAddon const* addon = GetTemplateAddon())
965 {
967 }
968
969 uint32 poolid = m_spawnId ? sPoolMgr->IsPartOfAPool<GameObject>(m_spawnId) : 0;
970 if (poolid)
971 {
972 sPoolMgr->UpdatePool<GameObject>(poolid, m_spawnId);
973 }
974 }
975 }
976}
@ GO_JUST_DEACTIVATED
Definition GameObject.h:113
GameObject * GetLinkedTrap()
Definition GameObject.cpp:2727
void SetRespawnTime(int32 respawn)
Definition GameObject.cpp:1284
int32 spawntimesecs
Definition GameObjectData.h:708

References Object::GetGUID(), GetLinkedTrap(), GetTemplateAddon(), GO_JUST_DEACTIVATED, GO_STATE_READY, m_despawnDelay, m_despawnRespawnTime, m_goData, 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::instance_molten_core_InstanceMapScript::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(), 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)
2597{
2598 if (!m_model)
2599 return;
2600
2601 /*if (enable && !GetMap()->ContainsGameObjectModel(*m_model))
2602 GetMap()->InsertGameObjectModel(*m_model);*/
2603
2604 uint32 phaseMask = 0;
2605 if (enable && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_GO_LOS, GetEntry(), nullptr))
2606 phaseMask = GetPhaseMask();
2607
2608 m_model->enable(phaseMask);
2609}
#define sDisableMgr
Definition DisableMgr.h:88
@ DISABLE_TYPE_GO_LOS
Definition DisableMgr.h:35
void enable(uint32 ph_mask)
Definition GameObjectModel.h:67
uint32 GetPhaseMask() const
Definition Object.h:513

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

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

◆ EventInform()

void GameObject::EventInform ( uint32  eventId)
2178{
2179 if (!eventId)
2180 return;
2181
2182 if (AI())
2183 AI()->EventInform(eventId);
2184
2185 if (m_zoneScript)
2186 m_zoneScript->ProcessEvent(this, eventId);
2187}
virtual void EventInform(uint32)
Definition GameObjectAI.h:65
GameObjectAI * AI() const
Definition GameObject.h:305
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
2540{
2541 uint8 m_state = 3;
2542
2543 if (state)
2544 {
2545 switch (*state)
2546 {
2547 case GO_STATE_ACTIVE:
2548 m_state = 0;
2549 return m_state;
2550 case GO_STATE_READY:
2551 m_state = 1;
2552 return m_state;
2554 m_state = 2;
2555 return m_state;
2556 }
2557 }
2558
2559 // Returning any value that is not one of the specified ones
2560 // Which will default into the invalid part of the switch
2561 return m_state;
2562}
@ GO_STATE_ACTIVE
Definition GameObjectData.h:691
@ GO_STATE_ACTIVE_ALTERNATIVE
Definition GameObjectData.h:693

References GO_STATE_ACTIVE, GO_STATE_ACTIVE_ALTERNATIVE, and GO_STATE_READY.

Referenced by SaveStateToDB().

◆ GetAIName()

std::string const & GameObject::GetAIName ( ) const
100{
101 return sObjectMgr->GetGameObjectTemplate(GetEntry())->AIName;
102}

References Object::GetEntry(), and sObjectMgr.

Referenced by GetDebugInfo().

◆ GetDebugInfo()

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

Reimplemented from Object.

Reimplemented in MotionTransport.

3080{
3081 std::stringstream sstr;
3082 sstr << WorldObject::GetDebugInfo() << "\n"
3083 << "SpawnId: " << GetSpawnId() << " GoState: " << std::to_string(GetGoState()) << " ScriptId: " << GetScriptId() << " AIName: " << GetAIName();
3084 return sstr.str();
3085}
std::string const & GetAIName() const
Definition GameObject.cpp:99
std::string GetDebugInfo() const override
Definition Object.cpp:2488

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

Referenced by MotionTransport::GetDebugInfo().

◆ GetDestructibleState()

GameObjectDestructibleState GameObject::GetDestructibleState ( ) const
inline
294 {
300 }
@ GO_FLAG_DESTROYED
Definition SharedDefines.h:1622
@ GO_FLAG_DAMAGED
Definition SharedDefines.h:1621
@ GO_DESTRUCTIBLE_DESTROYED
Definition SharedDefines.h:1640
@ GO_DESTRUCTIBLE_INTACT
Definition SharedDefines.h:1638
@ GO_DESTRUCTIBLE_DAMAGED
Definition SharedDefines.h:1639
bool HasGameObjectFlag(GameObjectFlags flags) const
Definition GameObject.h:216

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:294

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

◆ GetFishLoot()

void GameObject::GetFishLoot ( Loot fishLoot,
Player lootOwner,
bool  junk = false 
)
1002{
1003 fishLoot->clear();
1004
1005 uint32 zone, area;
1006 uint32 defaultZone = 1;
1007 GetZoneAndAreaId(zone, area);
1008
1009 uint16 lootMode = junk ? LOOT_MODE_JUNK_FISH : LOOT_MODE_DEFAULT;
1010 // Check to fill loot in the order area - zone - defaultZone.
1011 // This is because area and zone is not set in some places, like Off the coast of Storm Peaks.
1012 uint32 lootZones[] = { area, zone, defaultZone };
1013 for (uint32 fillZone : lootZones)
1014 {
1015 fishLoot->FillLoot(fillZone, LootTemplates_Fishing, lootOwner, true, true, lootMode);
1016
1017 // If the loot is filled and the loot is eligible, then we break out of the loop.
1018 if (!fishLoot->empty() && !fishLoot->isLooted())
1019 break;
1020 }
1021}
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:3079
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:571

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
208{ return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
@ GAMEOBJECT_BYTES_1
Definition UpdateFields.h:404
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition Object.cpp:312

References GAMEOBJECT_BYTES_1, and Object::GetByteValue().

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

◆ GetGoArtKit()

uint8 GameObject::GetGoArtKit ( ) const
inline
206{ 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
2865{
2866 switch (GetGoType())
2867 {
2869 return 0.0f;
2875 return 5.5555553f;
2877 return 10.0f;
2880 return 3.0f;
2882 return 100.0f;
2884 return 20.0f + CONTACT_DISTANCE; // max spell range
2890 return 5.0f;
2891 // Following values are not blizzlike
2894 // 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.
2895 // 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.
2896 return 10.0f; // 5.0f is blizzlike
2897 default:
2898 return INTERACTION_DISTANCE;
2899 }
2900}
#define INTERACTION_DISTANCE
Definition ObjectDefines.h:24
#define CONTACT_DISTANCE
Definition ObjectDefines.h:23
@ GAMEOBJECT_TYPE_GUILD_BANK
Definition SharedDefines.h:1605
@ GAMEOBJECT_TYPE_MINI_GAME
Definition SharedDefines.h:1598
@ GAMEOBJECT_TYPE_CAMERA
Definition SharedDefines.h:1584
@ GAMEOBJECT_TYPE_MAP_OBJECT
Definition SharedDefines.h:1585
@ GAMEOBJECT_TYPE_FLAGDROP
Definition SharedDefines.h:1597
@ GAMEOBJECT_TYPE_MAILBOX
Definition SharedDefines.h:1590
@ GAMEOBJECT_TYPE_FLAGSTAND
Definition SharedDefines.h:1595
@ GAMEOBJECT_TYPE_CHAIR
Definition SharedDefines.h:1578
@ GAMEOBJECT_TYPE_TEXT
Definition SharedDefines.h:1580
@ GAMEOBJECT_TYPE_DUNGEON_DIFFICULTY
Definition SharedDefines.h:1602
@ GAMEOBJECT_TYPE_AREADAMAGE
Definition SharedDefines.h:1583
@ GAMEOBJECT_TYPE_BARBER_CHAIR
Definition SharedDefines.h:1603
@ GAMEOBJECT_TYPE_DOOR
Definition SharedDefines.h:1571
@ GAMEOBJECT_TYPE_BINDER
Definition SharedDefines.h:1575

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.

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

References GetOwner().

◆ GetLinkedTrap()

GameObject * GameObject::GetLinkedTrap ( )
2728{
2730}
ObjectGuid m_linkedTrap
Definition GameObject.h:405
GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:184

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

◆ GetLocalRotation()

G3D::Quat const & GameObject::GetLocalRotation ( ) const
inline
150{ return m_localRotation; }
G3D::Quat m_localRotation
Definition GameObject.h:397

References m_localRotation.

Referenced by GetWorldRotation().

◆ GetLootGenerationTime()

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

References m_lootGenerationTime.

Referenced by Player::SendLoot().

◆ GetLootMode()

uint16 GameObject::GetLootMode ( ) const
inline

◆ GetLootRecipient()

Player * GameObject::GetLootRecipient ( ) const
2625{
2626 if (!m_lootRecipient)
2627 return nullptr;
2629}
ObjectGuid m_lootRecipient
Definition GameObject.h:400
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:257

References ObjectAccessor::FindConnectedPlayer(), and m_lootRecipient.

◆ GetLootRecipientGroup()

Group * GameObject::GetLootRecipientGroup ( ) const
2632{
2634 return nullptr;
2635 return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup);
2636}
#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.

2200{
2201 if (loc_idx != DEFAULT_LOCALE)
2202 {
2203 uint8 uloc_idx = uint8(loc_idx);
2204 if (GameObjectLocale const* cl = sObjectMgr->GetGameObjectLocale(GetEntry()))
2205 if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty())
2206 return cl->Name[uloc_idx];
2207 }
2208
2209 return GetName();
2210}
#define DEFAULT_LOCALE
Definition Common.h:131
std::string const & GetName() const
Definition Object.h:525
Definition GameObjectData.h:676

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

Referenced by gobject_commandscript::HandleGameObjectRespawn().

◆ GetOwner()

Unit * GameObject::GetOwner ( ) const
1220{
1221 return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
1222}
Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:199

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

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

◆ GetOwnerGUID()

◆ GetPackedLocalRotation()

int64 GameObject::GetPackedLocalRotation ( ) 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
2833{
2834 if (m_spawnId)
2835 {
2836 if (GameObjectData const* data = sObjectMgr->GetGameObjectData(m_spawnId))
2837 {
2838 x = data->posX;
2839 y = data->posY;
2840 z = data->posZ;
2841 if (ori)
2842 *ori = data->orientation;
2843 return;
2844 }
2845 }
2846
2847 x = GetPositionX();
2848 y = GetPositionY();
2849 z = GetPositionZ();
2850 if (ori)
2851 *ori = GetOrientation();
2852}
Definition GameObjectData.h:698

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
2916{
2917 time_t now = GameTime::GetGameTime().count();
2918 if (m_respawnTime > now)
2919 return m_respawnTime;
2920 else
2921 return now;
2922}
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
3001{
3002 if (!player)
3003 {
3004 return nullptr;
3005 }
3006
3007 uint32 lockId = GetGOInfo()->GetLockId();
3008 if (!lockId)
3009 {
3010 return nullptr;
3011 }
3012
3013 LockEntry const* lock = sLockStore.LookupEntry(lockId);
3014 if (!lock)
3015 {
3016 return nullptr;
3017 }
3018
3019 for (uint8 i = 0; i < MAX_LOCK_CASE; ++i)
3020 {
3021 if (!lock->Type[i])
3022 {
3023 continue;
3024 }
3025
3026 if (lock->Type[i] == LOCK_KEY_SPELL)
3027 {
3028 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(lock->Index[i]))
3029 {
3030 return spell;
3031 }
3032 }
3033
3034 if (lock->Type[i] != LOCK_KEY_SKILL)
3035 {
3036 break;
3037 }
3038
3039 for (auto&& playerSpell : player->GetSpellMap())
3040 {
3041 if (SpellInfo const* spell = sSpellMgr->GetSpellInfo(playerSpell.first))
3042 {
3043 for (auto&& effect : spell->Effects)
3044 {
3045 if (effect.Effect == SPELL_EFFECT_OPEN_LOCK && ((uint32) effect.MiscValue) == lock->Index[i])
3046 {
3047 if (effect.CalcValue(player) >= int32(lock->Skill[i]))
3048 {
3049 return spell;
3050 }
3051 }
3052 }
3053 }
3054 }
3055 }
3056
3057 return nullptr;
3058}
DBCStorage< LockEntry > sLockStore(LockEntryfmt)
#define MAX_LOCK_CASE
Definition DBCStructure.h:1306
@ SPELL_EFFECT_OPEN_LOCK
Definition SharedDefines.h:822
@ LOCK_KEY_SKILL
Definition SharedDefines.h:2597
@ LOCK_KEY_SPELL
Definition SharedDefines.h:2598
uint32 GetLockId() const
Definition GameObjectData.h:427
Definition DBCStructure.h:1309
uint32 Type[MAX_LOCK_CASE]
Definition DBCStructure.h:1311
uint32 Index[MAX_LOCK_CASE]
Definition DBCStructure.h:1312
uint32 Skill[MAX_LOCK_CASE]
Definition DBCStructure.h:1313

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
241{ return m_unique_users.size(); }

References m_unique_users.

Referenced by Update(), and Use().

◆ GetUseCount()

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

References m_usetimes.

Referenced by WorldSession::DoLootRelease().

◆ GetWorldRotation()

G3D::Quat GameObject::GetWorldRotation ( ) const
2253{
2254 G3D::Quat localRotation = GetLocalRotation();
2255 if (Transport* transport = GetTransport())
2256 {
2257 G3D::Quat worldRotation = transport->GetWorldRotation();
2258
2259 G3D::Quat worldRotationQuat(worldRotation.x, worldRotation.y, worldRotation.z, worldRotation.w);
2260 G3D::Quat localRotationQuat(localRotation.x, localRotation.y, localRotation.z, localRotation.w);
2261
2262 G3D::Quat resultRotation = localRotationQuat * worldRotationQuat;
2263
2264 return G3D::Quat(resultRotation.x, resultRotation.y, resultRotation.z, resultRotation.w);
2265 }
2266 return localRotation;
2267}
G3D::Quat const & GetLocalRotation() const
Definition GameObject.h:150
Definition Transport.h:30

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

Referenced by IsAtInteractDistance().

◆ HasGameObjectFlag()

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

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.

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

References Object::GetEntry(), and sObjectMgr.

◆ HasLootMode()

bool GameObject::HasLootMode ( uint16  lootMode) const
inline
228{ 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.

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

References Object::GetEntry(), and sObjectMgr.

◆ IsAllowedToSaveToDB()

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

References m_saveStateOnDb.

Referenced by SetGoState().

◆ IsAlwaysVisibleFor()

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

Reimplemented from WorldObject.

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

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
2954{
2955 if (spell || (spell = GetSpellForLock(player)))
2956 {
2957 float maxRange = spell->GetMaxRange(spell->IsPositive());
2958
2960 {
2961 return maxRange * maxRange >= GetExactDistSq(player);
2962 }
2963
2964 if (sGameObjectDisplayInfoStore.LookupEntry(GetGOInfo()->displayId))
2965 {
2966 return IsAtInteractDistance(*player, maxRange);
2967 }
2968 }
2969
2971}
DBCStorage< GameObjectDisplayInfoEntry > sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt)
bool IsAtInteractDistance(Position const &pos, float radius) const
Definition GameObject.cpp:2973
SpellInfo const * GetSpellForLock(Player const *player) const
Definition GameObject.cpp:3000
float GetInteractionDistance() const
Definition GameObject.cpp:2864
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
2974{
2975 if (GameObjectDisplayInfoEntry const* displayInfo = sGameObjectDisplayInfoStore.LookupEntry(GetGOInfo()->displayId))
2976 {
2977 float scale = GetObjectScale();
2978
2979 float minX = displayInfo->minX * scale - radius;
2980 float minY = displayInfo->minY * scale - radius;
2981 float minZ = displayInfo->minZ * scale - radius;
2982 float maxX = displayInfo->maxX * scale + radius;
2983 float maxY = displayInfo->maxY * scale + radius;
2984 float maxZ = displayInfo->maxZ * scale + radius;
2985
2986 G3D::Quat worldRotation = GetWorldRotation();
2987 G3D::Quat worldRotationQuat(worldRotation.x, worldRotation.y, worldRotation.z, worldRotation.w);
2988
2989 return G3D::CoordinateFrame {{worldRotationQuat}, {GetPositionX(), GetPositionY(), GetPositionZ()}}.toWorldSpace(G3D::Box {{minX, minY, minZ}, {maxX, maxY, maxZ}}).contains({pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()});
2990 }
2991
2992 return GetExactDist(&pos) <= radius;
2993}
G3D::Quat GetWorldRotation() const
Definition GameObject.cpp:2252
float GetObjectScale() const
Definition Object.h:119
Definition DBCStructure.h:1001
float GetExactDist(float x, float y, float z) const
Definition Position.h:182

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

Referenced by IsAtInteractDistance(), and IsWithinDistInMap().

◆ IsDestructibleBuilding()

bool GameObject::IsDestructibleBuilding ( ) const
1213{
1214 GameObjectTemplate const* gInfo = GetGOInfo();
1215 if (!gInfo) return false;
1217}

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

Referenced by IsAlwaysVisibleFor(), and ModifyHealth().

◆ IsInRange()

bool GameObject::IsInRange ( 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

2151{
2153 if (!info)
2154 return IsWithinDist3d(x, y, z, radius);
2155
2156 float sinA = std::sin(GetOrientation());
2157 float cosA = cos(GetOrientation());
2158 float dx = x - GetPositionX();
2159 float dy = y - GetPositionY();
2160 float dz = z - GetPositionZ();
2161 float dist = std::sqrt(dx * dx + dy * dy);
2164 if (G3D::fuzzyEq(dist, 0.0f))
2165 return true;
2166
2167 float scale = GetObjectScale();
2168 float sinB = dx / dist;
2169 float cosB = dy / dist;
2170 dx = dist * (cosA * cosB + sinA * sinB);
2171 dy = dist * (cosA * sinB - sinA * cosB);
2172 return dx < (info->maxX * scale) + radius && dx > (info->minX * scale) - radius
2173 && dy < (info->maxY * scale) + radius && dy > (info->minY * scale) - radius
2174 && dz < (info->maxZ * scale) + radius && dz > (info->minZ * scale) - radius;
2175}
bool IsWithinDist3d(float x, float y, float z, float dist) const
Definition Object.cpp:1328
float maxX
Definition DBCStructure.h:1008
float maxY
Definition DBCStructure.h:1009
float minY
Definition DBCStructure.h:1006
float minX
Definition DBCStructure.h:1005
float minZ
Definition DBCStructure.h:1007
float maxZ
Definition DBCStructure.h:1010

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
3067{
3068 for (auto const& itr : m_SkillupList)
3069 {
3070 if (itr.first == playerGuid)
3071 {
3072 return true;
3073 }
3074 }
3075
3076 return false;
3077}

References m_SkillupList.

Referenced by Spell::EffectOpenLock().

◆ IsInstanceGameobject()

bool GameObject::IsInstanceGameobject ( ) const
2506{
2507 // Avoid checking for unecessary gameobjects whose
2508 // states don't matter for the dungeon progression
2510 {
2511 return false;
2512 }
2513
2514 if (auto* map = FindMap())
2515 {
2516 if (map->IsDungeon() || map->IsRaid())
2517 {
2518 return true;
2519 }
2520 }
2521 return false;
2522}
bool ValidateGameobjectType() const
Definition GameObject.cpp:2524
Map * FindMap() const
Definition Object.h:622

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

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

◆ IsInvisibleDueToDespawn()

bool GameObject::IsInvisibleDueToDespawn ( ) const
overridevirtual

Reimplemented from WorldObject.

1273{
1275 return true;
1276
1277 // Despawned
1278 if (!isSpawned())
1279 return true;
1280
1281 return false;
1282}
bool isSpawned() const
Definition GameObject.h:189
virtual bool IsInvisibleDueToDespawn() const
Definition Object.h:758

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

◆ IsLootAllowedFor()

bool GameObject::IsLootAllowedFor ( Player const *  player) const
2695{
2697 {
2698 return true;
2699 }
2700
2701 if (player->GetGUID() == m_lootRecipient)
2702 {
2703 return true;
2704 }
2705
2706 if (player->HasPendingBind())
2707 {
2708 return false;
2709 }
2710
2711 // if we dont have a group we arent the recipient
2712 // if go doesnt have group bound it means it was solo killed by someone else
2713 Group const* playerGroup = player->GetGroup();
2714 if (!playerGroup || playerGroup != GetLootRecipientGroup())
2715 {
2716 return false;
2717 }
2718
2719 if (!HasAllowedLooter(player->GetGUID()))
2720 {
2721 return false;
2722 }
2723
2724 return true;
2725}
Group * GetLootRecipientGroup() const
Definition GameObject.cpp:2631
Definition Group.h:169
bool HasAllowedLooter(ObjectGuid guid) const
Definition Object.cpp:3119

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.

1234{
1236 return true;
1237
1238 if (GetGoType() == GAMEOBJECT_TYPE_SPELL_FOCUS && GetGOInfo()->spellFocus.serverOnly == 1)
1239 return true;
1240
1241 return false;
1242}
virtual bool IsNeverVisible() const
Definition Object.h:756
uint32 serverOnly
Definition GameObjectData.h:107

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

◆ isSpawned()

◆ isSpawnedByDefault()

bool GameObject::isSpawnedByDefault ( ) const
inline

◆ IsStaticTransport()

bool GameObject::IsStaticTransport ( ) const
inline

◆ IsTransport()

◆ IsUpdateNeeded()

bool GameObject::IsUpdateNeeded ( )
overridevirtual

Reimplemented from WorldObject.

3089{
3091 return true;
3092
3093 if (GetMap()->isCellMarked(GetCurrentCell().GetCellCoord().GetId()))
3094 return true;
3095
3096 if (!GetObjectVisibilityContainer().GetVisiblePlayersMap().empty())
3097 return true;
3098
3099 if (IsTransport())
3100 return true;
3101
3102 return false;
3103}
Cell const & GetCurrentCell() const
Definition Object.h:419
virtual bool IsUpdateNeeded()
Definition Object.cpp:3139
ObjectVisibilityContainer & GetObjectVisibilityContainer()
Definition Object.h:726
uint32 GetId(std::string const &username)
Definition AccountMgr.cpp:236

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
1355{
1356 return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D, incOwnRadius, incTargetRadius);
1357}
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:417

◆ 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:1104

References LoadGameObjectFromDB().

Referenced by GridObjectLoader::LoadGameObjects().

◆ LoadGameObjectFromDB()

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

Reimplemented in StaticTransport.

1105{
1106 GameObjectData const* data = sObjectMgr->GetGameObjectData(spawnId);
1107
1108 if (!data)
1109 {
1110 LOG_ERROR("sql.sql", "Gameobject (GUID: {}) not found in table `gameobject`, can't load. ", spawnId);
1111 return false;
1112 }
1113
1114 uint32 entry = data->id;
1115 //uint32 map_id = data->mapid; // already used before call
1116 uint32 phaseMask = data->phaseMask;
1117 float x = data->posX;
1118 float y = data->posY;
1119 float z = data->posZ;
1120 float ang = data->orientation;
1121
1122 uint32 animprogress = data->animprogress;
1123 GOState go_state = data->go_state;
1124 uint32 artKit = data->artKit;
1125
1126 m_goData = data;
1127 m_spawnId = spawnId;
1128
1129 if (!Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, phaseMask, x, y, z, ang, data->rotation, animprogress, go_state, artKit))
1130 return false;
1131
1132 if (data->spawntimesecs >= 0)
1133 {
1134 m_spawnedByDefault = true;
1135
1136 if (!GetGOInfo()->GetDespawnPossibility() && !GetGOInfo()->IsDespawnAtAction())
1137 {
1140 m_respawnTime = 0;
1141 }
1142 else
1143 {
1146
1147 // ready to respawn
1149 {
1150 m_respawnTime = 0;
1152 }
1153 }
1154 }
1155 else
1156 {
1157 m_spawnedByDefault = false;
1159 m_respawnTime = 0;
1160 }
1161
1162 if (addToMap && !GetMap()->AddToMap(this))
1163 return false;
1164
1165 return true;
1166}
@ GO_FLAG_NODESPAWN
Definition SharedDefines.h:1619
void SetGameObjectFlag(GameObjectFlags flags)
Definition GameObject.h:217
time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const
Definition Map.h:413
float orientation
Definition GameObjectData.h:706
float posZ
Definition GameObjectData.h:705
uint8 artKit
Definition GameObjectData.h:713
G3D::Quat rotation
Definition GameObjectData.h:707
uint32 animprogress
Definition GameObjectData.h:710
float posX
Definition GameObjectData.h:703
uint32 phaseMask
Definition GameObjectData.h:702
float posY
Definition GameObjectData.h:704
uint32 id
Definition GameObjectData.h:700
GOState go_state
Definition GameObjectData.h:711

References GameObjectData::animprogress, GameObjectData::artKit, Create(), GameObject, Map::GenerateLowGuid(), GameTime::GetGameTime(), GetGOInfo(), Map::GetGORespawnTime(), WorldObject::GetMap(), GO_FLAG_NODESPAWN, GameObjectData::go_state, GameObjectData::id, LOG_ERROR, m_goData, m_respawnDelayTime, m_respawnTime, m_spawnedByDefault, m_spawnId, GameObjectData::orientation, GameObjectData::phaseMask, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, Map::RemoveGORespawnTime(), GameObjectData::rotation, SetGameObjectFlag(), sObjectMgr, and GameObjectData::spawntimesecs.

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

◆ LookupFishingHoleAround()

GameObject * GameObject::LookupFishingHoleAround ( float  range)
1390{
1391 GameObject* ok = nullptr;
1392
1393 Acore::NearestGameObjectFishingHole u_check(*this, range);
1395
1396 Cell::VisitObjects(this, checker, range);
1397 return ok;
1398}
Definition GridNotifiers.h:673
Definition GridNotifiers.h:310
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?
2270{
2272 return;
2273
2274 // if this building doesn't have health, return
2276 return;
2277
2278 sScriptMgr->OnGameObjectModifyHealth(this, attackerOrHealer, change, sSpellMgr->GetSpellInfo(spellId));
2279
2280 // if the health isn't being changed, return
2281 if (!change)
2282 return;
2283
2285 change = 0;
2286
2287 // prevent double destructions of the same object
2288 if (change < 0 && !m_goValue.Building.Health)
2289 return;
2290
2291 if (int32(m_goValue.Building.Health) + change <= 0)
2295 else
2296 m_goValue.Building.Health += change;
2297
2298 // Set the health bar, value = 255 * healthPct;
2300
2301 Player* player = attackerOrHealer->GetCharmerOrOwnerPlayerOrPlayerItself();
2302
2303 // dealing damage, send packet
2305 if (player)
2306 {
2307 WorldPacket data(SMSG_DESTRUCTIBLE_BUILDING_DAMAGE, 8 + 8 + 8 + 4 + 4);
2308 data << GetPackGUID();
2309 data << attackerOrHealer->GetPackGUID();
2310 data << player->GetPackGUID();
2311 data << uint32(-change); // change < 0 triggers SPELL_BUILDING_HEAL combat log event
2312 // change >= 0 triggers SPELL_BUILDING_DAMAGE event
2313 data << uint32(spellId);
2314 player->SendDirectMessage(&data);
2315 }
2316
2318
2320 newState = GO_DESTRUCTIBLE_DESTROYED;
2321 else if (m_goValue.Building.Health <= GetGOInfo()->building.damagedNumHits)
2322 newState = GO_DESTRUCTIBLE_DAMAGED;
2324 newState = GO_DESTRUCTIBLE_INTACT;
2325
2326 if (newState == GetDestructibleState())
2327 return;
2328
2329 SetDestructibleState(newState, player, false);
2330}
GameObjectDestructibleState
Definition SharedDefines.h:1637
void SetDestructibleState(GameObjectDestructibleState state, Player *eventInvoker=nullptr, bool setHealth=false)
Definition GameObject.cpp:2332
GameObjectDestructibleState GetDestructibleState() const
Definition GameObject.h:293
PackedGuid const & GetPackGUID() const
Definition Object.h:115
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5711
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition Unit.cpp:10692
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 ( )
917{
918 // not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway)
920 return;
921
922 if (isSpawned())
923 GetMap()->AddToMap(this);
924}

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

Referenced by BattlegroundSA::ResetObjs().

◆ RemoveFromOwner()

void GameObject::RemoveFromOwner ( )
private
122{
123 ObjectGuid ownerGUID = GetOwnerGUID();
124 if (!ownerGUID)
125 return;
126
127 if (Unit* owner = ObjectAccessor::GetUnit(*this, ownerGUID))
128 {
129 owner->RemoveGameObject(this, false);
131 return;
132 }
133
134 LOG_DEBUG("entities.gameobject", "Delete GameObject ({} Entry: {} SpellId {} LinkedGO {}) that lost references to owner {} GO list.",
135 GetGUID().ToString(), GetGOInfo()->entry, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString());
136
138}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
void SetOwnerGUID(ObjectGuid owner)
Definition GameObject.h:163
static ObjectGuid const Empty
Definition ObjectGuid.h:120
std::string ToString() const
Definition ObjectGuid.cpp:47
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(), RemoveFromWorld(), and Use().

◆ RemoveFromWorld()

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

Reimplemented from Object.

169{
171 if (IsInWorld())
172 {
173 sScriptMgr->OnGameObjectRemoveWorld(this);
174
175 if (m_zoneScript)
177
179
180 if (m_model)
181 if (GetMap()->ContainsGameObjectModel(*m_model))
183
184 if (Transport* transport = GetTransport())
185 transport->RemovePassenger(this, true);
186
187 // If linked trap exists, despawn it
188 if (GameObject* linkedTrap = GetLinkedTrap())
189 {
190 linkedTrap->Delete();
191 }
192
194
195 if (m_spawnId)
196 Acore::Containers::MultimapErasePair(GetMap()->GetGameObjectBySpawnIdStore(), m_spawnId, this);
198 }
199}
void RemoveGameObjectModel(const GameObjectModel &model)
Definition Map.h:391
bool Remove(KEY_TYPE const &handle)
Definition TypeContainer.h:183
void RemoveFromWorld() override
Definition Object.cpp:1207
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
231{ 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.

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

References SaveRespawnTime().

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

◆ SaveRespawnTime() [2/2]

void GameObject::SaveRespawnTime ( uint32  forceDelay)
1225{
1226 if (m_goData && m_goData->dbData && (forceDelay || m_respawnTime > GameTime::GetGameTime().count()) && m_spawnedByDefault)
1227 {
1228 time_t respawnTime = forceDelay ? GameTime::GetGameTime().count() + forceDelay : m_respawnTime;
1229 GetMap()->SaveGORespawnTime(m_spawnId, respawnTime);
1230 }
1231}
void SaveGORespawnTime(ObjectGuid::LowType dbGuid, time_t &respawnTime)
Definition Map.cpp:2426
bool dbData
Definition GameObjectData.h:714

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

◆ SaveStateToDB()

void GameObject::SaveStateToDB ( )
2565{
2567 {
2568 if (InstanceScript* instance = GetInstanceScript())
2569 {
2570 GOState param = GetGoState();
2571 instance->StoreGameObjectState(GetSpawnId(), GameobjectStateToInt(&param));
2572
2574 stmt->SetData(0, GetInstanceId());
2575 stmt->SetData(1, GetSpawnId());
2576 stmt->SetData(2, GameobjectStateToInt(&param));
2577 CharacterDatabase.Execute(stmt);
2578 }
2579 }
2580}
@ CHAR_INSERT_INSTANCE_SAVED_DATA
Definition CharacterDatabase.h:527
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
uint8 GameobjectStateToInt(GOState *state) const
Definition GameObject.cpp:2539
uint32 GetInstanceId() const
Definition Object.h:510

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

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

Referenced by SaveToDB().

◆ SaveToDB() [2/2]

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

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_localRotation, m_respawnDelayTime, m_spawnedByDefault, m_spawnId, GameObjectData::mapid, GameObjectData::orientation, GameObjectData::phaseMask, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, GameObjectData::rotation, PreparedStatementBase::SetData(), sObjectMgr, GameObjectData::spawnMask, GameObjectData::spawntimesecs, sScriptMgr, WORLD_DEL_GAMEOBJECT, WORLD_INS_GAMEOBJECT, WORLD_INS_GAMEOBJECT_ADDON, and WorldDatabase.

◆ SendCustomAnim()

void GameObject::SendCustomAnim ( uint32  anim)
2143{
2145 data << GetGUID();
2146 data << uint32(anim);
2147 SendMessageToSet(&data, true);
2148}
virtual void SendMessageToSet(WorldPacket const *data, bool self) const
Definition Object.cpp:2090
@ 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::brann_bronzebeardAI::SwitchHeadVisaul(), Update(), go_suppression_device::go_suppression_deviceAI::UpdateAI(), and Use().

◆ SetDestructibleBuildingModifyState()

void GameObject::SetDestructibleBuildingModifyState ( bool  allow)
inline

◆ SetDestructibleState()

void GameObject::SetDestructibleState ( GameObjectDestructibleState  state,
Player eventInvoker = nullptr,
bool  setHealth = false 
)
2333{
2334 // the user calling this must know he is already operating on destructible gameobject
2336
2337 switch (state)
2338 {
2342 if (setHealth)
2343 {
2345 SetGoAnimProgress(255);
2346 }
2347 EnableCollision(true);
2348 break;
2350 {
2352
2353 sScriptMgr->OnGameObjectDamaged(this, eventInvoker);
2354
2355 if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
2356 if (Battleground* bg = bgMap->GetBG())
2357 bg->EventPlayerDamagedGO(eventInvoker, this, m_goInfo->building.damagedEvent);
2358
2361
2364 if (modelData->DamagedDisplayId)
2365 modelId = modelData->DamagedDisplayId;
2366 SetDisplayId(modelId);
2367
2368 if (setHealth)
2369 {
2371 uint32 maxHealth = m_goValue.Building.MaxHealth;
2372 // in this case current health is 0 anyway so just prevent crashing here
2373 if (!maxHealth)
2374 maxHealth = 1;
2375 SetGoAnimProgress(m_goValue.Building.Health * 255 / maxHealth);
2376 }
2377 break;
2378 }
2380 {
2381 sScriptMgr->OnGameObjectDestroyed(this, eventInvoker);
2382
2384
2385 if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
2386 {
2387 if (Battleground* bg = bgMap->GetBG())
2388 {
2389 bg->EventPlayerDamagedGO(eventInvoker, this, m_goInfo->building.destroyedEvent);
2390 bg->DestroyGate(eventInvoker, this);
2391 }
2392 }
2393
2396
2399 if (modelData->DestroyedDisplayId)
2400 modelId = modelData->DestroyedDisplayId;
2401 SetDisplayId(modelId);
2402
2403 if (setHealth)
2404 {
2407 }
2408 EnableCollision(false);
2409 break;
2410 }
2412 {
2415
2416 uint32 modelId = m_goInfo->displayId;
2418 if (modelData->RebuildingDisplayId)
2419 modelId = modelData->RebuildingDisplayId;
2420 SetDisplayId(modelId);
2421
2422 // restores to full health
2423 if (setHealth)
2424 {
2426 SetGoAnimProgress(255);
2427 }
2428 EnableCollision(true);
2429 break;
2430 }
2431 }
2432}
DBCStorage< DestructibleModelDataEntry > sDestructibleModelDataStore(DestructibleModelDatafmt)
@ GO_DESTRUCTIBLE_REBUILDING
Definition SharedDefines.h:1641
Definition Map.h:680
void RemoveGameObjectFlag(GameObjectFlags flags)
Definition GameObject.h:218
void EventInform(uint32 eventId)
Definition GameObject.cpp:2177
Definition DBCStructure.h:843
uint32 destructibleData
Definition GameObjectData.h:369
uint32 rebuildingEvent
Definition GameObjectData.h:370
uint32 destroyedEvent
Definition GameObjectData.h:365
uint32 damagedDisplayId
Definition GameObjectData.h:355
uint32 destroyedDisplayId
Definition GameObjectData.h:361
uint32 damagedEvent
Definition GameObjectData.h:360

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_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
217{ SetFlag(GAMEOBJECT_FLAGS, flags); }
void SetFlag(uint16 index, uint32 newFlag)
Definition Object.cpp:834

References GAMEOBJECT_FLAGS, and Object::SetFlag().

Referenced by go_suppression_device::go_suppression_deviceAI::Deactivate(), go_chromaggus_lever::go_chromaggus_leverAI::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_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_palehoof_sphere::OnGossipHello(), go_vh_activation_crystal::OnGossipHello(), go_main_chambers_access_panel::OnGossipHello(), SetDestructibleState(), SwitchDoorOrButton(), and Use().

◆ SetGoAnimProgress()

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

References GAMEOBJECT_BYTES_1, and Object::SetByteValue().

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

◆ SetGoArtKit() [1/2]

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

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
1433{
1434 const GameObjectData* data = nullptr;
1435 if (go)
1436 {
1437 go->SetGoArtKit(artkit);
1438 data = go->GetGameObjectData();
1439 }
1440 else if (lowguid)
1441 data = sObjectMgr->GetGameObjectData(lowguid);
1442
1443 if (data)
1444 const_cast<GameObjectData*>(data)->artKit = artkit;
1445}

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

◆ SetGoState()

void GameObject::SetGoState ( GOState  state)
2470{
2472
2473 sScriptMgr->OnGameObjectStateChanged(this, state);
2474
2475 if (m_model)
2476 {
2477 if (!IsInWorld())
2478 return;
2479
2480 // pussywizard: this startOpen is unneeded here, collision depends entirely on current GOState
2482 // pussywizard: commented out everything below
2483
2484 // startOpen determines whether we are going to add or remove the LoS on activation
2485 /*bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
2486
2487 if (GetGameObjectData() && GetGameObjectData()->go_state == GO_STATE_READY)
2488 startOpen = !startOpen;
2489
2490 if (state == GO_STATE_ACTIVE || state == GO_STATE_ACTIVE_ALTERNATIVE)
2491 EnableCollision(startOpen);
2492 else if (state == GO_STATE_READY)
2493 EnableCollision(!startOpen);*/
2494 }
2495 /* Whenever a gameobject inside an instance changes
2496 * save it's state on the database to be loaded properly
2497 * on server restart or crash.
2498 */
2500 {
2501 SaveStateToDB();
2502 }
2503}
bool IsAllowedToSaveToDB() const
Definition GameObject.h:355
void SaveStateToDB()
Definition GameObject.cpp:2564

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::go_suppression_deviceAI::Activate(), instance_naxxramas::ActivateWingPortal(), boss_thorim::boss_thorimAI::CloseDoors(), Create(), StaticTransport::Create(), MotionTransport::CreateMoTrans(), boss_thorim::boss_thorimAI::DamageTaken(), go_suppression_device::go_suppression_deviceAI::Deactivate(), Delete(), DespawnOrUnsummon(), go_chromaggus_lever::go_chromaggus_leverAI::GossipHello(), InstanceScript::HandleGameObject(), 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::brann_bronzebeardAI::SwitchHeadVisaul(), boss_flame_leviathan::boss_flame_leviathanAI::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
260{ m_linkedTrap = linkedTrap->GetGUID(); }

References Object::GetGUID(), and m_linkedTrap.

Referenced by Create().

◆ SetLocalRotation()

void GameObject::SetLocalRotation ( G3D::Quat const &  rot)
2226{
2227 G3D::Quat rotation;
2228 // Temporary solution for gameobjects that have no rotation data in DB:
2229 if (G3D::fuzzyEq(rot.z, 0.f) && G3D::fuzzyEq(rot.w, 0.f))
2230 rotation = G3D::Quat::fromAxisAngleRotation(G3D::Vector3::unitZ(), GetOrientation());
2231 else
2232 rotation = rot;
2233
2234 rotation.unitize();
2235 m_localRotation = rotation;
2237}
void UpdatePackedRotation()
Definition GameObject.cpp:2212

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

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

◆ SetLocalRotationAngles()

void GameObject::SetLocalRotationAngles ( float  z_rot,
float  y_rot,
float  x_rot 
)
2248{
2249 SetLocalRotation(G3D::Quat(G3D::Matrix3::fromEulerAnglesZYX(z_rot, y_rot, x_rot)));
2250}

References SetLocalRotation().

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

◆ SetLootGenerationTime()

void GameObject::SetLootGenerationTime ( )
2925{
2927}

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)
2639{
2640 // set the player whose group should receive the right
2641 // to loot the creature after it dies
2642 // should be set to nullptr after the loot disappears
2643 if (!creature)
2644 {
2648 return;
2649 }
2650
2654}
ObjectGuid GetLootRecipientGUID() const
Definition Creature.h:230
ObjectGuid::LowType GetLootRecipientGroupGUID() const
Definition Creature.h:232
void Clear()
Definition ObjectGuid.h:138
void ResetAllowedLooters()
Definition Object.cpp:3114
void SetAllowedLooters(GuidUnorderedSet const looters)
Definition Object.cpp:3109
GuidUnorderedSet const & GetAllowedLooters() const
Definition Object.cpp:3129

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

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

◆ SetLootRecipient() [2/2]

void GameObject::SetLootRecipient ( Map map)
2657{
2658 Group* group = nullptr;
2659 Map::PlayerList const& PlayerList = map->GetPlayers();
2660 for (Map::PlayerList::const_iterator i = PlayerList.begin(); i != PlayerList.end(); ++i)
2661 {
2662 if (Player* groupMember = i->GetSource())
2663 {
2664 if (groupMember->IsGameMaster() || groupMember->IsSpectator())
2665 {
2666 continue;
2667 }
2668
2669 if (!m_lootRecipient)
2670 {
2671 m_lootRecipient = groupMember->GetGUID();
2672 }
2673
2674 Group* memberGroup = groupMember->GetGroup();
2675 if (memberGroup && !group)
2676 {
2677 group = memberGroup;
2679 }
2680
2681 if (memberGroup == group)
2682 {
2683 AddAllowedLooter(groupMember->GetGUID());
2684 }
2685 }
2686 }
2687
2688 if (!group)
2689 {
2691 }
2692}
ObjectGuid GetGUID() const
Definition Group.cpp:2316
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:326
LowType GetCounter() const
Definition ObjectGuid.h:145
void AddAllowedLooter(ObjectGuid guid)
Definition Object.cpp:3104

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 
)
2435{
2436 m_lootState = state;
2437
2438 if (unit)
2439 _lootStateUnitGUID = unit->GetGUID();
2440 else
2442
2443 AI()->OnStateChanged(state, unit);
2444 sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
2445
2446 // Start restock timer if the chest is partially looted or not looted at all
2447 if (GetGoType() == GAMEOBJECT_TYPE_CHEST && state == GO_ACTIVATED && GetGOInfo()->chest.chestRestockTime > 0 && m_restockTime == 0s)
2448 {
2450 }
2451
2452 // 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
2453 /*if (m_model)
2454 {
2455 // startOpen determines whether we are going to add or remove the LoS on activation
2456 bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
2457
2458 // Use the current go state
2459 if (GetGoState() == GO_STATE_ACTIVE)
2460 startOpen = !startOpen;
2461
2462 if (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED)
2463 EnableCollision(startOpen);
2464 else if (state == GO_READY)
2465 EnableCollision(!startOpen);
2466 }*/
2467}
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:407
uint32 chestRestockTime
Definition GameObjectData.h:85

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::go_suppression_deviceAI::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_ulduar::instance_ulduar_InstanceMapScript::OnGameObjectCreate(), instance_oculus::instance_oculus_InstanceMapScript::OnGameObjectCreate(), go_massive_seaforium_charge::OnGossipHello(), go_ulduar_working_harpoon::OnGossipHello(), go_suppression_device::OnLootStateChanged(), SmartScript::ProcessAction(), go_direbrew_mole_machine::go_direbrew_mole_machineAI::Reset(), ResetDoorOrButton(), Map::ScriptsProcess(), Player::SendLoot(), boss_flame_leviathan::boss_flame_leviathanAI::TurnHealStations(), Update(), Use(), and UseDoorOrButton().

◆ SetOwnerGUID()

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

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(), Unit::RemoveGameObject(), and Use().

◆ SetPhaseMask()

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

Reimplemented from WorldObject.

2589{
2590 WorldObject::SetPhaseMask(newPhaseMask, update);
2591
2592 if (m_model && m_model->isEnabled())
2593 EnableCollision(true);
2594}
bool isEnabled() const
Definition GameObjectModel.h:69
virtual void SetPhaseMask(uint32 newPhaseMask, bool update)
Definition Object.cpp:2891

References EnableCollision(), GameObjectModel::isEnabled(), m_model, and WorldObject::SetPhaseMask().

Referenced by Create(), StaticTransport::Create(), instance_blackwing_lair::instance_blackwing_lair_InstanceMapScript::OnGameObjectCreate(), and instance_halls_of_reflection::instance_halls_of_reflection_InstanceMapScript::OnGameObjectCreate().

◆ SetPosition() [1/2]

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

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

Referenced by SetPosition().

◆ SetPosition() [2/2]

void GameObject::SetPosition ( float  x,
float  y,
float  z,
float  o 
)
2855{
2856 // pussywizard: do not call for MotionTransport and other gobjects not in grid
2857
2858 if (!Acore::IsValidMapCoord(x, y, z, o))
2859 return;
2860
2861 GetMap()->GameObjectRelocation(this, x, y, z, o);
2862}
void GameObjectRelocation(GameObject *go, float x, float y, float z, float o)
Definition Map.cpp:828
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().

◆ SetRespawnDelay()

void GameObject::SetRespawnDelay ( int32  respawn)
1295{
1296 m_respawnDelayTime = respawn > 0 ? respawn : 0;
1297}

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 
)
2240{
2245}
@ GAMEOBJECT_PARENTROTATION
Definition UpdateFields.h:400
void SetFloatValue(uint16 index, float value)
Definition Object.cpp:726

References GAMEOBJECT_PARENTROTATION, and Object::SetFloatValue().

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

◆ SwitchDoorOrButton()

void GameObject::SwitchDoorOrButton ( bool  activate,
bool  alternative = false 
)
private
1448{
1449 if (activate)
1451 else
1453
1454 if (GetGoState() == GO_STATE_READY) //if closed -> open
1456 else //if open -> close
1458}
@ GO_FLAG_IN_USE
Definition SharedDefines.h:1614

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

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

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(), 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
2612{
2613 if (!IsInWorld())
2614 return;
2615 if (m_model)
2616 if (GetMap()->ContainsGameObjectModel(*m_model))
2618 delete m_model;
2619 m_model = CreateModel();
2620 if (m_model)
2622}

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
2213{
2214 static const int32 PACK_YZ = 1 << 20;
2215 static const int32 PACK_X = PACK_YZ << 1;
2216 static const int32 PACK_YZ_MASK = (PACK_YZ << 1) - 1;
2217 static const int32 PACK_X_MASK = (PACK_X << 1) - 1;
2218 int8 w_sign = (m_localRotation.w >= 0.f ? 1 : -1);
2219 int64 x = int32(m_localRotation.x * PACK_X) * w_sign & PACK_X_MASK;
2220 int64 y = int32(m_localRotation.y * PACK_YZ) * w_sign & PACK_YZ_MASK;
2221 int64 z = int32(m_localRotation.z * PACK_YZ) * w_sign & PACK_YZ_MASK;
2222 m_packedRotation = z | (y << 21) | (x << 42);
2223}
std::int8_t int8
Definition Define.h:105
std::int64_t int64
Definition Define.h:102

References m_localRotation, and m_packedRotation.

Referenced by SetLocalRotation().

◆ Use()

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

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(), 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(), RemoveFromOwner(), GameObjectTemplate::reqParticipants, Map::ScriptsStart(), Player::SendCinematicStart(), SendCustomAnim(), Player::SendDirectMessage(), Player::SendLoot(), Player::SendPreparedGossip(), SetGameObjectFlag(), SetGoState(), SetLootState(), SetOwnerGUID(), 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, 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_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
2525{
2526 switch (m_goInfo->type)
2527 {
2533 return true;
2534 default:
2535 return false;
2536 }
2537}
@ GAMEOBJECT_TYPE_TRAPDOOR
Definition SharedDefines.h:1606

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

◆ ChairListSlots

ChairSlotAndUser GameObject::ChairListSlots
protected

Referenced by Use().

◆ gameObjectToEventFlag

std::unordered_map< int, goEventFlag > GameObject::gameObjectToEventFlag = { }
static
2978{
2979 //11 GAMEOBJECT_TYPE_TRANSPORT
2980 struct
2981 {
2982 uint32 PathProgress;
2983 TransportAnimation const* AnimationInfo;
2984 } Transport;
2985 //25 GAMEOBJECT_TYPE_FISHINGHOLE
2986 struct
2987 {
2988 uint32 MaxOpens;
2989 } FishingHole;
2990 //29 GAMEOBJECT_TYPE_CAPTURE_POINT
2991 struct
2992 {
2993 OPvPCapturePoint* OPvPObj;
2994 } CapturePoint;
2995 //33 GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING
2996 struct
2997 {
2998 uint32 Health;
2999 uint32 MaxHealth;
3000 } Building;
3001};
3002
3003enum class GameObjectActions : uint32
3004{
3005 // Name from client executable // Comments
3006 None, // -NONE-
3007 AnimateCustom0, // Animate Custom0
3008 AnimateCustom1, // Animate Custom1
3009 AnimateCustom2, // Animate Custom2
3010 AnimateCustom3, // Animate Custom3
3011 Disturb, // Disturb // Triggers trap
3012 Unlock, // Unlock // Resets GO_FLAG_LOCKED
3013 Lock, // Lock // Sets GO_FLAG_LOCKED
3014 Open, // Open // Sets GO_STATE_ACTIVE
3015 OpenAndUnlock, // Open + Unlock // Sets GO_STATE_ACTIVE and resets GO_FLAG_LOCKED
3016 Close, // Close // Sets GO_STATE_READY
3017 ToggleOpen, // Toggle Open
3018 Destroy, // Destroy // Sets GO_STATE_DESTROYED
3019 Rebuild, // Rebuild // Resets from GO_STATE_DESTROYED
3020 Creation, // Creation
3021 Despawn, // Despawn
3022 MakeInert, // Make Inert // Disables interactions
3023 MakeActive, // Make Active // Enables interactions
3024 CloseAndLock, // Close + Lock // Sets GO_STATE_READY and sets GO_FLAG_LOCKED
3025 UseArtKit0, // Use ArtKit0 // 46904: 121
3026 UseArtKit1, // Use ArtKit1 // 36639: 81, 46903: 122
3027 UseArtKit2, // Use ArtKit2
3028 UseArtKit3, // Use ArtKit3
3029 SetTapList, // Set Tap List
3030};
3031
3032// For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ...
3033// For bobber: GO_NOT_READY ->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-><deleted>
3034// For door(closed):[GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY(close) -> ...
3035// For door(open): [GO_NOT_READY]->GO_READY (open) ->GO_ACTIVATED (close)->GO_JUST_DEACTIVATED->GO_READY(open) -> ...
3036enum LootState
3037{
3039 GO_READY, // can be ready but despawned, and then not possible activate until spawn
3042};
3043
3044// 5 sec for bobber catch
3045#define FISHING_BOBBER_READY_TIME 5
3046
3047class GameObject : public WorldObject, public GridObject<GameObject>, public MovableMapObject, public UpdatableMapObject
3048{
3049public:
3050 explicit GameObject();
3051 ~GameObject() override;
3052
3053 void BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target) override;
3054
3055 void AddToWorld() override;
3056 void RemoveFromWorld() override;
3057 void CleanupsBeforeDelete(bool finalCleanup = true) override;
3058
3059 uint32 GetDynamicFlags() const override { return GetUInt32Value(GAMEOBJECT_DYNAMIC); }
3060 void ReplaceAllDynamicFlags(uint32 flag) override { SetUInt32Value(GAMEOBJECT_DYNAMIC, flag); }
3061
3062 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);
3063 void Update(uint32 p_time) override;
3064 [[nodiscard]] GameObjectTemplate const* GetGOInfo() const { return m_goInfo; }
3065 [[nodiscard]] GameObjectTemplateAddon const* GetTemplateAddon() const;
3066 [[nodiscard]] GameObjectData const* GetGameObjectData() const { return m_goData; }
3067 [[nodiscard]] GameObjectValue const* GetGOValue() const { return &m_goValue; }
3068
3069 [[nodiscard]] bool IsTransport() const;
3070 [[nodiscard]] bool IsDestructibleBuilding() const;
3071
3072 [[nodiscard]] ObjectGuid::LowType GetSpawnId() const { return m_spawnId; }
3073
3074 // z_rot, y_rot, x_rot - rotation angles around z, y and x axes
3075 void SetLocalRotationAngles(float z_rot, float y_rot, float x_rot);
3076 void SetLocalRotation(G3D::Quat const& rot);
3077 void SetTransportPathRotation(float qx, float qy, float qz, float qw);
3078 [[nodiscard]] G3D::Quat const& GetLocalRotation() const { return m_localRotation; }
3079 [[nodiscard]] int64 GetPackedLocalRotation() const { return m_packedRotation; }
3080 [[nodiscard]] G3D::Quat GetWorldRotation() const;
3081
3082 // overwrite WorldObject function for proper name localization
3083 [[nodiscard]] std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override;
3084
3085 void SaveToDB(bool saveAddon = false);
3086 void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask, bool saveAddon = false);
3087 virtual bool LoadFromDB(ObjectGuid::LowType guid, Map* map) { return LoadGameObjectFromDB(guid, map, false); }
3088 virtual bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map* map, bool addToMap = true);
3089 void DeleteFromDB();
3090
3091 void SetOwnerGUID(ObjectGuid owner)
3092 {
3093 // Owner already found and different than expected owner - remove object from old owner
3094 if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
3095 {
3096 ABORT();
3097 }
3098 m_spawnedByDefault = false; // all object with owner is despawned after delay
3100 }
3101 [[nodiscard]] ObjectGuid GetOwnerGUID() const { return GetGuidValue(OBJECT_FIELD_CREATED_BY); }
3102 [[nodiscard]] Unit* GetOwner() const;
3103
3104 void SetSpellId(uint32 id)
3105 {
3106 m_spawnedByDefault = false; // all summoned object is despawned after delay
3107 m_spellId = id;
3108 }
3109 [[nodiscard]] uint32 GetSpellId() const { return m_spellId;}
3110
3111 [[nodiscard]] time_t GetRespawnTime() const { return m_respawnTime; }
3112 [[nodiscard]] time_t GetRespawnTimeEx() const;
3113
3114 void SetRespawnTime(int32 respawn);
3115 void SetRespawnDelay(int32 respawn);
3116 void Respawn();
3117 [[nodiscard]] bool isSpawned() const
3118 {
3119 return m_respawnDelayTime == 0 ||
3122 }
3123 [[nodiscard]] bool isSpawnedByDefault() const { return m_spawnedByDefault; }
3124 void SetSpawnedByDefault(bool b) { m_spawnedByDefault = b; }
3125 [[nodiscard]] uint32 GetRespawnDelay() const { return m_respawnDelayTime; }
3126 void Refresh();
3127 void DespawnOrUnsummon(Milliseconds delay = 0ms, Seconds forcedRespawnTime = 0s);
3128 void Delete();
3129 void GetFishLoot(Loot* fishLoot, Player* lootOwner, bool junk = false);
3130 [[nodiscard]] GameobjectTypes GetGoType() const { return GameobjectTypes(GetByteValue(GAMEOBJECT_BYTES_1, 1)); }
3132 [[nodiscard]] GOState GetGoState() const { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
3133 void SetGoState(GOState state);
3134 [[nodiscard]] uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
3135 void SetGoArtKit(uint8 artkit);
3136 [[nodiscard]] uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
3137 void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
3138 static void SetGoArtKit(uint8 artkit, GameObject* go, ObjectGuid::LowType lowguid = 0);
3139
3140 void SetPhaseMask(uint32 newPhaseMask, bool update) override;
3141 void EnableCollision(bool enable);
3142
3144 bool HasGameObjectFlag(GameObjectFlags flags) const { return HasFlag(GAMEOBJECT_FLAGS, flags) != 0; }
3148
3149 void Use(Unit* user);
3150
3151 [[nodiscard]] LootState getLootState() const { return m_lootState; }
3152 // Note: unit is only used when s = GO_ACTIVATED
3153 void SetLootState(LootState s, Unit* unit = nullptr);
3154
3155 [[nodiscard]] uint16 GetLootMode() const { return m_LootMode; }
3156 [[nodiscard]] bool HasLootMode(uint16 lootMode) const { return m_LootMode & lootMode; }
3157 void SetLootMode(uint16 lootMode) { m_LootMode = lootMode; }
3158 void AddLootMode(uint16 lootMode) { m_LootMode |= lootMode; }
3159 void RemoveLootMode(uint16 lootMode) { m_LootMode &= ~lootMode; }
3161
3162 void AddToSkillupList(ObjectGuid const& playerGuid);
3163 [[nodiscard]] bool IsInSkillupList(ObjectGuid const& playerGuid) const;
3164
3165 void AddUniqueUse(Player* player);
3166 void AddUse() { ++m_usetimes; }
3167
3168 [[nodiscard]] uint32 GetUseCount() const { return m_usetimes; }
3169 [[nodiscard]] uint32 GetUniqueUseCount() const { return m_unique_users.size(); }
3170
3171 void SaveRespawnTime() override { SaveRespawnTime(0); }
3172 void SaveRespawnTime(uint32 forceDelay);
3173
3174 Loot loot;
3175
3176 [[nodiscard]] Player* GetLootRecipient() const;
3177 [[nodiscard]] Group* GetLootRecipientGroup() const;
3178 void SetLootRecipient(Creature* creature);
3179 void SetLootRecipient(Map* map);
3180 bool IsLootAllowedFor(Player const* player) const;
3181 [[nodiscard]] bool HasLootRecipient() const { return m_lootRecipient || m_lootRecipientGroup; }
3182 uint32 m_groupLootTimer; // (msecs)timer used for group loot
3183 uint32 lootingGroupLowGUID; // used to find group which is looting
3184 void SetLootGenerationTime();
3185 [[nodiscard]] uint32 GetLootGenerationTime() const { return m_lootGenerationTime; }
3186
3187 [[nodiscard]] GameObject* GetLinkedTrap();
3188 void SetLinkedTrap(GameObject* linkedTrap) { m_linkedTrap = linkedTrap->GetGUID(); }
3189
3190 [[nodiscard]] bool hasQuest(uint32 quest_id) const override;
3191 [[nodiscard]] bool hasInvolvedQuest(uint32 quest_id) const override;
3192 bool ActivateToQuest(Player* target) const;
3193 void UseDoorOrButton(uint32 time_to_restore = 0, bool alternative = false, Unit* user = nullptr);
3194 // 0 = use `gameobject`.`spawntimesecs`
3195 void ResetDoorOrButton();
3196
3197 void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target);
3198
3199 [[nodiscard]] bool IsNeverVisible() const override;
3200 bool IsAlwaysVisibleFor(WorldObject const* seer) const override;
3201 [[nodiscard]] bool IsInvisibleDueToDespawn() const override;
3202
3203 uint8 getLevelForTarget(WorldObject const* target) const override
3204 {
3205 if (Unit* owner = GetOwner())
3206 return owner->getLevelForTarget(target);
3207
3208 return 1;
3209 }
3210
3211 GameObject* LookupFishingHoleAround(float range);
3212
3213 void CastSpell(Unit* target, uint32 spell);
3214 void SendCustomAnim(uint32 anim);
3215 [[nodiscard]] bool IsInRange(float x, float y, float z, float radius) const;
3216
3217 void ModifyHealth(int32 change, Unit* attackerOrHealer = nullptr, uint32 spellId = 0);
3219 // sets GameObject type 33 destruction flags and optionally default health for that state
3220 void SetDestructibleState(GameObjectDestructibleState state, Player* eventInvoker = nullptr, bool setHealth = false);
3222 {
3228 }
3229
3230 void EventInform(uint32 eventId);
3231
3232 [[nodiscard]] virtual uint32 GetScriptId() const;
3233 [[nodiscard]] GameObjectAI* AI() const { return m_AI; }
3234
3235 [[nodiscard]] std::string const& GetAIName() const;
3236 void SetDisplayId(uint32 displayid);
3237 [[nodiscard]] uint32 GetDisplayId() const { return GetUInt32Value(GAMEOBJECT_DISPLAYID); }
3238
3240 void GetRespawnPosition(float& x, float& y, float& z, float* ori = nullptr) const;
3241
3242 void SetPosition(float x, float y, float z, float o);
3243 void SetPosition(const Position& pos) { SetPosition(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()); }
3244
3245 [[nodiscard]] bool IsStaticTransport() const { return GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT; }
3246 [[nodiscard]] bool IsMotionTransport() const { return GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT; }
3247
3248 Transport* ToTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT || GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<Transport*>(this); else return nullptr; }
3249 [[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; }
3250
3251 StaticTransport* ToStaticTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<StaticTransport*>(this); else return nullptr; }
3252 [[nodiscard]] StaticTransport const* ToStaticTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<StaticTransport const*>(this); else return nullptr; }
3253
3254 MotionTransport* ToMotionTransport() { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<MotionTransport*>(this); else return nullptr; }
3255 [[nodiscard]] MotionTransport const* ToMotionTransport() const { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MO_TRANSPORT) return reinterpret_cast<MotionTransport const*>(this); else return nullptr; }
3256
3257 [[nodiscard]] float GetStationaryX() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionX(); return GetPositionX(); }
3258 [[nodiscard]] float GetStationaryY() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionY(); return GetPositionY(); }
3259 [[nodiscard]] float GetStationaryZ() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetPositionZ(); return GetPositionZ(); }
3260 [[nodiscard]] float GetStationaryO() const override { if (GetGOInfo()->type != GAMEOBJECT_TYPE_MO_TRANSPORT) return m_stationaryPosition.GetOrientation(); return GetOrientation(); }
3261
3262 [[nodiscard]] float GetInteractionDistance() const;
3263
3264 void UpdateModelPosition();
3265
3266 [[nodiscard]] bool IsAtInteractDistance(Position const& pos, float radius) const;
3267 [[nodiscard]] bool IsAtInteractDistance(Player const* player, SpellInfo const* spell = nullptr) const;
3268
3269 [[nodiscard]] bool IsWithinDistInMap(Player const* player) const;
3271
3272 [[nodiscard]] SpellInfo const* GetSpellForLock(Player const* player) const;
3273
3274 static std::unordered_map<int, goEventFlag> gameObjectToEventFlag; // Gameobject -> event flag
3275
3276 [[nodiscard]] bool ValidateGameobjectType() const;
3277 [[nodiscard]] bool IsInstanceGameobject() const;
3278 [[nodiscard]] uint8 GameobjectStateToInt(GOState* state) const;
3279
3280 /* A check to verify if this object is available to be saved on the DB when
3281 * a state change occurs
3282 */
3283 [[nodiscard]] bool IsAllowedToSaveToDB() const { return m_saveStateOnDb; };
3284
3285 /* Enable or Disable the ability to save on the database this gameobject's state
3286 * whenever it changes
3287 */
3288 void AllowSaveToDB(bool enable) { m_saveStateOnDb = enable; };
3289
3290 void SaveStateToDB();
3291
3292 std::string GetDebugInfo() const override;
3293
3294 bool IsUpdateNeeded() override;
3295protected:
3296 bool AIM_Initialize();
3298 void UpdateModel(); // updates model in case displayId were changed
3300 time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()),
3301 uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer
3303 Seconds m_despawnRespawnTime; // override respawn time after delayed despawn
3306 bool m_spawnedByDefault;
3307 uint32 m_cooldownTime; // used as internal reaction delay time store (not state change reaction).
3308 // For traps this: spell casting cooldown, for doors/buttons: reset time.
3309 std::unordered_map<ObjectGuid, int32> m_SkillupList;
3310
3311 ObjectGuid m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
3314
3315 typedef std::map<uint32, ObjectGuid> ChairSlotAndUser;
3317
3320 GameObjectData const* m_goData;
3323
3325 G3D::Quat m_localRotation;
3327
3330 uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
3332
3334
3336
3337private:
3338 void CheckRitualList();
3339 void ClearRitualList();
3340 void RemoveFromOwner();
3341 void SwitchDoorOrButton(bool activate, bool alternative = false);
3342 void UpdatePackedRotation();
3343
3345 bool _IsWithinDist(WorldObject const* obj, float dist2compare, bool /*is3D*/, bool /*incOwnRadius = true*/, bool /*incTargetRadius = true*/) const override
3346 {
3348 dist2compare += obj->GetObjectSize();
3349 return IsInRange(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare);
3350 }
3352
3353 bool m_saveStateOnDb = false;
3354};
3355#endif
LocaleConstant
Definition Common.h:117
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:253
Definition GameObjectAI.h:33
Definition GameObjectModel.h:53
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr) const
Definition GameObject.cpp:2832
uint32 GetRespawnDelay() const
Definition GameObject.h:197
bool IsWithinDistInMap(Player const *player) const
Definition GameObject.cpp:2995
void AddLootMode(uint16 lootMode)
Definition GameObject.h:230
~GameObject() override
Definition GameObject.cpp:77
bool IsUpdateNeeded() override
Definition GameObject.cpp:3088
void DeleteFromDB()
Definition GameObject.cpp:1168
std::string GetDebugInfo() const override
Definition GameObject.cpp:3079
bool hasInvolvedQuest(uint32 quest_id) const override
Definition GameObject.cpp:1196
float GetStationaryZ() const override
Definition GameObject.h:331
uint32 GetDynamicFlags() const override
Definition GameObject.h:131
uint8 getLevelForTarget(WorldObject const *target) const override
Definition GameObject.h:275
float GetStationaryY() const override
Definition GameObject.h:330
void GetFishLoot(Loot *fishLoot, Player *lootOwner, bool junk=false)
Definition GameObject.cpp:1001
bool HasLootMode(uint16 lootMode) const
Definition GameObject.h:228
GameObjectValue const * GetGOValue() const
Definition GameObject.h:139
Player * GetLootRecipient() const
Definition GameObject.cpp:2624
bool IsAlwaysVisibleFor(WorldObject const *seer) const override
Definition GameObject.cpp:1244
time_t GetRespawnTime() const
Definition GameObject.h:183
uint32 GetLootGenerationTime() const
Definition GameObject.h:257
float GetStationaryX() const override
Definition GameObject.h:329
void RemoveLootMode(uint16 lootMode)
Definition GameObject.h:231
void SetSpawnedByDefault(bool b)
Definition GameObject.h:196
bool IsInSkillupList(ObjectGuid const &playerGuid) const
Definition GameObject.cpp:3066
void SetLootRecipient(Creature *creature)
Definition GameObject.cpp:2638
void SetDestructibleBuildingModifyState(bool allow)
Definition GameObject.h:290
bool IsMotionTransport() const
Definition GameObject.h:318
void Respawn()
Definition GameObject.cpp:1299
void Refresh()
Definition GameObject.cpp:916
time_t GetRespawnTimeEx() const
Definition GameObject.cpp:2915
bool hasQuest(uint32 quest_id) const override
Definition GameObject.cpp:1185
GameObjectFlags GetGameObjectFlags() const
Definition GameObject.h:215
uint32 GetDisplayId() const
Definition GameObject.h:309
int64 GetPackedLocalRotation() const
Definition GameObject.h:151
void UpdateModelPosition()
Definition GameObject.cpp:2902
bool IsStaticTransport() const
Definition GameObject.h:317
void SetLootMode(uint16 lootMode)
Definition GameObject.h:229
uint32 GetUseCount() const
Definition GameObject.h:240
void SetLootGenerationTime()
Definition GameObject.cpp:2924
std::map< uint32, ObjectGuid > ChairSlotAndUser
Definition GameObject.h:387
bool IsNeverVisible() const override
Definition GameObject.cpp:1233
virtual bool LoadFromDB(ObjectGuid::LowType guid, Map *map)
Definition GameObject.h:159
std::string const & GetNameForLocaleIdx(LocaleConstant locale_idx) const override
Definition GameObject.cpp:2199
void BuildValuesUpdate(uint8 updateType, ByteBuffer *data, Player *target) override
Definition GameObject.cpp:2732
void AddToSkillupList(ObjectGuid const &playerGuid)
Definition GameObject.cpp:3060
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition GameObject.cpp:104
uint16 GetLootMode() const
Definition GameObject.h:227
bool IsInvisibleDueToDespawn() const override
Definition GameObject.cpp:1272
void AddToWorld() override
Definition GameObject.cpp:140
void Update(uint32 p_time) override
Definition GameObject.cpp:443
float GetStationaryO() const override
Definition GameObject.h:332
void ModifyHealth(int32 change, Unit *attackerOrHealer=nullptr, uint32 spellId=0)
Definition GameObject.cpp:2269
void AllowSaveToDB(bool enable)
Definition GameObject.h:360
void ReplaceAllDynamicFlags(uint32 flag) override
Definition GameObject.h:132
Definition Object.h:359
Definition Map.h:163
Definition Object.h:411
Definition OutdoorPvP.h:91
uint32 LowType
Definition ObjectGuid.h:122
Definition Object.h:429
Definition Object.h:472
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1354
float GetObjectSize() const
Definition Object.cpp:2789
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_localRotation

G3D::Quat GameObject::m_localRotation
protected

◆ 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

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