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

#include <Object.h>

+ Inheritance diagram for WorldObject:

Public Member Functions

 ~WorldObject () override
 
virtual void Update (uint32)
 
void _Create (uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
 
virtual void RemoveFromWorld () override
 
void GetNearPoint2D (float &x, float &y, float distance, float absAngle) const
 
void GetNearPoint (WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
 
void GetClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
 
void MovePosition (Position &pos, float dist, float angle)
 
Position GetNearPosition (float dist, float angle)
 
void MovePositionToFirstCollision (Position &pos, float dist, float angle)
 
Position GetFirstCollisionPosition (float dist, float angle)
 
float GetPositionZTarget (Position &pos, float destx, float desty)
 
Position GetRandomNearPosition (float radius)
 
void GetContactPoint (const WorldObject *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
virtual float GetObjectBoundingRadius () const
 
float GetObjectSize () const
 
void UpdateGroundPositionZ (float x, float y, float &z) const
 
void UpdateAllowedPositionZ (float x, float y, float &z) const
 
void GetRandomPoint (const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
void GetRandomPoint (const Position &srcPos, float distance, Position &pos) const
 
float GetDistanceSqr (float x, float y, float z) const
 
bool HasInArc (float arcangle, const Position *pos) const
 
bool HasInArc (const float arcangle, const float x, const float y) const
 
uint32 GetInstanceId () const
 
virtual void SetPhaseMask (uint32 newPhaseMask, bool update)
 
uint32 GetPhaseMask () const
 
bool InSamePhase (uint32 phasemask) const
 
bool InSamePhase (WorldObject const *obj) const
 
uint32 GetZoneId () const
 
uint32 GetAreaId () const
 
InstanceDataGetInstanceData ()
 
const char * GetName () const
 
void SetName (const std::string &newname)
 
virtual const char * GetNameForLocaleIdx (int32) const
 
float GetDistance (const WorldObject *obj) const
 
float GetDistance (const Position &pos) const
 
float GetDistance (float x, float y, float z) const
 
float GetDistance2d (const WorldObject *obj) const
 
float GetDistance2d (float x, float y) const
 
float GetDistanceZ (const WorldObject *obj) const
 
bool IsInMap (const WorldObject *obj) const
 
bool IsWithinDist3d (float x, float y, float z, float dist) const
 
bool IsWithinDist3d (const Position *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (const Position *pos, float dist) const
 
bool _IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D) const
 
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true) const
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true) const
 
bool IsWithinLOS (float x, float y, float z) const
 
bool IsWithinLOSInMap (const WorldObject *obj) const
 
Position GetHitSpherePointFor (Position const &dest) const
 
void GetHitSpherePointFor (Position const &dest, float &x, float &y, float &z) const
 
bool GetDistanceOrder (WorldObject const *obj1, WorldObject const *obj2, bool is3D=true) const
 
bool IsInRange (WorldObject const *obj, float minRange, float maxRange, bool is3D=true) const
 
bool IsInRange2d (float x, float y, float minRange, float maxRange) const
 
bool IsInRange3d (float x, float y, float z, float minRange, float maxRange) const
 
virtual void CleanupsBeforeDelete ()
 
virtual void SendMessageToSet (WorldPacket *data, bool self)
 
virtual void SendMessageToSetInRange (WorldPacket *data, float dist, bool self)
 
virtual uint8 getLevelForTarget (WorldObject const *) const
 
void MonsterSay (const char *text, uint32 language, uint64 TargetGuid)
 
void MonsterYell (const char *text, uint32 language, uint64 TargetGuid)
 
void MonsterTextEmote (const char *text, uint64 TargetGuid, bool IsBossEmote=false)
 
void MonsterWhisper (const char *text, uint64 receiver, bool IsBossWhisper=false)
 
void MonsterSay (int32 textId, uint32 language, uint64 TargetGuid)
 
void MonsterYell (int32 textId, uint32 language, uint64 TargetGuid)
 
void MonsterTextEmote (int32 textId, uint64 TargetGuid, bool IsBossEmote=false)
 
void MonsterWhisper (int32 textId, uint64 receiver, bool IsBossWhisper=false)
 
void MonsterYellToZone (int32 textId, uint32 language, uint64 TargetGuid)
 
void BuildMonsterChat (WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
 
void PlayDistanceSound (uint32 sound_id, Player *target=NULL)
 
void PlayDirectSound (uint32 sound_id, Player *target=NULL)
 
void SendObjectDeSpawnAnim (uint64 guid)
 
void SendObjectCustomAnim (uint64 guid, uint32 anim=0)
 
virtual void SaveRespawnTime ()
 
void AddObjectToRemoveList ()
 
virtual bool isValid () const
 
virtual bool IsNeverVisible () const
 
virtual bool IsAlwaysVisibleFor (WorldObject const *) const
 
virtual bool IsInvisibleDueToDespawn () const
 
virtual bool IsAlwaysDetectableFor (WorldObject const *) const
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
float GetSightRange (const WorldObject *target=NULL) const
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
void SendPlaySound (uint32 Sound, bool OnlySelf)
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
Map const * GetBaseMap () const
 
void SetZoneScript ()
 
TempSummonSummonCreature (uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
 
TempSummonSummonCreature (uint32 id, float x, float y, float z, float ang, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime)
 
CreatureSummonTrigger (float x, float y, float z, float ang, uint32 dur, CreatureAI *(*GetAI)(Creature *)=NULL)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=NULL)
 
CreatureFindNearestCreature (uint32 entry, float range, bool alive=true)
 
GameObjectFindNearestGameObject (uint32 entry, float range)
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
void GetGameObjectListWithEntryInGrid (std::list< GameObject * > &gameobjectList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
 
void GetCreatureListWithEntryInGrid (std::list< Creature * > &creatureList, uint32 entry=GRID_SEARCH_ALL_ENTRIES, float maxSearchRange=250.0f) const
 
void DestroyForNearbyPlayers ()
 
virtual void UpdateObjectVisibility (bool forced=true)
 
virtual void UpdateObjectVisibilityOnCreate ()
 
void BuildUpdate (UpdateDataMapType &) override
 
void AddToNotify (uint16 f)
 
bool isNeedNotify (uint16 f) const
 
uint16 GetNotifyFlags () const
 
bool NotifyExecuted (uint16 f) const
 
void SetNotified (uint16 f)
 
void ResetAllNotifies ()
 
bool isActiveObject () const
 
void setActive (bool isActiveObject)
 
bool IsVisibilityOverridden () const
 
void SetVisibilityDistanceOverride (VisibilityDistanceType type)
 
void SetWorldObject (bool apply)
 
bool IsPermanentWorldObject () const
 
bool IsWorldObject () const
 
template<class NOTIFIER >
void VisitNearbyWorldObject (const float &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyObject (float const &radius, NOTIFIER &notifier) const
 
template<class NOTIFIER >
void VisitNearbyGridObject (float const &radius, NOTIFIER &notifier) const
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
const bool & IsInWorld () const
 
virtual void AddToWorld ()
 
uint64 GetGUID () const
 
uint32 GetGUIDLow () const
 
uint32 GetGUIDMid () const
 
uint32 GetGUIDHigh () const
 
PackedGuid const & GetPackGUID () const
 
ObjectGuid const & GetObjectGUID () const
 
std::string GetGuidStr () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
void SetObjectScale (float scale)
 
uint8 GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
 
void BuildMovementUpdateBlock (UpdateData *data, uint32 flags=0) const
 
virtual void DestroyForPlayer (Player *target, bool onDeath=false) const
 
const int32GetInt32Value (uint16 index) const
 
const uint32GetUInt32Value (uint16 index) const
 
const uint64GetUInt64Value (uint16 index) const
 
const float & GetFloatValue (uint16 index) const
 
uint8 GetByteValue (uint16 index, uint8 offset) const
 
ObjectGuid const & GetGuidValue (uint16 index) const
 
uint16 GetUInt16Value (uint16 index, uint8 offset) const
 
void SetInt32Value (uint16 index, int32 value)
 
void SetUInt32Value (uint16 index, uint32 value)
 
void SetUInt64Value (uint16 index, const uint64 &value)
 
void SetFloatValue (uint16 index, float value)
 
void SetByteValue (uint16 index, uint8 offset, uint8 value)
 
void SetUInt16Value (uint16 index, uint8 offset, uint16 value)
 
void SetInt16Value (uint16 index, uint8 offset, int16 value)
 
void SetStatFloatValue (uint16 index, float value)
 
void SetStatInt32Value (uint16 index, int32 value)
 
bool AddUInt64Value (uint16 index, const uint64 &value)
 
bool RemoveUInt64Value (uint16 index, const uint64 &value)
 
void ApplyModUInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModInt32Value (uint16 index, int32 val, bool apply)
 
void ApplyModUInt64Value (uint16 index, int32 val, bool apply)
 
void ApplyModPositiveFloatValue (uint16 index, float val, bool apply)
 
void ApplyModSignedFloatValue (uint16 index, float val, bool apply)
 
void ApplyPercentModFloatValue (uint16 index, float val, bool apply)
 
void SetFlag (uint16 index, uint32 newFlag)
 
void RemoveFlag (uint16 index, uint32 oldFlag)
 
void ToggleFlag (uint16 index, uint32 flag)
 
bool HasFlag (uint16 index, uint32 flag) const
 
void SetByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void RemoveByteFlag (uint16 index, uint8 offset, uint8 newFlag)
 
void ToggleFlag (uint16 index, uint8 offset, uint8 flag)
 
bool HasByteFlag (uint16 index, uint8 offset, uint8 flag) const
 
void ApplyModFlag (uint16 index, uint32 flag, bool apply)
 
void SetFlag64 (uint16 index, uint64 newFlag)
 
void RemoveFlag64 (uint16 index, uint64 oldFlag)
 
void ToggleFlag64 (uint16 index, uint64 flag)
 
bool HasFlag64 (uint16 index, uint64 flag) const
 
void ApplyModFlag64 (uint16 index, uint64 flag, bool apply)
 
void ClearUpdateMask (bool remove)
 
bool LoadValues (const char *data)
 
uint16 GetValuesCount () const
 
virtual bool hasQuest (uint32) const
 
virtual bool hasInvolvedQuest (uint32) const
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
 
void ForceValuesUpdateAtIndex (uint32)
 
PlayerToPlayer ()
 
Player const * ToPlayer () const
 
CreatureToCreature ()
 
Creature const * ToCreature () const
 
UnitToUnit ()
 
Unit const * ToUnit () const
 
GameObjectToGameObject ()
 
GameObject const * ToGameObject () const
 
CorpseToCorpse ()
 
Corpse const * ToCorpse () const
 
DynamicObjectToDynObject ()
 
DynamicObject const * ToDynObject () const
 
- Public Member Functions inherited from WorldLocation
 WorldLocation (uint32 _mapid=MAPID_INVALID, float _x=0, float _y=0, float _z=0, float _o=0)
 
 WorldLocation (const WorldLocation &loc)
 
void WorldRelocate (const WorldLocation &loc)
 
uint32 GetMapId () const
 
- Public Member Functions inherited from Position
 Position (float x=0, float y=0, float z=0, float o=0)
 
 Position (Position const &loc)
 
bool operator== (Position const &a)
 
bool operator!= (Position const &a)
 
void Relocate (float x, float y)
 
void Relocate (float x, float y, float z)
 
void Relocate (float x, float y, float z, float orientation)
 
void Relocate (Position const &pos)
 
void Relocate (Position const *pos)
 
void RelocateOffset (Position const &offset)
 
void SetOrientation (float orientation)
 
float GetPositionX () const
 
float GetPositionY () const
 
float GetPositionZ () const
 
float GetOrientation () const
 
void GetPosition (float &x, float &y) const
 
void GetPosition (float &x, float &y, float &z) const
 
void GetPosition (float &x, float &y, float &z, float &o) const
 
Position GetPosition () const
 
Position::PositionXYStreamer PositionXYStream ()
 
Position::PositionXYZStreamer PositionXYZStream ()
 
Position::PositionXYZOStreamer PositionXYZOStream ()
 
bool IsPositionValid () const
 
float GetExactDist2dSq (float x, float y) const
 
float GetExactDist2d (const float x, const float y) const
 
float GetExactDist2dSq (Position const *pos) const
 
float GetExactDist2d (Position const *pos) const
 
float GetExactDistSq (float x, float y, float z) const
 
float GetExactDist (float x, float y, float z) const
 
float GetExactDistSq (Position const *pos) const
 
float GetExactDist (Position const *pos) const
 
void GetPositionOffsetTo (Position const &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (Position const *pos) const
 
float GetAngle (float x, float y) const
 
float GetRelativeAngle (Position const *pos) const
 
float GetRelativeAngle (float x, float y) const
 
void GetSinCos (float x, float y, float &vsin, float &vcos) const
 
bool IsInDist2d (float x, float y, float dist) const
 
bool IsInDist2d (Position const *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (Position const *pos, float dist) const
 
bool IsWithinBox (const Position &center, float xradius, float yradius, float zradius) const
 
bool HasInArc (float arcangle, Position const *pos, float border=2.0f) const
 
bool HasInLine (Position const *pos, float width) const
 
std::string ToString () const
 

Static Public Member Functions

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

Public Attributes

FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealth
 
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPESm_stealthDetect
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibility
 
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPESm_invisibilityDetect
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibility
 
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPESm_serverSideVisibilityDetect
 
uint32 m_groupLootTimer
 
uint64 lootingGroupLeaderGUID
 
MovementInfo m_movementInfo
 
- Public Attributes inherited from WorldLocation
uint32 m_mapId
 
- Public Attributes inherited from Position
float m_positionX
 
float m_positionY
 
float m_positionZ
 

Protected Member Functions

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

Protected Attributes

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

Private Member Functions

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

Private Attributes

Mapm_currMap
 
uint32 m_InstanceId
 
uint32 m_phaseMask
 
uint16 m_notifyflags
 
uint16 m_executed_notifies
 

Detailed Description

Definition at line 610 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:1999
Definition: Corpse.h:48
Map * m_currMap
Definition: Object.h:913
#define sLog
Log class singleton.
Definition: Log.h:187
bool IsWorldObject() const
Definition: Object.cpp:1111
uint64 GetGUID() const
Definition: Object.h:177
uint8 GetTypeId() const
Definition: Object.h:192
#define UI64FMTD
Definition: Common.h:149
#define ASSERT
Definition: Errors.h:29
uint32 GetEntry() const
Definition: Object.h:186
WorldObject::WorldObject ( bool  isWorldObject)
explicitprotected

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

1085  :
1086  WorldLocation()
1087  , m_groupLootTimer(0)
1089  , m_isWorldObject(isWorldObject)
1090  , m_name("")
1091  , m_isActive(false)
1093  , m_zoneScript(NULL)
1094  , m_currMap(NULL)
1095  , m_InstanceId(0)
1098 {
1101 }
const bool m_isWorldObject
Definition: Object.h:896
Map * m_currMap
Definition: Object.h:913
std::string m_name
Definition: Object.h:894
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:809
uint64 lootingGroupLeaderGUID
Definition: Object.h:888
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:602
uint32 m_InstanceId
Definition: Object.h:916
uint16 m_notifyflags
Definition: Object.h:919
float m_visibilityDistanceOverride
Definition: Object.h:898
ZoneScript * m_zoneScript
Definition: Object.h:897
bool m_isActive
Definition: Object.h:895
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:810
uint32 m_phaseMask
Definition: Object.h:917
uint32 m_groupLootTimer
Definition: Object.h:887
uint16 m_executed_notifies
Definition: Object.h:920
WorldLocation(uint32 _mapid=MAPID_INVALID, float _x=0, float _y=0, float _z=0, float _o=0)
Definition: Object.h:552

Member Function Documentation

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

Definition at line 1185 of file Object.cpp.

References Object::_Create(), and m_phaseMask.

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

1186 {
1187  Object::_Create(guidlow, 0, guidhigh);
1188 
1189  m_phaseMask = phaseMask;
1190 }
void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
Definition: Object.cpp:125
uint32 m_phaseMask
Definition: Object.h:917
bool WorldObject::_IsWithinDist ( WorldObject const *  obj,
float  dist2compare,
bool  is3D 
) const

Definition at line 1236 of file Object.cpp.

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

1237 {
1238  float dx = GetPositionX() - obj->GetPositionX();
1239  float dy = GetPositionY() - obj->GetPositionY();
1240  float distsq = dx * dx + dy * dy;
1241  if (is3D)
1242  {
1243  float dz = GetPositionZ() - obj->GetPositionZ();
1244  distsq += dz * dz;
1245  }
1246  float sizefactor = GetObjectSize() + obj->GetObjectSize();
1247  float maxdist = dist2compare + sizefactor;
1248 
1249  return distsq < maxdist * maxdist;
1250 }
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:645
void WorldObject::AddObjectToRemoveList ( )

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

2018 {
2020 
2021  Map* map = FindMap();
2022  if (!map)
2023  {
2024  sLog.outError("Object (TypeId: %u Entry: %u GUID: %u) at attempt add to move list has invalid map (Id: %u).", GetTypeId(), GetEntry(), GetGUIDLow(), GetMapId());
2025  return;
2026  }
2027 
2028  map->AddObjectToRemoveList(this);
2029 }
uint32 * m_uint32Values
Definition: Object.h:408
#define sLog
Log class singleton.
Definition: Log.h:187
void AddObjectToRemoveList(WorldObject *obj)
Definition: Map.cpp:2035
uint32 GetGUIDLow() const
Definition: Object.h:178
uint8 GetTypeId() const
Definition: Object.h:192
Map * FindMap() const
Definition: Object.h:818
uint32 GetMapId() const
Definition: Object.h:567
Definition: Map.h:266
#define ASSERT
Definition: Errors.h:29
uint32 GetEntry() const
Definition: Object.h:186
void WorldObject::AddToNotify ( uint16  f)
inline

Definition at line 858 of file Object.h.

Referenced by Player::UpdateObjectVisibility().

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

Definition at line 1934 of file Object.cpp.

References Object::GetGUID(), and IS_PLAYER_GUID.

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

1935 {
1936  *data << (uint8)msgtype;
1937  *data << (uint32)language;
1938  *data << (uint64)GetGUID();
1939  *data << (uint32)0; //2.1.0
1940  *data << (uint32)(strlen(name) + 1);
1941  *data << name;
1942  *data << (uint64)targetGuid; //Unit Target
1943  if (targetGuid && !IS_PLAYER_GUID(targetGuid))
1944  {
1945  *data << (uint32)1; // target name length
1946  *data << (uint8)0; // target name
1947  }
1948  *data << (uint32)(strlen(text) + 1);
1949  *data << text;
1950  *data << (uint8)0; // ChatTag
1951 }
uint64 GetGUID() const
Definition: Object.h:177
#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
void WorldObject::BuildUpdate ( UpdateDataMapType data_map)
overridevirtual

Reimplemented from Object.

Definition at line 2716 of file Object.cpp.

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

2717 {
2719  Cell cell(p);
2720  cell.SetNoCreate();
2721  WorldObjectChangeAccumulator notifier(*this, data_map);
2723  Map& map = *GetMap();
2724  //we must build packets for all visible players
2725  cell.Visit(p, player_notifier, map, *this, GetVisibilityRange());
2726 
2727  ClearUpdateMask(false);
2728 }
void ClearUpdateMask(bool remove)
Definition: Object.cpp:676
Map * GetMap() const
Definition: Object.h:817
float GetVisibilityRange() const
Definition: Object.cpp:1575
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 923 of file Object.h.

Referenced by CanSeeOrDetect().

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

Definition at line 1695 of file Object.cpp.

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

Referenced by CanSeeOrDetect().

1696 {
1697  const WorldObject* seer = this;
1698 
1699  // Pets don't have detection, they use the detection of their masters
1700  if (const Unit* thisUnit = ToUnit())
1701  if (Unit* controller = thisUnit->GetCharmerOrOwner())
1702  seer = controller;
1703 
1704  if (obj->IsAlwaysDetectableFor(seer))
1705  return true;
1706 
1707  if (!ignoreStealth && !seer->CanDetectInvisibilityOf(obj))
1708  return false;
1709 
1710  if (!ignoreStealth && !seer->CanDetectStealthOf(obj, checkAlert))
1711  return false;
1712 
1713  return true;
1714 }
bool CanDetectStealthOf(WorldObject const *obj, bool checkAlert=false) const
Definition: Object.cpp:1747
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1410
Definition: Unit.h:908
bool CanDetectInvisibilityOf(WorldObject const *obj) const
Definition: Object.cpp:1716
Unit * ToUnit()
Definition: Object.h:374
bool WorldObject::CanDetectInvisibilityOf ( WorldObject const *  obj) const
private

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

1717 {
1718  uint32 mask = obj->m_invisibility.GetFlags() & m_invisibilityDetect.GetFlags();
1719 
1720  // Check for not detected types
1721  if (mask != obj->m_invisibility.GetFlags())
1722  return false;
1723 
1724  // It isn't possible in invisibility to detect something that can't detect the invisible object
1725  // (it's at least true for spell: 66)
1726  // It seems like that only Units are affected by this check (couldn't see arena doors with preparation invisibility)
1727  if (obj->ToUnit())
1728  if ((m_invisibility.GetFlags() & obj->m_invisibilityDetect.GetFlags()) != m_invisibility.GetFlags())
1729  return false;
1730 
1731  for (uint32 i = 0; i < TOTAL_INVISIBILITY_TYPES; ++i)
1732  {
1733  if (!(mask & (1 << i)))
1734  continue;
1735 
1736  int32 objInvisibilityValue = obj->m_invisibility.GetValue(InvisibilityType(i));
1737  int32 ownInvisibilityDetectValue = m_invisibilityDetect.GetValue(InvisibilityType(i));
1738 
1739  // Too low value to detect
1740  if (ownInvisibilityDetectValue < objInvisibilityValue)
1741  return false;
1742  }
1743 
1744  return true;
1745 }
T_FLAGS GetFlags() const
Definition: Object.h:596
ACE_INT32 int32
Definition: Define.h:67
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibilityDetect
Definition: Object.h:807
InvisibilityType
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibility
Definition: Object.h:806
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:601
ACE_UINT32 uint32
Definition: Define.h:71
bool WorldObject::CanDetectStealthOf ( WorldObject const *  obj,
bool  checkAlert = false 
) const
private

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

1748 {
1749  // Combat reach is the minimal distance (both in front and behind),
1750  // and it is also used in the range calculation.
1751  // One stealth point increases the visibility range by 0.3 yard.
1752 
1753  if (!obj->m_stealth.GetFlags())
1754  return true;
1755 
1756  float distance = GetExactDist(obj);
1757  float combatReach = 0.0f;
1758 
1759  Unit const* unit = ToUnit();
1760  if (unit)
1761  combatReach = unit->GetCombatReach();
1762 
1763  if (distance < combatReach)
1764  return true;
1765 
1766  if (!HasInArc(float(M_PI), obj))
1767  return false;
1768 
1769  GameObject const* go = obj->ToGameObject();
1770  for (uint32 i = 0; i < TOTAL_STEALTH_TYPES; ++i)
1771  {
1772  if (!(obj->m_stealth.GetFlags() & (1 << i)))
1773  continue;
1774 
1776  return true;
1777 
1778  // Starting points
1779  int32 detectionValue = 30;
1780 
1781  // Level difference: 5 point / level, starting from level 1.
1782  // There may be spells for this and the starting points too, but
1783  // not in the DBCs of the client.
1784  detectionValue += int32(getLevelForTarget(obj) - 1) * 5;
1785 
1786  // Apply modifiers
1787  detectionValue += m_stealthDetect.GetValue(StealthType(i));
1788  if (go)
1789  if (Unit* owner = go->GetOwner())
1790  detectionValue -= int32(owner->getLevelForTarget(this) - 1) * 5;
1791 
1792  detectionValue -= obj->m_stealth.GetValue(StealthType(i));
1793 
1794  // Calculate max distance
1795  float visibilityRange = float(detectionValue) * 0.3f + combatReach;
1796 
1797  // If this unit is an NPC then player detect range doesn't apply
1798  if (unit && unit->GetTypeId() == TYPEID_PLAYER && visibilityRange > MAX_PLAYER_STEALTH_DETECT_RANGE)
1799  visibilityRange = MAX_PLAYER_STEALTH_DETECT_RANGE;
1800 
1801  // When checking for alert state, look 8% further, and then 1.5 yards more than that.
1802  if (checkAlert)
1803  visibilityRange += (visibilityRange * 0.08f) + 1.5f;
1804 
1805  // If checking for alert, and creature's visibility range is greater than aggro distance, No alert
1806  Unit const* tunit = obj->ToUnit();
1807  if (checkAlert && unit && unit->ToCreature() && visibilityRange >= unit->ToCreature()->GetAttackDistance(tunit) + unit->ToCreature()->m_CombatDistance)
1808  return false;
1809 
1810  if (distance > visibilityRange)
1811  return false;
1812  }
1813 
1814  return true;
1815 }
Unit * GetOwner() const
Definition: GameObject.cpp:799
bool HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const
Definition: Unit.cpp:883
ACE_INT32 int32
Definition: Define.h:67
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPES > m_stealthDetect
Definition: Object.h:804
GameObject * ToGameObject()
Definition: Object.h:377
virtual uint8 getLevelForTarget(WorldObject const *) const
Definition: Object.h:768
float GetCombatReach() const
Definition: Unit.h:978
uint8 GetTypeId() const
Definition: Object.h:192
float GetAttackDistance(Unit const *pl) const
Definition: Creature.cpp:1532
StealthType
#define MAX_PLAYER_STEALTH_DETECT_RANGE
Definition: Unit.h:904
bool HasInArc(float arcangle, const Position *pos) const
Definition: Object.cpp:1416
Creature * ToCreature()
Definition: Object.h:371
float GetExactDist(float x, float y, float z) const
Definition: Position.h:150
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:601
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Unit.h:908
float m_CombatDistance
Definition: Creature.h:797
Unit * ToUnit()
Definition: Object.h:374
bool WorldObject::CanNeverSee ( WorldObject const *  obj) const
private

Definition at line 1690 of file Object.cpp.

References GetMap(), and InSamePhase().

Referenced by CanSeeOrDetect().

1691 {
1692  return GetMap() != obj->GetMap() || !InSamePhase(obj);
1693 }
Map * GetMap() const
Definition: Object.h:817
bool InSamePhase(uint32 phasemask) const
Definition: Object.h:671
bool WorldObject::CanSeeOrDetect ( WorldObject const *  obj,
bool  ignoreStealth = false,
bool  distanceCheck = false,
bool  checkAlert = false 
) const

Definition at line 1612 of file Object.cpp.

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

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

1613 {
1614  if (this == obj)
1615  return true;
1616 
1617  if (obj->IsNeverVisible() || CanNeverSee(obj))
1618  return false;
1619 
1620  if (obj->IsAlwaysVisibleFor(this) || CanAlwaysSee(obj))
1621  return true;
1622 
1623  bool corpseVisibility = false;
1624  if (distanceCheck)
1625  {
1626  bool corpseCheck = false;
1627  if (const Player* thisPlayer = ToPlayer())
1628  {
1629  if (thisPlayer->isDead() && thisPlayer->GetHealth() > 0 && // Cheap way to check for ghost state
1631  {
1632  if (Corpse* corpse = thisPlayer->GetCorpse())
1633  {
1634  corpseCheck = true;
1635  if (corpse->IsWithinDist(thisPlayer, GetSightRange(obj), false))
1636  if (corpse->IsWithinDist(obj, GetSightRange(obj), false))
1637  corpseVisibility = true;
1638  }
1639  }
1640  }
1641 
1642  WorldObject const* viewpoint = this;
1643  if (Player const* player = this->ToPlayer())
1644  viewpoint = player->GetViewpoint();
1645 
1646  if (!viewpoint)
1647  viewpoint = this;
1648 
1649  if (!corpseCheck && !viewpoint->IsWithinDist(obj, GetSightRange(obj), false))
1650  return false;
1651  }
1652 
1653  // GM visibility off or hidden NPC
1654  if (!obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM))
1655  {
1656  // Stop checking other things for GMs
1658  return true;
1659  }
1660  else
1661  return m_serverSideVisibilityDetect.GetValue(SERVERSIDE_VISIBILITY_GM) >= obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM);
1662 
1663  // Ghost players, Spirit Healers, and some other NPCs
1664  if (!corpseVisibility && !(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibilityDetect.GetValue(SERVERSIDE_VISIBILITY_GHOST)))
1665  {
1666  // Alive players can see dead players in some cases, but other objects can't do that
1667  if (const Player* thisPlayer = ToPlayer())
1668  {
1669  if (const Player* objPlayer = obj->ToPlayer())
1670  {
1671  if (thisPlayer->GetTeam() != objPlayer->GetTeam() || !thisPlayer->IsGroupVisibleFor(objPlayer))
1672  return false;
1673  }
1674  else
1675  return false;
1676  }
1677  else
1678  return false;
1679  }
1680 
1681  if (obj->IsInvisibleDueToDespawn())
1682  return false;
1683 
1684  if (!CanDetect(obj, ignoreStealth, checkAlert))
1685  return false;
1686 
1687  return true;
1688 }
Definition: Corpse.h:48
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:809
bool CanNeverSee(WorldObject const *obj) const
Definition: Object.cpp:1690
Player * ToPlayer()
Definition: Object.h:368
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.h:746
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:810
bool CanDetect(WorldObject const *obj, bool ignoreStealth, bool checkAlert=false) const
Definition: Object.cpp:1695
virtual bool CanAlwaysSee(WorldObject const *) const
Definition: Object.h:923
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:601
Definition: Player.h:923
float GetSightRange(const WorldObject *target=NULL) const
Definition: Object.cpp:1585
void WorldObject::CleanupsBeforeDelete ( )
virtual

Reimplemented in Player, Unit, and GameObject.

Definition at line 1179 of file Object.cpp.

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

Referenced by Map::AddObjectToRemoveList().

1180 {
1181  if (IsInWorld())
1182  RemoveFromWorld();
1183 }
const bool & IsInWorld() const
Definition: Object.h:150
virtual void RemoveFromWorld() override
Definition: Object.cpp:1192
void WorldObject::DestroyForNearbyPlayers ( )

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

2617 {
2618  if (!IsInWorld())
2619  return;
2620 
2621  std::list<Player*> targets;
2625  for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
2626  {
2627  Player* player = (*iter);
2628 
2629  if (player == this)
2630  continue;
2631 
2632  if (!player->HaveAtClient(this))
2633  continue;
2634 
2635  if (isType(TYPEMASK_UNIT) && ((Unit*)this)->GetCharmerGUID() == player->GetGUID()) // @todo this is for puppet
2636  continue;
2637 
2638  if (GetTypeId() == TYPEID_UNIT)
2639  {
2640  // at remove from world (destroy) show kill animation
2641  DestroyForPlayer(player, ToUnit()->IsDuringRemoveFromWorld() && ToCreature()->isDead());
2642  }
2643  else
2644  DestroyForPlayer(player);
2645 
2646  player->m_clientGUIDs.erase(GetGUID());
2647  }
2648 }
ClientGUIDs m_clientGUIDs
Definition: Player.h:2459
bool isType(uint16 mask) const
Definition: Object.h:193
float GetVisibilityRange() const
Definition: Object.cpp:1575
uint64 GetGUID() const
Definition: Object.h:177
uint8 GetTypeId() const
Definition: Object.h:192
virtual void DestroyForPlayer(Player *target, bool onDeath=false) const
Definition: Object.cpp:241
const bool & IsInWorld() const
Definition: Object.h:150
bool HaveAtClient(WorldObject const *u) const
Definition: Player.cpp:18689
Creature * ToCreature()
Definition: Object.h:371
Definition: Unit.h:908
Definition: Player.h:923
Unit * ToUnit()
Definition: Object.h:374
void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const
Definition: Object.h:883
Creature * WorldObject::FindNearestCreature ( uint32  entry,
float  range,
bool  alive = true 
)

Definition at line 2319 of file Object.cpp.

References VisitNearbyObject().

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

2320 {
2321  Creature* creature = NULL;
2322  Oregon::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range);
2324  VisitNearbyObject(range, searcher);
2325  return creature;
2326 }
void VisitNearbyObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:884
GameObject * WorldObject::FindNearestGameObject ( uint32  entry,
float  range 
)

Definition at line 2328 of file Object.cpp.

References VisitNearbyGridObject().

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

2329 {
2330  GameObject* go = NULL;
2331  Oregon::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range);
2333  VisitNearbyGridObject(range, searcher);
2334  return go;
2335 }
void VisitNearbyGridObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:885
GameObject * WorldObject::FindNearestGameObjectOfType ( GameobjectTypes  type,
float  range 
) const

Definition at line 2337 of file Object.cpp.

References VisitNearbyGridObject().

2338 {
2339  GameObject* go = NULL;
2340  Oregon::NearestGameObjectTypeInObjectRangeCheck checker(*this, type, range);
2342  VisitNearbyGridObject(range, searcher);
2343  return go;
2344 }
void VisitNearbyGridObject(float const &radius, NOTIFIER &notifier) const
Definition: Object.h:885
void WorldObject::GetClosePoint ( float &  x,
float &  y,
float &  z,
float  size,
float  distance2d = 0,
float  angle = 0 
) const
inline

Definition at line 622 of file Object.h.

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

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

Definition at line 634 of file Object.h.

References GetObjectSize().

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

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

Definition at line 2359 of file Object.cpp.

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

Referenced by GetCreatureListWithEntryInGrid().

2360 {
2362  Cell cell(pair);
2363  cell.SetNoCreate();
2364 
2365  Oregon::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange);
2366  Oregon::CreatureListSearcher<Oregon::AllCreaturesOfEntryInRange> searcher(this, creatureList, check);
2368 
2369  cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
2370 }
Map * GetMap() const
Definition: Object.h:817
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
float GetPositionX() const
Definition: Position.h:97
float WorldObject::GetDistance ( const Position pos) const
inline

Definition at line 699 of file Object.h.

700  {
701  float d = GetExactDist(&pos) - GetObjectSize();
702  return d > 0.0f ? d : 0.0f;
703  }
float GetExactDist(float x, float y, float z) const
Definition: Position.h:150
float GetObjectSize() const
Definition: Object.h:645
float WorldObject::GetDistance ( float  x,
float  y,
float  z 
) const
inline

Definition at line 704 of file Object.h.

705  {
706  float d = GetExactDist(x, y, z) - GetObjectSize();
707  return d > 0.0f ? d : 0.0f;
708  }
float GetExactDist(float x, float y, float z) const
Definition: Position.h:150
float GetObjectSize() const
Definition: Object.h:645
float WorldObject::GetDistance2d ( const WorldObject obj) const
inline

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

710  {
711  float d = GetExactDist2d(obj) - GetObjectSize() - obj->GetObjectSize();
712  return d > 0.0f ? d : 0.0f;
713  }
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:130
float GetObjectSize() const
Definition: Object.h:645
float WorldObject::GetDistance2d ( float  x,
float  y 
) const
inline

Definition at line 714 of file Object.h.

715  {
716  float d = GetExactDist2d(x, y) - GetObjectSize();
717  return d > 0.0f ? d : 0.0f;
718  }
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:130
float GetObjectSize() const
Definition: Object.h:645
bool WorldObject::GetDistanceOrder ( WorldObject const *  obj1,
WorldObject const *  obj2,
bool  is3D = true 
) const

Definition at line 1299 of file Object.cpp.

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

1300 {
1301  float dx1 = GetPositionX() - obj1->GetPositionX();
1302  float dy1 = GetPositionY() - obj1->GetPositionY();
1303  float distsq1 = dx1 * dx1 + dy1 * dy1;
1304  if (is3D)
1305  {
1306  float dz1 = GetPositionZ() - obj1->GetPositionZ();
1307  distsq1 += dz1 * dz1;
1308  }
1309 
1310  float dx2 = GetPositionX() - obj2->GetPositionX();
1311  float dy2 = GetPositionY() - obj2->GetPositionY();
1312  float distsq2 = dx2 * dx2 + dy2 * dy2;
1313  if (is3D)
1314  {
1315  float dz2 = GetPositionZ() - obj2->GetPositionZ();
1316  distsq2 += dz2 * dz2;
1317  }
1318 
1319  return distsq1 < distsq2;
1320 }
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 1226 of file Object.cpp.

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

1227 {
1228  float dx = GetPositionX() - x;
1229  float dy = GetPositionY() - y;
1230  float dz = GetPositionZ() - z;
1231  float sizefactor = GetObjectSize();
1232  float dist = dx * dx + dy * dy + dz * dz - sizefactor;
1233  return (dist > 0 ? dist : 0);
1234 }
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:645
float WorldObject::GetDistanceZ ( const WorldObject obj) const

Definition at line 1218 of file Object.cpp.

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

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

1219 {
1220  float dz = fabs(GetPositionZ() - obj->GetPositionZ());
1221  float sizefactor = GetObjectSize() + obj->GetObjectSize();
1222  float dist = dz - sizefactor;
1223  return (dist > 0 ? dist : 0);
1224 }
float GetPositionZ() const
Definition: Position.h:99
float GetObjectSize() const
Definition: Object.h:645
Position WorldObject::GetFirstCollisionPosition ( float  dist,
float  angle 
)

Definition at line 2419 of file Object.cpp.

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

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

2420 {
2421  Position pos = GetPosition();
2422  MovePositionToFirstCollision(pos, dist, angle);
2423  return pos;
2424 }
Position GetPosition() const
Definition: Position.h:117
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition: Object.cpp:2525
void WorldObject::GetGameObjectListWithEntryInGrid ( std::list< GameObject * > &  gameobjectList,
uint32  entry = GRID_SEARCH_ALL_ENTRIES,
float  maxSearchRange = 250.0f 
) const

Definition at line 2346 of file Object.cpp.

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

Referenced by GetGameObjectListWithEntryInGrid().

2347 {
2349  Cell cell(pair);
2350  cell.SetNoCreate();
2351 
2352  Oregon::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
2353  Oregon::GameObjectListSearcher<Oregon::AllGameObjectsWithEntryInRange> searcher(this, gameobjectList, check);
2355 
2356  cell.Visit(pair, visitor, *(this->GetMap()), *this, maxSearchRange);
2357 }
Map * GetMap() const
Definition: Object.h:817
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
float GetPositionX() const
Definition: Position.h:97
float WorldObject::GetGridActivationRange ( ) const

Definition at line 1554 of file Object.cpp.

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

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

1555 {
1556  if (ToPlayer())
1557  {
1558  if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
1560  return GetMap()->GetVisibilityRange();
1561  }
1562  else if (ToCreature())
1563  return ToCreature()->m_SightDistance;
1564  else if (ToDynObject())
1565  {
1566  if (isActiveObject())
1567  return GetMap()->GetVisibilityRange();
1568  else
1569  return 0.0f;
1570  }
1571  else
1572  return 0.0f;
1573 }
Map * GetMap() const
Definition: Object.h:817
#define DEFAULT_VISIBILITY_INSTANCE
Definition: Object.h:46
DynamicObject * ToDynObject()
Definition: Object.h:383
Player * ToPlayer()
Definition: Object.h:368
bool isActiveObject() const
Definition: Object.h:875
float GetVisibilityRange() const
Definition: Map.h:291
Creature * ToCreature()
Definition: Object.h:371
float m_SightDistance
Definition: Creature.h:797
Position WorldObject::GetHitSpherePointFor ( Position const &  dest) const

Definition at line 1282 of file Object.cpp.

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

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

1283 {
1284  G3D::Vector3 vThis(GetPositionX(), GetPositionY(), GetPositionZ());
1285  G3D::Vector3 vObj(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
1286  G3D::Vector3 contactPoint = vThis + (vObj - vThis).directionOrZero() * GetObjectSize();
1287 
1288  return Position(contactPoint.x, contactPoint.y, contactPoint.z, GetAngle(contactPoint.x, contactPoint.y));
1289 }
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:645
void WorldObject::GetHitSpherePointFor ( Position const &  dest,
float &  x,
float &  y,
float &  z 
) const

Definition at line 1291 of file Object.cpp.

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

1292 {
1293  Position pos = GetHitSpherePointFor(dest);
1294  x = pos.GetPositionX();
1295  y = pos.GetPositionY();
1296  z = pos.GetPositionZ();
1297 }
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1282
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 1212 of file Object.cpp.

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

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

1213 {
1214  Map* map = GetMap();
1215  return map->IsDungeon() ? ((InstanceMap*)map)->GetInstanceData() : NULL;
1216 }
Map * GetMap() const
Definition: Object.h:817
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 768 of file Object.h.

Referenced by CanDetectStealthOf().

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

Definition at line 817 of file Object.h.

References ASSERT.

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

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

Definition at line 680 of file Object.h.

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

681  {
682  return m_name.c_str();
683  }
std::string m_name
Definition: Object.h:894
virtual const char* WorldObject::GetNameForLocaleIdx ( int32  ) const
inlinevirtual

Reimplemented in GameObject, and Creature.

Definition at line 689 of file Object.h.

Referenced by CreatureTextMgr::BuildMonsterChat().

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

Definition at line 2381 of file Object.cpp.

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

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

2382 {
2383  GetNearPoint2D(x, y, distance2d + searcher_size, absAngle);
2384  z = GetPositionZ();
2385  UpdateAllowedPositionZ(x, y, z);
2386 
2387  // return if the point is already in LoS
2388  if (IsWithinLOS(x, y, z))
2389  return;
2390 
2391  // remember first point
2392  float first_x = x;
2393  float first_y = y;
2394  float first_z = z;
2395 
2396  // loop in a circle to look for a point in LoS using small steps
2397  for (float angle = float(M_PI) / 8; angle < float(M_PI) * 2; angle += float(M_PI) / 8)
2398  {
2399  GetNearPoint2D(x, y, distance2d + searcher_size, absAngle);
2400  z = GetPositionZ();
2401  UpdateAllowedPositionZ(x, y, z);
2402  if (IsWithinLOS(x, y, z))
2403  return;
2404  }
2405 
2406  // still not in LoS, give up and return first position found
2407  x = first_x;
2408  y = first_y;
2409  z = first_z;
2410 }
void UpdateAllowedPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1442
bool IsWithinLOS(float x, float y, float z) const
Definition: Object.cpp:1266
float GetPositionZ() const
Definition: Position.h:99
void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const
Definition: Object.cpp:2372
void WorldObject::GetNearPoint2D ( float &  x,
float &  y,
float  distance,
float  absAngle 
) const

Definition at line 2372 of file Object.cpp.

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

Referenced by GetNearPoint().

2373 {
2374  x = GetPositionX() + (GetObjectSize() + distance2d) * cos(absAngle);
2375  y = GetPositionY() + (GetObjectSize() + distance2d) * sin(absAngle);
2376 
2379 }
float GetPositionY() const
Definition: Position.h:98
float GetPositionX() const
Definition: Position.h:97
float GetObjectSize() const
Definition: Object.h:645
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:184
Position WorldObject::GetNearPosition ( float  dist,
float  angle 
)

Definition at line 2412 of file Object.cpp.

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

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

2413 {
2414  Position pos = GetPosition();
2415  MovePosition(pos, dist, angle);
2416  return pos;
2417 }
void MovePosition(Position &pos, float dist, float angle)
Definition: Object.cpp:2473
Position GetPosition() const
Definition: Position.h:117
uint16 WorldObject::GetNotifyFlags ( ) const
inline

Definition at line 860 of file Object.h.

860 { return m_notifyflags; }
uint16 m_notifyflags
Definition: Object.h:919
virtual float WorldObject::GetObjectBoundingRadius ( ) const
inlinevirtual

Definition at line 640 of file Object.h.

References DEFAULT_WORLD_OBJECT_SIZE.

Referenced by Spell::EffectDummy().

641  {
643  }
#define DEFAULT_WORLD_OBJECT_SIZE
Definition: Object.h:49
float WorldObject::GetPositionZTarget ( Position pos,
float  destx,
float  desty 
)

Definition at line 2436 of file Object.cpp.

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

Referenced by MovePositionToFirstCollision().

2437 {
2438 
2439  // Added in Bitbucket issue #1105 in order to solve the problem of
2440  // leap effects like Blink taking the caster to the bottom of a body of liquid.
2441 
2442  float bottom, ground, floor;
2443 
2444  ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
2445  floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
2446  // If we were to ignore liquid, the WorldObject would be placed here.
2447  bottom = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
2448 
2449  if(pos.m_positionZ > bottom)
2450  {
2451 
2452  // We are in the water or in the air.
2453  // Must be at least above ground.
2454 
2455  LiquidData dest_status;
2456  GetMap()->getLiquidStatus(destx, desty, pos.m_positionZ, MAP_ALL_LIQUIDS, &dest_status);
2457 
2458  // Source and destination are underwater.
2459  if(dest_status.level > pos.m_positionZ)
2460  return pos.m_positionZ;
2461 
2462  // When in doubt, send the user to water/ground level.
2463  return fabs(dest_status.level - pos.m_positionZ) <= fabs(bottom - pos.m_positionZ) ? dest_status.level : bottom;
2464 
2465  }
2466  else
2467  {
2468  // Destination is on or under the ground. Use ground Z.
2469  return bottom;
2470  }
2471 }
Map * GetMap() const
Definition: Object.h:817
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:1591
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=0) const
Definition: Map.cpp:1728
float level
Definition: Map.h:151
float m_positionZ
Definition: Position.h:52
#define MAP_ALL_LIQUIDS
Definition: Map.h:142
#define MAX_HEIGHT
Definition: Map.h:258
Position WorldObject::GetRandomNearPosition ( float  radius)

Definition at line 2426 of file Object.cpp.

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

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

2427 {
2428  Position pos = GetPosition();
2429  MovePosition(pos, radius * (float)rand_norm(), (float)rand_norm() * static_cast<float>(2 * M_PI));
2430  return pos;
2431 }
void MovePosition(Position &pos, float dist, float angle)
Definition: Object.cpp:2473
double rand_norm()
Definition: Util.cpp:48
Position GetPosition() const
Definition: Position.h:117
void WorldObject::GetRandomPoint ( const Position srcPos,
float  distance,
float &  rand_x,
float &  rand_y,
float &  rand_z 
) const

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

1422 {
1423  if (!distance)
1424  {
1425  pos.GetPosition(rand_x, rand_y, rand_z);
1426  return;
1427  }
1428 
1429  // angle to face `obj` to `this`
1430  float angle = rand_norm() * 2 * M_PI;
1431  float new_dist = rand_norm() * distance;
1432 
1433  rand_x = pos.m_positionX + new_dist * cos(angle);
1434  rand_y = pos.m_positionY + new_dist * sin(angle);
1435  rand_z = pos.m_positionZ;
1436 
1437  Oregon::NormalizeMapCoord(rand_x);
1438  Oregon::NormalizeMapCoord(rand_y);
1439  UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available
1440 }
double rand_norm()
Definition: Util.cpp:48
void UpdateGroundPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1506
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:184
void WorldObject::GetRandomPoint ( const Position srcPos,
float  distance,
Position pos 
) const
inline

Definition at line 653 of file Object.h.

References Position::Relocate().

654  {
655  float x, y, z;
656  GetRandomPoint(srcPos, distance, x, y, z);
657  pos.Relocate(x, y, z, GetOrientation());
658  }
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:1421
float WorldObject::GetSightRange ( const WorldObject target = NULL) const

Definition at line 1585 of file Object.cpp.

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

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

1586 {
1587  if (ToUnit())
1588  {
1589  if (ToPlayer())
1590  {
1591  if (target && target->IsVisibilityOverridden() && !target->ToPlayer())
1592  return target->m_visibilityDistanceOverride;
1593  else if (target && target->isActiveObject() && !target->ToPlayer())
1594  return MAX_VISIBILITY_DISTANCE;
1595  else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
1597  else
1598  return GetMap()->GetVisibilityRange();
1599  }
1600  else if (ToCreature())
1601  return ToCreature()->m_SightDistance;
1602  else
1603  return SIGHT_RANGE_UNIT;
1604  }
1605 
1606  if (ToDynObject() && isActiveObject())
1607  return GetMap()->GetVisibilityRange();
1608 
1609  return 0.0f;
1610 }
Map * GetMap() const
Definition: Object.h:817
#define DEFAULT_VISIBILITY_INSTANCE
Definition: Object.h:46
bool IsVisibilityOverridden() const
Definition: Object.h:877
DynamicObject * ToDynObject()
Definition: Object.h:383
#define SIGHT_RANGE_UNIT
Definition: Object.h:39
Player * ToPlayer()
Definition: Object.h:368
CinematicMgr * GetCinematicMgr() const
Definition: Player.h:1258
float m_visibilityDistanceOverride
Definition: Object.h:898
bool isActiveObject() const
Definition: Object.h:875
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:371
float m_SightDistance
Definition: Creature.h:797
Unit * ToUnit()
Definition: Object.h:374
float WorldObject::GetVisibilityRange ( ) const

Definition at line 1575 of file Object.cpp.

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

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

1576 {
1577  if (IsVisibilityOverridden() && !ToPlayer())
1579  else if (isActiveObject() && !ToPlayer())
1580  return MAX_VISIBILITY_DISTANCE;
1581  else
1582  return GetMap()->GetVisibilityRange();
1583 }
Map * GetMap() const
Definition: Object.h:817
bool IsVisibilityOverridden() const
Definition: Object.h:877
Player * ToPlayer()
Definition: Object.h:368
float m_visibilityDistanceOverride
Definition: Object.h:898
bool isActiveObject() const
Definition: Object.h:875
float GetVisibilityRange() const
Definition: Map.h:291
#define MAX_VISIBILITY_DISTANCE
Definition: Object.h:38
uint32 WorldObject::GetZoneId ( ) const

Definition at line 1202 of file Object.cpp.

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

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

1203 {
1205 }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
static uint32 GetZoneId(uint16 areaflag, uint32 map_id)
Definition: Map.cpp:1832
float m_positionZ
Definition: Position.h:52
Map const * GetBaseMap() const
Definition: Object.cpp:2011
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 1388 of file Object.cpp.

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

1389 {
1390  // always have self in arc
1391  if (x == m_positionX && y == m_positionY)
1392  return true;
1393 
1394  float arc = arcangle;
1395 
1396  // move arc to range 0.. 2*pi
1397  while ( arc >= 2.0f * float(M_PI) )
1398  arc -= 2.0f * float(M_PI);
1399  while ( arc < 0 )
1400  arc += 2.0f * float(M_PI);
1401 
1402  float angle = GetAngle( x, y );
1403  angle -= GetOrientation();
1404 
1405  // move angle to range -pi ... +pi
1406  while ( angle > float(M_PI))
1407  angle -= 2.0f * float(M_PI);
1408  while (angle < -M_PI)
1409  angle += 2.0f * float(M_PI);
1410 
1411  float lborder = -1 * (arc / 2.0f); // in range -pi..0
1412  float rborder = (arc / 2.0f); // in range 0..pi
1413  return (( angle >= lborder ) && ( angle <= rborder ));
1414 }
float m_positionY
Definition: Position.h:51
float m_positionX
Definition: Position.h:50
float GetOrientation() const
Definition: Position.h:100
float GetAngle(Position const *pos) const
bool WorldObject::InSamePhase ( WorldObject const *  obj) const
inline

Definition at line 672 of file Object.h.

References GetPhaseMask(), and InSamePhase().

Referenced by InSamePhase().

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

Definition at line 673 of file Object.h.

References InSamePhase().

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

Definition at line 875 of file Object.h.

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

875 { return m_isActive; }
bool m_isActive
Definition: Object.h:895
virtual bool WorldObject::IsAlwaysDetectableFor ( WorldObject const *  ) const
inlinevirtual

Reimplemented in Player, and Unit.

Definition at line 796 of file Object.h.

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

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

Reimplemented in Unit, and GameObject.

Definition at line 793 of file Object.h.

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

793 { 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 1322 of file Object.cpp.

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

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

1323 {
1324  float dx = GetPositionX() - obj->GetPositionX();
1325  float dy = GetPositionY() - obj->GetPositionY();
1326  float distsq = dx * dx + dy * dy;
1327  if (is3D)
1328  {
1329  float dz = GetPositionZ() - obj->GetPositionZ();
1330  distsq += dz * dz;
1331  }
1332 
1333  float sizefactor = GetObjectSize() + obj->GetObjectSize();
1334 
1335  // check only for real range
1336  if (minRange > 0.0f)
1337  {
1338  float mindist = minRange + sizefactor;
1339  if (distsq < mindist * mindist)
1340  return false;
1341  }
1342 
1343  float maxdist = maxRange + sizefactor;
1344  return distsq < maxdist * maxdist;
1345 }
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:645
bool WorldObject::IsInRange2d ( float  x,
float  y,
float  minRange,
float  maxRange 
) const

Definition at line 1347 of file Object.cpp.

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

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

Definition at line 1367 of file Object.cpp.

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

1368 {
1369  float dx = GetPositionX() - x;
1370  float dy = GetPositionY() - y;
1371  float dz = GetPositionZ() - z;
1372  float distsq = dx * dx + dy * dy + dz * dz;
1373 
1374  float sizefactor = GetObjectSize();
1375 
1376  // check only for real range
1377  if (minRange > 0.0f)
1378  {
1379  float mindist = minRange + sizefactor;
1380  if (distsq < mindist * mindist)
1381  return false;
1382  }
1383 
1384  float maxdist = maxRange + sizefactor;
1385  return distsq < maxdist * maxdist;
1386 }
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:645
virtual bool WorldObject::IsInvisibleDueToDespawn ( ) const
inlinevirtual

Reimplemented in Creature, and GameObject.

Definition at line 794 of file Object.h.

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

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

Reimplemented in Player, and GameObject.

Definition at line 792 of file Object.h.

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

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

Definition at line 880 of file Object.h.

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

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

Reimplemented in Unit.

Definition at line 1546 of file Object.cpp.

References Object::IsInWorld().

Referenced by Unit::isValid().

1547 {
1548  if (!IsInWorld())
1549  return false;
1550 
1551  return true;
1552 }
const bool & IsInWorld() const
Definition: Object.h:150
bool WorldObject::IsVisibilityOverridden ( ) const
inline

Definition at line 877 of file Object.h.

References ByteConverter::apply().

Referenced by GetSightRange(), and GetVisibilityRange().

877 { return m_visibilityDistanceOverride != 0; }
float m_visibilityDistanceOverride
Definition: Object.h:898
bool WorldObject::IsWithinDist ( WorldObject const *  obj,
float  dist2compare,
bool  is3D = true 
) const
inline

Definition at line 746 of file Object.h.

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

747  {
748  return obj && _IsWithinDist(obj, dist2compare, is3D);
749  }
bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D) const
Definition: Object.cpp:1236
bool WorldObject::IsWithinDist2d ( float  x,
float  y,
float  dist 
) const
inline

Definition at line 736 of file Object.h.

737  {
738  return IsInDist2d(x, y, dist + GetObjectSize());
739  }
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:178
float GetObjectSize() const
Definition: Object.h:645
bool WorldObject::IsWithinDist2d ( const Position pos,
float  dist 
) const
inline

Definition at line 740 of file Object.h.

741  {
742  return IsInDist2d(pos, dist + GetObjectSize());
743  }
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:178
float GetObjectSize() const
Definition: Object.h:645
bool WorldObject::IsWithinDist3d ( float  x,
float  y,
float  z,
float  dist 
) const
inline

Definition at line 728 of file Object.h.

Referenced by Player::TeleportTo().

729  {
730  return IsInDist(x, y, z, dist + GetObjectSize());
731  }
float GetObjectSize() const
Definition: Object.h:645
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 732 of file Object.h.

733  {
734  return IsInDist(pos, dist + GetObjectSize());
735  }
float GetObjectSize() const
Definition: Object.h:645
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 750 of file Object.h.

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

751  {
752  return obj && IsInMap(obj) && _IsWithinDist(obj, dist2compare, is3D);
753  }
bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D) const
Definition: Object.cpp:1236
bool IsInMap(const WorldObject *obj) const
Definition: Object.h:721
bool WorldObject::IsWithinLOS ( float  x,
float  y,
float  z 
) const

Definition at line 1266 of file Object.cpp.

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

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

1267 {
1268  if (IsInWorld())
1269  {
1270  float x, y, z;
1271  if (GetTypeId() == TYPEID_PLAYER)
1272  GetPosition(x, y, z);
1273  else
1274  GetHitSpherePointFor({ ox, oy, oz }, x, y, z);
1275 
1276  return GetMap()->isInLineOfSight(x, y, z + 2.0f, ox, oy, oz + 2.0f);
1277  }
1278 
1279  return true;
1280 }
Map * GetMap() const
Definition: Object.h:817
uint8 GetTypeId() const
Definition: Object.h:192
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1282
const bool & IsInWorld() const
Definition: Object.h:150
Position GetPosition() const
Definition: Position.h:117
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2) const
Definition: Map.cpp:1802
bool WorldObject::IsWithinLOSInMap ( const WorldObject obj) const

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

1253 {
1254  if (!IsInMap(obj))
1255  return false;
1256 
1257  float x, y, z;
1258  if (obj->GetTypeId() == TYPEID_PLAYER)
1259  obj->GetPosition(x, y, z);
1260  else
1261  obj->GetHitSpherePointFor(GetPosition(), x, y, z);
1262 
1263  return IsWithinLOS(x, y, z);
1264 }
bool IsWithinLOS(float x, float y, float z) const
Definition: Object.cpp:1266
uint8 GetTypeId() const
Definition: Object.h:192
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1282
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:721
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:896
Creature * ToCreature()
Definition: Object.h:371
void WorldObject::MonsterSay ( const char *  text,
uint32  language,
uint64  TargetGuid 
)

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

1514 {
1515  WorldPacket data(SMSG_MESSAGECHAT, 200);
1516  BuildMonsterChat(&data, CHAT_MSG_MONSTER_SAY, text, language, GetName(), TargetGuid);
1517  SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY), true);
1518 }
const char * GetName() const
Definition: Object.h:680
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
Definition: Object.cpp:1934
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
Definition: Object.cpp:1960
#define sWorld
Definition: World.h:860
void WorldObject::MonsterSay ( int32  textId,
uint32  language,
uint64  TargetGuid 
)

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

