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

#include <Object.h>

+ Inheritance diagram for WorldObject:

Public Member Functions

 ~WorldObject () override
 
virtual void Update (uint32)
 
void _Create (uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
 
virtual void RemoveFromWorld () override
 
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
 
virtual void SetPhaseMask (uint32 newPhaseMask, bool update)
 
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)
 
virtual const char * GetNameForLocaleIdx (int32) const
 
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 CleanupsBeforeDelete ()
 
virtual void SendMessageToSet (WorldPacket *data, bool self)
 
virtual void SendMessageToSetInRange (WorldPacket *data, float dist, bool self)
 
virtual uint8 getLevelForTarget (WorldObject const *) const
 
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)
 
virtual void SaveRespawnTime ()
 
void AddObjectToRemoveList ()
 
virtual bool isValid () const
 
virtual bool IsNeverVisible () const
 
virtual bool IsAlwaysVisibleFor (WorldObject const *) const
 
virtual bool IsInvisibleDueToDespawn () const
 
virtual bool IsAlwaysDetectableFor (WorldObject const *) const
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
float GetSightRange (const WorldObject *target=NULL) const
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
void SendPlaySound (uint32 Sound, bool OnlySelf)
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
Map const * GetBaseMap () const
 
void SetZoneScript ()
 
TempSummonSummonCreature (uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
 
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
 
CreatureSummonTrigger (float x, float y, float z, float ang, uint32 dur, CreatureAI *(*GetAI)(Creature *)=NULL)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=NULL)
 
CreatureFindNearestCreature (uint32 entry, float range, bool alive=true)
 
GameObjectFindNearestGameObject (uint32 entry, float range)
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &gameobjectList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &creatureList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
 
void DestroyForNearbyPlayers ()
 
virtual void UpdateObjectVisibility (bool forced=true)
 
virtual void UpdateObjectVisibilityOnCreate ()
 
void BuildUpdate (UpdateDataMapType &) override
 
void AddToNotify (uint16 f)
 
bool isNeedNotify (uint16 f) const
 
uint16 GetNotifyFlags () const
 
bool NotifyExecuted (uint16 f) const
 
void SetNotified (uint16 f)
 
void ResetAllNotifies ()
 
bool isActiveObject () const
 
void setActive (bool isActiveObject)
 
void SetWorldObject (bool apply)
 
bool IsPermanentWorldObject () const
 
bool IsWorldObject () const
 
