TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
GameObject Class Reference

#include <GameObject.h>

Public Member Functions

 GameObject ()
 
 ~GameObject ()
 
void BuildValuesUpdate (uint8 updatetype, ByteBuffer *data, Player *target) const override
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void CleanupsBeforeDelete (bool finalCleanup=true) override
 
bool Create (ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
 
void Update (uint32 p_time) override
 
GameObjectTemplate constGetGOInfo () const
 
GameObjectData constGetGOData () const
 
GameObjectValue constGetGOValue () const
 
bool IsTransport () const
 
bool IsDynTransport () const
 
bool IsDestructibleBuilding () const
 
ObjectGuid::LowType GetSpawnId () const
 
void UpdateRotationFields (float rotation2=0.0f, float rotation3=0.0f)
 
std::string constGetNameForLocaleIdx (LocaleConstant locale_idx) const override
 
void SaveToDB ()
 
void SaveToDB (uint32 mapid, uint32 spawnMask, uint32 phaseMask)
 
bool LoadFromDB (ObjectGuid::LowType spawnId, Map *map)
 
bool LoadGameObjectFromDB (ObjectGuid::LowType spawnId, 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 Respawn ()
 
bool isSpawned () const
 
bool isSpawnedByDefault () const
 
void SetSpawnedByDefault (bool b)
 
uint32 GetRespawnDelay () const
 
void Refresh ()
 
void Delete ()
 
void getFishLoot (Loot *loot, Player *loot_owner)
 
void getFishLootJunk (Loot *loot, Player *loot_owner)
 
GameobjectTypes GetGoType () const
 
void SetGoType (GameobjectTypes type)
 
GOState GetGoState () const
 
void SetGoState (GOState state)
 
virtual uint32 GetTransportPeriod () const
 
void SetTransportState (GOState state, uint32 stopFrame=0)
 
uint8 GetGoArtKit () const
 
void SetGoArtKit (uint8 artkit)
 
uint8 GetGoAnimProgress () const
 
void SetGoAnimProgress (uint8 animprogress)
 
bool SetInPhase (uint32 id, bool update, bool apply) override
 
void EnableCollision (bool enable)
 
void Use (Unit *user)
 
LootState getLootState () const
 
void SetLootState (LootState s, Unit *unit=NULL)
 
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 &PlayerGuidLow)
 
bool IsInSkillupList (ObjectGuid const &playerGuid) const
 
void ClearSkillupList ()
 
void AddUniqueUse (Player *player)
 
void AddUse ()
 
uint32 GetUseCount () const
 
uint32 GetUniqueUseCount () const
 
void SaveRespawnTime () override
 
PlayerGetLootRecipient () const
 
GroupGetLootRecipientGroup () const
 
void SetLootRecipient (Unit *unit)
 
bool IsLootAllowedFor (Player const *player) const
 
bool HasLootRecipient () const
 
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=NULL)
 
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, bool triggered=true)
 
void SendCustomAnim (uint32 anim)
 
bool IsInRange (float x, float y, float z, float radius) const
 
void ModifyHealth (int32 change, Unit *attackerOrHealer=NULL, uint32 spellId=0)
 
void SetDestructibleState (GameObjectDestructibleState state, Player *eventInvoker=NULL, bool setHealth=false)
 
GameObjectDestructibleState GetDestructibleState () const
 
void EventInform (uint32 eventId, WorldObject *invoker=NULL)
 
uint64 GetRotation () const
 
virtual uint32 GetScriptId () const
 
GameObjectAIAI () const
 
std::string GetAIName () const
 
void SetDisplayId (uint32 displayid)
 
uint32 GetDisplayId () const
 
uint32 GetFaction () const
 
void SetFaction (uint32 faction)
 
void GetRespawnPosition (float &x, float &y, float &z, float *ori=NULL) const
 
TransportToTransport ()
 
Transport constToTransport () const
 
float GetStationaryX () const override
 
float GetStationaryY () const override
 
float GetStationaryZ () const override
 
float GetStationaryO () const override
 
void RelocateStationaryPosition (float x, float y, float z, float o)
 
float GetInteractionDistance () const
 
void UpdateModelPosition ()
 
uint16 GetAIAnimKitId () const override
 
void SetAnimKitId (uint16 animKitId, bool oneshot)
 
- Public Member Functions inherited from WorldObject
virtual ~WorldObject ()
 
void GetNearPoint2D (float &x, float &y, float distance, float absAngle) const
 
void GetNearPoint (WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
 
void GetClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float angle=0) 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 dist, float angle)
 
Position GetRandomNearPosition (float radius)
 
void GetContactPoint (WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
float GetObjectSize () const
 
void UpdateGroundPositionZ (float x, float y, float &z) const
 
void UpdateAllowedPositionZ (float x, float y, float &z) const
 
void GetRandomPoint (Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
Position GetRandomPoint (Position const &srcPos, float distance) const
 
uint32 GetInstanceId () const
 
virtual void SetPhaseMask (uint32 newPhaseMask, bool update)
 
void CopyPhaseFrom (WorldObject *obj, bool update=false)
 
void UpdateAreaPhase ()
 
void ClearPhases (bool update=false)
 
void RebuildTerrainSwaps ()
 
void RebuildWorldMapAreaSwaps ()
 
bool HasInPhaseList (uint32 phase)
 
uint32 GetPhaseMask () const
 
bool IsInPhase (uint32 phase) const
 
bool IsInPhase (WorldObject const *obj) const
 
bool IsInTerrainSwap (uint32 terrainSwap) const
 
std::set< uint32 > constGetPhases () const
 
std::set< uint32 > constGetTerrainSwaps () const
 
std::set< uint32 > constGetWorldMapAreaSwaps () const
 
int32 GetDBPhase () const
 
void SetDBPhase (int32 p)
 
uint32 GetZoneId () const
 
uint32 GetAreaId () const
 
void GetZoneAndAreaId (uint32 &zoneid, uint32 &areaid) const
 
InstanceScriptGetInstanceScript ()
 
std::string constGetName () const
 
void SetName (std::string const &newname)
 
float GetDistance (WorldObject const *obj) const
 
float GetDistance (Position const &pos) const
 
float GetDistance (float x, float y, float z) const
 
float GetDistance2d (WorldObject const *obj) const
 
float GetDistance2d (float x, float y) const
 
float GetDistanceZ (WorldObject const *obj) const
 
bool IsSelfOrInSameMap (WorldObject const *obj) const
 
bool IsInMap (WorldObject const *obj) const
 
bool IsWithinDist3d (float x, float y, float z, float dist) const
 
bool IsWithinDist3d (Position const *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (Position const *pos, float dist) const
 
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true) const
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true) const
 
bool IsWithinLOS (float x, float y, float z) const
 
bool IsWithinLOSInMap (WorldObject const *obj) 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=float(M_PI)) const
 
bool isInBack (WorldObject const *target, float arc=float(M_PI)) const
 
bool IsInBetween (WorldObject const *obj1, WorldObject const *obj2, float size=0) const
 
virtual void SendMessageToSet (WorldPacket const *data, bool self)
 
virtual void SendMessageToSetInRange (WorldPacket const *data, float dist, bool self)
 
virtual void SendMessageToSet (WorldPacket const *data, Player const *skipped_rcvr)
 
void PlayDistanceSound (uint32 sound_id, Player *target=NULL)
 
void PlayDirectSound (uint32 sound_id, Player *target=NULL)
 
void SendObjectDeSpawnAnim (ObjectGuid guid)
 
void AddObjectToRemoveList ()
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
float GetSightRange (WorldObject const *target=NULL) const
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
Map constGetBaseMap () const
 
void SetZoneScript ()
 
ZoneScriptGetZoneScript () const
 
TempSummonSummonCreature (uint32 id, Position const &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0) const
 
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang=0, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0) const
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
 
CreatureSummonTrigger (float x, float y, float z, float ang, uint32 dur, CreatureAI *(*GetAI)(Creature *)=NULL)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=NULL)
 
CreatureFindNearestCreature (uint32 entry, float range, bool alive=true) const
 
GameObjectFindNearestGameObject (uint32 entry, float range) const
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &lList, uint32 uiEntry, float fMaxSearchRange) const
 
void GetPlayerListInGrid (std::list< Player * > &lList, float fMaxSearchRange) const
 
void DestroyForNearbyPlayers ()
 
virtual void UpdateObjectVisibility (bool forced=true)
 
void BuildUpdate (UpdateDataMapType &) override
 
void AddToObjectUpdate () override
 
void RemoveFromObjectUpdate () override
 
void AddToNotify (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)
 
void SetWorldObject (bool apply)
 
bool IsPermanentWorldObject () const
 
bool IsWorldObject () const
 