1865 {
1867 
1868  Cell cell(p);
1869  cell.SetNoCreate();
1870 
1871  Oregon::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_SAY, textId, language, TargetGuid);
1875  cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_SAY));
1876 }
Map * GetMap() const
Definition: Object.h:817
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
#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 1527 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().

1528 {
1529  WorldPacket data(SMSG_MESSAGECHAT, 200);
1530  BuildMonsterChat(&data, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, text, LANG_UNIVERSAL, GetName(), TargetGuid);
1532 }
const char * GetName() const
Definition: Object.h:680
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
Definition: Object.cpp:1934
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
Definition: Object.cpp:1960
#define sWorld
Definition: World.h:860
void WorldObject::MonsterTextEmote ( int32  textId,
uint64  TargetGuid,
bool  IsBossEmote = false 
)

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

1906 {
1908 
1909  Cell cell(p);
1910  cell.SetNoCreate();
1911 
1912  Oregon::MonsterChatBuilder say_build(*this, IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, textId, LANG_UNIVERSAL, TargetGuid);
1916  cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE));
1917 }
Map * GetMap() const
Definition: Object.h:817
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
#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 1534 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().

1535 {
1536  Player* player = sObjectMgr.GetPlayer(receiver);
1537  if (!player || !player->GetSession())
1538  return;
1539 
1540  WorldPacket data(SMSG_MESSAGECHAT, 200);
1541  BuildMonsterChat(&data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, GetName(), receiver);
1542 
1543  player->GetSession()->SendPacket(&data);
1544 }
#define sObjectMgr
Definition: ObjectMgr.h:1317
void SendPacket(WorldPacket const *packet)
const char * GetName() const
Definition: Object.h:680
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
Definition: Object.cpp:1934
WorldSession * GetSession() const
Definition: Player.h:1947
Definition: Player.h:923
void WorldObject::MonsterWhisper ( int32  textId,
uint64  receiver,
bool  IsBossWhisper = false 
)

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