template<class NOTIFIER >
void VisitNearbyWorldObject (const float &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyObject (float const &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyGridObject (float const &radius, NOTIFIER &notifier) const
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
const bool & IsInWorld () const
 
virtual void AddToWorld ()
 
const uint64GetGUID () const
 
uint32 GetGUIDLow () const
 
uint32 GetGUIDMid () const
 
uint32 GetGUIDHigh () const
 
PackedGuid const & GetPackGUID () const
 
ObjectGuid const & GetObjectGUID () const
 
std::string GetGuidStr () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
void SetObjectScale (float scale)
 
uint8 GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
 
void BuildMovementUpdateBlock (UpdateData *data, uint32 flags=0) const
 
virtual void DestroyForPlayer (Player *target, bool onDeath=false) const
 
const int32GetInt32Value (uint16 index) const
 
const uint32GetUInt32Value (uint16 index) const
 
const uint64GetUInt64Value (uint16 index) const
 
const float & GetFloatValue (uint16 index) const
 
uint8 GetByteValue (uint16 index, uint8 offset) const
 
ObjectGuid const & GetGuidValue (uint16 index) const
 
uint16 GetUInt16Value (uint16 index, uint8 offset) const
 
void SetInt32Value (uint16 index, int32 value)
 
void SetUInt32Value (uint16 index, uint32 value)
 
void SetUInt64Value (uint16 index, const uint64 &value)
 
void SetFloatValue (uint16 index, float value)
 
void SetByteValue (uint16 index, uint8 offset, uint8 value)
 
void SetUInt16Value (uint16 index, uint8 offset, uint16 value)
 
void SetInt16Value (uint16 index, uint8 offset, int16 value)
 
void SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddUInt64Value (uint16 index, const uint64 &value)
 
bool RemoveUInt64Value (uint16 index, const uint64 &value)
 
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModUInt64Value (uint16 index, int32 val, bool apply)
 
void ApplyModPositiveFloatValue (uint16 index, float val, bool apply)
 
void ApplyModSignedFloatValue (uint16 index, float val, bool apply)
 
void ApplyPercentModFloatValue (uint16 index, float val, bool apply)
 
void SetFlag (uint16 index, uint32 newFlag)
 
void RemoveFlag (uint16 index, uint32 oldFlag)
 
void ToggleFlag (uint16 index, uint32 flag)
 
bool HasFlag (uint16 index, uint32 flag) const
 
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void ToggleFlag (uint16 index, uint8 offset, uint8 flag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetFlag64 (uint16 index, uint64 newFlag)
 
void RemoveFlag64 (uint16 index, uint64 oldFlag)
 
void ToggleFlag64 (uint16 index, uint64 flag)
 
bool HasFlag64 (uint16 index, uint64 flag) const
 
void ApplyModFlag64 (uint16 index, uint64 flag, bool apply)
 
void ClearUpdateMask (bool remove)
 
bool LoadValues (const char *data)
 
uint16 GetValuesCount () const
 
virtual bool hasQuest (uint32) const
 
virtual bool hasInvolvedQuest (uint32) 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
 

Static Public Member Functions

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

Public Attributes

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

 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

std::string m_name
 
bool m_isActive
 
const bool m_isWorldObject
 
ZoneScriptm_zoneScript
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
uint8 m_objectTypeId
 
uint8 m_updateFlag
 
union {
   int32 *   m_int32Values
 
   uint32 *   m_uint32Values
 
   float *   m_floatValues
 
}; 
 
uint32m_uint32Values_mirror
 
uint16 m_valuesCount
 
bool m_objectUpdated
 

Private Member Functions

bool CanNeverSee (WorldObject const *obj) const
 
virtual bool CanAlwaysSee (WorldObject const *) const
 
bool CanDetect (WorldObject const *obj, bool ignoreStealth, bool checkAlert=false) const
 
bool CanDetectInvisibilityOf (WorldObject const *obj) const
 
bool CanDetectStealthOf (WorldObject const *obj, bool checkAlert=false) const
 

Private Attributes

Mapm_currMap
 
uint32 m_InstanceId
 
uint32 m_phaseMask
 
uint16 m_notifyflags
 
uint16 m_executed_notifies
 

Detailed Description

Definition at line 634 of file Object.h.

Constructor & Destructor Documentation

WorldObject::~WorldObject ( )
override

Definition at line 81 of file Object.cpp.

References ASSERT, Object::GetEntry(), Object::GetGUID(), Object::GetTypeId(), sLog, TYPEID_CORPSE, and UI64FMTD.

82 {
83  // this may happen because there are many !create/delete
84  if (IsWorldObject() && m_currMap)
85  {
86  if (GetTypeId() == TYPEID_CORPSE)
87  {
88  sLog.outError("Crash alert! Object::~Object Corpse guid=" UI64FMTD ", type=%d, entry=%u deleted but still in map!!", GetGUID(), ((Corpse*)this)->GetType(), GetEntry());
89  ASSERT(false);
90  }
91  ResetMap();
92  }
93 }
virtual void ResetMap()
Definition: Object.cpp:1972
Definition: Corpse.h:48
Map * m_currMap
Definition: Object.h:949
#define sLog
Log class singleton.
Definition: Log.h:187
bool IsWorldObject() const
Definition: Object.cpp:1112
uint8 GetTypeId() const
Definition: Object.h:210
#define UI64FMTD
Definition: Common.h:149
#define ASSERT
Definition: Errors.h:29
uint32 GetEntry() const
Definition: Object.h:192
const uint64 & GetGUID() const
Definition: Object.h:162
WorldObject::WorldObject ( bool  isWorldObject)
explicitprotected

Definition at line 1087 of file Object.cpp.

References GHOST_VISIBILITY_ALIVE, GHOST_VISIBILITY_GHOST, m_serverSideVisibility, m_serverSideVisibilityDetect, SERVERSIDE_VISIBILITY_GHOST, and FlaggedValuesArray32< T_VALUES, T_FLAGS, FLAG_TYPE, ARRAY_SIZE >::SetValue().

1087  :
1088  WorldLocation()
1089  , m_groupLootTimer(0)
1091  , m_isWorldObject(isWorldObject)
1092  , m_name("")
1093  , m_isActive(false)
1094  , m_zoneScript(NULL)
1095  , m_currMap(NULL)
1096  , m_InstanceId(0)
1099 {
1102 }
const bool m_isWorldObject
Definition: Object.h:933
Map * m_currMap
Definition: Object.h:949
std::string m_name
Definition: Object.h:931
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:833
uint64 lootingGroupLeaderGUID
Definition: Object.h:925
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:626
uint32 m_InstanceId
Definition: Object.h:952
uint16 m_notifyflags
Definition: Object.h:955
ZoneScript * m_zoneScript
Definition: Object.h:934
bool m_isActive
Definition: Object.h:932
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:834
uint32 m_phaseMask
Definition: Object.h:953
uint32 m_groupLootTimer
Definition: Object.h:924
uint16 m_executed_notifies
Definition: Object.h:956
WorldLocation(uint32 _mapid=MAPID_INVALID, float _x=0, float _y=0, float _z=0, float _o=0)
Definition: Object.h:576

Member Function Documentation

void WorldObject::_Create ( uint32  guidlow,
HighGuid  guidhigh,
uint32  phaseMask 
)

Definition at line 1162 of file Object.cpp.

References Object::_Create(), and m_phaseMask.

Referenced by Corpse::Create(), DynamicObject::CreateDynamicObject(), and Corpse::LoadCorpseFromDB().

1163 {
1164  Object::_Create(guidlow, 0, guidhigh);
1165 
1166  m_phaseMask = phaseMask;
1167 }
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:125
uint32 m_phaseMask
Definition: Object.h:953
bool WorldObject::_IsWithinDist ( WorldObject const *  obj,
float  dist2compare,
bool  is3D 
) const

Definition at line 1213 of file Object.cpp.

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

1214 {
1215  float dx = GetPositionX() - obj->GetPositionX();
1216  float dy = GetPositionY() - obj->GetPositionY();
1217  float distsq = dx * dx + dy * dy;
1218  if (is3D)
1219  {
1220  float dz = GetPositionZ() - obj->GetPositionZ();
1221  distsq += dz * dz;
1222  }
1223  float sizefactor = GetObjectSize() + obj->GetObjectSize();
1224  float maxdist = dist2compare + sizefactor;
1225 
1226  return distsq < maxdist * maxdist;
1227 }
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
float GetPositionX() const
Definition: Position.h:97
float GetObjectSize() const
Definition: Object.h:669
void WorldObject::AddObjectToRemoveList ( )

Definition at line 1990 of file Object.cpp.

References Map::AddObjectToRemoveList(), ASSERT, FindMap(), Object::GetEntry(), Object::GetGUIDLow(), WorldLocation::GetMapId(), Object::GetTypeId(), Object::m_uint32Values, and sLog.

Referenced by OPvPCapturePoint::DelCreature(), Battleground::DelCreature(), GameObject::Delete(), Corpse::DeleteBonesFromWorld(), CinematicMgr::EndCinematic(), ChatHandler::HandleNpcDeleteCommand(), ChatHandler::HandleWpModifyCommand(), ChatHandler::HandleWpShowCommand(), DynamicObject::Remove(), Player::RemovePet(), Totem::UnSummon(), and TempSummon::UnSummon().

1991 {
1993 
1994  Map* map = FindMap();
1995  if (!map)
1996  {
1997  sLog.outError("Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list has invalid map (Id: %u).", GetTypeId(), GetEntry(), GetGUIDLow(), GetMapId());
1998  return;
1999  }
2000 
2001  map->AddObjectToRemoveList(this);
2002 }
uint32 * m_uint32Values
Definition: Object.h:432
#define sLog
Log class singleton.
Definition: Log.h:187
void AddObjectToRemoveList(WorldObject *obj)
Definition: Map.cpp:2035
uint32 GetGUIDLow() const
Definition: Object.h:166
uint8 GetTypeId() const
Definition: Object.h:210
Map * FindMap() const
Definition: Object.h:842
uint32 GetMapId() const
Definition: Object.h:591
Definition: Map.h:266
#define ASSERT
Definition: Errors.h:29
uint32 GetEntry() const
Definition: Object.h:192
void WorldObject::AddToNotify ( uint16  f)
inline

Definition at line 885 of file Object.h.

Referenced by Player::UpdateObjectVisibility().

886  {
887  m_notifyflags |= f;
888  }
uint16 m_notifyflags
Definition: Object.h:955
void WorldObject::BuildMonsterChat ( WorldPacket data,
uint8  msgtype,
char const *  text,
uint32  language,
char const *  name,
uint64  TargetGuid 
) const

Definition at line 1907 of file Object.cpp.

References Object::GetGUID(), and IS_PLAYER_GUID.

Referenced by MonsterSay(), MonsterTextEmote(), MonsterWhisper(), MonsterYell(), and Battleground::YellToAll().

1908 {
1909  *data << (uint8)msgtype;
1910  *data << (uint32)language;
1911  *data << (uint64)GetGUID();
1912  *data << (uint32)0; //2.1.0
1913  *data << (uint32)(strlen(name) + 1);
1914  *data << name;
1915  *data << (uint64)targetGuid; //Unit Target
1916  if (targetGuid && !IS_PLAYER_GUID(targetGuid))
1917  {
1918  *data << (uint32)1; // target name length
1919  *data << (uint8)0; // target name
1920  }
1921  *data << (uint32)(strlen(text) + 1);
1922  *data << text;
1923  *data << (uint8)0; // ChatTag
1924 }
#define IS_PLAYER_GUID(Guid)
Definition: ObjectGuid.h:69
ACE_UINT8 uint8
Definition: Define.h:73
ACE_UINT64 uint64
Definition: Define.h:70
ACE_UINT32 uint32
Definition: Define.h:71
const uint64 & GetGUID() const
Definition: Object.h:162
void WorldObject::BuildUpdate ( UpdateDataMapType data_map)
overridevirtual

Reimplemented from Object.

Definition at line 2665 of file Object.cpp.

References Object::ClearUpdateMask(), Oregon::ComputeCellCoord(), GetMap(), Position::GetPositionX(), Position::GetPositionY(), GetVisibilityRange(), Cell::SetNoCreate(), and Cell::Visit().

2666 {
2668  Cell cell(p);
2669  cell.SetNoCreate();
2670  WorldObjectChangeAccumulator notifier(*this, data_map);
2672  Map& map = *GetMap();
2673  //we must build packets for all visible players
2674  cell.Visit(p, player_notifier, map, *this, GetVisibilityRange());
2675 
2676  ClearUpdateMask(false);
2677 }
void ClearUpdateMask(bool remove)
Definition: Object.cpp:678
Map * GetMap() const
Definition: Object.h:841
float GetVisibilityRange() const
Definition: Object.cpp:1552
float GetPositionY() const
Definition: Position.h:98
Definition: Map.h:266
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
float GetPositionX() const
Definition: Position.h:97
virtual bool WorldObject::CanAlwaysSee ( WorldObject const *  ) const
inlineprivatevirtual

Reimplemented in Player, and Creature.

Definition at line 959 of file Object.h.

Referenced by CanSeeOrDetect().

959 { return false; }
bool WorldObject::CanDetect ( WorldObject const *  obj,
bool  ignoreStealth,
bool  checkAlert = false 
) const
private

Definition at line 1668 of file Object.cpp.

References CanDetectInvisibilityOf(), CanDetectStealthOf(), Unit::GetCharmerOrOwner(), IsAlwaysDetectableFor(), and Object::ToUnit().

Referenced by CanSeeOrDetect().

1669 {
1670  const WorldObject* seer = this;
1671 
1672  // Pets don't have detection, they use the detection of their masters
1673  if (const Unit* thisUnit = ToUnit())
1674  if (Unit* controller = thisUnit->GetCharmerOrOwner())
1675  seer = controller;
1676 
1677  if (obj->IsAlwaysDetectableFor(seer))
1678  return true;
1679 
1680  if (!ignoreStealth && !seer->CanDetectInvisibilityOf(obj))
1681  return false;
1682 
1683  if (!ignoreStealth && !seer->CanDetectStealthOf(obj, checkAlert))
1684  return false;
1685 
1686  return true;
1687 }
bool CanDetectStealthOf(WorldObject const *obj, bool checkAlert=false) const
Definition: Object.cpp:1720
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1410
Definition: Unit.h:908
bool CanDetectInvisibilityOf(WorldObject const *obj) const
Definition: Object.cpp:1689
Unit * ToUnit()
Definition: Object.h:398
bool WorldObject::CanDetectInvisibilityOf ( WorldObject const *  obj) const
private

Definition at line 1689 of file Object.cpp.

References FlaggedValuesArray32< T_VALUES, T_FLAGS, FLAG_TYPE, ARRAY_SIZE >::GetFlags(), FlaggedValuesArray32< T_VALUES, T_FLAGS, FLAG_TYPE, ARRAY_SIZE >::GetValue(), m_invisibility, m_invisibilityDetect, TOTAL_INVISIBILITY_TYPES, and Object::ToUnit().

Referenced by CanDetect().

1690 {
1691  uint32 mask = obj->m_invisibility.GetFlags() & m_invisibilityDetect.GetFlags();
1692 
1693  // Check for not detected types
1694  if (mask != obj->m_invisibility.GetFlags())
1695  return false;
1696 
1697  // It isn't possible in invisibility to detect something that can't detect the invisible object
1698  // (it's at least true for spell: 66)
1699  // It seems like that only Units are affected by this check (couldn't see arena doors with preparation invisibility)
1700  if (obj->ToUnit())
1701  if ((m_invisibility.GetFlags() & obj->m_invisibilityDetect.GetFlags()) != m_invisibility.GetFlags())
1702  return false;
1703 
1704  for (uint32 i = 0; i < TOTAL_INVISIBILITY_TYPES; ++i)
1705  {
1706  if (!(mask & (1 << i)))
1707  continue;
1708 
1709  int32 objInvisibilityValue = obj->m_invisibility.GetValue(InvisibilityType(i));
1710  int32 ownInvisibilityDetectValue = m_invisibilityDetect.GetValue(InvisibilityType(i));
1711 
1712  // Too low value to detect
1713  if (ownInvisibilityDetectValue < objInvisibilityValue)
1714  return false;
1715  }
1716 
1717  return true;
1718 }
T_FLAGS GetFlags() const
Definition: Object.h:620
ACE_INT32 int32
Definition: Define.h:67
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibilityDetect
Definition: Object.h:831
InvisibilityType
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibility
Definition: Object.h:830
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:625
ACE_UINT32 uint32
Definition: Define.h:71
bool WorldObject::CanDetectStealthOf ( WorldObject const *  obj,
bool  checkAlert = false 
) const
private

Definition at line 1720 of file Object.cpp.

References Creature::GetAttackDistance(), Unit::GetCombatReach(), Position::GetExactDist(), FlaggedValuesArray32< T_VALUES, T_FLAGS, FLAG_TYPE, ARRAY_SIZE >::GetFlags(), getLevelForTarget(), GameObject::GetOwner(), Object::GetTypeId(), FlaggedValuesArray32< T_VALUES, T_FLAGS, FLAG_TYPE, ARRAY_SIZE >::GetValue(), Unit::HasAuraTypeWithMiscvalue(), HasInArc(), Creature::m_CombatDistance, m_stealth, m_stealthDetect, MAX_PLAYER_STEALTH_DETECT_RANGE, SPELL_AURA_DETECT_STEALTH, Object::ToCreature(), Object::ToGameObject(), TOTAL_STEALTH_TYPES, Object::ToUnit(), and TYPEID_PLAYER.

Referenced by CanDetect().

1721 {
1722  // Combat reach is the minimal distance (both in front and behind),
1723  // and it is also used in the range calculation.
1724  // One stealth point increases the visibility range by 0.3 yard.
1725 
1726  if (!obj->m_stealth.GetFlags())
1727  return true;
1728 
1729  float distance = GetExactDist(obj);
1730  float combatReach = 0.0f;
1731 
1732  Unit const* unit = ToUnit();
1733  if (unit)
1734  combatReach = unit->GetCombatReach();
1735 
1736  if (distance < combatReach)
1737  return true;
1738 
1739  if (!HasInArc(float(M_PI), obj))
1740  return false;
1741 
1742  GameObject const* go = obj->ToGameObject();
1743  for (uint32 i = 0; i < TOTAL_STEALTH_TYPES; ++i)
1744  {
1745  if (!(obj->m_stealth.GetFlags() & (1 << i)))
1746  continue;
1747 
1749  return true;
1750 
1751  // Starting points
1752  int32 detectionValue = 30;
1753 
1754  // Level difference: 5 point / level, starting from level 1.
1755  // There may be spells for this and the starting points too, but
1756  // not in the DBCs of the client.
1757  detectionValue += int32(getLevelForTarget(obj) - 1) * 5;
1758 
1759  // Apply modifiers
1760  detectionValue += m_stealthDetect.GetValue(StealthType(i));
1761  if (go)
1762  if (Unit* owner = go->GetOwner())
1763  detectionValue -= int32(owner->getLevelForTarget(this) - 1) * 5;
1764 
1765  detectionValue -= obj->m_stealth.GetValue(StealthType(i));
1766 
1767  // Calculate max distance
1768  float visibilityRange = float(detectionValue) * 0.3f + combatReach;
1769 
1770  // If this unit is an NPC then player detect range doesn't apply
1771  if (unit && unit->GetTypeId() == TYPEID_PLAYER && visibilityRange > MAX_PLAYER_STEALTH_DETECT_RANGE)
1772  visibilityRange = MAX_PLAYER_STEALTH_DETECT_RANGE;
1773 
1774  // When checking for alert state, look 8% further, and then 1.5 yards more than that.
1775  if (checkAlert)
1776  visibilityRange += (visibilityRange * 0.08f) + 1.5f;
1777 
1778  // If checking for alert, and creature's visibility range is greater than aggro distance, No alert
1779  Unit const* tunit = obj->ToUnit();
1780  if (checkAlert && unit && unit->ToCreature() && visibilityRange >= unit->ToCreature()->GetAttackDistance(tunit) + unit->ToCreature()->m_CombatDistance)
1781  return false;
1782 
1783  if (distance > visibilityRange)
1784  return false;
1785  }
1786 
1787  return true;
1788 }
Unit * GetOwner() const
Definition: GameObject.cpp:783
bool HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const
Definition: Unit.cpp:846
ACE_INT32 int32
Definition: Define.h:67
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPES > m_stealthDetect
Definition: Object.h:828
GameObject * ToGameObject()
Definition: Object.h:401
virtual uint8 getLevelForTarget(WorldObject const *) const
Definition: Object.h:792
float GetCombatReach() const
Definition: Unit.h:978
uint8 GetTypeId() const
Definition: Object.h:210
float GetAttackDistance(Unit const *pl) const
Definition: Creature.cpp:1537
StealthType
#define MAX_PLAYER_STEALTH_DETECT_RANGE
Definition: Unit.h:904
bool HasInArc(float arcangle, const Position *pos) const
Definition: Object.cpp:1393
Creature * ToCreature()
Definition: Object.h:395
float GetExactDist(float x, float y, float z) const
Definition: Position.h:150
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:625
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Unit.h:908
float m_CombatDistance
Definition: Creature.h:789
Unit * ToUnit()
Definition: Object.h:398
bool WorldObject::CanNeverSee ( WorldObject const *  obj) const
private

Definition at line 1663 of file Object.cpp.

References GetMap(), and InSamePhase().

Referenced by CanSeeOrDetect().

1664 {
1665  return GetMap() != obj->GetMap() || !InSamePhase(obj);
1666 }
Map * GetMap() const
Definition: Object.h:841
bool InSamePhase(uint32 phasemask) const
Definition: Object.h:695
bool WorldObject::CanSeeOrDetect ( WorldObject const *  obj,
bool  ignoreStealth = false,
bool  distanceCheck = false,
bool  checkAlert = false 
) const

Definition at line 1585 of file Object.cpp.

References CanAlwaysSee(), CanDetect(), CanNeverSee(), GetSightRange(), FlaggedValuesArray32< T_VALUES, T_FLAGS, FLAG_TYPE, ARRAY_SIZE >::GetValue(), GHOST_VISIBILITY_GHOST, IsAlwaysVisibleFor(), IsInvisibleDueToDespawn(), IsNeverVisible(), IsWithinDist(), m_serverSideVisibility, m_serverSideVisibilityDetect, SERVERSIDE_VISIBILITY_GHOST, SERVERSIDE_VISIBILITY_GM, and Object::ToPlayer().

Referenced by Unit::_IsValidAssistTarget(), Unit::_IsValidAttackTarget(), CreatureUnitRelocationWorker(), Spell::SearchChainTarget(), Creature::SelectVictim(), TotemAI::UpdateAI(), HostileRefManager::UpdateVisibility(), and Player::UpdateVisibilityOf().

1586 {
1587  if (this == obj)
1588  return true;
1589 
1590  if (obj->IsNeverVisible() || CanNeverSee(obj))
1591  return false;
1592 
1593  if (obj->IsAlwaysVisibleFor(this) || CanAlwaysSee(obj))
1594  return true;
1595 
1596  bool corpseVisibility = false;
1597  if (distanceCheck)
1598  {
1599  bool corpseCheck = false;
1600  if (const Player* thisPlayer = ToPlayer())
1601  {
1602  if (thisPlayer->isDead() && thisPlayer->GetHealth() > 0 && // Cheap way to check for ghost state
1604  {
1605  if (Corpse* corpse = thisPlayer->GetCorpse())
1606  {
1607  corpseCheck = true;
1608  if (corpse->IsWithinDist(thisPlayer, GetSightRange(obj), false))
1609  if (corpse->IsWithinDist(obj, GetSightRange(obj), false))
1610  corpseVisibility = true;
1611  }
1612  }
1613  }
1614 
1615  WorldObject const* viewpoint = this;
1616  if (Player const* player = this->ToPlayer())
1617  viewpoint = player->GetViewpoint();
1618 
1619  if (!viewpoint)
1620  viewpoint = this;
1621 
1622  if (!corpseCheck && !viewpoint->IsWithinDist(obj, GetSightRange(obj), false))
1623  return false;
1624  }
1625 
1626  // GM visibility off or hidden NPC
1627  if (!obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM))
1628  {
1629  // Stop checking other things for GMs
1631  return true;
1632  }
1633  else
1634  return m_serverSideVisibilityDetect.GetValue(SERVERSIDE_VISIBILITY_GM) >= obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM);
1635 
1636  // Ghost players, Spirit Healers, and some other NPCs
1637  if (!corpseVisibility && !(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibilityDetect.GetValue(SERVERSIDE_VISIBILITY_GHOST)))
1638  {
1639  // Alive players can see dead players in some cases, but other objects can't do that
1640  if (const Player* thisPlayer = ToPlayer())
1641  {
1642  if (const Player* objPlayer = obj->ToPlayer())
1643  {
1644  if (thisPlayer->GetTeam() != objPlayer->GetTeam() || !thisPlayer->IsGroupVisibleFor(objPlayer))
1645  return false;
1646  }
1647  else
1648  return false;
1649  }
1650  else
1651  return false;
1652  }
1653 
1654  if (obj->IsInvisibleDueToDespawn())
1655  return false;
1656 
1657  if (!CanDetect(obj, ignoreStealth, checkAlert))
1658  return false;
1659 
1660  return true;
1661 }
Definition: Corpse.h:48
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:833
bool CanNeverSee(WorldObject const *obj) const
Definition: Object.cpp:1663
Player * ToPlayer()
Definition: Object.h:392
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.h:770
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:834
bool CanDetect(WorldObject const *obj, bool ignoreStealth, bool checkAlert=false) const
Definition: Object.cpp:1668
virtual bool CanAlwaysSee(WorldObject const *) const
Definition: Object.h:959
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:625
Definition: Player.h:922
float GetSightRange(const WorldObject *target=NULL) const
Definition: Object.cpp:1560
void WorldObject::CleanupsBeforeDelete ( )
virtual

Reimplemented in Player, Unit, and GameObject.

Definition at line 1156 of file Object.cpp.

References Object::IsInWorld(), and RemoveFromWorld().

Referenced by Map::AddObjectToRemoveList().

1157 {
1158  if (IsInWorld())
1159  RemoveFromWorld();
1160 }
const bool & IsInWorld() const
Definition: Object.h:135
virtual void RemoveFromWorld() override
Definition: Object.cpp:1169
void WorldObject::DestroyForNearbyPlayers ( )

Definition at line 2565 of file Object.cpp.

References Object::DestroyForPlayer(), Object::GetGUID(), Object::GetTypeId(), GetVisibilityRange(), Player::HaveAtClient(), Object::IsInWorld(), Object::isType(), Player::m_clientGUIDs, Object::ToCreature(), Object::ToUnit(), TYPEID_UNIT, TYPEMASK_UNIT, and VisitNearbyWorldObject().

Referenced by SummonList::DespawnAll(), Creature::DisappearAndDie(), Spell::EffectDummy(), ChatHandler::HandleMoveObjectCommand(), ChatHandler::HandleTurnObjectCommand(), ObjectAccessor::RemoveCorpse(), RemoveFromWorld(), and Creature::Respawn().

2566 {
2567  if (!IsInWorld())
2568  return;
2569 
2570  std::list<Player*> targets;
2574  for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
2575  {
2576  Player* player = (*iter);
2577 
2578  if (player == this)
2579  continue;
2580 
2581  if (!player->HaveAtClient(this))
2582  continue;
2583 
2584  if (isType(TYPEMASK_UNIT) && ((Unit*)this)->GetCharmerGUID() == player->GetGUID()) // @todo this is for puppet
2585  continue;
2586 
2587  if (GetTypeId() == TYPEID_UNIT)
2588  {
2589  // at remove from world (destroy) show kill animation
2590  DestroyForPlayer(player, ToUnit()->IsDuringRemoveFromWorld() && ToCreature()->isDead());
2591  }
2592  else
2593  DestroyForPlayer(player);
2594 
2595  player->m_clientGUIDs.erase(GetGUID());
2596  }
2597 }
ClientGUIDs m_clientGUIDs
Definition: Player.h:2459
bool isType(uint16 mask) const
Definition: Object.h:214
float GetVisibilityRange() const
Definition: Object.cpp:1552
uint8 GetTypeId() const
Definition: Object.h:210
virtual void DestroyForPlayer(Player *target, bool onDeath=false) const
Definition: Object.cpp:241
const bool & IsInWorld() const
Definition: Object.h:135
bool HaveAtClient(WorldObject const *u) const
Definition: Player.cpp:18687
Creature * ToCreature()
Definition: Object.h:395
Definition: Unit.h:908
Definition: Player.h:922
Unit * ToUnit()
Definition: Object.h:398
void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const
Definition: Object.h:920
const uint64 & GetGUID() const
Definition: Object.h:162
Creature * WorldObject::FindNearestCreature ( uint32  entry,
float  range,
bool  alive = true 
)

Definition at line 2292 of file Object.cpp.

References VisitNearbyObject().

Referenced by Spell::EffectDummy(), GetClosestCreatureWithEntry(), Spell::SearchNearbyTarget(), Aura::TriggerSpell(), and SmartAI::UpdateAI().

2293 {
2294  Creature* creature = NULL;
2295  Oregon::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range);
2297  VisitNearbyObject(range, searcher);
2298  return creature;
2299 }
void VisitNearbyObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:921
GameObject * WorldObject::FindNearestGameObject ( uint32  entry,
float  range 
)

Definition at line 2301 of file Object.cpp.

References VisitNearbyGridObject().

Referenced by GetClosestGameObjectWithEntry(), and Spell::SearchNearbyTarget().

2302 {
2303  GameObject* go = NULL;
2304  Oregon::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range);
2306  VisitNearbyGridObject(range, searcher);
2307  return go;
2308 }
void VisitNearbyGridObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:922
GameObject * WorldObject::FindNearestGameObjectOfType ( GameobjectTypes  type,
float  range 
) const

Definition at line 2310 of file Object.cpp.

References VisitNearbyGridObject().

2311 {
2312  GameObject* go = NULL;
2313  Oregon::NearestGameObjectTypeInObjectRangeCheck checker(*this, type, range);
2315  VisitNearbyGridObject(range, searcher);
2316  return go;
2317 }
void VisitNearbyGridObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:922
void WorldObject::GetClosePoint ( float &  x,
float &  y,
float &  z,
float  size,
float  distance2d = 0,
float  angle = 0 
) const
inline

Definition at line 646 of file Object.h.

Referenced by Spell::EffectDummy(), Spell::EffectSummonDeadPet(), Spell::EffectSummonFriend(), Spell::EffectSummonObject(), Spell::EffectSummonObjectWild(), Spell::EffectSummonPet(), Spell::EffectTeleUnitsFaceCaster(), Spell::EffectTransmitted(), Spell::GetSummonPosition(), ChatHandler::HandleCastDistCommand(), ChatHandler::HandleGroupSummonCommand(), ChatHandler::HandleSummonCommand(), Pet::LoadPetFromDB(), Spell::SetTargetMap(), and Spell::SummonClassPet().

