OregonCore  revision be9e804-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)
 
bool IsVisibilityOverridden () const
 
void SetVisibilityDistanceOverride (VisibilityDistanceType type)
 
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
 
uint64 GetGUID () 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
 
float m_visibilityDistanceOverride
 
- 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 596 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:865
GameObjectInfo const * m_goInfo
Definition: GameObject.h:876
uint32 m_usetimes
Definition: GameObject.h:873
uint32 m_respawnDelayTime
Definition: GameObject.h:864
GameObjectAI * m_AI
Definition: GameObject.h:884
GameObjectData const * m_goData
Definition: GameObject.h:877
uint16 m_objectType
Definition: Object.h:400
time_t m_cooldownTime
Definition: GameObject.h:867
uint8 m_objectTypeId
Definition: Object.h:402
time_t m_respawnTime
Definition: GameObject.h:863
GameObjectModel * m_model
Definition: GameObject.h:880
uint64 m_ritualOwnerGUID
Definition: GameObject.h:871
uint8 m_updateFlag
Definition: Object.h:403
uint32 m_DBTableGuid
Definition: GameObject.h:875
WorldObject(bool isWorldObject)
Definition: Object.cpp:1085
bool m_spawnedByDefault
Definition: GameObject.h:866
uint32 m_spellId
Definition: GameObject.h:862
uint16 m_valuesCount
Definition: Object.h:414
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:884
GameObjectModel * m_model
Definition: GameObject.h:880

Member Function Documentation

bool GameObject::ActivateToQuest ( Player pTarget) const

Definition at line 868 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.

869 {
870  if (pTarget->HasQuestForGO(GetEntry()))
871  return true;
872 
873  if (!sObjectMgr.IsGameObjectForQuests(GetEntry()))
874  return false;
875 
876  switch (GetGoType())
877  {
878  // scan GO chest with loot including quest items
880  {
881  if (LootTemplates_Gameobject.HaveQuestLootForPlayer(GetGOInfo()->GetLootId(), pTarget))
882  {
883  //@todo fix this hack
884  //look for battlegroundAV for some objects which are only activated after mine gots captured by own team
886  if (Battleground* bg = pTarget->GetBattleground())
887  if (bg->GetTypeID() == BATTLEGROUND_AV && !(((BattlegroundAV*)bg)->PlayerCanDoMineQuest(GetEntry(), pTarget->GetTeam())))
888  return false;
889  return true;
890  }
891  break;
892  }
894  {
895  if (GetGOInfo()->_generic.questID == -1 || pTarget->GetQuestStatus(GetGOInfo()->_generic.questID) == QUEST_STATUS_INCOMPLETE)
896  return true;
897  break;
898  }
900  {
901  if (GetGOInfo()->goober.questId == -1 || pTarget->GetQuestStatus(GetGOInfo()->goober.questId) == QUEST_STATUS_INCOMPLETE)
902  return true;
903  break;
904  }
905  default:
906  break;
907  }
908 
909  return false;
910 }
uint32 questId
Definition: GameObject.h:96
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition: Player.cpp:13635
Battleground * GetBattleground() const
Definition: Player.cpp:19415
uint32 questID
Definition: GameObject.h:114
LootStore LootTemplates_Gameobject("gameobject_loot_template","gameobject entry")
bool HasQuestForGO(int32 GOId)
Definition: Player.cpp:19515
struct GameObjectInfo::@59::@65 _generic
#define sObjectMgr
Definition: ObjectMgr.h:1317
bool HaveQuestLootForPlayer(uint32 loot_id, Player *player) const
Definition: LootMgr.cpp:160
GameobjectTypes GetGoType() const
Definition: GameObject.h:737
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
uint32 GetTeam() const
Definition: Player.h:2066
uint32 GetEntry() const
Definition: Object.h:186
struct GameObjectInfo::@59::@70 goober
void GameObject::AddToSkillupList ( uint32  PlayerGuidLow)
inline

Definition at line 771 of file GameObject.h.

Referenced by Spell::EffectOpenLock().

772  {
773  m_SkillupList.push_back(PlayerGuidLow);
774  }
std::list< uint32 > m_SkillupList
Definition: GameObject.h:869
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:745
LootState getLootState() const
Definition: GameObject.h:765
Map * GetMap() const
Definition: Object.h:817
void AddObject(T *object)
GameObjectModel * m_model
Definition: GameObject.h:880
void Insert(const GameObjectModel &mdl)
Definition: Map.h:534
const bool & IsInWorld() const
Definition: Object.h:150
ZoneScript * m_zoneScript
Definition: Object.h:897
Transport * ToTransport()
Definition: GameObject.h:847
bool IsTransport() const
Definition: GameObject.cpp:789
void EnableCollision(bool enable)
virtual void AddToWorld()
Definition: Object.h:154
GameobjectTypes GetGoType() const
Definition: GameObject.h:737
virtual void OnGameObjectCreate(GameObject *, bool)
Definition: ZoneScript.h:45
void GameObject::AddUniqueUse ( Player player)

Definition at line 569 of file GameObject.cpp.

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

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

570 {
571  if (m_unique_users.find(player->GetGUIDLow()) != m_unique_users.end())
572  return;
573  AddUse();
574  m_unique_users.insert(player->GetGUID());
575 }
uint32 GetGUIDLow() const
Definition: Object.h:178
uint64 GetGUID() const
Definition: Object.h:177
std::set< uint64 > m_unique_users
Definition: GameObject.h:872
void AddUse()
Definition: GameObject.h:787
void GameObject::AddUse ( )
inline

Definition at line 787 of file GameObject.h.

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

788  {
789  ++m_usetimes;
790  }
uint32 m_usetimes
Definition: GameObject.h:873
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:884
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 1521 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().

1522 {
1523  SpellEntry const* spellProto = sSpellStore.LookupEntry(spellId);
1524  if (!spellProto)
1525  return;
1526 
1527  bool self = false;
1528  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1529  {
1530  if (spellProto->EffectImplicitTargetA[i] == TARGET_UNIT_CASTER)
1531  {
1532  self = true;
1533  break;
1534  }
1535  }
1536 
1537  if (self)
1538  {
1539  if (target)
1540  target->CastSpell(target, spellProto, triggered);
1541  return;
1542  }
1543 
1544  //summon world trigger
1545  Creature* trigger = SummonTrigger(GetPositionX(), GetPositionY(), GetPositionZ(), 0, GetSpellCastTime(spellProto) + 100);
1546  if (!trigger)
1547  return;
1548 
1549  // remove immunity flags, to allow spell to target anything
1551 
1552  if (Unit* owner = GetOwner())
1553  {
1554  trigger->SetFaction(owner->GetFaction());
1555  if (owner->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE))
1557  trigger->CastSpell(target ? target : trigger, spellId, triggered, 0, 0, owner->GetGUID());
1558  }
1559  else
1560  {
1561  trigger->SetFaction(IsPositiveSpell(spellId) ? 35 : 14);
1562  // Set owner guid for target if no owner available - needed by trigger auras
1563  trigger->CastSpell(target ? target : trigger, spellProto, triggered, nullptr, nullptr, target ? target->GetGUID() : 0);
1564  }
1565 }
Unit * GetOwner() const
Definition: GameObject.cpp:799
uint32 GetSpellCastTime(SpellEntry const *spellInfo, Spell const *spell)
Definition: SpellMgr.cpp:248
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:983
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
uint64 GetGUID() const
Definition: Object.h:177
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:1260
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:1004
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:2280
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:670
float GetPositionX() const
Definition: Position.h:97
Definition: Unit.h:908
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:408
uint64 GetOwnerGUID() const
Definition: GameObject.h:681
#define sLog
Log class singleton.
Definition: Log.h:187
uint32 GetGUIDLow() const
Definition: Object.h:178
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:150
ACE_UINT64 uint64
Definition: Define.h:70
void RemoveGameObject(GameObject *gameObj, bool del)
Definition: Unit.cpp:4760
uint32 m_spellId
Definition: GameObject.h:862
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
static Unit * GetUnit(WorldObject const &, uint64 guid)
Definition: Unit.h:908
void GameObject::ClearSkillupList ( )
inline