1920 {
1921  Player* player = sObjectMgr.GetPlayer(receiver);
1922  if (!player || !player->GetSession())
1923  return;
1924 
1925  uint32 loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
1926  char const* text = sObjectMgr.GetOregonString(textId, loc_idx);
1927 
1928  WorldPacket data(SMSG_MESSAGECHAT, 200);
1929  BuildMonsterChat(&data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, GetName(), receiver);
1930 
1931  player->GetSession()->SendPacket(&data);
1932 }
#define sObjectMgr
Definition: ObjectMgr.h:1317
void SendPacket(WorldPacket const *packet)
const char * GetName() const
Definition: Object.h:680
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:1934
WorldSession * GetSession() const
Definition: Player.h:1947
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:923
void WorldObject::MonsterYell ( const char *  text,
uint32  language,
uint64  TargetGuid 
)

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

1521 {
1522  WorldPacket data(SMSG_MESSAGECHAT, 200);
1523  BuildMonsterChat(&data, CHAT_MSG_MONSTER_YELL, text, language, GetName(), TargetGuid);
1524  SendMessageToSetInRange(&data, sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL), true);
1525 }
const char * GetName() const
Definition: Object.h:680
void BuildMonsterChat(WorldPacket *data, uint8 msgtype, char const *text, uint32 language, char const *name, uint64 TargetGuid) const
Definition: Object.cpp:1934
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self)
Definition: Object.cpp:1960
#define sWorld
Definition: World.h:860
void WorldObject::MonsterYell ( int32  textId,
uint32  language,
uint64  TargetGuid 
)

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