647  {
648  // angle calculated from current orientation
649  GetNearPoint(NULL, x, y, z, size, distance2d, GetOrientation() + angle);
650  }
float GetOrientation() const
Definition: Position.h:100
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
Definition: Object.cpp:2354
void WorldObject::GetContactPoint ( const WorldObject obj,
float &  x,
float &  y,
float &  z,
float  distance2d = CONTACT_DISTANCE 
) const
inline

Definition at line 658 of file Object.h.

References GetObjectSize().

Referenced by Spell::EffectCharge(), and Spell::SetTargetMap().

659  {
660  // angle to face `obj` to `this` using distance includes size of `obj`
661  GetNearPoint(obj, x, y, z, obj->GetObjectSize(), distance2d, GetAngle(obj));
662  }
float GetAngle(Position const *pos) const
float GetObjectSize() const
Definition: Object.h:669
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
Definition: Object.cpp:2354
void WorldObject::GetCreatureListWithEntryInGrid ( std::list< Creature * > &  creatureList,
uint32  entry = GRID_SEARCH_ALL_ENTRIES,
float  maxSearchRange = 250.0f 
) const

Definition at line 2332 of file Object.cpp.

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

Referenced by GetCreatureListWithEntryInGrid().

2333 {
2335  Cell cell(pair);
2336  cell.SetNoCreate();
2337 
2338  Oregon::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange);
2339  Oregon::CreatureListSearcher<Oregon::AllCreaturesOfEntryInRange> searcher(this, creatureList, check);
2341 
2342  cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
2343 }
Map * GetMap() const
Definition: Object.h:841
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
float GetPositionX() const
Definition: Position.h:97
float WorldObject::GetDistance ( const Position pos) const
inline

Definition at line 723 of file Object.h.

724  {
725  float d = GetExactDist(&pos) - GetObjectSize();
726  return d > 0.0f ? d : 0.0f;
727  }
float GetExactDist(float x, float y, float z) const
Definition: Position.h:150
float GetObjectSize() const
Definition: Object.h:669
float WorldObject::GetDistance ( float  x,
float  y,
float  z 
) const
inline

Definition at line 728 of file Object.h.

729  {
730  float d = GetExactDist(x, y, z) - GetObjectSize();
731  return d > 0.0f ? d : 0.0f;
732  }
float GetExactDist(float x, float y, float z) const
Definition: Position.h:150
float GetObjectSize() const
Definition: Object.h:669
float WorldObject::GetDistance2d ( const WorldObject obj) const
inline

Definition at line 733 of file Object.h.

References GetObjectSize().

Referenced by Spell::EffectPlayerPull(), ScriptedAI::EnterEvadeIfOutOfCombatArea(), ChatHandler::HandleGetDistanceCommand(), WorldSession::HandleInitiateTradeOpcode(), WorldSession::HandleLootMoneyOpcode(), Group::MasterLoot(), Group::NeedBeforeGreed(), Spell::SpellDamageSchoolDmg(), and GameObject::Use().

734  {
735  float d = GetExactDist2d(obj) - GetObjectSize() - obj->GetObjectSize();
736  return d > 0.0f ? d : 0.0f;
737  }
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:130
float GetObjectSize() const
Definition: Object.h:669
float WorldObject::GetDistance2d ( float  x,
float  y 
) const
inline

Definition at line 738 of file Object.h.

739  {
740  float d = GetExactDist2d(x, y) - GetObjectSize();
741  return d > 0.0f ? d : 0.0f;
742  }
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:130
float GetObjectSize() const
Definition: Object.h:669
bool WorldObject::GetDistanceOrder ( WorldObject const *  obj1,
WorldObject const *  obj2,
bool  is3D = true 
) const

Definition at line 1276 of file Object.cpp.

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

1277 {
1278  float dx1 = GetPositionX() - obj1->GetPositionX();
1279  float dy1 = GetPositionY() - obj1->GetPositionY();
1280  float distsq1 = dx1 * dx1 + dy1 * dy1;
1281  if (is3D)
1282  {
1283  float dz1 = GetPositionZ() - obj1->GetPositionZ();
1284  distsq1 += dz1 * dz1;
1285  }
1286 
1287  float dx2 = GetPositionX() - obj2->GetPositionX();
1288  float dy2 = GetPositionY() - obj2->GetPositionY();
1289  float distsq2 = dx2 * dx2 + dy2 * dy2;
1290  if (is3D)
1291  {
1292  float dz2 = GetPositionZ() - obj2->GetPositionZ();
1293  distsq2 += dz2 * dz2;
1294  }
1295 
1296  return distsq1 < distsq2;
1297 }
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
float GetPositionX() const
Definition: Position.h:97
float WorldObject::GetDistanceSqr ( float  x,
float  y,
float  z 
) const

Definition at line 1203 of file Object.cpp.

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

1204 {
1205  float dx = GetPositionX() - x;
1206  float dy = GetPositionY() - y;
1207  float dz = GetPositionZ() - z;
1208  float sizefactor = GetObjectSize();
1209  float dist = dx * dx + dy * dy + dz * dz - sizefactor;
1210  return (dist > 0 ? dist : 0);
1211 }
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
float GetPositionX() const
Definition: Position.h:97
float GetObjectSize() const
Definition: Object.h:669
float WorldObject::GetDistanceZ ( const WorldObject obj) const

Definition at line 1195 of file Object.cpp.

References GetObjectSize(), and Position::GetPositionZ().

Referenced by Creature::canStartAttack(), FollowerAI::MoveInLineOfSight(), and npc_escortAI::MoveInLineOfSight().

1196 {
1197  float dz = fabs(GetPositionZ() - obj->GetPositionZ());
1198  float sizefactor = GetObjectSize() + obj->GetObjectSize();
1199  float dist = dz - sizefactor;
1200  return (dist > 0 ? dist : 0);
1201 }
float GetPositionZ() const
Definition: Position.h:99
float GetObjectSize() const
Definition: Object.h:669
Position WorldObject::GetFirstCollisionPosition ( float  dist,
float  angle 
)

Definition at line 2368 of file Object.cpp.

References Position::GetPosition(), and MovePositionToFirstCollision().

Referenced by Spell::EffectMomentMove(), and Spell::SetTargetMap().

2369 {
2370  Position pos = GetPosition();
2371  MovePositionToFirstCollision(pos, dist, angle);
2372  return pos;
2373 }
Position GetPosition() const
Definition: Position.h:117
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition: Object.cpp:2474
void WorldObject::GetGameObjectListWithEntryInGrid ( std::list< GameObject * > &  gameobjectList,
uint32  entry = GRID_SEARCH_ALL_ENTRIES,
float  maxSearchRange = 250.0f 
) const

Definition at line 2319 of file Object.cpp.

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

Referenced by GetGameObjectListWithEntryInGrid().

2320 {
2322  Cell cell(pair);
2323  cell.SetNoCreate();
2324 
2325  Oregon::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
2326  Oregon::GameObjectListSearcher<Oregon::AllGameObjectsWithEntryInRange> searcher(this, gameobjectList, check);
2328 
2329  cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
2330 }
Map * GetMap() const
Definition: Object.h:841
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
float GetPositionX() const
Definition: Position.h:97
float WorldObject::GetGridActivationRange ( ) const

Definition at line 1531 of file Object.cpp.

References DEFAULT_VISIBILITY_INSTANCE, GetMap(), Map::GetVisibilityRange(), isActiveObject(), Creature::m_SightDistance, Object::ToCreature(), Object::ToDynObject(), and Object::ToPlayer().

Referenced by Map::_FindGameObject(), SmartScript::FindCreatureNear(), SmartScript::FindGameObjectNear(), ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(), ChatHandler::HandleRespawnCommand(), Map::ScriptsProcess(), and Map::VisitNearbyCellsOf().

1532 {
1533  if (ToPlayer())
1534  {
1535  if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
1537  return GetMap()->GetVisibilityRange();
1538  }
1539  else if (ToCreature())
1540  return ToCreature()->m_SightDistance;
1541  else if (ToDynObject())
1542  {
1543  if (isActiveObject())
1544  return GetMap()->GetVisibilityRange();
1545  else
1546  return 0.0f;
1547  }
1548  else
1549  return 0.0f;
1550 }
Map * GetMap() const
Definition: Object.h:841
#define DEFAULT_VISIBILITY_INSTANCE
Definition: Object.h:41
DynamicObject * ToDynObject()
Definition: Object.h:407
Player * ToPlayer()
Definition: Object.h:392
bool isActiveObject() const
Definition: Object.h:911
float GetVisibilityRange() const
Definition: Map.h:291
Creature * ToCreature()
Definition: Object.h:395
float m_SightDistance
Definition: Creature.h:789
Position WorldObject::GetHitSpherePointFor ( Position const &  dest) const

Definition at line 1259 of file Object.cpp.

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

Referenced by GetHitSpherePointFor(), IsWithinLOS(), and IsWithinLOSInMap().