Definition at line 781 of file GameObject.h.

782  {
783  m_SkillupList.clear();
784  }
std::list< uint32 > m_SkillupList
Definition: GameObject.h:869
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, GameObjectInfo::IsLargeGameObject(), 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::SetVisibilityDistanceOverride(), WorldObject::SetZoneScript(), GameObjectInfo::size, sLog, sObjectMgr, GameObjectInfo::type, UpdateRotationFields(), and VISDIST_LARGE.

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  // Check if GameObject is Large
228  if (goinfo->IsLargeGameObject())
230 
231  return true;
232 }
#define MAX_GAMEOBJECT_TYPE
GameobjectTypes
GameObjectInfo const * m_goInfo
Definition: GameObject.h:876
bool AIM_Initialize()
Definition: GameObject.cpp:76
bool IsLargeGameObject() const
Definition: GameObject.h:507
void SetGoType(GameobjectTypes type)
Definition: GameObject.h:741
void SetObjectScale(float scale)
Definition: Object.h:190
virtual void SetMap(Map *map)
Definition: Object.cpp:1981
#define sLog
Log class singleton.
Definition: Log.h:187
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:777
uint32 displayId
Definition: GameObject.h:40
#define sObjectMgr
Definition: ObjectMgr.h:1317
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:880
void Relocate(float x, float y)
Definition: Position.h:65
void SetGoAnimProgress(uint32 animprogress)
Definition: GameObject.h:758
void SetGoState(GOState state)
void SetPhaseMask(uint32 newPhaseMask, bool update) override
void SetZoneScript()
Definition: Object.cpp:2129
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:857
uint32 flags
Definition: GameObject.h:44
#define ASSERT
Definition: Errors.h:29
bool IsPositionValid() const
Definition: Position.cpp:40
void SetVisibilityDistanceOverride(VisibilityDistanceType type)
Definition: Object.cpp:1155
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 577 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().

578 {
580 
582 
585 
586  uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
587  if (poolid)
588  sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
589  else
591 }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:777
uint64 GetGUID() const
Definition: Object.h:177
void SetLootState(LootState s, Unit *unit=NULL)
#define sPoolMgr
Definition: PoolMgr.h:162
void AddObjectToRemoveList()
Definition: Object.cpp:2017
void SetGoState(GOState state)
void SendObjectDeSpawnAnim(uint64 guid)
Definition: Object.cpp:1966
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
uint32 GetDBTableGUIDLow() const
Definition: GameObject.h:624
ACE_UINT32 uint32
Definition: Define.h:71
void GameObject::DeleteFromDB ( )

Definition at line 751 of file GameObject.cpp.

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

Referenced by ChatHandler::HandleDelObjectCommand().