1879 {
1881 
1882  Cell cell(p);
1883  cell.SetNoCreate();
1884 
1885  Oregon::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, TargetGuid);
1889  cell.Visit(p, message, *GetMap(), *this, sWorld.getConfig(CONFIG_LISTEN_RANGE_YELL));
1890 }
Map * GetMap() const
Definition: Object.h:817
float GetPositionY() const
Definition: Position.h:98
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
Definition: Cell.h:46
#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 1892 of file Object.cpp.

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

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

1893 {
1894  Oregon::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_YELL, textId, language, TargetGuid);
1896 
1897  uint32 zoneid = GetZoneId();
1898 
1899  Map::PlayerList const& pList = GetMap()->GetPlayers();
1900  for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
1901  if (itr->GetSource()->GetZoneId() == zoneid)
1902  say_do(itr->GetSource());
1903 }
Map * GetMap() const
Definition: Object.h:817
uint32 GetZoneId() const
Definition: Object.cpp:1202
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 2473 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().

2474 {
2475  angle += GetOrientation();
2476  float destx, desty, destz, ground, floor;
2477  destx = pos.m_positionX + dist * cos(angle);
2478  desty = pos.m_positionY + dist * sin(angle);
2479 
2480  // Prevent invalid coordinates here, position is unchanged
2481  if (!Oregon::IsValidMapCoord(destx, desty, pos.m_positionZ))
2482  {
2483  sLog.outString("WorldObject::MovePosition invalid coordinates X: %f and Y: %f were passed!", destx, desty);
2484  return;
2485  }
2486 
2487  // Prevent invalid coordinates here, position is unchanged
2488  if (!Oregon::IsValidMapCoord(destx, desty))
2489  {
2490  sLog.outError("Crash alert! WorldObject::MovePositionToFirstCollision invalid coordinates X: %f and Y: %f were passed!", destx, desty);
2491  return;
2492  }
2493 
2494  ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
2495  floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
2496  destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
2497 
2498  float step = dist / 10.0f;
2499 
2500  for (uint8 j = 0; j < 10; ++j)
2501  {
2502  // do not allow too big z changes
2503  if (fabs(pos.m_positionZ - destz) > 6)
2504  {
2505  destx -= step * cos(angle);
2506  desty -= step * sin(angle);
2507  ground = GetMap()->GetHeight(destx, desty, MAX_HEIGHT, true);
2508  floor = GetMap()->GetHeight(destx, desty, pos.m_positionZ, true);
2509  destz = fabs(ground - pos.m_positionZ) <= fabs(floor - pos.m_positionZ) ? ground : floor;
2510  }
2511  // we have correct destz now
2512  else
2513  {
2514  pos.Relocate(destx, desty, destz);
2515  break;
2516  }
2517  }
2518 
2523 }
Map * GetMap() const
Definition: Object.h:817
float m_positionY
Definition: Position.h:51
void SetOrientation(float orientation)
Definition: Position.h:92
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:1591
#define sLog
Log class singleton.
Definition: Log.h:187
bool IsValidMapCoord(float c)
Definition: GridDefines.h:192
float m_positionX
Definition: Position.h:50
ACE_UINT8 uint8
Definition: Define.h:73
float GetOrientation() const
Definition: Position.h:100
void Relocate(float x, float y)
Definition: Position.h:65
float m_positionZ
Definition: Position.h:52
#define MAX_HEIGHT
Definition: Map.h:258
void UpdateGroundPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1506
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:184
void WorldObject::MovePositionToFirstCollision ( Position pos,
float  dist,
float  angle 
)

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

