OregonCore  revision 3611e8a-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)
 
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
 
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 *seer) 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
 

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
 
uint16 m_notifyflags
 
uint16 m_executed_notifies
 

Additional Inherited Members

- Static Public Member Functions inherited from Position
static float NormalizeOrientation (float o)
 

Detailed Description

Definition at line 628 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:1969
Definition: Corpse.h:48
Map * m_currMap
Definition: Object.h:937
#define sLog
Log class singleton.
Definition: Log.h:187
bool IsWorldObject() const
Definition: Object.cpp:1111
uint8 GetTypeId() const
Definition: Object.h:204
#define UI64FMTD
Definition: Common.h:149
#define ASSERT
Definition: Errors.h:33
uint32 GetEntry() const
Definition: Object.h:186
const uint64 & GetGUID() const
Definition: Object.h:156
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)
1098 {
1101 }
const bool m_isWorldObject
Definition: Object.h:921
Map * m_currMap
Definition: Object.h:937
std::string m_name
Definition: Object.h:919
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:821
uint64 lootingGroupLeaderGUID
Definition: Object.h:913
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:620
uint32 m_InstanceId
Definition: Object.h:940
uint16 m_notifyflags
Definition: Object.h:942
ZoneScript * m_zoneScript
Definition: Object.h:922
bool m_isActive
Definition: Object.h:920
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:822
uint32 m_groupLootTimer
Definition: Object.h:912
uint16 m_executed_notifies
Definition: Object.h:943
WorldLocation(uint32 _mapid=MAPID_INVALID, float _x=0, float _y=0, float _z=0, float _o=0)
Definition: Object.h:570

Member Function Documentation

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

Definition at line 1161 of file Object.cpp.

References Object::_Create().

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

1162 {
1163  Object::_Create(guidlow, 0, guidhigh);
1164 }
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:125
bool WorldObject::_IsWithinDist ( WorldObject const *  obj,
float  dist2compare,
bool  is3D 
) const

Definition at line 1210 of file Object.cpp.

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

1211 {
1212  float dx = GetPositionX() - obj->GetPositionX();
1213  float dy = GetPositionY() - obj->GetPositionY();
1214  float distsq = dx * dx + dy * dy;
1215  if (is3D)
1216  {
1217  float dz = GetPositionZ() - obj->GetPositionZ();
1218  distsq += dz * dz;
1219  }
1220  float sizefactor = GetObjectSize() + obj->GetObjectSize();
1221  float maxdist = dist2compare + sizefactor;
1222 
1223  return distsq < maxdist * maxdist;
1224 }
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:663
void WorldObject::AddObjectToRemoveList ( )

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

1988 {
1990 
1991  Map* map = FindMap();
1992  if (!map)
1993  {
1994  sLog.outError("Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list has invalid map (Id: %u).", GetTypeId(), GetEntry(), GetGUIDLow(), GetMapId());
1995  return;
1996  }
1997 
1998  map->AddObjectToRemoveList(this);
1999 }
uint32 * m_uint32Values
Definition: Object.h:426
#define sLog
Log class singleton.
Definition: Log.h:187
void AddObjectToRemoveList(WorldObject *obj)
Definition: Map.cpp:2037
uint32 GetGUIDLow() const
Definition: Object.h:160
uint8 GetTypeId() const
Definition: Object.h:204
Map * FindMap() const
Definition: Object.h:830
uint32 GetMapId() const
Definition: Object.h:585
Definition: Map.h:266
#define ASSERT
Definition: Errors.h:33
uint32 GetEntry() const
Definition: Object.h:186
void WorldObject::AddToNotify ( uint16  f)
inline

Definition at line 873 of file Object.h.

Referenced by Player::UpdateObjectVisibility().

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

Definition at line 1904 of file Object.cpp.

References Object::GetGUID(), and IS_PLAYER_GUID.

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

1905 {
1906  *data << (uint8)msgtype;
1907  *data << (uint32)language;
1908  *data << (uint64)GetGUID();
1909  *data << (uint32)0; //2.1.0
1910  *data << (uint32)(strlen(name) + 1);
1911  *data << name;
1912  *data << (uint64)targetGuid; //Unit Target
1913  if (targetGuid && !IS_PLAYER_GUID(targetGuid))
1914  {
1915  *data << (uint32)1; // target name length
1916  *data << (uint8)0; // target name
1917  }
1918  *data << (uint32)(strlen(text) + 1);
1919  *data << text;
1920  *data << (uint8)0; // ChatTag
1921 }
#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:156
void WorldObject::BuildUpdate ( UpdateDataMapType data_map)
overridevirtual

Reimplemented from Object.

Definition at line 2654 of file Object.cpp.

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

2655 {
2657  Cell cell(p);
2658  cell.SetNoCreate();
2659  WorldObjectChangeAccumulator notifier(*this, data_map);
2661  Map& map = *GetMap();
2662  //we must build packets for all visible players
2663  cell.Visit(p, player_notifier, map, *this, GetVisibilityRange());
2664 
2665  ClearUpdateMask(false);
2666 }
void ClearUpdateMask(bool remove)
Definition: Object.cpp:678
Map * GetMap() const
Definition: Object.h:829
float GetVisibilityRange() const
Definition: Object.cpp:1549
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 946 of file Object.h.

Referenced by CanSeeOrDetect().

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

Definition at line 1665 of file Object.cpp.

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

Referenced by CanSeeOrDetect().

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

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

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

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

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

Definition at line 1660 of file Object.cpp.

References GetMap().

Referenced by CanSeeOrDetect().

1661 {
1662  return GetMap() != obj->GetMap();
1663 }
Map * GetMap() const
Definition: Object.h:829
bool WorldObject::CanSeeOrDetect ( WorldObject const *  obj,
bool  ignoreStealth = false,
bool  distanceCheck = false,
bool  checkAlert = false 
) const