1260 {
1261  G3D::Vector3 vThis(GetPositionX(), GetPositionY(), GetPositionZ());
1262  G3D::Vector3 vObj(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
1263  G3D::Vector3 contactPoint = vThis + (vObj - vThis).directionOrZero() * GetObjectSize();
1264 
1265  return Position(contactPoint.x, contactPoint.y, contactPoint.z, GetAngle(contactPoint.x, contactPoint.y));
1266 }
float GetPositionY() const
Definition: Position.h:98
Position(float x=0, float y=0, float z=0, float o=0)
Definition: Position.h:27
float GetPositionZ() const
Definition: Position.h:99
float GetAngle(Position const *pos) const
float GetPositionX() const
Definition: Position.h:97
float GetObjectSize() const
Definition: Object.h:669
void WorldObject::GetHitSpherePointFor ( Position const &  dest,
float &  x,
float &  y,
float &  z 
) const

Definition at line 1268 of file Object.cpp.

References GetHitSpherePointFor(), Position::GetPositionX(), Position::GetPositionY(), and Position::GetPositionZ().

1269 {
1270  Position pos = GetHitSpherePointFor(dest);
1271  x = pos.GetPositionX();
1272  y = pos.GetPositionY();
1273  z = pos.GetPositionZ();
1274 }
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1259
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
float GetPositionX() const
Definition: Position.h:97
InstanceData * WorldObject::GetInstanceData ( )

Definition at line 1189 of file Object.cpp.

References GetMap(), and Map::IsDungeon().

Referenced by Spell::EffectDummy(), ChatHandler::HandleGetInstanceDataCommand(), ChatHandler::HandleSetInstanceDataCommand(), SmartScript::ProcessAction(), and CreatureEventAI::ProcessAction().

1190 {
1191  Map* map = GetMap();
1192  return map->IsDungeon() ? ((InstanceMap*)map)->GetInstanceData() : NULL;
1193 }
Map * GetMap() const
Definition: Object.h:841
bool IsDungeon() const
Definition: Map.h:427
Definition: Map.h:266
virtual uint8 WorldObject::getLevelForTarget ( WorldObject const *  ) const
inlinevirtual

Reimplemented in Unit, and GameObject.

Definition at line 792 of file Object.h.

Referenced by CanDetectStealthOf().

792 { return 1; }
Map* WorldObject::GetMap ( ) const
inline

Definition at line 841 of file Object.h.

References ASSERT.

Referenced by Map::_FindGameObject(), Spell::AddGOTarget(), Map::AddPlayerToMap(), Player::AddQuest(), GameObject::AddToWorld(), CinematicMgr::BeginCinematic(), Player::BuildPlayerRepop(), PathInfo::BuildPolyPath(), BuildUpdate(), Creature::CallAssistance(), Creature::CallForHelp(), Creature::CanCreatureAttack(), CanNeverSee(), Spell::CheckCast(), Player::CheckDuelDistance(), Transport::CheckForEvent(), Spell::CheckItems(), Corpse::Create(), Pet::CreateBaseAtCreature(), Player::CreateCorpse(), DynamicObject::CreateDynamicObject(), CreatureEventAI::CreatureEventAI(), Spell::DoAllEffectOnTarget(), Transport::DoEventIfAny(), FlightPathMovementGenerator::DoEventIfAny(), CreatureEventAI::DoFindFriendlyCC(), CreatureEventAI::DoFindFriendlyMissingBuff(), Creature::DoFleeToGetAssistance(), WorldSession::DoLootRelease(), CreatureEventAI::DoSelectLowestHpFriendly(), ScriptedAI::DoTeleportAll(), CreatureAI::DoZoneInCombat(), CreatureAI::DoZoneInCombatWithPlayers(), Player::DuelComplete(), Spell::EffectActivateObject(), Spell::EffectAddFarsight(), Spell::EffectDestroyAllTotems(), Spell::EffectDuel(), Spell::EffectDummy(), Spell::EffectPersistentAA(), Spell::EffectScriptEffect(), Spell::EffectSendEvent(), Spell::EffectSummonDeadPet(), Spell::EffectSummonObject(), Spell::EffectSummonObjectWild(), Spell::EffectSummonPet(), Spell::EffectSummonType(), Spell::EffectTameCreature(), Spell::EffectTransmitted(), SmartScript::FillScript(), Spell::FillTargetMap(), SmartScript::FindCreatureNear(), SmartScript::FindGameObjectNear(), ObjectAccessor::GetCorpse(), ObjectAccessor::GetCreature(), Unit::GetCreature(), GetCreatureListWithEntryInGrid(), ObjectAccessor::GetDynamicObject(), Unit::GetDynObject(), ObjectAccessor::GetGameObject(), GameObject::GetGameObject(), Player::GetGameObjectIfCanInteractWith(), GetGameObjectListWithEntryInGrid(), GetGridActivationRange(), GetInstanceData(), Creature::GetLinkedCreatureRespawnTime(), PathInfo::getNavTerrain(), Player::GetNextQuest(), Player::GetNPCIfCanInteractWith(), ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(), ObjectAccessor::GetPet(), ObjectAccessor::GetPlayer(), ScriptedAI::GetPlayerAtMinimumRange(), GetPositionZTarget(), Player::GetReferFriendXPMultiplier(), GetSightRange(), ObjectAccessor::GetUnit(), GetVisibilityRange(), ChatHandler::HandleAppearCommand(), WorldSession::HandleAreaSpiritHealerQueryOpcode(), WorldSession::HandleAreaSpiritHealerQueueOpcode(), Aura::HandleAuraDummy(), WorldSession::HandleAutostoreLootItemOpcode(), WorldSession::HandleBattlegroundArenaJoin(), WorldSession::HandleBattlegroundHelloOpcode(), WorldSession::HandleBattlegroundJoinOpcode(), ChatHandler::HandleCreatePetCommand(), OutdoorPvPSI::HandleDropFlag(), WorldSession::HandleDuelAcceptedOpcode(), WorldSession::HandleDungeonDifficultyOpcode(), Aura::HandleFeignDeath(), ChatHandler::HandleGameObjectCommand(), WorldSession::HandleGameObjectUseOpcode(), WorldSession::HandleGossipSelectOptionOpcode(), ChatHandler::HandleGPSCommand(), ChatHandler::HandleGroupSummonCommand(), ChatHandler::HandleInstanceSaveDataCommand(), WorldSession::HandleLootMasterGiveOpcode(), WorldSession::HandleLootMoneyOpcode(), Aura::HandleModPossessPet(), WorldSession::HandleMoveWorldportAckOpcode(), ChatHandler::HandleNpcAddCommand(), ChatHandler::HandleNpcDeleteCommand(), ChatHandler::HandleNpcMoveCommand(), ChatHandler::HandleNpcWhisperCommand(), WorldSession::HandlePlayerLogin(), WorldSession::HandleQuestgiverStatusQueryMultipleOpcode(), ChatHandler::HandleRespawnCommand(), ChatHandler::HandleSummonCommand(), ChatHandler::HandleTargetObjectCommand(), WorldSession::HandleTotemDestroy(), ChatHandler::HandleWpModifyCommand(), ChatHandler::HandleWpShowCommand(), Group::InCombatToInstance(), Creature::InitEntry(), TempSummon::InitStats(), Player::IsAtGroupRewardDistance(), Unit::isAttackingPlayer(), IsInMap(), IsWithinLOS(), Unit::Kill(), Creature::LoadCreatureFromDB(), GameObject::LoadGameObjectFromDB(), Pet::LoadPetFromDB(), WorldSession::LogoutPlayer(), GameObject::LookupFishingHoleAround(), MonsterSay(), MonsterTextEmote(), MonsterYell(), MonsterYellToZone(), MotionMaster::MoveFall(), FollowerAI::MoveInLineOfSight(), npc_escortAI::MoveInLineOfSight(), MovePosition(), MovePositionToFirstCollision(), Player::OnGossipSelect(), Player::PrepareQuestMenu(), GameObject::Refresh(), Unit::RemoveAllDynObjects(), Creature::RemoveCorpse(), Unit::RemoveDynObject(), GameObject::RemoveFromWorld(), Player::ResetMap(), Player::RewardQuest(), ScriptedAI::ScriptedAI(), Map::ScriptsProcess(), Spell::SearchAreaTarget(), Creature::SelectNearestTarget(), Creature::SelectNearestTargetInAttackDistance(), CreatureTextMgr::SendChatPacket(), Player::SendInitialPacketsBeforeAddToMap(), Spell::SendLoot(), Player::SendLoot(), CreatureTextMgr::SendNonChatPacket(), Player::SendPreparedQuest(), Player::SendQuestReward(), WorldSession::SendTaxiStatus(), Player::SetBattlegroundEntryPoint(), Creature::setDeathState(), Creature::SetInCombatWithZone(), Player::SetPosition(), Spell::SetTargetMap(), SetWorldObject(), Spell::SummonClassPet(), SummonGameObject(), Spell::SummonGuardian(), Player::SummonPet(), Player::TeleportTo(), Transport::TeleportTransport(), RegressionTestSuite::TestBreathingIssues(), GameObject::TriggeringLinkedGameObject(), Unit::UnsummonAllTotems(), Transport::Update(), WaypointMovementGenerator< T >::Update(), SpellCastTargets::Update(), Pet::Update(), Battleground::Update(), Spell::update(), Creature::Update(), GameObject::Update(), Player::Update(), GameObject::UpdateModel(), GameObject::UpdateModelPosition(), Creature::UpdateMovementFlags(), Player::UpdateTriggerVisibility(), GameObject::Use(), and ObjectGridEvacuator::Visit().

841 { ASSERT(m_currMap); return m_currMap; }
Map * m_currMap
Definition: Object.h:949
#define ASSERT
Definition: Errors.h:29
const char* WorldObject::GetName ( ) const
inline

Definition at line 704 of file Object.h.

Referenced by Object::_BuildValuesUpdate(), Player::_LoadBoundInstances(), Player::_LoadInventory(), Player::_LoadQuestStatus(), Player::_SaveInventory(), Player::addActionButton(), Group::AddLeaderInvite(), ArenaTeam::AddMember(), Transport::AddPassenger(), Battleground::AddPlayer(), InstanceMap::AddPlayerToMap(), Player::BindToInstance(), WorldSession::BuildPartyMemberStatsChangedPacket(), Player::BuildPlayerRepop(), InstanceMap::CannotEnter(), Spell::CheckCast(), Player::CleanupChannels(), Corpse::Create(), Pet::CreateBaseAtCreature(), Transport::DoEventIfAny(), FlightPathMovementGenerator::DoEventIfAny(), Player::DuelComplete(), Spell::EffectEnchantItemPerm(), Spell::EffectEnchantItemTmp(), Spell::EffectStuck(), BattlegroundEY::EventPlayerClickedOnFlag(), ChatHandler::ExecuteCommandInTable(), ChatHandler::FillMessageData(), Guild::FillPlayerData(), Unit::GetFactionTemplateEntry(), SocialMgr::GetFriendInfo(), ChatHandler::GetName(), Creature::GetNameForLocaleIdx(), GameObject::GetNameForLocaleIdx(), WorldSession::GetPlayerName(), ReputationMgr::GetReputation(), WorldSession::HandleAcceptGrantLevel(), WorldSession::HandleAcceptTradeOpcode(), ChatHandler::HandleAccountSetGmLevelCommand(), WorldSession::HandleAddFriendOpcodeCallBack(), ChatHandler::HandleAddItemCommand(), ChatHandler::HandleAppearCommand(), WorldSession::HandleArenaTeamAddMemberOpcode(), WorldSession::HandleArenaTeamInviteAcceptOpcode(), WorldSession::HandleArenaTeamLeaveOpcode(), WorldSession::HandleArenaTeamPromoteToCaptainOpcode(), WorldSession::HandleArenaTeamRemoveFromTeamOpcode(), WorldSession::HandleAuctionSellItem(), WorldSession::HandleBattlegroundArenaJoin(), WorldSession::HandleBattlegroundJoinOpcode(), WorldSession::HandleBattlegroundPlayerPortOpcode(), WorldSession::HandleBattlegroundReportAFK(), ChatHandler::HandleCharacterRenameCommand(), ChatHandler::HandleCharacterTitlesCommand(), ChatHandler::HandleCooldownCommand(), ChatHandler::HandleDebugHostilRefList(), ChatHandler::HandleDebugThreatList(), WorldSession::HandleDuelAcceptedOpcode(), ChatHandler::HandleExploreCheatCommand(), WorldSession::HandleFarSightOpcode(), ChatHandler::HandleFlyModeCommand(), ChatHandler::HandleFreezeCommand(), ChatHandler::HandleGetLootRecipient(), ChatHandler::HandleGMNameAnnounceCommand(), ChatHandler::HandleGMTicketCloseByIdCommand(), ChatHandler::HandleGMTicketCommentCommand(), WorldSession::HandleGMTicketCreateOpcode(), ChatHandler::HandleGMTicketDeleteByIdCommand(), ChatHandler::HandleGMTicketUnAssignCommand(), ChatHandler::HandleGPSCommand(), WorldSession::HandleGrantLevel(), WorldSession::HandleGroupDeclineOpcode(), WorldSession::HandleGroupInviteOpcode(), ChatHandler::HandleGroupJoinCommand(), ChatHandler::HandleGroupSummonCommand(), ChatHandler::HandleGroupTeleCommand(), WorldSession::HandleGuildAcceptOpcode(), WorldSession::HandleGuildBankDeposit(), WorldSession::HandleGuildBankDepositItem(), WorldSession::HandleGuildDemoteOpcode(), WorldSession::HandleGuildInviteOpcode(), WorldSession::HandleGuildLeaderOpcode(), WorldSession::HandleGuildLeaveOpcode(), WorldSession::HandleGuildPromoteOpcode(), WorldSession::HandleGuildRemoveOpcode(), ChatHandler::HandleKickPlayerCommand(), ChatHandler::HandleLearnAllDefaultCommand(), ChatHandler::HandleLearnCommand(), ChatHandler::HandleLevelUpCommand(), ChatHandler::HandleLookupTitleCommand(), WorldSession::HandleLootMasterGiveOpcode(), WorldSession::HandleMessagechatOpcode(), ChatHandler::HandleModifyArenaCommand(), ChatHandler::HandleModifyASpeedCommand(), ChatHandler::HandleModifyBWalkCommand(), ChatHandler::HandleModifyEnergyCommand(), ChatHandler::HandleModifyFlyCommand(), ChatHandler::HandleModifyGenderCommand(), ChatHandler::HandleModifyHonorCommand(), ChatHandler::HandleModifyHPCommand(), ChatHandler::HandleModifyManaCommand(), ChatHandler::HandleModifyMoneyCommand(), ChatHandler::HandleModifyMountCommand(), ChatHandler::HandleModifyRageCommand(), ChatHandler::HandleModifyRepCommand(), ChatHandler::HandleModifyScaleCommand(), ChatHandler::HandleModifySpeedCommand(), ChatHandler::HandleModifySpellCommand(), ChatHandler::HandleModifySwimCommand(), ChatHandler::HandleNameAnnounceCommand(), ChatHandler::HandleNameTeleCommand(), ChatHandler::HandleNpcFollowCommand(), ChatHandler::HandleNpcUnFollowCommand(), WorldSession::HandleOfferPetitionOpcode(), WorldSession::HandlePetitionSignOpcode(), WorldSession::HandlePetSetAction(), ChatHandler::HandlePInfoCommand(), OutdoorPvP::HandlePlayerLeaveZone(), WorldSession::HandlePlayerLogin(), WorldSession::HandleQuestComplete(), WorldSession::HandleQuestgiverChooseRewardOpcode(), ChatHandler::HandleRecallCommand(), ChatHandler::HandleRepairitemsCommand(), WorldSession::HandleRequestPartyMemberStatsOpcode(), ChatHandler::HandleResetSpellsCommand(), ChatHandler::HandleResetTalentsCommand(), ChatHandler::HandleSendOpcodeCommand(), ChatHandler::HandleSetSkillCommand(), ChatHandler::HandleSummonCommand(), WorldSession::HandleTakeItem(), ChatHandler::HandleTaxiCheatCommand(), WorldSession::HandleTextEmoteOpcode(), WorldSession::HandleTimeSyncResp(), ChatHandler::HandleTitlesAddCommand(), ChatHandler::HandleTitlesCurrentCommand(), ChatHandler::HandleTitlesRemoveCommand(), ChatHandler::HandleTitlesSetMaskCommand(), ChatHandler::HandleUnFreezeCommand(), ChatHandler::HandleWaterwalkCheatCommand(), Channel::Invite(), BattlegroundQueue::InviteGroupToBG(), ReputationMgr::IsAtWar(), World::KickPlayer(), Player::LoadFromDB(), Guild::LoadPlayerStatsByGuid(), WorldSession::LogoutPlayer(), Group::MasterLoot(), MonsterSay(), MonsterTextEmote(), MonsterWhisper(), MonsterYell(), WorldSession::moveItems(), MotionMaster::MoveTaxiFlight(), MapManager::PlayerCannotEnter(), Map::PlayerRelocation(), SmartScript::ProcessAction(), Map::RemoveAllPlayers(), Player::RemoveFromWorld(), Transport::RemovePassenger(), Battleground::RemovePlayerAtLeave(), InstanceMap::RemovePlayerFromMap(), BattlegroundMap::RemovePlayerFromMap(), Creature::Respawn(), Player::Say(), AuctionHouseMgr::SendAuctionWonMail(), CreatureTextMgr::SendChat(), Player::SendInitialPacketsAfterAddToMap(), WorldSession::SendNameQueryOpcode(), WorldSession::SendPetNameQuery(), WorldSession::SendStablePet(), BattlegroundMgr::SendToBattleground(), ArenaTeam::SetCaptain(), Unit::SetCharm(), Player::setDeathState(), Creature::SetTextRepeatId(), Player::SetViewpoint(), FollowerAI::StartFollow(), Player::StopCastingCharm(), Player::TeleportTo(), Player::TextEmote(), Player::Update(), Player::UpdateHomebindTime(), Player::Whisper(), Player::Yell(), and Battleground::YellToAll().

705  {
706  return m_name.c_str();
707  }
std::string m_name
Definition: Object.h:931
virtual const char* WorldObject::GetNameForLocaleIdx ( int32  ) const
inlinevirtual

Reimplemented in GameObject, and Creature.

Definition at line 713 of file Object.h.

Referenced by CreatureTextMgr::BuildMonsterChat().

714  {
715  return GetName();
716  }
const char * GetName() const
Definition: Object.h:704
void WorldObject::GetNearPoint ( WorldObject const *  searcher,
float &  x,
float &  y,
float &  z,
float  searcher_size,
float  distance2d,
float  absAngle 
) const

Definition at line 2354 of file Object.cpp.

References GetNearPoint2D(), Position::GetPositionZ(), and UpdateAllowedPositionZ().

Referenced by Spell::EffectStuck(), and Unit::GetRandomContactPoint().

2355 {
2356  GetNearPoint2D(x, y, distance2d + searcher_size, absAngle);
2357  z = GetPositionZ();
2358  UpdateAllowedPositionZ(x, y, z);
2359 }
void UpdateAllowedPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1419
float GetPositionZ() const
Definition: Position.h:99
void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const
Definition: Object.cpp:2345
void WorldObject::GetNearPoint2D ( float &  x,
float &  y,
float  distance,
float  absAngle 
) const

Definition at line 2345 of file Object.cpp.

References GetObjectSize(), Position::GetPositionX(), Position::GetPositionY(), and Oregon::NormalizeMapCoord().

Referenced by GetNearPoint().

2346 {
2347  x = GetPositionX() + (GetObjectSize() + distance2d) * cos(absAngle);
2348  y = GetPositionY() + (GetObjectSize() + distance2d) * sin(absAngle);
2349 
2352 }
float GetPositionY() const
Definition: Position.h:98
float GetPositionX() const
Definition: Position.h:97
float GetObjectSize() const
Definition: Object.h:669
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:184
Position WorldObject::GetNearPosition ( float  dist,
float  angle 
)

Definition at line 2361 of file Object.cpp.

References Position::GetPosition(), and MovePosition().

Referenced by Spell::GetSummonPosition(), and Spell::SetTargetMap().

2362 {
2363  Position pos = GetPosition();
2364  MovePosition(pos, dist, angle);
2365  return pos;
2366 }
void MovePosition(Position &pos, float dist, float angle)
Definition: Object.cpp:2422
Position GetPosition() const
Definition: Position.h:117
uint16 WorldObject::GetNotifyFlags ( ) const
inline

Definition at line 893 of file Object.h.

894  {
895  return m_notifyflags;
896  }
uint16 m_notifyflags
Definition: Object.h:955
virtual float WorldObject::GetObjectBoundingRadius ( ) const
inlinevirtual

Definition at line 664 of file Object.h.

References DEFAULT_WORLD_OBJECT_SIZE.

Referenced by Spell::EffectDummy().

665  {
667  }
#define DEFAULT_WORLD_OBJECT_SIZE
Definition: Object.h:44
float WorldObject::GetPositionZTarget ( Position pos,
float  destx,
float  desty 
)

Definition at line 2385 of file Object.cpp.

References Map::GetHeight(), Map::getLiquidStatus(), GetMap(), LiquidData::level, Position::m_positionZ, MAP_ALL_LIQUIDS, and MAX_HEIGHT.

Referenced by MovePositionToFirstCollision().

2386 {
2387 
2388  // Added in Bitbucket issue #1105 in order to solve the problem of
2389  // leap effects like Blink taking the caster to the bottom of a body of liquid.
2390 
2391  float bottom, ground, floor;
2392 
2393  ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
2394  floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
2395  // If we were to ignore liquid, the WorldObject would be placed here.
2396  bottom = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
2397 
2398  if(pos.m_positionZ > bottom)
2399  {
2400 
2401  // We are in the water or in the air.
2402  // Must be at least above ground.
2403 
2404  LiquidData dest_status;
2405  GetMap()->getLiquidStatus(destx, desty, pos.m_positionZ, MAP_ALL_LIQUIDS, &dest_status);
2406 
2407  // Source and destination are underwater.
2408  if(dest_status.level > pos.m_positionZ)
2409  return pos.m_positionZ;
2410 
2411  // When in doubt, send the user to water/ground level.
2412  return fabs(dest_status.level - pos.m_positionZ) <= fabs(bottom - pos.m_positionZ) ? dest_status.level : bottom;
2413 
2414  }
2415  else
2416  {
2417  // Destination is on or under the ground. Use ground Z.
2418  return bottom;
2419  }
2420 }
Map * GetMap() const
Definition: Object.h:841
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:1591
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=0) const
Definition: Map.cpp:1728
float level
Definition: Map.h:151
float m_positionZ
Definition: Position.h:52
#define MAP_ALL_LIQUIDS
Definition: Map.h:142
#define MAX_HEIGHT
Definition: Map.h:258
Position WorldObject::GetRandomNearPosition ( float  radius)

Definition at line 2375 of file Object.cpp.

References Position::GetPosition(), MovePosition(), and rand_norm().

Referenced by CreatureAI::DoSummon(), and CreatureAI::DoSummonFlyer().

2376 {
2377  Position pos = GetPosition();
2378  MovePosition(pos, radius * (float)rand_norm(), (float)rand_norm() * static_cast<float>(2 * M_PI));
2379  return pos;
2380 }
void MovePosition(Position &pos, float dist, float angle)
Definition: Object.cpp:2422
double rand_norm()
Definition: Util.cpp:48
Position GetPosition() const
Definition: Position.h:117
void WorldObject::GetRandomPoint ( const Position srcPos,
float  distance,
float &  rand_x,
float &  rand_y,
float &  rand_z 
) const

Definition at line 1398 of file Object.cpp.

References Position::GetPosition(), Position::m_positionX, Position::m_positionY, Position::m_positionZ, Oregon::NormalizeMapCoord(), rand_norm(), and UpdateGroundPositionZ().

Referenced by Spell::GetSummonPosition(), and Spell::SummonClassPet().

1399 {
1400  if (!distance)
1401  {
1402  pos.GetPosition(rand_x, rand_y, rand_z);
1403  return;
1404  }
1405 
1406  // angle to face `obj` to `this`
1407  float angle = rand_norm() * 2 * M_PI;
1408  float new_dist = rand_norm() * distance;
1409 
1410  rand_x = pos.m_positionX + new_dist * cos(angle);
1411  rand_y = pos.m_positionY + new_dist * sin(angle);
1412  rand_z = pos.m_positionZ;
1413 
1414  Oregon::NormalizeMapCoord(rand_x);
1415  Oregon::NormalizeMapCoord(rand_y);
1416  UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available
1417 }
double rand_norm()
Definition: Util.cpp:48
void UpdateGroundPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1483
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:184
void WorldObject::GetRandomPoint ( const Position srcPos,
float  distance,
Position pos 
) const
inline

