OregonCore  revision fb2a440-git
Your Favourite TBC server
GameObject Class Reference

#include <GameObject.h>

+ Inheritance diagram for GameObject:

Public Member Functions

 GameObject ()
 
 ~GameObject () override
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void CleanupsBeforeDelete () override
 
bool Create (uint32 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 diff) override
 
GameObjectInfo const * GetGOInfo () const
 
GameObjectData const * GetGOData () const
 
void SetGoState (GOState state)
 
void SetPhaseMask (uint32 newPhaseMask, bool update) override
 
void EnableCollision (bool enable)
 
bool IsTransport () const
 
uint32 GetDBTableGUIDLow () const
 
void UpdateRotationFields (float rotation2=0.0f, float rotation3=0.0f)
 
void Say (const char *text, uint32 language, uint64 TargetGuid)
 
void Yell (const char *text, uint32 language, uint64 TargetGuid)
 
void TextEmote (const char *text, uint64 TargetGuid)
 
void Whisper (const char *text, uint64 receiver)
 
void Say (int32 textId, uint32 language, uint64 TargetGuid)
 
void Yell (int32 textId, uint32 language, uint64 TargetGuid)
 
void TextEmote (int32 textId, uint64 TargetGuid)
 
void Whisper (int32 textId, uint64 receiver)
 
const char * GetNameForLocaleIdx (int32 locale_idx) const override
 
void SaveToDB ()
 
void SaveToDB (uint32 mapid, uint8 spawnMask, uint32 phaseMask)
 
bool LoadFromDB (uint32 guid, Map *map)
 
bool LoadGameObjectFromDB (uint32 guid, Map *map, bool addToMap=true)
 
void DeleteFromDB ()
 
void SetOwnerGUID (uint64 owner)
 
uint64 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)
 
GameobjectTypes GetGoType () const
 
void SetGoType (GameobjectTypes type)
 
GOState GetGoState () const
 
uint32 GetGoArtKit () const
 
void SetGoArtKit (uint32 artkit)
 
uint32 GetGoAnimProgress () const
 
void SetGoAnimProgress (uint32 animprogress)
 
void Use (Unit *user)
 
LootState getLootState () const
 
void SetLootState (LootState s, Unit *unit=NULL)
 
void AddToSkillupList (uint32 PlayerGuidLow)
 
bool IsInSkillupList (uint32 PlayerGuidLow) const
 
void ClearSkillupList ()
 
void AddUniqueUse (Player *player)
 
void AddUse ()
 
uint32 GetUseCount () const
 
uint32 GetUniqueUseCount () const
 
bool IsUsedBy (uint64 guid)
 
void SaveRespawnTime () override
 
bool hasQuest (uint32 quest_id) const override
 
bool hasInvolvedQuest (uint32 quest_id) const override
 
bool ActivateToQuest (Player *pTarget) const
 
void UseDoorOrButton (uint32 time_to_restore=0, bool alternative=false, Unit *user=NULL)
 
void ResetDoorOrButton ()
 
void Animate (uint32 anim=0)
 
uint32 GetCooldown () const
 
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
 
TransportToTransport ()
 
Transport const * ToTransport () const
 
float GetInteractionDistance () const
 
void UpdateModelPosition ()
 
GameObjectLookupFishingHoleAround (float range)
 
void CastSpell (Unit *target, uint32 spellId, bool triggered=true)
 
GameObjectAIAI () const
 
std::string GetAIName () const
 
- Public Member Functions inherited from WorldObject
 ~WorldObject () override
 
void _Create (uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
 
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)
 
float GetPositionZTarget (Position &pos, float destx, float desty)
 
Position GetRandomNearPosition (float radius)
 