Definition at line 1582 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(), Oregon::NearestAttackableUnitInObjectRangeCheck::operator()(), Spell::SearchChainTarget(), Creature::SelectVictim(), TotemAI::UpdateAI(), HostileRefManager::UpdateVisibility(), and Player::UpdateVisibilityOf().

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

Reimplemented in Player, Unit, and GameObject.

Definition at line 1155 of file Object.cpp.

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

Referenced by Map::AddObjectToRemoveList().

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

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

2555 {
2556  if (!IsInWorld())
2557  return;
2558 
2559  std::list<Player*> targets;
2563  for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
2564  {
2565  Player* player = (*iter);
2566 
2567  if (player == this)
2568  continue;
2569 
2570  if (!player->HaveAtClient(this))
2571  continue;
2572 
2573  if (isType(TYPEMASK_UNIT) && ((Unit*)this)->GetCharmerGUID() == player->GetGUID()) // @todo this is for puppet
2574  continue;
2575 
2576  if (GetTypeId() == TYPEID_UNIT)
2577  {
2578  // at remove from world (destroy) show kill animation
2579  DestroyForPlayer(player, ToUnit()->IsDuringRemoveFromWorld() && ToCreature()->isDead());
2580  }
2581  else
2582  DestroyForPlayer(player);
2583 
2584  player->m_clientGUIDs.erase(GetGUID());
2585  }
2586 }
ClientGUIDs m_clientGUIDs
Definition: Player.h:2471
bool isType(uint16 mask) const
Definition: Object.h:208
float GetVisibilityRange() const
Definition: Object.cpp:1549
uint8 GetTypeId() const
Definition: Object.h:204
virtual void DestroyForPlayer(Player *target, bool onDeath=false) const
Definition: Object.cpp:241
const bool & IsInWorld() const
Definition: Object.h:129
bool HaveAtClient(WorldObject const *u) const
Definition: Player.cpp:18670
Creature * ToCreature()
Definition: Object.h:389
Definition: Unit.h:884
Definition: Player.h:922
Unit * ToUnit()
Definition: Object.h:392
void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const
Definition: Object.h:908
const uint64 & GetGUID() const
Definition: Object.h:156
Creature * WorldObject::FindNearestCreature ( uint32  entry,
float  range,
bool  alive = true 
)

Definition at line 2289 of file Object.cpp.

References VisitNearbyObject().

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

2290 {
2291  Creature* creature = NULL;
2292  Oregon::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range);
2294  VisitNearbyObject(range, searcher);
2295  return creature;
2296 }
void VisitNearbyObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:909
GameObject * WorldObject::FindNearestGameObject ( uint32  entry,
float  range 
)

Definition at line 2298 of file Object.cpp.

References VisitNearbyGridObject().

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

2299 {
2300  GameObject* go = NULL;
2301  Oregon::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range);
2303  VisitNearbyGridObject(range, searcher);
2304  return go;
2305 }
void VisitNearbyGridObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:910
GameObject * WorldObject::FindNearestGameObjectOfType ( GameobjectTypes  type,
float  range 
) const

Definition at line 2307 of file Object.cpp.

References VisitNearbyGridObject().

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

Definition at line 640 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::HandleGroupgoCommand(), ChatHandler::HandleNamegoCommand(), Pet::LoadPetFromDB(), Spell::SetTargetMap(), and Spell::SummonClassPet().

641  {
642  // angle calculated from current orientation
643  GetNearPoint(NULL, x, y, z, size, distance2d, GetOrientation() + angle);
644  }
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:2351
void WorldObject::GetContactPoint ( const WorldObject obj,
float &  x,
float &  y,
float &  z,
float  distance2d = CONTACT_DISTANCE 
) const
inline

Definition at line 652 of file Object.h.

References GetObjectSize().

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

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

Definition at line 2329 of file Object.cpp.

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

Referenced by GetCreatureListWithEntryInGrid().

2330 {
2332  Cell cell(pair);
2333  cell.SetNoCreate();
2334 
2335  Oregon::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange);
2338 
2339  cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
2340 }
Map * GetMap() const
Definition: Object.h:829
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 711 of file Object.h.

712  {
713  float d = GetExactDist(&pos) - GetObjectSize();
714  return d > 0.0f ? d : 0.0f;
715  }
float GetExactDist(float x, float y, float z) const
Definition: Position.h:150
float GetObjectSize() const
Definition: Object.h:663
float WorldObject::GetDistance ( float  x,
float  y,
float  z 
) const
inline

Definition at line 716 of file Object.h.

717  {
718  float d = GetExactDist(x, y, z) - GetObjectSize();
719  return d > 0.0f ? d : 0.0f;
720  }
float GetExactDist(float x, float y, float z) const
Definition: Position.h:150
float GetObjectSize() const
Definition: Object.h:663
float WorldObject::GetDistance2d ( const WorldObject obj) const
inline

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

722  {
723  float d = GetExactDist2d(obj) - GetObjectSize() - obj->GetObjectSize();
724  return d > 0.0f ? d : 0.0f;
725  }
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:130
float GetObjectSize() const
Definition: Object.h:663
float WorldObject::GetDistance2d ( float  x,
float  y 
) const
inline

Definition at line 726 of file Object.h.

727  {
728  float d = GetExactDist2d(x, y) - GetObjectSize();
729  return d > 0.0f ? d : 0.0f;
730  }
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:130
float GetObjectSize() const
Definition: Object.h:663
bool WorldObject::GetDistanceOrder ( WorldObject const *  obj1,
WorldObject const *  obj2,
bool  is3D = true 
) const

Definition at line 1273 of file Object.cpp.

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