Definition at line 677 of file Object.h.

References Position::Relocate().

678  {
679  float x, y, z;
680  GetRandomPoint(srcPos, distance, x, y, z);
681  pos.Relocate(x, y, z, GetOrientation());
682  }
float GetOrientation() const
Definition: Position.h:100
void Relocate(float x, float y)
Definition: Position.h:65
void GetRandomPoint(const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition: Object.cpp:1398
float WorldObject::GetSightRange ( const WorldObject target = NULL) const

Definition at line 1560 of file Object.cpp.

References DEFAULT_VISIBILITY_INSTANCE, Player::GetCinematicMgr(), GetMap(), Map::GetVisibilityRange(), isActiveObject(), CinematicMgr::IsOnCinematic(), Creature::m_SightDistance, MAX_VISIBILITY_DISTANCE, SIGHT_RANGE_UNIT, Object::ToCreature(), Object::ToDynObject(), Object::ToPlayer(), and Object::ToUnit().

Referenced by CanSeeOrDetect(), Group::UpdatePlayerOutOfRange(), and Player::UpdateVisibilityForPlayer().

1561 {
1562  if (ToUnit())
1563  {
1564  if (ToPlayer())
1565  {
1566  if (target && target->isActiveObject() && !target->ToPlayer())
1567  return MAX_VISIBILITY_DISTANCE;
1568  else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
1570  else
1571  return GetMap()->GetVisibilityRange();
1572  }
1573  else if (ToCreature())
1574  return ToCreature()->m_SightDistance;
1575  else
1576  return SIGHT_RANGE_UNIT;
1577  }
1578 
1579  if (ToDynObject() && isActiveObject())
1580  return GetMap()->GetVisibilityRange();
1581 
1582  return 0.0f;
1583 }
Map * GetMap() const
Definition: Object.h:841
#define DEFAULT_VISIBILITY_INSTANCE
Definition: Object.h:41
DynamicObject * ToDynObject()
Definition: Object.h:407
#define SIGHT_RANGE_UNIT
Definition: Object.h:39
Player * ToPlayer()
Definition: Object.h:392
CinematicMgr * GetCinematicMgr() const
Definition: Player.h:1257
bool isActiveObject() const
Definition: Object.h:911
bool IsOnCinematic() const
Definition: CinematicMgr.h:39
float GetVisibilityRange() const
Definition: Map.h:291
#define MAX_VISIBILITY_DISTANCE
Definition: Object.h:38
Creature * ToCreature()
Definition: Object.h:395
float m_SightDistance
Definition: Creature.h:789
Unit * ToUnit()
Definition: Object.h:398
float WorldObject::GetVisibilityRange ( ) const

Definition at line 1552 of file Object.cpp.

References GetMap(), Map::GetVisibilityRange(), isActiveObject(), MAX_VISIBILITY_DISTANCE, and Object::ToPlayer().

Referenced by BuildUpdate(), DestroyForNearbyPlayers(), Player::TeleportTo(), Pet::Update(), Player::Update(), Map::UpdateObjectsVisibilityFor(), Map::UpdateObjectVisibility(), and UpdateObjectVisibility().

1553 {
1554  if (isActiveObject() && !ToPlayer())
1555  return MAX_VISIBILITY_DISTANCE;
1556  else
1557  return GetMap()->GetVisibilityRange();
1558 }
Map * GetMap() const
Definition: Object.h:841
Player * ToPlayer()
Definition: Object.h:392
bool isActiveObject() const
Definition: Object.h:911
float GetVisibilityRange() const
Definition: Map.h:291
#define MAX_VISIBILITY_DISTANCE
Definition: Object.h:38
uint32 WorldObject::GetZoneId ( ) const

Definition at line 1179 of file Object.cpp.

References GetBaseMap(), Map::GetZoneId(), Position::m_positionX, Position::m_positionY, and Position::m_positionZ.

Referenced by Player::_LoadInventory(), WorldSession::BuildPartyMemberStatsChangedPacket(), Spell::CheckCast(), Spell::EffectScriptEffect(), Spell::EffectSummonFriend(), Spell::EffectSummonPlayer(), Guild::FillPlayerData(), World::FindPlayerInZone(), GameObject::getFishLoot(), SocialMgr::GetFriendInfo(), Player::GetOutdoorPvP(), ChatHandler::HandleChangeWeather(), ChatHandler::HandleGoZoneXYCommand(), ChatHandler::HandleGPSCommand(), ChatHandler::HandleLinkGraveCommand(), WorldSession::HandleMoveTeleportAck(), ChatHandler::HandleNearGraveCommand(), WorldSession::HandleRequestPartyMemberStatsOpcode(), ChatHandler::HandleSummonCommand(), WorldSession::LogoutPlayer(), MonsterYellToZone(), Player::ResurrectPlayer(), Corpse::SaveToDB(), Player::SaveToDB(), CreatureTextMgr::SendChatPacket(), Player::SendInitialPacketsAfterAddToMap(), Player::SendInitialPacketsBeforeAddToMap(), Player::SendInitWorldStates(), WorldSession::SendLfgResult(), CreatureTextMgr::SendNonChatPacket(), Creature::SendZoneUnderAttackMessage(), SetZoneScript(), CreatureEventAI::SpawnedEventConditionsCheck(), Player::Update(), and GameObject::Use().

1180 {
1182 }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
static uint32 GetZoneId(uint16 areaflag, uint32 map_id)
Definition: Map.cpp:1832
float m_positionZ
Definition: Position.h:52
Map const * GetBaseMap() const
Definition: Object.cpp:1984
bool WorldObject::HasInArc ( float  arcangle,
const Position pos 
) const
bool WorldObject::HasInArc ( const float  arcangle,
const float  x,
const float  y 
) const

Definition at line 1365 of file Object.cpp.

References Position::GetAngle(), Position::GetOrientation(), Position::m_positionX, and Position::m_positionY.

1366 {
1367  // always have self in arc
1368  if (x == m_positionX && y == m_positionY)
1369  return true;
1370 
1371  float arc = arcangle;
1372 
1373  // move arc to range 0.. 2*pi
1374  while ( arc >= 2.0f * float(M_PI) )
1375  arc -= 2.0f * float(M_PI);
1376  while ( arc < 0 )
1377  arc += 2.0f * float(M_PI);
1378 
1379  float angle = GetAngle( x, y );
1380  angle -= GetOrientation();
1381 
1382  // move angle to range -pi ... +pi
1383  while ( angle > float(M_PI))
1384  angle -= 2.0f * float(M_PI);
1385  while (angle < -M_PI)
1386  angle += 2.0f * float(M_PI);
1387 
1388  float lborder = -1 * (arc / 2.0f); // in range -pi..0
1389  float rborder = (arc / 2.0f); // in range 0..pi
1390  return (( angle >= lborder ) && ( angle <= rborder ));
1391 }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
float GetOrientation() const
Definition: Position.h:100
float GetAngle(Position const *pos) const
bool WorldObject::InSamePhase ( WorldObject const *  obj) const
inline

Definition at line 696 of file Object.h.

References GetPhaseMask(), and InSamePhase().

Referenced by InSamePhase().

696 { return obj && InSamePhase(obj->GetPhaseMask()); }
bool InSamePhase(uint32 phasemask) const
Definition: Object.h:695
static bool WorldObject::InSamePhase ( WorldObject const *  a,
WorldObject const *  b 
)
inlinestatic

Definition at line 697 of file Object.h.

References InSamePhase().

697 { return a && a->InSamePhase(b); }
bool WorldObject::isActiveObject ( ) const
inline

Definition at line 911 of file Object.h.

References ByteConverter::apply().

Referenced by Map::CreatureCellRelocation(), GetGridActivationRange(), GetSightRange(), and GetVisibilityRange().

912  {
913  return m_isActive;
914  }
bool m_isActive
Definition: Object.h:932
virtual bool WorldObject::IsAlwaysDetectableFor ( WorldObject const *  ) const
inlinevirtual

Reimplemented in Player, and Unit.

Definition at line 820 of file Object.h.

Referenced by CanDetect(), and Unit::IsAlwaysDetectableFor().

820 { return false; }
virtual bool WorldObject::IsAlwaysVisibleFor ( WorldObject const *  ) const
inlinevirtual

Reimplemented in Unit, and GameObject.

Definition at line 817 of file Object.h.

Referenced by CanSeeOrDetect(), GameObject::IsAlwaysVisibleFor(), and Unit::IsAlwaysVisibleFor().

817 { return false; }
bool WorldObject::IsInMap ( const WorldObject obj) const
inline
bool WorldObject::IsInRange ( WorldObject const *  obj,
float  minRange,
float  maxRange,
bool  is3D = true 
) const

Definition at line 1299 of file Object.cpp.

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

Referenced by ScriptedAI::CanCast(), CreatureEventAI::CanCast(), SmartScript::GetTargets(), and CreatureEventAI::UpdateAI().

1300 {
1301  float dx = GetPositionX() - obj->GetPositionX();
1302  float dy = GetPositionY() - obj->GetPositionY();
1303  float distsq = dx * dx + dy * dy;
1304  if (is3D)
1305  {
1306  float dz = GetPositionZ() - obj->GetPositionZ();
1307  distsq += dz * dz;
1308  }
1309 
1310  float sizefactor = GetObjectSize() + obj->GetObjectSize();
1311 
1312  // check only for real range
1313  if (minRange > 0.0f)
1314  {
1315  float mindist = minRange + sizefactor;
1316  if (distsq < mindist * mindist)
1317  return false;
1318  }
1319 
1320  float maxdist = maxRange + sizefactor;
1321  return distsq < maxdist * maxdist;
1322 }
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
float GetPositionX() const
Definition: Position.h:97
float GetObjectSize() const
Definition: Object.h:669
bool WorldObject::IsInRange2d ( float  x,
float  y,
float  minRange,
float  maxRange 
) const

Definition at line 1324 of file Object.cpp.

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

1325 {
1326  float dx = GetPositionX() - x;
1327  float dy = GetPositionY() - y;
1328  float distsq = dx * dx + dy * dy;
1329 
1330  float sizefactor = GetObjectSize();
1331 
1332  // check only for real range
1333  if (minRange > 0.0f)
1334  {
1335  float mindist = minRange + sizefactor;
1336  if (distsq < mindist * mindist)
1337  return false;
1338  }
1339 
1340  float maxdist = maxRange + sizefactor;
1341  return distsq < maxdist * maxdist;
1342 }
float GetPositionY() const
Definition: Position.h:98
float GetPositionX() const
Definition: Position.h:97
float GetObjectSize() const
Definition: Object.h:669
bool WorldObject::IsInRange3d ( float  x,
float  y,
float  z,
float  minRange,
float  maxRange 
) const

Definition at line 1344 of file Object.cpp.

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

1345 {
1346  float dx = GetPositionX() - x;
1347  float dy = GetPositionY() - y;
1348  float dz = GetPositionZ() - z;
1349  float distsq = dx * dx + dy * dy + dz * dz;
1350 
1351  float sizefactor = GetObjectSize();
1352 
1353  // check only for real range
1354  if (minRange > 0.0f)
1355  {
1356  float mindist = minRange + sizefactor;
1357  if (distsq < mindist * mindist)
1358  return false;
1359  }
1360 
1361  float maxdist = maxRange + sizefactor;
1362  return distsq < maxdist * maxdist;
1363 }
float GetPositionY() const
Definition: Position.h:98
float GetPositionZ() const
Definition: Position.h:99
float GetPositionX() const
Definition: Position.h:97
float GetObjectSize() const
Definition: Object.h:669
virtual bool WorldObject::IsInvisibleDueToDespawn ( ) const
inlinevirtual

Reimplemented in Creature, and GameObject.

Definition at line 818 of file Object.h.

Referenced by CanSeeOrDetect(), GameObject::IsInvisibleDueToDespawn(), and Creature::IsInvisibleDueToDespawn().

818 { return false; }
bool WorldObject::isNeedNotify ( uint16  f) const
inline
virtual bool WorldObject::IsNeverVisible ( ) const
inlinevirtual

Reimplemented in Player, and GameObject.

Definition at line 816 of file Object.h.

Referenced by CanSeeOrDetect(), GameObject::IsNeverVisible(), and Player::IsNeverVisible().

816 { return !IsInWorld(); }
const bool & IsInWorld() const
Definition: Object.h:135
bool WorldObject::IsPermanentWorldObject ( ) const
inline

Definition at line 917 of file Object.h.

Referenced by Map::RemoveAllObjectsInRemoveList(), and Map::SwitchGridContainers().

917 { return m_isWorldObject; }
const bool m_isWorldObject
Definition: Object.h:933
bool WorldObject::isValid ( ) const
virtual

Reimplemented in Unit.

Definition at line 1523 of file Object.cpp.

References Object::IsInWorld().

Referenced by Unit::isValid().

1524 {
1525  if (!IsInWorld())
1526  return false;
1527 
1528  return true;
1529 }
const bool & IsInWorld() const
Definition: Object.h:135
bool WorldObject::IsWithinDist ( WorldObject const *  obj,
float  dist2compare,
bool  is3D = true 
) const
inline

Definition at line 770 of file Object.h.

Referenced by RandomMovementGenerator< T >::_setRandomLocation(), Creature::CanCreatureAttack(), CanSeeOrDetect(), Creature::canStartAttack(), CreatureGroup::LeaderMoveTo(), and Group::UpdatePlayerOutOfRange().

771  {
772  return obj && _IsWithinDist(obj, dist2compare, is3D);
773  }
bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D) const
Definition: Object.cpp:1213
bool WorldObject::IsWithinDist2d ( float  x,
float  y,
float  dist 
) const
inline

Definition at line 760 of file Object.h.

761  {
762  return IsInDist2d(x, y, dist + GetObjectSize());
763  }
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:178
float GetObjectSize() const
Definition: Object.h:669
bool WorldObject::IsWithinDist2d ( const Position pos,
float  dist 
) const
inline

Definition at line 764 of file Object.h.

765  {
766  return IsInDist2d(pos, dist + GetObjectSize());
767  }
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:178
float GetObjectSize() const
Definition: Object.h:669
bool WorldObject::IsWithinDist3d ( float  x,
float  y,
float  z,
float  dist 
) const
inline

Definition at line 752 of file Object.h.

Referenced by Player::TeleportTo().

753  {
754  return IsInDist(x, y, z, dist + GetObjectSize());
755  }
float GetObjectSize() const
Definition: Object.h:669
bool IsInDist(float x, float y, float z, float dist) const
Definition: Position.h:188
bool WorldObject::IsWithinDist3d ( const Position pos,
float  dist 
) const
inline

Definition at line 756 of file Object.h.

757  {
758  return IsInDist(pos, dist + GetObjectSize());
759  }
float GetObjectSize() const
Definition: Object.h:669
bool IsInDist(float x, float y, float z, float dist) const
Definition: Position.h:188
bool WorldObject::IsWithinDistInMap ( WorldObject const *  obj,
float  dist2compare,
bool  is3D = true 
) const
inline

Definition at line 774 of file Object.h.

Referenced by FollowerAI::AssistPlayerInCombat(), npc_escortAI::AssistPlayerInCombat(), SmartAI::AssistPlayerInCombat(), Creature::canStartAttack(), Player::CheckDuelDistance(), BattlegroundEY::CheckSomeoneJoinedPoint(), BattlegroundEY::CheckSomeoneLeftPoint(), WorldSession::DoLootRelease(), BattlegroundWS::EventPlayerClickedOnFlag(), BattlegroundAB::EventPlayerClickedOnFlag(), BattlegroundEY::EventPlayerClickedOnFlag(), Player::GetGameObjectIfCanInteractWith(), FollowerAI::GetLeaderForFollower(), Player::GetNextRandomRaidMember(), Player::GetNPCIfCanInteractWith(), Group::GroupLoot(), WorldSession::HandleAutostoreLootItemOpcode(), WorldSession::HandleCorpseReclaimOpcode(), WorldSession::HandleLootMoneyOpcode(), Aura::HandleModPossessPet(), Unit::isInBackInMap(), Unit::isInFrontInMap(), npc_escortAI::IsPlayerOrGroupInRange(), FollowerAI::MoveInLineOfSight(), npc_escortAI::MoveInLineOfSight(), CreatureEventAI::MoveInLineOfSight(), Oregon::GameObjectFocusCheck::operator()(), Oregon::CallOfHelpCreatureInRangeDo::operator()(), Oregon::NearestHostileUnitInAggroRangeCheck::operator()(), Map::ScriptsProcess(), ScriptedAI::SelectSpell(), Player::SendLoot(), Player::SetPosition(), Spell::SetTargetMap(), OPvPCapturePoint::Update(), Pet::Update(), Aura::Update(), AreaAura::Update(), PersistentAreaAura::Update(), Player::Update(), TotemAI::UpdateAI(), FollowerAI::UpdateAI(), Group::UpdateLooterGuid(), and Oregon::SpellNotifierCreatureAndPlayer::Visit().