void GetContactPoint (const WorldObject *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
virtual float GetObjectBoundingRadius () const
 
float GetObjectSize () const
 
void UpdateGroundPositionZ (float x, float y, float &z) const
 
void UpdateAllowedPositionZ (float x, float y, float &z) const
 
void GetRandomPoint (const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
void GetRandomPoint (const Position &srcPos, float distance, Position &pos) const
 
float GetDistanceSqr (float x, float y, float z) const
 
bool HasInArc (float arcangle, const Position *pos) const
 
bool HasInArc (const float arcangle, const float x, const float y) const
 
uint32 GetInstanceId () const
 
uint32 GetPhaseMask () const
 
bool InSamePhase (uint32 phasemask) const
 
bool InSamePhase (WorldObject const *obj) const
 
uint32 GetZoneId () const
 
uint32 GetAreaId () const
 
InstanceDataGetInstanceData ()
 
const char * GetName () const
 
void SetName (const std::string &newname)
 
float GetDistance (const WorldObject *obj) const
 
float GetDistance (const Position &pos) const
 
float GetDistance (float x, float y, float z) const
 
float GetDistance2d (const WorldObject *obj) const
 
float GetDistance2d (float x, float y) const
 
float GetDistanceZ (const WorldObject *obj) const
 
bool IsInMap (const WorldObject *obj) const
 
bool IsWithinDist3d (float x, float y, float z, float dist) const
 
bool IsWithinDist3d (const Position *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (const Position *pos, float dist) const
 
bool _IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D) 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 (const WorldObject *obj) const
 
Position GetHitSpherePointFor (Position const &dest) const
 
void GetHitSpherePointFor (Position const &dest, float &x, float &y, float &z) 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
 
virtual void SendMessageToSet (WorldPacket *data, bool self)
 
virtual void SendMessageToSetInRange (WorldPacket *data, float dist, bool self)
 
void MonsterSay (const char *text, uint32 language, uint64 TargetGuid)
 
void MonsterYell (const char *text, uint32 language, uint64 TargetGuid)
 
void MonsterTextEmote (const char *text, uint64 TargetGuid, bool IsBossEmote=false)
 
void MonsterWhisper (const char *text, uint64 receiver, bool IsBossWhisper=false)
 
void MonsterSay (int32 textId, uint32 language, uint64 TargetGuid)
 
void MonsterYell (int32 textId, uint32 language, uint64 TargetGuid)
 
void MonsterTextEmote (int32 textId, uint64 TargetGuid, bool IsBossEmote=false)
 
void MonsterWhisper (int32 textId, uint64 receiver, bool IsBossWhisper=false)
 
void MonsterYellToZone (int32 textId, uint32 language, uint64 TargetGuid)
 
void BuildMonsterChat (WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
 
void PlayDistanceSound (uint32 sound_id, Player *target=NULL)
 
void PlayDirectSound (uint32 sound_id, Player *target=NULL)
 
void SendObjectDeSpawnAnim (uint64 guid)
 
void SendObjectCustomAnim (uint64 guid, uint32 anim=0)
 
void AddObjectToRemoveList ()
 
virtual bool isValid () const
 
virtual bool IsAlwaysDetectableFor (WorldObject const *) const
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
float GetSightRange (const WorldObject *target=NULL) const
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
void SendPlaySound (uint32 Sound, bool OnlySelf)
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
Map const * GetBaseMap () const
 
void SetZoneScript ()
 
TempSummonSummonCreature (uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
 
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
 
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)
 
GameObjectFindNearestGameObject (uint32 entry, float range)
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &gameobjectList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &creatureList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
 
void DestroyForNearbyPlayers ()
 
virtual void UpdateObjectVisibility (bool forced=true)
 
virtual void UpdateObjectVisibilityOnCreate ()
 
void BuildUpdate (UpdateDataMapType &) 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 VisitNearbyWorldObject (const float &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyObject (float const &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyGridObject (float const &radius, NOTIFIER &notifier) const
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
const bool & IsInWorld () const
 
const uint64GetGUID () const
 
uint32 GetGUIDLow () const
 
uint32 GetGUIDMid () const
 
uint32 GetGUIDHigh () const
 
PackedGuid const & GetPackGUID () const
 
ObjectGuid const & GetObjectGUID () const
 
std::string GetGuidStr () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
void SetObjectScale (float scale)
 
uint8 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
 
void BuildMovementUpdateBlock (UpdateData *data, uint32 flags=0) const
 
virtual void DestroyForPlayer (Player *target, bool onDeath=false) const
 
const int32GetInt32Value (uint16 index) const
 
const uint32GetUInt32Value (uint16 index) const
 
const uint64GetUInt64Value (uint16 index) const
 
const float & GetFloatValue (uint16 index) const
 
uint8 GetByteValue (uint16 index, uint8 offset) const
 
ObjectGuid const & GetGuidValue (uint16 index) const
 
uint16 GetUInt16Value (uint16 index, uint8 offset) const
 
void SetInt32Value (uint16 index, int32 value)
 
void SetUInt32Value (uint16 index, uint32 value)
 
void SetUInt64Value (uint16 index, const uint64 &value)
 
void SetFloatValue (uint16 index, float value)
 
void SetByteValue (uint16 index, uint8 offset, uint8 value)
 
void SetUInt16Value (uint16 index, uint8 offset, uint16 value)
 
void SetInt16Value (uint16 index, uint8 offset, int16 value)
 
void SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddUInt64Value (uint16 index, const uint64 &value)
 
bool RemoveUInt64Value (uint16 index, const uint64 &value)
 
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModUInt64Value (uint16 index, int32 val, bool apply)
 
void ApplyModPositiveFloatValue (uint16 index, float val, bool apply)
 
void ApplyModSignedFloatValue (uint16 index, float val, bool apply)
 
void ApplyPercentModFloatValue (uint16 index, float val, bool apply)
 
void SetFlag (uint16 index, uint32 newFlag)
 
void RemoveFlag (uint16 index, uint32 oldFlag)
 
void ToggleFlag (uint16 index, uint32 flag)
 
bool HasFlag (uint16 index, uint32 flag) const
 
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void ToggleFlag (uint16 index, uint8 offset, uint8 flag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetFlag64 (uint16 index, uint64 newFlag)
 
void RemoveFlag64 (uint16 index, uint64 oldFlag)
 
void ToggleFlag64 (uint16 index, uint64 flag)
 
bool HasFlag64 (uint16 index, uint64 flag) const
 
void ApplyModFlag64 (uint16 index, uint64 flag, bool apply)
 
void ClearUpdateMask (bool remove)
 
bool LoadValues (const char *data)
 
uint16 GetValuesCount () const
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
 
void ForceValuesUpdateAtIndex (uint32)
 
PlayerToPlayer ()
 
Player const * ToPlayer () const
 
CreatureToCreature ()
 
Creature const * ToCreature () const
 
UnitToUnit ()
 
Unit const * ToUnit () const
 
GameObjectToGameObject ()
 
GameObject const * ToGameObject () const
 
CorpseToCorpse ()
 
Corpse const * ToCorpse () const
 
DynamicObjectToDynObject ()
 
DynamicObject const * ToDynObject () const
 
- Public Member Functions inherited from WorldLocation
 WorldLocation (uint32 _mapid=MAPID_INVALID, float _x=0, float _y=0, float _z=0, float _o=0)
 
 WorldLocation (const WorldLocation &loc)
 
void WorldRelocate (const WorldLocation &loc)
 
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 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 >
bool IsInGrid () const
 
void AddToGrid (GridRefManager< GameObject > &m)
 
void RemoveFromGrid ()
 

Static Public Member Functions

static GameObjectGetGameObject (WorldObject &object, uint64 guid)
 
- Static Public Member Functions inherited from WorldObject
static bool InSamePhase (WorldObject const *a, WorldObject const *b)
 
- Static Public Member Functions inherited from Position
static float NormalizeOrientation (float o)
 

Public Attributes

Loot loot
 
- Public Attributes inherited from WorldObject
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealth
 
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealthDetect
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibility
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibilityDetect
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibility
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibilityDetect
 
uint32 m_groupLootTimer
 
uint64 lootingGroupLeaderGUID
 
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 Member Functions

bool AIM_Initialize ()
 
void SetDisplayId (uint32 displayid)
 
- Protected Member Functions inherited from WorldObject
 WorldObject (bool isWorldObject)
 
void SetLocationMapId (uint32 _mapId)
 
void SetLocationInstanceId (uint32 _instanceId)
 
- Protected Member Functions inherited from Object
 Object ()
 
void _InitValues ()
 
void _Create (uint32 guidlow, uint32 entry, HighGuid guidhigh)
 
void _LoadIntoDataField (const char *data, uint32 startOffset, uint32 count)
 
virtual void _SetUpdateBits (UpdateMask *updateMask, Player *target) const
 
virtual void _SetCreateBits (UpdateMask *updateMask, Player *target) const
 
void _BuildMovementUpdate (ByteBuffer *data, uint8 updateFlags) const
 
void _BuildValuesUpdate (uint8 updatetype, ByteBuffer *data, UpdateMask *updateMask, Player *target) const
 

Protected Attributes

uint32 m_spellId
 
time_t m_respawnTime
 
uint32 m_respawnDelayTime
 
LootState m_lootState
 
bool m_spawnedByDefault
 
time_t m_cooldownTime
 
std::list< uint32m_SkillupList
 
uint64 m_ritualOwnerGUID
 
std::set< uint64m_unique_users
 
uint32 m_usetimes
 
uint32 m_DBTableGuid
 
GameObjectInfo const * m_goInfo
 
GameObjectData const * m_goData
 
GameObjectModelm_model
 
- Protected Attributes inherited from WorldObject
std::string m_name
 
bool m_isActive
 
const bool m_isWorldObject
 
ZoneScriptm_zoneScript
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
uint8 m_objectTypeId
 
uint8 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
uint32m_uint32Values_mirror
 
uint16 m_valuesCount
 
bool m_objectUpdated
 

Private Member Functions

void SwitchDoorOrButton (bool activate, bool alternative=false)
 
void UpdateModel ()
 

Private Attributes

GameObjectAIm_AI
 

Detailed Description

Definition at line 579 of file GameObject.h.

Constructor & Destructor Documentation

GameObject::GameObject ( )
explicit

Definition at line 48 of file GameObject.cpp.

References GAMEOBJECT_END, GO_NOT_READY, m_cooldownTime, m_DBTableGuid, m_goData, m_goInfo, m_lootState, Object::m_objectType, Object::m_objectTypeId, m_respawnDelayTime, m_respawnTime, m_ritualOwnerGUID, m_spawnedByDefault, m_spellId, Object::m_updateFlag, m_usetimes, Object::m_valuesCount, TYPEID_GAMEOBJECT, TYPEMASK_GAMEOBJECT, UPDATEFLAG_HAS_POSITION, UPDATEFLAG_HIGHGUID, and UPDATEFLAG_LOWGUID.

48  : WorldObject(false), m_model(NULL), m_AI(NULL)
49 {
52  // 2.3.2 - 0x58
54 
56  m_respawnTime = 0;
57  m_respawnDelayTime = 25;
59  m_spawnedByDefault = true;
60  m_usetimes = 0;
61  m_spellId = 0;
62  m_cooldownTime = 0;
63  m_goInfo = NULL;
65  m_goData = NULL;
66 
67  m_DBTableGuid = 0;
68 }
LootState m_lootState
Definition: GameObject.h:848
GameObjectInfo const * m_goInfo
Definition: GameObject.h:859
uint32 m_usetimes
Definition: GameObject.h:856
uint32 m_respawnDelayTime
Definition: GameObject.h:847
GameObjectAI * m_AI
Definition: GameObject.h:867
GameObjectData const * m_goData
Definition: GameObject.h:860
uint16 m_objectType
Definition: Object.h:424
time_t m_cooldownTime
Definition: GameObject.h:850
uint8 m_objectTypeId
Definition: Object.h:426
time_t m_respawnTime
Definition: GameObject.h:846
GameObjectModel * m_model
Definition: GameObject.h:863
uint64 m_ritualOwnerGUID
Definition: GameObject.h:854
uint8 m_updateFlag
Definition: Object.h:427
uint32 m_DBTableGuid
Definition: GameObject.h:858
WorldObject(bool isWorldObject)
Definition: Object.cpp:1087
bool m_spawnedByDefault
Definition: GameObject.h:849
uint32 m_spellId
Definition: GameObject.h:845
uint16 m_valuesCount
Definition: Object.h:438
GameObject::~GameObject ( )
override

Definition at line 70 of file GameObject.cpp.

References m_AI, and m_model.

71 {
72  delete m_model;
73  delete m_AI;
74 }
GameObjectAI * m_AI
Definition: GameObject.h:867
GameObjectModel * m_model
Definition: GameObject.h:863

Member Function Documentation

bool GameObject::ActivateToQuest ( Player pTarget) const

Definition at line 852 of file GameObject.cpp.

References GameObjectInfo::_generic, BATTLEGROUND_AV, BG_AV_OBJECTID_MINE_N, BG_AV_OBJECTID_MINE_S, GAMEOBJECT_TYPE_CHEST, GAMEOBJECT_TYPE_GENERIC, GAMEOBJECT_TYPE_GOOBER, Player::GetBattleground(), Object::GetEntry(), GetGOInfo(), GetGoType(), Player::GetQuestStatus(), Player::GetTeam(), GameObjectInfo::goober, Player::HasQuestForGO(), LootStore::HaveQuestLootForPlayer(), LootTemplates_Gameobject, QUEST_STATUS_INCOMPLETE, GameObjectInfo::questId, GameObjectInfo::questID, and sObjectMgr.

853 {
854  if (pTarget->HasQuestForGO(GetEntry()))
855  return true;
856 
857  if (!sObjectMgr.IsGameObjectForQuests(GetEntry()))
858  return false;
859 
860  switch (GetGoType())
861  {
862  // scan GO chest with loot including quest items
864  {
865  if (LootTemplates_Gameobject.HaveQuestLootForPlayer(GetGOInfo()->GetLootId(), pTarget))
866  {
867  //@todo fix this hack
868  //look for battlegroundAV for some objects which are only activated after mine gots captured by own team
870  if (Battleground* bg = pTarget->GetBattleground())
871  if (bg->GetTypeID() == BATTLEGROUND_AV && !(((BattlegroundAV*)bg)->PlayerCanDoMineQuest(GetEntry(), pTarget->GetTeam())))
872  return false;
873  return true;
874  }
875  break;
876  }
878  {
879  if (GetGOInfo()->_generic.questID == -1 || pTarget->GetQuestStatus(GetGOInfo()->_generic.questID) == QUEST_STATUS_INCOMPLETE)
880  return true;
881  break;
882  }
884  {
885  if (GetGOInfo()->goober.questId == -1 || pTarget->GetQuestStatus(GetGOInfo()->goober.questId) == QUEST_STATUS_INCOMPLETE)
886  return true;
887  break;
888  }
889  default:
890  break;
891  }
892 
893  return false;
894 }
uint32 questId
Definition: GameObject.h:96
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:13634
Battleground * GetBattleground() const
Definition: Player.cpp:19413
uint32 questID
Definition: GameObject.h:114
LootStore LootTemplates_Gameobject("gameobject_loot_template","gameobject entry")
bool HasQuestForGO(int32 GOId)
Definition: Player.cpp:19513
struct GameObjectInfo::@59::@65 _generic
#define sObjectMgr
Definition: ObjectMgr.h:1285
bool HaveQuestLootForPlayer(uint32 loot_id, Player *player) const
Definition: LootMgr.cpp:160
GameobjectTypes GetGoType() const
Definition: GameObject.h:720
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
uint32 GetTeam() const
Definition: Player.h:2063
uint32 GetEntry() const
Definition: Object.h:192
struct GameObjectInfo::@59::@70 goober
void GameObject::AddToSkillupList ( uint32  PlayerGuidLow)
inline

Definition at line 754 of file GameObject.h.

Referenced by Spell::EffectOpenLock().

755  {
756  m_SkillupList.push_back(PlayerGuidLow);
757  }
std::list< uint32 > m_SkillupList
Definition: GameObject.h:852
void GameObject::AddToWorld ( )
overridevirtual

Reimplemented from Object.

Definition at line 117 of file GameObject.cpp.

References ObjectAccessor::AddObject(), Object::AddToWorld(), EnableCollision(), GAMEOBJECT_TYPE_CHEST, GetGoState(), GetGoType(), getLootState(), WorldObject::GetMap(), GO_READY, GO_STATE_READY, Map::Insert(), Oregon::Singleton< ObjectAccessor, Oregon::ClassLevelLockable< ObjectAccessor, ACE_Thread_Mutex > >::Instance(), Object::IsInWorld(), IsTransport(), m_model, WorldObject::m_zoneScript, ZoneScript::OnGameObjectCreate(), and ToTransport().

118 {
119  // Register the gameobject for guid lookup
120  if (!IsInWorld())
121  {
122  if (m_zoneScript)
123  m_zoneScript->OnGameObjectCreate(this, true);
124 
126 
127  // The state can be changed after GameObject::Create but before GameObject::AddToWorld
128  bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState () == GO_READY : (GetGoState() == GO_STATE_READY || IsTransport());
129  if (m_model)
130  {
131  if (Transport* trans = ToTransport())
132  trans->SetDelayedAddModelToMap();
133  else
134  GetMap()->Insert(*m_model);
135  }
136  EnableCollision(toggledState);
138  }
139 }
GOState GetGoState() const
Definition: GameObject.h:728
LootState getLootState() const
Definition: GameObject.h:748
Map * GetMap() const
Definition: Object.h:841
void AddObject(T *object)
GameObjectModel * m_model
Definition: GameObject.h:863
void Insert(const GameObjectModel &mdl)
Definition: Map.h:534
const bool & IsInWorld() const
Definition: Object.h:135
ZoneScript * m_zoneScript
Definition: Object.h:934
Transport * ToTransport()
Definition: GameObject.h:830
bool IsTransport() const
Definition: GameObject.cpp:773
void EnableCollision(bool enable)
virtual void AddToWorld()
Definition: Object.h:139
GameobjectTypes GetGoType() const
Definition: GameObject.h:720
virtual void OnGameObjectCreate(GameObject *, bool)
Definition: ZoneScript.h:45
void GameObject::AddUniqueUse ( Player player)

Definition at line 556 of file GameObject.cpp.

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

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

557 {
558  if (m_unique_users.find(player->GetGUIDLow()) != m_unique_users.end())
559  return;
560  AddUse();
561  m_unique_users.insert(player->GetGUID());
562 }
uint32 GetGUIDLow() const
Definition: Object.h:166
std::set< uint64 > m_unique_users
Definition: GameObject.h:855
void AddUse()
Definition: GameObject.h:770
const uint64 & GetGUID() const
Definition: Object.h:162
void GameObject::AddUse ( )
inline

Definition at line 770 of file GameObject.h.

Referenced by AddUniqueUse(), WorldSession::DoLootRelease(), and Use().

771  {
772  ++m_usetimes;
773  }
uint32 m_usetimes
Definition: GameObject.h:856
bool GameObject::AIM_Initialize ( )
protected

Definition at line 76 of file GameObject.cpp.

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

Referenced by Create(), and Update().

77 {
78  delete m_AI;
79 
81 
82  if (!m_AI)
83  return false;
84 
85  m_AI->InitializeAI();
86  return true;
87 }
GameObjectAI * m_AI
Definition: GameObject.h:867
virtual void InitializeAI()
Definition: GameObjectAI.h:38
GameObjectAI * SelectGameObjectAI(GameObject *go)
void GameObject::Animate ( uint32  anim = 0)
void GameObject::CastSpell ( Unit target,
uint32  spellId,
bool  triggered = true 
)

Definition at line 1505 of file GameObject.cpp.

References Unit::CastSpell(), SpellEntry::EffectImplicitTargetA, Object::GetGUID(), GetOwner(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), GetSpellCastTime(), IsPositiveSpell(), MAX_SPELL_EFFECTS, Object::RemoveFlag(), Unit::SetFaction(), Object::SetFlag(), sSpellStore, WorldObject::SummonTrigger(), TARGET_UNIT_CASTER, UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_NPC, UNIT_FLAG_IMMUNE_TO_PC, and UNIT_FLAG_PVP_ATTACKABLE.

Referenced by Update(), and Use().

1506 {
1507  SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId);
1508  if (!spellProto)
1509  return;
1510 
1511  bool self = false;
1512  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1513  {
1514  if (spellProto->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER)
1515  {
1516  self = true;
1517  break;
1518  }
1519  }
1520 
1521  if (self)
1522  {
1523  if (target)
1524  target->CastSpell(target, spellProto, triggered);
1525  return;
1526  }
1527 
1528  //summon world trigger
1529  Creature* trigger = SummonTrigger(GetPositionX(), GetPositionY(), GetPositionZ(), 0, GetSpellCastTime(spellProto) + 100);
1530  if (!trigger)
1531  return;
1532 
1533  // remove immunity flags, to allow spell to target anything
1535 
1536  if (Unit* owner = GetOwner())
1537  {
1538  trigger->SetFaction(owner->GetFaction());
1539  if (owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
1541  trigger->CastSpell(target ? target : trigger, spellId, triggered, 0, 0, owner->GetGUID());
1542  }
1543  else
1544  {
1545  trigger->SetFaction(IsPositiveSpell(spellId) ? 35 : 14);
1546  // Set owner guid for target if no owner available - needed by trigger auras
1547  trigger->CastSpell(target ? target : trigger, spellProto, triggered, nullptr, nullptr, target ? target->GetGUID() : 0);
1548  }
1549 }
Unit * GetOwner() const
Definition: GameObject.cpp:783
uint32 GetSpellCastTime(SpellEntry const *spellInfo, Spell const *spell)
Definition: SpellMgr.cpp:248
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:985
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
ACE_UINT8 uint8
Definition: Define.h:73
float GetPositionY() const
Definition: Position.h:98
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
float GetPositionZ() const
Definition: Position.h:99
uint32 EffectImplicitTargetA[MAX_SPELL_EFFECTS]
Definition: DBCStructure.h:731
bool IsPositiveSpell(uint32 spellId)
Definition: SpellMgr.cpp:773
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1006
void SetFaction(uint32 faction)
Definition: Unit.h:1117
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI *(*GetAI)(Creature *)=NULL)
Definition: Object.cpp:2253
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:670
float GetPositionX() const
Definition: Position.h:97
Definition: Unit.h:908
const uint64 & GetGUID() const
Definition: Object.h:162
void GameObject::CleanupsBeforeDelete ( )
overridevirtual

Reimplemented from WorldObject.

Definition at line 89 of file GameObject.cpp.

References GetGOInfo(), Object::GetGUIDLow(), GetOwnerGUID(), ObjectAccessor::GetUnit(), GUID_LOPART, IS_PET_GUID, IS_PLAYER_GUID, Object::IsInWorld(), m_spellId, Object::m_uint32Values, RemoveFromWorld(), Unit::RemoveGameObject(), and sLog.

90 {
91  if (IsInWorld())
93 
94  if (m_uint32Values) // field array can be not exist if GameOBject not loaded
95  {
96  // Possible crash at access to deleted GO in Unit::m_gameobj
97  if (uint64 owner_guid = GetOwnerGUID())
98  {
99  Unit* owner = ObjectAccessor::GetUnit(*this, owner_guid);
100  if (owner)
101  owner->RemoveGameObject(this, false);
102  else
103  {
104  const char* ownerType = "creature";
105  if (IS_PLAYER_GUID(owner_guid))
106  ownerType = "player";
107  else if (IS_PET_GUID(owner_guid))
108  ownerType = "pet";
109 
110  sLog.outError("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.",
111  GetGUIDLow(), GetGOInfo()->id, m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), GUID_LOPART(owner_guid), ownerType);
112  }
113  }
114  }
115 }
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
uint32 * m_uint32Values
Definition: Object.h:432
uint64 GetOwnerGUID() const
Definition: GameObject.h:664
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 GetGUIDLow() const
Definition: Object.h:166
void RemoveFromWorld() override
Definition: GameObject.cpp:141
#define IS_PET_GUID(Guid)
Definition: ObjectGuid.h:67
#define IS_PLAYER_GUID(Guid)
Definition: ObjectGuid.h:69
const bool & IsInWorld() const
Definition: Object.h:135
ACE_UINT64 uint64
Definition: Define.h:70
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:4729
uint32 m_spellId
Definition: GameObject.h:845
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
static Unit * GetUnit(WorldObject const &, uint64 guid)
Definition: Unit.h:908
void GameObject::ClearSkillupList ( )
inline

Definition at line 764 of file GameObject.h.

765  {
766  m_SkillupList.clear();
767  }
std::list< uint32 > m_SkillupList
Definition: GameObject.h:852
bool GameObject::Create ( uint32  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 at line 166 of file GameObject.cpp.

References Object::_Create(), AIM_Initialize(), ASSERT, GameObjectModel::Create(), GameObjectInfo::displayId, GameObjectInfo::faction, GameObjectInfo::flags, GAMEOBJECT_ARTKIT, GAMEOBJECT_DISPLAYID, GAMEOBJECT_FACTION, GAMEOBJECT_FLAGS, GAMEOBJECT_POS_X, GAMEOBJECT_POS_Y, GAMEOBJECT_POS_Z, GAMEOBJECT_ROTATION, Map::GetId(), HIGHGUID_GAMEOBJECT, GameObjectInfo::id, Position::IsPositionValid(), m_goInfo, m_model, MAX_GAMEOBJECT_TYPE, OBJECT_FIELD_ENTRY, Position::Relocate(), Object::SetFloatValue(), SetGoAnimProgress(), SetGoState(), SetGoType(), WorldObject::SetMap(), Object::SetObjectScale(), SetPhaseMask(), Object::SetUInt32Value(), WorldObject::SetZoneScript(), GameObjectInfo::size, sLog, sObjectMgr, GameObjectInfo::type, and UpdateRotationFields().

Referenced by Battleground::AddObject(), Spell::EffectDuel(), Spell::EffectSummonObject(), Spell::EffectSummonObjectWild(), Spell::EffectTransmitted(), OutdoorPvPSI::HandleDropFlag(), ChatHandler::HandleGameObjectCommand(), LoadGameObjectFromDB(), and WorldObject::SummonGameObject().

167 {
168  ASSERT(map);
169  SetMap(map);
170 
171  Relocate(x, y, z, ang);
172 
173  if (!IsPositionValid())
174  {
175  sLog.outError("Gameobject (GUID: %u Entry: %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", guidlow, name_id, x, y);
176  return false;
177  }
178 
179  GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(name_id);
180  if (!goinfo)
181  {
182  sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: Invalid entry in gameobject_template. Map: %u (X: %f Y: %f Z: %f) ang: %f rotation0: %f rotation1: %f rotation2: %f rotation3: %f", guidlow, name_id, map->GetId(), x, y, z, ang, rotation0, rotation1, rotation2, rotation3);
183  return false;
184  }
185 
186  Object::_Create(guidlow, goinfo->id, HIGHGUID_GAMEOBJECT);
187 
188  m_goInfo = goinfo;
189 
190  if (goinfo->type >= MAX_GAMEOBJECT_TYPE)
191  {
192  sLog.outErrorDb("Gameobject (GUID: %u Entry: %u) not created: Invalid GO type '%u' in gameobject_template. It will crash the client if created.", guidlow, name_id, goinfo->type);
193  return false;
194  }
195 
196  SetPhaseMask(phaseMask, false);
200 
201  SetFloatValue(GAMEOBJECT_ROTATION + 0, rotation0);
202  SetFloatValue(GAMEOBJECT_ROTATION + 1, rotation1);
203 
204  UpdateRotationFields(rotation2, rotation3); // GAMEOBJECT_FACING, GAMEOBJECT_ROTATION, GAMEOBJECT_PARENTROTATION+2/3
205 
206  SetObjectScale(goinfo->size);
207 
210 
212 
214 
216  SetGoType(GameobjectTypes(goinfo->type));
217  SetGoState(go_state);
218 
219  SetGoAnimProgress(animprogress);
220 
222 
223  SetZoneScript();
224 
225  AIM_Initialize();
226 
227  return true;
228 }
#define MAX_GAMEOBJECT_TYPE
GameobjectTypes
GameObjectInfo const * m_goInfo
Definition: GameObject.h:859
bool AIM_Initialize()
Definition: GameObject.cpp:76
void SetGoType(GameobjectTypes type)
Definition: GameObject.h:724
void SetObjectScale(float scale)
Definition: Object.h:205
virtual void SetMap(Map *map)
Definition: Object.cpp:1954
#define sLog
Log class singleton.
Definition: Log.h:187
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
uint32 displayId
Definition: GameObject.h:40
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint32 GetId(void) const
Definition: Map.h:333
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:125
GameObjectModel * m_model
Definition: GameObject.h:863
void Relocate(float x, float y)
Definition: Position.h:65
void SetGoAnimProgress(uint32 animprogress)
Definition: GameObject.h:741
void SetGoState(GOState state)
void SetPhaseMask(uint32 newPhaseMask, bool update) override
void SetZoneScript()
Definition: Object.cpp:2102
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:859
uint32 flags
Definition: GameObject.h:44
#define ASSERT
Definition: Errors.h:29
bool IsPositionValid() const
Definition: Position.cpp:40
static GameObjectModel * Create(const GameObject &go)
uint32 faction
Definition: GameObject.h:43
void UpdateRotationFields(float rotation2=0.0f, float rotation3=0.0f)
void GameObject::Delete ( )

Definition at line 564 of file GameObject.cpp.

References WorldObject::AddObjectToRemoveList(), GAMEOBJECT_FLAGS, GetDBTableGUIDLow(), GetGOInfo(), Object::GetGUID(), GO_NOT_READY, GO_STATE_READY, WorldObject::SendObjectDeSpawnAnim(), SetGoState(), SetLootState(), Object::SetUInt32Value(), and sPoolMgr.

Referenced by OPvPCapturePoint::DelCapturePoint(), OPvPCapturePoint::DelObject(), Battleground::DelObject(), Spell::EffectSummonObject(), OutdoorPvPSI::HandleCustomSpell(), ChatHandler::HandleDelObjectCommand(), Unit::RemoveGameObject(), BattlegroundWS::RespawnFlagAfterDrop(), BattlegroundEY::RespawnFlagAfterDrop(), Update(), and Use().

565 {
567 
569 
572 
573  uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
574  if (poolid)
575  sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
576  else
578 }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
void SetLootState(LootState s, Unit *unit=NULL)
#define sPoolMgr
Definition: PoolMgr.h:162
void AddObjectToRemoveList()
Definition: Object.cpp:1990
void SetGoState(GOState state)
void SendObjectDeSpawnAnim(uint64 guid)
Definition: Object.cpp:1939
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
uint32 GetDBTableGUIDLow() const
Definition: GameObject.h:607
ACE_UINT32 uint32
Definition: Define.h:71
const uint64 & GetGUID() const
Definition: Object.h:162
void GameObject::DeleteFromDB ( )

Definition at line 735 of file GameObject.cpp.

References WorldObject::GetInstanceId(), m_DBTableGuid, Database::PExecuteLog(), sObjectMgr, and WorldDatabase.

Referenced by ChatHandler::HandleDelObjectCommand().

736 {
737  sObjectMgr.SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), 0);
738  sObjectMgr.DeleteGOData(m_DBTableGuid);
739  WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
740  WorldDatabase.PExecuteLog("DELETE FROM game_event_gameobject WHERE guid = '%u'", m_DBTableGuid);
741 }
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
#define sObjectMgr
Definition: ObjectMgr.h:1285
bool PExecuteLog(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:221
uint32 m_DBTableGuid
Definition: GameObject.h:858
uint32 GetInstanceId() const
Definition: Object.h:688
void GameObject::EnableCollision ( bool  enable)

Definition at line 1650 of file GameObject.cpp.

References GameObjectModel::enable(), and m_model.

Referenced by AddToWorld(), SetGoState(), and SetLootState().

1651 {
1652  if (!m_model)
1653  return;
1654 
1655  m_model->enable(enable);
1656 }
GameObjectModel * m_model
Definition: GameObject.h:863
void enable(bool enable)
std::string GameObject::GetAIName ( ) const

Definition at line 1584 of file GameObject.cpp.

References GameObjectInfo::AIName, and m_goInfo.

Referenced by SmartScript::IsSmartGO(), GameObjectAI::Permissible(), SmartGameObjectAI::Permissible(), and FactorySelector::SelectGameObjectAI().

1585 {
1586  if (m_goInfo)
1587  return m_goInfo->AIName;
1588 
1589  return "";
1590 }
GameObjectInfo const * m_goInfo
Definition: GameObject.h:859
char const * AIName
Definition: GameObject.h:366
uint32 GameObject::GetCooldown ( ) const
inline

Definition at line 802 of file GameObject.h.

References GAMEOBJECT_TYPE_GOOBER, and GAMEOBJECT_TYPE_TRAP.

Referenced by Use().

803  {
804  switch (GetGoType())
805  {
807  return GetGOInfo()->trap.cooldown;
809  return GetGOInfo()->goober.cooldown;
810  default:
811  return 0;
812  }
813  }
struct GameObjectInfo::@59::@66 trap
GameobjectTypes GetGoType() const
Definition: GameObject.h:720
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
struct GameObjectInfo::@59::@70 goober
void GameObject::getFishLoot ( Loot loot,
Player loot_owner 
)

Definition at line 580 of file GameObject.cpp.

References Loot::clear(), Loot::FillLoot(), WorldObject::GetAreaId(), WorldObject::GetZoneId(), LootStore::HaveLootFor(), and LootTemplates_Fishing.

Referenced by Player::SendLoot().

581 {
582  fishloot->clear();
583 
584  uint32 subzone = GetAreaId();
585 
586  // if subzone loot exist use it
587  if (LootTemplates_Fishing.HaveLootFor(subzone))
588  fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner, true);
589  // else use zone loot
590  else
591  fishloot->FillLoot(GetZoneId(), LootTemplates_Fishing, loot_owner, true);
592 }
uint32 GetZoneId() const
Definition: Object.cpp:1179
uint32 GetAreaId() const
Definition: Object.cpp:1184
bool HaveLootFor(uint32 loot_id) const
Definition: LootMgr.h:184
LootStore LootTemplates_Fishing("fishing_loot_template","area id")
ACE_UINT32 uint32
Definition: Define.h:71
GameObject * GameObject::GetGameObject ( WorldObject object,
uint64  guid 
)
static

Definition at line 743 of file GameObject.cpp.

References Map::GetGameObject(), and WorldObject::GetMap().

Referenced by Battleground::DelObject(), Battleground::DoorClose(), Battleground::DoorOpen(), Battleground::GetBGObject(), and Battleground::HandleTriggerBuff().

744 {
745  return object.GetMap()->GetGameObject(guid);
746 }
uint32 GameObject::GetGoAnimProgress ( ) const
inline

Definition at line 737 of file GameObject.h.

References GAMEOBJECT_ANIMPROGRESS.

Referenced by SaveToDB(), Update(), and Use().

738  {
740  }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
uint32 GameObject::GetGoArtKit ( ) const
inline

Definition at line 732 of file GameObject.h.

References GAMEOBJECT_ARTKIT.

733  {
735  }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
GameObjectData const* GameObject::GetGOData ( ) const
inline

Definition at line 596 of file GameObject.h.

597  {
598  return m_goData;
599  }
GameObjectData const * m_goData
Definition: GameObject.h:860
GOState GameObject::GetGoState ( ) const
inline

Definition at line 728 of file GameObject.h.

References GAMEOBJECT_STATE.

Referenced by Map::_ScriptProcessDoor(), AddToWorld(), Battleground::DoorClose(), SaveToDB(), SetLootState(), SwitchDoorOrButton(), and Update().

729  {
731  }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
GOState
Definition: GameObject.h:527
float GameObject::GetInteractionDistance ( ) const
Todo:
find out how the client calculates the maximal usage distance to spellless working

Definition at line 1609 of file GameObject.cpp.

References CONTACT_DISTANCE, GAMEOBJECT_TYPE_FISHINGHOLE, GAMEOBJECT_TYPE_FISHINGNODE, GAMEOBJECT_TYPE_GUILD_BANK, GAMEOBJECT_TYPE_MAILBOX, GetGoType(), and INTERACTION_DISTANCE.

Referenced by Player::GetGameObjectIfCanInteractWith().

1610 {
1611  switch (GetGoType())
1612  {
1614  // gameobjects like guildbanks and mailboxes - 10.0 is a just an abitrary choosen number
1617  return 10.0f;
1620  return 20.0f + CONTACT_DISTANCE; // max spell range
1621  default:
1622  return INTERACTION_DISTANCE;
1623  }
1624 }
#define INTERACTION_DISTANCE
Definition: Object.h:35
GameobjectTypes GetGoType() const
Definition: GameObject.h:720
#define CONTACT_DISTANCE
Definition: Object.h:34
uint8 GameObject::getLevelForTarget ( WorldObject const *  target) const
inlineoverridevirtual

Reimplemented from WorldObject.

Definition at line 822 of file GameObject.h.

823  {
824  if (Unit* owner = GetOwner())
825  return owner->getLevelForTarget(target);
826 
827  return 1;
828  }
Unit * GetOwner() const
Definition: GameObject.cpp:783
Definition: Unit.h:908
LootState GameObject::getLootState ( ) const
inline

Definition at line 748 of file GameObject.h.

Referenced by AddToWorld(), Battleground::DoorClose(), InstanceData::DoUseDoorOrButton(), Player::SendLoot(), Battleground::SpawnBGObject(), and Use().

749  {
750  return m_lootState;
751  }
LootState m_lootState
Definition: GameObject.h:848
const char * GameObject::GetNameForLocaleIdx ( int32  locale_idx) const
overridevirtual

Reimplemented from WorldObject.

Definition at line 1552 of file GameObject.cpp.

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

1553 {
1554  if (loc_idx >= 0)
1555  if (GameObjectLocale const* cl = sObjectMgr.GetGameObjectLocale(GetEntry()))
1556  if (cl->Name.size() > uint32(loc_idx) && !cl->Name[loc_idx].empty())
1557  return cl->Name[loc_idx].c_str();
1558 
1559  return GetName();
1560 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
const char * GetName() const
Definition: Object.h:704
uint32 GetEntry() const
Definition: Object.h:192
ACE_UINT32 uint32
Definition: Define.h:71
Unit * GameObject::GetOwner ( ) const

Definition at line 783 of file GameObject.cpp.

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

Referenced by WorldObject::CanDetectStealthOf(), CastSpell(), WorldSession::HandleGameObjectUseOpcode(), IsAlwaysVisibleFor(), RemoveFromWorld(), Update(), and Use().

784 {
785  return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
786 }
uint64 GetOwnerGUID() const
Definition: GameObject.h:664
static Unit * GetUnit(WorldObject const &, uint64 guid)
uint32 GameObject::GetRespawnDelay ( ) const
inline

Definition at line 713 of file GameObject.h.

Referenced by ChatHandler::HandleTargetObjectCommand().

714  {
715  return m_respawnDelayTime;
716  }
uint32 m_respawnDelayTime
Definition: GameObject.h:847
time_t GameObject::GetRespawnTime ( ) const
inline

Definition at line 680 of file GameObject.h.

Referenced by Player::SendLoot().

681  {
682  return m_respawnTime;
683  }
time_t m_respawnTime
Definition: GameObject.h:846
time_t GameObject::GetRespawnTimeEx ( ) const
inline

Definition at line 684 of file GameObject.h.

Referenced by ChatHandler::HandleTargetObjectCommand().

685  {
686  time_t now = time(NULL);
687  if (m_respawnTime > now)
688  return m_respawnTime;
689  else
690  return now;
691  }
time_t m_respawnTime
Definition: GameObject.h:846
uint32 GameObject::GetSpellId ( ) const
inline

Definition at line 675 of file GameObject.h.

Referenced by Unit::RemoveGameObject(), and Update().

676  {
677  return m_spellId;
678  }
uint32 m_spellId
Definition: GameObject.h:845
uint32 GameObject::GetUniqueUseCount ( ) const
inline

Definition at line 779 of file GameObject.h.

Referenced by Use().

780  {
781  return m_unique_users.size();
782  }
std::set< uint64 > m_unique_users
Definition: GameObject.h:855
uint32 GameObject::GetUseCount ( ) const
inline

Definition at line 775 of file GameObject.h.

Referenced by WorldSession::DoLootRelease().

776  {
777  return m_usetimes;
778  }
uint32 m_usetimes
Definition: GameObject.h:856
bool GameObject::hasInvolvedQuest ( uint32  quest_id) const
overridevirtual

Reimplemented from Object.

Definition at line 762 of file GameObject.cpp.

References Object::GetEntry(), and sObjectMgr.

763 {
764  QuestRelations const& qr = sObjectMgr.mGOQuestInvolvedRelations;
765  for (QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr)
766  {
767  if (itr->second == quest_id)
768  return true;
769  }
770  return false;
771 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
std::multimap< uint32, uint32 > QuestRelations
Definition: ObjectMgr.h:390
uint32 GetEntry() const
Definition: Object.h:192
bool GameObject::hasQuest ( uint32  quest_id) const
overridevirtual

Reimplemented from Object.

Definition at line 751 of file GameObject.cpp.

References Object::GetEntry(), and sObjectMgr.

752 {
753  QuestRelations const& qr = sObjectMgr.mGOQuestRelations;
754  for (QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr)
755  {
756  if (itr->second == quest_id)
757  return true;
758  }
759  return false;
760 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
std::multimap< uint32, uint32 > QuestRelations
Definition: ObjectMgr.h:390
uint32 GetEntry() const
Definition: Object.h:192
bool GameObject::IsAlwaysVisibleFor ( WorldObject const *  seer) const
overridevirtual

Reimplemented from WorldObject.

Definition at line 805 of file GameObject.cpp.

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

806 {
808  return true;
809 
810  if (IsTransport())
811  return true;
812 
813  if (!seer)
814  return false;
815 
816  // Always seen by owner and friendly units
817  if (ObjectGuid guid = GetOwnerGUID())
818  {
819  if (seer->GetGUID() == guid)
820  return true;
821 
822  Unit* owner = GetOwner();
823  if (Unit const* unitSeer = seer->ToUnit())
824  if (owner && owner->IsFriendlyTo(unitSeer))
825  return true;
826  }
827 
828  return false;
829 }
Unit * GetOwner() const
Definition: GameObject.cpp:783
uint64 GetOwnerGUID() const
Definition: GameObject.h:664
virtual bool IsAlwaysVisibleFor(WorldObject const *) const
Definition: Object.h:817
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7339
bool IsTransport() const
Definition: GameObject.cpp:773
Definition: Unit.h:908
Unit * ToUnit()
Definition: Object.h:398
bool GameObject::IsInSkillupList ( uint32  PlayerGuidLow) const
inline

Definition at line 758 of file GameObject.h.

Referenced by Spell::EffectOpenLock().

759  {
760  for (std::list<uint32>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i)
761  if (*i == PlayerGuidLow) return true;
762  return false;
763  }
std::list< uint32 > m_SkillupList
Definition: GameObject.h:852
bool GameObject::IsInvisibleDueToDespawn ( ) const
overridevirtual

Reimplemented from WorldObject.

Definition at line 831 of file GameObject.cpp.

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

832 {
834  return true;
835 
836  // Despawned
837  if (!isSpawned())
838  return true;
839 
840  return false;
841 }
virtual bool IsInvisibleDueToDespawn() const
Definition: Object.h:818
bool isSpawned() const
Definition: GameObject.h:699
bool GameObject::IsNeverVisible ( ) const
overridevirtual

Reimplemented from WorldObject.

Definition at line 794 of file GameObject.cpp.

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

795 {
797  return true;
798 
799  if (GetGoType() == GAMEOBJECT_TYPE_SPELL_FOCUS && GetGOInfo()->spellFocus.serverOnly == 1)
800  return true;
801 
802  return false;
803 }
virtual bool IsNeverVisible() const
Definition: Object.h:816
uint32 serverOnly
Definition: GameObject.h:111
GameobjectTypes GetGoType() const
Definition: GameObject.h:720
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
bool GameObject::isSpawned ( ) const
inline
bool GameObject::isSpawnedByDefault ( ) const
inline

Definition at line 705 of file GameObject.h.

Referenced by GameEventMgr::GameEventSpawn(), Player::SendLoot(), and PoolGroup< GameObject >::Spawn1Object().

706  {
707  return m_spawnedByDefault;
708  }
bool m_spawnedByDefault
Definition: GameObject.h:849
bool GameObject::IsTransport ( ) const

Definition at line 773 of file GameObject.cpp.

References GAMEOBJECT_TYPE_MO_TRANSPORT, GAMEOBJECT_TYPE_TRANSPORT, GetGOInfo(), and GameObjectInfo::type.

Referenced by AddToWorld(), IsAlwaysVisibleFor(), and SetGoState().

774 {
775  // If something is marked as a transport, don't transmit an out of range packet for it.
776  GameObjectInfo const* gInfo = GetGOInfo();
777  if (!gInfo)
778  return false;
779 
780  return gInfo->type == GAMEOBJECT_TYPE_TRANSPORT || gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT;
781 }
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
bool GameObject::IsUsedBy ( uint64  guid)
inline

Definition at line 784 of file GameObject.h.

785  {
786  return m_unique_users.find(guid) != m_unique_users.end();
787  }
std::set< uint64 > m_unique_users
Definition: GameObject.h:855
bool GameObject::LoadFromDB ( uint32  guid,
Map map 
)
inline

Definition at line 652 of file GameObject.h.

652 { return LoadGameObjectFromDB(guid, map, false); }
bool LoadGameObjectFromDB(uint32 guid, Map *map, bool addToMap=true)
Definition: GameObject.cpp:664
bool GameObject::LoadGameObjectFromDB ( uint32  guid,
Map map,
bool  addToMap = true 
)

Definition at line 664 of file GameObject.cpp.

References GameObjectData::animprogress, GameObjectData::artKit, Create(), GAMEOBJECT_FLAGS, GetGOInfo(), Map::GetInstanceId(), WorldObject::GetInstanceId(), WorldObject::GetMap(), GO_FLAG_NODESPAWN, GameObjectData::go_state, HIGHGUID_GAMEOBJECT, GameObjectData::id, m_DBTableGuid, m_goData, m_respawnDelayTime, m_respawnTime, m_spawnedByDefault, GameObjectData::orientation, GameObjectData::phaseMask, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, GameObjectData::rotation0, GameObjectData::rotation1, GameObjectData::rotation2, GameObjectData::rotation3, Object::SetFlag(), sLog, sObjectMgr, and GameObjectData::spawntimesecs.

Referenced by ObjectMgr::AddGOData(), GameEventMgr::GameEventSpawn(), ChatHandler::HandleGameObjectCommand(), and PoolGroup< GameObject >::Spawn1Object().

665 {
666  GameObjectData const* data = sObjectMgr.GetGOData(guid);
667 
668  if (!data)
669  {
670  sLog.outErrorDb("ERROR: Gameobject (GUID: %u) not found in table gameobject, can't load. ", guid);
671  return false;
672  }
673 
674  uint32 entry = data->id;
675  //uint32 map_id = data->mapid;
676  uint32 phaseMask = data->phaseMask;
677  float x = data->posX;
678  float y = data->posY;
679  float z = data->posZ;
680  float ang = data->orientation;
681 
682  float rotation0 = data->rotation0;
683  float rotation1 = data->rotation1;
684  float rotation2 = data->rotation2;
685  float rotation3 = data->rotation3;
686 
687  uint32 animprogress = data->animprogress;
688  GOState go_state = data->go_state;
689  uint32 artKit = data->artKit;
690 
691  m_DBTableGuid = guid;
692  if (map->GetInstanceId() != 0) guid = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
693 
694  if (!Create(guid, entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit))
695  return false;
696 
697  if (data->spawntimesecs >= 0)
698  {
699  m_spawnedByDefault = true;
700 
701  if (!GetGOInfo()->GetDespawnPossibility() && !GetGOInfo()->IsDespawnAtAction())
702  {
704  m_respawnDelayTime = 0;
705  m_respawnTime = 0;
706  }
707  else
708  {
710  m_respawnTime = sObjectMgr.GetGORespawnTime(m_DBTableGuid, map->GetInstanceId());
711 
712  // ready to respawn
713  if (m_respawnTime && m_respawnTime <= time(NULL))
714  {
715  m_respawnTime = 0;
716  sObjectMgr.SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), 0);
717  }
718  }
719  }
720  else
721  {
722  m_spawnedByDefault = false;
724  m_respawnTime = 0;
725  }
726 
727  m_goData = data;
728 
729  if (addToMap && !GetMap()->AddToMap(this))
730  return false;
731 
732  return true;
733 }
Map * GetMap() const
Definition: Object.h:841
int32 spawntimesecs
Definition: GameObject.h:551
uint32 m_respawnDelayTime
Definition: GameObject.h:847
#define sLog
Log class singleton.
Definition: Log.h:187
GameObjectData const * m_goData
Definition: GameObject.h:860
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:985
float orientation
Definition: GameObject.h:546
#define sObjectMgr
Definition: ObjectMgr.h:1285
time_t m_respawnTime
Definition: GameObject.h:846
uint32 m_DBTableGuid
Definition: GameObject.h:858
uint32 GetInstanceId() const
Definition: Object.h:688
GOState
Definition: GameObject.h:527
bool m_spawnedByDefault
Definition: GameObject.h:849
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
uint32 animprogress
Definition: GameObject.h:552
bool Create(uint32 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:166
ACE_UINT32 uint32
Definition: Define.h:71
uint32 phaseMask
Definition: GameObject.h:542
uint32 GetInstanceId() const
Definition: Map.h:390
GOState go_state
Definition: GameObject.h:553
GameObject * GameObject::LookupFishingHoleAround ( float  range)

Definition at line 930 of file GameObject.cpp.

References Oregon::ComputeCellCoord(), WorldObject::GetMap(), Position::GetPositionX(), Position::GetPositionY(), and Cell::Visit().

Referenced by Use().

931 {
932  GameObject* ok = NULL;
933 
935  Cell cell(p);
936  Oregon::NearestGameObjectFishingHole u_check(*this, range);
938 
940  cell.Visit(p, grid_object_checker, *GetMap(), *this, range);
941 
942  return ok;
943 }
Map * GetMap() const
Definition: Object.h:841
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
float GetPositionX() const
Definition: Position.h:97
void GameObject::Refresh ( )

Definition at line 546 of file GameObject.cpp.

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

Referenced by ChatHandler::HandleMoveObjectCommand(), and ChatHandler::HandleTurnObjectCommand().

547 {
548  // not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway)
550  return;
551 
552  if (isSpawned())
553  GetMap()->AddToMap(this);
554 }
bool AddToMap(T *)
Definition: Map.cpp:424
Map * GetMap() const
Definition: Object.h:841
time_t m_respawnTime
Definition: GameObject.h:846
bool isSpawned() const
Definition: GameObject.h:699
bool m_spawnedByDefault
Definition: GameObject.h:849
void GameObject::RemoveFromWorld ( )
overridevirtual

Reimplemented from WorldObject.

Definition at line 141 of file GameObject.cpp.

References GetGOInfo(), Object::GetGUIDLow(), WorldObject::GetMap(), GetOwner(), GetOwnerGUID(), GUID_LOPART, Oregon::Singleton< ObjectAccessor, Oregon::ClassLevelLockable< ObjectAccessor, ACE_Thread_Mutex > >::Instance(), Object::IsInWorld(), m_model, WorldObject::m_zoneScript, ZoneScript::OnGameObjectCreate(), Map::Remove(), WorldObject::RemoveFromWorld(), ObjectAccessor::RemoveObject(), and sLog.

Referenced by CleanupsBeforeDelete().

142 {
143  // Remove the gameobject from the accessor
144  if (IsInWorld())
145  {
146  if (m_zoneScript)
147  m_zoneScript->OnGameObjectCreate(this, false);
148 
149  // Possible crash at access to deleted GO in Unit::m_gameobj
150  if (uint64 owner_guid = GetOwnerGUID())
151  {
152  if (Unit* owner = GetOwner())
153  owner->RemoveGameObject(this, false);
154  else
155  sLog.outError("Delete GameObject (GUID: %u Entry: %u) that has references in invalid creature %u GO list. Crash possible.", GetGUIDLow(), GetGOInfo()->id, GUID_LOPART(owner_guid));
156  }
157 
158  if (m_model)
159  if (GetMap()->Contains(*m_model))
160  GetMap()->Remove(*m_model);
163  }
164 }
Unit * GetOwner() const
Definition: GameObject.cpp:783
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
Map * GetMap() const
Definition: Object.h:841
uint64 GetOwnerGUID() const
Definition: GameObject.h:664
#define sLog
Log class singleton.
Definition: Log.h:187
void Remove(const GameObjectModel &mdl)
Definition: Map.h:533
uint32 GetGUIDLow() const
Definition: Object.h:166
GameObjectModel * m_model
Definition: GameObject.h:863
const bool & IsInWorld() const
Definition: Object.h:135
ZoneScript * m_zoneScript
Definition: Object.h:934
virtual void RemoveFromWorld() override
Definition: Object.cpp:1169
void RemoveObject(T *object)
ACE_UINT64 uint64
Definition: Define.h:70
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
Definition: Unit.h:908
virtual void OnGameObjectCreate(GameObject *, bool)
Definition: ZoneScript.h:45
void GameObject::ResetDoorOrButton ( )

Definition at line 945 of file GameObject.cpp.

References GO_JUST_DEACTIVATED, GO_READY, m_cooldownTime, m_lootState, SetLootState(), and SwitchDoorOrButton().

Referenced by InstanceData::DoUseDoorOrButton(), and Update().

946 {
948  return;
949 
950  SwitchDoorOrButton(false);
952  m_cooldownTime = 0;
953 }
LootState m_lootState
Definition: GameObject.h:848
void SwitchDoorOrButton(bool activate, bool alternative=false)
Definition: GameObject.cpp:977
time_t m_cooldownTime
Definition: GameObject.h:850
void SetLootState(LootState s, Unit *unit=NULL)
void GameObject::Respawn ( )

Definition at line 843 of file GameObject.cpp.

References WorldObject::GetInstanceId(), m_DBTableGuid, m_respawnTime, m_spawnedByDefault, and sObjectMgr.

Referenced by Oregon::RespawnDo::operator()().

844 {
846  {
847  m_respawnTime = time(NULL);
848  sObjectMgr.SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), 0);
849  }
850 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
time_t m_respawnTime
Definition: GameObject.h:846
uint32 m_DBTableGuid
Definition: GameObject.h:858
uint32 GetInstanceId() const
Definition: Object.h:688
bool m_spawnedByDefault
Definition: GameObject.h:849
void GameObject::SaveRespawnTime ( )
overridevirtual

Reimplemented from WorldObject.

Definition at line 788 of file GameObject.cpp.

References GameObjectData::dbData, WorldObject::GetInstanceId(), m_DBTableGuid, m_goData, m_respawnTime, m_spawnedByDefault, and sObjectMgr.

Referenced by Update().

789 {
790  if (m_goData && m_goData->dbData && m_respawnTime > time(NULL) && m_spawnedByDefault)
791  sObjectMgr.SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), m_respawnTime);
792 }
GameObjectData const * m_goData
Definition: GameObject.h:860
#define sObjectMgr
Definition: ObjectMgr.h:1285
time_t m_respawnTime
Definition: GameObject.h:846
uint32 m_DBTableGuid
Definition: GameObject.h:858
uint32 GetInstanceId() const
Definition: Object.h:688
bool m_spawnedByDefault
Definition: GameObject.h:849
void GameObject::SaveToDB ( )

Definition at line 594 of file GameObject.cpp.

References WorldLocation::GetMapId(), m_DBTableGuid, GameObjectData::phaseMask, sLog, sObjectMgr, and GameObjectData::spawnMask.

Referenced by ChatHandler::HandleGameObjectCommand(), ChatHandler::HandleGOPhaseCommand(), ChatHandler::HandleMoveObjectCommand(), and ChatHandler::HandleTurnObjectCommand().

595 {
596  // this should only be used when the gameobject has already been loaded
597  // preferably after adding to map, because mapid may not be valid otherwise
598  GameObjectData const* data = sObjectMgr.GetGOData(m_DBTableGuid);
599  if (!data)
600  {
601  sLog.outError("GameObject::SaveToDB failed, cannot get gameobject data!");
602  return;
603  }
604 
605  SaveToDB(GetMapId(), data->spawnMask, data->phaseMask);
606 }
#define sLog
Log class singleton.
Definition: Log.h:187
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint32 m_DBTableGuid
Definition: GameObject.h:858
uint32 GetMapId() const
Definition: Object.h:591
void SaveToDB()
Definition: GameObject.cpp:594
uint32 phaseMask
Definition: GameObject.h:542
void GameObject::SaveToDB ( uint32  mapid,
uint8  spawnMask,
uint32  phaseMask 
)

Definition at line 608 of file GameObject.cpp.

References GameObjectData::animprogress, GameObjectData::artKit, Database::BeginTransaction(), Database::CommitTransaction(), GAMEOBJECT_ARTKIT, GAMEOBJECT_FACING, GAMEOBJECT_POS_X, GAMEOBJECT_POS_Y, GAMEOBJECT_POS_Z, GAMEOBJECT_ROTATION, Object::GetEntry(), Object::GetFloatValue(), GetGoAnimProgress(), GetGOInfo(), GetGoState(), Object::GetGUIDLow(), Object::GetUInt32Value(), GameObjectData::go_state, GameObjectData::id, m_DBTableGuid, m_respawnDelayTime, m_spawnedByDefault, GameObjectData::mapid, OBJECT_FIELD_ENTRY, GameObjectData::orientation, Database::PExecuteLog(), GameObjectData::phaseMask, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, GameObjectData::rotation0, GameObjectData::rotation1, GameObjectData::rotation2, GameObjectData::rotation3, sObjectMgr, GameObjectData::spawnMask, GameObjectData::spawntimesecs, and WorldDatabase.

609 {
610  const GameObjectInfo* goI = GetGOInfo();
611 
612  if (!goI)
613  return;
614 
615  if (!m_DBTableGuid)
617  // update in loaded data (changing data only in this place)
618  GameObjectData& data = sObjectMgr.NewGOData(m_DBTableGuid);
619 
620  // data->guid = guid don't must be update at save
621  data.id = GetEntry();
622  data.mapid = mapid;
623  data.phaseMask = phaseMask;
634  data.go_state = GetGoState();
635  data.spawnMask = spawnMask;
637 
638  // updated in DB
639  std::ostringstream ss;
640  ss << "INSERT INTO gameobject VALUES ("
641  << m_DBTableGuid << ", "
643  << mapid << ", "
644  << (uint32)phaseMask << ", "
645  << (uint32)spawnMask << ", "
646  << GetFloatValue(GAMEOBJECT_POS_X) << ", "
647  << GetFloatValue(GAMEOBJECT_POS_Y) << ", "
648  << GetFloatValue(GAMEOBJECT_POS_Z) << ", "
649  << GetFloatValue(GAMEOBJECT_FACING) << ", "
651  << GetFloatValue(GAMEOBJECT_ROTATION + 1) << ", "
652  << GetFloatValue(GAMEOBJECT_ROTATION + 2) << ", "
653  << GetFloatValue(GAMEOBJECT_ROTATION + 3) << ", "
654  << m_respawnDelayTime << ", "
655  << uint32(GetGoAnimProgress()) << ", "
656  << uint32(GetGoState()) << ")";
657 
658  WorldDatabase.BeginTransaction();
659  WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
660  WorldDatabase.PExecuteLog("%s", ss.str().c_str());
661  WorldDatabase.CommitTransaction();
662 }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
GOState GetGoState() const
Definition: GameObject.h:728
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
int32 spawntimesecs
Definition: GameObject.h:551
uint32 m_respawnDelayTime
Definition: GameObject.h:847
ACE_INT32 int32
Definition: Define.h:67
uint32 GetGUIDLow() const
Definition: Object.h:166
float orientation
Definition: GameObject.h:546
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint32 GetGoAnimProgress() const
Definition: GameObject.h:737
uint32 m_DBTableGuid
Definition: GameObject.h:858
bool m_spawnedByDefault
Definition: GameObject.h:849
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
uint32 animprogress
Definition: GameObject.h:552
uint32 GetEntry() const
Definition: Object.h:192
ACE_UINT32 uint32
Definition: Define.h:71
uint32 phaseMask
Definition: GameObject.h:542
GOState go_state
Definition: GameObject.h:553
const float & GetFloatValue(uint16 index) const
Definition: Object.h:246
void GameObject::Say ( const char *  text,
uint32  language,
uint64  TargetGuid 
)
inline

Definition at line 614 of file GameObject.h.

615  {
616  MonsterSay(text, language, TargetGuid);
617  }
void MonsterSay(const char *text, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1490
void GameObject::Say ( int32  textId,
uint32  language,
uint64  TargetGuid 
)
inline

Definition at line 630 of file GameObject.h.

631  {
632  MonsterSay(textId, language, TargetGuid);
633  }
void MonsterSay(const char *text, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1490
void GameObject::SetDisplayId ( uint32  displayid)
protected

Definition at line 1639 of file GameObject.cpp.

References GAMEOBJECT_DISPLAYID, Object::SetUInt32Value(), and UpdateModel().

1640 {
1642  UpdateModel();
1643 }
void UpdateModel()
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
void GameObject::SetGoAnimProgress ( uint32  animprogress)
inline

Definition at line 741 of file GameObject.h.

References GAMEOBJECT_ANIMPROGRESS.

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

742  {
744  }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
void GameObject::SetGoArtKit ( uint32  artkit)

Definition at line 969 of file GameObject.cpp.

References GameObjectData::artKit, GAMEOBJECT_ARTKIT, m_DBTableGuid, Object::SetUInt32Value(), and sObjectMgr.

Referenced by OPvPCapturePointHP::ChangeState(), OPvPCapturePointTF::ChangeState(), OPvPCapturePointEP::ChangeState(), and OPvPCapturePointNA::ChangeState().

970 {
972  GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr.GetGOData(m_DBTableGuid));
973  if (data)
974  data->artKit = kit;
975 }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint32 m_DBTableGuid
Definition: GameObject.h:858
void GameObject::SetGoState ( GOState  state)

Definition at line 1592 of file GameObject.cpp.

References EnableCollision(), GAMEOBJECT_STATE, GO_STATE_READY, Object::IsInWorld(), IsTransport(), m_model, and Object::SetUInt32Value().

Referenced by Transport::Create(), Create(), Delete(), InstanceData::HandleGameObject(), ChatHandler::HandleObjectStateCommand(), SwitchDoorOrButton(), Update(), InstanceData::UpdateDoorState(), and Use().

1593 {
1595  if (m_model && !IsTransport())
1596  {
1597  if (!IsInWorld())
1598  return;
1599 
1600  // startOpen determines whether we are going to add or remove the LoS on activation
1601  bool collision = false;
1602  if (state == GO_STATE_READY)
1603  collision = !collision;
1604 
1605  EnableCollision(collision);
1606  }
1607 }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
GameObjectModel * m_model
Definition: GameObject.h:863
const bool & IsInWorld() const
Definition: Object.h:135
bool IsTransport() const
Definition: GameObject.cpp:773
void EnableCollision(bool enable)
void GameObject::SetGoType ( GameobjectTypes  type)
inline

Definition at line 724 of file GameObject.h.

References GAMEOBJECT_TYPE_ID.

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

725  {
727  }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
void GameObject::SetLootState ( LootState  s,
Unit unit = NULL 
)

Definition at line 1489 of file GameObject.cpp.

References AI(), EnableCollision(), GetGoState(), GO_ACTIVATED, GO_JUST_DEACTIVATED, GO_READY, GO_STATE_READY, m_lootState, m_model, and GameObjectAI::OnStateChanged().

Referenced by Delete(), WorldSession::DoLootRelease(), Battleground::DoorClose(), Battleground::DoorOpen(), ChatHandler::HandleActivateObjectCommand(), ResetDoorOrButton(), Map::ScriptsProcess(), Spell::SendLoot(), Player::SendLoot(), Battleground::SpawnBGObject(), Update(), Use(), and UseDoorOrButton().

1490 {
1491  m_lootState = s;
1492 
1493  AI()->OnStateChanged(s, unit);
1494  if (m_model)
1495  {
1496  bool collision = false;
1497  // Use the current go state
1498  if ((GetGoState() != GO_STATE_READY && (s == GO_ACTIVATED || s == GO_JUST_DEACTIVATED)) || s == GO_READY)
1499  collision = !collision;
1500 
1501  EnableCollision(collision);
1502  }
1503 }
LootState m_lootState
Definition: GameObject.h:848
GameObjectAI * AI() const
Definition: GameObject.h:840
virtual void OnStateChanged(uint32, Unit *)
Definition: GameObjectAI.h:54
GOState GetGoState() const
Definition: GameObject.h:728
GameObjectModel * m_model
Definition: GameObject.h:863
void EnableCollision(bool enable)
void GameObject::SetOwnerGUID ( uint64  owner)
inline

Definition at line 656 of file GameObject.h.

References OBJECT_FIELD_CREATED_BY.

Referenced by Unit::AddGameObject(), Spell::EffectTransmitted(), Unit::RemoveGameObject(), and Use().

657  {
658  // Owner already found and different than expected owner - remove object from old owner
659  if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
660  assert(false);
661  m_spawnedByDefault = false; // all object with owner is despawned after delay
663  }
uint64 GetOwnerGUID() const
Definition: GameObject.h:664
void SetUInt64Value(uint16 index, const uint64 &value)
Definition: Object.cpp:798
bool m_spawnedByDefault
Definition: GameObject.h:849
void GameObject::SetPhaseMask ( uint32  newPhaseMask,
bool  update 
)
overridevirtual

Reimplemented from WorldObject.

Definition at line 1645 of file GameObject.cpp.

References WorldObject::SetPhaseMask().

Referenced by Create(), and ChatHandler::HandleGOPhaseCommand().

1646 {
1647  WorldObject::SetPhaseMask(newPhaseMask, update);
1648 }
virtual void SetPhaseMask(uint32 newPhaseMask, bool update)
Definition: Object.cpp:2536
void GameObject::SetSpawnedByDefault ( bool  b)
inline

Definition at line 709 of file GameObject.h.

Referenced by WorldObject::SummonGameObject().

710  {
711  m_spawnedByDefault = b;
712  }
bool m_spawnedByDefault
Definition: GameObject.h:849
void GameObject::SetSpellId ( uint32  id)
inline

Definition at line 670 of file GameObject.h.

References GameObjectInfo::id.

Referenced by Spell::EffectDuel(), Spell::EffectSummonObject(), Spell::EffectSummonObjectWild(), Spell::EffectTransmitted(), and Use().

671  {
672  m_spawnedByDefault = false; // all summoned object is despawned after delay
673  m_spellId = id;
674  }
bool m_spawnedByDefault
Definition: GameObject.h:849
uint32 m_spellId
Definition: GameObject.h:845
void GameObject::SwitchDoorOrButton ( bool  activate,
bool  alternative = false 
)
private

Definition at line 977 of file GameObject.cpp.

References GAMEOBJECT_FLAGS, GetGoState(), GO_FLAG_IN_USE, GO_STATE_ACTIVE, GO_STATE_ACTIVE_ALTERNATIVE, GO_STATE_READY, Object::RemoveFlag(), Object::SetFlag(), and SetGoState().

Referenced by ResetDoorOrButton(), and UseDoorOrButton().

978 {
979  if (activate)
981  else
983 
984  if (GetGoState() == GO_STATE_READY) //if closed -> open
986  else //if open -> close
988 }
GOState GetGoState() const
Definition: GameObject.h:728
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:985
void SetGoState(GOState state)
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1006
void GameObject::TextEmote ( const char *  text,
uint64  TargetGuid 
)
inline

Definition at line 622 of file GameObject.h.

623  {
624  MonsterTextEmote(text, TargetGuid);
625  }
void MonsterTextEmote(const char *text, uint64 TargetGuid, bool IsBossEmote=false)
Definition: Object.cpp:1504
void GameObject::TextEmote ( int32  textId,
uint64  TargetGuid 
)
inline

Definition at line 638 of file GameObject.h.

639  {
640  MonsterTextEmote(textId, TargetGuid);
641  }
void MonsterTextEmote(const char *text, uint64 TargetGuid, bool IsBossEmote=false)
Definition: Object.cpp:1504
Transport* GameObject::ToTransport ( )
inline

Definition at line 830 of file GameObject.h.

References GAMEOBJECT_TYPE_TRANSPORT, and GameObjectInfo::type.

Referenced by AddToWorld().

830 { if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<Transport*>(this); else return NULL; }
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
Transport const* GameObject::ToTransport ( ) const
inline

Definition at line 831 of file GameObject.h.

References GAMEOBJECT_TYPE_TRANSPORT, GameObjectInfo::spellId, and GameObjectInfo::type.

831 { if (GetGOInfo()->type == GAMEOBJECT_TYPE_TRANSPORT) return reinterpret_cast<Transport const*>(this); else return NULL; }
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
void GameObject::TriggeringLinkedGameObject ( uint32  trapEntry,
Unit target 
)

Definition at line 896 of file GameObject.cpp.

References Unit::CastSpell(), Oregon::ComputeCellCoord(), CONTACT_DISTANCE, GAMEOBJECT_TYPE_TRAP, WorldObject::GetMap(), Position::GetPositionX(), Position::GetPositionY(), GetSpellMaxRange(), SQLStorage::LookupEntry(), SpellEntry::rangeIndex, sGOStorage, sSpellRangeStore, sSpellStore, GameObjectInfo::trap, GameObjectInfo::type, and Cell::Visit().

Referenced by Spell::SendLoot().

897 {
898  GameObjectInfo const* trapInfo = sGOStorage.LookupEntry<GameObjectInfo>(trapEntry);
899  if (!trapInfo || trapInfo->type != GAMEOBJECT_TYPE_TRAP)
900  return;
901 
902  SpellEntry const* trapSpell = sSpellStore.LookupEntry(trapInfo->trap.spellId);
903  if (!trapSpell) // checked at load already
904  return;
905 
906  float range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(trapSpell->rangeIndex));
907  if (range < CONTACT_DISTANCE)
908  range = CONTACT_DISTANCE;
909 
910  // search nearest linked GO
911  GameObject* trapGO = NULL;
912  {
913  // using original GO distance
915  Cell cell(p);
916 
917  Oregon::NearestGameObjectEntryInObjectRangeCheck go_check(*target, trapEntry, range);
919 
921  cell.Visit(p, object_checker, *GetMap(), *target, range);
922  }
923 
924  // found correct GO
925  // FIXME: when GO casting will be implemented trap must cast spell to target
926  if (trapGO)
927  target->CastSpell(target, trapSpell, true);
928 }
struct GameObjectInfo::@59::@66 trap
Map * GetMap() const
Definition: Object.h:841
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
uint32 rangeIndex
Definition: DBCStructure.h:714
float GetPositionY() const
Definition: Position.h:98
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
T const * LookupEntry(uint32 id) const
Definition: SQLStorage.h:52
#define CONTACT_DISTANCE
Definition: Object.h:34
SQLStorage sGOStorage
float GetPositionX() const
Definition: Position.h:97
DBCStorage< SpellRangeEntry > sSpellRangeStore(SpellRangefmt)
float GetSpellMaxRange(SpellRangeEntry const *range)
Definition: SpellMgr.h:143
void GameObject::Update ( uint32  diff)
overridevirtual
Todo:
this hack with search required until GO casting not implemented

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.

Definition at line 230 of file GameObject.cpp.

References Map::AddToMap(), AI(), AIM_Initialize(), UpdateData::BuildPacket(), Object::BuildValuesUpdateBlockForPlayer(), CastSpell(), Loot::clear(), CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY, CURRENT_CHANNELED_SPELL, Delete(), Group::EndRoll(), Unit::FinishSpell(), FISHING_BOBBER_READY_TIME, GAMEOBJECT_FLAGS, GAMEOBJECT_TYPE_BUTTON, GAMEOBJECT_TYPE_CHEST, GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_FISHINGNODE, GAMEOBJECT_TYPE_GOOBER, GAMEOBJECT_TYPE_TRAP, Player::GetBattleground(), GameObjectInfo::GetCharges(), GetDBTableGUIDLow(), GetGoAnimProgress(), GetGOInfo(), GetGoState(), GetGoType(), Object::GetGUID(), WorldObject::GetMap(), GetOwner(), GetOwnerGUID(), ObjectAccessor::GetPlayer(), Player::GetSession(), GetSpellId(), GetSpellRadius(), Object::GetTypeId(), Object::GetUInt32Value(), GO_ACTIVATED, GO_FLAG_IN_USE, GO_FLAG_INTERACT_COND, GO_FLAG_LOCKED, GO_FLAG_NODESPAWN, GO_FLAG_NOT_SELECTABLE, GO_JUST_DEACTIVATED, GO_NOT_READY, GO_READY, GO_STATE_ACTIVE, GO_STATE_READY, GameObjectInfo::goober, Player::InBattleground(), IS_MO_TRANSPORT, Unit::IsInCombat(), isSpawned(), loot, WorldObject::lootingGroupLeaderGUID, m_cooldownTime, WorldObject::m_groupLootTimer, m_lootState, m_respawnDelayTime, m_respawnTime, m_SkillupList, m_spawnedByDefault, m_unique_users, m_usetimes, Object::RemoveFlag(), ResetDoorOrButton(), SaveRespawnTime(), WorldObject::SendObjectCustomAnim(), WorldObject::SendObjectDeSpawnAnim(), WorldSession::SendPacket(), SetGoState(), SetLootState(), SetRespawnTime(), Object::SetUInt32Value(), sLog, SMSG_FISH_NOT_HOOKED, sObjectMgr, sPoolMgr, sSpellStore, sWorld, Object::ToPlayer(), GameObjectInfo::trap, GameObjectInfo::type, TYPEID_PLAYER, GameObjectAI::UpdateAI(), WorldObject::UpdateObjectVisibility(), WorldObject::VisitNearbyGridObject(), and WorldObject::VisitNearbyWorldObject().

231 {
232  if (IS_MO_TRANSPORT(GetGUID()))
233  {
234  //((Transport*)this)->Update(p_time);
235  return;
236  }
237 
238  if (AI())
239  AI()->UpdateAI(diff);
240  else if (!AIM_Initialize())
241  sLog.outError("Could not initialize GameObjectAI");
242 
243  switch (m_lootState)
244  {
245  case GO_NOT_READY:
246  {
247  switch (GetGoType())
248  {
250  {
251  // Arming Time for GAMEOBJECT_TYPE_TRAP (6)
252  Unit* owner = GetOwner();
253  if (owner && owner->IsInCombat())
254  m_cooldownTime = time(NULL) + GetGOInfo()->trap.cooldown;
256  break;
257  }
259  {
260  // fishing code (bobber ready)
261  if (time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME)
262  {
263  // splash bobber (bobber ready now)
264  Unit* caster = GetOwner();
265  if (caster && caster->GetTypeId() == TYPEID_PLAYER)
266  {
269 
270  UpdateData udata;
271  WorldPacket packet;
272  BuildValuesUpdateBlockForPlayer(&udata, caster->ToPlayer());
273  udata.BuildPacket(&packet);
274  caster->ToPlayer()->GetSession()->SendPacket(&packet);
275 
277  }
278 
279  m_lootState = GO_READY; // can be successfully open with some chance
280  }
281  return;
282  }
283  default:
284  m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY
285  break;
286  }
287  // NO BREAK for switch (m_lootState)
288  }
289  case GO_READY:
290  {
291  if (m_respawnTime > 0) // timer on
292  {
293  if (m_respawnTime <= time(NULL)) // timer expired
294  {
295  m_respawnTime = 0;
296  m_SkillupList.clear();
297  m_usetimes = 0;
298 
299  switch (GetGoType())
300  {
301  case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
302  {
303  Unit* caster = GetOwner();
304  if (caster && caster->GetTypeId() == TYPEID_PLAYER)
305  {
307 
309  caster->ToPlayer()->GetSession()->SendPacket(&data);
310  }
311  // can be delete
313  return;
314  }
317  //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)
318  if (GetGoState() != GO_STATE_READY)
320  break;
321  default:
322  break;
323  }
324 
325  // Despawn timer
326  if (!m_spawnedByDefault)
327  {
328  // Can be despawned or destroyed
330  return;
331  }
332 
333  // Respawn timer
334  uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
335  if (poolid)
336  sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
337  else
338  GetMap()->AddToMap(this);
339  }
340  }
341 
342  if (isSpawned())
343  {
344  GameObjectInfo const* goInfo = GetGOInfo();
345  if (goInfo->type == GAMEOBJECT_TYPE_TRAP)
346  {
347  if (m_cooldownTime >= time(NULL))
348  break;
349 
350  // traps
351  Unit* owner = GetOwner();
352  Unit* ok = NULL; // pointer to appropriate target if found any
353 
354  bool IsBattlegroundTrap = false;
355  //FIXME: this is activation radius (in different casting radius that must be selected from spell data)
356  //@todo move activated state code (cast itself) to GO_ACTIVATED, in this place only check activating and set state
357  float radius = (float)(goInfo->trap.radius) / 2; // TODO rename radius to diameter (goInfo->trap.radius) should be (goInfo->trap.diameter)
358  if (!radius)
359  {
360  if (goInfo->trap.cooldown != 3) // cast in other case (at some triggering/linked go/etc explicit call)
361  {
362  // try to read radius from trap spell
363  if (const SpellEntry* spellEntry = sSpellStore.LookupEntry(goInfo->trap.spellId))
364  radius = GetSpellRadius(spellEntry, 0, false);
365  // radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellEntry->EffectRadiusIndex[0]));
366 
367  if (!radius)
368  break;
369  }
370  else
371  {
372  if (m_respawnTime > 0)
373  break;
374 
375  radius = goInfo->trap.cooldown; // battlegrounds gameobjects has data2 == 0 && data5 == 3
376  IsBattlegroundTrap = true;
377  }
378  }
379 
381  if (owner)
382  {
383  // Hunter trap: Search units which are unfriendly to the trap's owner
384  Oregon::AnyUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
386  VisitNearbyGridObject(radius, searcher);
387  if (!ok)
388  VisitNearbyWorldObject(radius, searcher);
389  }
390  else
391  {
392  // Environmental trap: Any player
393  Player* player = NULL;
394  Oregon::AnyPlayerInObjectRangeCheck checker(this, radius);
395  Oregon::PlayerSearcher<Oregon::AnyPlayerInObjectRangeCheck> searcher(this, player, checker);
396  VisitNearbyWorldObject(radius, searcher);
397  ok = player;
398  }
399 
400  if (ok)
401  {
402  // some traps do not have spell but should be triggered
403  if (goInfo->trap.spellId)
404  CastSpell(ok, goInfo->trap.spellId);
405 
406  m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4));
407 
408  if (goInfo->trap.type == 1)
410 
411  if (IsBattlegroundTrap && ok->GetTypeId() == TYPEID_PLAYER)
412  {
413  //Battleground gameobjects case
414  if (ok->ToPlayer()->InBattleground())
415  if (Battleground* bg = ok->ToPlayer()->GetBattleground())
416  bg->HandleTriggerBuff(GetGUID());
417  }
418  }
419  }
420  else if (uint32 max_charges = goInfo->GetCharges())
421  {
422  if (m_usetimes >= max_charges)
423  {
424  m_usetimes = 0;
425  SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed
426  }
427  }
428  }
429 
430  break;
431  }
432  case GO_ACTIVATED:
433  {
434  switch (GetGoType())
435  {
438  if (GetGOInfo()->GetAutoCloseTime() && (m_cooldownTime < time(NULL)))
440  break;
442  if (m_cooldownTime < time(NULL))
443  {
445 
447  m_cooldownTime = 0;
448  }
449  break;
452  {
453  if (diff <= m_groupLootTimer)
454  m_groupLootTimer -= diff;
455  else
456  {
457  Group* group = sObjectMgr.GetGroupByLeader(lootingGroupLeaderGUID);
458  if (group)
459  group->EndRoll();
460  m_groupLootTimer = 0;
462  }
463  }
464  break;
465  default:
466  break;
467  }
468  break;
469  }
470  case GO_JUST_DEACTIVATED:
471  {
472  //if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
474  {
475  uint32 spellId = GetGOInfo()->goober.spellId;
476 
477  if (spellId)
478  {
479  for (std::set<uint64>::const_iterator it = m_unique_users.begin(); it != m_unique_users.end(); ++it)
480  // m_unique_users can contain only player GUIDs
481  if (Player* owner = ObjectAccessor::GetPlayer(*this, *it))
482  owner->CastSpell(owner, spellId, false);
483 
484  m_unique_users.clear();
485  m_usetimes = 0;
486  }
487 
489 
490  //any return here in case battleground traps
491  if (GetGOInfo()->flags & GO_FLAG_NODESPAWN)
492  return;
493  }
494 
495  loot.clear();
496 
499  if (GetSpellId() || GetOwnerGUID())
500  {
501  SetRespawnTime(0);
502  Delete();
503  return;
504  }
505 
507 
508  //burning flags in some battlegrounds, if you find better condition, just add it
509  if (GetGOInfo()->IsDespawnAtAction() || GetGoAnimProgress() > 0)
510  {
512  //reset flags
513  if (GetMap()->Instanceable())
514  {
515  // In Instances GO_FLAG_LOCKED, GO_FLAG_INTERACT_COND or GO_FLAG_NO_INTERACT are not changed
517  SetUInt32Value(GAMEOBJECT_FLAGS, (GetGOInfo()->flags & ~(GO_FLAG_LOCKED | GO_FLAG_INTERACT_COND | GO_FLAG_NOT_SELECTABLE)) | currentLockOrInteractFlags);
518  }
519  else
521  }
522 
523  if (!m_respawnDelayTime)
524  return;
525 
526  if (!m_spawnedByDefault)
527  {
528  m_respawnTime = 0;
530  return;
531  }
532 
533  m_respawnTime = time(NULL) + m_respawnDelayTime;
534 
535  // if option not set then object will be saved at grid unload
537  SaveRespawnTime();
538 
540 
541  break;
542  }
543  }
544 }
bool BuildPacket(WorldPacket *packet, bool hasTransport=false)
Definition: UpdateData.cpp:103
struct GameObjectInfo::@59::@66 trap
LootState m_lootState
Definition: GameObject.h:848
bool AddToMap(T *)
Definition: Map.cpp:424
GameObjectAI * AI() const
Definition: GameObject.h:840
bool AIM_Initialize()
Definition: GameObject.cpp:76
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:234
Unit * GetOwner() const
Definition: GameObject.cpp:783
void ResetDoorOrButton()
Definition: GameObject.cpp:945
Battleground * GetBattleground() const
Definition: Player.cpp:19413
GOState GetGoState() const
Definition: GameObject.h:728
Map * GetMap() const
Definition: Object.h:841
void SendObjectCustomAnim(uint64 guid, uint32 anim=0)
Definition: Object.cpp:1946
uint32 m_usetimes
Definition: GameObject.h:856
uint32 m_respawnDelayTime
Definition: GameObject.h:847
void BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) const
Definition: Object.cpp:218
uint64 GetOwnerGUID() const
Definition: GameObject.h:664
uint64 lootingGroupLeaderGUID
Definition: Object.h:925
bool IsInCombat() const
Definition: Unit.h:1243
#define sLog
Log class singleton.
Definition: Log.h:187
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:779
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:693
static Player * GetPlayer(WorldObject const &, uint64 guid)
void clear()
Definition: LootMgr.h:327
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
time_t m_cooldownTime
Definition: GameObject.h:850
void VisitNearbyGridObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:922
Player * ToPlayer()
Definition: Object.h:392
virtual void UpdateAI(uint32)
Definition: GameObjectAI.h:36
uint32 GetGoAnimProgress() const
Definition: GameObject.h:737
void SetLootState(LootState s, Unit *unit=NULL)
uint8 GetTypeId() const
Definition: Object.h:210
time_t m_respawnTime
Definition: GameObject.h:846
uint32 GetCharges() const
Definition: GameObject.h:380
#define FISHING_BOBBER_READY_TIME
Definition: GameObject.h:577
#define sPoolMgr
Definition: PoolMgr.h:162
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
std::set< uint64 > m_unique_users
Definition: GameObject.h:855
void SetGoState(GOState state)
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1006
float GetSpellRadius(SpellEntry const *spellInfo, uint32 effectIdx, bool positive)
Definition: SpellMgr.h:176
bool InBattleground() const
Definition: Player.h:2195
bool isSpawned() const
Definition: GameObject.h:699
#define IS_MO_TRANSPORT(Guid)
Definition: ObjectGuid.h:75
bool m_spawnedByDefault
Definition: GameObject.h:849
GameobjectTypes GetGoType() const
Definition: GameObject.h:720
void SendObjectDeSpawnAnim(uint64 guid)
Definition: Object.cpp:1939
void EndRoll()
Definition: Group.cpp:761
void CastSpell(Unit *target, uint32 spellId, bool triggered=true)
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:2599
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
void SaveRespawnTime() override
Definition: GameObject.cpp:788
void FinishSpell(CurrentSpellTypes spellType, bool ok=true)
Definition: Unit.cpp:3535
std::list< uint32 > m_SkillupList
Definition: GameObject.h:852
uint32 GetSpellId() const
Definition: GameObject.h:675
WorldSession * GetSession() const
Definition: Player.h:1944
uint32 GetDBTableGUIDLow() const
Definition: GameObject.h:607
#define sWorld
Definition: World.h:860
ACE_UINT32 uint32
Definition: Define.h:71
struct GameObjectInfo::@59::@70 goober
Definition: Unit.h:908
Definition: Player.h:922
uint32 m_groupLootTimer
Definition: Object.h:924
void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const
Definition: Object.h:920
Definition: Group.h:154
void Delete()
Definition: GameObject.cpp:564
const uint64 & GetGUID() const
Definition: Object.h:162
void GameObject::UpdateModel ( )
private