1274 {
1275  float dx1 = GetPositionX() - obj1->GetPositionX();
1276  float dy1 = GetPositionY() - obj1->GetPositionY();
1277  float distsq1 = dx1 * dx1 + dy1 * dy1;
1278  if (is3D)
1279  {
1280  float dz1 = GetPositionZ() - obj1->GetPositionZ();
1281  distsq1 += dz1 * dz1;
1282  }
1283 
1284  float dx2 = GetPositionX() - obj2->GetPositionX();
1285  float dy2 = GetPositionY() - obj2->GetPositionY();
1286  float distsq2 = dx2 * dx2 + dy2 * dy2;
1287  if (is3D)
1288  {
1289  float dz2 = GetPositionZ() - obj2->GetPositionZ();
1290  distsq2 += dz2 * dz2;
1291  }
1292 
1293  return distsq1 < distsq2;
1294 }
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 1200 of file Object.cpp.

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

1201 {
1202  float dx = GetPositionX() - x;
1203  float dy = GetPositionY() - y;
1204  float dz = GetPositionZ() - z;
1205  float sizefactor = GetObjectSize();
1206  float dist = dx * dx + dy * dy + dz * dz - sizefactor;
1207  return (dist > 0 ? dist : 0);
1208 }
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:663
float WorldObject::GetDistanceZ ( const WorldObject obj) const

Definition at line 1192 of file Object.cpp.

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

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

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

Definition at line 2365 of file Object.cpp.

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

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

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

Definition at line 2316 of file Object.cpp.

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

Referenced by GetGameObjectListWithEntryInGrid().

2317 {
2319  Cell cell(pair);
2320  cell.SetNoCreate();
2321 
2322  Oregon::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
2325 
2326  cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
2327 }
Map * GetMap() const
Definition: Object.h:829
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 1528 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(), TotemAI::UpdateAI(), and Map::VisitNearbyCellsOf().

1529 {
1530  if (ToPlayer())
1531  {
1532  if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
1534  return GetMap()->GetVisibilityRange();
1535  }
1536  else if (ToCreature())
1537  return ToCreature()->m_SightDistance;
1538  else if (ToDynObject())
1539  {
1540  if (isActiveObject())
1541  return GetMap()->GetVisibilityRange();
1542  else
1543  return 0.0f;
1544  }
1545  else
1546  return 0.0f;
1547 }
Map * GetMap() const
Definition: Object.h:829
#define DEFAULT_VISIBILITY_INSTANCE
Definition: Object.h:41
DynamicObject * ToDynObject()
Definition: Object.h:401
Player * ToPlayer()
Definition: Object.h:386
bool isActiveObject() const
Definition: Object.h:899
float GetVisibilityRange() const
Definition: Map.h:291
Creature * ToCreature()
Definition: Object.h:389
float m_SightDistance
Definition: Creature.h:864
Position WorldObject::GetHitSpherePointFor ( Position const &  dest) const

Definition at line 1256 of file Object.cpp.

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

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