2526 {
2527  angle += GetOrientation();
2528  float destx, desty, destz;
2529  destx = pos.m_positionX + dist * cos(angle);
2530  desty = pos.m_positionY + dist * sin(angle);
2531 
2532  // Prevent invalid coordinates here, position is unchanged
2533  if (!Oregon::IsValidMapCoord(destx, desty))
2534  {
2535  sLog.outFatal("WorldObject::MovePositionToFirstCollision invalid coordinates X: %f and Y: %f were passed!", destx, desty);
2536  return;
2537  }
2538 
2539  destz = GetPositionZTarget(pos, destx, desty);
2540  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);
2541 
2542  // collision occured
2543  if (col)
2544  {
2545  // move back a bit
2546  destx -= CONTACT_DISTANCE * cos(angle);
2547  desty -= CONTACT_DISTANCE * sin(angle);
2548  dist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
2549  }
2550 
2551  // check dynamic collision
2552  col = GetMap()->getObjectHitPos(pos.m_positionX, pos.m_positionY, pos.m_positionZ + 0.5f, destx, desty, destz + 0.5f, destx, desty, destz, -0.5f);
2553 
2554  // Collided with a gameobject
2555  if (col)
2556  {
2557  destx -= CONTACT_DISTANCE * cos(angle);
2558  desty -= CONTACT_DISTANCE * sin(angle);
2559  dist = sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty));
2560  }
2561 
2562  float step = dist / 10.0f;
2563 
2564  for (uint8 j = 0; j < 10; ++j)
2565  {
2566  // do not allow too big z changes
2567  if (fabs(pos.m_positionZ - destz) > 6.0f)
2568  {
2569  destx -= step * cos(angle);
2570  desty -= step * sin(angle);
2571  destz = GetPositionZTarget(pos, destx, desty);
2572  }
2573  // we have correct destz now
2574  else
2575  {
2576  pos.Relocate(destx, desty, destz);
2577  break;
2578  }
2579  }
2580 
2583  pos.m_positionZ = GetPositionZTarget(pos, destx, desty);
2585 }
Map * GetMap() const
Definition: Object.h:817
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:2436
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:567
float m_positionZ
Definition: Position.h:52
static IVMapManager * createOrGetVMapManager()
#define CONTACT_DISTANCE
Definition: Object.h:34
bool getObjectHitPos(float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist)
Definition: Map.cpp:1808
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:184
bool WorldObject::NotifyExecuted ( uint16  f) const
inline