template<class NOTIFIER >
void VisitNearbyObject (float const &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyGridObject (float const &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyWorldObject (float const &radius, NOTIFIER &notifier) const
 
TransportGetTransport () const
 
float GetTransOffsetX () const
 
float GetTransOffsetY () const
 
float GetTransOffsetZ () const
 
float GetTransOffsetO () const
 
uint32 GetTransTime () const
 
int8 GetTransSeat () const
 
virtual ObjectGuid GetTransGUID () const
 
void SetTransport (Transport *t)
 
virtual uint16 GetMovementAnimKitId () const
 
virtual uint16 GetMeleeAnimKitId () const
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
bool IsInWorld () const
 
ObjectGuid constGetGUID () const
 
PackedGuid constGetPackGUID () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
virtual void SetObjectScale (float scale)
 
TypeID GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
 
virtual void DestroyForPlayer (Player *target) 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 constGetGuidValue (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 SetGuidValue (uint16 index, ObjectGuid const &value)
 
void SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddGuidValue (uint16 index, ObjectGuid const &value)
 
bool RemoveGuidValue (uint16 index, ObjectGuid const &value)
 
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModUInt16Value (uint16 index, uint8 offset, int16 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)
 
void ToggleByteFlag (uint16 index, uint8 offset, uint8 flag)
 
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)
 
std::vector< uint32 > constGetDynamicValues (uint16 index) const
 
void AddDynamicValue (uint16 index, uint32 value)
 
void RemoveDynamicValue (uint16 index, uint32 value)
 
void ClearDynamicValue (uint16 index)
 
void SetDynamicValue (uint16 index, uint8 offset, uint32 value)
 
void ClearUpdateMask (bool remove)
 
uint16 GetValuesCount () const
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
 
void SetFieldNotifyFlag (uint16 flag)
 
void RemoveFieldNotifyFlag (uint16 flag)
 
void ForceValuesUpdateAtIndex (uint32)
 
PlayerToPlayer ()
 
Player constToPlayer () const
 
CreatureToCreature ()
 
Creature constToCreature () const
 
UnitToUnit ()
 
Unit constToUnit () const
 
GameObjectToGameObject ()
 
GameObject constToGameObject () const
 
CorpseToCorpse ()
 
Corpse constToCorpse () const
 
DynamicObjectToDynObject ()
 
DynamicObject constToDynObject () const
 
AreaTriggerToAreaTrigger ()
 
AreaTrigger constToAreaTrigger () 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 (WorldLocation const &loc)
 
void WorldRelocate (WorldLocation const &loc)
 
void WorldRelocate (uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
WorldLocation GetWorldLocation () const
 
uint32 GetMapId () const
 
- Public Member Functions inherited from Position
 Position (float x=0, float y=0, float z=0, float o=0)
 
 Position (Position const &loc)
 
bool operator== (Position const &a)
 
bool operator!= (Position const &a)
 
void Relocate (float x, float y)
 
void Relocate (float x, float y, float z)
 
void Relocate (float x, float y, float z, float orientation)
 
void Relocate (Position const &pos)
 
void Relocate (Position const *pos)
 
void Relocate (G3D::Vector3 const &pos)
 
void RelocateOffset (Position const &offset)
 
void SetOrientation (float orientation)
 
float GetPositionX () const
 
float GetPositionY () const
 
float GetPositionZ () const
 
float GetOrientation () const
 
void GetPosition (float &x, float &y) const
 
void GetPosition (float &x, float &y, float &z) const
 
void GetPosition (float &x, float &y, float &z, float &o) const
 
Position GetPosition () const
 
Position::PositionXYStreamer PositionXYStream ()
 
Position::PositionXYZStreamer PositionXYZStream ()
 
Position::PositionXYZOStreamer PositionXYZOStream ()
 
bool IsPositionValid () const
 
float GetExactDist2dSq (float x, float y) const
 
float GetExactDist2d (const float x, const float y) const
 
float GetExactDist2dSq (Position const *pos) const
 
float GetExactDist2d (Position const *pos) const
 
float GetExactDistSq (float x, float y, float z) const
 
float GetExactDist (float x, float y, float z) const
 
float GetExactDistSq (Position const *pos) const
 
float GetExactDist (Position const *pos) const
 
void GetPositionOffsetTo (Position const &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (Position const *pos) const
 
float GetAngle (float x, float y) const
 
float GetRelativeAngle (Position const *pos) const
 
float GetRelativeAngle (float x, float y) const
 
void GetSinCos (float x, float y, float &vsin, float &vcos) const
 
bool IsInDist2d (float x, float y, float dist) const
 
bool IsInDist2d (Position const *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (Position const *pos, float dist) const
 
bool IsWithinBox (const Position &center, float xradius, float yradius, float zradius) const
 
bool HasInArc (float arcangle, Position const *pos, float border=2.0f) const
 
bool HasInLine (Position const *pos, float width) const
 
std::string ToString () const
 
- Public Member Functions inherited from GridObject< GameObject >
virtual ~GridObject ()
 
bool IsInGrid () const
 
void AddToGrid (GridRefManager< GameObject > &m)
 
void RemoveFromGrid ()
 

Static Public Member Functions

static void SetGoArtKit (uint8 artkit, GameObject *go, ObjectGuid::LowType lowguid=UI64LIT(0))
 
- Static Public Member Functions inherited from Position
static float NormalizeOrientation (float o)
 

Public Attributes

Loot loot
 
uint32 m_groupLootTimer
 
ObjectGuid lootingGroupLowGUID
 
GameObjectModelm_model
 
- Public Attributes inherited from WorldObject
FlaggedValuesArray32< int32,
uint32, StealthType,
TOTAL_STEALTH_TYPES
m_stealth
 
FlaggedValuesArray32< int32,
uint32, StealthType,
TOTAL_STEALTH_TYPES
m_stealthDetect
 
FlaggedValuesArray32< int32,
uint32, InvisibilityType,
TOTAL_INVISIBILITY_TYPES
m_invisibility
 
FlaggedValuesArray32< int32,
uint32, InvisibilityType,
TOTAL_INVISIBILITY_TYPES
m_invisibilityDetect
 
FlaggedValuesArray32< int32,
uint32,
ServerSideVisibilityType,
TOTAL_SERVERSIDE_VISIBILITY_TYPES
m_serverSideVisibility
 
FlaggedValuesArray32< int32,
uint32,
ServerSideVisibilityType,
TOTAL_SERVERSIDE_VISIBILITY_TYPES
m_serverSideVisibilityDetect
 
uint32 LastUsedScriptID
 
MovementInfo m_movementInfo
 
- Public Attributes inherited from WorldLocation
uint32 m_mapId
 
- Public Attributes inherited from Position
float m_positionX
 
float m_positionY
 
float m_positionZ
 

Protected Types

typedef std::map< uint32,
ObjectGuid
ChairSlotAndUser
 

Protected Member Functions

bool AIM_Initialize ()
 
GameObjectModelCreateModel ()
 
void UpdateModel ()
 
- Protected Member Functions inherited from WorldObject
 WorldObject (bool isWorldObject)
 
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 const &guid)
 
std::string _ConcatFields (uint16 startIndex, uint16 size) const
 
void _LoadIntoDataField (std::string const &data, uint32 startOffset, uint32 count)
 
uint32 GetUpdateFieldData (Player const *target, uint32 *&flags) const
 
uint32 GetDynamicUpdateFieldData (Player const *target, uint32 *&flags) const
 
void BuildMovementUpdate (ByteBuffer *data, uint32 flags) const
 
virtual void BuildDynamicValuesUpdate (uint8 updatetype, ByteBuffer *data, Player *target) const
 
void AddToObjectUpdateIfNeeded ()
 
- Protected Member Functions inherited from MapObject
 MapObject ()
 

Protected Attributes

uint32 m_spellId
 
time_t m_respawnTime
 
uint32 m_respawnDelayTime
 
LootState m_lootState
 
ObjectGuid m_lootStateUnitGUID
 
bool m_spawnedByDefault
 
time_t m_cooldownTime
 
GuidSet m_SkillupList
 
ObjectGuid m_ritualOwnerGUID
 
GuidSet m_unique_users
 
uint32 m_usetimes
 
ChairSlotAndUser ChairListSlots
 
ObjectGuid::LowType m_spawnId
 For new or temporary gameobjects is 0 for saved it is lowguid. More...
 
GameObjectTemplate constm_goInfo
 
GameObjectData constm_goData
 
GameObjectValue m_goValue
 
uint64 m_rotation
 
Position m_stationaryPosition
 
ObjectGuid m_lootRecipient
 
ObjectGuid m_lootRecipientGroup
 
uint16 m_LootMode
 
- Protected Attributes inherited from WorldObject
std::string m_name
 
bool m_isActive
 
const bool m_isWorldObject
 
ZoneScriptm_zoneScript
 
Transportm_transport
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
TypeID m_objectTypeId
 
uint32 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
std::vector< uint32 > * _dynamicValues
 
UpdateMask _changesMask
 
UpdateMask _dynamicChangesMask
 
UpdateMask_dynamicChangesArrayMask
 
uint16 m_valuesCount
 
uint16 _dynamicValuesCount
 
uint16 _fieldNotifyFlags
 
bool m_objectUpdated
 

Private Member Functions

void RemoveFromOwner ()
 
void SwitchDoorOrButton (bool activate, bool alternative=false)
 
bool _IsWithinDist (WorldObject const *obj, float dist2compare, bool) const override
 Object distance/size - overridden from Object::_IsWithinDist. Needs to take in account proper GO size. More...
 

Private Attributes

GameObjectAIm_AI
 
uint16 _animKitId
 

Member Typedef Documentation

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

Constructor & Destructor Documentation

GameObject::GameObject ( )
explicit
38  : WorldObject(false), MapObject(),
40 {
43 
45 
48  m_respawnTime = 0;
49  m_respawnDelayTime = 300;
51  m_spawnedByDefault = true;
52  m_usetimes = 0;
53  m_spellId = 0;
54  m_cooldownTime = 0;
55  m_goInfo = NULL;
56  m_goData = NULL;
57 
58  m_spawnId = UI64LIT(0);
59  m_rotation = 0;
60 
61  m_groupLootTimer = 0;
62 
63  ResetLootMode(); // restore default loot mode
64  m_stationaryPosition.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
65 }
LootState m_lootState
Definition: GameObject.h:1096
uint32 m_usetimes
Definition: GameObject.h:1105
Definition: UpdateFields.h:329
uint32 m_respawnDelayTime
Definition: GameObject.h:1095
uint16 _dynamicValuesCount
Definition: Object.h:246
Position m_stationaryPosition
Definition: GameObject.h:1116
Definition: UpdateData.h:46
GameObjectAI * m_AI
Definition: GameObject.h:1132
#define UI64LIT(N)
Definition: Define.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
GameObjectData const * m_goData
Definition: GameObject.h:1112
uint16 m_objectType
Definition: Object.h:227
Definition: UpdateFields.h:335
GameObjectTemplate const * m_goInfo
Definition: GameObject.h:1111
time_t m_cooldownTime
Definition: GameObject.h:1099
time_t m_respawnTime
Definition: GameObject.h:1094
GameObjectModel * m_model
Definition: GameObject.h:1070
Definition: ObjectGuid.h:51
void Relocate(float x, float y)
Definition: Position.h:67
TypeID m_objectTypeId
Definition: Object.h:229
GameObjectValue m_goValue
Definition: GameObject.h:1113
MapObject()
Definition: Object.h:404
Definition: ObjectGuid.h:34
uint32 m_groupLootTimer
Definition: GameObject.h:1014
uint64 m_rotation
Definition: GameObject.h:1115
WorldObject(bool isWorldObject)
Definition: Object.cpp:1445
bool m_spawnedByDefault
Definition: GameObject.h:1098
uint32 m_spellId
Definition: GameObject.h:1093
Definition: GameObject.h:868
uint16 m_valuesCount
Definition: Object.h:245
Definition: UpdateData.h:43
void ResetLootMode()
Definition: GameObject.h:990
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110
uint16 _animKitId
Definition: GameObject.h:1133
uint32 m_updateFlag
Definition: Object.h:230

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GameObject::~GameObject ( )
68 {
69  delete m_AI;
70  delete m_model;
73  //if (m_uint32Values) // field array can be not exist if GameOBject not loaded
74  // CleanupsBeforeDelete();
75 }
GameObjectAI * m_AI
Definition: GameObject.h:1132
struct GameObjectValue::@273 Transport
GameObjectTemplate const * m_goInfo
Definition: GameObject.h:1111
GameObjectModel * m_model
Definition: GameObject.h:1070
GameObjectValue m_goValue
Definition: GameObject.h:1113
std::vector< uint32 > * StopFrames
Definition: GameObject.h:782
Definition: SharedDefines.h:2076
uint32 type
Definition: GameObject.h:37

Member Function Documentation

bool GameObject::_IsWithinDist ( WorldObject const obj,
float  dist2compare,
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.

1127  {
1129  return IsInRange(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare);
1130  }
bool IsInRange(float x, float y, float z, float radius) const
Definition: GameObject.cpp:1887

+ Here is the call graph for this function:

bool GameObject::ActivateToQuest ( Player target) const
1079 {
1080  if (target->HasQuestForGO(GetEntry()))
1081  return true;
1082 
1083  if (!sObjectMgr->IsGameObjectForQuests(GetEntry()))
1084  return false;
1085 
1086  switch (GetGoType())
1087  {
1089  {
1090  GameObject* go = const_cast<GameObject*>(this);
1091  QuestGiverStatus questStatus = target->GetQuestDialogStatus(go);
1092  if (questStatus > DIALOG_STATUS_UNAVAILABLE)
1093  return true;
1094  break;
1095  }
1096  case GAMEOBJECT_TYPE_CHEST:
1097  {
1098  // scan GO chest with loot including quest items
1099  if (LootTemplates_Gameobject.HaveQuestLootForPlayer(GetGOInfo()->GetLootId(), target))
1100  {
1101  if (Battleground const* bg = target->GetBattleground())
1102  return bg->CanActivateGO(GetEntry(), target->GetTeam());
1103  return true;
1104  }
1105  break;
1106  }
1108  {
1109  if (target->GetQuestStatus(GetGOInfo()->generic.questID) == QUEST_STATUS_INCOMPLETE)
1110  return true;
1111  break;
1112  }
1114  {
1115  if (target->GetQuestStatus(GetGOInfo()->goober.questID) == QUEST_STATUS_INCOMPLETE)
1116  return true;
1117  break;
1118  }
1119  default:
1120  break;
1121  }
1122 
1123  return false;
1124 }
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 questID
Definition: GameObject.h:105
LootStore LootTemplates_Gameobject("gameobject_loot_template","gameobject entry", true)
bool HaveQuestLootForPlayer(uint32 loot_id, Player *player) const
Definition: LootMgr.cpp:208
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
Definition: GameObject.h:880
QuestGiverStatus
Definition: QuestDef.h:120
Definition: SharedDefines.h:2067
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
Definition: SharedDefines.h:2075
Definition: QuestDef.h:113
Definition: SharedDefines.h:2068
Definition: Battleground.h:235
uint32 GetEntry() const
Definition: Object.h:107
Definition: QuestDef.h:124
Definition: SharedDefines.h:2070

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::AddLootMode ( uint16  lootMode)
inline
988 { m_LootMode |= lootMode; }
uint16 m_LootMode
Definition: GameObject.h:1120
void GameObject::AddToSkillupList ( ObjectGuid const PlayerGuidLow)
inline
992 { m_SkillupList.insert(PlayerGuidLow); }
GuidSet m_SkillupList
Definition: GameObject.h:1101

+ Here is the caller graph for this function:

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

Reimplemented from Object.

126 {
128  if (!IsInWorld())
129  {
130  if (m_zoneScript)
132 
134  if (m_spawnId)
135  GetMap()->GetGameObjectBySpawnIdStore().insert(std::make_pair(m_spawnId, this));
136 
137  // The state can be changed after GameObject::Create but before GameObject::AddToWorld
138  bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState() == GO_READY : (GetGoState() == GO_STATE_READY || IsTransport());
139  if (m_model)
140  {
141  if (Transport* trans = ToTransport())
142  trans->SetDelayedAddModelToMap();
143  else
145  }
146 
147  EnableCollision(toggledState);
149  }
150 }
bool Insert(KEY_TYPE const &handle, SPECIFIC_TYPE *obj)
Definition: TypeContainer.h:119
GOState GetGoState() const
Definition: GameObject.h:966
LootState getLootState() const
Definition: GameObject.h:981
Map * GetMap() const
Definition: Object.h:543
virtual void OnGameObjectCreate(GameObject *)
Definition: ZoneScript.h:38
Definition: Transport.h:28
GameObjectModel * m_model
Definition: GameObject.h:1070
ZoneScript * m_zoneScript
Definition: Object.h:627
Transport * ToTransport()
Definition: GameObject.h:1073
bool IsTransport() const
Definition: GameObject.cpp:979
void EnableCollision(bool enable)
Definition: GameObject.cpp:2203
Definition: GameObject.h:880
MapStoredObjectTypesContainer & GetObjectsStore()
Definition: Map.h:466
virtual void AddToWorld()
Definition: Object.cpp:142
Definition: GameObject.h:823
ObjectGuid const & GetGUID() const
Definition: Object.h:105
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:472
Definition: SharedDefines.h:2068
bool IsInWorld() const
Definition: Object.h:100
Definition: GameObject.h:869
void InsertGameObjectModel(const GameObjectModel &model)
Definition: Map.h:506
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::AddUniqueUse ( Player player)
721 {
722  AddUse();
723  m_unique_users.insert(player->GetGUID());
724 }
GuidSet m_unique_users
Definition: GameObject.h:1104
void AddUse()
Definition: GameObject.h:1000

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::AddUse ( )
inline
1000 { ++m_usetimes; }
uint32 m_usetimes
Definition: GameObject.h:1105

+ Here is the caller graph for this function:

GameObjectAI* GameObject::AI ( ) const
inline
1061 { return m_AI; }
GameObjectAI * m_AI
Definition: GameObject.h:1132

+ Here is the caller graph for this function:

bool GameObject::AIM_Initialize ( )
protected
78 {
79  delete m_AI;
80 
82 
83  if (!m_AI)
84  return false;
85 
86  m_AI->InitializeAI();
87  return true;
88 }
GameObjectAI * m_AI
Definition: GameObject.h:1132
GameObjectAI * SelectGameObjectAI(GameObject *go)
Definition: CreatureAISelector.cpp:128
virtual void InitializeAI()
Definition: GameObjectAI.h:39

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Reimplemented from Object.

2282 {
2283  if (!target)
2284  return;
2285 
2286  bool isStoppableTransport = GetGoType() == GAMEOBJECT_TYPE_TRANSPORT && !m_goValue.Transport.StopFrames->empty();
2287  bool forcedFlags = GetGoType() == GAMEOBJECT_TYPE_CHEST && GetGOInfo()->chest.usegrouplootrules && HasLootRecipient();
2288  bool targetIsGM = target->IsGameMaster();
2289 
2290  ByteBuffer fieldBuffer;
2291 
2292  UpdateMask updateMask;
2293  updateMask.SetCount(m_valuesCount);
2294 
2296  uint32 visibleFlag = UF_FLAG_PUBLIC;
2297  if (GetOwnerGUID() == target->GetGUID())
2298  visibleFlag |= UF_FLAG_OWNER;
2299 
2300  for (uint16 index = 0; index < m_valuesCount; ++index)
2301  {
2302  if (_fieldNotifyFlags & flags[index] ||
2303  ((updateType == UPDATETYPE_VALUES ? _changesMask.GetBit(index) : m_uint32Values[index]) && (flags[index] & visibleFlag)) ||
2304  (index == GAMEOBJECT_FLAGS && forcedFlags))
2305  {
2306  updateMask.SetBit(index);
2307 
2308  if (index == OBJECT_DYNAMIC_FLAGS)
2309  {
2310  uint16 dynFlags = 0;
2311  int16 pathProgress = -1;
2312  switch (GetGoType())
2313  {
2315  if (ActivateToQuest(target))
2316  dynFlags |= GO_DYNFLAG_LO_ACTIVATE;
2317  break;
2318  case GAMEOBJECT_TYPE_CHEST:
2320  if (ActivateToQuest(target))
2322  else if (targetIsGM)
2323  dynFlags |= GO_DYNFLAG_LO_ACTIVATE;
2324  break;
2326  if (ActivateToQuest(target))
2327  dynFlags |= GO_DYNFLAG_LO_SPARKLE;
2328  break;
2331  {
2332  if (uint32 transportPeriod = GetTransportPeriod())
2333  {
2334  float timer = float(m_goValue.Transport.PathProgress % transportPeriod);
2335  pathProgress = int16(timer / float(transportPeriod) * 65535.0f);
2336  }
2337  break;
2338  }
2339  default:
2340  break;
2341  }
2342 
2343  fieldBuffer << uint16(dynFlags);
2344  fieldBuffer << int16(pathProgress);
2345  }
2346  else if (index == GAMEOBJECT_FLAGS)
2347  {
2350  if (GetGOInfo()->chest.usegrouplootrules && !IsLootAllowedFor(target))
2352 
2353  fieldBuffer << goFlags;
2354  }
2355  else if (index == GAMEOBJECT_LEVEL)
2356  {
2357  if (isStoppableTransport)
2358  fieldBuffer << uint32(m_goValue.Transport.PathProgress);
2359  else
2360  fieldBuffer << m_uint32Values[index];
2361  }
2362  else if (index == GAMEOBJECT_BYTES_1)
2363  {
2364  uint32 bytes1 = m_uint32Values[index];
2365  if (isStoppableTransport && GetGoState() == GO_STATE_TRANSPORT_ACTIVE)
2366  {
2367  if ((m_goValue.Transport.StateUpdateTimer / 20000) & 1)
2368  {
2369  bytes1 &= 0xFFFFFF00;
2370  bytes1 |= GO_STATE_TRANSPORT_STOPPED;
2371  }
2372  }
2373 
2374  fieldBuffer << bytes1;
2375  }
2376  else
2377  fieldBuffer << m_uint32Values[index]; // other cases
2378  }
2379  }
2380 
2381  *data << uint8(updateMask.GetBlockCount());
2382  updateMask.AppendToPacket(data);
2383  data->append(fieldBuffer);
2384 }
Definition: SharedDefines.h:2138
Definition: UpdateMask.h:26
Definition: GameObject.h:825
Definition: ByteBuffer.h:70
UpdateMask _changesMask
Definition: Object.h:241
GOState GetGoState() const
Definition: GameObject.h:966
uint32 * m_uint32Values
Definition: Object.h:235
int16_t int16
Definition: g3dmath.h:165
Definition: SharedDefines.h:2125
uint32 GameObjectUpdateFieldFlags[GAMEOBJECT_END]
Definition: UpdateFieldFlags.cpp:3875
Definition: UpdateFieldFlags.h:27
Definition: GameObject.h:826
uint32 GetBlockCount() const
Definition: UpdateMask.h:64
struct GameObjectValue::@273 Transport
uint32 StateUpdateTimer
Definition: GameObject.h:783
void AppendToPacket(ByteBuffer *data)
Definition: UpdateMask.h:51
uint16_t uint16
Definition: g3dmath.h:166
bool ActivateToQuest(Player *target) const
Definition: GameObject.cpp:1078
Definition: UpdateFields.h:323
Definition: SharedDefines.h:2080
GameObjectValue m_goValue
Definition: GameObject.h:1113
struct GameObjectTemplate::@221::@226 chest
Definition: UpdateFields.h:322
Definition: SharedDefines.h:2122
uint32_t uint32
Definition: Define.h:150
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
uint16_t uint16
Definition: Define.h:151
std::vector< uint32 > * StopFrames
Definition: GameObject.h:782
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
void append(T value)
Definition: ByteBuffer.h:143
Definition: UpdateFields.h:319
uint32 usegrouplootrules
Definition: GameObject.h:112
bool HasLootRecipient() const
Definition: GameObject.h:1013
uint8_t uint8
Definition: g3dmath.h:164
bool IsLootAllowedFor(Player const *player) const
Definition: GameObject.cpp:2266
Definition: SharedDefines.h:2067
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
Definition: SharedDefines.h:2075
Definition: UpdateFieldFlags.h:29
void SetCount(uint32 valuesCount)
Definition: UpdateMask.h:67
uint16 m_valuesCount
Definition: Object.h:245
uint32 PathProgress
Definition: GameObject.h:779
Definition: UpdateFields.h:30
Definition: SharedDefines.h:2068
int16_t int16
Definition: Define.h:147
bool GetBit(uint32 index) const
Definition: UpdateMask.h:49
uint32_t uint32
Definition: g3dmath.h:168
uint8 flags
Definition: DisableMgr.cpp:44
Definition: SharedDefines.h:2135
virtual uint32 GetTransportPeriod() const
Definition: GameObject.cpp:2155
Definition: SharedDefines.h:2070
void SetBit(uint32 index)
Definition: UpdateMask.h:47
Definition: SharedDefines.h:2076
Definition: UpdateData.h:30
uint16 _fieldNotifyFlags
Definition: Object.h:248

+ Here is the call graph for this function:

void GameObject::CastSpell ( Unit target,
uint32  spell,
bool  triggered = true 
)
1834 {
1835  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
1836  if (!spellInfo)
1837  return;
1838 
1839  bool self = false;
1840  for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
1841  {
1842  if (effect && effect->TargetA.GetTarget() == TARGET_UNIT_CASTER)
1843  {
1844  self = true;
1845  break;
1846  }
1847  }
1848 
1849  if (self)
1850  {
1851  if (target)
1852  target->CastSpell(target, spellInfo, triggered);
1853  return;
1854  }
1855 
1856  //summon world trigger
1857  Creature* trigger = SummonTrigger(GetPositionX(), GetPositionY(), GetPositionZ(), 0, spellInfo->CalcCastTime() + 100);
1858  if (!trigger)
1859  return;
1860 
1861  if (Unit* owner = GetOwner())
1862  {
1863  trigger->setFaction(owner->getFaction());
1864  if (owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
1866  // needed for GO casts for proper target validation checks
1867  trigger->SetOwnerGUID(owner->GetGUID());
1868  trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, owner->GetGUID());
1869  }
1870  else
1871  {
1872  trigger->setFaction(14);
1873  // Set owner guid for target if no owner available - needed by trigger auras
1874  // - trigger gets despawned and there's no caster avalible (see AuraEffect::TriggerSpell())
1875  trigger->CastSpell(target ? target : trigger, spellInfo, triggered, nullptr, nullptr, target ? target->GetGUID() : ObjectGuid::Empty);
1876  }
1877 }
Unit * GetOwner() const
Definition: GameObject.cpp:1009
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Map * GetMap() const
Definition: Object.h:543
Definition: SpellInfo.h:326
uint32 CalcCastTime(uint8 level=0, Spell *spell=NULL) const
Definition: SpellInfo.cpp:2504
Definition: Creature.h:467
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
void setFaction(uint32 faction)
Definition: Unit.h:1467
float GetPositionY() const
Definition: Position.h:105
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
float GetPositionZ() const
Definition: Position.h:106
void SetOwnerGUID(ObjectGuid owner)
Definition: Unit.cpp:7517
Definition: Unit.h:676
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: UpdateFields.h:109
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI *(*GetAI)(Creature *)=NULL)
Definition: Object.cpp:2404
SpellEffectInfoVector GetEffectsForDifficulty(uint32 difficulty) const
Definition: SpellInfo.cpp:3311
Definition: SharedDefines.h:1875
float GetPositionX() const
Definition: Position.h:104
Definition: Unit.h:1305
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Reimplemented from WorldObject.

Reimplemented in Transport.

99 {
100  WorldObject::CleanupsBeforeDelete(finalCleanup);
101 
102  if (m_uint32Values) // field array can be not exist if GameOBject not loaded
103  RemoveFromOwner();
104 }
uint32 * m_uint32Values
Definition: Object.h:235
virtual void CleanupsBeforeDelete(bool finalCleanup=true)
Definition: Object.cpp:1506
void RemoveFromOwner()
Definition: GameObject.cpp:106

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::ClearSkillupList ( )
inline
997 { m_SkillupList.clear(); }
GuidSet m_SkillupList
Definition: GameObject.h:1101
bool GameObject::Create ( ObjectGuid::LowType  guidlow,
uint32  name_id,
Map map,
uint32  phaseMask,
float  x,
float  y,
float  z,
float  ang,
float  rotation0,
float  rotation1,
float  rotation2,
float  rotation3,
uint32  animprogress,
GOState  go_state,
uint32  artKit = 0 
)
174 {
175  ASSERT(map);
176  SetMap(map);
177 
178  Relocate(x, y, z, ang);
180  if (!IsPositionValid())
181  {
182  TC_LOG_ERROR("misc", "Gameobject (GUID: " UI64FMTD " Spawn id: " UI64FMTD " Entry: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", guidlow, GetSpawnId(), name_id, x, y);
183  return false;
184  }
185 
186  SetZoneScript();
187  if (m_zoneScript)
188  {
189  name_id = m_zoneScript->GetGameObjectEntry(guidlow, name_id);
190  if (!name_id)
191  return false;
192  }
193 
194  GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(name_id);
195  if (!goinfo)
196  {
197  TC_LOG_ERROR("sql.sql", "Gameobject (GUID: " UI64FMTD " Spawn id: " UI64FMTD " Entry: %u) not created: non-existing entry in `gameobject_template`. Map: %u (X: %f Y: %f Z: %f)", guidlow, GetSpawnId(), name_id, map->GetId(), x, y, z);
198  return false;
199  }
200 
202  {
203  TC_LOG_ERROR("sql.sql", "Gameobject (GUID: " UI64FMTD " Spawn id: " UI64FMTD " Entry: %u) not created: gameobject type GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT cannot be manually created.", guidlow, GetSpawnId(), name_id);
204  return false;
205  }
206 
207  if (goinfo->type == GAMEOBJECT_TYPE_TRANSPORT)
209 
210  Object::_Create(ObjectGuid::Create<HighGuid::GameObject>(map->GetId(), goinfo->entry, guidlow));
211 
212  m_goInfo = goinfo;
213 
214  if (goinfo->type >= MAX_GAMEOBJECT_TYPE)
215  {
216  TC_LOG_ERROR("sql.sql", "Gameobject (GUID: " UI64FMTD " Spawn id: " UI64FMTD " Entry: %u) not created: non-existing GO type '%u' in `gameobject_template`. It will crash client if created.", guidlow, GetSpawnId(), name_id, goinfo->type);
217  return false;
218  }
219 
222 
223  UpdateRotationFields(rotation2, rotation3); // GAMEOBJECT_FACING, GAMEOBJECT_ROTATION, GAMEOBJECT_PARENTROTATION+2/3
224 
225  SetObjectScale(goinfo->size);
226 
229 
230  SetEntry(goinfo->entry);
231 
232  // set name for logs usage, doesn't affect anything ingame
233  SetName(goinfo->name);
234 
235  SetDisplayId(goinfo->displayId);
236 
237  m_model = CreateModel();
238  // GAMEOBJECT_BYTES_1, index at 0, 1, 2 and 3
239  SetGoType(GameobjectTypes(goinfo->type));
240  SetGoState(go_state);
241  SetGoArtKit(artKit);
242 
243  switch (goinfo->type)
244  {
246  SetGoAnimProgress(animprogress);
247  m_goValue.FishingHole.MaxOpens = urand(GetGOInfo()->fishingHole.minRestock, GetGOInfo()->fishingHole.maxRestock);
248  break;
250  // TODO: Get the values somehow, no longer in gameobject_template
251  m_goValue.Building.Health = 20000/*goinfo->destructibleBuilding.intactNumHits + goinfo->destructibleBuilding.damagedNumHits*/;
253  SetGoAnimProgress(255);
255  break;
257  {
258  m_goValue.Transport.AnimationInfo = sTransportMgr->GetTransportAnimInfo(goinfo->entry);
264  m_goValue.Transport.StopFrames = new std::vector<uint32>();
265  if (goinfo->transport.Timeto2ndfloor > 0)
266  m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto2ndfloor);
267  if (goinfo->transport.Timeto3rdfloor > 0)
268  m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto3rdfloor);
269  if (goinfo->transport.Timeto4thfloor > 0)
270  m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto4thfloor);
271  if (goinfo->transport.Timeto5thfloor > 0)
272  m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto5thfloor);
273  if (goinfo->transport.Timeto6thfloor > 0)
274  m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto6thfloor);
275  if (goinfo->transport.Timeto7thfloor > 0)
276  m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto7thfloor);
277  if (goinfo->transport.Timeto8thfloor > 0)
278  m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto8thfloor);
279  if (goinfo->transport.Timeto9thfloor > 0)
280  m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto9thfloor);
281  if (goinfo->transport.Timeto10thfloor > 0)
282  m_goValue.Transport.StopFrames->push_back(goinfo->transport.Timeto10thfloor);
283  if (goinfo->transport.startOpen)
285  else
287 
288  SetGoAnimProgress(animprogress);
289  break;
290  }
293  break;
295  if (GetGOInfo()->trap.stealthed)
296  {
299  }
300 
301  if (GetGOInfo()->trap.stealthAffected)
302  {
305  }
306  break;
307  default:
308  SetGoAnimProgress(animprogress);
309  break;
310  }
311 
312  if (GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(GetSpawnId()))
313  {
314  if (addon->InvisibilityValue)
315  {
316  m_invisibility.AddFlag(addon->invisibilityType);
317  m_invisibility.AddValue(addon->invisibilityType, addon->InvisibilityValue);
318  }
319  }
320 
322  AIM_Initialize();
323 
324  // Initialize loot duplicate count depending on raid difficulty
325  if (map->Is25ManRaid())
326  loot.maxDuplicates = 3;
327 
328  return true;
329 }
#define MAX_GAMEOBJECT_TYPE
Definition: SharedDefines.h:2116
bool AIM_Initialize()
Definition: GameObject.cpp:77
Definition: GameObject.h:825
Definition: UpdateFields.h:320
void _Create(ObjectGuid const &guid)
Definition: Object.cpp:125
TransportAnimation const * AnimationInfo
Definition: GameObject.h:780
uint32 minRestock
Definition: GameObject.h:101
Definition: GameObject.h:811
Definition: SharedDefines.h:1700
void SetGoType(GameobjectTypes type)
Definition: GameObject.h:965
Position m_stationaryPosition
Definition: GameObject.h:1116
Definition: GameObject.h:826
virtual void SetMap(Map *map)
Definition: Object.cpp:2169
uint32 getMSTime()
Definition: Timer.h:24
Definition: GameObject.h:34
#define sTransportMgr
Definition: TransportMgr.h:162
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
struct GameObjectValue::@273 Transport
bool Is25ManRaid() const
Definition: Map.h:400
void SetTransportState(GOState state, uint32 stopFrame=0)
Definition: GameObject.cpp:2164
struct GameObjectValue::@276 Building
uint32 StateUpdateTimer
Definition: GameObject.h:783
uint32 displayId
Definition: GameObject.h:38
GameObjectModel * CreateModel()
Definition: GameObject.cpp:2475
void SetEntry(uint32 entry)
Definition: Object.h:108
uint32 faction
Definition: GameObject.h:43
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:902
Definition: SharedDefines.h:2082
void SetName(std::string const &newname)
Definition: Object.h:480
float size
Definition: GameObject.h:45
void SetGoAnimProgress(uint8 animprogress)
Definition: GameObject.h:973
#define sObjectMgr
Definition: ObjectMgr.h:1567
GameObjectTemplate const * m_goInfo
Definition: GameObject.h:1111
GameobjectTypes
Definition: SharedDefines.h:2063
uint32 CurrentSeg
Definition: GameObject.h:781
uint32 GetId(void) const
Definition: Map.h:325
struct GameObjectTemplate::@221::@234 transport
void SetDisplayId(uint32 displayid)
Definition: GameObject.cpp:2188
GameObjectModel * m_model
Definition: GameObject.h:1070
void Relocate(float x, float y)
Definition: Position.h:67
uint32 stealthAffected
Definition: GameObject.h:162
uint32 MaxOpens
Definition: GameObject.h:788
ZoneScript * m_zoneScript
Definition: Object.h:627
uint32 maxRestock
Definition: GameObject.h:102
Definition: SharedDefines.h:2080
GameObjectValue m_goValue
Definition: GameObject.h:1113
G3D::int16 z
Definition: Vector3int16.h:46
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
#define UI64FMTD
Definition: Define.h:137
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
G3D::int16 y
Definition: Vector2int16.h:38
Loot loot
Definition: GameObject.h:1007
struct GameObjectValue::@274 FishingHole
virtual uint32 GetGameObjectEntry(ObjectGuid::LowType, uint32 entry)
Definition: ZoneScript.h:33
Definition: SharedDefines.h:1690
void AddValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:384
uint32 entry
Definition: GameObject.h:36
std::vector< uint32 > * StopFrames
Definition: GameObject.h:782
uint32 ScriptId
Definition: GameObject.h:625
Definition: UpdateData.h:40
Definition: UpdateFields.h:321
Definition: UpdateFields.h:319
void AddFlag(FLAG_TYPE flag)
Definition: Object.h:379
Definition: SharedDefines.h:2090
struct GameObjectTemplate::@221::@256 destructibleBuilding
void SetGoState(GOState state)
Definition: GameObject.cpp:2137
uint8 maxDuplicates
Definition: LootMgr.h:326
std::string name
Definition: GameObject.h:39
virtual void SetObjectScale(float scale)
Definition: Object.h:111
void SetZoneScript()
Definition: Object.cpp:2330
uint32 Health
Definition: GameObject.h:798
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:1067
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPES > m_stealth
Definition: Object.h:532
#define ASSERT
Definition: Errors.h:55
uint32 PathProgress
Definition: GameObject.h:779
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibility
Definition: Object.h:535
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool IsPositionValid() const
Definition: Position.cpp:40
uint32 flags
Definition: GameObject.h:44
virtual uint32 GetTransportPeriod() const
Definition: GameObject.cpp:2155
void SetGoArtKit(uint8 artkit)
Definition: GameObject.cpp:1196
G3D::int16 x
Definition: Vector2int16.h:37
uint32 stealthed
Definition: GameObject.h:160
Definition: SharedDefines.h:2098
Definition: SharedDefines.h:2076
Definition: SharedDefines.h:2071
uint32 MaxHealth
Definition: GameObject.h:799
uint32 type
Definition: GameObject.h:37
uint32 LastUsedScriptID
Definition: Object.h:599
uint32 m_updateFlag
Definition: Object.h:230
void UpdateRotationFields(float rotation2=0.0f, float rotation3=0.0f)
Definition: GameObject.cpp:1943

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GameObjectModel * GameObject::CreateModel ( )
protected
2476 {
2477  return GameObjectModel::Create(Trinity::make_unique<GameObjectModelOwnerImpl>(this), sWorld->GetDataPath());
2478 }
static GameObjectModel * Create(std::unique_ptr< GameObjectModelOwnerBase > modelOwner, std::string const &dataPath)
Definition: GameObjectModel.cpp:144
#define sWorld
Definition: World.h:887

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::Delete ( )
727 {
729  RemoveFromOwner();
730 
732 
735 
736  uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
737  if (poolid)
738  sPoolMgr->UpdatePool<GameObject>(poolid, GetSpawnId());
739  else
741 }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:902
void RemoveFromOwner()
Definition: GameObject.cpp:106
void SetLootState(LootState s, Unit *unit=NULL)
Definition: GameObject.cpp:2112
void SendObjectDeSpawnAnim(ObjectGuid guid)
Definition: Object.cpp:2162
#define sPoolMgr
Definition: PoolMgr.h:166
void AddObjectToRemoveList()
Definition: Object.cpp:2205
uint32_t uint32
Definition: Define.h:150
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
Definition: GameObject.h:880
Definition: UpdateFields.h:319
Definition: GameObject.h:823
void SetGoState(GOState state)
Definition: GameObject.cpp:2137
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: GameObject.h:868
uint8 flags
Definition: DisableMgr.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::DeleteFromDB ( )
937 {
939  sObjectMgr->DeleteGOData(m_spawnId);
940 
942 
943  stmt->setUInt64(0, m_spawnId);
944 
945  WorldDatabase.Execute(stmt);
946 
948 
949  stmt->setUInt64(0, m_spawnId);
950 
951  WorldDatabase.Execute(stmt);
952 }
Definition: WorldDatabase.h:39
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Map * GetMap() const
Definition: Object.h:543
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: WorldDatabase.h:38
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110
void RemoveGORespawnTime(ObjectGuid::LowType dbGuid)
Definition: Map.cpp:3619