1257 {
1258  G3D::Vector3 vThis(GetPositionX(), GetPositionY(), GetPositionZ());
1259  G3D::Vector3 vObj(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
1260  G3D::Vector3 contactPoint = vThis + (vObj - vThis).directionOrZero() * GetObjectSize();
1261 
1262  return Position(contactPoint.x, contactPoint.y, contactPoint.z, GetAngle(contactPoint.x, contactPoint.y));
1263 }
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:663
void WorldObject::GetHitSpherePointFor ( Position const &  dest,
float &  x,
float &  y,
float &  z 
) const

Definition at line 1265 of file Object.cpp.

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

1266 {
1267  Position pos = GetHitSpherePointFor(dest);
1268  x = pos.GetPositionX();
1269  y = pos.GetPositionY();
1270  z = pos.GetPositionZ();
1271 }
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1256
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 1186 of file Object.cpp.

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

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

1187 {
1188  Map* map = GetMap();
1189  return map->IsDungeon() ? ((InstanceMap*)map)->GetInstanceData() : NULL;
1190 }
Map * GetMap() const
Definition: Object.h:829
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 780 of file Object.h.

Referenced by CanDetectStealthOf().

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

Definition at line 829 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(), 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(), ChatHandler::HandleGonameCommand(), WorldSession::HandleGossipSelectOptionOpcode(), ChatHandler::HandleGPSCommand(), ChatHandler::HandleGroupgoCommand(), ChatHandler::HandleInstanceSaveDataCommand(), WorldSession::HandleLootMasterGiveOpcode(), WorldSession::HandleLootMoneyOpcode(), Aura::HandleModPossessPet(), WorldSession::HandleMoveWorldportAckOpcode(), ChatHandler::HandleNamegoCommand(), ChatHandler::HandleNpcAddCommand(), ChatHandler::HandleNpcDeleteCommand(), ChatHandler::HandleNpcMoveCommand(), ChatHandler::HandleNpcWhisperCommand(), WorldSession::HandlePlayerLogin(), WorldSession::HandleQuestgiverStatusQueryMultipleOpcode(), ChatHandler::HandleRespawnCommand(), ChatHandler::HandleTargetObjectCommand(), WorldSession::HandleTotemDestroy(), ChatHandler::HandleWpModifyCommand(), ChatHandler::HandleWpShowCommand(), Group::InCombatToInstance(), Creature::InitEntry(), TempSummon::InitStats(), 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(), TotemAI::UpdateAI(), GameObject::UpdateModel(), GameObject::UpdateModelPosition(), Creature::UpdateMovementFlags(), Player::UpdateTriggerVisibility(), GameObject::Use(), and ObjectGridEvacuator::Visit().

829 { ASSERT(m_currMap); return m_currMap; }
Map * m_currMap
Definition: Object.h:937
#define ASSERT
Definition: Errors.h:33
const char* WorldObject::GetName ( ) const
inline

Definition at line 692 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(), Player::GetGameObjectIfCanInteractWith(), ChatHandler::GetName(), GameObject::GetNameForLocaleIdx(), Creature::GetNameForLocaleIdx(), WorldSession::GetPlayerName(), ReputationMgr::GetReputation(), WorldSession::HandleAcceptGrantLevel(), WorldSession::HandleAcceptTradeOpcode(), ChatHandler::HandleAccountSetGmLevelCommand(), WorldSession::HandleAddFriendOpcodeCallBack(), ChatHandler::HandleAddItemCommand(), 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::HandleGonameCommand(), ChatHandler::HandleGPSCommand(), WorldSession::HandleGrantLevel(), WorldSession::HandleGroupDeclineOpcode(), ChatHandler::HandleGroupgoCommand(), WorldSession::HandleGroupInviteOpcode(), ChatHandler::HandleGroupJoinCommand(), 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::HandleNamegoCommand(), 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(), 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().

693  {
694  return m_name.c_str();
695  }
std::string m_name
Definition: Object.h:919
virtual const char* WorldObject::GetNameForLocaleIdx ( int32  ) const
inlinevirtual

Reimplemented in Creature, and GameObject.

Definition at line 701 of file Object.h.

Referenced by CreatureTextMgr::BuildMonsterChat().

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

Definition at line 2351 of file Object.cpp.

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

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

2352 {
2353  GetNearPoint2D(x, y, distance2d + searcher_size, absAngle);
2354  z = GetPositionZ();
2355  UpdateAllowedPositionZ(x, y, z);
2356 }
void UpdateAllowedPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1416
float GetPositionZ() const
Definition: Position.h:99
void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const
Definition: Object.cpp:2342
void WorldObject::GetNearPoint2D ( float &  x,
float &  y,
float  distance,
float  absAngle 
) const

Definition at line 2342 of file Object.cpp.

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

Referenced by GetNearPoint().

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

Definition at line 2358 of file Object.cpp.

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

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

2359 {
2360  Position pos = GetPosition();
2361  MovePosition(pos, dist, angle);
2362  return pos;
2363 }
void MovePosition(Position &pos, float dist, float angle)
Definition: Object.cpp:2419
Position GetPosition() const
Definition: Position.h:117
uint16 WorldObject::GetNotifyFlags ( ) const
inline

Definition at line 881 of file Object.h.

882  {
883  return m_notifyflags;
884  }
uint16 m_notifyflags
Definition: Object.h:942
virtual float WorldObject::GetObjectBoundingRadius ( ) const
inlinevirtual

Definition at line 658 of file Object.h.

References DEFAULT_WORLD_OBJECT_SIZE.

Referenced by Spell::EffectDummy().

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

Definition at line 2382 of file Object.cpp.

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

Referenced by MovePositionToFirstCollision().

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

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

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

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

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

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

Definition at line 671 of file Object.h.

References Position::Relocate().

672  {
673  float x, y, z;
674  GetRandomPoint(srcPos, distance, x, y, z);
675  pos.Relocate(x, y, z, GetOrientation());
676  }
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:1395
float WorldObject::GetSightRange ( const WorldObject target = NULL) const

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

1558 {
1559  if (ToUnit())
1560  {
1561  if (ToPlayer())
1562  {
1563  if (target && target->isActiveObject() && !target->ToPlayer())
1564  return MAX_VISIBILITY_DISTANCE;
1565  else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
1567  else
1568  return GetMap()->GetVisibilityRange();
1569  }
1570  else if (ToCreature())
1571  return ToCreature()->m_SightDistance;
1572  else
1573  return SIGHT_RANGE_UNIT;
1574  }
1575 
1576  if (ToDynObject() && isActiveObject())
1577  return GetMap()->GetVisibilityRange();
1578 
1579  return 0.0f;
1580 }
Map * GetMap() const
Definition: Object.h:829
#define DEFAULT_VISIBILITY_INSTANCE
Definition: Object.h:41
DynamicObject * ToDynObject()
Definition: Object.h:401
#define SIGHT_RANGE_UNIT
Definition: Object.h:39
Player * ToPlayer()
Definition: Object.h:386
CinematicMgr * GetCinematicMgr() const
Definition: Player.h:1255
bool isActiveObject() const
Definition: Object.h:899
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:389
float m_SightDistance
Definition: Creature.h:864
Unit * ToUnit()
Definition: Object.h:392
float WorldObject::GetVisibilityRange ( ) const

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

1550 {
1551  if (isActiveObject() && !ToPlayer())
1552  return MAX_VISIBILITY_DISTANCE;
1553  else
1554  return GetMap()->GetVisibilityRange();
1555 }
Map * GetMap() const
Definition: Object.h:829
Player * ToPlayer()
Definition: Object.h:386
bool isActiveObject() const
Definition: Object.h:899
float GetVisibilityRange() const
Definition: Map.h:291
#define MAX_VISIBILITY_DISTANCE
Definition: Object.h:38
uint32 WorldObject::GetZoneId ( ) const

Definition at line 1176 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::HandleNamegoCommand(), ChatHandler::HandleNearGraveCommand(), WorldSession::HandleRequestPartyMemberStatsOpcode(), WorldSession::LogoutPlayer(), MonsterYellToZone(), Player::ResurrectPlayer(), Corpse::SaveToDB(), Player::SaveToDB(), CreatureTextMgr::SendChatPacket(), Player::SendInitialPacketsBeforeAddToMap(), Player::SendInitWorldStates(), WorldSession::SendLfgResult(), CreatureTextMgr::SendNonChatPacket(), Creature::SendZoneUnderAttackMessage(), SetZoneScript(), CreatureEventAI::SpawnedEventConditionsCheck(), Player::Update(), and GameObject::Use().

1177 {
1179 }
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:1834
float m_positionZ
Definition: Position.h:52
Map const * GetBaseMap() const
Definition: Object.cpp:1981
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 1362 of file Object.cpp.

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

1363 {
1364  // always have self in arc
1365  if (x == m_positionX && y == m_positionY)
1366  return true;
1367 
1368  float arc = arcangle;
1369 
1370  // move arc to range 0.. 2*pi
1371  while ( arc >= 2.0f * float(M_PI) )
1372  arc -= 2.0f * float(M_PI);
1373  while ( arc < 0 )
1374  arc += 2.0f * float(M_PI);
1375 
1376  float angle = GetAngle( x, y );
1377  angle -= GetOrientation();
1378 
1379  // move angle to range -pi ... +pi
1380  while ( angle > float(M_PI))
1381  angle -= 2.0f * float(M_PI);
1382  while (angle < -M_PI)
1383  angle += 2.0f * float(M_PI);
1384 
1385  float lborder = -1 * (arc / 2.0f); // in range -pi..0
1386  float rborder = (arc / 2.0f); // in range 0..pi
1387  return (( angle >= lborder ) && ( angle <= rborder ));
1388 }
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::isActiveObject ( ) const
inline

Definition at line 899 of file Object.h.

References ByteConverter::apply().

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

900  {
901  return m_isActive;
902  }
bool m_isActive
Definition: Object.h:920
virtual bool WorldObject::IsAlwaysDetectableFor ( WorldObject const *  ) const
inlinevirtual

Reimplemented in Player, and Unit.

Definition at line 808 of file Object.h.

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

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

Reimplemented in Unit, and GameObject.

Definition at line 805 of file Object.h.

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

805 { 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 1296 of file Object.cpp.

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

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

1297 {
1298  float dx = GetPositionX() - obj->GetPositionX();
1299  float dy = GetPositionY() - obj->GetPositionY();
1300  float distsq = dx * dx + dy * dy;
1301  if (is3D)
1302  {
1303  float dz = GetPositionZ() - obj->GetPositionZ();
1304  distsq += dz * dz;
1305  }
1306 
1307  float sizefactor = GetObjectSize() + obj->GetObjectSize();
1308 
1309  // check only for real range
1310  if (minRange > 0.0f)
1311  {
1312  float mindist = minRange + sizefactor;
1313  if (distsq < mindist * mindist)
1314  return false;
1315  }
1316 
1317  float maxdist = maxRange + sizefactor;
1318  return distsq < maxdist * maxdist;
1319 }
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:663
bool WorldObject::IsInRange2d ( float  x,
float  y,
float  minRange,
float  maxRange 
) const

Definition at line 1321 of file Object.cpp.

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

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

Definition at line 1341 of file Object.cpp.

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

1342 {
1343  float dx = GetPositionX() - x;
1344  float dy = GetPositionY() - y;
1345  float dz = GetPositionZ() - z;
1346  float distsq = dx * dx + dy * dy + dz * dz;
1347 
1348  float sizefactor = GetObjectSize();
1349 
1350  // check only for real range
1351  if (minRange > 0.0f)
1352  {
1353  float mindist = minRange + sizefactor;
1354  if (distsq < mindist * mindist)
1355  return false;
1356  }
1357 
1358  float maxdist = maxRange + sizefactor;
1359  return distsq < maxdist * maxdist;
1360 }
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:663
virtual bool WorldObject::IsInvisibleDueToDespawn ( ) const
inlinevirtual

Reimplemented in Creature, and GameObject.

Definition at line 806 of file Object.h.

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

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

Reimplemented in Player, and GameObject.

Definition at line 804 of file Object.h.

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

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

Definition at line 905 of file Object.h.

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

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

Reimplemented in Unit.

Definition at line 1520 of file Object.cpp.

References Object::IsInWorld().

Referenced by Unit::isValid().

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

Definition at line 758 of file Object.h.

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

759  {
760  return obj && _IsWithinDist(obj, dist2compare, is3D);
761  }
bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D) const
Definition: Object.cpp:1210
bool WorldObject::IsWithinDist2d ( float  x,
float  y,
float  dist 
) const
inline

Definition at line 748 of file Object.h.

749  {
750  return IsInDist2d(x, y, dist + GetObjectSize());
751  }
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:178
float GetObjectSize() const
Definition: Object.h:663
bool WorldObject::IsWithinDist2d ( const Position pos,
float  dist 
) const
inline

Definition at line 752 of file Object.h.

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

Definition at line 740 of file Object.h.

Referenced by Player::TeleportTo().

741  {
742  return IsInDist(x, y, z, dist + GetObjectSize());
743  }
float GetObjectSize() const
Definition: Object.h:663
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 744 of file Object.h.

745  {
746  return IsInDist(pos, dist + GetObjectSize());
747  }
float GetObjectSize() const
Definition: Object.h:663
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 762 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(), 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().

763  {
764  return obj && IsInMap(obj) && _IsWithinDist(obj, dist2compare, is3D);
765  }
bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D) const
Definition: Object.cpp:1210
bool IsInMap(const WorldObject *obj) const
Definition: Object.h:733
bool WorldObject::IsWithinLOS ( float  x,
float  y,
float  z 
) const

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