775  {
776  return obj && IsInMap(obj) && _IsWithinDist(obj, dist2compare, is3D);
777  }
bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D) const
Definition: Object.cpp:1213
bool IsInMap(const WorldObject *obj) const
Definition: Object.h:745
bool WorldObject::IsWithinLOS ( float  x,
float  y,
float  z 
) const

Definition at line 1243 of file Object.cpp.

References GetHitSpherePointFor(), GetMap(), Position::GetPosition(), Object::GetTypeId(), Map::isInLineOfSight(), Object::IsInWorld(), and TYPEID_PLAYER.

Referenced by CreatureEventAI::CanCast(), Unit::isAttackableByAOE(), and IsWithinLOSInMap().

1244 {
1245  if (IsInWorld())
1246  {
1247  float x, y, z;
1248  if (GetTypeId() == TYPEID_PLAYER)
1249  GetPosition(x, y, z);
1250  else
1251  GetHitSpherePointFor({ ox, oy, oz }, x, y, z);
1252 
1253  return GetMap()->isInLineOfSight(x, y, z + 2.0f, ox, oy, oz + 2.0f);
1254  }
1255 
1256  return true;
1257 }
Map * GetMap() const
Definition: Object.h:841
uint8 GetTypeId() const
Definition: Object.h:210
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1259
const bool & IsInWorld() const
Definition: Object.h:135
Position GetPosition() const
Definition: Position.h:117
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2) const
Definition: Map.cpp:1802
bool WorldObject::IsWithinLOSInMap ( const WorldObject obj) const

Definition at line 1229 of file Object.cpp.

References GetHitSpherePointFor(), Position::GetPosition(), Object::GetTypeId(), IsInMap(), IsWithinLOS(), and TYPEID_PLAYER.

Referenced by FollowerAI::AssistPlayerInCombat(), npc_escortAI::AssistPlayerInCombat(), SmartAI::AssistPlayerInCombat(), Unit::AttackerStateUpdate(), CreatureEventAI::CanCast(), Creature::canStartAttack(), Spell::CheckCast(), Spell::CheckTarget(), FollowerAI::MoveInLineOfSight(), npc_escortAI::MoveInLineOfSight(), CreatureEventAI::MoveInLineOfSight(), Oregon::CallOfHelpCreatureInRangeDo::operator()(), Oregon::NearestHostileUnitInAggroRangeCheck::operator()(), and Spell::SearchChainTarget().

1230 {
1231  if (!IsInMap(obj))
1232  return false;
1233 
1234  float x, y, z;
1235  if (obj->GetTypeId() == TYPEID_PLAYER)
1236  obj->GetPosition(x, y, z);
1237  else
1238  obj->GetHitSpherePointFor(GetPosition(), x, y, z);
1239 
1240  return IsWithinLOS(x, y, z);
1241 }
bool IsWithinLOS(float x, float y, float z) const
Definition: Object.cpp:1243
uint8 GetTypeId() const
Definition: Object.h:210
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1259
void GetPosition(float &x, float &y) const
Definition: Position.h:102
Position GetPosition() const
Definition: Position.h:117
bool IsInMap(const WorldObject *obj) const
Definition: Object.h:745
bool WorldObject::IsWorldObject ( ) const

Definition at line 1112 of file Object.cpp.

References m_isWorldObject, and Object::ToCreature().

Referenced by Map::AddToGrid(), DynamicObject::CreateDynamicObject(), ResetMap(), SetMap(), and Map::~Map().

1113 {
1114  if (m_isWorldObject)
1115  return true;
1116 
1117  if (ToCreature() && ToCreature()->m_isTempWorldObject)
1118  return true;
1119 
1120  return false;
1121 }
const bool m_isWorldObject
Definition: Object.h:933
Creature * ToCreature()
Definition: Object.h:395
void WorldObject::MonsterSay ( const char *  text,
uint32  language,
uint64  TargetGuid 
)

Definition at line 1490 of file Object.cpp.

References BuildMonsterChat(), CHAT_MSG_MONSTER_SAY, CONFIG_LISTEN_RANGE_SAY, GetName(), SendMessageToSetInRange(), SMSG_MESSAGECHAT, and sWorld.

Referenced by DoScriptText(), CreatureEventAI::DoScriptText(), DynamicObject::Say(), and Corpse::Say().

1491 {
1492  WorldPacket data(SMSG_MESSAGECHAT, 200);
1493  BuildMonsterChat(&data, CHAT_MSG_MONSTER_SAY, text, language, GetName(), TargetGuid);
1494  SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY), true);
1495 }
const char * GetName() const
Definition: Object.h:704
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
Definition: Object.cpp:1907
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
Definition: Object.cpp:1933
#define sWorld
Definition: World.h:860
void WorldObject::MonsterSay ( int32  textId,
uint32  language,
uint64  TargetGuid 
)

Definition at line 1837 of file Object.cpp.

References CHAT_MSG_MONSTER_SAY, Oregon::ComputeCellCoord(), CONFIG_LISTEN_RANGE_SAY, GetMap(), Position::GetPositionX(), Position::GetPositionY(), Cell::SetNoCreate(), sWorld, and Cell::Visit().

1838 {
1840 
1841  Cell cell(p);
1842  cell.SetNoCreate();
1843 
1844  Oregon::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_SAY, textId, language, TargetGuid);
1848  cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY));
1849 }
Map * GetMap() const
Definition: Object.h:841
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
#define sWorld
Definition: World.h:860
float GetPositionX() const
Definition: Position.h:97
void WorldObject::MonsterTextEmote ( const char *  text,
uint64  TargetGuid,
bool  IsBossEmote = false 
)

Definition at line 1504 of file Object.cpp.

References BuildMonsterChat(), CHAT_MSG_MONSTER_EMOTE, CHAT_MSG_RAID_BOSS_EMOTE, CONFIG_LISTEN_RANGE_TEXTEMOTE, GetName(), LANG_UNIVERSAL, SendMessageToSetInRange(), SMSG_MESSAGECHAT, and sWorld.

Referenced by DoScriptText(), CreatureEventAI::DoScriptText(), DynamicObject::TextEmote(), and Corpse::TextEmote().

1505 {
1506  WorldPacket data(SMSG_MESSAGECHAT, 200);
1507  BuildMonsterChat(&data, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, text, LANG_UNIVERSAL, GetName(), TargetGuid);
1509 }
const char * GetName() const
Definition: Object.h:704
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
Definition: Object.cpp:1907
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
Definition: Object.cpp:1933
#define sWorld
Definition: World.h:860
void WorldObject::MonsterTextEmote ( int32  textId,
uint64  TargetGuid,
bool  IsBossEmote = false 
)

Definition at line 1878 of file Object.cpp.

References CHAT_MSG_MONSTER_EMOTE, CHAT_MSG_RAID_BOSS_EMOTE, Oregon::ComputeCellCoord(), CONFIG_LISTEN_RANGE_TEXTEMOTE, GetMap(), Position::GetPositionX(), Position::GetPositionY(), LANG_UNIVERSAL, Cell::SetNoCreate(), sWorld, and Cell::Visit().

1879 {
1881 
1882  Cell cell(p);
1883  cell.SetNoCreate();
1884 
1885  Oregon::MonsterChatBuilder say_build(*this, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, textId, LANG_UNIVERSAL, TargetGuid);
1889  cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
1890 }
Map * GetMap() const
Definition: Object.h:841
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
#define sWorld
Definition: World.h:860
float GetPositionX() const
Definition: Position.h:97
void WorldObject::MonsterWhisper ( const char *  text,
uint64  receiver,
bool  IsBossWhisper = false 
)

Definition at line 1511 of file Object.cpp.

References BuildMonsterChat(), CHAT_MSG_MONSTER_WHISPER, CHAT_MSG_RAID_BOSS_WHISPER, GetName(), Player::GetSession(), LANG_UNIVERSAL, WorldSession::SendPacket(), SMSG_MESSAGECHAT, and sObjectMgr.

Referenced by DoScriptText(), CreatureEventAI::DoScriptText(), DynamicObject::Whisper(), and Corpse::Whisper().

1512 {
1513  Player* player = sObjectMgr.GetPlayer(receiver);
1514  if (!player || !player->GetSession())
1515  return;
1516 
1517  WorldPacket data(SMSG_MESSAGECHAT, 200);
1518  BuildMonsterChat(&data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, GetName(), receiver);
1519 
1520  player->GetSession()->SendPacket(&data);
1521 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
const char * GetName() const
Definition: Object.h:704
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
Definition: Object.cpp:1907
WorldSession * GetSession() const
Definition: Player.h:1944
Definition: Player.h:922
void WorldObject::MonsterWhisper ( int32  textId,
uint64  receiver,
bool  IsBossWhisper = false 
)

Definition at line 1892 of file Object.cpp.

References BuildMonsterChat(), CHAT_MSG_MONSTER_WHISPER, CHAT_MSG_RAID_BOSS_WHISPER, GetName(), Player::GetSession(), WorldSession::GetSessionDbLocaleIndex(), LANG_UNIVERSAL, WorldSession::SendPacket(), SMSG_MESSAGECHAT, and sObjectMgr.

1893 {
1894  Player* player = sObjectMgr.GetPlayer(receiver);
1895  if (!player || !player->GetSession())
1896  return;
1897 
1898  uint32 loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
1899  char const* text = sObjectMgr.GetOregonString(textId, loc_idx);
1900 
1901  WorldPacket data(SMSG_MESSAGECHAT, 200);
1902  BuildMonsterChat(&data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, GetName(), receiver);
1903 
1904  player->GetSession()->SendPacket(&data);
1905 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
const char * GetName() const
Definition: Object.h:704
int GetSessionDbLocaleIndex() const
Definition: WorldSession.h:237
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
Definition: Object.cpp:1907
WorldSession * GetSession() const
Definition: Player.h:1944
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:922
void WorldObject::MonsterYell ( const char *  text,
uint32  language,
uint64  TargetGuid 
)

Definition at line 1497 of file Object.cpp.

References BuildMonsterChat(), CHAT_MSG_MONSTER_YELL, CONFIG_LISTEN_RANGE_YELL, GetName(), SendMessageToSetInRange(), SMSG_MESSAGECHAT, and sWorld.

Referenced by DoScriptText(), CreatureEventAI::DoScriptText(), DynamicObject::Yell(), and Corpse::Yell().

1498 {
1499  WorldPacket data(SMSG_MESSAGECHAT, 200);
1500  BuildMonsterChat(&data, CHAT_MSG_MONSTER_YELL, text, language, GetName(), TargetGuid);
1501  SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL), true);
1502 }
const char * GetName() const
Definition: Object.h:704
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
Definition: Object.cpp:1907
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
Definition: Object.cpp:1933
#define sWorld
Definition: World.h:860
void WorldObject::MonsterYell ( int32  textId,
uint32  language,
uint64  TargetGuid 
)

Definition at line 1851 of file Object.cpp.

References CHAT_MSG_MONSTER_YELL, Oregon::ComputeCellCoord(), CONFIG_LISTEN_RANGE_YELL, GetMap(), Position::GetPositionX(), Position::GetPositionY(), Cell::SetNoCreate(), sWorld, and Cell::Visit().

1852 {
1854 
1855  Cell cell(p);
1856  cell.SetNoCreate();
1857 
1858  Oregon::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, TargetGuid);
1862  cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL));
1863 }
Map * GetMap() const
Definition: Object.h:841
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
#define sWorld
Definition: World.h:860
float GetPositionX() const
Definition: Position.h:97
void WorldObject::MonsterYellToZone ( int32  textId,
uint32  language,
uint64  TargetGuid 
)

Definition at line 1865 of file Object.cpp.

References MapRefManager::begin(), CHAT_MSG_MONSTER_YELL, MapRefManager::end(), GetMap(), Map::GetPlayers(), and GetZoneId().

Referenced by DoScriptText(), and CreatureEventAI::DoScriptText().

1866 {
1867  Oregon::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, TargetGuid);
1869 
1870  uint32 zoneid = GetZoneId();
1871 
1872  Map::PlayerList const& pList = GetMap()->GetPlayers();
1873  for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
1874  if (itr->GetSource()->GetZoneId() == zoneid)
1875  say_do(itr->GetSource());
1876 }
Map * GetMap() const
Definition: Object.h:841
uint32 GetZoneId() const
Definition: Object.cpp:1179
iterator begin()
Definition: MapRefManager.h:48
PlayerList const & GetPlayers() const
Definition: Map.h:491
ACE_UINT32 uint32
Definition: Define.h:71
iterator end()
Definition: MapRefManager.h:52
void WorldObject::MovePosition ( Position pos,
float  dist,
float  angle 
)

Definition at line 2422 of file Object.cpp.

References Map::GetHeight(), GetMap(), Position::GetOrientation(), Oregon::IsValidMapCoord(), Position::m_positionX, Position::m_positionY, Position::m_positionZ, MAX_HEIGHT, Oregon::NormalizeMapCoord(), Position::Relocate(), Position::SetOrientation(), sLog, and UpdateGroundPositionZ().

Referenced by GetNearPosition(), and GetRandomNearPosition().

2423 {
2424  angle += GetOrientation();
2425  float destx, desty, destz, ground, floor;
2426  destx = pos.m_positionX + dist * cos(angle);
2427  desty = pos.m_positionY + dist * sin(angle);
2428 
2429  // Prevent invalid coordinates here, position is unchanged
2430  if (!Oregon::IsValidMapCoord(destx, desty, pos.m_positionZ))
2431  {
2432  sLog.outString("WorldObject::MovePosition invalid coordinates X: %f and Y: %f were passed!", destx, desty);
2433  return;
2434  }
2435 
2436  // Prevent invalid coordinates here, position is unchanged
2437  if (!Oregon::IsValidMapCoord(destx, desty))
2438  {
2439  sLog.outError("Crash alert! WorldObject::MovePositionToFirstCollision invalid coordinates X: %f and Y: %f were passed!", destx, desty);
2440  return;
2441  }
2442 
2443  ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
2444  floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
2445  destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
2446 
2447  float step = dist / 10.0f;
2448 
2449  for (uint8 j = 0; j < 10; ++j)
2450  {
2451  // do not allow too big z changes
2452  if (fabs(pos.m_positionZ - destz) > 6)
2453  {
2454  destx -= step * cos(angle);
2455  desty -= step * sin(angle);
2456  ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
2457  floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
2458  destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
2459  }
2460  // we have correct destz now
2461  else
2462  {
2463  pos.Relocate(destx, desty, destz);
2464  break;
2465  }
2466  }
2467 
2472 }
Map * GetMap() const
Definition: Object.h:841
float m_positionY
Definition: Position.h:51
void SetOrientation(float orientation)
Definition: Position.h:92
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:1591
#define sLog
Log class singleton.
Definition: Log.h:187
bool IsValidMapCoord(float c)
Definition: GridDefines.h:192
float m_positionX
Definition: Position.h:50
ACE_UINT8 uint8
Definition: Define.h:73
float GetOrientation() const
Definition: Position.h:100
void Relocate(float x, float y)
Definition: Position.h:65
float m_positionZ
Definition: Position.h:52
#define MAX_HEIGHT
Definition: Map.h:258
void UpdateGroundPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1483
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:184
void WorldObject::MovePositionToFirstCollision ( Position pos,
float  dist,
float  angle 
)

Definition at line 2474 of file Object.cpp.

References CONTACT_DISTANCE, VMAP::VMapFactory::createOrGetVMapManager(), GetMap(), WorldLocation::GetMapId(), VMAP::IVMapManager::getObjectHitPos(), Map::getObjectHitPos(), Position::GetOrientation(), GetPositionZTarget(), Oregon::IsValidMapCoord(), Position::m_positionX, Position::m_positionY, Position::m_positionZ, Oregon::NormalizeMapCoord(), Position::Relocate(), Position::SetOrientation(), and sLog.

Referenced by GetFirstCollisionPosition(), and Spell::SetTargetMap().