Definition at line 861 of file Object.h.

862  {
863  return m_executed_notifies & f;
864  }
uint16 m_executed_notifies
Definition: Object.h:920
void WorldObject::PlayDirectSound ( uint32  sound_id,
Player target = NULL 
)

Definition at line 2606 of file Object.cpp.

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

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

2607 {
2608  WorldPacket data(SMSG_PLAY_SOUND, 4);
2609  data << uint32(sound_id);
2610  if (target)
2611  target->SendDirectMessage(&data);
2612  else
2613  SendMessageToSet(&data, true);
2614 }
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:765
void SendDirectMessage(WorldPacket *data)
Definition: Player.cpp:5717
ACE_UINT32 uint32
Definition: Define.h:71
void WorldObject::PlayDistanceSound ( uint32  sound_id,
Player target = NULL 
)

Definition at line 2595 of file Object.cpp.

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

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

2596 {
2597  WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 4 + 8);
2598  data << uint32(sound_id);
2599  data << uint64(GetGUID());
2600  if (target)
2601  target->SendDirectMessage(&data);
2602  else
2603  SendMessageToSet(&data, true);
2604 }
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:765
uint64 GetGUID() const
Definition: Object.h:177
void SendDirectMessage(WorldPacket *data)
Definition: Player.cpp:5717
ACE_UINT64 uint64
Definition: Define.h:70
ACE_UINT32 uint32
Definition: Define.h:71
void WorldObject::RemoveFromWorld ( )
overridevirtual