1241 {
1242  if (IsInWorld())
1243  {
1244  float x, y, z;
1245  if (GetTypeId() == TYPEID_PLAYER)
1246  GetPosition(x, y, z);
1247  else
1248  GetHitSpherePointFor({ ox, oy, oz }, x, y, z);
1249 
1250  return GetMap()->isInLineOfSight(x, y, z + 2.0f, ox, oy, oz + 2.0f);
1251  }
1252 
1253  return true;
1254 }
Map * GetMap() const
Definition: Object.h:829
uint8 GetTypeId() const
Definition: Object.h:204
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1256
const bool & IsInWorld() const
Definition: Object.h:129
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:1804
bool WorldObject::IsWithinLOSInMap ( const WorldObject obj) const

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

1227 {
1228  if (!IsInMap(obj))
1229  return false;
1230 
1231  float x, y, z;
1232  if (obj->GetTypeId() == TYPEID_PLAYER)
1233  obj->GetPosition(x, y, z);
1234  else
1235  obj->GetHitSpherePointFor(GetPosition(), x, y, z);
1236 
1237  return IsWithinLOS(x, y, z);
1238 }
bool IsWithinLOS(float x, float y, float z) const
Definition: Object.cpp:1240
uint8 GetTypeId() const
Definition: Object.h:204
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1256
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:733
bool WorldObject::IsWorldObject ( ) const