Definition at line 1658 of file GameObject.cpp.

References GameObjectModel::Create(), WorldObject::GetMap(), Map::Insert(), Object::IsInWorld(), m_model, and Map::Remove().

Referenced by SetDisplayId().

1659 {
1660  if (!IsInWorld())
1661  return;
1662  if (m_model)
1663  if (GetMap()->Contains(*m_model))
1664  GetMap()->Remove(*m_model);
1665  delete m_model;
1667  if (m_model)
1668  GetMap()->Insert(*m_model);
1669 }
Map * GetMap() const
Definition: Object.h:841
void Remove(const GameObjectModel &mdl)
Definition: Map.h:533
GameObjectModel * m_model
Definition: GameObject.h:863
void Insert(const GameObjectModel &mdl)
Definition: Map.h:534
const bool & IsInWorld() const
Definition: Object.h:135
static GameObjectModel * Create(const GameObject &go)
void GameObject::UpdateModelPosition ( )

Definition at line 1626 of file GameObject.cpp.

References WorldObject::GetMap(), Map::Insert(), m_model, GameObjectModel::Relocate(), and Map::Remove().

Referenced by Transport::Update().

1627 {
1628  if (!m_model)
1629  return;
1630 
1631  if (GetMap()->Contains(*m_model))
1632  {
1633  GetMap()->Remove(*m_model);
1634  m_model->Relocate(*this);
1635  GetMap()->Insert(*m_model);
1636  }
1637 }
Map * GetMap() const
Definition: Object.h:841
void Remove(const GameObjectModel &mdl)
Definition: Map.h:533
bool Relocate(GameObject const &go)
GameObjectModel * m_model
Definition: GameObject.h:863
void Insert(const GameObjectModel &mdl)
Definition: Map.h:534
void GameObject::UpdateRotationFields ( float  rotation2 = 0.0f,
float  rotation3 = 0.0f 
)