+ Here is the call graph for this function:

void GameObject::EnableCollision ( bool  enable)
2204 {
2205  if (!m_model)
2206  return;
2207 
2208  /*if (enable && !GetMap()->ContainsGameObjectModel(*m_model))
2209  GetMap()->InsertGameObjectModel(*m_model);*/
2210 
2211  m_model->enable(enable ? GetPhaseMask() : 0);
2212 }
GameObjectModel * m_model
Definition: GameObject.h:1070
uint32 GetPhaseMask() const
Definition: Object.h:461
void enable(uint32 ph_mask)
Definition: GameObjectModel.h:64

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::EventInform ( uint32  eventId,
WorldObject invoker = NULL 
)
1914 {
1915  if (!eventId)
1916  return;
1917 
1918  if (AI())
1919  AI()->EventInform(eventId);
1920 
1921  if (GetZoneScript())
1922  GetZoneScript()->ProcessEvent(this, eventId);
1923 
1924  if (BattlegroundMap* bgMap = GetMap()->ToBattlegroundMap())
1925  if (bgMap->GetBG())
1926  bgMap->GetBG()->ProcessEvent(this, eventId, invoker);
1927 }
GameObjectAI * AI() const
Definition: GameObject.h:1061
Map * GetMap() const
Definition: Object.h:543
Definition: Map.h:790
ZoneScript * GetZoneScript() const
Definition: Object.h:551
virtual void EventInform(uint32)
Definition: GameObjectAI.h:63
virtual void ProcessEvent(WorldObject *, uint32)
Definition: ZoneScript.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint16 GameObject::GetAIAnimKitId ( ) const
inlineoverridevirtual

Reimplemented from WorldObject.

1086 { return _animKitId; }
uint16 _animKitId
Definition: GameObject.h:1133
std::string GameObject::GetAIName ( ) const
91 {
92  if (GameObjectTemplate const* got = sObjectMgr->GetGameObjectTemplate(GetEntry()))
93  return got->AIName;
94 
95  return "";
96 }
Definition: GameObject.h:34
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 GetEntry() const
Definition: Object.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GameObjectDestructibleState GameObject::GetDestructibleState ( ) const
inline
1049  {
1053  return GO_DESTRUCTIBLE_DAMAGED;
1054  return GO_DESTRUCTIBLE_INTACT;
1055  }
Definition: SharedDefines.h:2128
Definition: SharedDefines.h:2145
Definition: SharedDefines.h:2144
Definition: SharedDefines.h:2146
Definition: SharedDefines.h:2129
Definition: UpdateFields.h:319
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239

+ Here is the caller graph for this function:

uint32 GameObject::GetDisplayId ( ) const
inline
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:318

+ Here is the caller graph for this function:

uint32 GameObject::GetFaction ( ) const
inline
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: UpdateFields.h:321
void GameObject::getFishLoot ( Loot loot,
Player loot_owner 
)
744 {
745  fishloot->clear();
746 
747  uint32 zone, subzone;
748  uint32 defaultzone = 1;
749  GetZoneAndAreaId(zone, subzone);
750 
751  // if subzone loot exist use it
752  fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner, true, true);
753  if (fishloot->empty()) //use this becase if zone or subzone has set LOOT_MODE_JUNK_FISH,Even if no normal drop, fishloot->FillLoot return true. it wrong.
754  {
755  //subzone no result,use zone loot
756  fishloot->FillLoot(zone, LootTemplates_Fishing, loot_owner, true, true);
757  //use zone 1 as default, somewhere fishing got nothing,becase subzone and zone not set, like Off the coast of Storm Peaks.
758  if (fishloot->empty())
759  fishloot->FillLoot(defaultzone, LootTemplates_Fishing, loot_owner, true, true);
760  }
761 }
LootStore LootTemplates_Fishing("fishing_loot_template","area id", true)
uint32_t uint32
Definition: Define.h:150
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition: Object.cpp:1535

+ Here is the call graph for this function:

void GameObject::getFishLootJunk ( Loot loot,
Player loot_owner 
)
764 {
765  fishloot->clear();
766 
767  uint32 zone, subzone;
768  uint32 defaultzone = 1;
769  GetZoneAndAreaId(zone, subzone);
770 
771  // if subzone loot exist use it
772  fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner, true, true, LOOT_MODE_JUNK_FISH);
773  if (fishloot->empty()) //use this becase if zone or subzone has normal mask drop, then fishloot->FillLoot return true.
774  {
775  //use zone loot
776  fishloot->FillLoot(zone, LootTemplates_Fishing, loot_owner, true, true, LOOT_MODE_JUNK_FISH);
777  if (fishloot->empty())
778  //use zone 1 as default
779  fishloot->FillLoot(defaultzone, LootTemplates_Fishing, loot_owner, true, true, LOOT_MODE_JUNK_FISH);
780  }
781 }
LootStore LootTemplates_Fishing("fishing_loot_template","area id", true)
uint32_t uint32
Definition: Define.h:150
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition: Object.cpp:1535
Definition: SharedDefines.h:74

+ Here is the call graph for this function:

uint8 GameObject::GetGoAnimProgress ( ) const
inline
972 { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
Definition: UpdateFields.h:323
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the caller graph for this function:

uint8 GameObject::GetGoArtKit ( ) const
inline
970 { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
Definition: UpdateFields.h:323
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the caller graph for this function:

GameObjectData const* GameObject::GetGOData ( ) const
inline
895 { return m_goData; }
GameObjectData const * m_goData
Definition: GameObject.h:1112

+ Here is the caller graph for this function:

GameObjectTemplate const* GameObject::GetGOInfo ( ) const
inline
894 { return m_goInfo; }
GameObjectTemplate const * m_goInfo
Definition: GameObject.h:1111

+ Here is the caller graph for this function:

GOState GameObject::GetGoState ( ) const
inline
966 { return GOState(GetByteValue(GAMEOBJECT_BYTES_1, 0)); }
Definition: UpdateFields.h:323
GOState
Definition: GameObject.h:820
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the caller graph for this function:

GameobjectTypes GameObject::GetGoType ( ) const
inline
GameobjectTypes
Definition: SharedDefines.h:2063
Definition: UpdateFields.h:323
uint8 GetByteValue(uint16 index, uint8 offset) const
Definition: Object.cpp:318

+ Here is the caller graph for this function:

GameObjectValue const* GameObject::GetGOValue ( ) const
inline
896 { return &m_goValue; }
GameObjectValue m_goValue
Definition: GameObject.h:1113

+ Here is the caller graph for this function:

float GameObject::GetInteractionDistance ( ) const
Todo:
find out how the client calculates the maximal usage distance to spellless working
2409 {
2410  switch (GetGoType())
2411  {
2413  // gameobjects like guildbanks and mailboxes - 10.0 is a just an abitrary choosen number
2416  return 10.0f;
2419  return 20.0f + CONTACT_DISTANCE; // max spell range
2420  default:
2421  return INTERACTION_DISTANCE;
2422  }
2423 }
#define INTERACTION_DISTANCE
Definition: Object.h:34
Definition: SharedDefines.h:2082
Definition: SharedDefines.h:2099
Definition: SharedDefines.h:2084
Definition: SharedDefines.h:2090
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
#define CONTACT_DISTANCE
Definition: Object.h:33

+ Here is the call graph for this function:

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

Reimplemented from WorldObject.

1032  {
1033  if (Unit* owner = GetOwner())
1034  return owner->getLevelForTarget(target);
1035 
1036  return 1;
1037  }
Unit * GetOwner() const
Definition: GameObject.cpp:1009
Definition: Unit.h:1305
uint16 GameObject::GetLootMode ( ) const
inline
985 { return m_LootMode; }
uint16 m_LootMode
Definition: GameObject.h:1120
Player * GameObject::GetLootRecipient ( ) const
2228 {
2229  if (!m_lootRecipient)
2230  return NULL;
2232 }
arena_t NULL
Definition: jemalloc_internal.h:624
ObjectGuid m_lootRecipient
Definition: GameObject.h:1118
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

Group * GameObject::GetLootRecipientGroup ( ) const
2235 {
2236  if (!m_lootRecipientGroup)
2237  return NULL;
2238  return sGroupMgr->GetGroupByGUID(m_lootRecipientGroup);
2239 }
arena_t NULL
Definition: jemalloc_internal.h:624
#define sGroupMgr
Definition: GroupMgr.h:59
ObjectGuid m_lootRecipientGroup
Definition: GameObject.h:1119

+ Here is the caller graph for this function:

LootState GameObject::getLootState ( ) const
inline
981 { return m_lootState; }
LootState m_lootState
Definition: GameObject.h:1096

+ Here is the caller graph for this function:

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

Reimplemented from WorldObject.

1931 {
1932  if (loc_idx != DEFAULT_LOCALE)
1933  {
1934  uint8 uloc_idx = uint8(loc_idx);
1935  if (GameObjectLocale const* cl = sObjectMgr->GetGameObjectLocale(GetEntry()))
1936  if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty())
1937  return cl->Name[uloc_idx];
1938  }
1939 
1940  return GetName();
1941 }
std::string const & GetName() const
Definition: Object.h:479
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: GameObject.h:803
uint8_t uint8
Definition: g3dmath.h:164
uint8_t uint8
Definition: Define.h:152
uint32 GetEntry() const
Definition: Object.h:107
#define DEFAULT_LOCALE
Definition: Common.h:134

+ Here is the call graph for this function:

Unit * GameObject::GetOwner ( ) const
1010 {
1011  return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
1012 }
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjectGuid GameObject::GetOwnerGUID ( ) const
inline
Definition: UpdateFields.h:317
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332

+ Here is the caller graph for this function:

uint32 GameObject::GetRespawnDelay ( ) const
inline
959 { return m_respawnDelayTime; }
uint32 m_respawnDelayTime
Definition: GameObject.h:1095

+ Here is the caller graph for this function:

void GameObject::GetRespawnPosition ( float &  x,
float &  y,
float &  z,
float *  ori = NULL 
) const
2387 {
2388  if (m_spawnId)
2389  {
2390  if (GameObjectData const* data = sObjectMgr->GetGOData(GetSpawnId()))
2391  {
2392  x = data->posX;
2393  y = data->posY;
2394  z = data->posZ;
2395  if (ori)
2396  *ori = data->orientation;
2397  return;
2398  }
2399  }
2400 
2401  x = GetPositionX();
2402  y = GetPositionY();
2403  z = GetPositionZ();
2404  if (ori)
2405  *ori = GetOrientation();
2406 }
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:902
#define sObjectMgr
Definition: ObjectMgr.h:1567
float GetOrientation() const
Definition: Position.h:107
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
float GetPositionZ() const
Definition: Position.h:106
G3D::int16 y
Definition: Vector2int16.h:38
Definition: GameObject.h:833
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

time_t GameObject::GetRespawnTime ( ) const
inline
935 { return m_respawnTime; }
time_t m_respawnTime
Definition: GameObject.h:1094

+ Here is the caller graph for this function:

time_t GameObject::GetRespawnTimeEx ( ) const
inline
937  {
938  time_t now = time(NULL);
939  if (m_respawnTime > now)
940  return m_respawnTime;
941  else
942  return now;
943  }
arena_t NULL
Definition: jemalloc_internal.h:624
time_t m_respawnTime
Definition: GameObject.h:1094

+ Here is the caller graph for this function:

uint64 GameObject::GetRotation ( ) const
inline
1059 { return m_rotation; }
uint64 m_rotation
Definition: GameObject.h:1115
virtual uint32 GameObject::GetScriptId ( ) const
inlinevirtual
1060 { return GetGOInfo()->ScriptId; }
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
uint32 ScriptId
Definition: GameObject.h:625

+ Here is the caller graph for this function:

ObjectGuid::LowType GameObject::GetSpawnId ( ) const
inline
902 { return m_spawnId; }
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110

+ Here is the caller graph for this function:

uint32 GameObject::GetSpellId ( ) const
inline
933 { return m_spellId;}
uint32 m_spellId
Definition: GameObject.h:1093

+ Here is the caller graph for this function:

float GameObject::GetStationaryO ( ) const
inlineoverridevirtual

Reimplemented from WorldObject.

Position m_stationaryPosition
Definition: GameObject.h:1116
float GetOrientation() const
Definition: Position.h:107
Definition: SharedDefines.h:2080
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
float GameObject::GetStationaryX ( ) const
inlineoverridevirtual

Reimplemented from WorldObject.

Position m_stationaryPosition
Definition: GameObject.h:1116
Definition: SharedDefines.h:2080
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
float GetPositionX() const
Definition: Position.h:104
float GameObject::GetStationaryY ( ) const
inlineoverridevirtual

Reimplemented from WorldObject.

Position m_stationaryPosition
Definition: GameObject.h:1116
Definition: SharedDefines.h:2080
float GetPositionY() const
Definition: Position.h:105
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
float GameObject::GetStationaryZ ( ) const
inlineoverridevirtual

Reimplemented from WorldObject.

Position m_stationaryPosition
Definition: GameObject.h:1116
Definition: SharedDefines.h:2080
float GetPositionZ() const
Definition: Position.h:106
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
uint32 GameObject::GetTransportPeriod ( ) const
virtual

Reimplemented in Transport.

2156 {
2160 
2161  return 0;
2162 }
TransportAnimation const * AnimationInfo
Definition: GameObject.h:780
struct GameObjectValue::@273 Transport
GameObjectValue m_goValue
Definition: GameObject.h:1113
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
#define ASSERT
Definition: Errors.h:55
Definition: SharedDefines.h:2076
uint32 TotalTime
Definition: TransportMgr.h:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 GameObject::GetUniqueUseCount ( ) const
inline
1003 { return uint32(m_unique_users.size()); }
GuidSet m_unique_users
Definition: GameObject.h:1104
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the caller graph for this function:

uint32 GameObject::GetUseCount ( ) const
inline
1002 { return m_usetimes; }
uint32 m_usetimes
Definition: GameObject.h:1105

+ Here is the caller graph for this function:

bool GameObject::hasInvolvedQuest ( uint32  quest_id) const
overridevirtual

Reimplemented from Object.

969 {
970  QuestRelationBounds qir = sObjectMgr->GetGOQuestInvolvedRelationBounds(GetEntry());
971  for (QuestRelations::const_iterator itr = qir.first; itr != qir.second; ++itr)
972  {
973  if (itr->second == quest_id)
974  return true;
975  }
976  return false;
977 }
std::pair< QuestRelations::const_iterator, QuestRelations::const_iterator > QuestRelationBounds
Definition: ObjectMgr.h:442
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 GetEntry() const
Definition: Object.h:107

+ Here is the call graph for this function:

bool GameObject::HasLootMode ( uint16  lootMode) const
inline
986 { return (m_LootMode & lootMode) != 0; }
uint16 m_LootMode
Definition: GameObject.h:1120
bool GameObject::HasLootRecipient ( ) const
inline
ObjectGuid m_lootRecipientGroup
Definition: GameObject.h:1119
ObjectGuid m_lootRecipient
Definition: GameObject.h:1118
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the caller graph for this function:

bool GameObject::hasQuest ( uint32  quest_id) const
overridevirtual

Reimplemented from Object.

958 {
959  QuestRelationBounds qr = sObjectMgr->GetGOQuestRelationBounds(GetEntry());
960  for (QuestRelations::const_iterator itr = qr.first; itr != qr.second; ++itr)
961  {
962  if (itr->second == quest_id)
963  return true;
964  }
965  return false;
966 }
std::pair< QuestRelations::const_iterator, QuestRelations::const_iterator > QuestRelationBounds
Definition: ObjectMgr.h:442
#define qr(a_type)
Definition: qr.h:2
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 GetEntry() const
Definition: Object.h:107

+ Here is the call graph for this function:

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

Reimplemented from WorldObject.

1032 {
1034  return true;
1035 
1037  return true;
1038 
1039  if (!seer)
1040  return false;
1041 
1042  // Always seen by owner and friendly units
1043  if (!GetOwnerGUID().IsEmpty())
1044  {
1045  if (seer->GetGUID() == GetOwnerGUID())
1046  return true;
1047 
1048  Unit* owner = GetOwner();
1049  if (Unit const* unitSeer = seer->ToUnit())
1050  if (owner && owner->IsFriendlyTo(unitSeer))
1051  return true;
1052  }
1053 
1054  return false;
1055 }
Unit * GetOwner() const
Definition: GameObject.cpp:1009
virtual bool IsAlwaysVisibleFor(WorldObject const *) const
Definition: Object.h:639
bool IsDestructibleBuilding() const
Definition: GameObject.cpp:1000
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7170
bool IsTransport() const
Definition: GameObject.cpp:979
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
Definition: Unit.h:1305
Unit * ToUnit()
Definition: Object.h:197

+ Here is the call graph for this function:

bool GameObject::IsDestructibleBuilding ( ) const
1001 {
1002  GameObjectTemplate const* gInfo = GetGOInfo();
1003  if (!gInfo)
1004  return false;
1005 
1007 }
Definition: GameObject.h:34
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
Definition: SharedDefines.h:2098
uint32 type
Definition: GameObject.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool GameObject::IsDynTransport ( ) const
991 {
992  // If something is marked as a transport, don't transmit an out of range packet for it.
993  GameObjectTemplate const* gInfo = GetGOInfo();
994  if (!gInfo)
995  return false;
996 
998 }
Definition: GameObject.h:34
struct GameObjectValue::@273 Transport
Definition: SharedDefines.h:2080
GameObjectValue m_goValue
Definition: GameObject.h:1113
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
std::vector< uint32 > * StopFrames
Definition: GameObject.h:782
Definition: SharedDefines.h:2076
uint32 type
Definition: GameObject.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

1888 {
1890  if (!info)
1891  return IsWithinDist3d(x, y, z, radius);
1892 
1893  float sinA = std::sin(GetOrientation());
1894  float cosA = std::cos(GetOrientation());
1895  float dx = x - GetPositionX();
1896  float dy = y - GetPositionY();
1897  float dz = z - GetPositionZ();
1898  float dist = std::sqrt(dx*dx + dy*dy);
1901  if (G3D::fuzzyEq(dist, 0.0f))
1902  return true;
1903 
1904  float sinB = dx / dist;
1905  float cosB = dy / dist;
1906  dx = dist * (cosA * cosB + sinA * sinB);
1907  dy = dist * (cosA * sinB - sinA * cosB);
1908  return dx < info->GeoBoxMax.X + radius && dx > info->GeoBoxMin.X - radius
1909  && dy < info->GeoBoxMax.Y + radius && dy > info->GeoBoxMin.Y - radius
1910  && dz < info->GeoBoxMax.Z + radius && dz > info->GeoBoxMin.Z - radius;
1911 }
DBCPosition3D GeoBoxMin
Definition: DBCStructure.h:492
float Z
Definition: DBCEnums.h:36
float Y
Definition: DBCEnums.h:35
uint32 displayId
Definition: GameObject.h:38
GameObjectTemplate const * m_goInfo
Definition: GameObject.h:1111
float GetOrientation() const
Definition: Position.h:107
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
Definition: DBCStructure.h:487
float GetPositionZ() const
Definition: Position.h:106
G3D::int16 y
Definition: Vector2int16.h:38
float X
Definition: DBCEnums.h:34
bool IsWithinDist3d(float x, float y, float z, float dist) const
Definition: Object.cpp:1638
DBCStorage< GameObjectDisplayInfoEntry > sGameObjectDisplayInfoStore(GameObjectDisplayInfofmt)
DBCPosition3D GeoBoxMax
Definition: DBCStructure.h:493
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104
bool fuzzyEq(double a, double b)
Definition: g3dmath.h:857

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool GameObject::IsInSkillupList ( ObjectGuid const playerGuid) const
inline
994  {
995  return m_SkillupList.count(playerGuid) > 0;
996  }
GuidSet m_SkillupList
Definition: GameObject.h:1101

+ Here is the caller graph for this function:

bool GameObject::IsInvisibleDueToDespawn ( ) const
overridevirtual

Reimplemented from WorldObject.

1058 {
1060  return true;
1061 
1062  // Despawned
1063  if (!isSpawned())
1064  return true;
1065 
1066  return false;
1067 }
virtual bool IsInvisibleDueToDespawn() const
Definition: Object.h:640
bool isSpawned() const
Definition: GameObject.h:951

+ Here is the call graph for this function:

bool GameObject::IsLootAllowedFor ( Player const player) const
2267 {
2269  return true;
2270 
2271  if (player->GetGUID() == m_lootRecipient)
2272  return true;
2273 
2274  Group const* playerGroup = player->GetGroup();
2275  if (!playerGroup || playerGroup != GetLootRecipientGroup()) // if we dont have a group we arent the recipient
2276  return false; // if go doesnt have group bound it means it was solo killed by someone else
2277 
2278  return true;
2279 }
Group * GetLootRecipientGroup() const
Definition: GameObject.cpp:2234
ObjectGuid m_lootRecipientGroup
Definition: GameObject.h:1119
ObjectGuid m_lootRecipient
Definition: GameObject.h:1118
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool GameObject::IsNeverVisible ( ) const
overridevirtual

Reimplemented from WorldObject.

1021 {
1023  return true;
1024 
1025  if (GetGoType() == GAMEOBJECT_TYPE_SPELL_FOCUS && GetGOInfo()->spellFocus.serverOnly == 1)
1026  return true;
1027 
1028  return false;
1029 }
virtual bool IsNeverVisible() const
Definition: Object.h:638
Definition: SharedDefines.h:2073
uint32 serverOnly
Definition: GameObject.h:140
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
GameobjectTypes GetGoType() const
Definition: GameObject.h:964

+ Here is the call graph for this function:

bool GameObject::isSpawned ( ) const
inline
952  {
953  return m_respawnDelayTime == 0 ||
954  (m_respawnTime > 0 && !m_spawnedByDefault) ||
956  }
uint32 m_respawnDelayTime
Definition: GameObject.h:1095
time_t m_respawnTime
Definition: GameObject.h:1094
bool m_spawnedByDefault
Definition: GameObject.h:1098

+ Here is the caller graph for this function:

bool GameObject::isSpawnedByDefault ( ) const
inline
957 { return m_spawnedByDefault; }
bool m_spawnedByDefault
Definition: GameObject.h:1098

+ Here is the caller graph for this function:

bool GameObject::IsTransport ( ) const
980 {
981  // If something is marked as a transport, don't transmit an out of range packet for it.
982  GameObjectTemplate const* gInfo = GetGOInfo();
983  if (!gInfo)
984  return false;
985 
987 }
Definition: GameObject.h:34
Definition: SharedDefines.h:2080
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
Definition: SharedDefines.h:2076
uint32 type
Definition: GameObject.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool GameObject::LoadFromDB ( ObjectGuid::LowType  spawnId,
Map map 
)
inline
911 { return LoadGameObjectFromDB(spawnId, map, false); }
bool LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap=true)
Definition: GameObject.cpp:858
bool GameObject::LoadGameObjectFromDB ( ObjectGuid::LowType  spawnId,
Map map,
bool  addToMap = true 
)
859 {
860  GameObjectData const* data = sObjectMgr->GetGOData(spawnId);
861  if (!data)
862  {
863  TC_LOG_ERROR("sql.sql", "Gameobject (GUID: " UI64FMTD ") not found in table `gameobject`, can't load. ", spawnId);
864  return false;
865  }
866 
867  uint32 entry = data->id;
868  //uint32 map_id = data->mapid; // already used before call
869  uint32 phaseMask = data->phaseMask;
870  float x = data->posX;
871  float y = data->posY;
872  float z = data->posZ;
873  float ang = data->orientation;
874 
875  float rotation0 = data->rotation0;
876  float rotation1 = data->rotation1;
877  float rotation2 = data->rotation2;
878  float rotation3 = data->rotation3;
879 
880  uint32 animprogress = data->animprogress;
881  GOState go_state = data->go_state;
882  uint32 artKit = data->artKit;
883 
884  m_spawnId = spawnId;
885  if (!Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit))
886  return false;
887 
888  if (data->phaseid)
889  SetInPhase(data->phaseid, false, true);
890 
891  if (data->phaseGroup)
892  {
893  // Set the gameobject in all the phases of the phasegroup
894  for (auto ph : sDB2Manager.GetPhasesForGroup(data->phaseGroup))
895  SetInPhase(ph, false, true);
896  }
897 
898  if (data->spawntimesecs >= 0)
899  {
900  m_spawnedByDefault = true;
901 
903  {
905  m_respawnDelayTime = 0;
906  m_respawnTime = 0;
907  }
908  else
909  {
912 
913  // ready to respawn
914  if (m_respawnTime && m_respawnTime <= time(NULL))
915  {
916  m_respawnTime = 0;
918  }
919  }
920  }
921  else
922  {
923  m_spawnedByDefault = false;
925  m_respawnTime = 0;
926  }
927 
928  m_goData = data;
929 
930  if (addToMap && !GetMap()->AddToMap(this))
931  return false;
932 
933  return true;
934 }
#define sDB2Manager
Definition: DB2Stores.h:224
float posZ
Definition: GameObject.h:843
float rotation0
Definition: GameObject.h:845
Map * GetMap() const
Definition: Object.h:543
int32 spawntimesecs
Definition: GameObject.h:849
uint32 m_respawnDelayTime
Definition: GameObject.h:1095
float rotation2
Definition: GameObject.h:847
float rotation3
Definition: GameObject.h:848
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 phaseid
Definition: GameObject.h:854
GameObjectData const * m_goData
Definition: GameObject.h:1112
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
float orientation
Definition: GameObject.h:844
#define sObjectMgr
Definition: ObjectMgr.h:1567
time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const
Definition: Map.h:524
time_t m_respawnTime
Definition: GameObject.h:1094
uint8 artKit
Definition: GameObject.h:853
G3D::int16 z
Definition: Vector3int16.h:46
bool GetDespawnPossibility() const
Definition: GameObject.h:672
#define UI64FMTD
Definition: Define.h:137
Definition: SharedDefines.h:2126
uint32_t uint32
Definition: Define.h:150
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
uint32 id
Definition: GameObject.h:838
G3D::int16 y
Definition: Vector2int16.h:38
Definition: UpdateFields.h:319
bool IsDespawnAtAction() const
Definition: GameObject.h:628
GOState
Definition: GameObject.h:820
Definition: GameObject.h:833
bool m_spawnedByDefault
Definition: GameObject.h:1098
bool SetInPhase(uint32 id, bool update, bool apply) override
Definition: GameObject.cpp:2194
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition: GameObject.cpp:173
uint32 animprogress
Definition: GameObject.h:850
float rotation1
Definition: GameObject.h:846
uint32 phaseGroup
Definition: GameObject.h:855
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
float posX
Definition: GameObject.h:841
uint32 phaseMask
Definition: GameObject.h:840
float posY
Definition: GameObject.h:842
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110
GOState go_state
Definition: GameObject.h:851
void RemoveGORespawnTime(ObjectGuid::LowType dbGuid)
Definition: Map.cpp:3619

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GameObject * GameObject::LookupFishingHoleAround ( float  range)
1158 {
1159  GameObject* ok = NULL;
1160 
1162  Cell cell(p);
1163  Trinity::NearestGameObjectFishingHole u_check(*this, range);
1165 
1167  cell.Visit(p, grid_object_checker, *GetMap(), *this, range);
1168 
1169  return ok;
1170 }
Definition: TypeContainerVisitor.h:32
Map * GetMap() const
Definition: Object.h:543
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: GridNotifiers.h:307
Definition: TypeContainer.h:86
float GetPositionY() const
Definition: Position.h:105
Definition: GameObject.h:880
Definition: Cell.h:49
Definition: GridNotifiers.h:647
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::ModifyHealth ( int32  change,
Unit attackerOrHealer = NULL,
uint32  spellId = 0 
)
Todo:
: pass attackerOrHealer instead of player
1974 {
1975  if (!m_goValue.Building.MaxHealth || !change)
1976  return;
1977 
1978  // prevent double destructions of the same object
1979  if (change < 0 && !m_goValue.Building.Health)
1980  return;
1981 
1982  if (int32(m_goValue.Building.Health) + change <= 0)
1986  else
1987  m_goValue.Building.Health += change;
1988 
1989  // Set the health bar, value = 255 * healthPct;
1991 
1992  Player* player = attackerOrHealer ? attackerOrHealer->GetCharmerOrOwnerPlayerOrPlayerItself() : NULL;
1993 
1994  // dealing damage, send packet
1995  if (player)
1996  {
1998  packet.Caster = attackerOrHealer->GetGUID(); // todo: this can be a GameObject
1999  packet.Target = GetGUID();
2000  packet.Damage = -change;
2001  packet.Owner = player->GetGUID();
2002  packet.SpellID = spellId;
2003  player->SendDirectMessage(packet.Write());
2004  }
2005 
2007 
2008  if (!m_goValue.Building.Health)
2009  newState = GO_DESTRUCTIBLE_DESTROYED;
2010  else if (m_goValue.Building.Health <= 10000/*GetGOInfo()->destructibleBuilding.damagedNumHits*/) // TODO: Get health somewhere
2011  newState = GO_DESTRUCTIBLE_DAMAGED;
2013  newState = GO_DESTRUCTIBLE_INTACT;
2014 
2015  if (newState == GetDestructibleState())
2016  return;
2017 
2019  SetDestructibleState(newState, player, false);
2020 }
arena_t NULL
Definition: jemalloc_internal.h:624
GameObjectDestructibleState GetDestructibleState() const
Definition: GameObject.h:1048
struct GameObjectValue::@276 Building
void SetGoAnimProgress(uint8 animprogress)
Definition: GameObject.h:973
ObjectGuid Caster
Definition: GameObjectPackets.h:90
Definition: SharedDefines.h:2145
Definition: SharedDefines.h:2144
Definition: SharedDefines.h:2146
GameObjectValue m_goValue
Definition: GameObject.h:1113
int32 SpellID
Definition: GameObjectPackets.h:93
int32_t int32
Definition: Define.h:146
int32 Damage
Definition: GameObjectPackets.h:92
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid Target
Definition: GameObjectPackets.h:89
uint32 Health
Definition: GameObject.h:798
int32_t int32
Definition: g3dmath.h:167
WorldPacket const * Write() override
Definition: GameObjectPackets.cpp:52
GameObjectDestructibleState
Definition: SharedDefines.h:2142
void SetDestructibleState(GameObjectDestructibleState state, Player *eventInvoker=NULL, bool setHealth=false)
Definition: GameObject.cpp:2022
uint32 MaxHealth
Definition: GameObject.h:799
ObjectGuid Owner
Definition: GameObjectPackets.h:91
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::Refresh ( )
711 {
712  // Do not refresh despawned GO from spellcast (GO's from spellcast are destroyed after despawn)
714  return;
715 
716  if (isSpawned())
717  GetMap()->AddToMap(this);
718 }
Map * GetMap() const
Definition: Object.h:543
time_t m_respawnTime
Definition: GameObject.h:1094
bool AddToMap(T *)
Definition: Map.cpp:566
bool isSpawned() const
Definition: GameObject.h:951
bool m_spawnedByDefault
Definition: GameObject.h:1098

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::RelocateStationaryPosition ( float  x,
float  y,
float  z,
float  o 
)
inline
1080 { m_stationaryPosition.Relocate(x, y, z, o); }
Position m_stationaryPosition
Definition: GameObject.h:1116
void Relocate(float x, float y)
Definition: Position.h:67
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the caller graph for this function:

void GameObject::RemoveFromOwner ( )
private
107 {
108  ObjectGuid ownerGUID = GetOwnerGUID();
109  if (!ownerGUID)
110  return;
111 
112  if (Unit* owner = ObjectAccessor::GetUnit(*this, ownerGUID))
113  {
114  owner->RemoveGameObject(this, false);
115  ASSERT(!GetOwnerGUID());
116  return;
117  }
118 
119  // This happens when a mage portal is despawned after the caster changes map (for example using the portal)
120  TC_LOG_DEBUG("misc", "Removed GameObject (%s SpellId: %u LinkedGO: %u) that just lost any reference to the owner (%s) GO list",
121  GetGUID().ToString().c_str(), m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), ownerGUID.ToString().c_str());
123 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
std::string ToString() const
Definition: Position.cpp:160
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 m_spellId
Definition: GameObject.h:1093
#define ASSERT
Definition: Errors.h:55
Definition: ObjectGuid.h:189
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99
void SetOwnerGUID(ObjectGuid owner)
Definition: GameObject.h:915

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Reimplemented from WorldObject.

153 {
155  if (IsInWorld())
156  {
157  if (m_zoneScript)
159 
160  RemoveFromOwner();
161  if (m_model)
162  if (GetMap()->ContainsGameObjectModel(*m_model))
164 
166 
167  if (m_spawnId)
168  Trinity::Containers::MultimapErasePair(GetMap()->GetGameObjectBySpawnIdStore(), m_spawnId, this);
170  }
171 }
Map * GetMap() const
Definition: Object.h:543
void RemoveGameObjectModel(const GameObjectModel &model)
Definition: Map.h:505
void RemoveFromOwner()
Definition: GameObject.cpp:106
GameObjectModel * m_model
Definition: GameObject.h:1070
ZoneScript * m_zoneScript
Definition: Object.h:627
virtual void OnGameObjectRemove(GameObject *)
Definition: ZoneScript.h:39
virtual void RemoveFromWorld() override
Definition: Object.cpp:1515
Definition: GameObject.h:880
MapStoredObjectTypesContainer & GetObjectsStore()
Definition: Map.h:466
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void MultimapErasePair(M< K, V, Rest...> &multimap, K const &key, V const &value)
Definition: Containers.h:149
bool Remove(KEY_TYPE const &handle)
Definition: TypeContainer.h:125
bool IsInWorld() const
Definition: Object.h:100
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::RemoveLootMode ( uint16  lootMode)
inline
989 { m_LootMode &= ~lootMode; }
uint16 m_LootMode
Definition: GameObject.h:1120
void GameObject::ResetDoorOrButton ( )
1173 {
1175  return;
1176 
1177  SwitchDoorOrButton(false);
1179  m_cooldownTime = 0;
1180 }
LootState m_lootState
Definition: GameObject.h:1096
void SwitchDoorOrButton(bool activate, bool alternative=false)
Definition: GameObject.cpp:1219
Definition: GameObject.h:871
time_t m_cooldownTime
Definition: GameObject.h:1099
void SetLootState(LootState s, Unit *unit=NULL)
Definition: GameObject.cpp:2112
Definition: GameObject.h:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::ResetLootMode ( )
inline
Definition: SharedDefines.h:69
uint16 m_LootMode
Definition: GameObject.h:1120

+ Here is the caller graph for this function:

void GameObject::Respawn ( )
1070 {
1071  if (m_spawnedByDefault && m_respawnTime > 0)
1072  {
1073  m_respawnTime = time(NULL);
1075  }
1076 }
Map * GetMap() const
Definition: Object.h:543
arena_t NULL
Definition: jemalloc_internal.h:624
time_t m_respawnTime
Definition: GameObject.h:1094
bool m_spawnedByDefault
Definition: GameObject.h:1098
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110
void RemoveGORespawnTime(ObjectGuid::LowType dbGuid)
Definition: Map.cpp:3619

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SaveRespawnTime ( )
overridevirtual

Reimplemented from WorldObject.

1015 {
1018 }
Map * GetMap() const
Definition: Object.h:543
void SaveGORespawnTime(ObjectGuid::LowType dbGuid, time_t respawnTime)
Definition: Map.cpp:3600
arena_t NULL
Definition: jemalloc_internal.h:624
GameObjectData const * m_goData
Definition: GameObject.h:1112
time_t m_respawnTime
Definition: GameObject.h:1094
bool m_spawnedByDefault
Definition: GameObject.h:1098
bool dbData
Definition: GameObject.h:856
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SaveToDB ( )
784 {
785  // this should only be used when the gameobject has already been loaded
786  // preferably after adding to map, because mapid may not be valid otherwise
787  GameObjectData const* data = sObjectMgr->GetGOData(m_spawnId);
788  if (!data)
789  {
790  TC_LOG_ERROR("misc", "GameObject::SaveToDB failed, cannot get gameobject data!");
791  return;
792  }
793 
794  SaveToDB(GetMapId(), data->spawnMask, data->phaseMask);
795 }
uint32 spawnMask
Definition: GameObject.h:852
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 GetMapId() const
Definition: Position.h:254
Definition: GameObject.h:833
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SaveToDB()
Definition: GameObject.cpp:783
uint32 phaseMask
Definition: GameObject.h:840
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110

+ Here is the call graph for this function:

void GameObject::SaveToDB ( uint32  mapid,
uint32  spawnMask,
uint32  phaseMask 
)
798 {
799  const GameObjectTemplate* goI = GetGOInfo();
800 
801  if (!goI)
802  return;
803 
804  if (!m_spawnId)
805  m_spawnId = sObjectMgr->GenerateGameObjectSpawnId();
806 
807  // update in loaded data (changing data only in this place)
808  GameObjectData& data = sObjectMgr->NewGOData(m_spawnId);
809 
810  // data->guid = guid must not be updated at save
811  data.id = GetEntry();
812  data.mapid = mapid;
813  data.phaseMask = phaseMask;
814  data.posX = GetPositionX();
815  data.posY = GetPositionY();
816  data.posZ = GetPositionZ();
817  data.orientation = GetOrientation();
824  data.go_state = GetGoState();
825  data.spawnMask = spawnMask;
826  data.artKit = GetGoArtKit();
827 
828  // Update in DB
830 
831  uint8 index = 0;
832 
834  stmt->setUInt64(0, m_spawnId);
835  trans->Append(stmt);
836 
838  stmt->setUInt64(index++, m_spawnId);
839  stmt->setUInt32(index++, GetEntry());
840  stmt->setUInt16(index++, uint16(mapid));
841  stmt->setUInt8(index++, spawnMask);
842  stmt->setFloat(index++, GetPositionX());
843  stmt->setFloat(index++, GetPositionY());
844  stmt->setFloat(index++, GetPositionZ());
845  stmt->setFloat(index++, GetOrientation());
850  stmt->setInt32(index++, int32(m_respawnDelayTime));
851  stmt->setUInt8(index++, GetGoAnimProgress());
852  stmt->setUInt8(index++, uint8(GetGoState()));
853  trans->Append(stmt);
854 
856 }
uint32 spawnMask
Definition: GameObject.h:852
float posZ
Definition: GameObject.h:843
Definition: UpdateFields.h:320
float rotation0
Definition: GameObject.h:845
GOState GetGoState() const
Definition: GameObject.h:966
int32 spawntimesecs
Definition: GameObject.h:849
uint32 m_respawnDelayTime
Definition: GameObject.h:1095
float rotation2
Definition: GameObject.h:847
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
float rotation3
Definition: GameObject.h:848
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: GameObject.h:34
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: WorldDatabase.h:38
float orientation
Definition: GameObject.h:844
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint16_t uint16
Definition: g3dmath.h:166
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
float GetOrientation() const
Definition: Position.h:107
uint8 artKit
Definition: GameObject.h:853
float GetPositionY() const
Definition: Position.h:105
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
float GetPositionZ() const
Definition: Position.h:106
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
uint32 id
Definition: GameObject.h:838
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setInt32(const uint8 index, const int32 value)
Definition: PreparedStatement.cpp:151
Definition: WorldDatabase.h:95
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: GameObject.h:833
uint8_t uint8
Definition: g3dmath.h:164
bool m_spawnedByDefault
Definition: GameObject.h:1098
uint8 GetGoAnimProgress() const
Definition: GameObject.h:972
uint16 mapid
Definition: GameObject.h:839
uint32 animprogress
Definition: GameObject.h:850
uint8 GetGoArtKit() const
Definition: GameObject.h:970
void setFloat(const uint8 index, const float value)
Definition: PreparedStatement.cpp:169
int32_t int32
Definition: g3dmath.h:167
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
float rotation1
Definition: GameObject.h:846
uint8_t uint8
Definition: Define.h:152
uint32 GetEntry() const
Definition: Object.h:107
float posX
Definition: GameObject.h:841
float GetPositionX() const
Definition: Position.h:104
uint32 phaseMask
Definition: GameObject.h:840
float posY
Definition: GameObject.h:842
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110
GOState go_state
Definition: GameObject.h:851
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

void GameObject::SendCustomAnim ( uint32  anim)
1880 {
1882  customAnim.ObjectGUID = GetGUID();
1883  customAnim.CustomAnim = anim;
1884  SendMessageToSet(customAnim.Write(), true);
1885 }
Definition: GameObjectPackets.h:112
WorldPacket const * Write() override
Definition: GameObjectPackets.cpp:63
ObjectGuid ObjectGUID
Definition: GameObjectPackets.h:119
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
uint32 CustomAnim
Definition: GameObjectPackets.h:120

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SetAnimKitId ( uint16  animKitId,
bool  oneshot 
)
2439 {
2440  if (_animKitId == animKitId)
2441  return;
2442 
2443  if (animKitId && !sAnimKitStore.LookupEntry(animKitId))
2444  return;
2445 
2446  if (!oneshot)
2447  _animKitId = animKitId;
2448  else
2449  _animKitId = 0;
2450 
2452  activateAnimKit.ObjectGUID = GetGUID();
2453  activateAnimKit.AnimKitID = animKitId;
2454  activateAnimKit.Maintain = !oneshot;
2455  SendMessageToSet(activateAnimKit.Write(), true);
2456 }
ObjectGuid ObjectGUID
Definition: GameObjectPackets.h:77
int32 AnimKitID
Definition: GameObjectPackets.h:78
Definition: GameObjectPackets.h:70
bool Maintain
Definition: GameObjectPackets.h:79
ObjectGuid const & GetGUID() const
Definition: Object.h:105
DBCStorage< AnimKitEntry > sAnimKitStore(AnimKitfmt)
WorldPacket const * Write() override
Definition: GameObjectPackets.cpp:42
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
uint16 _animKitId
Definition: GameObject.h:1133

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SetDestructibleState ( GameObjectDestructibleState  state,
Player eventInvoker = NULL,
bool  setHealth = false 
)
2023 {
2024  // the user calling this must know he is already operating on destructible gameobject
2026 
2027  switch (state)
2028  {
2032  if (setHealth)
2033  {
2035  SetGoAnimProgress(255);
2036  }
2037  EnableCollision(true);
2038  break;
2040  {
2041  EventInform(m_goInfo->destructibleBuilding.DamagedEvent, eventInvoker);
2042  sScriptMgr->OnGameObjectDamaged(this, eventInvoker);
2043 
2046 
2047  uint32 modelId = m_goInfo->displayId;
2048  if (DestructibleModelDataEntry const* modelData = sDestructibleModelDataStore.LookupEntry(m_goInfo->destructibleBuilding.DestructibleModelRec))
2049  if (modelData->StateDamaged.DisplayID)
2050  modelId = modelData->StateDamaged.DisplayID;
2051  SetDisplayId(modelId);
2052 
2053  if (setHealth)
2054  {
2055  m_goValue.Building.Health = 10000/*m_goInfo->destructibleBuilding.damagedNumHits*/;
2056  uint32 maxHealth = m_goValue.Building.MaxHealth;
2057  // in this case current health is 0 anyway so just prevent crashing here
2058  if (!maxHealth)
2059  maxHealth = 1;
2060  SetGoAnimProgress(m_goValue.Building.Health * 255 / maxHealth);
2061  }
2062  break;
2063  }
2065  {
2066  sScriptMgr->OnGameObjectDestroyed(this, eventInvoker);
2067  EventInform(m_goInfo->destructibleBuilding.DestroyedEvent, eventInvoker);
2068  if (eventInvoker)
2069  if (Battleground* bg = eventInvoker->GetBattleground())
2070  bg->DestroyGate(eventInvoker, this);
2071 
2074 
2075  uint32 modelId = m_goInfo->displayId;
2076  if (DestructibleModelDataEntry const* modelData = sDestructibleModelDataStore.LookupEntry(m_goInfo->destructibleBuilding.DestructibleModelRec))
2077  if (modelData->StateDestroyed.DisplayID)
2078  modelId = modelData->StateDestroyed.DisplayID;
2079  SetDisplayId(modelId);
2080 
2081  if (setHealth)
2082  {
2084  SetGoAnimProgress(0);
2085  }
2086  EnableCollision(false);
2087  break;
2088  }
2090  {
2091  EventInform(m_goInfo->destructibleBuilding.RebuildingEvent, eventInvoker);
2093 
2094  uint32 modelId = m_goInfo->displayId;
2095  if (DestructibleModelDataEntry const* modelData = sDestructibleModelDataStore.LookupEntry(m_goInfo->destructibleBuilding.DestructibleModelRec))
2096  if (modelData->StateRebuilding.DisplayID)
2097  modelId = modelData->StateRebuilding.DisplayID;
2098  SetDisplayId(modelId);
2099 
2100  // restores to full health
2101  if (setHealth)
2102  {
2104  SetGoAnimProgress(255);
2105  }
2106  EnableCollision(true);
2107  break;
2108  }
2109  }
2110 }
void EventInform(uint32 eventId, WorldObject *invoker=NULL)
Definition: GameObject.cpp:1913
struct GameObjectValue::@276 Building
uint32 displayId
Definition: GameObject.h:38
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
void SetGoAnimProgress(uint8 animprogress)
Definition: GameObject.h:973
GameObjectTemplate const * m_goInfo
Definition: GameObject.h:1111
Definition: DB2Structure.h:354
Definition: SharedDefines.h:2128
Definition: SharedDefines.h:2145
Definition: SharedDefines.h:2144
void SetDisplayId(uint32 displayid)
Definition: GameObject.cpp:2188
Definition: SharedDefines.h:2146
GameObjectValue m_goValue
Definition: GameObject.h:1113
Definition: SharedDefines.h:2129
DB2Storage< DestructibleModelDataEntry > sDestructibleModelDataStore("DestructibleModelData.db2", DestructibleModelDataFormat, HOTFIX_SEL_DESTRUCTIBLE_MODEL_DATA)
uint32_t uint32
Definition: Define.h:150
void EnableCollision(bool enable)
Definition: GameObject.cpp:2203
Definition: UpdateFields.h:319
struct GameObjectTemplate::@221::@256 destructibleBuilding
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
uint32 Health
Definition: GameObject.h:798
#define ASSERT
Definition: Errors.h:55
Definition: Battleground.h:235
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: SharedDefines.h:2098
uint32 MaxHealth
Definition: GameObject.h:799
Definition: SharedDefines.h:2147

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SetDisplayId ( uint32  displayid)
2189 {
2191  UpdateModel();
2192 }
void UpdateModel()
Definition: GameObject.cpp:2214
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: UpdateFields.h:318

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SetFaction ( uint32  faction)
inline
1068 { SetUInt32Value(GAMEOBJECT_FACTION, faction); }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: UpdateFields.h:321

+ Here is the caller graph for this function:

void GameObject::SetGoAnimProgress ( uint8  animprogress)
inline
973 { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
Definition: UpdateFields.h:323
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080

+ Here is the caller graph for this function:

void GameObject::SetGoArtKit ( uint8  artkit)
1197 {
1199  GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr->GetGOData(m_spawnId));
1200  if (data)
1201  data->artKit = kit;
1202 }
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint8 artKit
Definition: GameObject.h:853
Definition: UpdateFields.h:323
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080
Definition: GameObject.h:833
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SetGoArtKit ( uint8  artkit,
GameObject go,
ObjectGuid::LowType  lowguid = UI64LIT(0) 
)
static
1205 {
1206  const GameObjectData* data = NULL;
1207  if (go)
1208  {
1209  go->SetGoArtKit(artkit);
1210  data = go->GetGOData();
1211  }
1212  else if (lowguid)
1213  data = sObjectMgr->GetGOData(lowguid);
1214 
1215  if (data)
1216  const_cast<GameObjectData*>(data)->artKit = artkit;
1217 }
GameObjectData const * GetGOData() const
Definition: GameObject.h:895
arena_t NULL
Definition: jemalloc_internal.h:624
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: GameObject.h:833
void SetGoArtKit(uint8 artkit)
Definition: GameObject.cpp:1196

+ Here is the call graph for this function:

void GameObject::SetGoState ( GOState  state)
2138 {
2139  SetByteValue(GAMEOBJECT_BYTES_1, 0, state);
2140  sScriptMgr->OnGameObjectStateChanged(this, state);
2141  if (m_model && !IsTransport())
2142  {
2143  if (!IsInWorld())
2144  return;
2145 
2146  // startOpen determines whether we are going to add or remove the LoS on activation
2147  bool collision = false;
2148  if (state == GO_STATE_READY)
2149  collision = !collision;
2150 
2151  EnableCollision(collision);
2152  }
2153 }
GameObjectModel * m_model
Definition: GameObject.h:1070
Definition: UpdateFields.h:323
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080
bool IsTransport() const
Definition: GameObject.cpp:979
void EnableCollision(bool enable)
Definition: GameObject.cpp:2203
Definition: GameObject.h:823
#define sScriptMgr
Definition: ScriptMgr.h:837
bool IsInWorld() const
Definition: Object.h:100

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SetGoType ( GameobjectTypes  type)
inline
965 { SetByteValue(GAMEOBJECT_BYTES_1, 1, type); }
Definition: UpdateFields.h:323
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:1080