Definition at line 1111 of file Object.cpp.

References m_isWorldObject, and Object::ToCreature().

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

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

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

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

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

1835 {
1837 
1838  Cell cell(p);
1839  cell.SetNoCreate();
1840 
1841  Oregon::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_SAY, textId, language, TargetGuid);
1845  cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY));
1846 }
Map * GetMap() const
Definition: Object.h:829
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 1501 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().

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

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

1876 {
1878 
1879  Cell cell(p);
1880  cell.SetNoCreate();
1881 
1882  Oregon::MonsterChatBuilder say_build(*this, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, textId, LANG_UNIVERSAL, TargetGuid);
1886  cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
1887 }
Map * GetMap() const
Definition: Object.h:829
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 1508 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().

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

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

1890 {
1891  Player* player = sObjectMgr.GetPlayer(receiver);
1892  if (!player || !player->GetSession())
1893  return;
1894 
1895  uint32 loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
1896  char const* text = sObjectMgr.GetOregonString(textId, loc_idx);
1897 
1898  WorldPacket data(SMSG_MESSAGECHAT, 200);
1899  BuildMonsterChat(&data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, GetName(), receiver);
1900 
1901  player->GetSession()->SendPacket(&data);
1902 }
#define sObjectMgr
Definition: ObjectMgr.h:1285
void SendPacket(WorldPacket const *packet)
const char * GetName() const
Definition: Object.h:692
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:1904
WorldSession * GetSession() const
Definition: Player.h:1959
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:922
void WorldObject::MonsterYell ( const char *  text,
uint32  language,
uint64  TargetGuid 
)

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

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

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

1849 {
1851 
1852  Cell cell(p);
1853  cell.SetNoCreate();
1854 
1855  Oregon::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, TargetGuid);
1859  cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL));
1860 }
Map * GetMap() const
Definition: Object.h:829
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 1862 of file Object.cpp.

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

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

1863 {
1864  Oregon::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, TargetGuid);
1866 
1867  uint32 zoneid = GetZoneId();
1868 
1869  Map::PlayerList const& pList = GetMap()->GetPlayers();
1870  for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
1871  if (itr->GetSource()->GetZoneId() == zoneid)
1872  say_do(itr->GetSource());
1873 }
Map * GetMap() const
Definition: Object.h:829
uint32 GetZoneId() const
Definition: Object.cpp:1176
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 2419 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().

2420 {
2421  angle += GetOrientation();
2422  float destx, desty, destz, ground, floor;
2423  destx = pos.m_positionX + dist * cos(angle);
2424  desty = pos.m_positionY + dist * sin(angle);
2425 
2426  // Prevent invalid coordinates here, position is unchanged
2427  if (!Oregon::IsValidMapCoord(destx, desty, pos.m_positionZ))
2428  {
2429  sLog.outString("WorldObject::MovePosition invalid coordinates X: %f and Y: %f were passed!", destx, desty);
2430  return;
2431  }
2432 
2433  // Prevent invalid coordinates here, position is unchanged
2434  if (!Oregon::IsValidMapCoord(destx, desty))
2435  {
2436  sLog.outError("Crash alert! WorldObject::MovePositionToFirstCollision invalid coordinates X: %f and Y: %f were passed!", destx, desty);
2437  return;
2438  }
2439 
2440  ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
2441  floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
2442  destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
2443 
2444  float step = dist / 10.0f;
2445 
2446  for (uint8 j = 0; j < 10; ++j)
2447  {
2448  // do not allow too big z changes
2449  if (fabs(pos.m_positionZ - destz) > 6)
2450  {
2451  destx -= step * cos(angle);
2452  desty -= step * sin(angle);
2453  ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
2454  floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
2455  destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
2456  }
2457  // we have correct destz now
2458  else
2459  {
2460  pos.Relocate(destx, desty, destz);
2461  break;
2462  }
2463  }
2464 
2469 }
Map * GetMap() const
Definition: Object.h:829
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:1590
#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:1480
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:184
void WorldObject::MovePositionToFirstCollision ( Position pos,
float  dist,
float  angle 
)

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

2472 {
2473  angle += GetOrientation();
2474  float destx, desty, destz;
2475  destx = pos.m_positionX + dist * cos(angle);
2476  desty = pos.m_positionY + dist * sin(angle);
2477 
2478  // Prevent invalid coordinates here, position is unchanged
2479  if (!Oregon::IsValidMapCoord(destx, desty))
2480  {
2481  sLog.outFatal("WorldObject::MovePositionToFirstCollision invalid coordinates X: %f and Y: %f were passed!", destx, desty);
2482  return;
2483  }
2484 
2485  destz = GetPositionZTarget(pos, destx, desty);
2486  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);
2487 
2488  // collision occured
2489  if (col)
2490  {
2491  // move back a bit
2492  destx -= CONTACT_DISTANCE * cos(angle);
2493  desty -= CONTACT_DISTANCE * sin(angle);
2494  dist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
2495  }
2496 
2497  // check dynamic collision
2498  col = GetMap()->getObjectHitPos(pos.m_positionX, pos.m_positionY, pos.m_positionZ + 0.5f, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
2499 
2500  // Collided with a gameobject
2501  if (col)
2502  {
2503  destx -= CONTACT_DISTANCE * cos(angle);
2504  desty -= CONTACT_DISTANCE * sin(angle);
2505  dist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
2506  }
2507 
2508  float step = dist / 10.0f;
2509 
2510  for (uint8 j = 0; j < 10; ++j)
2511  {
2512  // do not allow too big z changes
2513  if (fabs(pos.m_positionZ - destz) > 6.0f)
2514  {
2515  destx -= step * cos(angle);
2516  desty -= step * sin(angle);
2517  destz = GetPositionZTarget(pos, destx, desty);
2518  }
2519  // we have correct destz now
2520  else
2521  {
2522  pos.Relocate(destx, desty, destz);
2523  break;
2524  }
2525  }
2526 
2529  pos.m_positionZ = GetPositionZTarget(pos, destx, desty);
2531 }
Map * GetMap() const
Definition: Object.h:829
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:2382
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:585
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:1810
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:184
bool WorldObject::NotifyExecuted ( uint16  f) const
inline