Reimplemented from Object.

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

Definition at line 1192 of file Object.cpp.

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

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

1193 {
1194  if (!IsInWorld())
1195  return;
1196 
1198 
1200 }
virtual void RemoveFromWorld()
Definition: Object.h:166
const bool & IsInWorld() const
Definition: Object.h:150
void DestroyForNearbyPlayers()
Definition: Object.cpp:2616
void WorldObject::ResetAllNotifies ( )
inline

Definition at line 869 of file Object.h.

870  {
871  m_notifyflags = 0;
873  }
uint16 m_notifyflags
Definition: Object.h:919
uint16 m_executed_notifies
Definition: Object.h:920
void WorldObject::ResetMap ( )
virtual

Reimplemented in Player.

Definition at line 1999 of file Object.cpp.

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

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

2000 {
2001  ASSERT(m_currMap);
2002  ASSERT(!IsInWorld());
2003  if (IsWorldObject())
2005  m_currMap = NULL;
2006  //maybe not for corpse
2007  //m_mapId = 0;
2008  //m_InstanceId = 0;
2009 }
Map * m_currMap
Definition: Object.h:913
bool IsWorldObject() const
Definition: Object.cpp:1111
void RemoveWorldObject(WorldObject *obj)
Definition: Map.h:483
const bool & IsInWorld() const
Definition: Object.h:150
#define ASSERT
Definition: Errors.h:29
virtual void WorldObject::SaveRespawnTime ( )
inlinevirtual

Reimplemented in GameObject, and Creature.

Definition at line 787 of file Object.h.

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

Reimplemented in Player.

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

Reimplemented in Player.

Definition at line 1960 of file Object.cpp.

References VisitNearbyWorldObject().

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

1961 {
1962  Oregon::MessageDistDeliverer notifier(this, data, dist);
1963  VisitNearbyWorldObject(dist, notifier);
1964 }
void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const
Definition: Object.h:883
void WorldObject::SendObjectCustomAnim ( uint64  guid,
uint32  anim = 0 
)

Definition at line 1973 of file Object.cpp.

References SendMessageToSet(), and SMSG_GAMEOBJECT_CUSTOM_ANIM.

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

1974 {
1976  data << uint64(guid);
1977  data << uint32(anim);
1978  SendMessageToSet(&data, true);
1979 }
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:765
ACE_UINT64 uint64
Definition: Define.h:70
ACE_UINT32 uint32
Definition: Define.h:71
void WorldObject::SendObjectDeSpawnAnim ( uint64  guid)

Definition at line 1966 of file Object.cpp.

References SendMessageToSet(), and SMSG_GAMEOBJECT_DESPAWN_ANIM.

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

1967 {
1969  data << uint64(guid);
1970  SendMessageToSet(&data, true);
1971 }
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:765
ACE_UINT64 uint64
Definition: Define.h:70
void WorldObject::SendPlaySound ( uint32  Sound,
bool  OnlySelf 
)

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

1818 {
1819  WorldPacket data(SMSG_PLAY_SOUND, 4);
1820  data << Sound;
1821  if (OnlySelf && GetTypeId() == TYPEID_PLAYER)
1822  ToPlayer()->GetSession()->SendPacket(&data);
1823  else
1824  SendMessageToSet(&data, true); // ToSelf ignored in this case
1825 }
void SendPacket(WorldPacket const *packet)
virtual void SendMessageToSet(WorldPacket *data, bool self)
Definition: Object.h:765
Player * ToPlayer()
Definition: Object.h:368
uint8 GetTypeId() const
Definition: Object.h:192
WorldSession * GetSession() const
Definition: Player.h:1947
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 (on && !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:192
const bool & IsInWorld() const
Definition: Object.h:150
Map * FindMap() const
Definition: Object.h:818
bool m_isActive
Definition: Object.h:895
Definition: Map.h:266
Creature * ToCreature()
Definition: Object.h:371
void AddToActive(T *obj)
Definition: Map.h:502
void WorldObject::SetLocationInstanceId ( uint32  _instanceId)
inlineprotected

Definition at line 907 of file Object.h.

Referenced by Corpse::LoadCorpseFromDB().

908  {
909  m_InstanceId = _instanceId;
910  }
uint32 m_InstanceId
Definition: Object.h:916
void WorldObject::SetLocationMapId ( uint32  _mapId)
inlineprotected

Definition at line 903 of file Object.h.

Referenced by Corpse::LoadCorpseFromDB().

904  {
905  m_mapId = _mapId;
906  }
uint32 m_mapId
Definition: Object.h:572
void WorldObject::SetMap ( Map map)
virtual

Reimplemented in Player.

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

1982 {
1983  ASSERT(map);
1985  if (m_currMap == map) // command add npc: first create, than loadfromdb
1986  return;
1987  if (m_currMap)
1988  {
1989  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());
1990  ASSERT(false);
1991  }
1992  m_currMap = map;
1993  m_mapId = map->GetId();
1994  m_InstanceId = map->GetInstanceId();
1995  if (IsWorldObject())
1996  m_currMap->AddWorldObject(this);
1997 }
Map * m_currMap
Definition: Object.h:913
#define sLog
Log class singleton.
Definition: Log.h:187
bool IsWorldObject() const
Definition: Object.cpp:1111
uint32 m_InstanceId
Definition: Object.h:916
uint32 GetId(void) const
Definition: Map.h:333
uint8 GetTypeId() const
Definition: Object.h:192
uint32 m_mapId
Definition: Object.h:572
const bool & IsInWorld() const
Definition: Object.h:150
#define ASSERT
Definition: Errors.h:29
void AddWorldObject(WorldObject *obj)
Definition: Map.h:479
ACE_UINT32 uint32
Definition: Define.h:71
uint32 GetInstanceId() const
Definition: Map.h:390
void WorldObject::SetName ( const std::string &  newname)
inline
void WorldObject::SetNotified ( uint16  f)
inline

Definition at line 865 of file Object.h.

866  {
867  m_executed_notifies |= f;
868  }
uint16 m_executed_notifies
Definition: Object.h:920
void WorldObject::SetPhaseMask ( uint32  newPhaseMask,
bool  update 
)
virtual

Reimplemented in Unit, and GameObject.

Definition at line 2587 of file Object.cpp.

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

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

2588 {
2589  m_phaseMask = newPhaseMask;
2590 
2591  if (update && IsInWorld())
2593 }
const bool & IsInWorld() const
Definition: Object.h:150
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:2650
uint32 m_phaseMask
Definition: Object.h:917
void WorldObject::SetVisibilityDistanceOverride ( VisibilityDistanceType  type)

Definition at line 1155 of file Object.cpp.

References Object::GetTypeId(), m_visibilityDistanceOverride, TYPEID_PLAYER, VISDIST_GIGANTIC, VISDIST_LARGE, VISDIST_SMALL, VISDIST_TINY, VISIBILITY_DISTANCE_GIGANTIC, VISIBILITY_DISTANCE_LARGE, VISIBILITY_DISTANCE_SMALL, and VISIBILITY_DISTANCE_TINY.

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