752 {
753  sObjectMgr.SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), 0);
754  sObjectMgr.DeleteGOData(m_DBTableGuid);
755  WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
756  WorldDatabase.PExecuteLog("DELETE FROM game_event_gameobject WHERE guid = '%u'", m_DBTableGuid);
757 }
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
#define sObjectMgr
Definition: ObjectMgr.h:1317
bool PExecuteLog(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:221
uint32 m_DBTableGuid
Definition: GameObject.h:875
uint32 GetInstanceId() const
Definition: Object.h:664
void GameObject::EnableCollision ( bool  enable)

Definition at line 1666 of file GameObject.cpp.

References GameObjectModel::enable(), and m_model.

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

1667 {
1668  if (!m_model)
1669  return;
1670 
1671  m_model->enable(enable);
1672 }
GameObjectModel * m_model
Definition: GameObject.h:880
void enable(bool enable)
std::string GameObject::GetAIName ( ) const

Definition at line 1600 of file GameObject.cpp.

References GameObjectInfo::AIName, and m_goInfo.

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

1601 {
1602  if (m_goInfo)
1603  return m_goInfo->AIName;
1604 
1605  return "";
1606 }
GameObjectInfo const * m_goInfo
Definition: GameObject.h:876
char const * AIName
Definition: GameObject.h:366
uint32 GameObject::GetCooldown ( ) const
inline

Definition at line 819 of file GameObject.h.

References GAMEOBJECT_TYPE_GOOBER, and GAMEOBJECT_TYPE_TRAP.

Referenced by Use().

820  {
821  switch (GetGoType())
822  {
824  return GetGOInfo()->trap.cooldown;
826  return GetGOInfo()->goober.cooldown;
827  default:
828  return 0;
829  }
830  }
struct GameObjectInfo::@59::@66 trap
GameobjectTypes GetGoType() const
Definition: GameObject.h:737
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
struct GameObjectInfo::@59::@70 goober
void GameObject::getFishLoot ( Loot loot,
Player loot_owner 
)

Definition at line 593 of file GameObject.cpp.

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

Referenced by Player::SendLoot().

594 {
595  fishloot->clear();
596 
597  uint32 subzone = GetAreaId();
598 
599  // if subzone loot exist use it
600  if (LootTemplates_Fishing.HaveLootFor(subzone))
601  fishloot->FillLoot(subzone, LootTemplates_Fishing, loot_owner, true);
602  // else use zone loot
603  else
604  fishloot->FillLoot(GetZoneId(), LootTemplates_Fishing, loot_owner, true);
605 }
uint32 GetZoneId() const
Definition: Object.cpp:1202
uint32 GetAreaId() const
Definition: Object.cpp:1207
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 759 of file GameObject.cpp.

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

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

760 {
761  return object.GetMap()->GetGameObject(guid);
762 }
uint32 GameObject::GetGoAnimProgress ( ) const
inline

Definition at line 754 of file GameObject.h.

References GAMEOBJECT_ANIMPROGRESS.

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

755  {
757  }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:210
uint32 GameObject::GetGoArtKit ( ) const
inline

Definition at line 749 of file GameObject.h.

References GAMEOBJECT_ARTKIT.

750  {
752  }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:210
GameObjectData const* GameObject::GetGOData ( ) const
inline

Definition at line 613 of file GameObject.h.

614  {
615  return m_goData;
616  }
GameObjectData const * m_goData
Definition: GameObject.h:877
GOState GameObject::GetGoState ( ) const
inline

Definition at line 745 of file GameObject.h.

References GAMEOBJECT_STATE.

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

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

Definition at line 1625 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().

1626 {
1627  switch (GetGoType())
1628  {
1630  // gameobjects like guildbanks and mailboxes - 10.0 is a just an abitrary choosen number
1633  return 10.0f;
1636  return 20.0f + CONTACT_DISTANCE; // max spell range
1637  default:
1638  return INTERACTION_DISTANCE;
1639  }
1640 }
#define INTERACTION_DISTANCE
Definition: Object.h:35
GameobjectTypes GetGoType() const
Definition: GameObject.h:737
#define CONTACT_DISTANCE
Definition: Object.h:34
uint8 GameObject::getLevelForTarget ( WorldObject const *  target) const
inlineoverridevirtual

Reimplemented from WorldObject.

Definition at line 839 of file GameObject.h.

840  {
841  if (Unit* owner = GetOwner())
842  return owner->getLevelForTarget(target);
843 
844  return 1;
845  }
Unit * GetOwner() const
Definition: GameObject.cpp:799
Definition: Unit.h:908
LootState GameObject::getLootState ( ) const
inline

Definition at line 765 of file GameObject.h.

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

766  {
767  return m_lootState;
768  }
LootState m_lootState
Definition: GameObject.h:865
const char * GameObject::GetNameForLocaleIdx ( int32  locale_idx) const
overridevirtual

Reimplemented from WorldObject.

Definition at line 1568 of file GameObject.cpp.

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

1569 {
1570  if (loc_idx >= 0)
1571  if (GameObjectLocale const* cl = sObjectMgr.GetGameObjectLocale(GetEntry()))
1572  if (cl->Name.size() > uint32(loc_idx) && !cl->Name[loc_idx].empty())
1573  return cl->Name[loc_idx].c_str();
1574 
1575  return GetName();
1576 }
#define sObjectMgr
Definition: ObjectMgr.h:1317
const char * GetName() const
Definition: Object.h:680
uint32 GetEntry() const
Definition: Object.h:186
ACE_UINT32 uint32
Definition: Define.h:71
Unit * GameObject::GetOwner ( ) const

Definition at line 799 of file GameObject.cpp.

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

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

800 {
801  return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
802 }
uint64 GetOwnerGUID() const
Definition: GameObject.h:681
static Unit * GetUnit(WorldObject const &, uint64 guid)
uint32 GameObject::GetRespawnDelay ( ) const
inline

Definition at line 730 of file GameObject.h.

Referenced by ChatHandler::HandleTargetObjectCommand().

731  {
732  return m_respawnDelayTime;
733  }
uint32 m_respawnDelayTime
Definition: GameObject.h:864
time_t GameObject::GetRespawnTime ( ) const
inline

Definition at line 697 of file GameObject.h.

Referenced by Player::SendLoot().

698  {
699  return m_respawnTime;
700  }
time_t m_respawnTime
Definition: GameObject.h:863
time_t GameObject::GetRespawnTimeEx ( ) const
inline

Definition at line 701 of file GameObject.h.

Referenced by ChatHandler::HandleTargetObjectCommand().

702  {
703  time_t now = time(NULL);
704  if (m_respawnTime > now)
705  return m_respawnTime;
706  else
707  return now;
708  }
time_t m_respawnTime
Definition: GameObject.h:863
uint32 GameObject::GetSpellId ( ) const
inline

Definition at line 692 of file GameObject.h.

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

693  {
694  return m_spellId;
695  }
uint32 m_spellId
Definition: GameObject.h:862
uint32 GameObject::GetUniqueUseCount ( ) const
inline

Definition at line 796 of file GameObject.h.

Referenced by Use().

797  {
798  return m_unique_users.size();
799  }
std::set< uint64 > m_unique_users
Definition: GameObject.h:872
uint32 GameObject::GetUseCount ( ) const
inline

Definition at line 792 of file GameObject.h.

Referenced by WorldSession::DoLootRelease().

793  {
794  return m_usetimes;
795  }
uint32 m_usetimes
Definition: GameObject.h:873
bool GameObject::hasInvolvedQuest ( uint32  quest_id) const
overridevirtual

Reimplemented from Object.

Definition at line 778 of file GameObject.cpp.

References Object::GetEntry(), and sObjectMgr.

779 {
780  QuestRelations const& qr = sObjectMgr.mGOQuestInvolvedRelations;
781  for (QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr)
782  {
783  if (itr->second == quest_id)
784  return true;
785  }
786  return false;
787 }
#define sObjectMgr
Definition: ObjectMgr.h:1317
std::multimap< uint32, uint32 > QuestRelations
Definition: ObjectMgr.h:391
uint32 GetEntry() const
Definition: Object.h:186
bool GameObject::hasQuest ( uint32  quest_id) const
overridevirtual

Reimplemented from Object.

Definition at line 767 of file GameObject.cpp.

References Object::GetEntry(), and sObjectMgr.

768 {
769  QuestRelations const& qr = sObjectMgr.mGOQuestRelations;
770  for (QuestRelations::const_iterator itr = qr.lower_bound(GetEntry()); itr != qr.upper_bound(GetEntry()); ++itr)
771  {
772  if (itr->second == quest_id)
773  return true;
774  }
775  return false;
776 }
#define sObjectMgr
Definition: ObjectMgr.h:1317
std::multimap< uint32, uint32 > QuestRelations
Definition: ObjectMgr.h:391
uint32 GetEntry() const
Definition: Object.h:186
bool GameObject::IsAlwaysVisibleFor ( WorldObject const *  seer) const
overridevirtual

Reimplemented from WorldObject.

Definition at line 821 of file GameObject.cpp.

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

822 {
824  return true;
825 
826  if (IsTransport())
827  return true;
828 
829  if (!seer)
830  return false;
831 
832  // Always seen by owner and friendly units
833  if (ObjectGuid guid = GetOwnerGUID())
834  {
835  if (seer->GetGUID() == guid)
836  return true;
837 
838  Unit* owner = GetOwner();
839  if (Unit const* unitSeer = seer->ToUnit())
840  if (owner && owner->IsFriendlyTo(unitSeer))
841  return true;
842  }
843 
844  return false;
845 }
Unit * GetOwner() const
Definition: GameObject.cpp:799
uint64 GetOwnerGUID() const
Definition: GameObject.h:681
virtual bool IsAlwaysVisibleFor(WorldObject const *) const
Definition: Object.h:793
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:7374
bool IsTransport() const
Definition: GameObject.cpp:789
Definition: Unit.h:908
Unit * ToUnit()
Definition: Object.h:374
bool GameObject::IsInSkillupList ( uint32  PlayerGuidLow) const
inline

Definition at line 775 of file GameObject.h.

Referenced by Spell::EffectOpenLock().

776  {
777  for (std::list<uint32>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i)
778  if (*i == PlayerGuidLow) return true;
779  return false;
780  }
std::list< uint32 > m_SkillupList
Definition: GameObject.h:869
bool GameObject::IsInvisibleDueToDespawn ( ) const
overridevirtual

Reimplemented from WorldObject.

Definition at line 847 of file GameObject.cpp.

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

848 {
850  return true;
851 
852  // Despawned
853  if (!isSpawned())
854  return true;
855 
856  return false;
857 }
virtual bool IsInvisibleDueToDespawn() const
Definition: Object.h:794
bool isSpawned() const
Definition: GameObject.h:716
bool GameObject::IsNeverVisible ( ) const
overridevirtual

Reimplemented from WorldObject.

Definition at line 810 of file GameObject.cpp.

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

811 {
813  return true;
814 
815  if (GetGoType() == GAMEOBJECT_TYPE_SPELL_FOCUS && GetGOInfo()->spellFocus.serverOnly == 1)
816  return true;
817 
818  return false;
819 }
virtual bool IsNeverVisible() const
Definition: Object.h:792
uint32 serverOnly
Definition: GameObject.h:111
GameobjectTypes GetGoType() const
Definition: GameObject.h:737
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
bool GameObject::isSpawned ( ) const
inline
bool GameObject::isSpawnedByDefault ( ) const
inline

Definition at line 722 of file GameObject.h.

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

723  {
724  return m_spawnedByDefault;
725  }
bool m_spawnedByDefault
Definition: GameObject.h:866
bool GameObject::IsTransport ( ) const

Definition at line 789 of file GameObject.cpp.

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

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

790 {
791  // If something is marked as a transport, don't transmit an out of range packet for it.
792  GameObjectInfo const* gInfo = GetGOInfo();
793  if (!gInfo)
794  return false;
795 
796  return gInfo->type == GAMEOBJECT_TYPE_TRANSPORT || gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT;
797 }
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
bool GameObject::IsUsedBy ( uint64  guid)
inline

Definition at line 801 of file GameObject.h.

802  {
803  return m_unique_users.find(guid) != m_unique_users.end();
804  }
std::set< uint64 > m_unique_users
Definition: GameObject.h:872
bool GameObject::LoadFromDB ( uint32  guid,
Map map 
)
inline

Definition at line 669 of file GameObject.h.

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

Definition at line 680 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().

681 {
682  GameObjectData const* data = sObjectMgr.GetGOData(guid);
683 
684  if (!data)
685  {
686  sLog.outErrorDb("ERROR: Gameobject (GUID: %u) not found in table gameobject, can't load. ", guid);
687  return false;
688  }
689 
690  uint32 entry = data->id;
691  //uint32 map_id = data->mapid;
692  uint32 phaseMask = data->phaseMask;
693  float x = data->posX;
694  float y = data->posY;
695  float z = data->posZ;
696  float ang = data->orientation;
697 
698  float rotation0 = data->rotation0;
699  float rotation1 = data->rotation1;
700  float rotation2 = data->rotation2;
701  float rotation3 = data->rotation3;
702 
703  uint32 animprogress = data->animprogress;
704  GOState go_state = data->go_state;
705  uint32 artKit = data->artKit;
706 
707  m_DBTableGuid = guid;
708  if (map->GetInstanceId() != 0) guid = sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
709 
710  if (!Create(guid, entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit))
711  return false;
712 
713  if (data->spawntimesecs >= 0)
714  {
715  m_spawnedByDefault = true;
716 
717  if (!GetGOInfo()->GetDespawnPossibility() && !GetGOInfo()->IsDespawnAtAction())
718  {
720  m_respawnDelayTime = 0;
721  m_respawnTime = 0;
722  }
723  else
724  {
726  m_respawnTime = sObjectMgr.GetGORespawnTime(m_DBTableGuid, map->GetInstanceId());
727 
728  // ready to respawn
729  if (m_respawnTime && m_respawnTime <= time(NULL))
730  {
731  m_respawnTime = 0;
732  sObjectMgr.SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), 0);
733  }
734  }
735  }
736  else
737  {
738  m_spawnedByDefault = false;
740  m_respawnTime = 0;
741  }
742 
743  m_goData = data;
744 
745  if (addToMap && !GetMap()->AddToMap(this))
746  return false;
747 
748  return true;
749 }
Map * GetMap() const
Definition: Object.h:817
int32 spawntimesecs
Definition: GameObject.h:568
uint32 m_respawnDelayTime
Definition: GameObject.h:864
#define sLog
Log class singleton.
Definition: Log.h:187
GameObjectData const * m_goData
Definition: GameObject.h:877
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:983
float orientation
Definition: GameObject.h:563
#define sObjectMgr
Definition: ObjectMgr.h:1317
time_t m_respawnTime
Definition: GameObject.h:863
uint32 m_DBTableGuid
Definition: GameObject.h:875
uint32 GetInstanceId() const
Definition: Object.h:664
GOState
Definition: GameObject.h:542
bool m_spawnedByDefault
Definition: GameObject.h:866
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
uint32 animprogress
Definition: GameObject.h:569
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:557
uint32 GetInstanceId() const
Definition: Map.h:390
GOState go_state
Definition: GameObject.h:570
GameObject * GameObject::LookupFishingHoleAround ( float  range)