+ Here is the caller graph for this function:

bool GameObject::SetInPhase ( uint32  id,
bool  update,
bool  apply 
)
overridevirtual

Reimplemented from WorldObject.

2195 {
2196  bool res = WorldObject::SetInPhase(id, update, apply);
2197  if (m_model && m_model->isEnabled())
2198  EnableCollision(true);
2199 
2200  return res;
2201 }
void apply(T *val)
Definition: ByteConverter.h:41
bool isEnabled() const
Definition: GameObjectModel.h:66
GameObjectModel * m_model
Definition: GameObject.h:1070
virtual bool SetInPhase(uint32 id, bool update, bool apply)
Definition: Object.cpp:2879
void EnableCollision(bool enable)
Definition: GameObject.cpp:2203

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SetLootMode ( uint16  lootMode)
inline
987 { m_LootMode = lootMode; }
uint16 m_LootMode
Definition: GameObject.h:1120
void GameObject::SetLootRecipient ( Unit unit)
2242 {
2243  // set the player whose group should receive the right
2244  // to loot the creature after it dies
2245  // should be set to NULL after the loot disappears
2246 
2247  if (!unit)
2248  {
2251  return;
2252  }
2253 
2254  if (unit->GetTypeId() != TYPEID_PLAYER && !unit->IsVehicle())
2255  return;
2256 
2258  if (!player) // normal creature, no player involved
2259  return;
2260 
2261  m_lootRecipient = player->GetGUID();
2262  if (Group* group = player->GetGroup())
2263  m_lootRecipientGroup = group->GetGUID();
2264 }
bool IsVehicle() const
Definition: Unit.h:1406
TypeID GetTypeId() const
Definition: Object.h:113
void Clear()
Definition: ObjectGuid.h:215
Definition: ObjectGuid.h:33
ObjectGuid m_lootRecipientGroup
Definition: GameObject.h:1119
ObjectGuid m_lootRecipient
Definition: GameObject.h:1118
Definition: Group.h:191
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Unit.cpp:7560

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SetLootState ( LootState  s,
Unit unit = NULL 
)
2113 {
2114  m_lootState = state;
2115  if (unit)
2116  m_lootStateUnitGUID = unit->GetGUID();
2117  else
2119 
2120  AI()->OnStateChanged(state, unit);
2121  sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
2122 
2123  if (GetGoType() == GAMEOBJECT_TYPE_DOOR) // only set collision for doors on SetGoState
2124  return;
2125 
2126  if (m_model)
2127  {
2128  bool collision = false;
2129  // Use the current go state
2130  if ((GetGoState() != GO_STATE_READY && (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED)) || state == GO_READY)
2131  collision = !collision;
2132 
2133  EnableCollision(collision);
2134  }
2135 }
LootState m_lootState
Definition: GameObject.h:1096
GameObjectAI * AI() const
Definition: GameObject.h:1061
virtual void OnStateChanged(uint32, Unit *)
Definition: GameObjectAI.h:62
Definition: GameObject.h:871
GOState GetGoState() const
Definition: GameObject.h:966
ObjectGuid m_lootStateUnitGUID
Definition: GameObject.h:1097
Definition: GameObject.h:870
GameObjectModel * m_model
Definition: GameObject.h:1070
void EnableCollision(bool enable)
Definition: GameObject.cpp:2203
Definition: GameObject.h:823
void Clear()
Definition: ObjectGuid.h:215
ObjectGuid const & GetGUID() const
Definition: Object.h:105
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: GameObject.h:869
Definition: SharedDefines.h:2065

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SetOwnerGUID ( ObjectGuid  owner)
inline
916  {
917  // Owner already found and different than expected owner - remove object from old owner
918  if (!owner.IsEmpty() && !GetOwnerGUID().IsEmpty() && GetOwnerGUID() != owner)
919  {
920  ABORT();
921  }
922  m_spawnedByDefault = false; // all object with owner is despawned after delay
924  }
Definition: UpdateFields.h:317
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
bool m_spawnedByDefault
Definition: GameObject.h:1098
#define ABORT
Definition: Errors.h:56
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SetRespawnTime ( int32  respawn)
inline
946  {
947  m_respawnTime = respawn > 0 ? time(NULL) + respawn : 0;
948  m_respawnDelayTime = respawn > 0 ? respawn : 0;
949  }
uint32 m_respawnDelayTime
Definition: GameObject.h:1095
arena_t NULL
Definition: jemalloc_internal.h:624
time_t m_respawnTime
Definition: GameObject.h:1094

+ Here is the caller graph for this function:

void GameObject::SetSpawnedByDefault ( bool  b)
inline
958 { m_spawnedByDefault = b; }
bool m_spawnedByDefault
Definition: GameObject.h:1098

+ Here is the caller graph for this function:

void GameObject::SetSpellId ( uint32  id)
inline
929  {
930  m_spawnedByDefault = false; // all summoned object is despawned after delay
931  m_spellId = id;
932  }
bool m_spawnedByDefault
Definition: GameObject.h:1098
uint32 m_spellId
Definition: GameObject.h:1093

+ Here is the caller graph for this function:

void GameObject::SetTransportState ( GOState  state,
uint32  stopFrame = 0 
)
2165 {
2166  if (GetGoState() == state)
2167  return;
2168 
2171  if (state == GO_STATE_TRANSPORT_ACTIVE)
2172  {
2178  }
2179  else
2180  {
2182  ASSERT(stopFrame < m_goValue.Transport.StopFrames->size());
2185  }
2186 }
Definition: GameObject.h:825
GOState GetGoState() const
Definition: GameObject.h:966
Definition: GameObject.h:826
uint32 getMSTime()
Definition: Timer.h:24
struct GameObjectValue::@273 Transport
uint32 StateUpdateTimer
Definition: GameObject.h:783
GameObjectValue m_goValue
Definition: GameObject.h:1113
#define MAX_GO_STATE_TRANSPORT_STOP_FRAMES
Definition: GameObject.h:830
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
std::vector< uint32 > * StopFrames
Definition: GameObject.h:782
GOState
Definition: GameObject.h:820
void SetGoState(GOState state)
Definition: GameObject.cpp:2137
#define ASSERT
Definition: Errors.h:55
uint32 PathProgress
Definition: GameObject.h:779
Definition: SharedDefines.h:2076

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::SwitchDoorOrButton ( bool  activate,
bool  alternative = false 
)
private
1220 {
1221  if (activate)
1223  else
1225 
1226  if (GetGoState() == GO_STATE_READY) //if closed -> open
1228  else //if open -> close
1230 }
GOState GetGoState() const
Definition: GameObject.h:966
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
Definition: SharedDefines.h:2121
Definition: GameObject.h:824
Definition: UpdateFields.h:319
Definition: GameObject.h:822
Definition: GameObject.h:823
void SetGoState(GOState state)
Definition: GameObject.cpp:2137
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Transport* GameObject::ToTransport ( )
inline
1073 { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT) return reinterpret_cast<Transport*>(this); else return NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Transport.h:28
Definition: SharedDefines.h:2080
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894

+ Here is the caller graph for this function:

Transport const* GameObject::ToTransport ( ) const
inline
1074 { if (GetGOInfo()->type == GAMEOBJECT_TYPE_MAP_OBJ_TRANSPORT) return reinterpret_cast<Transport const*>(this); else return NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Transport.h:28
Definition: SharedDefines.h:2080
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
#define const
Definition: zconf.h:217
void GameObject::TriggeringLinkedGameObject ( uint32  trapEntry,
Unit target 
)
1127 {
1128  GameObjectTemplate const* trapInfo = sObjectMgr->GetGameObjectTemplate(trapEntry);
1129  if (!trapInfo || trapInfo->type != GAMEOBJECT_TYPE_TRAP)
1130  return;
1131 
1132  SpellInfo const* trapSpell = sSpellMgr->GetSpellInfo(trapInfo->trap.spell);
1133  if (!trapSpell) // checked at load already
1134  return;
1135 
1136  float range = float(target->GetSpellMaxRangeForTarget(GetOwner(), trapSpell));
1137 
1138  // search nearest linked GO
1139  GameObject* trapGO = NULL;
1140  {
1141  // using original GO distance
1143  Cell cell(p);
1144 
1145  Trinity::NearestGameObjectEntryInObjectRangeCheck go_check(*target, trapEntry, range);
1147 
1149  cell.Visit(p, object_checker, *GetMap(), *target, range);
1150  }
1151 
1152  // found correct GO
1153  if (trapGO)
1154  trapGO->CastSpell(target, trapInfo->trap.spell);
1155 }
Unit * GetOwner() const
Definition: GameObject.cpp:1009
Definition: TypeContainerVisitor.h:32
Map * GetMap() const
Definition: Object.h:543
Definition: GridNotifiers.h:323
Definition: SpellInfo.h:326
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
Definition: GameObject.h:34
arena_t NULL
Definition: jemalloc_internal.h:624
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: TypeContainer.h:86
struct GameObjectTemplate::@221::@229 trap
float GetPositionY() const
Definition: Position.h:105
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: GameObject.h:880
Definition: Cell.h:49
float GetPositionX() const
Definition: Position.h:104
Definition: SharedDefines.h:2071
float GetSpellMaxRangeForTarget(Unit const *target, SpellInfo const *spellInfo) const
Definition: Unit.cpp:11228
uint32 type
Definition: GameObject.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::Update ( uint32  p_time)
overridevirtual
Todo:
This is activation radius. Casting radius must be selected from spell data.
Todo:
this hack with search required until GO casting not implemented
Todo:
NULL target won't work for target type 1

If this is summoned by a spell with ie. SPELL_EFFECT_SUMMON_OBJECT_WILD, with or without owner, we check respawn criteria based on spell The GetOwnerGUID() check is mostly for compatibility with hacky scripts - 99% of the time summoning should be done trough spells.

Reimplemented from WorldObject.

Reimplemented in Transport.

332 {
333  if (AI())
334  AI()->UpdateAI(diff);
335  else if (!AIM_Initialize())
336  TC_LOG_ERROR("misc", "Could not initialize GameObjectAI");
337 
338  switch (m_lootState)
339  {
340  case GO_NOT_READY:
341  {
342  switch (GetGoType())
343  {
345  {
346  // Arming Time for GAMEOBJECT_TYPE_TRAP (6)
347  GameObjectTemplate const* goInfo = GetGOInfo();
348  // Bombs
349  if (goInfo->trap.charges == 2)
350  // Hardcoded tooltip value
351  m_cooldownTime = time(NULL) + 10;
352  else if (Unit* owner = GetOwner())
353  if (owner->IsInCombat())
354  m_cooldownTime = time(NULL) + goInfo->trap.startDelay;
355 
357  break;
358  }
360  {
362  break;
363 
365  {
367  /* TODO: Fix movement in unloaded grid - currently GO will just disappear
368  uint32 timer = m_goValue.Transport.PathProgress % GetTransportPeriod();
369  TransportAnimationEntry const* node = m_goValue.Transport.AnimationInfo->GetAnimNode(timer);
370  if (node && m_goValue.Transport.CurrentSeg != node->TimeSeg)
371  {
372  m_goValue.Transport.CurrentSeg = node->TimeSeg;
373 
374  G3D::Quat rotation = m_goValue.Transport.AnimationInfo->GetAnimRotation(timer);
375  G3D::Vector3 pos = rotation.toRotationMatrix()
376  * G3D::Matrix3::fromEulerAnglesZYX(GetOrientation(), 0.0f, 0.0f)
377  * G3D::Vector3(node->X, node->Y, node->Z);
378 
379  pos += G3D::Vector3(GetStationaryX(), GetStationaryY(), GetStationaryZ());
380 
381  G3D::Vector3 src(GetPositionX(), GetPositionY(), GetPositionZ());
382 
383  TC_LOG_DEBUG("misc", "Src: %s Dest: %s", src.toString().c_str(), pos.toString().c_str());
384 
385  GetMap()->GameObjectRelocation(this, pos.x, pos.y, pos.z, GetOrientation());
386  }
387  */
388 
389  if (!m_goValue.Transport.StopFrames->empty())
390  {
391  uint32 visualStateBefore = (m_goValue.Transport.StateUpdateTimer / 20000) & 1;
393  uint32 visualStateAfter = (m_goValue.Transport.StateUpdateTimer / 20000) & 1;
394  if (visualStateBefore != visualStateAfter)
395  {
398  }
399  }
400  }
401  break;
402  }
404  {
405  // fishing code (bobber ready)
407  {
408  // splash bobber (bobber ready now)
409  Unit* caster = GetOwner();
410  if (caster && caster->GetTypeId() == TYPEID_PLAYER)
411  {
414 
415  UpdateData udata(caster->GetMapId());
416  WorldPacket packet;
417  BuildValuesUpdateBlockForPlayer(&udata, caster->ToPlayer());
418  udata.BuildPacket(&packet);
419  caster->ToPlayer()->SendDirectMessage(&packet);
420 
422  }
423 
424  m_lootState = GO_READY; // can be successfully open with some chance
425  }
426  return;
427  }
428  default:
429  m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY
430  break;
431  }
432  // NO BREAK for switch (m_lootState)
433  }
434  case GO_READY:
435  {
436  if (m_respawnTime > 0) // timer on
437  {
438  time_t now = time(NULL);
439  if (m_respawnTime <= now) // timer expired
440  {
441  ObjectGuid dbtableHighGuid = ObjectGuid::Create<HighGuid::GameObject>(GetMapId(), GetEntry(), m_spawnId);
442  time_t linkedRespawntime = GetMap()->GetLinkedRespawnTime(dbtableHighGuid);
443  if (linkedRespawntime) // Can't respawn, the master is dead
444  {
445  ObjectGuid targetGuid = sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid);
446  if (targetGuid == dbtableHighGuid) // if linking self, never respawn (check delayed to next day)
448  else
449  m_respawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // else copy time from master and add a little
450  SaveRespawnTime(); // also save to DB immediately
451  return;
452  }
453 
454  m_respawnTime = 0;
455  m_SkillupList.clear();
456  m_usetimes = 0;
457 
458  switch (GetGoType())
459  {
460  case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
461  {
462  Unit* caster = GetOwner();
463  if (caster && caster->GetTypeId() == TYPEID_PLAYER)
464  {
465  caster->ToPlayer()->RemoveGameObject(this, false);
466  caster->ToPlayer()->SendDirectMessage(WorldPackets::GameObject::FishEscaped().Write());
467  }
468  // can be delete
470  return;
471  }
474  // 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)
475  if (GetGoState() != GO_STATE_READY)
477  break;
479  // Initialize a new max fish count on respawn
480  m_goValue.FishingHole.MaxOpens = urand(GetGOInfo()->fishingHole.minRestock, GetGOInfo()->fishingHole.maxRestock);
481  break;
482  default:
483  break;
484  }
485 
486  // Despawn timer
487  if (!m_spawnedByDefault)
488  {
489  // Can be despawned or destroyed
491  return;
492  }
493 
494  // Respawn timer
495  uint32 poolid = GetSpawnId() ? sPoolMgr->IsPartOfAPool<GameObject>(GetSpawnId()) : 0;
496  if (poolid)
497  sPoolMgr->UpdatePool<GameObject>(poolid, GetSpawnId());
498  else
499  GetMap()->AddToMap(this);
500  }
501  }
502 
503  if (isSpawned())
504  {
505  GameObjectTemplate const* goInfo = GetGOInfo();
506  if (goInfo->type == GAMEOBJECT_TYPE_TRAP)
507  {
508  if (m_cooldownTime >= time(NULL))
509  break;
510 
511  // Type 2 (bomb) does not need to be triggered by a unit and despawns after casting its spell.
512  if (goInfo->trap.charges == 2)
513  {
515  break;
516  }
517 
518  // Type 0 despawns after being triggered, type 1 does not.
520  float radius;
521  if (!goInfo->trap.radius)
522  {
523  // Battleground traps: data2 == 0 && data5 == 3
524  if (goInfo->trap.cooldown != 3)
525  break;
526 
527  radius = 3.f;
528  }
529  else
530  radius = goInfo->trap.radius / 2.f;
531 
532  // Pointer to appropriate target if found any
533  Unit* target = NULL;
534 
536  if (Unit* owner = GetOwner())
537  {
538  // Hunter trap: Search units which are unfriendly to the trap's owner
539  Trinity::AnyUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
541  VisitNearbyGridObject(radius, searcher);
542  if (!target)
543  VisitNearbyWorldObject(radius, searcher);
544  }
545  else
546  {
547  // Environmental trap: Any player
548  Player* player = NULL;
549  Trinity::AnyPlayerInObjectRangeCheck checker(this, radius);
551  VisitNearbyWorldObject(radius, searcher);
552  target = player;
553  }
554 
555  if (target)
556  SetLootState(GO_ACTIVATED, target);
557 
558  }
559  else if (uint32 max_charges = goInfo->GetCharges())
560  {
561  if (m_usetimes >= max_charges)
562  {
563  m_usetimes = 0;
564  SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed
565  }
566  }
567  }
568 
569  break;
570  }
571  case GO_ACTIVATED:
572  {
573  switch (GetGoType())
574  {
577  if (m_cooldownTime && (m_cooldownTime < time(NULL)))
579  break;
581  if (m_cooldownTime < time(NULL))
582  {
584 
586  m_cooldownTime = 0;
587  }
588  break;
590  if (m_groupLootTimer)
591  {
592  if (m_groupLootTimer <= diff)
593  {
594  if (Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID))
595  group->EndRoll(&loot);
596 
597  m_groupLootTimer = 0;
599  }
600  else
601  m_groupLootTimer -= diff;
602  }
603  break;
605  {
606  GameObjectTemplate const* goInfo = GetGOInfo();
607  if (goInfo->trap.charges == 2 && goInfo->trap.spell)
608  {
610  CastSpell(NULL, goInfo->trap.spell);
612  }
613  else if (Unit* target = ObjectAccessor::GetUnit(*this, m_lootStateUnitGUID))
614  {
615  // Some traps do not have a spell but should be triggered
616  if (goInfo->trap.spell)
617  CastSpell(target, goInfo->trap.spell);
618 
619  // Template value or 4 seconds
620  m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4));
621 
622  if (goInfo->trap.charges == 1)
624  else if (!goInfo->trap.charges)
626 
627  // Battleground gameobjects have data2 == 0 && data5 == 3
628  if (!goInfo->trap.radius && goInfo->trap.cooldown == 3)
629  if (Player* player = target->ToPlayer())
630  if (Battleground* bg = player->GetBattleground())
631  bg->HandleTriggerBuff(GetGUID());
632  }
633  break;
634  }
635  default:
636  break;
637  }
638  break;
639  }
640  case GO_JUST_DEACTIVATED:
641  {
642  //if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
644  {
645  uint32 spellId = GetGOInfo()->goober.spell;
646 
647  if (spellId)
648  {
649  for (GuidSet::const_iterator it = m_unique_users.begin(); it != m_unique_users.end(); ++it)
650  // m_unique_users can contain only player GUIDs
651  if (Player* owner = ObjectAccessor::GetPlayer(*this, *it))
652  owner->CastSpell(owner, spellId, false);
653 
654  m_unique_users.clear();
655  m_usetimes = 0;
656  }
657 
659 
660  //any return here in case battleground traps
662  return;
663  }
664 
665  loot.clear();
666 
669  if (GetSpellId() || !GetOwnerGUID().IsEmpty())
670  {
671  SetRespawnTime(0);
672  Delete();
673  return;
674  }
675 
677 
678  //burning flags in some battlegrounds, if you find better condition, just add it
679  if (GetGOInfo()->IsDespawnAtAction() || GetGoAnimProgress() > 0)
680  {
682  //reset flags
684  }
685 
686  if (!m_respawnDelayTime)
687  return;
688 
689  if (!m_spawnedByDefault)
690  {
691  m_respawnTime = 0;
693  return;
694  }
695 
697 
698  // if option not set then object will be saved at grid unload
699  if (sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY))
700  SaveRespawnTime();
701 
703 
704  break;
705  }
706  }
707  sScriptMgr->OnGameObjectUpdate(this, diff);
708 }
LootState m_lootState
Definition: GameObject.h:1096
GameObjectAI * AI() const
Definition: GameObject.h:1061
bool AIM_Initialize()
Definition: GameObject.cpp:77
Unit * GetOwner() const
Definition: GameObject.cpp:1009
uint32 GetCharges() const
Definition: GameObject.h:686
Definition: GameObject.h:825
void ResetDoorOrButton()
Definition: GameObject.cpp:1172
TransportAnimation const * AnimationInfo
Definition: GameObject.h:780
Definition: GameObject.h:871
GuidSet m_unique_users
Definition: GameObject.h:1104
GOState GetGoState() const
Definition: GameObject.h:966
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
Map * GetMap() const
Definition: Object.h:543
ObjectGuid m_lootStateUnitGUID
Definition: GameObject.h:1097
uint32 minRestock
Definition: GameObject.h:101
uint32 m_usetimes
Definition: GameObject.h:1105
Definition: GridNotifiers.h:1188
uint32 m_respawnDelayTime
Definition: GameObject.h:1095
Definition: GameObject.h:870
void BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) const
Definition: Object.cpp:265
Definition: GridNotifiers.h:376
Definition: GameObjectPackets.h:104
void VisitNearbyWorldObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:589
Definition: GameObject.h:34
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
struct GameObjectValue::@273 Transport
uint32 StateUpdateTimer
Definition: GameObject.h:783
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:945
#define sWorld
Definition: World.h:887
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:902
Definition: SharedDefines.h:2082
void clear()
Definition: LootMgr.h:349
time_t GetLinkedRespawnTime(ObjectGuid guid) const
Definition: Map.cpp:3684
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: SharedDefines.h:2121
Definition: UpdateData.h:59
Definition: Common.h:97
time_t m_cooldownTime
Definition: GameObject.h:1099
void VisitNearbyGridObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:588
Player * ToPlayer()
Definition: Object.h:191
Definition: GridNotifiers.h:495
virtual void UpdateAI(uint32)
Definition: GameObjectAI.h:37
GuidSet m_SkillupList
Definition: GameObject.h:1101
TypeID GetTypeId() const
Definition: Object.h:113
void SetLootState(LootState s, Unit *unit=NULL)
Definition: GameObject.cpp:2112
time_t m_respawnTime
Definition: GameObject.h:1094
struct GameObjectTemplate::@221::@229 trap
Definition: SharedDefines.h:2066
ObjectGuid lootingGroupLowGUID
Definition: GameObject.h:1015
uint32 MaxOpens
Definition: GameObject.h:788
void SendObjectDeSpawnAnim(ObjectGuid guid)
Definition: Object.cpp:2162
#define FISHING_BOBBER_READY_TIME
Definition: GameObject.h:878
#define sPoolMgr
Definition: PoolMgr.h:166
Definition: UpdateFields.h:323
uint32 maxRestock
Definition: GameObject.h:102
GameObjectValue m_goValue
Definition: GameObject.h:1113
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
Definition: Common.h:99
bool AddToMap(T *)
Definition: Map.cpp:566
Definition: UpdateFields.h:322
Definition: SharedDefines.h:2126
uint32_t uint32
Definition: Define.h:150
#define sGroupMgr
Definition: GroupMgr.h:59
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
Loot loot
Definition: GameObject.h:1007
struct GameObjectValue::@274 FishingHole
Definition: GameObject.h:880
uint32 GetMapId() const
Definition: Position.h:254
void CastSpell(Unit *target, uint32 spell, bool triggered=true)
Definition: GameObject.cpp:1833
std::vector< uint32 > * StopFrames
Definition: GameObject.h:782
struct GameObjectTemplate::@221::@233 goober
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
Definition: UpdateFields.h:319
Definition: GameObject.h:822
Definition: SharedDefines.h:2090
uint32 m_groupLootTimer
Definition: GameObject.h:1014
Definition: GameObject.h:823
void Clear()
Definition: ObjectGuid.h:215
void SetGoState(GOState state)
Definition: GameObject.cpp:2137
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
void ForceValuesUpdateAtIndex(uint32)
Definition: Object.cpp:2138
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool isSpawned() const
Definition: GameObject.h:951
Definition: ObjectGuid.h:33
bool m_spawnedByDefault
Definition: GameObject.h:1098
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
uint8 GetGoAnimProgress() const
Definition: GameObject.h:972
Definition: SharedDefines.h:2075
Definition: GameObject.h:868
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:3001
void SendCustomAnim(uint32 anim)
Definition: GameObject.cpp:1879
void SaveRespawnTime() override
Definition: GameObject.cpp:1014
uint32 PathProgress
Definition: GameObject.h:779
Definition: SharedDefines.h:2068
Definition: Battleground.h:235
uint32 GetSpellId() const
Definition: GameObject.h:933
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
uint8 flags
Definition: DisableMgr.cpp:44
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:1305
Definition: GameObject.h:869
Definition: SharedDefines.h:2076
Definition: SharedDefines.h:2071
Definition: WorldPacket.h:26
uint32 type
Definition: GameObject.h:37
ObjectGuid::LowType m_spawnId
For new or temporary gameobjects is 0 for saved it is lowguid.
Definition: GameObject.h:1110
Definition: Group.h:191
Definition: SharedDefines.h:2065
void Delete()
Definition: GameObject.cpp:726