Definition at line 1562 of file GameObject.cpp.

References GAMEOBJECT_FACING, GAMEOBJECT_ROTATION, Position::GetOrientation(), and Object::SetFloatValue().

Referenced by Create(), and ChatHandler::HandleTurnObjectCommand().

1563 {
1564  static double const atan_pow = atan(pow(2.0f, -20.0f));
1565 
1566  double f_rot1 = std::sin(GetOrientation() / 2.0f);
1567  double f_rot2 = std::cos(GetOrientation() / 2.0f);
1568 
1569  int64 i_rot1 = int64(f_rot1 / atan_pow *(f_rot2 >= 0 ? 1.0f : -1.0f));
1570  int64 rotation = (i_rot1 << 43 >> 43) & 0x00000000001FFFFF;
1571 
1573 
1574  if (rotation2 == 0.0f && rotation3 == 0.0f)
1575  {
1576  rotation2 = sin(GetOrientation() / 2);
1577  rotation3 = cos(GetOrientation() / 2);
1578  }
1579 
1580  SetFloatValue(GAMEOBJECT_ROTATION+2, rotation2);
1581  SetFloatValue(GAMEOBJECT_ROTATION+3, rotation3);
1582 }
float GetOrientation() const
Definition: Position.h:100
ACE_INT64 int64
Definition: Define.h:66
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:859
void GameObject::Use ( Unit user)