2475 {
2476  angle += GetOrientation();
2477  float destx, desty, destz;
2478  destx = pos.m_positionX + dist * cos(angle);
2479  desty = pos.m_positionY + dist * sin(angle);
2480 
2481  // Prevent invalid coordinates here, position is unchanged
2482  if (!Oregon::IsValidMapCoord(destx, desty))
2483  {
2484  sLog.outFatal("WorldObject::MovePositionToFirstCollision invalid coordinates X: %f and Y: %f were passed!", destx, desty);
2485  return;
2486  }
2487 
2488  destz = GetPositionZTarget(pos, destx, desty);
2489  bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), pos.m_positionX, pos.m_positionY, pos.m_positionZ + 0.5f, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
2490 
2491  // collision occured
2492  if (col)
2493  {
2494  // move back a bit
2495  destx -= CONTACT_DISTANCE * cos(angle);
2496  desty -= CONTACT_DISTANCE * sin(angle);
2497  dist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
2498  }
2499 
2500  // check dynamic collision
2501  col = GetMap()->getObjectHitPos(pos.m_positionX, pos.m_positionY, pos.m_positionZ + 0.5f, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
2502 
2503  // Collided with a gameobject
2504  if (col)
2505  {
2506  destx -= CONTACT_DISTANCE * cos(angle);
2507  desty -= CONTACT_DISTANCE * sin(angle);
2508  dist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
2509  }
2510 
2511  float step = dist / 10.0f;
2512 
2513  for (uint8 j = 0; j < 10; ++j)
2514  {
2515  // do not allow too big z changes
2516  if (fabs(pos.m_positionZ - destz) > 6.0f)
2517  {
2518  destx -= step * cos(angle);
2519  desty -= step * sin(angle);
2520  destz = GetPositionZTarget(pos, destx, desty);
2521  }
2522  // we have correct destz now
2523  else
2524  {
2525  pos.Relocate(destx, desty, destz);
2526  break;
2527  }
2528  }
2529 
2532  pos.m_positionZ = GetPositionZTarget(pos, destx, desty);
2534 }
Map * GetMap() const
Definition: Object.h:841
float m_positionY
Definition: Position.h:51
void SetOrientation(float orientation)
Definition: Position.h:92
#define sLog
Log class singleton.
Definition: Log.h:187
bool IsValidMapCoord(float c)
Definition: GridDefines.h:192
float m_positionX
Definition: Position.h:50
virtual bool getObjectHitPos(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float pModifyDist)=0
float GetPositionZTarget(Position &pos, float destx, float desty)
Definition: Object.cpp:2385
ACE_UINT8 uint8
Definition: Define.h:73
float GetOrientation() const
Definition: Position.h:100
void Relocate(float x, float y)
Definition: Position.h:65
uint32 GetMapId() const
Definition: Object.h:591
float m_positionZ
Definition: Position.h:52
static IVMapManager * createOrGetVMapManager()
#define CONTACT_DISTANCE
Definition: Object.h:34
bool getObjectHitPos(float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist)
Definition: Map.cpp:1808
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:184
bool WorldObject::NotifyExecuted ( uint16  f) const
inline

Definition at line 897 of file Object.h.

898  {
899  return m_executed_notifies & f;
900  }
uint16 m_executed_notifies
Definition: Object.h:956
void WorldObject::PlayDirectSound ( uint32  sound_id,
Player target = NULL 
)

Definition at line 2555 of file Object.cpp.

References Player::SendDirectMessage(), SendMessageToSet(), and SMSG_PLAY_SOUND.

Referenced by ScriptedAI::DoPlaySoundToSet(), and ChatHandler::HandleDebugPlaySoundCommand().

2556 {
2557  WorldPacket data(SMSG_PLAY_SOUND, 4);
2558  data << uint32(sound_id);
2559  if (target)
2560  target->SendDirectMessage(&data);
2561  else
2562  SendMessageToSet(&data, true);
2563 }
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:789
void SendDirectMessage(WorldPacket *data)
Definition: Player.cpp:5724
ACE_UINT32 uint32
Definition: Define.h:71
void WorldObject::PlayDistanceSound ( uint32  sound_id,
Player target = NULL 
)

Definition at line 2544 of file Object.cpp.

References Object::GetGUID(), Player::SendDirectMessage(), SendMessageToSet(), and SMSG_PLAY_OBJECT_SOUND.

Referenced by Aura::HandleAuraDummy(), and ChatHandler::HandleDebugPlaySoundCommand().

2545 {
2546  WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8);
2547  data << uint32(sound_id);
2548  data << uint64(GetGUID());
2549  if (target)
2550  target->SendDirectMessage(&data);
2551  else
2552  SendMessageToSet(&data, true);
2553 }
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:789
void SendDirectMessage(WorldPacket *data)
Definition: Player.cpp:5724
ACE_UINT64 uint64
Definition: Define.h:70
ACE_UINT32 uint32
Definition: Define.h:71
const uint64 & GetGUID() const
Definition: Object.h:162
void WorldObject::RemoveFromWorld ( )
overridevirtual

Reimplemented from Object.

Reimplemented in Player, Unit, GameObject, Creature, Pet, Puppet, Minion, Corpse, TempSummon, and DynamicObject.

Definition at line 1169 of file Object.cpp.

References DestroyForNearbyPlayers(), Object::IsInWorld(), and Object::RemoveFromWorld().

Referenced by CleanupsBeforeDelete(), DynamicObject::RemoveFromWorld(), GameObject::RemoveFromWorld(), Unit::RemoveFromWorld(), and Map::~Map().

1170 {
1171  if (!IsInWorld())
1172  return;
1173 
1175 
1177 }
virtual void RemoveFromWorld()
Definition: Object.h:151
const bool & IsInWorld() const
Definition: Object.h:135
void DestroyForNearbyPlayers()
Definition: Object.cpp:2565
void WorldObject::ResetAllNotifies ( )
inline

Definition at line 905 of file Object.h.

906  {
907  m_notifyflags = 0;
909  }
uint16 m_notifyflags
Definition: Object.h:955
uint16 m_executed_notifies
Definition: Object.h:956
void WorldObject::ResetMap ( )
virtual

Reimplemented in Player.

Definition at line 1972 of file Object.cpp.

References ASSERT, Object::IsInWorld(), IsWorldObject(), m_currMap, and Map::RemoveWorldObject().

Referenced by Player::ResetMap(), Transport::TeleportTransport(), and Map::~Map().

1973 {
1974  ASSERT(m_currMap);
1975  ASSERT(!IsInWorld());
1976  if (IsWorldObject())
1978  m_currMap = NULL;
1979  //maybe not for corpse
1980  //m_mapId = 0;
1981  //m_InstanceId = 0;
1982 }
Map * m_currMap
Definition: Object.h:949
bool IsWorldObject() const
Definition: Object.cpp:1112
void RemoveWorldObject(WorldObject *obj)
Definition: Map.h:483
const bool & IsInWorld() const
Definition: Object.h:135
#define ASSERT
Definition: Errors.h:29
virtual void WorldObject::SaveRespawnTime ( )
inlinevirtual

Reimplemented in GameObject, and Creature.

Definition at line 811 of file Object.h.

811 {}
virtual void WorldObject::SendMessageToSet ( WorldPacket data,
bool  self 
)
inlinevirtual

Reimplemented in Player.

Definition at line 789 of file Object.h.

Referenced by Unit::DealMeleeDamage(), Spell::Delayed(), Unit::Dismount(), Spell::EffectDispel(), Spell::EffectDummy(), Spell::EffectInstaKill(), Spell::EffectScriptEffect(), Spell::EffectStealBeneficialBuff(), Spell::EffectSummonObject(), Spell::EffectTransmitted(), Unit::HandleEmoteCommand(), ChatHandler::HandleFlyModeCommand(), WorldSession::HandleMovementOpcodes(), Totem::InitSummon(), Movement::MoveSplineInit::Launch(), Aura::PeriodicTick(), PlayDirectSound(), PlayDistanceSound(), Unit::SendAttackStateUpdate(), Spell::SendChannelStart(), Spell::SendChannelUpdate(), Unit::SendEnergizeSpellLog(), Unit::SendHealSpellLog(), Spell::SendInterrupted(), Spell::SendLogExecute(), Unit::SendMeleeAttackStart(), Unit::SendMeleeAttackStop(), SendObjectCustomAnim(), SendObjectDeSpawnAnim(), SendPlaySound(), Unit::SendSpellDamageImmune(), Spell::SendSpellGo(), Unit::SendSpellMiss(), Unit::SendSpellNonMeleeDamageLog(), Spell::SendSpellStart(), Creature::SetCanFly(), Creature::SetFeatherFall(), Creature::SetHover(), Creature::SetLevitate(), Unit::SetSpeed(), Creature::SetSwim(), Creature::SetWalk(), Creature::SetWaterWalking(), and Movement::MoveSplineInit::Stop().

float GetVisibilityRange() const
Definition: Object.cpp:1552
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
Definition: Object.cpp:1933
void WorldObject::SendMessageToSetInRange ( WorldPacket data,
float  dist,
bool  self 
)
virtual

Reimplemented in Player.

Definition at line 1933 of file Object.cpp.

References VisitNearbyWorldObject().

Referenced by MonsterSay(), MonsterTextEmote(), MonsterYell(), and CreatureTextMgr::SendNonChatPacket().

1934 {
1935  Oregon::MessageDistDeliverer notifier(this, data, dist);
1936  VisitNearbyWorldObject(dist, notifier);
1937 }
void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const
Definition: Object.h:920
void WorldObject::SendObjectCustomAnim ( uint64  guid,
uint32  anim = 0 
)

Definition at line 1946 of file Object.cpp.

References SendMessageToSet(), and SMSG_GAMEOBJECT_CUSTOM_ANIM.

Referenced by Spell::EffectActivateObject(), GameObject::Update(), and GameObject::Use().

1947 {
1949  data << uint64(guid);
1950  data << uint32(anim);
1951  SendMessageToSet(&data, true);
1952 }
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:789
ACE_UINT64 uint64
Definition: Define.h:70
ACE_UINT32 uint32
Definition: Define.h:71
void WorldObject::SendObjectDeSpawnAnim ( uint64  guid)

Definition at line 1939 of file Object.cpp.

References SendMessageToSet(), and SMSG_GAMEOBJECT_DESPAWN_ANIM.

Referenced by GameObject::Delete(), ChatHandler::HandleObjectStateCommand(), DynamicObject::Remove(), Totem::UnSummon(), and GameObject::Update().

1940 {
1942  data << uint64(guid);
1943  SendMessageToSet(&data, true);
1944 }
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:789
ACE_UINT64 uint64
Definition: Define.h:70
void WorldObject::SendPlaySound ( uint32  Sound,
bool  OnlySelf 
)

Definition at line 1790 of file Object.cpp.

References Player::GetSession(), Object::GetTypeId(), SendMessageToSet(), WorldSession::SendPacket(), SMSG_PLAY_SOUND, Object::ToPlayer(), and TYPEID_PLAYER.

Referenced by DoScriptText(), CreatureEventAI::DoScriptText(), and CreatureEventAI::ProcessAction().

1791 {
1792  WorldPacket data(SMSG_PLAY_SOUND, 4);
1793  data << Sound;
1794  if (OnlySelf && GetTypeId() == TYPEID_PLAYER)
1795  ToPlayer()->GetSession()->SendPacket(&data);
1796  else
1797  SendMessageToSet(&data, true); // ToSelf ignored in this case
1798 }
void SendPacket(WorldPacket const *packet)
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:789
Player * ToPlayer()
Definition: Object.h:392
uint8 GetTypeId() const
Definition: Object.h:210
WorldSession * GetSession() const
Definition: Player.h:1944
void WorldObject::setActive ( bool  isActiveObject)

Definition at line 1123 of file Object.cpp.

References Map::AddToActive(), FindMap(), Object::GetTypeId(), Object::IsInWorld(), m_isActive, Map::RemoveFromActive(), Object::ToCreature(), TYPEID_DYNAMICOBJECT, TYPEID_PLAYER, and TYPEID_UNIT.

Referenced by BossAI::_EnterCombat(), BossAI::_JustReachedHome(), Unit::AddPlayerToVision(), CinematicMgr::BeginCinematic(), DynamicObject::CreateDynamicObject(), Spell::EffectAddFarsight(), BossAI::JustReachedHome(), Unit::RemovePlayerFromVision(), and Creature::setDeathState().

1124 {
1125  if (m_isActive == on)
1126  return;
1127 
1128  if (GetTypeId() == TYPEID_PLAYER)
1129  return;
1130 
1131  m_isActive = on;
1132 
1133  if (!IsInWorld())
1134  return;
1135 
1136  Map* map = FindMap();
1137  if (!map)
1138  return;
1139 
1140  if (on)
1141  {
1142  if (GetTypeId() == TYPEID_UNIT)
1143  map->AddToActive(ToCreature());
1144  else if (GetTypeId() == TYPEID_DYNAMICOBJECT)
1145  map->AddToActive((DynamicObject*)this);
1146  }
1147  else
1148  {
1149  if (GetTypeId() == TYPEID_UNIT)
1150  map->RemoveFromActive(ToCreature());
1151  else if (GetTypeId() == TYPEID_DYNAMICOBJECT)
1152  map->RemoveFromActive((DynamicObject*)this);
1153  }
1154 }
void RemoveFromActive(T *obj)
Definition: Map.h:511
uint8 GetTypeId() const
Definition: Object.h:210
const bool & IsInWorld() const
Definition: Object.h:135
Map * FindMap() const
Definition: Object.h:842
bool m_isActive
Definition: Object.h:932
Definition: Map.h:266
Creature * ToCreature()
Definition: Object.h:395
void AddToActive(T *obj)
Definition: Map.h:502
void WorldObject::SetLocationInstanceId ( uint32  _instanceId)
inlineprotected

Definition at line 943 of file Object.h.

Referenced by Corpse::LoadCorpseFromDB().

944  {
945  m_InstanceId = _instanceId;
946  }
uint32 m_InstanceId
Definition: Object.h:952
void WorldObject::SetLocationMapId ( uint32  _mapId)
inlineprotected

Definition at line 939 of file Object.h.

Referenced by Corpse::LoadCorpseFromDB().

940  {
941  m_mapId = _mapId;
942  }
uint32 m_mapId
Definition: Object.h:596
void WorldObject::SetMap ( Map map)
virtual

Reimplemented in Player.

Definition at line 1954 of file Object.cpp.

References Map::AddWorldObject(), ASSERT, Map::GetId(), Map::GetInstanceId(), Object::GetTypeId(), Object::IsInWorld(), IsWorldObject(), m_currMap, m_InstanceId, WorldLocation::m_mapId, sLog, and TYPEID_CORPSE.

Referenced by Corpse::Create(), Pet::Create(), Creature::Create(), GameObject::Create(), DynamicObject::CreateDynamicObject(), LoadHelper(), MapManager::LoadTransports(), Player::SetMap(), and Transport::TeleportTransport().

1955 {
1956  ASSERT(map);
1958  if (m_currMap == map) // command add npc: first create, than loadfromdb
1959  return;
1960  if (m_currMap)
1961  {
1962  sLog.outError("Crash alert! WorldObject::SetMap: obj %u new map %u %u, old map %u %u", (uint32)GetTypeId(), map->GetId(), map->GetInstanceId(), m_currMap->GetId(), m_currMap->GetInstanceId());
1963  ASSERT(false);
1964  }
1965  m_currMap = map;
1966  m_mapId = map->GetId();
1967  m_InstanceId = map->GetInstanceId();
1968  if (IsWorldObject())
1969  m_currMap->AddWorldObject(this);
1970 }
Map * m_currMap
Definition: Object.h:949
#define sLog
Log class singleton.
Definition: Log.h:187
bool IsWorldObject() const
Definition: Object.cpp:1112
uint32 m_InstanceId
Definition: Object.h:952
uint32 GetId(void) const
Definition: Map.h:333
uint8 GetTypeId() const
Definition: Object.h:210
uint32 m_mapId
Definition: Object.h:596
const bool & IsInWorld() const
Definition: Object.h:135
#define ASSERT
Definition: Errors.h:29
void AddWorldObject(WorldObject *obj)
Definition: Map.h:479
ACE_UINT32 uint32
Definition: Define.h:71
uint32 GetInstanceId() const
Definition: Map.h:390
void WorldObject::SetName ( const std::string &  newname)
inline
void WorldObject::SetNotified ( uint16  f)
inline

Definition at line 901 of file Object.h.

902  {
903  m_executed_notifies |= f;
904  }
uint16 m_executed_notifies
Definition: Object.h:956
void WorldObject::SetPhaseMask ( uint32  newPhaseMask,
bool  update 
)
virtual

Reimplemented in Unit, and GameObject.

Definition at line 2536 of file Object.cpp.

References Object::IsInWorld(), m_phaseMask, and UpdateObjectVisibility().

Referenced by ObjectAccessor::ConvertCorpseForPlayer(), Corpse::LoadCorpseFromDB(), GameObject::SetPhaseMask(), and Unit::SetPhaseMask().

2537 {
2538  m_phaseMask = newPhaseMask;
2539 
2540  if (update && IsInWorld())
2542 }
const bool & IsInWorld() const
Definition: Object.h:135
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:2599
uint32 m_phaseMask
Definition: Object.h:953
void WorldObject::SetWorldObject ( bool  apply)

Definition at line 1104 of file Object.cpp.

References Map::AddObjectToSwitchList(), GetMap(), and Object::IsInWorld().