Definition at line 946 of file GameObject.cpp.

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

Referenced by Use().

947 {
948  GameObject* ok = NULL;
949 
951  Cell cell(p);
952  Oregon::NearestGameObjectFishingHole u_check(*this, range);
954 
956  cell.Visit(p, grid_object_checker, *GetMap(), *this, range);
957 
958  return ok;
959 }
Map * GetMap() const
Definition: Object.h:817
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 559 of file GameObject.cpp.

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

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

560 {
561  // not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway)
563  return;
564 
565  if (isSpawned())
566  GetMap()->AddToMap(this);
567 }
bool AddToMap(T *)
Definition: Map.cpp:424
Map * GetMap() const
Definition: Object.h:817
time_t m_respawnTime
Definition: GameObject.h:863
bool isSpawned() const
Definition: GameObject.h:716
bool m_spawnedByDefault
Definition: GameObject.h:866
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:799
#define GUID_LOPART(x)
Definition: ObjectGuid.h:110
Map * GetMap() const
Definition: Object.h:817
uint64 GetOwnerGUID() const
Definition: GameObject.h:681
#define sLog
Log class singleton.
Definition: Log.h:187
void Remove(const GameObjectModel &mdl)
Definition: Map.h:533
uint32 GetGUIDLow() const
Definition: Object.h:178
GameObjectModel * m_model
Definition: GameObject.h:880
const bool & IsInWorld() const
Definition: Object.h:150
ZoneScript * m_zoneScript
Definition: Object.h:897
virtual void RemoveFromWorld() override
Definition: Object.cpp:1192
void RemoveObject(T *object)
ACE_UINT64 uint64
Definition: Define.h:70
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
Definition: Unit.h:908
virtual void OnGameObjectCreate(GameObject *, bool)
Definition: ZoneScript.h:45
void GameObject::ResetDoorOrButton ( )

Definition at line 961 of file GameObject.cpp.

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

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

962 {
964  return;
965 
966  SwitchDoorOrButton(false);
968  m_cooldownTime = 0;
969 }
LootState m_lootState
Definition: GameObject.h:865
void SwitchDoorOrButton(bool activate, bool alternative=false)
Definition: GameObject.cpp:993
time_t m_cooldownTime
Definition: GameObject.h:867
void SetLootState(LootState s, Unit *unit=NULL)
void GameObject::Respawn ( )

Definition at line 859 of file GameObject.cpp.

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

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

860 {
862  {
863  m_respawnTime = time(NULL);
864  sObjectMgr.SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), 0);
865  }
866 }
#define sObjectMgr
Definition: ObjectMgr.h:1317
time_t m_respawnTime
Definition: GameObject.h:863
uint32 m_DBTableGuid
Definition: GameObject.h:875
uint32 GetInstanceId() const
Definition: Object.h:664
bool m_spawnedByDefault
Definition: GameObject.h:866
void GameObject::SaveRespawnTime ( )
overridevirtual

Reimplemented from WorldObject.

Definition at line 804 of file GameObject.cpp.

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

Referenced by Update().

805 {
806  if (m_goData && m_goData->dbData && m_respawnTime > time(NULL) && m_spawnedByDefault)
807  sObjectMgr.SaveGORespawnTime(m_DBTableGuid, GetInstanceId(), m_respawnTime);
808 }
GameObjectData const * m_goData
Definition: GameObject.h:877
#define sObjectMgr
Definition: ObjectMgr.h:1317
time_t m_respawnTime
Definition: GameObject.h:863
uint32 m_DBTableGuid
Definition: GameObject.h:875
uint32 GetInstanceId() const
Definition: Object.h:664
bool m_spawnedByDefault
Definition: GameObject.h:866
void GameObject::SaveToDB ( )

Definition at line 607 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().

608 {
609  // this should only be used when the gameobject has already been loaded
610  // preferably after adding to map, because mapid may not be valid otherwise
611  GameObjectData const* data = sObjectMgr.GetGOData(m_DBTableGuid);
612  if (!data)
613  {
614  sLog.outError("GameObject::SaveToDB failed, cannot get gameobject data!");
615  return;
616  }
617 
618  SaveToDB(GetMapId(), data->spawnMask, data->phaseMask);
619 }
#define sLog
Log class singleton.
Definition: Log.h:187
#define sObjectMgr
Definition: ObjectMgr.h:1317
uint32 m_DBTableGuid
Definition: GameObject.h:875
uint32 GetMapId() const
Definition: Object.h:567
void SaveToDB()
Definition: GameObject.cpp:607
uint32 phaseMask
Definition: GameObject.h:557
void GameObject::SaveToDB ( uint32  mapid,
uint8  spawnMask,
uint32  phaseMask 
)