Definition at line 885 of file Object.h.

886  {
887  return m_executed_notifies & f;
888  }
uint16 m_executed_notifies
Definition: Object.h:943
void WorldObject::PlayDirectSound ( uint32  sound_id,
Player target = NULL 
)

Definition at line 2544 of file Object.cpp.

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

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

2545 {
2546  WorldPacket data(SMSG_PLAY_SOUND, 4);
2547  data << uint32(sound_id);
2548  if (target)
2549  target->SendDirectMessage(&data);
2550  else
2551  SendMessageToSet(&data, true);
2552 }
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:777
void SendDirectMessage(WorldPacket *data)
Definition: Player.cpp:5782
ACE_UINT32 uint32
Definition: Define.h:71
void WorldObject::PlayDistanceSound ( uint32  sound_id,
Player target = NULL 
)

Definition at line 2533 of file Object.cpp.

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

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

2534 {
2535  WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8);
2536  data << uint32(sound_id);
2537  data << uint64(GetGUID());
2538  if (target)
2539  target->SendDirectMessage(&data);
2540  else
2541  SendMessageToSet(&data, true);
2542 }
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:777
void SendDirectMessage(WorldPacket *data)
Definition: Player.cpp:5782
ACE_UINT64 uint64
Definition: Define.h:70
ACE_UINT32 uint32
Definition: Define.h:71
const uint64 & GetGUID() const
Definition: Object.h:156
void WorldObject::RemoveFromWorld ( )
overridevirtual

Reimplemented from Object.

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

Definition at line 1166 of file Object.cpp.

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

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

1167 {
1168  if (!IsInWorld())
1169  return;
1170 
1172 
1174 }
virtual void RemoveFromWorld()
Definition: Object.h:145
const bool & IsInWorld() const
Definition: Object.h:129
void DestroyForNearbyPlayers()
Definition: Object.cpp:2554
void WorldObject::ResetAllNotifies ( )
inline

Definition at line 893 of file Object.h.

894  {
895  m_notifyflags = 0;
897  }
uint16 m_notifyflags
Definition: Object.h:942
uint16 m_executed_notifies
Definition: Object.h:943
void WorldObject::ResetMap ( )
virtual

Reimplemented in Player.

Definition at line 1969 of file Object.cpp.

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

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

1970 {
1971  ASSERT(m_currMap);
1972  ASSERT(!IsInWorld());
1973  if (IsWorldObject())
1975  m_currMap = NULL;
1976  //maybe not for corpse
1977  //m_mapId = 0;
1978  //m_InstanceId = 0;
1979 }
Map * m_currMap
Definition: Object.h:937
bool IsWorldObject() const
Definition: Object.cpp:1111
void RemoveWorldObject(WorldObject *obj)
Definition: Map.h:483
const bool & IsInWorld() const
Definition: Object.h:129
#define ASSERT
Definition: Errors.h:33
virtual void WorldObject::SaveRespawnTime ( )
inlinevirtual

Reimplemented in GameObject, and Creature.

Definition at line 799 of file Object.h.

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

Reimplemented in Player.

Definition at line 777 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:1549
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
Definition: Object.cpp:1930
void WorldObject::SendMessageToSetInRange ( WorldPacket data,
float  dist,
bool  self 
)
virtual

Reimplemented in Player.

Definition at line 1930 of file Object.cpp.

References VisitNearbyWorldObject().

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

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

Definition at line 1943 of file Object.cpp.

References SendMessageToSet(), and SMSG_GAMEOBJECT_CUSTOM_ANIM.

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

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

Definition at line 1936 of file Object.cpp.

References SendMessageToSet(), and SMSG_GAMEOBJECT_DESPAWN_ANIM.

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

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

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

1788 {
1789  WorldPacket data(SMSG_PLAY_SOUND, 4);
1790  data << Sound;
1791  if (OnlySelf && GetTypeId() == TYPEID_PLAYER)
1792  ToPlayer()->GetSession()->SendPacket(&data);
1793  else
1794  SendMessageToSet(&data, true); // ToSelf ignored in this case
1795 }
void SendPacket(WorldPacket const *packet)
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:777
Player * ToPlayer()
Definition: Object.h:386
uint8 GetTypeId() const
Definition: Object.h:204
WorldSession * GetSession() const
Definition: Player.h:1959
void WorldObject::setActive ( bool  isActiveObject)

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

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

Definition at line 931 of file Object.h.

Referenced by Corpse::LoadCorpseFromDB().

932  {
933  m_InstanceId = _instanceId;
934  }
uint32 m_InstanceId
Definition: Object.h:940
void WorldObject::SetLocationMapId ( uint32  _mapId)
inlineprotected

Definition at line 927 of file Object.h.

Referenced by Corpse::LoadCorpseFromDB().

928  {
929  m_mapId = _mapId;
930  }
uint32 m_mapId
Definition: Object.h:590
void WorldObject::SetMap ( Map map)
virtual

Reimplemented in Player.

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