Definition at line 990 of file GameObject.cpp.

References AddUniqueUse(), AddUse(), AI(), BATTLEGROUND_EY, BATTLEGROUND_WS, GameObjectInfo::camera, Player::CanUseBattlegroundObject(), Player::CastedCreatureOrGO(), CastSpell(), Unit::CastSpell(), GameObjectInfo::chair, Spell::CheckCast(), CURRENT_CHANNELED_SPELL, DEBUG_LOG, DEFAULT_VISIBILITY_DISTANCE, Delete(), Battleground::EventPlayerClickedOnFlag(), ObjectAccessor::FindPlayer(), Unit::FinishSpell(), GAMEOBJECT_FLAGS, GAMEOBJECT_TYPE_BUTTON, GAMEOBJECT_TYPE_CAMERA, GAMEOBJECT_TYPE_CHAIR, GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_FISHINGNODE, GAMEOBJECT_TYPE_FLAGDROP, GAMEOBJECT_TYPE_FLAGSTAND, GAMEOBJECT_TYPE_GOOBER, GAMEOBJECT_TYPE_MEETINGSTONE, GAMEOBJECT_TYPE_QUESTGIVER, GAMEOBJECT_TYPE_SPELLCASTER, GAMEOBJECT_TYPE_SUMMONING_RITUAL, WorldObject::GetAreaId(), GameObjectInfo::GetAutoCloseTime(), Player::GetBattleground(), GetCooldown(), Unit::GetCurrentSpell(), GetDBTableGUIDLow(), WorldObject::GetDistance2d(), Object::GetEntry(), GetGoAnimProgress(), GetGOInfo(), GetGoType(), Object::GetGUID(), Unit::getLevel(), getLootState(), WorldObject::GetMap(), Position::GetOrientation(), GetOwner(), GetOwnerGUID(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Player::GetQuestStatus(), Player::GetSession(), Player::GetSkillValue(), Unit::GetTarget(), Object::GetTypeId(), Battleground::GetTypeID(), GetUniqueUseCount(), WorldObject::GetZoneId(), GO_ACTIVATED, GO_FLAG_IN_USE, GO_JUST_DEACTIVATED, GO_READY, GO_STATE_ACTIVE, GameObjectInfo::goober, GameObjectAI::GossipHello(), GameObjectInfo::gossipID, GameObjectInfo::id, irand(), Player::IsInSameRaidWith(), LookupFishingHoleAround(), LOOT_FISHING, LOOT_FISHINGHOLE, m_cooldownTime, m_ritualOwnerGUID, m_unique_users, m_usetimes, GameObjectInfo::meetingstone, Unit::NearTeleportTo(), Player::PrepareGossipMenu(), QUEST_STATUS_INCOMPLETE, Unit::RemoveAurasByType(), Unit::RemoveGameObject(), Map::ScriptsStart(), Player::SendCinematicStart(), Player::SendLoot(), WorldObject::SendObjectCustomAnim(), WorldSession::SendPacket(), Player::SendPreparedGossip(), Object::SetFlag(), SetGoState(), SetLootState(), SetOwnerGUID(), SetSpellId(), Unit::SetStandState(), sEventScripts, sGameObjectScripts, GameObjectInfo::size, SKILL_FISHING, sLog, SMSG_FISH_ESCAPED, SMSG_FISH_NOT_HOOKED, SMSG_GAMEOBJECT_PAGETEXT, sObjectMgr, sOutdoorPvPMgr, SPELL_AURA_FLY, SPELL_AURA_MOD_INVISIBILITY, SPELL_AURA_MOD_STEALTH, SPELL_AURA_MOUNTED, SPELL_CAST_OK, GameObjectInfo::spellcaster, sScriptMgr, sSpellStore, GameObjectInfo::summoningRitual, sWorld, TELE_TO_NOT_LEAVE_COMBAT, TELE_TO_NOT_LEAVE_TRANSPORT, TELE_TO_NOT_UNSUMMON_PET, Object::ToPlayer(), TYPEID_PLAYER, UNIT_STAND_STATE_SIT_LOW_CHAIR, Player::UpdateFishingSkill(), and UseDoorOrButton().

Referenced by WorldSession::HandleGameObjectUseOpcode().

991 {
992  // by default spell caster is user
993  Unit* spellCaster = user;
994  uint32 spellId = 0;
995  bool triggered = false;
996 
997  if (Player* playerUser = user->ToPlayer())
998  {
999  if (sScriptMgr.GOHello(playerUser, this))
1000  return;
1001 
1002  if (AI()->GossipHello(playerUser))
1003  return;
1004  }
1005 
1006  // If cooldown data present in template
1007  if (uint32 cooldown = GetCooldown())
1008  {
1009  if (m_cooldownTime > sWorld.GetGameTime())
1010  return;
1011 
1012  m_cooldownTime = sWorld.GetGameTime() + cooldown;
1013  }
1014 
1015  switch (GetGoType())
1016  {
1017  case GAMEOBJECT_TYPE_DOOR: //0
1018  case GAMEOBJECT_TYPE_BUTTON: //1
1019  //doors/buttons never really despawn, only reset to default state/flags
1020  UseDoorOrButton(0, false, user);
1021 
1022  // activate script
1023  GetMap()->ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
1024  return;
1025 
1026  case GAMEOBJECT_TYPE_QUESTGIVER: //2
1027  {
1028  if (user->GetTypeId() != TYPEID_PLAYER)
1029  return;
1030 
1031  Player* player = user->ToPlayer();
1032 
1033  player->PrepareGossipMenu(this, GetGOInfo()->questgiver.gossipID);
1034  player->SendPreparedGossip(this);
1035  return;
1036  }
1037  //Sitting: Wooden bench, chairs enzz
1038  case GAMEOBJECT_TYPE_CHAIR: //7
1039  {
1040  GameObjectInfo const* info = GetGOInfo();
1041  if (!info)
1042  return;
1043 
1044  // a chair may have n slots. we have to calculate their positions and teleport the player to the nearest one
1045 
1046  // check if the db is sane
1047  if (info->chair.slots > 0)
1048  {
1049  float lowestDist = DEFAULT_VISIBILITY_DISTANCE;
1050 
1051  float x_lowest = GetPositionX();
1052  float y_lowest = GetPositionY();
1053 
1054  // the object orientation + 1/2 pi
1055  // every slot will be on that straight line
1056  float orthogonalOrientation = GetOrientation() + M_PI * 0.5f;
1057  // find nearest slot
1058  for (uint32 i = 0; i < info->chair.slots; i++)
1059  {
1060  // the distance between this slot and the center of the go - imagine a 1D space
1061  float relativeDistance = (info->size * i) - (info->size * (info->chair.slots - 1) / 2.0f);
1062 
1063  float x_i = GetPositionX() + relativeDistance * cos(orthogonalOrientation);
1064  float y_i = GetPositionY() + relativeDistance * sin(orthogonalOrientation);
1065 
1066  // calculate the distance between the player and this slot
1067  float thisDistance = user->GetDistance2d(x_i, y_i);
1068 
1069  /* debug code. It will spawn a npc on each slot to visualize them.
1070  Creature* helper = player->SummonCreature(14496, x_i, y_i, GetPositionZ(), GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10000);
1071  std::ostringstream output;
1072  output << i << ": thisDist: " << thisDistance;
1073  helper->MonsterSay(output.str().c_str(), LANG_UNIVERSAL, 0);
1074  */
1075 
1076  if (thisDistance <= lowestDist)
1077  {
1078  lowestDist = thisDistance;
1079  x_lowest = x_i;
1080  y_lowest = y_i;
1081  }
1082  }
1084  }
1085  else
1086  {
1087  // fallback, will always work
1089  }
1090  user->SetStandState(UNIT_STAND_STATE_SIT_LOW_CHAIR + info->chair.height);
1091  return;
1092  }
1093  //big gun, its a spell/aura
1094  case GAMEOBJECT_TYPE_GOOBER: //10
1095  {
1096  GameObjectInfo const* info = GetGOInfo();
1097 
1098  if (user->GetTypeId() == TYPEID_PLAYER)
1099  {
1100  Player* player = user->ToPlayer();
1101 
1102  if (info->goober.pageId) // show page...
1103  {
1105  data << GetGUID();
1106  player->GetSession()->SendPacket(&data);
1107  }
1108  else if (info->goober.gossipID)
1109  {
1110  player->PrepareGossipMenu(this, info->goober.gossipID);
1111  player->SendPreparedGossip(this);
1112  }
1113 
1114  if (info->goober.eventId)
1115  GetMap()->ScriptsStart(sEventScripts, info->goober.eventId, player, this);
1116 
1117  // possible quest objective for active quests
1118  if (info->goober.questId && sObjectMgr.GetQuestTemplate(info->goober.questId))
1119  {
1120  //Quest require to be active for GO using
1121  if (player->GetQuestStatus(info->goober.questId) != QUEST_STATUS_INCOMPLETE)
1122  break;
1123  }
1124 
1125  player->CastedCreatureOrGO(info->id, GetGUID(), 0);
1126  }
1127 
1129  SetLootState(GO_ACTIVATED, user);
1130 
1131  // this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389)
1132  if (info->goober.customAnim)
1134  else
1136 
1137  m_cooldownTime = time(NULL) + GetGOInfo()->GetAutoCloseTime();
1138 
1139  // cast this spell later if provided
1140  spellId = info->goober.spellId;
1141 
1142  break;
1143  }
1144  case GAMEOBJECT_TYPE_CAMERA: //13
1145  {
1146  GameObjectInfo const* info = GetGOInfo();
1147  if (!info)
1148  return;
1149 
1150  if (user->GetTypeId() != TYPEID_PLAYER)
1151  return;
1152 
1153  Player* player = user->ToPlayer();
1154 
1155  if (info->camera.cinematicId)
1156  player->SendCinematicStart(info->camera.cinematicId);
1157 
1158  if (info->camera.eventID)
1159  GetMap()->ScriptsStart(sEventScripts, info->camera.eventID, player, this);
1160 
1161  if (GetEntry() == 187578)
1163 
1164  return;
1165  }
1166  //fishing bobber
1167  case GAMEOBJECT_TYPE_FISHINGNODE: //17
1168  {
1169  if (user->GetTypeId() != TYPEID_PLAYER)
1170  return;
1171 
1172  Player* player = user->ToPlayer();
1173 
1174  if (player->GetGUID() != GetOwnerGUID())
1175  return;
1176 
1177  switch (getLootState())
1178  {
1179  case GO_READY: // ready for loot
1180  {
1181  // 1) skill must be >= base_zone_skill
1182  // 2) if skill == base_zone_skill => 5% chance
1183  // 3) chance is linear dependence from (base_zone_skill-skill)
1184 
1185  uint32 subzone = GetAreaId();
1186 
1187  int32 zone_skill = sObjectMgr.GetFishingBaseSkillLevel(subzone);
1188  if (!zone_skill)
1189  zone_skill = sObjectMgr.GetFishingBaseSkillLevel(GetZoneId());
1190 
1191  //provide error, no fishable zone or area should be 0
1192  if (!zone_skill)
1193  sLog.outErrorDb("Fishable areaId %u is not properly defined in skill_fishing_base_level.", subzone);
1194 
1195  int32 skill = player->GetSkillValue(SKILL_FISHING);
1196  int32 chance = skill - zone_skill + 5;
1197  int32 roll = irand(1, 100);
1198 
1199  DEBUG_LOG("Fishing check (skill: %i zone min skill: %i chance %i roll: %i", skill, zone_skill, chance, roll);
1200 
1201  if (skill >= zone_skill && chance >= roll)
1202  {
1203  // prevent removing GO at spell cancel
1204  player->RemoveGameObject(this, false);
1205  SetOwnerGUID(player->GetGUID());
1206  SetSpellId(0); // prevent removing unintended auras at Unit::RemoveGameObject
1207 
1208  //fish caught
1209  player->UpdateFishingSkill();
1210 
1212  if (ok)
1213  {
1214  player->SendLoot(ok->GetGUID(), LOOT_FISHINGHOLE);
1216  }
1217  else
1218  player->SendLoot(GetGUID(), LOOT_FISHING);
1219  }
1220  else
1221  {
1222  // fish escaped, can be deleted now
1224 
1225  WorldPacket data(SMSG_FISH_ESCAPED, 0);
1226  player->GetSession()->SendPacket(&data);
1227  }
1228  break;
1229  }
1230  case GO_JUST_DEACTIVATED: // nothing to do, will be deleted at next update
1231  break;
1232  default:
1233  {
1235 
1237  player->GetSession()->SendPacket(&data);
1238  break;
1239  }
1240  }
1241 
1243  return;
1244  }
1245 
1247  {
1248  if (user->GetTypeId() != TYPEID_PLAYER)
1249  return;
1250 
1251  Player* player = user->ToPlayer();
1252 
1253  Unit* owner = GetOwner();
1254 
1255  GameObjectInfo const* info = GetGOInfo();
1256 
1257  Player* m_ritualOwner = NULL;
1258  if (m_ritualOwnerGUID)
1260 
1261  // ritual owner is set for GO's without owner (not summoned)
1262  if (!m_ritualOwner && !owner)
1263  {
1264  m_ritualOwnerGUID = player->GetGUID();
1265  m_ritualOwner = player;
1266  }
1267 
1268  if (owner)
1269  {
1270  if (owner->GetTypeId() != TYPEID_PLAYER)
1271  return;
1272 
1273  // accept only use by player from same group as owner, excluding owner itself (unique use already added in spell effect)
1274  if (player == owner->ToPlayer() || (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(owner->ToPlayer())))
1275  return;
1276 
1277  // expect owner to already be channeling, so if not...
1279  return;
1280 
1281  // in case summoning ritual caster is GO creator
1282  spellCaster = owner;
1283  }
1284  else
1285  {
1286  if (player != m_ritualOwner && (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(m_ritualOwner)))
1287  return;
1288 
1289  spellCaster = player;
1290  }
1291 
1292  AddUniqueUse(player);
1293 
1294  if (info->summoningRitual.animSpell)
1295  {
1296  player->CastSpell(player, info->summoningRitual.animSpell, false);
1297 
1298  // for this case, summoningRitual.spellId is always triggered
1299  triggered = true;
1300  }
1301 
1302  // full amount unique participants including original summoner
1303  if (GetUniqueUseCount() == info->summoningRitual.reqParticipants)
1304  {
1305  if (m_ritualOwner)
1306  spellCaster = m_ritualOwner;
1307 
1308  spellId = info->summoningRitual.spellId;
1309 
1310  // finish owners spell
1311  if (owner)
1313 
1314  // can be deleted now, if
1315  if (!info->summoningRitual.ritualPersistent)
1317  else
1318  {
1319  // reset ritual for this GO
1320  m_ritualOwnerGUID = 0;
1321  m_unique_users.clear();
1322  m_usetimes = 0;
1323  }
1324  }
1325  else
1326  return;
1327 
1328  // go to end function to spell casting
1329  break;
1330  }
1331  case GAMEOBJECT_TYPE_SPELLCASTER: //22
1332  {
1333  GameObjectInfo const* info = GetGOInfo();
1334  if (!info)
1335  return;
1336 
1337  if (info->spellcaster.partyOnly)
1338  {
1339  Unit* caster = GetOwner();
1340  if (!caster || caster->GetTypeId() != TYPEID_PLAYER)
1341  return;
1342 
1343  if (user->GetTypeId() != TYPEID_PLAYER || !user->ToPlayer()->IsInSameRaidWith(caster->ToPlayer()))
1344  return;
1345  }
1346 
1349  spellId = info->spellcaster.spellId;
1350 
1351  break;
1352  }
1353  case GAMEOBJECT_TYPE_MEETINGSTONE: //23
1354  {
1355  GameObjectInfo const* info = GetGOInfo();
1356 
1357  if (user->GetTypeId() != TYPEID_PLAYER)
1358  return;
1359 
1360  Player* player = user->ToPlayer();
1361 
1362  Player* targetPlayer = ObjectAccessor::FindPlayer(player->GetTarget());
1363 
1364  // accept only use by player from same group for caster except caster itself
1365  if (!targetPlayer || targetPlayer == player || !targetPlayer->IsInSameRaidWith(player))
1366  return;
1367 
1368  //required lvl checks!
1369  uint8 level = player->getLevel();
1370  if (level < info->meetingstone.minLevel || level > info->meetingstone.maxLevel)
1371  return;
1372  level = targetPlayer->getLevel();
1373  if (level < info->meetingstone.minLevel || level > info->meetingstone.maxLevel)
1374  return;
1375 
1376  spellId = 23598;
1377 
1378  break;
1379  }
1380 
1381  case GAMEOBJECT_TYPE_FLAGSTAND: // 24
1382  {
1383  if (user->GetTypeId() != TYPEID_PLAYER)
1384  return;
1385 
1386  Player* player = user->ToPlayer();
1387 
1388  if (player->CanUseBattlegroundObject(this))
1389  {
1390  // in battleground check
1391  Battleground* bg = player->GetBattleground();
1392  if (!bg)
1393  return;
1394 
1397  // BG flag click
1398  // AB:
1399  // 15001
1400  // 15002
1401  // 15003
1402  // 15004
1403  // 15005
1404  bg->EventPlayerClickedOnFlag(player, this);
1405  return; //we don;t need to delete flag ... it is despawned!
1406  }
1407  break;
1408  }
1409  case GAMEOBJECT_TYPE_FLAGDROP: // 26
1410  {
1411  if (user->GetTypeId() != TYPEID_PLAYER)
1412  return;
1413 
1414  Player* player = user->ToPlayer();
1415 
1416  if (player->CanUseBattlegroundObject(this))
1417  {
1418  // in battleground check
1419  Battleground* bg = player->GetBattleground();
1420  if (!bg)
1421  return;
1422 
1425  // BG flag dropped
1426  // WS:
1427  // 179785 - Silverwing Flag
1428  // 179786 - Warsong Flag
1429  // EotS:
1430  // 184142 - Netherstorm Flag
1431  GameObjectInfo const* info = GetGOInfo();
1432  if (info)
1433  {
1434  switch (info->id)
1435  {
1436  case 179785: // Silverwing Flag
1437  case 179786: // Warsong Flag
1438  if (bg->GetTypeID() == BATTLEGROUND_WS)
1439  bg->EventPlayerClickedOnFlag(player, this);
1440  break;
1441  case 184142: // Netherstorm Flag
1442  if (bg->GetTypeID() == BATTLEGROUND_EY)
1443  bg->EventPlayerClickedOnFlag(player, this);
1444  break;
1445  }
1446  }
1447  //this cause to call return, all flags must be deleted here!!
1448  spellId = 0;
1449  Delete();
1450  }
1451  break;
1452  }
1453  default:
1454  sLog.outDebug("Unknown Object Type %u", GetGoType());
1455  break;
1456  }
1457 
1458  if (!spellId)
1459  return;
1460 
1461  SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
1462  if (!spellInfo)
1463  {
1464  if (user->GetTypeId() != TYPEID_PLAYER || !sOutdoorPvPMgr.HandleCustomSpell(user->ToPlayer(), spellId, this))
1465  sLog.outError("WORLD: unknown spell id %u at use action for gameobject (Entry: %u GoType: %u)", spellId, GetEntry(), GetGoType());
1466  else
1467  sLog.outDebug("WORLD: %u non-dbc spell was handled by OutdoorPvP", spellId);
1468  return;
1469  }
1470 
1471  if (Player* player = user->ToPlayer())
1472  sOutdoorPvPMgr.HandleCustomSpell(player, spellId, this);
1473 
1474  Spell* spell = new Spell(spellCaster, spellInfo, triggered);
1475 
1476  // Check cast is OK, and only add use if we are really casting the spell
1477  // to prevent taking charges on spell fail
1478  if (spell->CheckCast(true) != SPELL_CAST_OK)
1479  return;
1480 
1481  AddUse();
1482 
1483  if (spellCaster)
1484  spellCaster->CastSpell(user, spellInfo, triggered);
1485  else
1486  CastSpell(user, spellId);
1487 }
void SendLoot(uint64 guid, LootType loot_type)
Definition: Player.cpp:7299
struct GameObjectInfo::@59::@80 meetingstone
void CastedCreatureOrGO(uint32 entry, uint64 guid, uint32 spell_id)
Definition: Player.cpp:13918
uint32 GetCooldown() const
Definition: GameObject.h:802
struct GameObjectInfo::@59::@73 camera
GameObjectAI * AI() const
Definition: GameObject.h:840
struct GameObjectInfo::@59::@76 summoningRitual
Unit * GetOwner() const
Definition: GameObject.cpp:783
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:13634
void SetStandState(uint8 state)
Definition: Unit.cpp:11951
Battleground * GetBattleground() const
Definition: Player.cpp:19413
void ScriptsStart(std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
Definition: MapScripts.cpp:33
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:79
LootState getLootState() const
Definition: GameObject.h:748
Map * GetMap() const
Definition: Object.h:841
void SendObjectCustomAnim(uint64 guid, uint32 anim=0)
Definition: Object.cpp:1946
uint32 m_usetimes
Definition: GameObject.h:856
unsupported by client, sending LOOT_FISHING instead
Definition: LootMgr.h:67
bool UpdateFishingSkill()
Definition: Player.cpp:5147
uint64 GetOwnerGUID() const
Definition: GameObject.h:664
uint32 GetZoneId() const
Definition: Object.cpp:1179
int32 irand(int32 min, int32 max)
Definition: Util.cpp:28
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 gossipID
Definition: GameObject.h:77
ACE_INT32 int32
Definition: Define.h:67
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:985
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
time_t m_cooldownTime
Definition: GameObject.h:850
Player * ToPlayer()
Definition: Object.h:392
float GetDistance2d(const WorldObject *obj) const
Definition: Object.h:733
void PrepareGossipMenu(WorldObject *pSource, uint32 menuId=0)
Definition: Player.cpp:12118
uint8 getLevel() const
Definition: Unit.h:1057
uint32 GetGoAnimProgress() const
Definition: GameObject.h:737
void SetLootState(LootState s, Unit *unit=NULL)
uint8 GetTypeId() const
Definition: Object.h:210
void SendPreparedGossip(WorldObject *pSource)
Definition: Player.cpp:12276
ACE_UINT8 uint8
Definition: Define.h:73
float GetOrientation() const
Definition: Position.h:100
uint64 GetTarget() const
Definition: Unit.h:1590
bool CanUseBattlegroundObject(GameObject *gameobject)
Definition: Player.cpp:20487
virtual bool GossipHello(Player *)
Definition: GameObjectAI.h:44
void NearTeleportTo(float x, float y, float z, float orientation, bool casting=false)
Definition: Unit.cpp:12583
void SendCinematicStart(uint32 CinematicSequenceId)
Definition: Player.cpp:5729
uint64 m_ritualOwnerGUID
Definition: GameObject.h:854
void RemoveAurasByType(AuraType auraType, uint64 casterGUID=0, Aura *except=NULL, bool negative=true, bool positive=true)
Definition: Unit.cpp:4395
float GetPositionY() const
Definition: Position.h:98
void CastSpell(Unit *Victim, uint32 spellId, bool triggered, Item *castItem=NULL, Aura *triggeredByAura=NULL, uint64 originalCaster=0)
Definition: Unit.cpp:1223
static Player * FindPlayer(uint64, bool force=false)
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1593
float GetPositionZ() const
Definition: Position.h:99
uint16 GetSkillValue(uint32 skill) const
Definition: Player.cpp:5487
virtual void EventPlayerClickedOnFlag(Player *, GameObject *)
Definition: Battleground.h:654
#define DEBUG_LOG(...)
Definition: Log.h:194
uint32 GetAutoCloseTime() const
Definition: GameObject.h:391
uint32 GetAreaId() const
Definition: Object.cpp:1184
std::set< uint64 > m_unique_users
Definition: GameObject.h:855
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=NULL)
Definition: GameObject.cpp:955
void SetGoState(GOState state)
bool IsInSameRaidWith(Player const *p) const
Definition: Player.h:1802
ScriptMapMap sGameObjectScripts
Definition: ObjectMgr.cpp:51
SpellCastResult CheckCast(bool strict)
Definition: Spell.cpp:3729
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:4729
uint32 GetTypeID() const
Definition: Battleground.h:305
GameobjectTypes GetGoType() const
Definition: GameObject.h:720
void SetOwnerGUID(uint64 owner)
Definition: GameObject.h:656
void AddUniqueUse(Player *player)
Definition: GameObject.cpp:556
ScriptMapMap sEventScripts
Definition: ObjectMgr.cpp:52
void AddUse()
Definition: GameObject.h:770
void CastSpell(Unit *target, uint32 spellId, bool triggered=true)
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
void SetSpellId(uint32 id)
Definition: GameObject.h:670
struct GameObjectInfo::@59::@79 spellcaster
void FinishSpell(CurrentSpellTypes spellType, bool ok=true)
Definition: Unit.cpp:3535
#define sScriptMgr
Definition: Group.h:526
uint32 GetUniqueUseCount() const
Definition: GameObject.h:779
uint32 GetEntry() const
Definition: Object.h:192
WorldSession * GetSession() const
Definition: Player.h:1944
uint32 GetDBTableGUIDLow() const
Definition: GameObject.h:607
#define sWorld
Definition: World.h:860
ACE_UINT32 uint32
Definition: Define.h:71
float GetPositionX() const
Definition: Position.h:97
struct GameObjectInfo::@59::@70 goober
Definition: Unit.h:908
Definition: Player.h:922
struct GameObjectInfo::@59::@67 chair
GameObject * LookupFishingHoleAround(float range)
Definition: GameObject.cpp:930
void Delete()
Definition: GameObject.cpp:564
const uint64 & GetGUID() const
Definition: Object.h:162
#define DEFAULT_VISIBILITY_DISTANCE
Definition: Object.h:40
Definition: Spell.h:249
void GameObject::UseDoorOrButton ( uint32  time_to_restore = 0,
bool  alternative = false,
Unit user = NULL 
)

Definition at line 955 of file GameObject.cpp.

References GameObjectInfo::GetAutoCloseTime(), GetGOInfo(), GO_ACTIVATED, GO_READY, m_cooldownTime, m_lootState, SetLootState(), and SwitchDoorOrButton().

Referenced by Map::_ScriptProcessDoor(), WorldSession::DoLootRelease(), Battleground::DoorClose(), Battleground::DoorOpen(), InstanceData::DoUseDoorOrButton(), Spell::EffectActivateObject(), Spell::EffectOpenLock(), ChatHandler::HandleActivateObjectCommand(), Spell::SendLoot(), and Use().

956 {
957  if (m_lootState != GO_READY)
958  return;
959 
960  if (!time_to_restore)
961  time_to_restore = GetGOInfo()->GetAutoCloseTime();
962 
963  SwitchDoorOrButton(true, alternative);
964  SetLootState(GO_ACTIVATED, user);
965 
966  m_cooldownTime = time_to_restore ? (time(NULL) + time_to_restore) : 0;
967 }
LootState m_lootState
Definition: GameObject.h:848
void SwitchDoorOrButton(bool activate, bool alternative=false)
Definition: GameObject.cpp:977
time_t m_cooldownTime
Definition: GameObject.h:850
void SetLootState(LootState s, Unit *unit=NULL)
uint32 GetAutoCloseTime() const
Definition: GameObject.h:391
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:592
void GameObject::Whisper ( const char *  text,
uint64  receiver 
)
inline

Definition at line 626 of file GameObject.h.

627  {
628  MonsterWhisper(text, receiver);
629  }
void MonsterWhisper(const char *text, uint64 receiver, bool IsBossWhisper=false)
Definition: Object.cpp:1511
void GameObject::Whisper ( int32  textId,
uint64  receiver 
)
inline

Definition at line 642 of file GameObject.h.

643  {
644  MonsterWhisper(textId, receiver);
645  }
void MonsterWhisper(const char *text, uint64 receiver, bool IsBossWhisper=false)
Definition: Object.cpp:1511
void GameObject::Yell ( const char *  text,
uint32  language,
uint64  TargetGuid 
)
inline

Definition at line 618 of file GameObject.h.

619  {
620  MonsterYell(text, language, TargetGuid);
621  }
void MonsterYell(const char *text, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1497
void GameObject::Yell ( int32  textId,
uint32  language,
uint64  TargetGuid 
)
inline

Definition at line 634 of file GameObject.h.

635  {
636  MonsterYell(textId, language, TargetGuid);
637  }
void MonsterYell(const char *text, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1497

Member Data Documentation

GameObjectAI* GameObject::m_AI
private

Definition at line 867 of file GameObject.h.

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

time_t GameObject::m_cooldownTime
protected

Definition at line 850 of file GameObject.h.

Referenced by GameObject(), ResetDoorOrButton(), Update(), Use(), and UseDoorOrButton().

uint32 GameObject::m_DBTableGuid
protected
GameObjectData const* GameObject::m_goData
protected

Definition at line 860 of file GameObject.h.

Referenced by GameObject(), LoadGameObjectFromDB(), and SaveRespawnTime().

GameObjectInfo const* GameObject::m_goInfo
protected

Definition at line 859 of file GameObject.h.

Referenced by Transport::Create(), Create(), GameObject(), and GetAIName().

LootState GameObject::m_lootState
protected

Definition at line 848 of file GameObject.h.

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

uint32 GameObject::m_respawnDelayTime
protected

Definition at line 847 of file GameObject.h.

Referenced by GameObject(), LoadGameObjectFromDB(), SaveToDB(), and Update().

time_t GameObject::m_respawnTime
protected
uint64 GameObject::m_ritualOwnerGUID
protected

Definition at line 854 of file GameObject.h.

Referenced by GameObject(), and Use().

std::list<uint32> GameObject::m_SkillupList
protected

Definition at line 852 of file GameObject.h.

Referenced by Update().

bool GameObject::m_spawnedByDefault
protected
uint32 GameObject::m_spellId
protected

Definition at line 845 of file GameObject.h.

Referenced by CleanupsBeforeDelete(), and GameObject().

std::set<uint64> GameObject::m_unique_users
protected

Definition at line 855 of file GameObject.h.

Referenced by AddUniqueUse(), Update(), and Use().

uint32 GameObject::m_usetimes
protected

Definition at line 856 of file GameObject.h.

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


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