1156 {
1157  if (GetTypeId() == TYPEID_PLAYER)
1158  return;
1159 
1160  switch (type)
1161  {
1162  case VISDIST_TINY:
1164  break;
1165  case VISDIST_SMALL:
1167  break;
1168  case VISDIST_LARGE:
1170  break;
1171  case VISDIST_GIGANTIC:
1173  break;
1174  default:
1176  }
1177 }
#define VISIBILITY_DISTANCE_LARGE
Definition: Object.h:41
uint8 GetTypeId() const
Definition: Object.h:192
float m_visibilityDistanceOverride
Definition: Object.h:898
#define VISIBILITY_DISTANCE_GIGANTIC
Definition: Object.h:40
#define VISIBILITY_DISTANCE_SMALL
Definition: Object.h:43
#define VISIBILITY_DISTANCE_TINY
Definition: Object.h:44
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:817
void AddObjectToSwitchList(WorldObject *obj, bool on)
Definition: Map.cpp:2045
const bool & IsInWorld() const
Definition: Object.h:150
void WorldObject::SetZoneScript ( )

Definition at line 2129 of file Object.cpp.

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

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

2130 {
2131  if (Map* map = FindMap())
2132  {
2133  if (map->IsDungeon())
2134  m_zoneScript = (ZoneScript*)((InstanceMap*)map)->GetInstanceData();
2135  else if (!map->IsBattlegroundOrArena())
2136  m_zoneScript = sOutdoorPvPMgr.GetZoneScript(GetZoneId());
2137  }
2138 }
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:79
uint32 GetZoneId() const
Definition: Object.cpp:1202
ZoneScript * m_zoneScript
Definition: Object.h:897
Map * FindMap() const
Definition: Object.h:818
Definition: Map.h:266
TempSummon * WorldObject::SummonCreature ( uint32  id,
const Position pos,
TempSummonType  spwtype = TEMPSUMMON_MANUAL_DESPAWN,
uint32  despwtime = 0 
)

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

2119 {
2120  if (Map* map = FindMap())
2121  {
2122  if (TempSummon* summon = map->SummonCreature(entry, pos, NULL, duration, isType(TYPEMASK_UNIT) ? (Unit*)this : NULL, NULL, spwtype))
2123  return summon;
2124  }
2125 
2126  return NULL;
2127 }
bool isType(uint16 mask) const
Definition: Object.h:193
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2118
Map * FindMap() const
Definition: Object.h:818
Definition: Map.h:266
Definition: Unit.h:908
TempSummon* WorldObject::SummonCreature ( uint32  id,
float  x,
float  y,
float  z,
float  ang,
TempSummonType  spwtype = TEMPSUMMON_MANUAL_DESPAWN,
uint32  despwtime = 0 
)
inline

Definition at line 827 of file Object.h.

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

828  {
829  if (!x && !y && !z)
830  {
831  GetClosePoint(x, y, z, GetObjectSize());
832  ang = GetOrientation();
833  }
834  Position pos = {x, y, z, ang};
835  return SummonCreature(id, pos, spwtype, despwtime);
836  }
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2118
float GetOrientation() const
Definition: Position.h:100
float GetObjectSize() const
Definition: Object.h:645
void GetClosePoint(float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
Definition: Object.h:622
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 2305 of file Object.cpp.

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

2306 {
2307  ASSERT((GetTypeId() == TYPEID_GAMEOBJECT || GetTypeId() == TYPEID_UNIT) && "Only GOs and creatures can summon npc groups!");
2308 
2309  std::vector<TempSummonData> const* data = sObjectMgr.GetSummonGroup(GetEntry(), GetTypeId() == TYPEID_GAMEOBJECT ? SUMMONER_TYPE_GAMEOBJECT : SUMMONER_TYPE_CREATURE, group);
2310  if (!data)
2311  return;
2312 
2313  for (std::vector<TempSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr)
2314  if (TempSummon* summon = SummonCreature(itr->entry, itr->pos, itr->type, itr->time))
2315  if (list)
2316  list->push_back(summon);
2317 }
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0)
Definition: Object.cpp:2118
#define sObjectMgr
Definition: ObjectMgr.h:1317
uint8 GetTypeId() const
Definition: Object.h:192
#define ASSERT
Definition: Errors.h:29
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 2252 of file Object.cpp.

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

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

2253 {
2254  if (!IsInWorld())
2255  return NULL;
2256 
2257  GameObjectInfo const* goinfo = sObjectMgr.GetGameObjectInfo(entry);
2258  if (!goinfo)
2259  {
2260  sLog.outErrorDb("Gameobject template %u not found in database!", entry);
2261  return NULL;
2262  }
2263  Map* map = GetMap();
2264  GameObject* go = new GameObject();
2265  if (!go->Create(sObjectMgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, PHASEMASK_NORMAL, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, 100, GO_STATE_READY))
2266  {
2267  delete go;
2268  return NULL;
2269  }
2270  go->SetRespawnTime(respawnTime);
2271  if (GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT) //not sure how to handle this
2272  ((Unit*)this)->AddGameObject(go);
2273  else
2274  go->SetSpawnedByDefault(false);
2275  map->AddToMap(go);
2276 
2277  return go;
2278 }
Map * GetMap() const
Definition: Object.h:817
#define sLog
Log class singleton.
Definition: Log.h:187
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:710
#define sObjectMgr
Definition: ObjectMgr.h:1317
uint8 GetTypeId() const
Definition: Object.h:192
const bool & IsInWorld() const
Definition: Object.h:150
void SetSpawnedByDefault(bool b)
Definition: GameObject.h:726
Definition: Map.h:266
bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 ArtKit=0)
Definition: GameObject.cpp:166
Definition: Unit.h:908
Creature * WorldObject::SummonTrigger ( float  x,
float  y,
float  z,
float  ang,
uint32  dur,
CreatureAI *(*)(Creature *)  GetAI = NULL 
)

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

2281 {
2282  TempSummonType summonType = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
2283  Creature* summon = SummonCreature(WORLD_TRIGGER, x, y, z, ang, summonType, duration);
2284  if (!summon)
2285  return NULL;
2286 
2287  //summon->SetName(GetName());
2288  if (GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT)
2289  {
2290  summon->SetFaction(((Unit*)this)->GetFaction());
2291  summon->SetLevel(((Unit*)this)->getLevel());
2292  }
2293 
2294  if (GetAI)
2295  summon->AIM_Initialize(GetAI(summon));
2296  return summon;
2297 }
#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:2118
bool AIM_Initialize(CreatureAI *ai=NULL)
Definition: Creature.cpp:741
despawns when the creature disappears
despawns after a specified time
uint8 GetTypeId() const
Definition: Object.h:192
TempSummonType
void SetFaction(uint32 faction)
Definition: Unit.h:1117
void SetLevel(uint32 lvl)
Definition: Unit.cpp:10931
Definition: Unit.h:908
virtual void WorldObject::Update ( uint32  )
inlinevirtual

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

Definition at line 615 of file Object.h.

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

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

1443 {
1444  switch (GetTypeId())
1445  {
1446  case TYPEID_UNIT:
1447  {
1448  // non fly unit don't must be in air
1449  // non swim unit must be at ground (mostly speedup, because it don't must be in water and water level check less fast
1450  if (!((Creature const*)this)->CanFly())
1451  {
1452  bool canSwim = ((Creature const*)this)->CanSwim();
1453  float ground_z = z;
1454  float max_z = canSwim
1455  ? GetBaseMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK))
1456  : ((ground_z = GetBaseMap()->GetHeight(x, y, z, true)));
1457  if (max_z > INVALID_HEIGHT)
1458  {
1459  if (z > max_z)
1460  z = max_z;
1461  else if (z < ground_z)
1462  z = ground_z;
1463  }
1464  }
1465  else
1466  {
1467  float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
1468  if (z < ground_z)
1469  z = ground_z;
1470  }
1471  break;
1472  }
1473  case TYPEID_PLAYER:
1474  {
1475  // for server controlled moves playr work same as creature (but it can always swim)
1476  if (!((Player const*)this)->CanFly())
1477  {
1478  float ground_z = z;
1479  float max_z = GetBaseMap()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK));
1480  if (max_z > INVALID_HEIGHT)
1481  {
1482  if (z > max_z)
1483  z = max_z;
1484  else if (z < ground_z)
1485  z = ground_z;
1486  }
1487  }
1488  else
1489  {
1490  float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
1491  if (z < ground_z)
1492  z = ground_z;
1493  }
1494  break;
1495  }
1496  default:
1497  {
1498  float ground_z = GetBaseMap()->GetHeight(x, y, z, true);
1499  if (ground_z > INVALID_HEIGHT)
1500  z = ground_z;
1501  break;
1502  }
1503  }
1504 }
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:1591
float GetWaterOrGroundLevel(float x, float y, float z, float *ground=NULL, bool swim=false) const
Definition: Map.cpp:1573
uint8 GetTypeId() const
Definition: Object.h:192
Map const * GetBaseMap() const
Definition: Object.cpp:2011
#define INVALID_HEIGHT
Definition: Map.h:259
Definition: Unit.h:908
Definition: Player.h:923
void WorldObject::UpdateGroundPositionZ ( float  x,
float  y,
float &  z 
) const

Definition at line 1506 of file Object.cpp.

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

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

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

Reimplemented in Player, and Unit.

Definition at line 2650 of file Object.cpp.

References GetVisibilityRange(), and VisitNearbyWorldObject().

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

2651 {
2652  //updates object's visibility for nearby players
2653  Oregon::VisibleChangesNotifier notifier(*this);
2655 }
float GetVisibilityRange() const
Definition: Object.cpp:1575
void VisitNearbyWorldObject(const float &radius, NOTIFIER &notifier) const
Definition: Object.h:883
virtual void WorldObject::UpdateObjectVisibilityOnCreate ( )
inlinevirtual

Definition at line 850 of file Object.h.

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

Definition at line 885 of file Object.h.

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

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

Definition at line 884 of file Object.h.

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

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

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

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

Member Data Documentation

uint64 WorldObject::lootingGroupLeaderGUID

Definition at line 888 of file Object.h.

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

Map* WorldObject::m_currMap
private

Definition at line 913 of file Object.h.

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

uint16 WorldObject::m_executed_notifies
private

Definition at line 920 of file Object.h.

uint32 WorldObject::m_groupLootTimer

Definition at line 887 of file Object.h.

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

uint32 WorldObject::m_InstanceId
private

Definition at line 916 of file Object.h.

Referenced by SetMap().

bool WorldObject::m_isActive
protected

Definition at line 895 of file Object.h.

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

const bool WorldObject::m_isWorldObject
protected

Definition at line 896 of file Object.h.

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

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

Definition at line 919 of file Object.h.

uint32 WorldObject::m_phaseMask
private

Definition at line 917 of file Object.h.

Referenced by _Create(), and SetPhaseMask().

Definition at line 804 of file Object.h.

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

float WorldObject::m_visibilityDistanceOverride
protected

Definition at line 898 of file Object.h.

Referenced by GetSightRange(), GetVisibilityRange(), and SetVisibilityDistanceOverride().


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