Referenced by Unit::AddPlayerToVision(), and Unit::RemovePlayerFromVision().

1105 {
1106  if (!IsInWorld())
1107  return;
1108 
1109  GetMap()->AddObjectToSwitchList(this, on);
1110 }
Map * GetMap() const
Definition: Object.h:841
void AddObjectToSwitchList(WorldObject *obj, bool on)
Definition: Map.cpp:2045
const bool & IsInWorld() const
Definition: Object.h:135
void WorldObject::SetZoneScript ( )

Definition at line 2102 of file Object.cpp.

References FindMap(), GetZoneId(), m_zoneScript, and sOutdoorPvPMgr.

Referenced by GameObject::Create(), and Creature::CreateFromProto().

2103 {
2104  if (Map* map = FindMap())
2105  {
2106  if (map->IsDungeon())
2107  m_zoneScript = (ZoneScript*)((InstanceMap*)map)->GetInstanceData();
2108  else if (!map->IsBattlegroundOrArena())
2109  m_zoneScript = sOutdoorPvPMgr.GetZoneScript(GetZoneId());
2110  }
2111 }
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:79
uint32 GetZoneId() const
Definition: Object.cpp:1179
ZoneScript * m_zoneScript
Definition: Object.h:934
Map * FindMap() const
Definition: Object.h:842
Definition: Map.h:266
TempSummon * WorldObject::SummonCreature ( uint32  id,
const Position pos,
TempSummonType  spwtype = TEMPSUMMON_MANUAL_DESPAWN,
uint32  despwtime = 0 
)

Definition at line 2091 of file Object.cpp.

References FindMap(), Object::isType(), SummonCreature(), and TYPEMASK_UNIT.

Referenced by CinematicMgr::BeginCinematic(), ScriptedAI::DoSpawnCreature(), CreatureAI::DoSummon(), CreatureAI::DoSummonFlyer(), Spell::EffectDummy(), Spell::EffectSummonType(), Aura::HandleAuraDummy(), ChatHandler::HandleTempAddSpwCommand(), GameObjectModel::initialize(), SmartScript::ProcessAction(), CreatureEventAI::ProcessAction(), SummonCreature(), SummonCreatureGroup(), SummonTrigger(), and Aura::TriggerSpell().

2092 {
2093  if (Map* map = FindMap())
2094  {
2095  if (TempSummon* summon = map->SummonCreature(entry, pos, NULL, duration, isType(TYPEMASK_UNIT) ? (Unit*)this : NULL, NULL, spwtype))
2096  return summon;
2097  }
2098 
2099  return NULL;
2100 }
bool isType(uint16 mask) const
Definition: Object.h:214
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2091
Map * FindMap() const
Definition: Object.h:842
Definition: Map.h:266
Definition: Unit.h:908
TempSummon* WorldObject::SummonCreature ( uint32  id,
float  x,
float  y,
float  z,
float  ang,
TempSummonType  spwtype = TEMPSUMMON_MANUAL_DESPAWN,
uint32  despwtime = 0 
)
inline

Definition at line 854 of file Object.h.

References GetCreatureListWithEntryInGrid(), GetGameObjectListWithEntryInGrid(), and GRID_SEARCH_ALL_ENTRIES.

855  {
856  if (!x && !y && !z)
857  {
858  GetClosePoint(x, y, z, GetObjectSize());
859  ang = GetOrientation();
860  }
861  Position pos = {x, y, z, ang};
862  return SummonCreature(id, pos, spwtype, despwtime);
863  }
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2091
float GetOrientation() const
Definition: Position.h:100
float GetObjectSize() const
Definition: Object.h:669
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
Definition: Object.h:646
void WorldObject::SummonCreatureGroup ( uint8  group,
std::list< TempSummon * > *  list = NULL 
)

Summons group of creatures. Should be called only by instances of Creature and GameObject classes.

Parameters
groupId of group to summon.
listList to store pointers to summoned creatures.

Definition at line 2278 of file Object.cpp.

References ASSERT, Object::GetEntry(), Object::GetTypeId(), sObjectMgr, SummonCreature(), SUMMONER_TYPE_CREATURE, SUMMONER_TYPE_GAMEOBJECT, TYPEID_GAMEOBJECT, and TYPEID_UNIT.

2279 {
2280  ASSERT((GetTypeId() == TYPEID_GAMEOBJECT || GetTypeId() == TYPEID_UNIT) && "Only GOs and creatures can summon npc groups!");
2281 
2282  std::vector<TempSummonData> const* data = sObjectMgr.GetSummonGroup(GetEntry(), GetTypeId() == TYPEID_GAMEOBJECT ? SUMMONER_TYPE_GAMEOBJECT : SUMMONER_TYPE_CREATURE, group);
2283  if (!data)
2284  return;
2285 
2286  for (std::vector<TempSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr)
2287  if (TempSummon* summon = SummonCreature(itr->entry, itr->pos, itr->type, itr->time))
2288  if (list)
2289  list->push_back(summon);
2290 }
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2091
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint8 GetTypeId() const
Definition: Object.h:210
#define ASSERT
Definition: Errors.h:29
uint32 GetEntry() const
Definition: Object.h:192
GameObject * WorldObject::SummonGameObject ( uint32  entry,
float  x,
float  y,
float  z,
float  ang,
float  rotation0,
float  rotation1,
float  rotation2,
float  rotation3,
uint32  respawnTime 
)

Definition at line 2225 of file Object.cpp.

References GameObject::Create(), GetMap(), Object::GetTypeId(), GO_STATE_READY, HIGHGUID_GAMEOBJECT, Object::IsInWorld(), PHASEMASK_NORMAL, GameObject::SetRespawnTime(), GameObject::SetSpawnedByDefault(), sLog, sObjectMgr, TYPEID_PLAYER, and TYPEID_UNIT.

Referenced by Spell::EffectDummy(), ChatHandler::HandleTempGameObjectCommand(), and CreatureEventAI::ProcessAction().

2226 {
2227  if (!IsInWorld())
2228  return NULL;
2229 
2230  GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(entry);
2231  if (!goinfo)
2232  {
2233  sLog.outErrorDb("Gameobject template %u not found in database!", entry);
2234  return NULL;
2235  }
2236  Map* map = GetMap();
2237  GameObject* go = new GameObject();
2238  if (!go->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, PHASEMASK_NORMAL, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, 100, GO_STATE_READY))
2239  {
2240  delete go;
2241  return NULL;
2242  }
2243  go->SetRespawnTime(respawnTime);
2244  if (GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT) //not sure how to handle this
2245  ((Unit*)this)->AddGameObject(go);
2246  else
2247  go->SetSpawnedByDefault(false);
2248  map->AddToMap(go);
2249 
2250  return go;
2251 }
Map * GetMap() const
Definition: Object.h:841
#define sLog
Log class singleton.
Definition: Log.h:187
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:693
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint8 GetTypeId() const
Definition: Object.h:210
const bool & IsInWorld() const
Definition: Object.h:135
void SetSpawnedByDefault(bool b)
Definition: GameObject.h:709
Definition: Map.h:266
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
Definition: Unit.h:908
Creature * WorldObject::SummonTrigger ( float  x,
float  y,
float  z,
float  ang,
uint32  dur,
CreatureAI *(*)(Creature *)  GetAI = NULL 
)

Definition at line 2253 of file Object.cpp.

References Creature::AIM_Initialize(), Object::GetTypeId(), Unit::SetFaction(), Unit::SetLevel(), SummonCreature(), TEMPSUMMON_DEAD_DESPAWN, TEMPSUMMON_TIMED_DESPAWN, TYPEID_PLAYER, TYPEID_UNIT, and WORLD_TRIGGER.

Referenced by GameObject::CastSpell(), and ChatHandler::HandleSpellCrashTestCommand().

2254 {
2255  TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
2256  Creature* summon = SummonCreature(WORLD_TRIGGER, x, y, z, ang, summonType, duration);
2257  if (!summon)
2258  return NULL;
2259 
2260  //summon->SetName(GetName());
2261  if (GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT)
2262  {
2263  summon->SetFaction(((Unit*)this)->GetFaction());
2264  summon->SetLevel(((Unit*)this)->getLevel());
2265  }
2266 
2267  if (GetAI)
2268  summon->AIM_Initialize(GetAI(summon));
2269  return summon;
2270 }
#define WORLD_TRIGGER
Definition: Unit.h:38
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2091
bool AIM_Initialize(CreatureAI *ai=NULL)
Definition: Creature.cpp:746
despawns when the creature disappears
despawns after a specified time
uint8 GetTypeId() const
Definition: Object.h:210
TempSummonType
void SetFaction(uint32 faction)
Definition: Unit.h:1117
void SetLevel(uint32 lvl)
Definition: Unit.cpp:10896
Definition: Unit.h:908
virtual void WorldObject::Update ( uint32  )
inlinevirtual

Reimplemented in Player, Unit, GameObject, Creature, Pet, Puppet, TempSummon, DynamicObject, Totem, and Transport.

Definition at line 639 of file Object.h.

639 { }
void WorldObject::UpdateAllowedPositionZ ( float  x,
float  y,
float &  z 
) const

Definition at line 1419 of file Object.cpp.

References GetBaseMap(), Map::GetHeight(), Object::GetTypeId(), Map::GetWaterOrGroundLevel(), INVALID_HEIGHT, SPELL_AURA_WATER_WALK, TYPEID_PLAYER, and TYPEID_UNIT.

Referenced by GetNearPoint(), and PathInfo::NormalizePath().

1420 {
1421  switch (GetTypeId())
1422  {
1423  case TYPEID_UNIT:
1424  {
1425  // non fly unit don't must be in air
1426  // non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast
1427  if (!((Creature const*)this)->CanFly())
1428  {
1429  bool canSwim = ((Creature const*)this)->CanSwim();
1430  float ground_z = z;
1431  float max_z = canSwim
1432  ? GetBaseMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK))
1433  : ((ground_z = GetBaseMap()->GetHeight(x, y, z, true)));
1434  if (max_z > INVALID_HEIGHT)
1435  {
1436  if (z > max_z)
1437  z = max_z;
1438  else if (z < ground_z)
1439  z = ground_z;
1440  }
1441  }
1442  else
1443  {
1444  float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
1445  if (z < ground_z)
1446  z = ground_z;
1447  }
1448  break;
1449  }
1450  case TYPEID_PLAYER:
1451  {
1452  // for server controlled moves playr work same as creature (but it can always swim)
1453  if (!((Player const*)this)->CanFly())
1454  {
1455  float ground_z = z;
1456  float max_z = GetBaseMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK));
1457  if (max_z > INVALID_HEIGHT)
1458  {
1459  if (z > max_z)
1460  z = max_z;
1461  else if (z < ground_z)
1462  z = ground_z;
1463  }
1464  }
1465  else
1466  {
1467  float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
1468  if (z < ground_z)
1469  z = ground_z;
1470  }
1471  break;
1472  }
1473  default:
1474  {
1475  float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
1476  if (ground_z > INVALID_HEIGHT)
1477  z = ground_z;
1478  break;
1479  }
1480  }
1481 }
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:1591
float GetWaterOrGroundLevel(float x, float y, float z, float *ground=NULL, bool swim=false) const
Definition: Map.cpp:1573
uint8 GetTypeId() const
Definition: Object.h:210
Map const * GetBaseMap() const
Definition: Object.cpp:1984
#define INVALID_HEIGHT
Definition: Map.h:259
Definition: Unit.h:908
Definition: Player.h:922
void WorldObject::UpdateGroundPositionZ ( float  x,
float  y,
float &  z 
) const

Definition at line 1483 of file Object.cpp.

References GetBaseMap(), Map::GetHeight(), and INVALID_HEIGHT.

Referenced by GetRandomPoint(), Player::HandleFallDamage(), CreatureGroup::LeaderMoveTo(), and MovePosition().

1484 {
1485  float new_z = GetBaseMap()->GetHeight(x, y, z, true);
1486  if (new_z > INVALID_HEIGHT)
1487  z = new_z + 0.05f; // just to be sure that we are not a few pixel under the surface
1488 }
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:1591
Map const * GetBaseMap() const
Definition: Object.cpp:1984
#define INVALID_HEIGHT
Definition: Map.h:259
void WorldObject::UpdateObjectVisibility ( bool  forced = true)
virtual

Reimplemented in Player, and Unit.

Definition at line 2599 of file Object.cpp.

References GetVisibilityRange(), and VisitNearbyWorldObject().

Referenced by ChatHandler::HandleMoveObjectCommand(), ChatHandler::HandleTurnObjectCommand(), SetPhaseMask(), GameObject::Update(), and Unit::UpdateObjectVisibility().

2600 {
2601  //updates object's visibility for nearby players
2602  Oregon::VisibleChangesNotifier notifier(*this);
2604 }
float GetVisibilityRange() const
Definition: Object.cpp:1552
void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const
Definition: Object.h:920
virtual void WorldObject::UpdateObjectVisibilityOnCreate ( )
inlinevirtual

Definition at line 877 of file Object.h.

878  {
880  }
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:2599
template<class NOTIFIER >
void WorldObject::VisitNearbyGridObject ( float const &  radius,
NOTIFIER &  notifier 
) const
inline

Definition at line 922 of file Object.h.

Referenced by Spell::FillTargetMap(), FindNearestGameObject(), FindNearestGameObjectOfType(), Creature::SelectNearestHostileUnitInAggroRange(), and GameObject::Update().

922 { if (IsInWorld()) GetMap()->VisitGrid(GetPositionX(), GetPositionY(), radius, notifier); }
Map * GetMap() const
Definition: Object.h:841
const bool & IsInWorld() const
Definition: Object.h:135
float GetPositionY() const
Definition: Position.h:98
void VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
Definition: Map.h:794
float GetPositionX() const
Definition: Position.h:97
template<class NOTIFIER >
void WorldObject::VisitNearbyObject ( float const &  radius,
NOTIFIER &  notifier 
) const
inline

Definition at line 921 of file Object.h.

Referenced by ScriptedAI::DoFindFriendlyCC(), ScriptedAI::DoFindFriendlyMissingBuff(), ScriptedAI::DoSelectLowestHpFriendly(), FindNearestCreature(), SmartScript::GetWorldObjectsInDist(), Aura::HandleFeignDeath(), Spell::SearchNearbyTarget(), DynamicObject::Update(), AreaAura::Update(), TotemAI::UpdateAI(), and Player::UpdateVisibilityForPlayer().

921 { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); }
Map * GetMap() const
Definition: Object.h:841
const bool & IsInWorld() const
Definition: Object.h:135
float GetPositionY() const
Definition: Position.h:98
void VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier)
float GetPositionX() const
Definition: Position.h:97
template<class NOTIFIER >
void WorldObject::VisitNearbyWorldObject ( const float &  radius,
NOTIFIER &  notifier 
) const
inline

Definition at line 920 of file Object.h.

Referenced by DestroyForNearbyPlayers(), Spell::FillTargetMap(), CreatureTextMgr::SendChatPacket(), SendMessageToSetInRange(), Player::SendMessageToSetInRange(), OPvPCapturePoint::Update(), GameObject::Update(), and UpdateObjectVisibility().

920 { if (IsInWorld()) GetMap()->VisitWorld(GetPositionX(), GetPositionY(), radius, notifier); }
Map * GetMap() const
Definition: Object.h:841
const bool & IsInWorld() const
Definition: Object.h:135
float GetPositionY() const
Definition: Position.h:98
void VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier)
Definition: Map.h:783
float GetPositionX() const
Definition: Position.h:97

Member Data Documentation

uint64 WorldObject::lootingGroupLeaderGUID

Definition at line 925 of file Object.h.

Referenced by Creature::Update(), and GameObject::Update().

Map* WorldObject::m_currMap
private

Definition at line 949 of file Object.h.

Referenced by GetBaseMap(), ResetMap(), and SetMap().

uint16 WorldObject::m_executed_notifies
private

Definition at line 956 of file Object.h.

uint32 WorldObject::m_groupLootTimer

Definition at line 924 of file Object.h.

Referenced by Creature::Update(), and GameObject::Update().

uint32 WorldObject::m_InstanceId
private

Definition at line 952 of file Object.h.

Referenced by SetMap().

bool WorldObject::m_isActive
protected

Definition at line 932 of file Object.h.

Referenced by Player::Player(), and setActive().

const bool WorldObject::m_isWorldObject
protected

Definition at line 933 of file Object.h.

Referenced by IsWorldObject(), and DynamicObject::RemoveFromWorld().

std::string WorldObject::m_name
protected
uint16 WorldObject::m_notifyflags
private

Definition at line 955 of file Object.h.

uint32 WorldObject::m_phaseMask
private

Definition at line 953 of file Object.h.

Referenced by _Create(), and SetPhaseMask().

Definition at line 828 of file Object.h.

Referenced by CanDetectStealthOf(), and Aura::HandleModStealthDetect().


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