+ Here is the call graph for this function:

void GameObject::UpdateModel ( )
protected
2215 {
2216  if (!IsInWorld())
2217  return;
2218  if (m_model)
2219  if (GetMap()->ContainsGameObjectModel(*m_model))
2221  delete m_model;
2222  m_model = CreateModel();
2223  if (m_model)
2225 }
Map * GetMap() const
Definition: Object.h:543
void RemoveGameObjectModel(const GameObjectModel &model)
Definition: Map.h:505
GameObjectModel * CreateModel()
Definition: GameObject.cpp:2475
GameObjectModel * m_model
Definition: GameObject.h:1070
bool IsInWorld() const
Definition: Object.h:100
void InsertGameObjectModel(const GameObjectModel &model)
Definition: Map.h:506

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::UpdateModelPosition ( )
2426 {
2427  if (!m_model)
2428  return;
2429 
2430  if (GetMap()->ContainsGameObjectModel(*m_model))
2431  {
2435  }
2436 }
bool UpdatePosition()
Definition: GameObjectModel.cpp:178
Map * GetMap() const
Definition: Object.h:543
void RemoveGameObjectModel(const GameObjectModel &model)
Definition: Map.h:505
GameObjectModel * m_model
Definition: GameObject.h:1070
void InsertGameObjectModel(const GameObjectModel &model)
Definition: Map.h:506

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::UpdateRotationFields ( float  rotation2 = 0.0f,
float  rotation3 = 0.0f 
)
1944 {
1945  static double const atan_pow = atan(pow(2.0f, -20.0f));
1946 
1947  double f_rot1 = std::sin(GetOrientation() / 2.0f);
1948  double f_rot2 = std::cos(GetOrientation() / 2.0f);
1949 
1950  int64 i_rot1 = int64(f_rot1 / atan_pow *(f_rot2 >= 0 ? 1.0f : -1.0f));
1951  int64 rotation = (i_rot1 << 43 >> 43) & 0x00000000001FFFFF;
1952 
1953  //float f_rot2 = std::sin(0.0f / 2.0f);
1954  //int64 i_rot2 = f_rot2 / atan(pow(2.0f, -20.0f));
1955  //rotation |= (((i_rot2 << 22) >> 32) >> 11) & 0x000003FFFFE00000;
1956 
1957  //float f_rot3 = std::sin(0.0f / 2.0f);
1958  //int64 i_rot3 = f_rot3 / atan(pow(2.0f, -21.0f));
1959  //rotation |= (i_rot3 >> 42) & 0x7FFFFC0000000000;
1960 
1961  m_rotation = rotation;
1962 
1963  if (rotation2 == 0.0f && rotation3 == 0.0f)
1964  {
1965  rotation2 = (float)f_rot1;
1966  rotation3 = (float)f_rot2;
1967  }
1968 
1971 }
Definition: UpdateFields.h:320
int64_t int64
Definition: Define.h:145
float GetOrientation() const
Definition: Position.h:107
int64_t int64
Definition: g3dmath.h:169
G3D::Quat pow(const G3D::Quat &q, double x)
Definition: Quat.h:761
uint64 m_rotation
Definition: GameObject.h:1115
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:1067

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void GameObject::Use ( Unit user)
Todo:
I do not understand this hack. Need some explanation.
Todo:
find reasonable value for fishing hole search
1233 {
1234  // by default spell caster is user
1235  Unit* spellCaster = user;
1236  uint32 spellId = 0;
1237  bool triggered = false;
1238 
1239  if (Player* playerUser = user->ToPlayer())
1240  {
1241  if (sScriptMgr->OnGossipHello(playerUser, this))
1242  return;
1243 
1244  if (AI()->GossipHello(playerUser))
1245  return;
1246  }
1247 
1248  // If cooldown data present in template
1249  if (uint32 cooldown = GetGOInfo()->GetCooldown())
1250  {
1251  if (m_cooldownTime > sWorld->GetGameTime())
1252  return;
1253 
1254  m_cooldownTime = sWorld->GetGameTime() + cooldown;
1255  }
1256 
1257  switch (GetGoType())
1258  {
1259  case GAMEOBJECT_TYPE_DOOR: //0
1260  case GAMEOBJECT_TYPE_BUTTON: //1
1261  //doors/buttons never really despawn, only reset to default state/flags
1262  UseDoorOrButton(0, false, user);
1263  return;
1264  case GAMEOBJECT_TYPE_QUESTGIVER: //2
1265  {
1266  if (user->GetTypeId() != TYPEID_PLAYER)
1267  return;
1268 
1269  Player* player = user->ToPlayer();
1270 
1271  player->PrepareGossipMenu(this, GetGOInfo()->questgiver.gossipID, true);
1272  player->SendPreparedGossip(this);
1273  return;
1274  }
1275  case GAMEOBJECT_TYPE_TRAP: //6
1276  {
1277  GameObjectTemplate const* goInfo = GetGOInfo();
1278  if (goInfo->trap.spell)
1279  CastSpell(user, goInfo->trap.spell);
1280 
1281  m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4)); // template or 4 seconds
1282 
1283  if (goInfo->trap.charges == 1) // Deactivate after trigger
1285 
1286  return;
1287  }
1288  //Sitting: Wooden bench, chairs enzz
1289  case GAMEOBJECT_TYPE_CHAIR: //7
1290  {
1291  GameObjectTemplate const* info = GetGOInfo();
1292  if (!info)
1293  return;
1294 
1295  if (user->GetTypeId() != TYPEID_PLAYER)
1296  return;
1297 
1298  if (ChairListSlots.empty()) // this is called once at first chair use to make list of available slots
1299  {
1300  if (info->chair.chairslots > 0) // sometimes chairs in DB have error in fields and we dont know number of slots
1301  for (uint32 i = 0; i < info->chair.chairslots; ++i)
1302  ChairListSlots[i].Clear(); // Last user of current slot set to 0 (none sit here yet)
1303  else
1304  ChairListSlots[0].Clear(); // error in DB, make one default slot
1305  }
1306 
1307  Player* player = user->ToPlayer();
1308 
1309  // a chair may have n slots. we have to calculate their positions and teleport the player to the nearest one
1310 
1311  float lowestDist = DEFAULT_VISIBILITY_DISTANCE;
1312 
1313  uint32 nearest_slot = 0;
1314  float x_lowest = GetPositionX();
1315  float y_lowest = GetPositionY();
1316 
1317  // the object orientation + 1/2 pi
1318  // every slot will be on that straight line
1319  float orthogonalOrientation = GetOrientation() + float(M_PI) * 0.5f;
1320  // find nearest slot
1321  bool found_free_slot = false;
1322  for (ChairSlotAndUser::iterator itr = ChairListSlots.begin(); itr != ChairListSlots.end(); ++itr)
1323  {
1324  // the distance between this slot and the center of the go - imagine a 1D space
1325  float relativeDistance = (info->size*itr->first) - (info->size*(info->chair.chairslots - 1) / 2.0f);
1326 
1327  float x_i = GetPositionX() + relativeDistance * std::cos(orthogonalOrientation);
1328  float y_i = GetPositionY() + relativeDistance * std::sin(orthogonalOrientation);
1329 
1330  if (!itr->second.IsEmpty())
1331  {
1332  if (Player* ChairUser = ObjectAccessor::FindPlayer(itr->second))
1333  {
1334  if (ChairUser->IsSitState() && ChairUser->GetStandState() != UNIT_STAND_STATE_SIT && ChairUser->GetExactDist2d(x_i, y_i) < 0.1f)
1335  continue; // This seat is already occupied by ChairUser. NOTE: Not sure if the ChairUser->GetStandState() != UNIT_STAND_STATE_SIT check is required.
1336  else
1337  itr->second.Clear(); // This seat is unoccupied.
1338  }
1339  else
1340  itr->second.Clear(); // The seat may of had an occupant, but they're offline.
1341  }
1342 
1343  found_free_slot = true;
1344 
1345  // calculate the distance between the player and this slot
1346  float thisDistance = player->GetDistance2d(x_i, y_i);
1347 
1348  if (thisDistance <= lowestDist)
1349  {
1350  nearest_slot = itr->first;
1351  lowestDist = thisDistance;
1352  x_lowest = x_i;
1353  y_lowest = y_i;
1354  }
1355  }
1356 
1357  if (found_free_slot)
1358  {
1359  ChairSlotAndUser::iterator itr = ChairListSlots.find(nearest_slot);
1360  if (itr != ChairListSlots.end())
1361  {
1362  itr->second = player->GetGUID(); //this slot in now used by player
1363  player->TeleportTo(GetMapId(), x_lowest, y_lowest, GetPositionZ(), GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);
1364  player->SetStandState(UnitStandStateType(UNIT_STAND_STATE_SIT_LOW_CHAIR + info->chair.chairheight));
1365  return;
1366  }
1367  }
1368 
1369  return;
1370  }
1371  //big gun, its a spell/aura
1372  case GAMEOBJECT_TYPE_GOOBER: //10
1373  {
1374  GameObjectTemplate const* info = GetGOInfo();
1375 
1376  if (Player* player = user->ToPlayer())
1377  {
1378  if (info->goober.pageID) // show page...
1379  {
1381  data.GameObjectGUID = GetGUID();
1382  player->SendDirectMessage(data.Write());
1383  }
1384  else if (info->goober.gossipID)
1385  {
1386  player->PrepareGossipMenu(this, info->goober.gossipID);
1387  player->SendPreparedGossip(this);
1388  }
1389 
1390  if (info->goober.eventID)
1391  {
1392  TC_LOG_DEBUG("maps.script", "Goober ScriptStart id %u for GO entry %u (GUID " UI64FMTD ").", info->goober.eventID, GetEntry(), GetSpawnId());
1393  GetMap()->ScriptsStart(sEventScripts, info->goober.eventID, player, this);
1394  EventInform(info->goober.eventID, user);
1395  }
1396 
1397  // possible quest objective for active quests
1398  if (info->goober.questID && sObjectMgr->GetQuestTemplate(info->goober.questID))
1399  {
1400  //Quest require to be active for GO using
1401  if (player->GetQuestStatus(info->goober.questID) != QUEST_STATUS_INCOMPLETE)
1402  break;
1403  }
1404 
1405  if (Group* group = player->GetGroup())
1406  {
1407  for (GroupReference const* itr = group->GetFirstMember(); itr != nullptr; itr = itr->next())
1408  if (Player* member = itr->GetSource())
1409  if (member->IsAtGroupRewardDistance(this))
1410  member->KillCreditGO(info->entry, GetGUID());
1411  }
1412  else
1413  player->KillCreditGO(info->entry, GetGUID());
1414  }
1415 
1416  if (uint32 trapEntry = info->goober.linkedTrap)
1417  TriggeringLinkedGameObject(trapEntry, user);
1418 
1420  SetLootState(GO_ACTIVATED, user);
1421 
1422  // this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
1423  if (info->goober.customAnim)
1425  else
1427 
1428  m_cooldownTime = time(NULL) + info->GetAutoCloseTime();
1429 
1430  // cast this spell later if provided
1431  spellId = info->goober.spell;
1432  spellCaster = NULL;
1433 
1434  break;
1435  }
1436  case GAMEOBJECT_TYPE_CAMERA: //13
1437  {
1438  GameObjectTemplate const* info = GetGOInfo();
1439  if (!info)
1440  return;
1441 
1442  if (user->GetTypeId() != TYPEID_PLAYER)
1443  return;
1444 
1445  Player* player = user->ToPlayer();
1446 
1447  if (info->camera.camera)
1448  player->SendCinematicStart(info->camera.camera);
1449 
1450  if (info->camera.eventID)
1451  {
1452  GetMap()->ScriptsStart(sEventScripts, info->camera.eventID, player, this);
1453  EventInform(info->camera.eventID, user);
1454  }
1455 
1456  return;
1457  }
1458  //fishing bobber
1459  case GAMEOBJECT_TYPE_FISHINGNODE: //17
1460  {
1461  Player* player = user->ToPlayer();
1462  if (!player)
1463  return;
1464 
1465  if (player->GetGUID() != GetOwnerGUID())
1466  return;
1467 
1468  switch (getLootState())
1469  {
1470  case GO_READY: // ready for loot
1471  {
1472  uint32 zone, subzone;
1473  GetZoneAndAreaId(zone, subzone);
1474 
1475  int32 zone_skill = sObjectMgr->GetFishingBaseSkillLevel(subzone);
1476  if (!zone_skill)
1477  zone_skill = sObjectMgr->GetFishingBaseSkillLevel(zone);
1478 
1479  //provide error, no fishable zone or area should be 0
1480  if (!zone_skill)
1481  TC_LOG_ERROR("sql.sql", "Fishable areaId %u are not properly defined in `skill_fishing_base_level`.", subzone);
1482 
1483  int32 skill = player->GetSkillValue(SKILL_FISHING);
1484 
1485  int32 chance;
1486  if (skill < zone_skill)
1487  {
1488  chance = int32(pow((double)skill/zone_skill, 2) * 100);
1489  if (chance < 1)
1490  chance = 1;
1491  }
1492  else
1493  chance = 100;
1494 
1495  int32 roll = irand(1, 100);
1496 
1497  TC_LOG_DEBUG("misc", "Fishing check (skill: %i zone min skill: %i chance %i roll: %i", skill, zone_skill, chance, roll);
1498 
1499  // but you will likely cause junk in areas that require a high fishing skill (not yet implemented)
1500  if (chance >= roll)
1501  {
1502  player->UpdateFishingSkill();
1503 
1505  // prevent removing GO at spell cancel
1506  RemoveFromOwner();
1507  SetOwnerGUID(player->GetGUID());
1508  SetSpellId(0); // prevent removing unintended auras at Unit::RemoveGameObject
1509 
1512  if (ok)
1513  {
1514  ok->Use(player);
1516  }
1517  else
1518  player->SendLoot(GetGUID(), LOOT_FISHING);
1519  }
1520  else // else: junk
1521  player->SendLoot(GetGUID(), LOOT_FISHING_JUNK);
1522  break;
1523  }
1524  case GO_JUST_DEACTIVATED: // nothing to do, will be deleted at next update
1525  break;
1526  default:
1527  {
1529  player->SendDirectMessage(WorldPackets::GameObject::FishNotHooked().Write());
1530  break;
1531  }
1532  }
1533 
1534  player->FinishSpell(CURRENT_CHANNELED_SPELL);
1535  return;
1536  }
1537 
1538  case GAMEOBJECT_TYPE_RITUAL: //18
1539  {
1540  if (user->GetTypeId() != TYPEID_PLAYER)
1541  return;
1542 
1543  Player* player = user->ToPlayer();
1544 
1545  Unit* owner = GetOwner();
1546 
1547  GameObjectTemplate const* info = GetGOInfo();
1548 
1549  Player* m_ritualOwner = NULL;
1550  if (!m_ritualOwnerGUID.IsEmpty())
1552 
1553  // ritual owner is set for GO's without owner (not summoned)
1554  if (!m_ritualOwner && !owner)
1555  {
1556  m_ritualOwnerGUID = player->GetGUID();
1557  m_ritualOwner = player;
1558  }
1559 
1560  if (owner)
1561  {
1562  if (owner->GetTypeId() != TYPEID_PLAYER)
1563  return;
1564 
1565  // accept only use by player from same group as owner, excluding owner itself (unique use already added in spell effect)
1566  if (player == owner->ToPlayer() || (info->ritual.castersGrouped && !player->IsInSameRaidWith(owner->ToPlayer())))
1567  return;
1568 
1569  // expect owner to already be channeling, so if not...
1571  return;
1572 
1573  // in case summoning ritual caster is GO creator
1574  spellCaster = owner;
1575  }
1576  else
1577  {
1578  if (player != m_ritualOwner && (info->ritual.castersGrouped && !player->IsInSameRaidWith(m_ritualOwner)))
1579  return;
1580 
1581  spellCaster = player;
1582  }
1583 
1584  AddUniqueUse(player);
1585 
1586  if (info->ritual.animSpell)
1587  {
1588  player->CastSpell(player, info->ritual.animSpell, true);
1589 
1590  // for this case, summoningRitual.spellId is always triggered
1591  triggered = true;
1592  }
1593 
1594  // full amount unique participants including original summoner
1595  if (GetUniqueUseCount() == info->ritual.casters)
1596  {
1597  if (m_ritualOwner)
1598  spellCaster = m_ritualOwner;
1599 
1600  spellId = info->ritual.spell;
1601 
1602  if (spellId == 62330) // GO store nonexistent spell, replace by expected
1603  {
1604  // spell have reagent and mana cost but it not expected use its
1605  // it triggered spell in fact cast at currently channeled GO
1606  spellId = 61993;
1607  triggered = true;
1608  }
1609 
1610  // Cast casterTargetSpell at a random GO user
1611  // on the current DB there is only one gameobject that uses this (Ritual of Doom)
1612  // and its required target number is 1 (outter for loop will run once)
1613  if (info->ritual.casterTargetSpell && info->ritual.casterTargetSpell != 1) // No idea why this field is a bool in some cases
1614  for (uint32 i = 0; i < info->ritual.casterTargetSpellTargets; i++)
1615  // m_unique_users can contain only player GUIDs
1617  spellCaster->CastSpell(target, info->ritual.casterTargetSpell, true);
1618 
1619  // finish owners spell
1620  if (owner)
1622 
1623  // can be deleted now, if
1624  if (!info->ritual.ritualPersistent)
1626  else
1627  {
1628  // reset ritual for this GO
1630  m_unique_users.clear();
1631  m_usetimes = 0;
1632  }
1633  }
1634  else
1635  return;
1636 
1637  // go to end function to spell casting
1638  break;
1639  }
1640  case GAMEOBJECT_TYPE_SPELLCASTER: //22
1641  {
1642  GameObjectTemplate const* info = GetGOInfo();
1643  if (!info)
1644  return;
1645 
1646  if (info->spellCaster.partyOnly)
1647  {
1648  Unit* caster = GetOwner();
1649  if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
1650  return;
1651 
1652  if (user->GetTypeId() != TYPEID_PLAYER || !user->ToPlayer()->IsInSameRaidWith(caster->ToPlayer()))
1653  return;
1654  }
1655 
1657  spellId = info->spellCaster.spell;
1658 
1659  AddUse();
1660  break;
1661  }
1662  case GAMEOBJECT_TYPE_MEETINGSTONE: //23
1663  {
1664  GameObjectTemplate const* info = GetGOInfo();
1665 
1666  if (user->GetTypeId() != TYPEID_PLAYER)
1667  return;
1668 
1669  Player* player = user->ToPlayer();
1670 
1671  Player* targetPlayer = ObjectAccessor::FindPlayer(player->GetTarget());
1672 
1673  // accept only use by player from same raid as caster, except caster itself
1674  if (!targetPlayer || targetPlayer == player || !targetPlayer->IsInSameRaidWith(player))
1675  return;
1676 
1677  //required lvl checks!
1678  uint8 level = player->getLevel();
1679  if (level < info->meetingStone.minLevel)
1680  return;
1681  level = targetPlayer->getLevel();
1682  if (level < info->meetingStone.minLevel)
1683  return;
1684 
1685  if (info->entry == 194097)
1686  spellId = 61994; // Ritual of Summoning
1687  else
1688  spellId = 59782; // Summoning Stone Effect
1689 
1690  break;
1691  }
1692 
1693  case GAMEOBJECT_TYPE_FLAGSTAND: // 24
1694  {
1695  if (user->GetTypeId() != TYPEID_PLAYER)
1696  return;
1697 
1698  Player* player = user->ToPlayer();
1699 
1700  if (player->CanUseBattlegroundObject(this))
1701  {
1702  // in battleground check
1703  Battleground* bg = player->GetBattleground();
1704  if (!bg)
1705  return;
1706 
1707  if (player->GetVehicle())
1708  return;
1709 
1710  player->RemoveAurasByType(SPELL_AURA_MOD_STEALTH);
1711  player->RemoveAurasByType(SPELL_AURA_MOD_INVISIBILITY);
1712  // BG flag click
1713  // AB:
1714  // 15001
1715  // 15002
1716  // 15003
1717  // 15004
1718  // 15005
1719  bg->EventPlayerClickedOnFlag(player, this);
1720  return; //we don;t need to delete flag ... it is despawned!
1721  }
1722  break;
1723  }
1724 
1725  case GAMEOBJECT_TYPE_FISHINGHOLE: // 25
1726  {
1727  if (user->GetTypeId() != TYPEID_PLAYER)
1728  return;
1729 
1730  Player* player = user->ToPlayer();
1731 
1732  player->SendLoot(GetGUID(), LOOT_FISHINGHOLE);
1733  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT, GetGOInfo()->entry);
1734  return;
1735  }
1736 
1737  case GAMEOBJECT_TYPE_FLAGDROP: // 26
1738  {
1739  if (user->GetTypeId() != TYPEID_PLAYER)
1740  return;
1741 
1742  Player* player = user->ToPlayer();
1743 
1744  if (player->CanUseBattlegroundObject(this))
1745  {
1746  // in battleground check
1747  Battleground* bg = player->GetBattleground();
1748  if (!bg)
1749  return;
1750 
1751  if (player->GetVehicle())
1752  return;
1753 
1754  player->RemoveAurasByType(SPELL_AURA_MOD_STEALTH);
1755  player->RemoveAurasByType(SPELL_AURA_MOD_INVISIBILITY);
1756  // BG flag dropped
1757  // WS:
1758  // 179785 - Silverwing Flag
1759  // 179786 - Warsong Flag
1760  // EotS:
1761  // 184142 - Netherstorm Flag
1762  GameObjectTemplate const* info = GetGOInfo();
1763  if (info)
1764  {
1765  switch (info->entry)
1766  {
1767  case 179785: // Silverwing Flag
1768  case 179786: // Warsong Flag
1769  if (bg->GetTypeID(true) == BATTLEGROUND_WS)
1770  bg->EventPlayerClickedOnFlag(player, this);
1771  break;
1772  case 184142: // Netherstorm Flag
1773  if (bg->GetTypeID(true) == BATTLEGROUND_EY)
1774  bg->EventPlayerClickedOnFlag(player, this);
1775  break;
1776  }
1777  }
1778  //this cause to call return, all flags must be deleted here!!
1779  spellId = 0;
1780  Delete();
1781  }
1782  break;
1783  }
1784  case GAMEOBJECT_TYPE_BARBER_CHAIR: //32
1785  {
1786  GameObjectTemplate const* info = GetGOInfo();
1787  if (!info)
1788  return;
1789 
1790  if (user->GetTypeId() != TYPEID_PLAYER)
1791  return;
1792 
1793  Player* player = user->ToPlayer();
1794 
1796  player->SendDirectMessage(packet.Write());
1797 
1798  // fallback, will always work
1799  player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);
1800 
1801  player->SetStandState(UnitStandStateType(UNIT_STAND_STATE_SIT_LOW_CHAIR + info->barberChair.chairheight), info->barberChair.SitAnimKit);
1802  return;
1803  }
1804  default:
1805  if (GetGoType() >= MAX_GAMEOBJECT_TYPE)
1806  TC_LOG_ERROR("misc", "GameObject::Use(): unit (type: %u, %s, name: %s) tries to use object (%s, name: %s) of unknown type (%u)",
1807  user->GetTypeId(), user->GetGUID().ToString().c_str(), user->GetName().c_str(), GetGUID().ToString().c_str(), GetGOInfo()->name.c_str(), GetGoType());
1808  break;
1809  }
1810 
1811  if (!spellId)
1812  return;
1813 
1814  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
1815  if (!spellInfo)
1816  {
1817  if (user->GetTypeId() != TYPEID_PLAYER || !sOutdoorPvPMgr->HandleCustomSpell(user->ToPlayer(), spellId, this))
1818  TC_LOG_ERROR("misc", "WORLD: unknown spell id %u at use action for gameobject (Entry: %u GoType: %u)", spellId, GetEntry(), GetGoType());
1819  else
1820  TC_LOG_DEBUG("outdoorpvp", "WORLD: %u non-dbc spell was handled by OutdoorPvP", spellId);
1821  return;
1822  }
1823 
1824  if (Player* player = user->ToPlayer())
1825  sOutdoorPvPMgr->HandleCustomSpell(player, spellId, this);
1826 
1827  if (spellCaster)
1828  spellCaster->CastSpell(user, spellInfo, triggered);
1829  else
1830  CastSpell(user, spellId);
1831 }
#define MAX_GAMEOBJECT_TYPE
Definition: SharedDefines.h:2116
struct GameObjectTemplate::@221::@255 barberChair
Definition: Unit.h:208
Definition: GameObjectPackets.h:96
GameObjectAI * AI() const
Definition: GameObject.h:1061
Unit * GetOwner() const
Definition: GameObject.cpp:1009
uint32 camera
Definition: GameObject.h:281
void ScriptsStart(std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
Put scripts in the execution queue.
Definition: MapScripts.cpp:33
struct GameObjectTemplate::@221::@230 chair
Definition: GameObject.h:871
GuidSet m_unique_users
Definition: GameObject.h:1104
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:105
LootState getLootState() const
Definition: GameObject.h:981
Map * GetMap() const
Definition: Object.h:543
uint32 m_usetimes
Definition: GameObject.h:1105
Definition: LootMgr.h:99
C::value_type const & SelectRandomContainerElement(C const &container)
Definition: Containers.h:68
#define M_PI
Definition: Common.h:163
Definition: SpellInfo.h:326
uint32 gossipID
Definition: GameObject.h:84
Definition: SharedDefines.h:4562
Definition: GameObject.h:870
Definition: SpellAuraDefines.h:76
WorldPacket const * Write() override
Definition: GameObjectPackets.cpp:36
void TriggeringLinkedGameObject(uint32 trapEntry, Unit *target)
Definition: GameObject.cpp:1126
std::string const & GetName() const
Definition: Object.h:479
Definition: Unit.h:1110
uint32 GetCooldown() const
Definition: GameObject.h:757
void EventInform(uint32 eventId, WorldObject *invoker=NULL)
Definition: GameObject.cpp:1913
Definition: LootMgr.h:101
Definition: GameObject.h:34
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:4567
Definition: GameObjectPackets.h:60
Definition: SharedDefines.h:2091
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sWorld
Definition: World.h:887
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:902
Definition: SharedDefines.h:2082
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
float size
Definition: GameObject.h:45
void RemoveFromOwner()
Definition: GameObject.cpp:106
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: SharedDefines.h:2121
time_t m_cooldownTime
Definition: GameObject.h:1099
Player * ToPlayer()
Definition: Object.h:191
Definition: MiscPackets.h:538
int32 irand(int32 min, int32 max)
Definition: Random.cpp:39
TypeID GetTypeId() const
Definition: Object.h:113
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
void SetLootState(LootState s, Unit *unit=NULL)
Definition: GameObject.cpp:2112
float GetOrientation() const
Definition: Position.h:107
ObjectGuid GameObjectGUID
Definition: GameObjectPackets.h:67
struct GameObjectTemplate::@221::@229 trap
virtual bool GossipHello(Player *)
Definition: GameObjectAI.h:50
Definition: SharedDefines.h:2078
Definition: SharedDefines.h:2066
float GetPositionY() const
Definition: Position.h:105
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
#define UI64FMTD
Definition: Define.h:137
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SharedDefines.h:3976
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1920
float GetPositionZ() const
Definition: Position.h:106
UnitStandStateType
Definition: Unit.h:205
int32_t int32
Definition: Define.h:146
Definition: SharedDefines.h:2089
virtual void EventPlayerClickedOnFlag(Player *, GameObject *)
Definition: Battleground.h:428
uint32_t uint32
Definition: Define.h:150
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
struct GameObjectTemplate::@221::@245 spellCaster
Definition: Unit.h:211
Definition: GameObject.h:880
uint32 GetMapId() const
Definition: Position.h:254
uint32 entry
Definition: GameObject.h:36
void CastSpell(Unit *target, uint32 spell, bool triggered=true)
Definition: GameObject.cpp:1833
struct GameObjectTemplate::@221::@233 goober
WorldPacket const * Write() override
Definition: MiscPackets.h:543
GroupReference * next()
Definition: GroupReference.h:37
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
Definition: UpdateFields.h:319
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=NULL)
Definition: GameObject.cpp:1182
Definition: GameObject.h:822
Definition: SharedDefines.h:2090
void Use(Unit *user)
Definition: GameObject.cpp:1232
void Clear()
Definition: ObjectGuid.h:215
void SetGoState(GOState state)
Definition: GameObject.cpp:2137
G3D::Quat pow(const G3D::Quat &q, double x)
Definition: Quat.h:761
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: SharedDefines.h:2067
Definition: ObjectGuid.h:33
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid) const
Definition: Object.cpp:1535
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
Definition: SharedDefines.h:2072
uint8 GetGoAnimProgress() const
Definition: GameObject.h:972
void AddUniqueUse(Player *player)
Definition: GameObject.cpp:720
ScriptMapMap sEventScripts
Definition: ObjectMgr.cpp:52
Definition: SharedDefines.h:2075
void AddUse()
Definition: GameObject.h:1000
std::string name
Definition: GameObject.h:39
void SendCustomAnim(uint32 anim)
Definition: GameObject.cpp:1879
void SetSpellId(uint32 id)
Definition: GameObject.h:928
Definition: SharedDefines.h:2083
ChairSlotAndUser ChairListSlots
Definition: GameObject.h:1108
int32_t int32
Definition: g3dmath.h:167
Definition: QuestDef.h:113
Definition: SpellAuraDefines.h:78
uint8_t uint8
Definition: Define.h:152
void FinishSpell(CurrentSpellTypes spellType, bool ok=true)
Definition: Unit.cpp:2874
BattlegroundTypeId GetTypeID(bool GetRandom=false) const
Definition: Battleground.h:263
Definition: SharedDefines.h:2097
void RemoveAurasByType(AuraType auraType, std::function< bool(AuraApplication const *)> const &check)
Definition: Unit.cpp:3567
Definition: SharedDefines.h:2088
ObjectGuid m_ritualOwnerGUID
Definition: GameObject.h:1103
Definition: Battleground.h:235
uint32 GetUniqueUseCount() const
Definition: GameObject.h:1003
uint32 GetAutoCloseTime() const
Definition: GameObject.h:709
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
Definition: SharedDefines.h:2087
#define CONTACT_DISTANCE
Definition: Object.h:33
Definition: LootMgr.h:92
float GetPositionX() const
Definition: Position.h:104
struct GameObjectTemplate::@221::@241 ritual
Definition: Unit.h:1305
Definition: GameObject.h:869
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: SharedDefines.h:2071
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242
GameObject * LookupFishingHoleAround(float range)
Definition: GameObject.cpp:1157
void SetOwnerGUID(ObjectGuid owner)
Definition: GameObject.h:915
Definition: Group.h:191
Definition: GroupReference.h:27
Definition: SpellAuraDefines.h:138
Definition: SharedDefines.h:2065
void Delete()
Definition: GameObject.cpp:726
#define DEFAULT_VISIBILITY_DISTANCE
Definition: Object.h:40