Definition at line 621 of file GameObject.cpp.

References GameObjectData::animprogress, GameObjectData::areaId, Database::BeginTransaction(), Database::CommitTransaction(), GAMEOBJECT_FACING, GAMEOBJECT_POS_X, GAMEOBJECT_POS_Y, GAMEOBJECT_POS_Z, GAMEOBJECT_ROTATION, WorldObject::GetAreaId(), Object::GetEntry(), Object::GetFloatValue(), GetGoAnimProgress(), GetGOInfo(), GetGoState(), Object::GetGUIDLow(), Object::GetUInt32Value(), WorldObject::GetZoneId(), 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, WorldDatabase, and GameObjectData::zoneId.

622 {
623  const GameObjectInfo* goI = GetGOInfo();
624 
625  if (!goI)
626  return;
627 
628  if (!m_DBTableGuid)
630  // update in loaded data (changing data only in this place)
631  GameObjectData& data = sObjectMgr.NewGOData(m_DBTableGuid);
632 
633  // data->guid = guid don't must be update at save
634  data.id = GetEntry();
635  data.mapid = mapid;
636  data.zoneId = GetZoneId();
637  data.areaId = GetAreaId();
638  data.spawnMask = spawnMask;
639  data.phaseMask = phaseMask;
650  data.go_state = GetGoState();
651 
652  // updated in DB
653  std::ostringstream ss;
654  ss << "INSERT INTO gameobject VALUES ("
655  << m_DBTableGuid << ", "
657  << mapid << ", "
658  << (uint32)GetZoneId() << ", "
659  << (uint32)GetAreaId() << ", "
660  << (uint32)spawnMask << ", "
661  << (uint32)phaseMask << ", "
662  << GetFloatValue(GAMEOBJECT_POS_X) << ", "
663  << GetFloatValue(GAMEOBJECT_POS_Y) << ", "
664  << GetFloatValue(GAMEOBJECT_POS_Z) << ", "
665  << GetFloatValue(GAMEOBJECT_FACING) << ", "
667  << GetFloatValue(GAMEOBJECT_ROTATION + 1) << ", "
668  << GetFloatValue(GAMEOBJECT_ROTATION + 2) << ", "
669  << GetFloatValue(GAMEOBJECT_ROTATION + 3) << ", "
670  << m_respawnDelayTime << ", "
671  << uint32(GetGoAnimProgress()) << ", "
672  << uint32(GetGoState()) << ")";
673 
675  WorldDatabase.PExecuteLog("DELETE FROM gameobject WHERE guid = '%u'", m_DBTableGuid);
676  WorldDatabase.PExecuteLog("%s", ss.str().c_str());
678 }
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:210
GOState GetGoState() const
Definition: GameObject.h:745
DatabaseType WorldDatabase
Accessor to the world database.
Definition: Main.cpp:53
int32 spawntimesecs
Definition: GameObject.h:568
bool BeginTransaction()
Definition: Database.cpp:533
uint32 m_respawnDelayTime
Definition: GameObject.h:864
uint32 GetZoneId() const
Definition: Object.cpp:1202
ACE_INT32 int32
Definition: Define.h:67
uint32 GetGUIDLow() const
Definition: Object.h:178
float orientation
Definition: GameObject.h:563
#define sObjectMgr
Definition: ObjectMgr.h:1317
bool CommitTransaction()
Definition: Database.cpp:551
bool PExecuteLog(const char *format,...) ATTR_PRINTF(2
Definition: Database.cpp:221
uint32 GetGoAnimProgress() const
Definition: GameObject.h:754
uint32 m_DBTableGuid
Definition: GameObject.h:875
uint32 GetAreaId() const
Definition: Object.cpp:1207
bool m_spawnedByDefault
Definition: GameObject.h:866
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
uint32 animprogress
Definition: GameObject.h:569
uint32 GetEntry() const
Definition: Object.h:186
ACE_UINT32 uint32
Definition: Define.h:71
uint32 phaseMask
Definition: GameObject.h:557
GOState go_state
Definition: GameObject.h:570
const float & GetFloatValue(uint16 index) const
Definition: Object.h:222
void GameObject::Say ( const char *  text,
uint32  language,
uint64  TargetGuid 
)
inline

Definition at line 631 of file GameObject.h.

632  {
633  MonsterSay(text, language, TargetGuid);
634  }
void MonsterSay(const char *text, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1513
void GameObject::Say ( int32  textId,
uint32  language,
uint64  TargetGuid 
)
inline

Definition at line 647 of file GameObject.h.

648  {
649  MonsterSay(textId, language, TargetGuid);
650  }
void MonsterSay(const char *text, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1513
void GameObject::SetDisplayId ( uint32  displayid)
protected

Definition at line 1655 of file GameObject.cpp.

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

1656 {
1658  UpdateModel();
1659 }
void UpdateModel()
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:777
void GameObject::SetGoAnimProgress ( uint32  animprogress)
inline

Definition at line 758 of file GameObject.h.

References GAMEOBJECT_ANIMPROGRESS.

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

759  {
761  }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:777
void GameObject::SetGoArtKit ( uint32  artkit)

Definition at line 985 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().

986 {
988  GameObjectData* data = const_cast<GameObjectData*>(sObjectMgr.GetGOData(m_DBTableGuid));
989  if (data)
990  data->artKit = kit;
991 }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:777
#define sObjectMgr
Definition: ObjectMgr.h:1317
uint32 m_DBTableGuid
Definition: GameObject.h:875
void GameObject::SetGoState ( GOState  state)

Definition at line 1608 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().

1609 {
1611  if (m_model && !IsTransport())
1612  {
1613  if (!IsInWorld())
1614  return;
1615 
1616  // startOpen determines whether we are going to add or remove the LoS on activation
1617  bool collision = false;
1618  if (state == GO_STATE_READY)
1619  collision = !collision;
1620 
1621  EnableCollision(collision);
1622  }
1623 }
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:777
GameObjectModel * m_model
Definition: GameObject.h:880
const bool & IsInWorld() const
Definition: Object.h:150
bool IsTransport() const
Definition: GameObject.cpp:789
void EnableCollision(bool enable)
void GameObject::SetGoType ( GameobjectTypes  type)
inline

Definition at line 741 of file GameObject.h.

References GAMEOBJECT_TYPE_ID.

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

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

Definition at line 1505 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().

1506 {
1507  m_lootState = s;
1508 
1509  AI()->OnStateChanged(s, unit);
1510  if (m_model)
1511  {
1512  bool collision = false;
1513  // Use the current go state
1514  if ((GetGoState() != GO_STATE_READY && (s == GO_ACTIVATED || s == GO_JUST_DEACTIVATED)) || s == GO_READY)
1515  collision = !collision;
1516 
1517  EnableCollision(collision);
1518  }
1519 }
LootState m_lootState
Definition: GameObject.h:865
GameObjectAI * AI() const
Definition: GameObject.h:857
virtual void OnStateChanged(uint32, Unit *)
Definition: GameObjectAI.h:54
GOState GetGoState() const
Definition: GameObject.h:745
GameObjectModel * m_model
Definition: GameObject.h:880
void EnableCollision(bool enable)
void GameObject::SetOwnerGUID ( uint64  owner)
inline

Definition at line 673 of file GameObject.h.

References OBJECT_FIELD_CREATED_BY.

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

674  {
675  // Owner already found and different than expected owner - remove object from old owner
676  if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
677  assert(false);
678  m_spawnedByDefault = false; // all object with owner is despawned after delay
680  }
uint64 GetOwnerGUID() const
Definition: GameObject.h:681
void SetUInt64Value(uint16 index, const uint64 &value)
Definition: Object.cpp:796
bool m_spawnedByDefault
Definition: GameObject.h:866
void GameObject::SetPhaseMask ( uint32  newPhaseMask,
bool  update 
)
overridevirtual

Reimplemented from WorldObject.

Definition at line 1661 of file GameObject.cpp.

References WorldObject::SetPhaseMask().

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

1662 {
1663  WorldObject::SetPhaseMask(newPhaseMask, update);
1664 }
virtual void SetPhaseMask(uint32 newPhaseMask, bool update)
Definition: Object.cpp:2587
void GameObject::SetSpawnedByDefault ( bool  b)
inline

Definition at line 726 of file GameObject.h.

Referenced by WorldObject::SummonGameObject().

727  {
728  m_spawnedByDefault = b;
729  }
bool m_spawnedByDefault
Definition: GameObject.h:866
void GameObject::SetSpellId ( uint32  id)
inline

Definition at line 687 of file GameObject.h.

References GameObjectInfo::id.

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

688  {
689  m_spawnedByDefault = false; // all summoned object is despawned after delay
690  m_spellId = id;
691  }
bool m_spawnedByDefault
Definition: GameObject.h:866
uint32 m_spellId
Definition: GameObject.h:862
void GameObject::SwitchDoorOrButton ( bool  activate,
bool  alternative = false 
)
private

Definition at line 993 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().

994 {
995  if (activate)
997  else
999 
1000  if (GetGoState() == GO_STATE_READY) //if closed -> open
1002  else //if open -> close
1004 }
GOState GetGoState() const
Definition: GameObject.h:745
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:983
void SetGoState(GOState state)
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1004
void GameObject::TextEmote ( const char *  text,
uint64  TargetGuid 
)
inline

Definition at line 639 of file GameObject.h.

640  {
641  MonsterTextEmote(text, TargetGuid);
642  }
void MonsterTextEmote(const char *text, uint64 TargetGuid, bool IsBossEmote=false)
Definition: Object.cpp:1527
void GameObject::TextEmote ( int32  textId,
uint64  TargetGuid 
)
inline

Definition at line 655 of file GameObject.h.

656  {
657  MonsterTextEmote(textId, TargetGuid);
658  }
void MonsterTextEmote(const char *text, uint64 TargetGuid, bool IsBossEmote=false)
Definition: Object.cpp:1527
Transport* GameObject::ToTransport ( )
inline

Definition at line 847 of file GameObject.h.

References GAMEOBJECT_TYPE_TRANSPORT, and GameObjectInfo::type.

Referenced by AddToWorld().

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

Definition at line 848 of file GameObject.h.

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

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

Definition at line 912 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().

913 {
914  GameObjectInfo const* trapInfo = sGOStorage.LookupEntry<GameObjectInfo>(trapEntry);
915  if (!trapInfo || trapInfo->type != GAMEOBJECT_TYPE_TRAP)
916  return;
917 
918  SpellEntry const* trapSpell = sSpellStore.LookupEntry(trapInfo->trap.spellId);
919  if (!trapSpell) // checked at load already
920  return;
921 
922  float range = GetSpellMaxRange(sSpellRangeStore.LookupEntry(trapSpell->rangeIndex));
923  if (range < CONTACT_DISTANCE)
924  range = CONTACT_DISTANCE;
925 
926  // search nearest linked GO
927  GameObject* trapGO = NULL;
928  {
929  // using original GO distance
931  Cell cell(p);
932 
933  Oregon::NearestGameObjectEntryInObjectRangeCheck go_check(*target, trapEntry, range);
935 
937  cell.Visit(p, object_checker, *GetMap(), *target, range);
938  }
939 
940  // found correct GO
941  // FIXME: when GO casting will be implemented trap must cast spell to target
942  if (trapGO)
943  target->CastSpell(target, trapSpell, true);
944 }
struct GameObjectInfo::@59::@66 trap
Map * GetMap() const
Definition: Object.h:817
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:1260
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 234 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_ESCAPED, sObjectMgr, sPoolMgr, sSpellStore, sWorld, Object::ToPlayer(), GameObjectInfo::trap, GameObjectInfo::type, TYPEID_PLAYER, GameObjectAI::UpdateAI(), WorldObject::UpdateObjectVisibility(), WorldObject::VisitNearbyGridObject(), and WorldObject::VisitNearbyWorldObject().

235 {
236  if (IS_MO_TRANSPORT(GetGUID()))
237  {
238  //((Transport*)this)->Update(p_time);
239  return;
240  }
241 
242  if (AI())
243  AI()->UpdateAI(diff);
244  else if (!AIM_Initialize())
245  sLog.outError("Could not initialize GameObjectAI");
246 
247  switch (m_lootState)
248  {
249  case GO_NOT_READY:
250  {
251  switch (GetGoType())
252  {
254  {
255  // Arming Time for GAMEOBJECT_TYPE_TRAP (6)
256  Unit* owner = GetOwner();
257  if (owner && owner->IsInCombat())
258  m_cooldownTime = time(NULL) + GetGOInfo()->trap.cooldown;
260  break;
261  }
263  {
264  // fishing code (bobber ready)
265  if (time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME)
266  {
267  // splash bobber (bobber ready now)
268  Unit* caster = GetOwner();
269  if (caster && caster->GetTypeId() == TYPEID_PLAYER)
270  {
273 
274  UpdateData udata;
275  WorldPacket packet;
276  BuildValuesUpdateBlockForPlayer(&udata, caster->ToPlayer());
277  udata.BuildPacket(&packet);
278  caster->ToPlayer()->GetSession()->SendPacket(&packet);
279 
281  }
282 
283  m_lootState = GO_READY; // can be successfully open with some chance
284  }
285  return;
286  }
287  default:
288  m_lootState = GO_READY; // for other GOis same switched without delay to GO_READY
289  break;
290  }
291  // NO BREAK for switch (m_lootState)
292  }
293  case GO_READY:
294  {
295  if (m_respawnTime > 0) // timer on
296  {
297  if (m_respawnTime <= time(NULL)) // timer expired
298  {
299  m_respawnTime = 0;
300  m_SkillupList.clear();
301  m_usetimes = 0;
302 
303  switch (GetGoType())
304  {
305  case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now
306  {
307  Unit* caster = GetOwner();
308  if (caster && caster->GetTypeId() == TYPEID_PLAYER)
309  {
311 
313  caster->ToPlayer()->GetSession()->SendPacket(&data);
314  }
315  // can be delete
317  return;
318  }
321  //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)
322  if (GetGoState() != GO_STATE_READY)
324  break;
325  default:
326  break;
327  }
328 
329  // Despawn timer
330  if (!m_spawnedByDefault)
331  {
332  // Can be despawned or destroyed
334  return;
335  }
336 
337  // Respawn timer
338  uint32 poolid = GetDBTableGUIDLow() ? sPoolMgr.IsPartOfAPool<GameObject>(GetDBTableGUIDLow()) : 0;
339  if (poolid)
340  sPoolMgr.UpdatePool<GameObject>(poolid, GetDBTableGUIDLow());
341  else
342  GetMap()->AddToMap(this);
343  }
344  }
345 
346  if (isSpawned())
347  {
348  GameObjectInfo const* goInfo = GetGOInfo();
349  if (goInfo->type == GAMEOBJECT_TYPE_TRAP)
350  {
351  if (m_cooldownTime >= time(NULL))
352  break;
353 
354  // traps
355  Unit* owner = GetOwner();
356  Unit* ok = NULL; // pointer to appropriate target if found any
357 
358  bool IsBattlegroundTrap = false;
359  //FIXME: this is activation radius (in different casting radius that must be selected from spell data)
360  //@todo move activated state code (cast itself) to GO_ACTIVATED, in this place only check activating and set state
361  float radius = (float)(goInfo->trap.radius) / 2; // TODO rename radius to diameter (goInfo->trap.radius) should be (goInfo->trap.diameter)
362  if (!radius)
363  {
364  if (goInfo->trap.cooldown != 3) // cast in other case (at some triggering/linked go/etc explicit call)
365  {
366  // try to read radius from trap spell
367  if (const SpellEntry* spellEntry = sSpellStore.LookupEntry(goInfo->trap.spellId))
368  radius = GetSpellRadius(spellEntry, 0, false);
369  // radius = GetSpellRadius(sSpellRadiusStore.LookupEntry(spellEntry->EffectRadiusIndex[0]));
370 
371  if (!radius)
372  break;
373  }
374  else
375  {
376  if (m_respawnTime > 0)
377  break;
378 
379  radius = goInfo->trap.cooldown; // battlegrounds gameobjects has data2 == 0 && data5 == 3
380  IsBattlegroundTrap = true;
381  }
382  }
383 
385  if (owner)
386  {
387  // Hunter trap: Search units which are unfriendly to the trap's owner
388  Oregon::AnyUnfriendlyNoTotemUnitInObjectRangeCheck checker(this, owner, radius);
390  VisitNearbyGridObject(radius, searcher);
391  if (!ok)
392  VisitNearbyWorldObject(radius, searcher);
393  }
394  else
395  {
396  // Environmental trap: Any player
397  Player* player = NULL;
398  Oregon::AnyPlayerInObjectRangeCheck checker(this, radius);
399  Oregon::PlayerSearcher<Oregon::AnyPlayerInObjectRangeCheck> searcher(this, player, checker);
400  VisitNearbyWorldObject(radius, searcher);
401  ok = player;
402  }
403 
404  if (ok)
405  {
406  // some traps do not have spell but should be triggered
407  if (goInfo->trap.spellId)
408  CastSpell(ok, goInfo->trap.spellId);
409 
410  m_cooldownTime = time(NULL) + (goInfo->trap.cooldown ? goInfo->trap.cooldown : uint32(4));
411 
412  if (goInfo->trap.type == 1)
414 
415  if (IsBattlegroundTrap && ok->GetTypeId() == TYPEID_PLAYER)
416  {
417  //Battleground gameobjects case
418  if (ok->ToPlayer()->InBattleground())
419  if (Battleground* bg = ok->ToPlayer()->GetBattleground())
420  bg->HandleTriggerBuff(GetGUID());
421  }
422  }
423  }
424  else if (uint32 max_charges = goInfo->GetCharges())
425  {
426  if (m_usetimes >= max_charges)
427  {
428  m_usetimes = 0;
429  SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed
430  }
431  }
432  }
433 
434  break;
435  }
436  case GO_ACTIVATED:
437  {
438  switch (GetGoType())
439  {
442  if (GetGOInfo()->GetAutoCloseTime() && (m_cooldownTime < time(NULL)))
444  break;
446  if (m_cooldownTime < time(NULL))
447  {
449 
451  m_cooldownTime = 0;
452  }
453  break;
456  {
457  if (diff <= m_groupLootTimer)
458  m_groupLootTimer -= diff;
459  else
460  {
461  Group* group = sObjectMgr.GetGroupByLeader(lootingGroupLeaderGUID);
462  if (group)
463  group->EndRoll();
464  m_groupLootTimer = 0;
466  }
467  }
468  break;
469  default:
470  break;
471  }
472  break;
473  }
474  case GO_JUST_DEACTIVATED:
475  {
476  //if Gameobject should cast spell, then this, but some GOs (type = 10) should be destroyed
478  {
479  uint32 spellId = GetGOInfo()->goober.spellId;
480 
481  if (spellId)
482  {
483  for (std::set<uint64>::const_iterator it = m_unique_users.begin(); it != m_unique_users.end(); ++it)
484  // m_unique_users can contain only player GUIDs
485  if (Player* owner = ObjectAccessor::GetPlayer(*this, *it))
486  owner->CastSpell(owner, spellId, false);
487 
488  m_unique_users.clear();
489  m_usetimes = 0;
490  }
491 
493 
494  //any return here in case battleground traps
495  if (GetGOInfo()->flags & GO_FLAG_NODESPAWN)
496  return;
497  }
498 
499  loot.clear();
500 
503  if (GetSpellId() || GetOwnerGUID())
504  {
505  //Don't delete spell spawned chests, which are not consumed on loot
506  if (m_respawnTime > 0 && GetGoType() == GAMEOBJECT_TYPE_CHEST && !GetGOInfo()->IsDespawnAtAction())
507  {
510  }
511  else
512  {
513  SetRespawnTime(0);
514  Delete();
515  }
516  return;
517  }
518 
520 
521  //burning flags in some battlegrounds, if you find better condition, just add it
522  if (GetGOInfo()->IsDespawnAtAction() || GetGoAnimProgress() > 0)
523  {
525  //reset flags
526  if (GetMap()->Instanceable())
527  {
528  // In Instances GO_FLAG_LOCKED, GO_FLAG_INTERACT_COND or GO_FLAG_NO_INTERACT are not changed
530  SetUInt32Value(GAMEOBJECT_FLAGS, (GetGOInfo()->flags & ~(GO_FLAG_LOCKED | GO_FLAG_INTERACT_COND | GO_FLAG_NOT_SELECTABLE)) | currentLockOrInteractFlags);
531  }
532  else
534  }
535 
536  if (!m_respawnDelayTime)
537  return;
538 
539  if (!m_spawnedByDefault)
540  {
541  m_respawnTime = 0;
542  Delete();
543  return;
544  }
545 
546  m_respawnTime = time(NULL) + m_respawnDelayTime;
547 
548  // if option not set then object will be saved at grid unload
550  SaveRespawnTime();
551 
553 
554  break;
555  }
556  }
557 }
bool BuildPacket(WorldPacket *packet, bool hasTransport=false)
Definition: UpdateData.cpp:103
struct GameObjectInfo::@59::@66 trap
LootState m_lootState
Definition: GameObject.h:865
bool AddToMap(T *)
Definition: Map.cpp:424
GameObjectAI * AI() const
Definition: GameObject.h:857
bool AIM_Initialize()
Definition: GameObject.cpp:76
const uint32 & GetUInt32Value(uint16 index) const
Definition: Object.h:210
Unit * GetOwner() const
Definition: GameObject.cpp:799
void ResetDoorOrButton()
Definition: GameObject.cpp:961
Battleground * GetBattleground() const
Definition: Player.cpp:19415
GOState GetGoState() const
Definition: GameObject.h:745
Map * GetMap() const
Definition: Object.h:817
void SendObjectCustomAnim(uint64 guid, uint32 anim=0)
Definition: Object.cpp:1973
uint32 m_usetimes
Definition: GameObject.h:873
uint32 m_respawnDelayTime
Definition: GameObject.h:864
void BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) const
Definition: Object.cpp:218
uint64 GetOwnerGUID() const
Definition: GameObject.h:681
uint64 lootingGroupLeaderGUID
Definition: Object.h:888
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:777
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:710
static Player * GetPlayer(WorldObject const &, uint64 guid)
void clear()
Definition: LootMgr.h:327
#define sObjectMgr
Definition: ObjectMgr.h:1317
void SendPacket(WorldPacket const *packet)
DBCStorage< SpellEntry > sSpellStore(SpellEntryfmt)
time_t m_cooldownTime
Definition: GameObject.h:867
void VisitNearbyGridObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:885
Player * ToPlayer()
Definition: Object.h:368
virtual void UpdateAI(uint32)
Definition: GameObjectAI.h:36
uint64 GetGUID() const
Definition: Object.h:177
uint32 GetGoAnimProgress() const
Definition: GameObject.h:754
void SetLootState(LootState s, Unit *unit=NULL)
uint8 GetTypeId() const
Definition: Object.h:192
time_t m_respawnTime
Definition: GameObject.h:863
uint32 GetCharges() const
Definition: GameObject.h:380
#define FISHING_BOBBER_READY_TIME
Definition: GameObject.h:594
#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:1260
std::set< uint64 > m_unique_users
Definition: GameObject.h:872
void SetGoState(GOState state)
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1004
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:716
#define IS_MO_TRANSPORT(Guid)
Definition: ObjectGuid.h:75
bool m_spawnedByDefault
Definition: GameObject.h:866
GameobjectTypes GetGoType() const
Definition: GameObject.h:737
void SendObjectDeSpawnAnim(uint64 guid)
Definition: Object.cpp:1966
void EndRoll()
Definition: Group.cpp:761
void CastSpell(Unit *target, uint32 spellId, bool triggered=true)
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:2650
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
void SaveRespawnTime() override
Definition: GameObject.cpp:804
void FinishSpell(CurrentSpellTypes spellType, bool ok=true)
Definition: Unit.cpp:3566
std::list< uint32 > m_SkillupList
Definition: GameObject.h:869
uint32 GetSpellId() const
Definition: GameObject.h:692
WorldSession * GetSession() const
Definition: Player.h:1947
uint32 GetDBTableGUIDLow() const
Definition: GameObject.h:624
#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:923
uint32 m_groupLootTimer
Definition: Object.h:887
void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const
Definition: Object.h:883
Definition: Group.h:154
void Delete()
Definition: GameObject.cpp:577
void GameObject::UpdateModel ( )
private

Definition at line 1674 of file GameObject.cpp.

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

Referenced by SetDisplayId().

1675 {
1676  if (!IsInWorld())
1677  return;
1678  if (m_model)
1679  if (GetMap()->Contains(*m_model))
1680  GetMap()->Remove(*m_model);
1681  delete m_model;
1683  if (m_model)
1684  GetMap()->Insert(*m_model);
1685 }
Map * GetMap() const
Definition: Object.h:817
void Remove(const GameObjectModel &mdl)
Definition: Map.h:533
GameObjectModel * m_model
Definition: GameObject.h:880
void Insert(const GameObjectModel &mdl)
Definition: Map.h:534
const bool & IsInWorld() const
Definition: Object.h:150
static GameObjectModel * Create(const GameObject &go)
void GameObject::UpdateModelPosition ( )

Definition at line 1642 of file GameObject.cpp.

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

Referenced by Transport::Update().

1643 {
1644  if (!m_model)
1645  return;
1646 
1647  if (GetMap()->Contains(*m_model))
1648  {
1649  GetMap()->Remove(*m_model);
1650  m_model->Relocate(*this);
1651  GetMap()->Insert(*m_model);
1652  }
1653 }
Map * GetMap() const
Definition: Object.h:817
void Remove(const GameObjectModel &mdl)
Definition: Map.h:533
bool Relocate(GameObject const &go)
GameObjectModel * m_model
Definition: GameObject.h:880
void Insert(const GameObjectModel &mdl)
Definition: Map.h:534
void GameObject::UpdateRotationFields ( float  rotation2 = 0.0f,
float  rotation3 = 0.0f 
)

Definition at line 1578 of file GameObject.cpp.

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

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

1579 {
1580  static double const atan_pow = atan(pow(2.0f, -20.0f));
1581 
1582  double f_rot1 = std::sin(GetOrientation() / 2.0f);
1583  double f_rot2 = std::cos(GetOrientation() / 2.0f);
1584 
1585  int64 i_rot1 = int64(f_rot1 / atan_pow *(f_rot2 >= 0 ? 1.0f : -1.0f));
1586  int64 rotation = (i_rot1 << 43 >> 43) & 0x00000000001FFFFF;
1587 
1589 
1590  if (rotation2 == 0.0f && rotation3 == 0.0f)
1591  {
1592  rotation2 = sin(GetOrientation() / 2);
1593  rotation3 = cos(GetOrientation() / 2);
1594  }
1595 
1596  SetFloatValue(GAMEOBJECT_ROTATION+2, rotation2);
1597  SetFloatValue(GAMEOBJECT_ROTATION+3, rotation3);
1598 }
float GetOrientation() const
Definition: Position.h:100
ACE_INT64 int64
Definition: Define.h:66
void SetFloatValue(uint16 index, float value)
Definition: Object.cpp:857
void GameObject::Use ( Unit user)

Definition at line 1006 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().

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

Definition at line 971 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().

972 {
973  if (m_lootState != GO_READY)
974  return;
975 
976  if (!time_to_restore)
977  time_to_restore = GetGOInfo()->GetAutoCloseTime();
978 
979  SwitchDoorOrButton(true, alternative);
980  SetLootState(GO_ACTIVATED, user);
981 
982  m_cooldownTime = time_to_restore ? (time(NULL) + time_to_restore) : 0;
983 }
LootState m_lootState
Definition: GameObject.h:865
void SwitchDoorOrButton(bool activate, bool alternative=false)
Definition: GameObject.cpp:993
time_t m_cooldownTime
Definition: GameObject.h:867
void SetLootState(LootState s, Unit *unit=NULL)
uint32 GetAutoCloseTime() const
Definition: GameObject.h:391
GameObjectInfo const * GetGOInfo() const
Definition: GameObject.h:609
void GameObject::Whisper ( const char *  text,
uint64  receiver 
)
inline

Definition at line 643 of file GameObject.h.

644  {
645  MonsterWhisper(text, receiver);
646  }
void MonsterWhisper(const char *text, uint64 receiver, bool IsBossWhisper=false)
Definition: Object.cpp:1534
void GameObject::Whisper ( int32  textId,
uint64  receiver 
)
inline

Definition at line 659 of file GameObject.h.

660  {
661  MonsterWhisper(textId, receiver);
662  }
void MonsterWhisper(const char *text, uint64 receiver, bool IsBossWhisper=false)
Definition: Object.cpp:1534
void GameObject::Yell ( const char *  text,
uint32  language,
uint64  TargetGuid 
)
inline

Definition at line 635 of file GameObject.h.

636  {
637  MonsterYell(text, language, TargetGuid);
638  }
void MonsterYell(const char *text, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1520
void GameObject::Yell ( int32  textId,
uint32  language,
uint64  TargetGuid 
)
inline

Definition at line 651 of file GameObject.h.

652  {
653  MonsterYell(textId, language, TargetGuid);
654  }
void MonsterYell(const char *text, uint32 language, uint64 TargetGuid)
Definition: Object.cpp:1520

Member Data Documentation

GameObjectAI* GameObject::m_AI
private

Definition at line 884 of file GameObject.h.

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

time_t GameObject::m_cooldownTime
protected

Definition at line 867 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 877 of file GameObject.h.

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

GameObjectInfo const* GameObject::m_goInfo
protected

Definition at line 876 of file GameObject.h.

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

LootState GameObject::m_lootState
protected

Definition at line 865 of file GameObject.h.

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

uint32 GameObject::m_respawnDelayTime
protected

Definition at line 864 of file GameObject.h.

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

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