1952 {
1953  ASSERT(map);
1955  if (m_currMap == map) // command add npc: first create, than loadfromdb
1956  return;
1957  if (m_currMap)
1958  {
1959  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());
1960  ASSERT(false);
1961  }
1962  m_currMap = map;
1963  m_mapId = map->GetId();
1964  m_InstanceId = map->GetInstanceId();
1965  if (IsWorldObject())
1966  m_currMap->AddWorldObject(this);
1967 }
Map * m_currMap
Definition: Object.h:937
#define sLog
Log class singleton.
Definition: Log.h:187
bool IsWorldObject() const
Definition: Object.cpp:1111
uint32 m_InstanceId
Definition: Object.h:940
uint32 GetId(void) const
Definition: Map.h:333
uint8 GetTypeId() const
Definition: Object.h:204
uint32 m_mapId
Definition: Object.h:590
const bool & IsInWorld() const
Definition: Object.h:129
#define ASSERT
Definition: Errors.h:33
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 889 of file Object.h.

890  {
891  m_executed_notifies |= f;
892  }
uint16 m_executed_notifies
Definition: Object.h:943
void WorldObject::SetWorldObject ( bool  apply)

Definition at line 1103 of file Object.cpp.

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

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

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

Definition at line 2099 of file Object.cpp.

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

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

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

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

2089 {
2090  if (Map* map = FindMap())
2091  {
2092  if (TempSummon* summon = map->SummonCreature(entry, pos, NULL, duration, isType(TYPEMASK_UNIT) ? (Unit*)this : NULL, NULL, spwtype))
2093  return summon;
2094  }
2095 
2096  return NULL;
2097 }
bool isType(uint16 mask) const
Definition: Object.h:208
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2088
Map * FindMap() const
Definition: Object.h:830
Definition: Map.h:266
Definition: Unit.h:884
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 842 of file Object.h.

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

843  {
844  if (!x && !y && !z)
845  {
846  GetClosePoint(x, y, z, GetObjectSize());
847  ang = GetOrientation();
848  }
849  Position pos = {x, y, z, ang};
850  return SummonCreature(id, pos, spwtype, despwtime);
851  }
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2088
float GetOrientation() const
Definition: Position.h:100
float GetObjectSize() const
Definition: Object.h:663
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
Definition: Object.h:640
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 2275 of file Object.cpp.

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

2276 {
2277  ASSERT((GetTypeId() == TYPEID_GAMEOBJECT || GetTypeId() == TYPEID_UNIT) && "Only GOs and creatures can summon npc groups!");
2278 
2279  std::vector<TempSummonData> const* data = sObjectMgr.GetSummonGroup(GetEntry(), GetTypeId() == TYPEID_GAMEOBJECT ? SUMMONER_TYPE_GAMEOBJECT : SUMMONER_TYPE_CREATURE, group);
2280  if (!data)
2281  return;
2282 
2283  for (std::vector<TempSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr)
2284  if (TempSummon* summon = SummonCreature(itr->entry, itr->pos, itr->type, itr->time))
2285  if (list)
2286  list->push_back(summon);
2287 }
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2088
#define sObjectMgr
Definition: ObjectMgr.h:1285
uint8 GetTypeId() const
Definition: Object.h:204
#define ASSERT
Definition: Errors.h:33
uint32 GetEntry() const
Definition: Object.h:186
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 2222 of file Object.cpp.

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

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

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

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

2251 {
2252  TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
2253  Creature* summon = SummonCreature(WORLD_TRIGGER, x, y, z, ang, summonType, duration);
2254  if (!summon)
2255  return NULL;
2256 
2257  //summon->SetName(GetName());
2258  if (GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT)
2259  {
2260  summon->setFaction(((Unit*)this)->getFaction());
2261  summon->SetLevel(((Unit*)this)->getLevel());
2262  }
2263 
2264  if (GetAI)
2265  summon->AIM_Initialize(GetAI(summon));
2266  return summon;
2267 }
#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:2088
bool AIM_Initialize(CreatureAI *ai=NULL)
Definition: Creature.cpp:741
void setFaction(uint32 faction)
Definition: Unit.h:1115
despawns when the creature disappears
despawns after a specified time
uint8 GetTypeId() const
Definition: Object.h:204
TempSummonType
void SetLevel(uint32 lvl)
Definition: Unit.cpp:10817
Definition: Unit.h:884
virtual void WorldObject::Update ( uint32  )
inlinevirtual

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

Definition at line 633 of file Object.h.

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

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

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

Definition at line 1480 of file Object.cpp.

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

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

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

Reimplemented in Player, and Unit.

Definition at line 2588 of file Object.cpp.

References GetVisibilityRange(), and VisitNearbyWorldObject().

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

2589 {
2590  //updates object's visibility for nearby players
2591  Oregon::VisibleChangesNotifier notifier(*this);
2593 }
float GetVisibilityRange() const
Definition: Object.cpp:1549
void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const
Definition: Object.h:908
virtual void WorldObject::UpdateObjectVisibilityOnCreate ( )
inlinevirtual

Definition at line 865 of file Object.h.

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

Definition at line 910 of file Object.h.

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

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

Definition at line 909 of file Object.h.

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

909 { if (IsInWorld()) GetMap()->VisitAll(GetPositionX(), GetPositionY(), radius, notifier); }
Map * GetMap() const
Definition: Object.h:829
const bool & IsInWorld() const
Definition: Object.h:129
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 908 of file Object.h.

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

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

Member Data Documentation

uint64 WorldObject::lootingGroupLeaderGUID

Definition at line 913 of file Object.h.

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

Map* WorldObject::m_currMap
private

Definition at line 937 of file Object.h.

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

uint16 WorldObject::m_executed_notifies
private

Definition at line 943 of file Object.h.

uint32 WorldObject::m_groupLootTimer

Definition at line 912 of file Object.h.

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

uint32 WorldObject::m_InstanceId
private

Definition at line 940 of file Object.h.

Referenced by SetMap().

bool WorldObject::m_isActive
protected

Definition at line 920 of file Object.h.

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

const bool WorldObject::m_isWorldObject
protected

Definition at line 921 of file Object.h.

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

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

Definition at line 942 of file Object.h.

Definition at line 816 of file Object.h.

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


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