+ Here is the caller graph for this function:

void GameObject::UseDoorOrButton ( uint32  time_to_restore = 0,
bool  alternative = false,
Unit user = NULL 
)
1183 {
1184  if (m_lootState != GO_READY)
1185  return;
1186 
1187  if (!time_to_restore)
1188  time_to_restore = GetGOInfo()->GetAutoCloseTime();
1189 
1190  SwitchDoorOrButton(true, alternative);
1191  SetLootState(GO_ACTIVATED, user);
1192 
1193  m_cooldownTime = time_to_restore ? (time(NULL) + time_to_restore) : 0;
1194 }
LootState m_lootState
Definition: GameObject.h:1096
void SwitchDoorOrButton(bool activate, bool alternative=false)
Definition: GameObject.cpp:1219
Definition: GameObject.h:870
arena_t NULL
Definition: jemalloc_internal.h:624
time_t m_cooldownTime
Definition: GameObject.h:1099
void SetLootState(LootState s, Unit *unit=NULL)
Definition: GameObject.cpp:2112
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
uint32 GetAutoCloseTime() const
Definition: GameObject.h:709
Definition: GameObject.h:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

uint16 GameObject::_animKitId
private
ChairSlotAndUser GameObject::ChairListSlots
protected
Loot GameObject::loot
ObjectGuid GameObject::lootingGroupLowGUID
GameObjectAI* GameObject::m_AI
private
time_t GameObject::m_cooldownTime
protected
GameObjectData const* GameObject::m_goData
protected
GameObjectTemplate const* GameObject::m_goInfo
protected
GameObjectValue GameObject::m_goValue
protected
uint32 GameObject::m_groupLootTimer
uint16 GameObject::m_LootMode
protected
ObjectGuid GameObject::m_lootRecipient
protected
ObjectGuid GameObject::m_lootRecipientGroup
protected
LootState GameObject::m_lootState
protected
ObjectGuid GameObject::m_lootStateUnitGUID
protected
GameObjectModel* GameObject::m_model
uint32 GameObject::m_respawnDelayTime
protected
time_t GameObject::m_respawnTime
protected
ObjectGuid GameObject::m_ritualOwnerGUID
protected
uint64 GameObject::m_rotation
protected
GuidSet GameObject::m_SkillupList
protected
bool GameObject::m_spawnedByDefault
protected
ObjectGuid::LowType GameObject::m_spawnId
protected

For new or temporary gameobjects is 0 for saved it is lowguid.

uint32 GameObject::m_spellId
protected
Position GameObject::m_stationaryPosition
protected
GuidSet GameObject::m_unique_users
protected
uint32 GameObject::m_usetimes
protected

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