TrinityCore
WorldObject Class Referenceabstract

#include <Object.h>

Public Member Functions

virtual ~WorldObject ()
 
virtual void Update (uint32)
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void GetNearPoint2D (WorldObject const *searcher, float &x, float &y, float distance, float absAngle) const
 
void GetNearPoint (WorldObject const *searcher, float &x, float &y, float &z, float distance2d, float absAngle) const
 
void GetClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float relAngle=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)
 
Position GetRandomNearPosition (float radius)
 
void GetContactPoint (WorldObject const *obj, float &x, float &y, float &z, float distance2d=CONTACT_DISTANCE) const
 
virtual float GetCombatReach () const
 
void UpdateGroundPositionZ (float x, float y, float &z) const
 
void UpdateAllowedPositionZ (float x, float y, float &z, float *groundZ=nullptr) const
 
void GetRandomPoint (Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
 
Position GetRandomPoint (Position const &srcPos, float distance) const
 
uint32 GetInstanceId () const
 
bool IsInPhase (WorldObject const *obj) const
 
PhaseShiftGetPhaseShift ()
 
PhaseShift const & GetPhaseShift () const
 
PhaseShiftGetSuppressedPhaseShift ()
 
PhaseShift const & GetSuppressedPhaseShift () const
 
int32 GetDBPhase () const
 
void SetDBPhase (int32 p)
 
uint32 GetZoneId () const
 
uint32 GetAreaId () const
 
void GetZoneAndAreaId (uint32 &zoneid, uint32 &areaid) const
 
bool IsInWorldPvpZone () const
 
bool IsOutdoors () const
 
ZLiquidStatus GetLiquidStatus () const
 
InstanceScriptGetInstanceScript () const
 
std::string const & GetName () const
 
void SetName (std::string newname)
 
std::string GetNameForLocaleIdx (LocaleConstant) const override
 
float GetDistance (WorldObject const *obj) const
 
float GetDistance (Position const &pos) const
 
float GetDistance (float x, float y, float z) const
 
float GetDistance2d (WorldObject const *obj) const
 
float GetDistance2d (float x, float y) const
 
float GetDistanceZ (WorldObject const *obj) const
 
bool IsSelfOrInSameMap (WorldObject const *obj) const
 
bool IsInMap (WorldObject const *obj) const
 
bool IsWithinDist3d (float x, float y, float z, float dist) const
 
bool IsWithinDist3d (Position const *pos, float dist) const
 
bool IsWithinDist2d (float x, float y, float dist) const
 
bool IsWithinDist2d (Position const *pos, float dist) const
 
bool IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D=true) const
 
bool IsWithinDistInMap (WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
 
bool IsWithinLOS (float x, float y, float z, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
 
bool IsWithinLOSInMap (WorldObject const *obj, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) 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
 
bool isInFront (WorldObject const *target, float arc=float(M_PI)) const
 
bool isInBack (WorldObject const *target, float arc=float(M_PI)) const
 
bool IsInBetween (Position const &pos1, Position const &pos2, float size=0) const
 
bool IsInBetween (WorldObject const *obj1, WorldObject const *obj2, float size=0) const
 
virtual void CleanupsBeforeDelete (bool finalCleanup=true)
 
virtual void SendMessageToSet (WorldPacket const *data, bool self) const
 
virtual void SendMessageToSetInRange (WorldPacket const *data, float dist, bool self) const
 
virtual void SendMessageToSet (WorldPacket const *data, Player const *skipped_rcvr) const
 
void SendCombatLogMessage (WorldPackets::CombatLog::CombatLogServerPacket *combatLog) const
 
virtual uint8 GetLevelForTarget (WorldObject const *) const
 
void PlayDistanceSound (uint32 soundId, Player *target=nullptr)
 
void PlayDirectSound (uint32 soundId, Player *target=nullptr, uint32 broadcastTextId=0)
 
void PlayDirectMusic (uint32 musicId, Player *target=nullptr)
 
void AddObjectToRemoveList ()
 
float GetGridActivationRange () const
 
float GetVisibilityRange () const
 
float GetSightRange (WorldObject const *target=nullptr) const
 
bool CanSeeOrDetect (WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
 
virtual void SetMap (Map *map)
 
virtual void ResetMap ()
 
MapGetMap () const
 
MapFindMap () const
 
void SetZoneScript ()
 
ZoneScriptFindZoneScript () const
 
ZoneScriptGetZoneScript () const
 
ScenarioGetScenario () const
 
TempSummonSummonCreature (uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
 
TempSummonSummonCreature (uint32 entry, float x, float y, float z, float o=0, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
 
TempSummonSummonPersonalClone (Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, Player *privateObjectOwner=nullptr)
 
GameObjectSummonGameObject (uint32 entry, Position const &pos, QuaternionData const &rot, Seconds respawnTime, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, QuaternionData const &rot, Seconds respawnTime, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
 
CreatureSummonTrigger (float x, float y, float z, float ang, Milliseconds despawnTime, CreatureAI *(*GetAI)(Creature *)=nullptr)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon *> *list=nullptr)
 
CreatureFindNearestCreature (uint32 entry, float range, bool alive=true) const
 
GameObjectFindNearestGameObject (uint32 entry, float range, bool spawnedOnly=true) const
 
GameObjectFindNearestUnspawnedGameObject (uint32 entry, float range) const
 
GameObjectFindNearestGameObjectOfType (GameobjectTypes type, float range) const
 
PlayerSelectNearestPlayer (float distance) const
 
virtual ObjectGuid GetOwnerGUID () const =0
 
virtual ObjectGuid GetCharmerOrOwnerGUID () const
 
ObjectGuid GetCharmerOrOwnerOrOwnGUID () const
 
UnitGetOwner () const
 
UnitGetCharmerOrOwner () const
 
UnitGetCharmerOrOwnerOrSelf () const
 
PlayerGetCharmerOrOwnerPlayerOrPlayerItself () const
 
PlayerGetAffectingPlayer () const
 
PlayerGetSpellModOwner () const
 
int32 CalculateSpellDamage (Unit const *target, SpellEffectInfo const &spellEffectInfo, int32 const *basePoints=nullptr, float *variance=nullptr, uint32 castItemId=0, int32 itemLevel=-1) const
 
float GetSpellMaxRangeForTarget (Unit const *target, SpellInfo const *spellInfo) const
 
float GetSpellMinRangeForTarget (Unit const *target, SpellInfo const *spellInfo) const
 
float ApplyEffectModifiers (SpellInfo const *spellInfo, uint8 effIndex, float value) const
 
int32 CalcSpellDuration (SpellInfo const *spellInfo) const
 
int32 ModSpellDuration (SpellInfo const *spellInfo, WorldObject const *target, int32 duration, bool positive, uint32 effectMask) const
 
void ModSpellCastTime (SpellInfo const *spellInfo, int32 &castTime, Spell *spell=nullptr) const
 
void ModSpellDurationTime (SpellInfo const *spellInfo, int32 &durationTime, Spell *spell=nullptr) const
 
virtual float MeleeSpellMissChance (Unit const *victim, WeaponAttackType attType, SpellInfo const *spellInfo) const
 
virtual SpellMissInfo MeleeSpellHitResult (Unit *victim, SpellInfo const *spellInfo) const
 
SpellMissInfo MagicSpellHitResult (Unit *victim, SpellInfo const *spellInfo) const
 
SpellMissInfo SpellHitResult (Unit *victim, SpellInfo const *spellInfo, bool canReflect=false) const
 
void SendSpellMiss (Unit *target, uint32 spellID, SpellMissInfo missInfo)
 
virtual uint32 GetFaction () const =0
 
virtual void SetFaction (uint32)
 
FactionTemplateEntry const * GetFactionTemplateEntry () const
 
ReputationRank GetReactionTo (WorldObject const *target) const
 
bool IsHostileTo (WorldObject const *target) const
 
bool IsHostileToPlayers () const
 
bool IsFriendlyTo (WorldObject const *target) const
 
bool IsNeutralToAll () const
 
SpellCastResult CastSpell (CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
 
void SendPlayOrphanSpellVisual (ObjectGuid const &target, uint32 spellVisualId, float travelSpeed, bool speedAsTime=false, bool withSourceOrientation=false)
 
void SendPlayOrphanSpellVisual (Position const &targetLocation, uint32 spellVisualId, float travelSpeed, bool speedAsTime=false, bool withSourceOrientation=false)
 
void SendCancelOrphanSpellVisual (uint32 id)
 
void SendPlaySpellVisual (WorldObject *target, uint32 spellVisualId, uint16 missReason, uint16 reflectStatus, float travelSpeed, bool speedAsTime=false)
 
void SendPlaySpellVisual (Position const &targetPosition, float o, uint32 spellVisualId, uint16 missReason, uint16 reflectStatus, float travelSpeed, bool speedAsTime=false)
 
void SendCancelSpellVisual (uint32 id)
 
void SendPlaySpellVisualKit (uint32 id, uint32 type, uint32 duration) const
 
void SendCancelSpellVisualKit (uint32 id)
 
bool IsValidAttackTarget (WorldObject const *target, SpellInfo const *bySpell=nullptr) const
 
bool IsValidAssistTarget (WorldObject const *target, SpellInfo const *bySpell=nullptr) const
 
UnitGetMagicHitRedirectTarget (Unit *victim, SpellInfo const *spellInfo)
 
virtual uint32 GetCastSpellXSpellVisualId (SpellInfo const *spellInfo) const
 
template<typename Container >
void GetGameObjectListWithEntryInGrid (Container &gameObjectContainer, uint32 entry, float maxSearchRange=250.0f) const
 
template<typename Container >
void GetCreatureListWithEntryInGrid (Container &creatureContainer, uint32 entry, float maxSearchRange=250.0f) const
 
template<typename Container >
void GetPlayerListInGrid (Container &playerContainer, float maxSearchRange, bool alive=true) const
 
void DestroyForNearbyPlayers ()
 
virtual void UpdateObjectVisibility (bool forced=true)
 
virtual void UpdateObjectVisibilityOnCreate ()
 
virtual void UpdateObjectVisibilityOnDestroy ()
 
void UpdatePositionData ()
 
void BuildUpdate (UpdateDataMapType &) override
 
bool AddToObjectUpdate () override
 
void RemoveFromObjectUpdate () override
 
void AddToNotify (uint16 f)
 
bool isNeedNotify (uint16 f) const
 
uint16 GetNotifyFlags () const
 
void ResetAllNotifies ()
 
bool isActiveObject () const
 
void setActive (bool isActiveObject)
 
bool IsFarVisible () const
 
void SetFarVisible (bool on)
 
bool IsVisibilityOverridden () const
 
void SetVisibilityDistanceOverride (VisibilityDistanceType type)
 
void SetWorldObject (bool apply)
 
bool IsPermanentWorldObject () const
 
bool IsWorldObject () const
 
TransportBaseGetTransport () const
 
float GetTransOffsetX () const
 
float GetTransOffsetY () const
 
float GetTransOffsetZ () const
 
float GetTransOffsetO () const
 
Position const & GetTransOffset () const
 
uint32 GetTransTime () const
 
int8 GetTransSeat () const
 
virtual ObjectGuid GetTransGUID () const
 
void SetTransport (TransportBase *t)
 
virtual float GetStationaryX () const
 
virtual float GetStationaryY () const
 
virtual float GetStationaryZ () const
 
virtual float GetStationaryO () const
 
float GetFloorZ () const
 
virtual float GetCollisionHeight () const
 
float GetMapWaterOrGroundLevel (float x, float y, float z, float *ground=nullptr) const
 
float GetMapHeight (float x, float y, float z, bool vmap=true, float distanceToSearch=50.0f) const
 
std::string GetDebugInfo () const override
 
virtual uint16 GetAIAnimKitId () const
 
virtual uint16 GetMovementAnimKitId () const
 
virtual uint16 GetMeleeAnimKitId () const
 
bool IsPrivateObject () const
 
ObjectGuid GetPrivateObjectOwner () const
 
void SetPrivateObjectOwner (ObjectGuid const &owner)
 
bool CheckPrivateObjectOwnerVisibility (WorldObject const *seer) const
 
SmoothPhasingGetOrCreateSmoothPhasing ()
 
SmoothPhasingGetSmoothPhasing ()
 
SmoothPhasing const * GetSmoothPhasing () const
 
- Public Member Functions inherited from Object
virtual ~Object ()
 
bool IsInWorld () const
 
ObjectGuid const & GetGUID () const
 
uint32 GetEntry () const
 
void SetEntry (uint32 entry)
 
float GetObjectScale () const
 
virtual void SetObjectScale (float scale)
 
uint32 GetDynamicFlags () const
 
bool HasDynamicFlag (uint32 flag) const
 
void SetDynamicFlag (uint32 flag)
 
void RemoveDynamicFlag (uint32 flag)
 
void ReplaceAllDynamicFlags (uint32 flag)
 
TypeID GetTypeId () const
 
bool isType (uint16 mask) const
 
virtual void BuildCreateUpdateBlockForPlayer (UpdateData *data, Player *target) const
 
void SendUpdateToPlayer (Player *player)
 
void BuildValuesUpdateBlockForPlayer (UpdateData *data, Player const *target) const
 
void BuildValuesUpdateBlockForPlayerWithFlag (UpdateData *data, UF::UpdateFieldFlag flags, Player const *target) const
 
void BuildDestroyUpdateBlock (UpdateData *data) const
 
void BuildOutOfRangeUpdateBlock (UpdateData *data) const
 
ByteBuffer PrepareValuesUpdateBuffer () const
 
virtual void DestroyForPlayer (Player *target) const
 
void SendOutOfRangeForPlayer (Player *target) const
 
virtual void ClearUpdateMask (bool remove)
 
virtual bool hasQuest (uint32) const
 
virtual bool hasInvolvedQuest (uint32) const
 
void SetIsNewObject (bool enable)
 
bool IsDestroyedObject () const
 
void SetDestroyedObject (bool destroyed)
 
void BuildFieldsUpdate (Player *, UpdateDataMapType &) const
 
bool IsPlayer () const
 
PlayerToPlayer ()
 
Player const * ToPlayer () const
 
bool IsCreature () const
 
CreatureToCreature ()
 
Creature const * ToCreature () const
 
bool IsUnit () const
 
UnitToUnit ()
 
Unit const * ToUnit () const
 
bool IsGameObject () const
 
GameObjectToGameObject ()
 
GameObject const * ToGameObject () const
 
bool IsCorpse () const
 
CorpseToCorpse ()
 
Corpse const * ToCorpse () const
 
bool IsDynObject () const
 
DynamicObjectToDynObject ()
 
DynamicObject const * ToDynObject () const
 
bool IsAreaTrigger () const
 
AreaTriggerToAreaTrigger ()
 
AreaTrigger const * ToAreaTrigger () const
 
bool IsSceneObject () const
 
SceneObjectToSceneObject ()
 
SceneObject const * ToSceneObject () const
 
bool IsConversation () const
 
ConversationToConversation ()
 
Conversation const * ToConversation () const
 
template<typename T >
void ForceUpdateFieldChange (UF::UpdateFieldSetter< T > const &)
 
virtual void BuildValuesUpdateWithFlag (ByteBuffer *data, UF::UpdateFieldFlag flags, Player const *target) const
 
- Public Member Functions inherited from WorldLocation
 WorldLocation (uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
 WorldLocation (uint32 mapId, Position const &position)
 
void WorldRelocate (WorldLocation const &loc)
 
void WorldRelocate (WorldLocation const *loc)
 
void WorldRelocate (uint32 mapId, Position const &pos)
 
void WorldRelocate (uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
 
WorldLocation GetWorldLocation () const
 
uint32 GetMapId () const
 
std::string GetDebugInfo () const
 
- Public Member Functions inherited from Position
 Position (float x=0, float y=0, float z=0, float o=0)
 
bool operator== (Position const &a) const
 
bool operator!= (Position const &a) const
 
void Relocate (float x, float y)
 
void Relocate (float x, float y, float z)
 
void Relocate (float x, float y, float z, float o)
 
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
 
Streamer< XY > PositionXYStream ()
 
ConstStreamer< XY > PositionXYStream () const
 
Streamer< XYZ > PositionXYZStream ()
 
ConstStreamer< XYZ > PositionXYZStream () const
 
Streamer< XYZO > PositionXYZOStream ()
 
ConstStreamer< XYZO > PositionXYZOStream () const
 
Streamer< PackedXYZ > PositionPackedXYZStream ()
 
ConstStreamer< PackedXYZ > PositionPackedXYZStream () const
 
bool IsPositionValid () const
 
float GetExactDist2dSq (const float x, const float y) const
 
float GetExactDist2dSq (Position const &pos) const
 
float GetExactDist2dSq (Position const *pos) const
 
float GetExactDist2d (const float x, const float y) const
 
float GetExactDist2d (Position const &pos) const
 
float GetExactDist2d (Position const *pos) const
 
float GetExactDistSq (float x, float y, float z) const
 
float GetExactDistSq (Position const &pos) const
 
float GetExactDistSq (Position const *pos) const
 
float GetExactDist (float x, float y, float z) const
 
float GetExactDist (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 GetAbsoluteAngle (float x, float y) const
 
float GetAbsoluteAngle (Position const &pos) const
 
float GetAbsoluteAngle (Position const *pos) const
 
float ToAbsoluteAngle (float relAngle) const
 
float ToRelativeAngle (float absAngle) const
 
float GetRelativeAngle (float x, float y) const
 
float GetRelativeAngle (Position const &pos) const
 
float GetRelativeAngle (Position const *pos) 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 IsInDist (Position const *pos, float dist) const
 
bool IsWithinBox (Position const &center, float xradius, float yradius, float zradius) const
 
bool IsWithinDoubleVerticalCylinder (Position const *center, float radius, float height) const
 
bool HasInArc (float arcangle, Position const *pos, float border=2.0f) const
 
bool HasInLine (Position const *pos, float objSize, float width) const
 
std::string ToString () const
 

Static Public Member Functions

static bool InSamePhase (WorldObject const *a, WorldObject const *b)
 
static ReputationRank GetFactionReactionTo (FactionTemplateEntry const *factionTemplateEntry, WorldObject const *target)
 
- Static Public Member Functions inherited from Object
static ObjectGuid GetGUID (Object const *o)
 
static PlayerToPlayer (Object *o)
 
static Player const * ToPlayer (Object const *o)
 
static CreatureToCreature (Object *o)
 
static Creature const * ToCreature (Object const *o)
 
static UnitToUnit (Object *o)
 
static Unit const * ToUnit (Object const *o)
 
static GameObjectToGameObject (Object *o)
 
static GameObject const * ToGameObject (Object const *o)
 
static CorpseToCorpse (Object *o)
 
static Corpse const * ToCorpse (Object const *o)
 
static DynamicObjectToDynObject (Object *o)
 
static DynamicObject const * ToDynObject (Object const *o)
 
static AreaTriggerToAreaTrigger (Object *o)
 
static AreaTrigger const * ToAreaTrigger (Object const *o)
 
static SceneObjectToSceneObject (Object *o)
 
static SceneObject const * ToSceneObject (Object const *o)
 
static ConversationToConversation (Object *o)
 
static Conversation const * ToConversation (Object const *o)
 
- 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 LastUsedScriptID
 
MovementInfo m_movementInfo
 
EventProcessor m_Events
 
- Public Attributes inherited from Object
UF::UpdateFieldHolder m_values
 
UF::UpdateField< UF::ObjectData, 0, TYPEID_OBJECTm_objectData
 
- 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)
 
virtual void ProcessPositionDataChanged (PositionFullTerrainStatus const &data)
 
void SetLocationMapId (uint32 _mapId)
 
void SetLocationInstanceId (uint32 _instanceId)
 
virtual bool CanNeverSee (WorldObject const *obj) const
 
virtual bool IsNeverVisibleFor (WorldObject const *) const
 
virtual bool IsAlwaysVisibleFor (WorldObject const *) const
 
virtual bool IsInvisibleDueToDespawn () const
 
virtual bool IsAlwaysDetectableFor (WorldObject const *) const
 
- Protected Member Functions inherited from Object
 Object ()
 
void _Create (ObjectGuid const &guid)
 
template<typename T >
void SetUpdateFieldValue (UF::UpdateFieldSetter< T > setter, typename UF::UpdateFieldSetter< T >::value_type value)
 
template<typename T >
void SetUpdateFieldFlagValue (UF::UpdateFieldSetter< T > setter, typename UF::UpdateFieldSetter< T >::value_type flag)
 
template<typename T >
void RemoveUpdateFieldFlagValue (UF::UpdateFieldSetter< T > setter, typename UF::UpdateFieldSetter< T >::value_type flag)
 
template<typename T >
UF::DynamicUpdateFieldSetter< T >::insert_result AddDynamicUpdateFieldValue (UF::DynamicUpdateFieldSetter< T > setter)
 
template<typename T >
UF::DynamicUpdateFieldSetter< T >::insert_result InsertDynamicUpdateFieldValue (UF::DynamicUpdateFieldSetter< T > setter, uint32 index)
 
template<typename T >
void RemoveDynamicUpdateFieldValue (UF::DynamicUpdateFieldSetter< T > setter, uint32 index)
 
template<typename T >
void ClearDynamicUpdateFieldValues (UF::DynamicUpdateFieldSetter< T > setter)
 
template<typename T >
void RemoveOptionalUpdateFieldValue (UF::OptionalUpdateFieldSetter< T > setter)
 
template<typename T >
void SetUpdateFieldStatValue (UF::UpdateFieldSetter< T > setter, typename UF::UpdateFieldSetter< T >::value_type value)
 
template<typename T >
void ApplyModUpdateFieldValue (UF::UpdateFieldSetter< T > setter, typename UF::UpdateFieldSetter< T >::value_type mod, bool apply)
 
template<typename T >
void ApplyPercentModUpdateFieldValue (UF::UpdateFieldSetter< T > setter, float percent, bool apply)
 
template<typename Action >
void DoWithSuppressingObjectUpdates (Action &&action)
 
void BuildMovementUpdate (ByteBuffer *data, CreateObjectBits flags, Player *target) const
 
virtual UF::UpdateFieldFlag GetUpdateFieldFlagsFor (Player const *target) const
 
virtual void BuildValuesCreate (ByteBuffer *data, Player const *target) const =0
 
virtual void BuildValuesUpdate (ByteBuffer *data, Player const *target) const =0
 
void AddToObjectUpdateIfNeeded ()
 

Protected Attributes

std::string m_name
 
bool m_isActive
 
bool m_isFarVisible
 
Optional< float > m_visibilityDistanceOverride
 
bool const m_isWorldObject
 
ZoneScriptm_zoneScript
 
TransportBasem_transport
 
uint32 m_zoneId
 
uint32 m_areaId
 
float m_staticFloorZ
 
bool m_outdoors
 
ZLiquidStatus m_liquidStatus
 
- Protected Attributes inherited from Object
uint16 m_objectType
 
TypeID m_objectTypeId
 
CreateObjectBits m_updateFlag
 
bool m_objectUpdated
 

Private Member Functions

virtual bool _IsWithinDist (WorldObject const *obj, float dist2compare, bool is3D, bool incOwnRadius=true, bool incTargetRadius=true) 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
 
PhaseShift _phaseShift
 
PhaseShift _suppressedPhaseShift
 
int32 _dbPhase
 
uint16 m_notifyflags
 
ObjectGuid _privateObjectOwner
 
std::unique_ptr< SmoothPhasing_smoothPhasing
 

Constructor & Destructor Documentation

◆ WorldObject()

WorldObject::WorldObject ( bool  isWorldObject)
explicitprotected
825 m_movementInfo(), m_name(), m_isActive(false), m_isFarVisible(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
827 m_currMap(nullptr), m_InstanceId(0), _dbPhase(0), m_notifyflags(0)
828 {
831 }
Map * m_currMap
Definition: Object.h:754
bool m_outdoors
Definition: Object.h:738
ZLiquidStatus m_liquidStatus
Definition: Object.h:739
#define VMAP_INVALID_HEIGHT
Definition: IVMapManager.h:50
MovementInfo m_movementInfo
Definition: Object.h:690
std::string m_name
Definition: Object.h:724
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:550
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:422
float m_staticFloorZ
Definition: Object.h:737
Definition: Map.h:93
bool m_isFarVisible
Definition: Object.h:726
uint32 m_InstanceId
Definition: Object.h:756
Definition: SharedDefines.h:2406
uint16 m_notifyflags
Definition: Object.h:761
Definition: SharedDefines.h:2407
int32 _dbPhase
Definition: Object.h:759
WorldLocation(uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
Definition: Position.h:166
ZoneScript * m_zoneScript
Definition: Object.h:729
TransportBase * m_transport
Definition: Object.h:732
bool m_isActive
Definition: Object.h:725
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:551
uint32 m_zoneId
Definition: Object.h:735
Object()
Definition: Object.cpp:72
Definition: SharedDefines.h:2399
uint32 m_areaId
Definition: Object.h:736
bool const m_isWorldObject
Definition: Object.h:728
uint32 LastUsedScriptID
Definition: Object.h:676
+ Here is the call graph for this function:

◆ ~WorldObject()

WorldObject::~WorldObject ( )
virtual
85 {
86  // this may happen because there are many !create/delete
87  if (IsWorldObject() && m_currMap)
88  {
89  if (GetTypeId() == TYPEID_CORPSE)
90  {
91  TC_LOG_FATAL("misc", "WorldObject::~WorldObject Corpse Type: %d (%s) deleted but still in map!!",
92  ToCorpse()->GetType(), GetGUID().ToString().c_str());
93  ABORT();
94  }
95  ResetMap();
96  }
97 }
virtual void ResetMap()
Definition: Object.cpp:1716
Map * m_currMap
Definition: Object.h:754
bool IsWorldObject() const
Definition: Object.cpp:841
TypeID GetTypeId() const
Definition: Object.h:170
Definition: ObjectGuid.h:44
ObjectGuid const & GetGUID() const
Definition: Object.h:157
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:188
Corpse * ToCorpse()
Definition: Object.h:224
#define ABORT
Definition: Errors.h:74
std::string ToString() const
Definition: Position.cpp:128
+ Here is the call graph for this function:

Member Function Documentation

◆ _IsWithinDist()

bool WorldObject::_IsWithinDist ( WorldObject const *  obj,
float  dist2compare,
bool  is3D,
bool  incOwnRadius = true,
bool  incTargetRadius = true 
) const
privatevirtual

Reimplemented in GameObject.

965 {
966  float sizefactor = 0;
967  sizefactor += incOwnRadius ? GetCombatReach() : 0.0f;
968  sizefactor += incTargetRadius ? obj->GetCombatReach() : 0.0f;
969  float maxdist = dist2compare + sizefactor;
970 
971  Position const* thisOrTransport = this;
972  Position const* objOrObjTransport = obj;
973 
974  if (GetTransport() && obj->GetTransport() && obj->GetTransport()->GetTransportGUID() == GetTransport()->GetTransportGUID())
975  {
976  thisOrTransport = &m_movementInfo.transport.pos;
977  objOrObjTransport = &obj->m_movementInfo.transport.pos;
978  }
979 
980  if (is3D)
981  return thisOrTransport->IsInDist(objOrObjTransport, maxdist);
982  else
983  return thisOrTransport->IsInDist2d(objOrObjTransport, maxdist);
984 }
bool IsInDist(float x, float y, float z, float dist) const
Definition: Position.h:144
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:141
MovementInfo m_movementInfo
Definition: Object.h:690
virtual float GetCombatReach() const
Definition: Object.h:452
struct MovementInfo::TransportInfo transport
Position pos
Definition: MovementInfo.h:51
virtual ObjectGuid GetTransportGUID() const =0
Definition: Position.h:27
TransportBase * GetTransport() const
Definition: Object.h:679
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddObjectToRemoveList()

void WorldObject::AddObjectToRemoveList ( )
1729 {
1730  Map* map = FindMap();
1731  if (!map)
1732  {
1733  TC_LOG_ERROR("misc", "Object %s at attempt add to move list not have valid map (Id: %u).", GetGUID().ToString().c_str(), GetMapId());
1734  return;
1735  }
1736 
1737  map->AddObjectToRemoveList(this);
1738 }
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
void AddObjectToRemoveList(WorldObject *obj)
Definition: Map.cpp:3741
ObjectGuid const & GetGUID() const
Definition: Object.h:157
Definition: Map.h:264
Map * FindMap() const
Definition: Object.h:556
uint32 GetMapId() const
Definition: Position.h:186
std::string ToString() const
Definition: Position.cpp:128
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddToNotify()

void WorldObject::AddToNotify ( uint16  f)
inline
661 { m_notifyflags |= f;}
uint16 m_notifyflags
Definition: Object.h:761
+ Here is the caller graph for this function:

◆ AddToObjectUpdate()

bool WorldObject::AddToObjectUpdate ( )
overridevirtual

Implements Object.

3574 {
3575  GetMap()->AddUpdateObject(this);
3576  return true;
3577 }
Map * GetMap() const
Definition: Object.h:555
void AddUpdateObject(Object *obj)
Definition: Map.h:613
+ Here is the call graph for this function:

◆ AddToWorld()

void WorldObject::AddToWorld ( )
overridevirtual

Reimplemented from Object.

Reimplemented in Player, Unit, SceneObject, and Pet.

920 {
923 }
PhaseShift _phaseShift
Definition: Object.h:757
float GetPositionY() const
Definition: Position.h:78
Map * GetMap() const
Definition: Object.h:555
float GetPositionZ() const
Definition: Position.h:79
uint32 m_zoneId
Definition: Object.h:735
virtual void AddToWorld()
Definition: Object.cpp:122
float GetPositionX() const
Definition: Position.h:77
void GetZoneAndAreaId(PhaseShift const &phaseShift, uint32 &zoneid, uint32 &areaid, float x, float y, float z)
Definition: Map.cpp:2770
uint32 m_areaId
Definition: Object.h:736
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ApplyEffectModifiers()

float WorldObject::ApplyEffectModifiers ( SpellInfo const *  spellInfo,
uint8  effIndex,
float  value 
) const
2210 {
2211  if (Player* modOwner = GetSpellModOwner())
2212  {
2213  modOwner->ApplySpellMod(spellInfo, SpellModOp::Points, value);
2214  switch (effIndex)
2215  {
2216  case EFFECT_0:
2217  modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex0, value);
2218  break;
2219  case EFFECT_1:
2220  modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex1, value);
2221  break;
2222  case EFFECT_2:
2223  modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex2, value);
2224  break;
2225  case EFFECT_3:
2226  modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex3, value);
2227  break;
2228  case EFFECT_4:
2229  modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex4, value);
2230  break;
2231  }
2232  }
2233  return value;
2234 }
Definition: SharedDefines.h:31
Definition: SharedDefines.h:33
Definition: SharedDefines.h:29
Definition: SharedDefines.h:30
Player * GetSpellModOwner() const
Definition: Object.cpp:2148
Definition: SharedDefines.h:32
Definition: Player.h:1131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildUpdate()

void WorldObject::BuildUpdate ( UpdateDataMapType data_map)
overridevirtual

Reimplemented from Object.

Reimplemented in Transport.

3565 {
3566  WorldObjectChangeAccumulator notifier(*this, data_map);
3567  //we must build packets for all visible players
3568  Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
3569 
3570  ClearUpdateMask(false);
3571 }
virtual void ClearUpdateMask(bool remove)
Definition: Object.cpp:756
Definition: Object.cpp:3494
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:191
float GetVisibilityRange() const
Definition: Object.cpp:1351
+ Here is the call graph for this function:

◆ CalcSpellDuration()

int32 WorldObject::CalcSpellDuration ( SpellInfo const *  spellInfo) const
2237 {
2238  int32 comboPoints = 0;
2239  int32 maxComboPoints = 5;
2240  if (Unit const* unit = ToUnit())
2241  {
2242  comboPoints = unit->GetPower(POWER_COMBO_POINTS);
2243  maxComboPoints = unit->GetMaxPower(POWER_COMBO_POINTS);
2244  }
2245 
2246  int32 minduration = spellInfo->GetDuration();
2247  int32 maxduration = spellInfo->GetMaxDuration();
2248 
2249  int32 duration;
2250  if (comboPoints && minduration != -1 && minduration != maxduration)
2251  duration = minduration + int32((maxduration - minduration) * comboPoints / maxComboPoints);
2252  else
2253  duration = minduration;
2254 
2255  return duration;
2256 }
Definition: SharedDefines.h:276
int32_t int32
Definition: Define.h:139
Definition: Unit.h:746
Unit * ToUnit()
Definition: Object.h:212
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CalculateSpellDamage()

int32 WorldObject::CalculateSpellDamage ( Unit const *  target,
SpellEffectInfo const &  spellEffectInfo,
int32 const *  basePoints = nullptr,
float *  variance = nullptr,
uint32  castItemId = 0,
int32  itemLevel = -1 
) const
2174 {
2175  if (variance)
2176  *variance = 0.0f;
2177 
2178  return spellEffectInfo.CalcValue(this, basePoints, target, variance, castItemId, itemLevel);
2179 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanAlwaysSee()

virtual bool WorldObject::CanAlwaysSee ( WorldObject const *  ) const
inlineprivatevirtual

Reimplemented in Player, and Creature.

769 { return false; }
+ Here is the caller graph for this function:

◆ CanDetect()

bool WorldObject::CanDetect ( WorldObject const *  obj,
bool  ignoreStealth,
bool  checkAlert = false 
) const
private
1520 {
1521  WorldObject const* seer = this;
1522 
1523  // If a unit is possessing another one, it uses the detection of the latter
1524  // Pets don't have detection, they use the detection of their masters
1525  if (Unit const* thisUnit = ToUnit())
1526  {
1527  if (thisUnit->isPossessing())
1528  {
1529  if (Unit* charmed = thisUnit->GetCharmed())
1530  seer = charmed;
1531  }
1532  else if (Unit* controller = thisUnit->GetCharmerOrOwner())
1533  seer = controller;
1534  }
1535 
1536  if (obj->IsAlwaysDetectableFor(seer))
1537  return true;
1538 
1539  if (!ignoreStealth && !seer->CanDetectInvisibilityOf(obj))
1540  return false;
1541 
1542  if (!ignoreStealth && !seer->CanDetectStealthOf(obj, checkAlert))
1543  return false;
1544 
1545  return true;
1546 }
bool CanDetectInvisibilityOf(WorldObject const *obj) const
Definition: Object.cpp:1548
Definition: Object.h:430
Unit * GetCharmed() const
Definition: Unit.h:1276
bool CanDetectStealthOf(WorldObject const *obj, bool checkAlert=false) const
Definition: Object.cpp:1572
Unit * GetCharmerOrOwner() const
Definition: Unit.h:1285
Definition: Unit.h:746
Unit * ToUnit()
Definition: Object.h:212
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanDetectInvisibilityOf()

bool WorldObject::CanDetectInvisibilityOf ( WorldObject const *  obj) const
private
1549 {
1550  uint32 mask = obj->m_invisibility.GetFlags() & m_invisibilityDetect.GetFlags();
1551 
1552  // Check for not detected types
1553  if (mask != obj->m_invisibility.GetFlags())
1554  return false;
1555 
1556  for (uint32 i = 0; i < TOTAL_INVISIBILITY_TYPES; ++i)
1557  {
1558  if (!(mask & (1 << i)))
1559  continue;
1560 
1561  int32 objInvisibilityValue = obj->m_invisibility.GetValue(InvisibilityType(i));
1562  int32 ownInvisibilityDetectValue = m_invisibilityDetect.GetValue(InvisibilityType(i));
1563 
1564  // Too low value to detect
1565  if (ownInvisibilityDetectValue < objInvisibilityValue)
1566  return false;
1567  }
1568 
1569  return true;
1570 }
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:421
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibilityDetect
Definition: Object.h:548
InvisibilityType
Definition: SharedDefines.h:2352
int32_t int32
Definition: Define.h:139
uint32_t uint32
Definition: Define.h:143
Definition: SharedDefines.h:2393
T_FLAGS GetFlags() const
Definition: Object.h:416
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanDetectStealthOf()

bool WorldObject::CanDetectStealthOf ( WorldObject const *  obj,
bool  checkAlert = false 
) const
private
1573 {
1574  // Combat reach is the minimal distance (both in front and behind),
1575  // and it is also used in the range calculation.
1576  // One stealth point increases the visibility range by 0.3 yard.
1577 
1578  if (!obj->m_stealth.GetFlags())
1579  return true;
1580 
1581  float distance = GetExactDist(obj);
1582  float combatReach = 0.0f;
1583 
1584  Unit const* unit = ToUnit();
1585  if (unit)
1586  combatReach = unit->GetCombatReach();
1587 
1588  if (distance < combatReach)
1589  return true;
1590 
1591  // Only check back for units, it does not make sense for gameobjects
1592  if (unit && !HasInArc(float(M_PI), obj))
1593  return false;
1594 
1595  // Traps should detect stealth always
1596  if (GameObject const* go = ToGameObject())
1597  if (go->GetGoType() == GAMEOBJECT_TYPE_TRAP)
1598  return true;
1599 
1600  GameObject const* go = obj->ToGameObject();
1601  for (uint32 i = 0; i < TOTAL_STEALTH_TYPES; ++i)
1602  {
1603  if (!(obj->m_stealth.GetFlags() & (1 << i)))
1604  continue;
1605 
1607  return true;
1608 
1609  // Starting points
1610  int32 detectionValue = 30;
1611 
1612  // Level difference: 5 point / level, starting from level 1.
1613  // There may be spells for this and the starting points too, but
1614  // not in the DBCs of the client.
1615  detectionValue += int32(GetLevelForTarget(obj) - 1) * 5;
1616 
1617  // Apply modifiers
1618  detectionValue += m_stealthDetect.GetValue(StealthType(i));
1619  if (go)
1620  if (Unit* owner = go->GetOwner())
1621  detectionValue -= int32(owner->GetLevelForTarget(this) - 1) * 5;
1622 
1623  detectionValue -= obj->m_stealth.GetValue(StealthType(i));
1624 
1625  // Calculate max distance
1626  float visibilityRange = float(detectionValue) * 0.3f + combatReach;
1627 
1628  // If this unit is an NPC then player detect range doesn't apply
1629  if (unit && unit->GetTypeId() == TYPEID_PLAYER && visibilityRange > MAX_PLAYER_STEALTH_DETECT_RANGE)
1630  visibilityRange = MAX_PLAYER_STEALTH_DETECT_RANGE;
1631 
1632  // When checking for alert state, look 8% further, and then 1.5 yards more than that.
1633  if (checkAlert)
1634  visibilityRange += (visibilityRange * 0.08f) + 1.5f;
1635 
1636  // If checking for alert, and creature's visibility range is greater than aggro distance, No alert
1637  Unit const* tunit = obj->ToUnit();
1638  if (checkAlert && unit && unit->ToCreature() && visibilityRange >= unit->ToCreature()->GetAttackDistance(tunit) + unit->ToCreature()->m_CombatDistance)
1639  return false;
1640 
1641  if (distance > visibilityRange)
1642  return false;
1643  }
1644 
1645  return true;
1646 }
float GetCombatReach() const override
Definition: Unit.h:812
Definition: SpellAuraDefines.h:322
TypeID GetTypeId() const
Definition: Object.h:170
float GetAttackDistance(Unit const *player) const
Definition: Creature.cpp:2046
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:421
virtual uint8 GetLevelForTarget(WorldObject const *) const
Definition: Object.h:531
static GameObject * ToGameObject(Object *o)
Definition: Object.h:216
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPES > m_stealthDetect
Definition: Object.h:545
#define M_PI
Definition: Common.h:157
GameObject * ToGameObject()
Definition: Object.h:218
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:99
bool HasAuraTypeWithMiscvalue(AuraType auraType, int32 miscValue) const
Definition: Unit.cpp:4543
Unit * GetOwner() const
Definition: Object.cpp:2105
int32_t int32
Definition: Define.h:139
uint32_t uint32
Definition: Define.h:143
Definition: GameObject.h:125
StealthType
Definition: SharedDefines.h:2344
static Creature * ToCreature(Object *o)
Definition: Object.h:204
#define MAX_PLAYER_STEALTH_DETECT_RANGE
Definition: Unit.h:744
Definition: ObjectGuid.h:40
Definition: SharedDefines.h:2349
static Unit * ToUnit(Object *o)
Definition: Object.h:210
Definition: Unit.h:746
float m_CombatDistance
Definition: Creature.h:352
Definition: SharedDefines.h:2738
Unit * ToUnit()
Definition: Object.h:212
float GetExactDist(float x, float y, float z) const
Definition: Position.h:119
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanNeverSee()

bool WorldObject::CanNeverSee ( WorldObject const *  obj) const
protectedvirtual

Reimplemented in Player.

1515 {
1516  return GetMap() != obj->GetMap() || !IsInPhase(obj);
1517 }
bool IsInPhase(WorldObject const *obj) const
Definition: Object.h:461
Map * GetMap() const
Definition: Object.h:555
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanSeeOrDetect()

bool WorldObject::CanSeeOrDetect ( WorldObject const *  obj,
bool  ignoreStealth = false,
bool  distanceCheck = false,
bool  checkAlert = false 
) const
1419 {
1420  if (this == obj)
1421  return true;
1422 
1423  if (obj->IsNeverVisibleFor(this) || CanNeverSee(obj))
1424  return false;
1425 
1426  if (obj->IsAlwaysVisibleFor(this) || CanAlwaysSee(obj))
1427  return true;
1428 
1429  if (!obj->CheckPrivateObjectOwnerVisibility(this))
1430  return false;
1431 
1432  if (SmoothPhasing const* smoothPhasing = obj->GetSmoothPhasing())
1433  if (smoothPhasing->IsBeingReplacedForSeer(GetGUID()))
1434  return false;
1435 
1436  if (!sConditionMgr->IsObjectMeetingVisibilityByObjectIdConditions(obj->GetTypeId(), obj->GetEntry(), const_cast<WorldObject*>(this)))
1437  return false;
1438 
1439  bool corpseVisibility = false;
1440  if (distanceCheck)
1441  {
1442  bool corpseCheck = false;
1443  if (Player const* thisPlayer = ToPlayer())
1444  {
1445  if (thisPlayer->isDead() && thisPlayer->GetHealth() > 0 && // Cheap way to check for ghost state
1447  {
1448  if (Corpse* corpse = thisPlayer->GetCorpse())
1449  {
1450  corpseCheck = true;
1451  if (corpse->IsWithinDist(thisPlayer, GetSightRange(obj), false))
1452  if (corpse->IsWithinDist(obj, GetSightRange(obj), false))
1453  corpseVisibility = true;
1454  }
1455  }
1456 
1457  if (Unit const* target = obj->ToUnit())
1458  {
1459  // Don't allow to detect vehicle accessories if you can't see vehicle
1460  if (Unit const* vehicle = target->GetVehicleBase())
1461  if (!thisPlayer->HaveAtClient(vehicle))
1462  return false;
1463  }
1464  }
1465 
1466  WorldObject const* viewpoint = this;
1467  if (Player const* player = ToPlayer())
1468  viewpoint = player->GetViewpoint();
1469 
1470  if (!viewpoint)
1471  viewpoint = this;
1472 
1473  if (!corpseCheck && !viewpoint->IsWithinDist(obj, GetSightRange(obj), false))
1474  return false;
1475  }
1476 
1477  // GM visibility off or hidden NPC
1478  if (!obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM))
1479  {
1480  // Stop checking other things for GMs
1482  return true;
1483  }
1484  else
1485  return m_serverSideVisibilityDetect.GetValue(SERVERSIDE_VISIBILITY_GM) >= obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM);
1486 
1487  // Ghost players, Spirit Healers, and some other NPCs
1488  if (!corpseVisibility && !(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibilityDetect.GetValue(SERVERSIDE_VISIBILITY_GHOST)))
1489  {
1490  // Alive players can see dead players in some cases, but other objects can't do that
1491  if (Player const* thisPlayer = ToPlayer())
1492  {
1493  if (Player const* objPlayer = obj->ToPlayer())
1494  {
1495  if (!thisPlayer->IsGroupVisibleFor(objPlayer))
1496  return false;
1497  }
1498  else
1499  return false;
1500  }
1501  else
1502  return false;
1503  }
1504 
1505  if (obj->IsInvisibleDueToDespawn())
1506  return false;
1507 
1508  if (!CanDetect(obj, ignoreStealth, checkAlert))
1509  return false;
1510 
1511  return true;
1512 }
static Player * ToPlayer(Object *o)
Definition: Object.h:198
Definition: Corpse.h:51
Unit * GetVehicleBase() const
Definition: Unit.cpp:11437
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:421
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:550
Definition: Object.h:430
Player * ToPlayer()
Definition: Object.h:200
Definition: SmoothPhasing.h:37
Definition: SharedDefines.h:2407
Definition: SharedDefines.h:2398
ObjectGuid const & GetGUID() const
Definition: Object.h:157
float GetSightRange(WorldObject const *target=nullptr) const
Definition: Object.cpp:1361
virtual bool CanNeverSee(WorldObject const *obj) const
Definition: Object.cpp:1514
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:551
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1050
#define sConditionMgr
Definition: ConditionMgr.h:350
virtual bool CanAlwaysSee(WorldObject const *) const
Definition: Object.h:769
Definition: SharedDefines.h:2399
static Unit * ToUnit(Object *o)
Definition: Object.h:210
Definition: Unit.h:746
Definition: Player.h:1131
bool CanDetect(WorldObject const *obj, bool ignoreStealth, bool checkAlert=false) const
Definition: Object.cpp:1519
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CastSpell()

SpellCastResult WorldObject::CastSpell ( CastSpellTargetArg const &  targets,
uint32  spellId,
CastSpellExtraArgs const &  args = { } 
)
2731 {
2732  SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId, args.CastDifficulty != DIFFICULTY_NONE ? args.CastDifficulty : GetMap()->GetDifficultyID());
2733  if (!info)
2734  {
2735  TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell %u by caster %s", spellId, GetGUID().ToString().c_str());
2737  }
2738 
2739  if (!targets.Targets)
2740  {
2741  TC_LOG_ERROR("entities.unit", "CastSpell: Invalid target passed to spell cast %u by %s", spellId, GetGUID().ToString().c_str());
2742  return SPELL_FAILED_BAD_TARGETS;
2743  }
2744 
2745  Spell* spell = new Spell(this, info, args.TriggerFlags, args.OriginalCaster, args.OriginalCastId);
2746  for (auto const& pair : args.SpellValueOverrides)
2747  spell->SetSpellValue(pair.first, pair.second);
2748 
2749  spell->m_CastItem = args.CastItem;
2750  if (args.OriginalCastItemLevel)
2751  spell->m_castItemLevel = *args.OriginalCastItemLevel;
2752 
2754  {
2755  if (args.TriggeringSpell)
2756  spell->m_CastItem = args.TriggeringSpell->m_CastItem;
2757  else if (args.TriggeringAura && !args.TriggeringAura->GetBase()->GetCastItemGUID().IsEmpty())
2758  if (Player const* triggeringAuraCaster = Object::ToPlayer(args.TriggeringAura->GetCaster()))
2759  spell->m_CastItem = triggeringAuraCaster->GetItemByGuid(args.TriggeringAura->GetBase()->GetCastItemGUID());
2760  }
2761 
2762  return spell->prepare(*targets.Targets, args.TriggeringAura);
2763 }
Definition: DBCEnums.h:666
Definition: SpellInfo.h:342
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
Item * m_CastItem
Definition: Spell.h:533
Player * ToPlayer()
Definition: Object.h:200
Definition: SharedDefines.h:512
Map * GetMap() const
Definition: Object.h:555
ObjectGuid const & GetGUID() const
Definition: Object.h:157
Definition: SharedDefines.h:1457
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:461
SpellCastResult prepare(SpellCastTargets const &targets, AuraEffect const *triggeredByAura=nullptr)
Definition: Spell.cpp:3287
#define sSpellMgr
Definition: SpellMgr.h:825
Definition: SharedDefines.h:1571
std::string ToString() const
Definition: Position.cpp:128
void SetSpellValue(SpellValueMod mod, int32 value)
Definition: Spell.cpp:8317
int32 m_castItemLevel
Definition: Spell.h:536
Definition: Player.h:1131
Definition: Spell.h:238
+ Here is the call graph for this function:

◆ CheckPrivateObjectOwnerVisibility()

bool WorldObject::CheckPrivateObjectOwnerVisibility ( WorldObject const *  seer) const
1391 {
1392  if (!IsPrivateObject())
1393  return true;
1394 
1395  // Owner of this private object
1396  if (_privateObjectOwner == seer->GetGUID())
1397  return true;
1398 
1399  // Another private object of the same owner
1400  if (_privateObjectOwner == seer->GetPrivateObjectOwner())
1401  return true;
1402 
1403  if (Player const* playerSeer = seer->ToPlayer())
1404  if (playerSeer->IsInGroup(_privateObjectOwner))
1405  return true;
1406 
1407  return false;
1408 }
static Player * ToPlayer(Object *o)
Definition: Object.h:198
bool IsPrivateObject() const
Definition: Object.h:713
ObjectGuid _privateObjectOwner
Definition: Object.h:763
Definition: Player.h:1131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CleanupsBeforeDelete()

void WorldObject::CleanupsBeforeDelete ( bool  finalCleanup = true)
virtual

Reimplemented in Player, Unit, GameObject, and Transport.

893 {
894  if (IsInWorld())
895  RemoveFromWorld();
896 
897  if (TransportBase* transport = GetTransport())
898  transport->RemovePassenger(this);
899 }
bool IsInWorld() const
Definition: Object.h:151
Definition: VehicleDefines.h:153
void RemoveFromWorld() override
Definition: Object.cpp:925
TransportBase * GetTransport() const
Definition: Object.h:679
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DestroyForNearbyPlayers()

void WorldObject::DestroyForNearbyPlayers ( )
Todo:
this is for puppet
3460 {
3461  if (!IsInWorld())
3462  return;
3463 
3464  std::list<Player*> targets;
3467  Cell::VisitWorldObjects(this, searcher, GetVisibilityRange());
3468  for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
3469  {
3470  Player* player = (*iter);
3471 
3472  if (player == this)
3473  continue;
3474 
3475  if (!player->HaveAtClient(this))
3476  continue;
3477 
3478  if (isType(TYPEMASK_UNIT) && ToUnit()->GetCharmerGUID() == player->GetGUID())
3479  continue;
3480 
3481  DestroyForPlayer(player);
3482  player->m_clientGUIDs.erase(GetGUID());
3483  }
3484 }
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1272
Definition: GridNotifiers.h:1437
bool HaveAtClient(Object const *u) const
Definition: Player.cpp:24002
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
bool IsInWorld() const
Definition: Object.h:151
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:191
Definition: GridNotifiers.h:610
Definition: ObjectGuid.h:59
virtual void DestroyForPlayer(Player *target) const
Definition: Object.cpp:241
ObjectGuid const & GetGUID() const
Definition: Object.h:157
bool isType(uint16 mask) const
Definition: Object.h:171
float GetVisibilityRange() const
Definition: Object.cpp:1351
GuidUnorderedSet m_clientGUIDs
Definition: Player.h:2488
Definition: Player.h:1131
Unit * ToUnit()
Definition: Object.h:212
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindMap()

Map* WorldObject::FindMap ( ) const
inline
556 { return m_currMap; }
Map * m_currMap
Definition: Object.h:754
+ Here is the caller graph for this function:

◆ FindNearestCreature()

Creature * WorldObject::FindNearestCreature ( uint32  entry,
float  range,
bool  alive = true 
) const
2051 {
2052  Creature* creature = nullptr;
2053  Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range);
2055  Cell::VisitAllObjects(this, searcher, range);
2056  return creature;
2057 }
Definition: Creature.h:69
Definition: GridNotifiers.h:543
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:203
+ Here is the call graph for this function:

◆ FindNearestGameObject()

GameObject * WorldObject::FindNearestGameObject ( uint32  entry,
float  range,
bool  spawnedOnly = true 
) const
2060 {
2061  GameObject* go = nullptr;
2062  Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range, spawnedOnly);
2064  Cell::VisitGridObjects(this, searcher, range);
2065  return go;
2066 }
Definition: GridNotifiers.h:420
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
Definition: GameObject.h:125
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindNearestGameObjectOfType()

GameObject * WorldObject::FindNearestGameObjectOfType ( GameobjectTypes  type,
float  range 
) const
2078 {
2079  GameObject* go = nullptr;
2080  Trinity::NearestGameObjectTypeInObjectRangeCheck checker(*this, type, range);
2082  Cell::VisitGridObjects(this, searcher, range);
2083  return go;
2084 }
Definition: GridNotifiers.h:420
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
Definition: GameObject.h:125
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindNearestUnspawnedGameObject()

GameObject * WorldObject::FindNearestUnspawnedGameObject ( uint32  entry,
float  range 
) const
2069 {
2070  GameObject* go = nullptr;
2073  Cell::VisitGridObjects(this, searcher, range);
2074  return go;
2075 }
Definition: GridNotifiers.h:420
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
Definition: GameObject.h:125
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindZoneScript()

ZoneScript * WorldObject::FindZoneScript ( ) const
1897 {
1898  if (Map* map = FindMap())
1899  {
1900  if (InstanceMap* instanceMap = map->ToInstanceMap())
1901  return reinterpret_cast<ZoneScript*>(instanceMap->GetInstanceScript());
1902  else if (!map->IsBattlegroundOrArena())
1903  {
1904  if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId()))
1905  return bf;
1906  else
1907  return sOutdoorPvPMgr->GetZoneScript(GetZoneId());
1908  }
1909  }
1910  return nullptr;
1911 }
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:102
uint32 GetZoneId() const
Definition: Object.h:479
Definition: Map.h:945
InstanceMap * ToInstanceMap()
Definition: Map.h:528
Definition: Battlefield.h:209
Definition: Map.h:264
Map * FindMap() const
Definition: Object.h:556
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAffectingPlayer()

Player * WorldObject::GetAffectingPlayer ( ) const
2138 {
2139  if (!GetCharmerOrOwnerGUID())
2140  return const_cast<WorldObject*>(this)->ToPlayer();
2141 
2142  if (Unit* owner = GetCharmerOrOwner())
2143  return owner->GetCharmerOrOwnerPlayerOrPlayerItself();
2144 
2145  return nullptr;
2146 }
Definition: Object.h:430
Player * ToPlayer()
Definition: Object.h:200
virtual ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Object.h:580
Unit * GetCharmerOrOwner() const
Definition: Object.cpp:2110
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Object.cpp:2128
Definition: Unit.h:746
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAIAnimKitId()

virtual uint16 WorldObject::GetAIAnimKitId ( ) const
inlinevirtual

Reimplemented in Unit, and GameObject.

708 { return 0; }

◆ GetAreaId()

uint32 WorldObject::GetAreaId ( ) const
inline
480 { return m_areaId; }
uint32 m_areaId
Definition: Object.h:736
+ Here is the caller graph for this function:

◆ GetCastSpellXSpellVisualId()

uint32 WorldObject::GetCastSpellXSpellVisualId ( SpellInfo const *  spellInfo) const
virtual

Reimplemented in Unit.

3170 {
3171  return spellInfo->GetSpellXSpellVisualId(this);
3172 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCharmerOrOwner()

Unit * WorldObject::GetCharmerOrOwner ( ) const
2111 {
2112  if (Unit const* unit = ToUnit())
2113  return unit->GetCharmerOrOwner();
2114  else if (GameObject const* go = ToGameObject())
2115  return go->GetOwner();
2116 
2117  return nullptr;
2118 }
GameObject * ToGameObject()
Definition: Object.h:218
Definition: GameObject.h:125
Definition: Unit.h:746
Unit * ToUnit()
Definition: Object.h:212
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCharmerOrOwnerGUID()

virtual ObjectGuid WorldObject::GetCharmerOrOwnerGUID ( ) const
inlinevirtual

Reimplemented in Unit.

580 { return GetOwnerGUID(); }
virtual ObjectGuid GetOwnerGUID() const =0
+ Here is the caller graph for this function:

◆ GetCharmerOrOwnerOrOwnGUID()

ObjectGuid WorldObject::GetCharmerOrOwnerOrOwnGUID ( ) const
2098 {
2100  if (!guid.IsEmpty())
2101  return guid;
2102  return GetGUID();
2103 }
ObjectGuid const & GetGUID() const
Definition: Object.h:157
virtual ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Object.h:580
bool IsEmpty() const
Definition: ObjectGuid.h:310
Definition: ObjectGuid.h:258
+ Here is the call graph for this function:

◆ GetCharmerOrOwnerOrSelf()

Unit * WorldObject::GetCharmerOrOwnerOrSelf ( ) const
2121 {
2122  if (Unit* u = GetCharmerOrOwner())
2123  return u;
2124 
2125  return const_cast<WorldObject*>(this)->ToUnit();
2126 }
Definition: Object.h:430
Unit * GetCharmerOrOwner() const
Definition: Object.cpp:2110
Definition: Unit.h:746
Unit * ToUnit()
Definition: Object.h:212
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCharmerOrOwnerPlayerOrPlayerItself()

Player * WorldObject::GetCharmerOrOwnerPlayerOrPlayerItself ( ) const
2129 {
2131  if (guid.IsPlayer())
2132  return ObjectAccessor::GetPlayer(*this, guid);
2133 
2134  return const_cast<WorldObject*>(this)->ToPlayer();
2135 }
Definition: Object.h:430
Player * ToPlayer()
Definition: Object.h:200
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:227
virtual ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Object.h:580
bool IsPlayer() const
Definition: ObjectGuid.h:317
Definition: ObjectGuid.h:258
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetClosePoint()

void WorldObject::GetClosePoint ( float &  x,
float &  y,
float &  z,
float  size,
float  distance2d = 0,
float  relAngle = 0 
) const
3263 {
3264  // angle calculated from current orientation
3265  GetNearPoint(nullptr, x, y, z, distance2d + size, GetOrientation() + relAngle);
3266 }
float GetOrientation() const
Definition: Position.h:80
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float distance2d, float absAngle) const
Definition: Object.cpp:3227
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCollisionHeight()

virtual float WorldObject::GetCollisionHeight ( ) const
inlinevirtual

Reimplemented in Unit.

698 { return 0.0f; }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCombatReach()

virtual float WorldObject::GetCombatReach ( ) const
inlinevirtual

Reimplemented in Unit.

452 { return 0.0f; } // overridden (only) in Unit
+ Here is the caller graph for this function:

◆ GetContactPoint()

void WorldObject::GetContactPoint ( WorldObject const *  obj,
float &  x,
float &  y,
float &  z,
float  distance2d = CONTACT_DISTANCE 
) const
3290 {
3291  // angle to face `obj` to `this` using distance includes size of `obj`
3292  GetNearPoint(obj, x, y, z, distance2d, GetAbsoluteAngle(obj));
3293 }
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float distance2d, float absAngle) const
Definition: Object.cpp:3227
float GetAbsoluteAngle(float x, float y) const
Definition: Position.h:126
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCreatureListWithEntryInGrid()

template<typename Container >
template TC_GAME_API void WorldObject::GetCreatureListWithEntryInGrid ( Container &  creatureContainer,
uint32  entry,
float  maxSearchRange = 250.0f 
) const
3184 {
3185  Trinity::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange);
3186  Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, creatureContainer, check);
3187  Cell::VisitGridObjects(this, searcher, maxSearchRange);
3188 }
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
Definition: GridNotifiers.h:558
Definition: GridNotifiers.h:1538
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDBPhase()

int32 WorldObject::GetDBPhase ( ) const
inline
474 { return _dbPhase; }
int32 _dbPhase
Definition: Object.h:759
+ Here is the caller graph for this function:

◆ GetDebugInfo()

std::string WorldObject::GetDebugInfo ( ) const
overridevirtual

Reimplemented from Object.

Reimplemented in Player, Unit, Pet, and Transport.

3614 {
3615  std::stringstream sstr;
3616  sstr << WorldLocation::GetDebugInfo() << "\n"
3617  << Object::GetDebugInfo() << "\n"
3618  << "Name: " << GetName();
3619  return sstr.str();
3620 }
std::string GetDebugInfo() const
Definition: Position.cpp:203
std::string const & GetName() const
Definition: Object.h:488
virtual std::string GetDebugInfo() const
Definition: Object.cpp:782
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDistance() [1/3]

float WorldObject::GetDistance ( WorldObject const *  obj) const
987 {
988  float d = GetExactDist(obj) - GetCombatReach() - obj->GetCombatReach();
989  return d > 0.0f ? d : 0.0f;
990 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetExactDist(float x, float y, float z) const
Definition: Position.h:119
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDistance() [2/3]

float WorldObject::GetDistance ( Position const &  pos) const
993 {
994  float d = GetExactDist(&pos) - GetCombatReach();
995  return d > 0.0f ? d : 0.0f;
996 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetExactDist(float x, float y, float z) const
Definition: Position.h:119
+ Here is the call graph for this function:

◆ GetDistance() [3/3]

float WorldObject::GetDistance ( float  x,
float  y,
float  z 
) const
999 {
1000  float d = GetExactDist(x, y, z) - GetCombatReach();
1001  return d > 0.0f ? d : 0.0f;
1002 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetExactDist(float x, float y, float z) const
Definition: Position.h:119
+ Here is the call graph for this function:

◆ GetDistance2d() [1/2]

float WorldObject::GetDistance2d ( WorldObject const *  obj) const
1005 {
1006  float d = GetExactDist2d(obj) - GetCombatReach() - obj->GetCombatReach();
1007  return d > 0.0f ? d : 0.0f;
1008 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:107
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDistance2d() [2/2]

float WorldObject::GetDistance2d ( float  x,
float  y 
) const
1011 {
1012  float d = GetExactDist2d(x, y) - GetCombatReach();
1013  return d > 0.0f ? d : 0.0f;
1014 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:107
+ Here is the call graph for this function:

◆ GetDistanceOrder()

bool WorldObject::GetDistanceOrder ( WorldObject const *  obj1,
WorldObject const *  obj2,
bool  is3D = true 
) const
1124 {
1125  float dx1 = GetPositionX() - obj1->GetPositionX();
1126  float dy1 = GetPositionY() - obj1->GetPositionY();
1127  float distsq1 = dx1*dx1 + dy1*dy1;
1128  if (is3D)
1129  {
1130  float dz1 = GetPositionZ() - obj1->GetPositionZ();
1131  distsq1 += dz1*dz1;
1132  }
1133 
1134  float dx2 = GetPositionX() - obj2->GetPositionX();
1135  float dy2 = GetPositionY() - obj2->GetPositionY();
1136  float distsq2 = dx2*dx2 + dy2*dy2;
1137  if (is3D)
1138  {
1139  float dz2 = GetPositionZ() - obj2->GetPositionZ();
1140  distsq2 += dz2*dz2;
1141  }
1142 
1143  return distsq1 < distsq2;
1144 }
float GetPositionY() const
Definition: Position.h:78
float GetPositionZ() const
Definition: Position.h:79
float GetPositionX() const
Definition: Position.h:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDistanceZ()

float WorldObject::GetDistanceZ ( WorldObject const *  obj) const
957 {
958  float dz = std::fabs(GetPositionZ() - obj->GetPositionZ());
959  float sizefactor = GetCombatReach() + obj->GetCombatReach();
960  float dist = dz - sizefactor;
961  return (dist > 0 ? dist : 0);
962 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetPositionZ() const
Definition: Position.h:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFaction()

virtual uint32 WorldObject::GetFaction ( ) const
pure virtual

Implemented in Unit, GameObject, AreaTrigger, Corpse, DynamicObject, Conversation, and SceneObject.

+ Here is the caller graph for this function:

◆ GetFactionReactionTo()

ReputationRank WorldObject::GetFactionReactionTo ( FactionTemplateEntry const *  factionTemplateEntry,
WorldObject const *  target 
)
static
2648 {
2649  // always neutral when no template entry found
2650  if (!factionTemplateEntry)
2651  return REP_NEUTRAL;
2652 
2653  FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry();
2654  if (!targetFactionTemplateEntry)
2655  return REP_NEUTRAL;
2656 
2657  if (Player const* targetPlayerOwner = target->GetAffectingPlayer())
2658  {
2659  // check contested flags
2660  if ((factionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD) &&
2661  targetPlayerOwner->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
2662  return REP_HOSTILE;
2663  if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(factionTemplateEntry))
2664  return *repRank;
2665  if (target->IsUnit() && !target->ToUnit()->HasUnitFlag2(UNIT_FLAG2_IGNORE_REPUTATION))
2666  {
2667  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->Faction))
2668  {
2669  if (factionEntry->CanHaveReputation())
2670  {
2671  // CvP case - check reputation, don't allow state higher than neutral when at war
2672  ReputationRank repRank = targetPlayerOwner->GetReputationMgr().GetRank(factionEntry);
2673  if (targetPlayerOwner->GetReputationMgr().IsAtWar(factionEntry))
2674  repRank = std::min(REP_NEUTRAL, repRank);
2675  return repRank;
2676  }
2677  }
2678  }
2679  }
2680 
2681  // common faction based check
2682  if (factionTemplateEntry->IsHostileTo(targetFactionTemplateEntry))
2683  return REP_HOSTILE;
2684  if (factionTemplateEntry->IsFriendlyTo(targetFactionTemplateEntry))
2685  return REP_FRIENDLY;
2686  if (targetFactionTemplateEntry->IsFriendlyTo(factionTemplateEntry))
2687  return REP_FRIENDLY;
2688  if (factionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT)
2689  return REP_HOSTILE;
2690  // neutral by default
2691  return REP_NEUTRAL;
2692 }
Definition: Player.h:461
ReputationRank
Definition: SharedDefines.h:186
Player * GetAffectingPlayer() const
Definition: Object.cpp:2137
Definition: SharedDefines.h:191
Definition: SharedDefines.h:192
Definition: SharedDefines.h:189
Definition: DBCEnums.h:735
Definition: UnitDefines.h:177
Definition: DB2Structure.h:1459
Definition: DB2Structure.h:1431
bool IsFriendlyTo(FactionTemplateEntry const *entry) const
Definition: DB2Structure.h:1473
DB2Storage< FactionEntry > sFactionStore("Faction.db2", FactionLoadInfo::Instance())
Definition: Player.h:1131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFactionTemplateEntry()

FactionTemplateEntry const * WorldObject::GetFactionTemplateEntry ( ) const
2533 {
2534  uint32 factionId = GetFaction();
2535  FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(factionId);
2536  if (!entry)
2537  {
2538  switch (GetTypeId())
2539  {
2540  case TYPEID_PLAYER:
2541  TC_LOG_ERROR("entities.unit", "Player %s has invalid faction (faction template id) #%u", ToPlayer()->GetName().c_str(), factionId);
2542  break;
2543  case TYPEID_UNIT:
2544  TC_LOG_ERROR("entities.unit", "Creature (template id: %u) has invalid faction (faction template Id) #%u", ToCreature()->GetCreatureTemplate()->Entry, factionId);
2545  break;
2546  case TYPEID_GAMEOBJECT:
2547  if (factionId) // Gameobjects may have faction template id = 0
2548  TC_LOG_ERROR("entities.faction", "GameObject (template id: %u) has invalid faction (faction template Id) #%u", ToGameObject()->GetGOInfo()->entry, factionId);
2549  break;
2550  default:
2551  TC_LOG_ERROR("entities.unit", "Object (name=%s, type=%u) has invalid faction (faction template Id) #%u", GetName().c_str(), uint32(GetTypeId()), factionId);
2552  break;
2553  }
2554  }
2555 
2556  return entry;
2557 }
TypeID GetTypeId() const
Definition: Object.h:170
virtual uint32 GetFaction() const =0
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
Definition: ObjectGuid.h:39
uint32 const Entry[5]
Definition: boss_nefarian.cpp:163
GameObject * ToGameObject()
Definition: Object.h:218
Player * ToPlayer()
Definition: Object.h:200
std::string const & GetName() const
Definition: Object.h:488
Definition: ObjectGuid.h:42
uint32_t uint32
Definition: Define.h:143
DB2Storage< FactionTemplateEntry > sFactionTemplateStore("FactionTemplate.db2", FactionTemplateLoadInfo::Instance())
Definition: DB2Structure.h:1459
Definition: ObjectGuid.h:40
Creature * ToCreature()
Definition: Object.h:206
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFirstCollisionPosition()

Position WorldObject::GetFirstCollisionPosition ( float  dist,
float  angle 
)
3276 {
3277  Position pos = GetPosition();
3278  MovePositionToFirstCollision(pos, dist, angle);
3279  return pos;
3280 }
Position GetPosition() const
Definition: Position.h:85
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition: Object.cpp:3341
Definition: Position.h:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFloorZ()

float WorldObject::GetFloorZ ( ) const
3592 {
3593  if (!IsInWorld())
3594  return m_staticFloorZ;
3596 }
bool IsInWorld() const
Definition: Object.h:151
float m_staticFloorZ
Definition: Object.h:737
float GetGameObjectFloor(PhaseShift const &phaseShift, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.h:546
float GetPositionY() const
Definition: Position.h:78
Map * GetMap() const
Definition: Object.h:555
PhaseShift & GetPhaseShift()
Definition: Object.h:470
float GetPositionZ() const
Definition: Position.h:79
float GetPositionX() const
Definition: Position.h:77
constexpr float Z_OFFSET_FIND_HEIGHT
Definition: SharedDefines.h:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGameObjectListWithEntryInGrid()

template<typename Container >
template TC_GAME_API void WorldObject::GetGameObjectListWithEntryInGrid ( Container &  gameObjectContainer,
uint32  entry,
float  maxSearchRange = 250.0f 
) const
3176 {
3177  Trinity::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
3178  Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, gameObjectContainer, check);
3179  Cell::VisitGridObjects(this, searcher, maxSearchRange);
3180 }
Definition: GridNotifiers.h:435
Definition: GridNotifiers.h:1519
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:179
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGridActivationRange()

float WorldObject::GetGridActivationRange ( ) const
1336 {
1337  if (isActiveObject())
1338  {
1339  if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetCinematicMgr()->IsOnCinematic())
1340  return std::max(DEFAULT_VISIBILITY_INSTANCE, GetMap()->GetVisibilityRange());
1341 
1342  return GetMap()->GetVisibilityRange();
1343  }
1344 
1345  if (Creature const* thisCreature = ToCreature())
1346  return thisCreature->m_SightDistance;
1347 
1348  return 0.0f;
1349 }
float GetVisibilityRange() const
Definition: Map.h:295
TypeID GetTypeId() const
Definition: Object.h:170
bool isActiveObject() const
Definition: Object.h:666
Definition: Creature.h:69
Player * ToPlayer()
Definition: Object.h:200
Map * GetMap() const
Definition: Object.h:555
float GetVisibilityRange() const
Definition: Object.cpp:1351
#define DEFAULT_VISIBILITY_INSTANCE
Definition: ObjectDefines.h:36
Definition: ObjectGuid.h:40
Creature * ToCreature()
Definition: Object.h:206
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHitSpherePointFor() [1/2]

Position WorldObject::GetHitSpherePointFor ( Position const &  dest) const
1061 {
1062  G3D::Vector3 vThis(GetPositionX(), GetPositionY(), GetPositionZ() + GetCollisionHeight());
1063  G3D::Vector3 vObj(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
1064  G3D::Vector3 contactPoint = vThis + (vObj - vThis).directionOrZero() * std::min(dest.GetExactDist(GetPosition()), GetCombatReach());
1065 
1066  return Position(contactPoint.x, contactPoint.y, contactPoint.z, GetAbsoluteAngle(contactPoint.x, contactPoint.y));
1067 }
Position GetPosition() const
Definition: Position.h:85
virtual float GetCollisionHeight() const
Definition: Object.h:698
virtual float GetCombatReach() const
Definition: Object.h:452
float GetPositionY() const
Definition: Position.h:78
Position(float x=0, float y=0, float z=0, float o=0)
Definition: Position.h:29
float GetPositionZ() const
Definition: Position.h:79
float GetPositionX() const
Definition: Position.h:77
float GetAbsoluteAngle(float x, float y) const
Definition: Position.h:126
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetHitSpherePointFor() [2/2]

void WorldObject::GetHitSpherePointFor ( Position const &  dest,
float &  x,
float &  y,
float &  z 
) const
1116 {
1117  Position pos = GetHitSpherePointFor(dest);
1118  x = pos.GetPositionX();
1119  y = pos.GetPositionY();
1120  z = pos.GetPositionZ();
1121 }
float GetPositionY() const
Definition: Position.h:78
float GetPositionZ() const
Definition: Position.h:79
float GetPositionX() const
Definition: Position.h:77
Definition: Position.h:27
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1060
+ Here is the call graph for this function:

◆ GetInstanceId()

uint32 WorldObject::GetInstanceId ( ) const
inline
459 { return m_InstanceId; }
uint32 m_InstanceId
Definition: Object.h:756
+ Here is the caller graph for this function:

◆ GetInstanceScript()

InstanceScript * WorldObject::GetInstanceScript ( ) const
951 {
952  Map* map = GetMap();
953  return map->IsDungeon() ? ((InstanceMap*)map)->GetInstanceScript() : nullptr;
954 }
bool IsDungeon() const
Definition: Map.cpp:4420
Map * GetMap() const
Definition: Object.h:555
Definition: Map.h:945
Definition: Map.h:264
+ Here is the call graph for this function:

◆ GetLevelForTarget()

virtual uint8 WorldObject::GetLevelForTarget ( WorldObject const *  ) const
inlinevirtual

Reimplemented in Unit, GameObject, and Creature.

531 { return 1; }
+ Here is the caller graph for this function:

◆ GetLiquidStatus()

ZLiquidStatus WorldObject::GetLiquidStatus ( ) const
inline
484 { return m_liquidStatus; }
ZLiquidStatus m_liquidStatus
Definition: Object.h:739
+ Here is the caller graph for this function:

◆ GetMagicHitRedirectTarget()

Unit * WorldObject::GetMagicHitRedirectTarget ( Unit victim,
SpellInfo const *  spellInfo 
)
Todo:
handle this charge drop by proc in cast phase on explicit target
3133 {
3134  // Patch 1.2 notes: Spell Reflection no longer reflects abilities
3135  if (spellInfo->HasAttribute(SPELL_ATTR0_IS_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR1_NO_REDIRECTION) || spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
3136  return victim;
3137 
3139  for (AuraEffect const* aurEff : magnetAuras)
3140  {
3141  if (Unit* magnet = aurEff->GetBase()->GetCaster())
3142  {
3143  if (spellInfo->CheckExplicitTarget(this, magnet) == SPELL_CAST_OK && IsValidAttackTarget(magnet, spellInfo))
3144  {
3146  if (spellInfo->HasHitDelay())
3147  {
3148  // Set up missile speed based delay
3149  float hitDelay = spellInfo->LaunchDelay;
3150  if (spellInfo->HasAttribute(SPELL_ATTR9_SPECIAL_DELAY_CALCULATION))
3151  hitDelay += spellInfo->Speed;
3152  else if (spellInfo->Speed > 0.0f)
3153  hitDelay += std::max(victim->GetDistance(this), 5.0f) / spellInfo->Speed;
3154 
3155  uint32 delay = uint32(std::floor(hitDelay * 1000.0f));
3156  // Schedule charge drop
3157  aurEff->GetBase()->DropChargeDelayed(delay, AURA_REMOVE_BY_EXPIRE);
3158  }
3159  else
3160  aurEff->GetBase()->DropCharge(AURA_REMOVE_BY_EXPIRE);
3161 
3162  return magnet;
3163  }
3164  }
3165  }
3166  return victim;
3167 }
Definition: SpellAuraDefines.h:190
Definition: SpellAuraEffects.h:28
bool IsValidAttackTarget(WorldObject const *target, SpellInfo const *bySpell=nullptr) const
Definition: Object.cpp:2877
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:764
Definition: SharedDefines.h:744
Definition: SharedDefines.h:411
Definition: SharedDefines.h:436
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1406
uint32_t uint32
Definition: Define.h:143
Definition: SharedDefines.h:447
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:986
Definition: SpellAuraDefines.h:69
Definition: Unit.h:746
Definition: SharedDefines.h:1760
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMap()

Map* WorldObject::GetMap ( ) const
inline
555 { ASSERT(m_currMap); return m_currMap; }
Map * m_currMap
Definition: Object.h:754
#define ASSERT
Definition: Errors.h:68

◆ GetMapHeight()

float WorldObject::GetMapHeight ( float  x,
float  y,
float  z,
bool  vmap = true,
float  distanceToSearch = 50.0f 
) const
3606 {
3607  if (z != MAX_HEIGHT)
3608  z += Z_OFFSET_FIND_HEIGHT;
3609 
3610  return GetMap()->GetHeight(GetPhaseShift(), x, y, z, vmap, distanceToSearch);
3611 }
float GetHeight(PhaseShift const &phaseShift, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
Definition: Map.h:539
Map * GetMap() const
Definition: Object.h:555
PhaseShift & GetPhaseShift()
Definition: Object.h:470
constexpr float Z_OFFSET_FIND_HEIGHT
Definition: SharedDefines.h:25
#define MAX_HEIGHT
Definition: Map.h:225
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMapWaterOrGroundLevel()

float WorldObject::GetMapWaterOrGroundLevel ( float  x,
float  y,
float  z,
float *  ground = nullptr 
) const
3599 {
3600  return GetMap()->GetWaterOrGroundLevel(GetPhaseShift(), x, y, z, ground,
3601  isType(TYPEMASK_UNIT) ? !static_cast<Unit const*>(this)->HasAuraType(SPELL_AURA_WATER_WALK) : false,
3602  GetCollisionHeight());
3603 }
Definition: SpellAuraDefines.h:198
virtual float GetCollisionHeight() const
Definition: Object.h:698
Definition: ObjectGuid.h:59
Map * GetMap() const
Definition: Object.h:555
PhaseShift & GetPhaseShift()
Definition: Object.h:470
bool isType(uint16 mask) const
Definition: Object.h:171
float GetWaterOrGroundLevel(PhaseShift const &phaseShift, float x, float y, float z, float *ground=nullptr, bool swim=false, float collisionHeight=2.03128f)
Definition: Map.cpp:2590
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMeleeAnimKitId()

virtual uint16 WorldObject::GetMeleeAnimKitId ( ) const
inlinevirtual

Reimplemented in Unit.

710 { return 0; }

◆ GetMovementAnimKitId()

virtual uint16 WorldObject::GetMovementAnimKitId ( ) const
inlinevirtual

Reimplemented in Unit.

709 { return 0; }

◆ GetName()

std::string const& WorldObject::GetName ( ) const
inline
488 { return m_name; }
std::string m_name
Definition: Object.h:724

◆ GetNameForLocaleIdx()

std::string WorldObject::GetNameForLocaleIdx ( LocaleConstant  ) const
inlineoverridevirtual

Implements Object.

491 { return m_name; }
std::string m_name
Definition: Object.h:724
+ Here is the caller graph for this function:

◆ GetNearPoint()

void WorldObject::GetNearPoint ( WorldObject const *  searcher,
float &  x,
float &  y,
float &  z,
float  distance2d,
float  absAngle 
) const
3228 {
3229  GetNearPoint2D(searcher, x, y, distance2d, absAngle);
3230  z = GetPositionZ();
3231  (searcher ? searcher : this)->UpdateAllowedPositionZ(x, y, z);
3232 
3233  // if detection disabled, return first point
3234  if (!sWorld->getBoolConfig(CONFIG_DETECT_POS_COLLISION))
3235  return;
3236 
3237  // return if the point is already in LoS
3238  if (IsWithinLOS(x, y, z))
3239  return;
3240 
3241  // remember first point
3242  float first_x = x;
3243  float first_y = y;
3244  float first_z = z;
3245 
3246  // loop in a circle to look for a point in LoS using small steps
3247  for (float angle = float(M_PI) / 8; angle < float(M_PI) * 2; angle += float(M_PI) / 8)
3248  {
3249  GetNearPoint2D(searcher, x, y, distance2d, absAngle + angle);
3250  z = GetPositionZ();
3251  (searcher ? searcher : this)->UpdateAllowedPositionZ(x, y, z);
3252  if (IsWithinLOS(x, y, z))
3253  return;
3254  }
3255 
3256  // still not in LoS, give up and return first position found
3257  x = first_x;
3258  y = first_y;
3259  z = first_z;
3260 }
void GetNearPoint2D(WorldObject const *searcher, float &x, float &y, float distance, float absAngle) const
Definition: Object.cpp:3198
Definition: World.h:126
#define sWorld
Definition: World.h:946
#define M_PI
Definition: Common.h:157
void UpdateAllowedPositionZ(float x, float y, float &z, float *groundZ=nullptr) const
Definition: Object.cpp:1275
float GetPositionZ() const
Definition: Position.h:79
bool IsWithinLOS(float x, float y, float z, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
Definition: Object.cpp:1069
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNearPoint2D()

void WorldObject::GetNearPoint2D ( WorldObject const *  searcher,
float &  x,
float &  y,
float  distance,
float  absAngle 
) const
3199 {
3200  float effectiveReach = GetCombatReach();
3201 
3202  if (searcher)
3203  {
3204  effectiveReach += searcher->GetCombatReach();
3205 
3206  if (this != searcher)
3207  {
3208  float myHover = 0.0f, searcherHover = 0.0f;
3209  if (Unit const* unit = ToUnit())
3210  myHover = unit->GetHoverOffset();
3211  if (Unit const* searchUnit = searcher->ToUnit())
3212  searcherHover = searchUnit->GetHoverOffset();
3213 
3214  float hoverDelta = myHover - searcherHover;
3215  if (hoverDelta != 0.0f)
3216  effectiveReach = std::sqrt(std::max(effectiveReach * effectiveReach - hoverDelta * hoverDelta, 0.0f));
3217  }
3218  }
3219 
3220  x = GetPositionX() + (effectiveReach + distance2d) * std::cos(absAngle);
3221  y = GetPositionY() + (effectiveReach + distance2d) * std::sin(absAngle);
3222 
3225 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetPositionY() const
Definition: Position.h:78
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:222
float GetPositionX() const
Definition: Position.h:77
static Unit * ToUnit(Object *o)
Definition: Object.h:210
Definition: Unit.h:746
Unit * ToUnit()
Definition: Object.h:212
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNearPosition()

Position WorldObject::GetNearPosition ( float  dist,
float  angle 
)
3269 {
3270  Position pos = GetPosition();
3271  MovePosition(pos, dist, angle);
3272  return pos;
3273 }
void MovePosition(Position &pos, float dist, float angle)
Definition: Object.cpp:3295
Position GetPosition() const
Definition: Position.h:85
Definition: Position.h:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNotifyFlags()

uint16 WorldObject::GetNotifyFlags ( ) const
inline
663 { return m_notifyflags; }
uint16 m_notifyflags
Definition: Object.h:761

◆ GetOrCreateSmoothPhasing()

SmoothPhasing * WorldObject::GetOrCreateSmoothPhasing ( )
1411 {
1412  if (!_smoothPhasing)
1413  _smoothPhasing = std::make_unique<SmoothPhasing>();
1414 
1415  return _smoothPhasing.get();
1416 }
std::unique_ptr< SmoothPhasing > _smoothPhasing
Definition: Object.h:765
+ Here is the caller graph for this function:

◆ GetOwner()

Unit * WorldObject::GetOwner ( ) const
2106 {
2107  return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
2108 }
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:206
virtual ObjectGuid GetOwnerGUID() const =0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetOwnerGUID()

virtual ObjectGuid WorldObject::GetOwnerGUID ( ) const
pure virtual

Implemented in Unit, GameObject, AreaTrigger, Corpse, DynamicObject, Conversation, and SceneObject.

+ Here is the caller graph for this function:

◆ GetPhaseShift() [1/2]

PhaseShift& WorldObject::GetPhaseShift ( )
inline
470 { return _phaseShift; }
PhaseShift _phaseShift
Definition: Object.h:757
+ Here is the caller graph for this function:

◆ GetPhaseShift() [2/2]

PhaseShift const& WorldObject::GetPhaseShift ( ) const
inline
471 { return _phaseShift; }
PhaseShift _phaseShift
Definition: Object.h:757

◆ GetPlayerListInGrid()

template<typename Container >
template TC_GAME_API void WorldObject::GetPlayerListInGrid ( Container &  playerContainer,
float  maxSearchRange,
bool  alive = true 
) const
3192 {
3193  Trinity::AnyPlayerInObjectRangeCheck checker(this, maxSearchRange, alive);
3194  Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, playerContainer, checker);
3195  Cell::VisitWorldObjects(this, searcher, maxSearchRange);
3196 }
Definition: GridNotifiers.h:1437
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:191
Definition: GridNotifiers.h:610
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPrivateObjectOwner()

ObjectGuid WorldObject::GetPrivateObjectOwner ( ) const
inline
714 { return _privateObjectOwner; }
ObjectGuid _privateObjectOwner
Definition: Object.h:763
+ Here is the caller graph for this function:

◆ GetRandomNearPosition()

Position WorldObject::GetRandomNearPosition ( float  radius)
3283 {
3284  Position pos = GetPosition();
3285  MovePosition(pos, radius * (float)rand_norm(), (float)rand_norm() * static_cast<float>(2 * M_PI));
3286  return pos;
3287 }
void MovePosition(Position &pos, float dist, float angle)
Definition: Object.cpp:3295
Position GetPosition() const
Definition: Position.h:85
double rand_norm()
Definition: Random.cpp:75
#define M_PI
Definition: Common.h:157
Definition: Position.h:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetRandomPoint() [1/2]

void WorldObject::GetRandomPoint ( Position const &  srcPos,
float  distance,
float &  rand_x,
float &  rand_y,
float &  rand_z 
) const
1240 {
1241  if (!distance)
1242  {
1243  pos.GetPosition(rand_x, rand_y, rand_z);
1244  return;
1245  }
1246 
1247  // angle to face `obj` to `this`
1248  float angle = (float)rand_norm()*static_cast<float>(2*M_PI);
1249  float new_dist = (float)rand_norm() + (float)rand_norm();
1250  new_dist = distance * (new_dist > 1 ? new_dist - 2 : new_dist);
1251 
1252  rand_x = pos.m_positionX + new_dist * std::cos(angle);
1253  rand_y = pos.m_positionY + new_dist * std::sin(angle);
1254  rand_z = pos.m_positionZ;
1255 
1258  UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available
1259 }
double rand_norm()
Definition: Random.cpp:75
#define M_PI
Definition: Common.h:157
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:222
void UpdateGroundPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1268
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetRandomPoint() [2/2]

Position WorldObject::GetRandomPoint ( Position const &  srcPos,
float  distance 
) const
1262 {
1263  float x, y, z;
1264  GetRandomPoint(srcPos, distance, x, y, z);
1265  return Position(x, y, z, GetOrientation());
1266 }
float GetOrientation() const
Definition: Position.h:80
Position(float x=0, float y=0, float z=0, float o=0)
Definition: Position.h:29
void GetRandomPoint(Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition: Object.cpp:1239
+ Here is the call graph for this function:

◆ GetReactionTo()

ReputationRank WorldObject::GetReactionTo ( WorldObject const *  target) const
2561 {
2562  // always friendly to self
2563  if (this == target)
2564  return REP_FRIENDLY;
2565 
2566  // always friendly to charmer or owner
2568  return REP_FRIENDLY;
2569 
2570  Player const* selfPlayerOwner = GetAffectingPlayer();
2571  Player const* targetPlayerOwner = target->GetAffectingPlayer();
2572 
2573  // check forced reputation to support SPELL_AURA_FORCE_REACTION
2574  if (selfPlayerOwner)
2575  {
2576  if (FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry())
2577  if (ReputationRank const* repRank = selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry))
2578  return *repRank;
2579  }
2580  else if (targetPlayerOwner)
2581  {
2582  if (FactionTemplateEntry const* selfFactionTemplateEntry = GetFactionTemplateEntry())
2583  if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(selfFactionTemplateEntry))
2584  return *repRank;
2585  }
2586 
2587  Unit const* unit = Coalesce<const Unit>(ToUnit(), selfPlayerOwner);
2588  Unit const* targetUnit = Coalesce<const Unit>(target->ToUnit(), targetPlayerOwner);
2589  if (unit && unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
2590  {
2591  if (targetUnit && targetUnit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
2592  {
2593  if (selfPlayerOwner && targetPlayerOwner)
2594  {
2595  // always friendly to other unit controlled by player, or to the player himself
2596  if (selfPlayerOwner == targetPlayerOwner)
2597  return REP_FRIENDLY;
2598 
2599  // duel - always hostile to opponent
2600  if (selfPlayerOwner->duel && selfPlayerOwner->duel->Opponent == targetPlayerOwner && selfPlayerOwner->duel->State == DUEL_STATE_IN_PROGRESS)
2601  return REP_HOSTILE;
2602 
2603  // same group - checks dependant only on our faction - skip FFA_PVP for example
2604  if (selfPlayerOwner->IsInRaidWith(targetPlayerOwner))
2605  return REP_FRIENDLY; // return true to allow config option AllowTwoSide.Interaction.Group to work
2606  // however client seems to allow mixed group parties, because in 13850 client it works like:
2607  // return GetFactionReactionTo(GetFactionTemplateEntry(), target);
2608  }
2609 
2610  // check FFA_PVP
2611  if (unit->IsFFAPvP() && targetUnit->IsFFAPvP())
2612  return REP_HOSTILE;
2613 
2614  if (selfPlayerOwner)
2615  {
2616  if (FactionTemplateEntry const* targetFactionTemplateEntry = targetUnit->GetFactionTemplateEntry())
2617  {
2618  if (ReputationRank const* repRank = selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry))
2619  return *repRank;
2620  if (!selfPlayerOwner->HasUnitFlag2(UNIT_FLAG2_IGNORE_REPUTATION))
2621  {
2622  if (FactionEntry const* targetFactionEntry = sFactionStore.LookupEntry(targetFactionTemplateEntry->Faction))
2623  {
2624  if (targetFactionEntry->CanHaveReputation())
2625  {
2626  // check contested flags
2627  if ((targetFactionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD) &&
2628  selfPlayerOwner->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
2629  return REP_HOSTILE;
2630 
2631  // if faction has reputation, hostile state depends only from AtWar state
2632  if (selfPlayerOwner->GetReputationMgr().IsAtWar(targetFactionEntry))
2633  return REP_HOSTILE;
2634  return REP_FRIENDLY;
2635  }
2636  }
2637  }
2638  }
2639  }
2640  }
2641  }
2642 
2643  // do checks dependant only on our faction
2645 }
Definition: Player.h:461
ReputationRank const * GetForcedRankIfAny(FactionTemplateEntry const *factionTemplateEntry) const
Definition: ReputationMgr.cpp:215
ReputationRank
Definition: SharedDefines.h:186
bool IsAtWar(uint32 faction_id) const
Definition: ReputationMgr.cpp:91
Player * GetAffectingPlayer() const
Definition: Object.cpp:2137
bool HasPlayerFlag(PlayerFlags flags) const
Definition: Player.h:2706
static ReputationRank GetFactionReactionTo(FactionTemplateEntry const *factionTemplateEntry, WorldObject const *target)
Definition: Object.cpp:2647
bool HasUnitFlag2(UnitFlags2 flags) const
Definition: Unit.h:953
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:948
Definition: Player.h:384
Definition: SharedDefines.h:192
Definition: SharedDefines.h:189
std::unique_ptr< DuelInfo > duel
Definition: Player.h:1956
Definition: DBCEnums.h:735
Definition: UnitDefines.h:177
Definition: DB2Structure.h:1459
ReputationMgr & GetReputationMgr()
Definition: Player.h:2230
Definition: DB2Structure.h:1431
Definition: UnitDefines.h:128
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Object.cpp:2532
Unit * GetCharmerOrOwnerOrSelf() const
Definition: Object.cpp:2120
DB2Storage< FactionEntry > sFactionStore("Faction.db2", FactionLoadInfo::Instance())
Definition: Unit.h:746
Definition: Player.h:1131
Unit * ToUnit()
Definition: Object.h:212
bool IsFFAPvP() const
Definition: Unit.h:988
bool IsInRaidWith(Unit const *unit) const
Definition: Unit.cpp:11503
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetScenario()

Scenario * WorldObject::GetScenario ( ) const
1919 {
1920  if (IsInWorld())
1921  if (InstanceMap* instanceMap = GetMap()->ToInstanceMap())
1922  return instanceMap->GetInstanceScenario();
1923 
1924  return nullptr;
1925 }
bool IsInWorld() const
Definition: Object.h:151
Map * GetMap() const
Definition: Object.h:555
Definition: Map.h:945
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSightRange()

float WorldObject::GetSightRange ( WorldObject const *  target = nullptr) const
1362 {
1363  if (ToUnit())
1364  {
1365  if (ToPlayer())
1366  {
1367  if (target && target->IsVisibilityOverridden() && !target->ToPlayer())
1368  return *target->m_visibilityDistanceOverride;
1369  else if (target && target->IsFarVisible() && !target->ToPlayer())
1370  return MAX_VISIBILITY_DISTANCE;
1371  else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
1373  else
1374  return GetMap()->GetVisibilityRange();
1375  }
1376  else if (ToCreature())
1377  return ToCreature()->m_SightDistance;
1378  else
1379  return SIGHT_RANGE_UNIT;
1380  }
1381 
1382  if (ToDynObject() && isActiveObject())
1383  {
1384  return GetMap()->GetVisibilityRange();
1385  }
1386 
1387  return 0.0f;
1388 }
float GetVisibilityRange() const
Definition: Map.h:295
#define SIGHT_RANGE_UNIT
Definition: ObjectDefines.h:29
bool isActiveObject() const
Definition: Object.h:666
DynamicObject * ToDynObject()
Definition: Object.h:230
Player * ToPlayer()
Definition: Object.h:200
Map * GetMap() const
Definition: Object.h:555
bool IsOnCinematic() const
Definition: CinematicMgr.h:38
#define MAX_VISIBILITY_DISTANCE
Definition: ObjectDefines.h:28
#define DEFAULT_VISIBILITY_INSTANCE
Definition: ObjectDefines.h:36
Creature * ToCreature()
Definition: Object.h:206
float m_SightDistance
Definition: Creature.h:352
Unit * ToUnit()
Definition: Object.h:212
CinematicMgr * GetCinematicMgr() const
Definition: Player.h:1511
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSmoothPhasing() [1/2]

SmoothPhasing* WorldObject::GetSmoothPhasing ( )
inline
720 { return _smoothPhasing.get(); }
std::unique_ptr< SmoothPhasing > _smoothPhasing
Definition: Object.h:765
+ Here is the caller graph for this function:

◆ GetSmoothPhasing() [2/2]

SmoothPhasing const* WorldObject::GetSmoothPhasing ( ) const
inline
721 { return _smoothPhasing.get(); }
std::unique_ptr< SmoothPhasing > _smoothPhasing
Definition: Object.h:765

◆ GetSpellMaxRangeForTarget()

float WorldObject::GetSpellMaxRangeForTarget ( Unit const *  target,
SpellInfo const *  spellInfo 
) const
2182 {
2183  if (!spellInfo->RangeEntry)
2184  return 0.f;
2185 
2186  if (spellInfo->RangeEntry->RangeMax[0] == spellInfo->RangeEntry->RangeMax[1])
2187  return spellInfo->GetMaxRange();
2188 
2189  if (!target)
2190  return spellInfo->GetMaxRange(true);
2191 
2192  return spellInfo->GetMaxRange(!IsHostileTo(target));
2193 }
bool IsHostileTo(WorldObject const *target) const
Definition: Object.cpp:2694
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSpellMinRangeForTarget()

float WorldObject::GetSpellMinRangeForTarget ( Unit const *  target,
SpellInfo const *  spellInfo 
) const
2196 {
2197  if (!spellInfo->RangeEntry)
2198  return 0.f;
2199 
2200  if (spellInfo->RangeEntry->RangeMin[0] == spellInfo->RangeEntry->RangeMin[1])
2201  return spellInfo->GetMinRange();
2202 
2203  if (!target)
2204  return spellInfo->GetMinRange(true);
2205 
2206  return spellInfo->GetMinRange(!IsHostileTo(target));
2207 }
bool IsHostileTo(WorldObject const *target) const
Definition: Object.cpp:2694
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSpellModOwner()

Player * WorldObject::GetSpellModOwner ( ) const
2149 {
2150  if (Player* player = const_cast<WorldObject*>(this)->ToPlayer())
2151  return player;
2152 
2153  if (GetTypeId() == TYPEID_UNIT)
2154  {
2155  Creature const* creature = ToCreature();
2156  if (creature->IsPet() || creature->IsTotem())
2157  {
2158  if (Unit* owner = creature->GetOwner())
2159  return owner->ToPlayer();
2160  }
2161  }
2162  else if (GetTypeId() == TYPEID_GAMEOBJECT)
2163  {
2164  GameObject const* go = ToGameObject();
2165  if (Unit* owner = go->GetOwner())
2166  return owner->ToPlayer();
2167  }
2168 
2169  return nullptr;
2170 }
bool IsTotem() const
Definition: Unit.h:860
TypeID GetTypeId() const
Definition: Object.h:170
Definition: ObjectGuid.h:39
Definition: Creature.h:69
GameObject * ToGameObject()
Definition: Object.h:218
Player * ToPlayer()
Definition: Object.h:200
Unit * GetOwner() const
Definition: Object.cpp:2105
bool IsPet() const
Definition: Unit.h:858
Definition: ObjectGuid.h:42
Definition: GameObject.h:125
Creature * ToCreature()
Definition: Object.h:206
Definition: Unit.h:746
Definition: Player.h:1131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetStationaryO()

virtual float WorldObject::GetStationaryO ( ) const
inlinevirtual

Reimplemented in GameObject, Conversation, and SceneObject.

695 { return GetOrientation(); }
float GetOrientation() const
Definition: Position.h:80

◆ GetStationaryX()

virtual float WorldObject::GetStationaryX ( ) const
inlinevirtual

Reimplemented in GameObject, Conversation, and SceneObject.

692 { return GetPositionX(); }
float GetPositionX() const
Definition: Position.h:77

◆ GetStationaryY()

virtual float WorldObject::GetStationaryY ( ) const
inlinevirtual

Reimplemented in GameObject, Conversation, and SceneObject.

693 { return GetPositionY(); }
float GetPositionY() const
Definition: Position.h:78

◆ GetStationaryZ()

virtual float WorldObject::GetStationaryZ ( ) const
inlinevirtual

Reimplemented in GameObject, Conversation, and SceneObject.

694 { return GetPositionZ(); }
float GetPositionZ() const
Definition: Position.h:79

◆ GetSuppressedPhaseShift() [1/2]

PhaseShift& WorldObject::GetSuppressedPhaseShift ( )
inline
472 { return _suppressedPhaseShift; }
PhaseShift _suppressedPhaseShift
Definition: Object.h:758
+ Here is the caller graph for this function:

◆ GetSuppressedPhaseShift() [2/2]

PhaseShift const& WorldObject::GetSuppressedPhaseShift ( ) const
inline
473 { return _suppressedPhaseShift; }
PhaseShift _suppressedPhaseShift
Definition: Object.h:758

◆ GetTransGUID()

ObjectGuid WorldObject::GetTransGUID ( ) const
virtual

Reimplemented in Unit.

3585 {
3586  if (GetTransport())
3587  return GetTransport()->GetTransportGUID();
3588  return ObjectGuid::Empty;
3589 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:265
virtual ObjectGuid GetTransportGUID() const =0
TransportBase * GetTransport() const
Definition: Object.h:679
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetTransOffset()

Position const& WorldObject::GetTransOffset ( ) const
inline
684 { return m_movementInfo.transport.pos; }
MovementInfo m_movementInfo
Definition: Object.h:690
struct MovementInfo::TransportInfo transport
Position pos
Definition: MovementInfo.h:51
+ Here is the caller graph for this function:

◆ GetTransOffsetO()

float WorldObject::GetTransOffsetO ( ) const
inline
MovementInfo m_movementInfo
Definition: Object.h:690
float GetOrientation() const
Definition: Position.h:80
struct MovementInfo::TransportInfo transport
Position pos
Definition: MovementInfo.h:51
+ Here is the caller graph for this function:

◆ GetTransOffsetX()

float WorldObject::GetTransOffsetX ( ) const
inline
MovementInfo m_movementInfo
Definition: Object.h:690
struct MovementInfo::TransportInfo transport
Position pos
Definition: MovementInfo.h:51
float GetPositionX() const
Definition: Position.h:77
+ Here is the caller graph for this function:

◆ GetTransOffsetY()

float WorldObject::GetTransOffsetY ( ) const
inline
MovementInfo m_movementInfo
Definition: Object.h:690
struct MovementInfo::TransportInfo transport
float GetPositionY() const
Definition: Position.h:78
Position pos
Definition: MovementInfo.h:51
+ Here is the caller graph for this function:

◆ GetTransOffsetZ()

float WorldObject::GetTransOffsetZ ( ) const
inline
MovementInfo m_movementInfo
Definition: Object.h:690
struct MovementInfo::TransportInfo transport
float GetPositionZ() const
Definition: Position.h:79
Position pos
Definition: MovementInfo.h:51
+ Here is the caller graph for this function:

◆ GetTransport()

TransportBase* WorldObject::GetTransport ( ) const
inline
679 { return m_transport; }
TransportBase * m_transport
Definition: Object.h:732
+ Here is the caller graph for this function:

◆ GetTransSeat()

int8 WorldObject::GetTransSeat ( ) const
inline
686 { return m_movementInfo.transport.seat; }
MovementInfo m_movementInfo
Definition: Object.h:690
struct MovementInfo::TransportInfo transport
int8 seat
Definition: MovementInfo.h:52
+ Here is the caller graph for this function:

◆ GetTransTime()

uint32 WorldObject::GetTransTime ( ) const
inline
685 { return m_movementInfo.transport.time; }
MovementInfo m_movementInfo
Definition: Object.h:690
struct MovementInfo::TransportInfo transport
uint32 time
Definition: MovementInfo.h:53

◆ GetVisibilityRange()

float WorldObject::GetVisibilityRange ( ) const
1352 {
1353  if (IsVisibilityOverridden() && !ToPlayer())
1355  else if (IsFarVisible() && !ToPlayer())
1356  return MAX_VISIBILITY_DISTANCE;
1357  else
1358  return GetMap()->GetVisibilityRange();
1359 }
bool IsFarVisible() const
Definition: Object.h:668
float GetVisibilityRange() const
Definition: Map.h:295
bool IsVisibilityOverridden() const
Definition: Object.h:670
Player * ToPlayer()
Definition: Object.h:200
Map * GetMap() const
Definition: Object.h:555
Optional< float > m_visibilityDistanceOverride
Definition: Object.h:727
#define MAX_VISIBILITY_DISTANCE
Definition: ObjectDefines.h:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetZoneAndAreaId()

void WorldObject::GetZoneAndAreaId ( uint32 zoneid,
uint32 areaid 
) const
inline
481 { zoneid = m_zoneId, areaid = m_areaId; }
uint32 m_zoneId
Definition: Object.h:735
uint32 m_areaId
Definition: Object.h:736
+ Here is the caller graph for this function:

◆ GetZoneId()

uint32 WorldObject::GetZoneId ( ) const
inline
479 { return m_zoneId; }
uint32 m_zoneId
Definition: Object.h:735
+ Here is the caller graph for this function:

◆ GetZoneScript()

ZoneScript* WorldObject::GetZoneScript ( ) const
inline
561 { return m_zoneScript; }
ZoneScript * m_zoneScript
Definition: Object.h:729
+ Here is the caller graph for this function:

◆ InSamePhase()

static bool WorldObject::InSamePhase ( WorldObject const *  a,
WorldObject const *  b 
)
inlinestatic
466  {
467  return a && b && a->IsInPhase(b);
468  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isActiveObject()

bool WorldObject::isActiveObject ( ) const
inline
666 { return m_isActive; }
bool m_isActive
Definition: Object.h:725
+ Here is the caller graph for this function:

◆ IsAlwaysDetectableFor()

virtual bool WorldObject::IsAlwaysDetectableFor ( WorldObject const *  ) const
inlineprotectedvirtual

Reimplemented in Player, and Unit.

752 { return false; }
+ Here is the caller graph for this function:

◆ IsAlwaysVisibleFor()

virtual bool WorldObject::IsAlwaysVisibleFor ( WorldObject const *  ) const
inlineprotectedvirtual

Reimplemented in Unit, and GameObject.

749 { return false; }
+ Here is the caller graph for this function:

◆ IsFarVisible()

bool WorldObject::IsFarVisible ( ) const
inline
668 { return m_isFarVisible; }
bool m_isFarVisible
Definition: Object.h:726
+ Here is the caller graph for this function:

◆ IsFriendlyTo()

bool WorldObject::IsFriendlyTo ( WorldObject const *  target) const
2700 {
2701  return GetReactionTo(target) >= REP_FRIENDLY;
2702 }
ReputationRank GetReactionTo(WorldObject const *target) const
Definition: Object.cpp:2560
Definition: SharedDefines.h:192
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsHostileTo()

bool WorldObject::IsHostileTo ( WorldObject const *  target) const
2695 {
2696  return GetReactionTo(target) <= REP_HOSTILE;
2697 }
ReputationRank GetReactionTo(WorldObject const *target) const
Definition: Object.cpp:2560
Definition: SharedDefines.h:189
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsHostileToPlayers()

bool WorldObject::IsHostileToPlayers ( ) const
2705 {
2706  FactionTemplateEntry const* my_faction = GetFactionTemplateEntry();
2707  if (!my_faction->Faction)
2708  return false;
2709 
2710  FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->Faction);
2711  if (raw_faction && raw_faction->ReputationIndex >= 0)
2712  return false;
2713 
2714  return my_faction->IsHostileToPlayers();
2715 }
int16 ReputationIndex
Definition: DB2Structure.h:1437
Definition: DB2Structure.h:1459
Definition: DB2Structure.h:1431
uint16 Faction
Definition: DB2Structure.h:1462
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Object.cpp:2532
bool IsHostileToPlayers() const
Definition: DB2Structure.h:1503
DB2Storage< FactionEntry > sFactionStore("Faction.db2", FactionLoadInfo::Instance())
+ Here is the call graph for this function:

◆ isInBack()

bool WorldObject::isInBack ( WorldObject const *  target,
float  arc = float(M_PI) 
) const
1235 {
1236  return !HasInArc(2 * float(M_PI) - arc, target);
1237 }
#define M_PI
Definition: Common.h:157
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInBetween() [1/2]

bool WorldObject::IsInBetween ( Position const &  pos1,
Position const &  pos2,
float  size = 0 
) const
1213 {
1214  float dist = GetExactDist2d(pos1);
1215 
1216  // not using sqrt() for performance
1217  if ((dist * dist) >= pos1.GetExactDist2dSq(pos2))
1218  return false;
1219 
1220  if (!size)
1221  size = GetCombatReach() / 2;
1222 
1223  float angle = pos1.GetAbsoluteAngle(pos2);
1224 
1225  // not using sqrt() for performance
1226  return (size * size) >= GetExactDist2dSq(pos1.GetPositionX() + std::cos(angle) * dist, pos1.GetPositionY() + std::sin(angle) * dist);
1227 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetExactDist2dSq(const float x, const float y) const
Definition: Position.h:98
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:107
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInBetween() [2/2]

bool WorldObject::IsInBetween ( WorldObject const *  obj1,
WorldObject const *  obj2,
float  size = 0 
) const
inline
521 { return obj1 && obj2 && IsInBetween(obj1->GetPosition(), obj2->GetPosition(), size); }
bool IsInBetween(Position const &pos1, Position const &pos2, float size=0) const
Definition: Object.cpp:1212
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInFront()

bool WorldObject::isInFront ( WorldObject const *  target,
float  arc = float(M_PI) 
) const
1230 {
1231  return HasInArc(arc, target);
1232 }
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInMap()

bool WorldObject::IsInMap ( WorldObject const *  obj) const
1024 {
1025  if (obj)
1026  return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap());
1027  return false;
1028 }
bool IsInWorld() const
Definition: Object.h:151
Map * GetMap() const
Definition: Object.h:555
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInPhase()

bool WorldObject::IsInPhase ( WorldObject const *  obj) const
inline
462  {
463  return GetPhaseShift().CanSee(obj->GetPhaseShift());
464  }
PhaseShift & GetPhaseShift()
Definition: Object.h:470
bool CanSee(PhaseShift const &other) const
Definition: PhaseShift.cpp:108
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInRange()

bool WorldObject::IsInRange ( WorldObject const *  obj,
float  minRange,
float  maxRange,
bool  is3D = true 
) const
1147 {
1148  float dx = GetPositionX() - obj->GetPositionX();
1149  float dy = GetPositionY() - obj->GetPositionY();
1150  float distsq = dx*dx + dy*dy;
1151  if (is3D)
1152  {
1153  float dz = GetPositionZ() - obj->GetPositionZ();
1154  distsq += dz*dz;
1155  }
1156 
1157  float sizefactor = GetCombatReach() + obj->GetCombatReach();
1158 
1159  // check only for real range
1160  if (minRange > 0.0f)
1161  {
1162  float mindist = minRange + sizefactor;
1163  if (distsq < mindist * mindist)
1164  return false;
1165  }
1166 
1167  float maxdist = maxRange + sizefactor;
1168  return distsq < maxdist * maxdist;
1169 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetPositionY() const
Definition: Position.h:78
float GetPositionZ() const
Definition: Position.h:79
float GetPositionX() const
Definition: Position.h:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInRange2d()

bool WorldObject::IsInRange2d ( float  x,
float  y,
float  minRange,
float  maxRange 
) const
1172 {
1173  float dx = GetPositionX() - x;
1174  float dy = GetPositionY() - y;
1175  float distsq = dx*dx + dy*dy;
1176 
1177  float sizefactor = GetCombatReach();
1178 
1179  // check only for real range
1180  if (minRange > 0.0f)
1181  {
1182  float mindist = minRange + sizefactor;
1183  if (distsq < mindist * mindist)
1184  return false;
1185  }
1186 
1187  float maxdist = maxRange + sizefactor;
1188  return distsq < maxdist * maxdist;
1189 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetPositionY() const
Definition: Position.h:78
float GetPositionX() const
Definition: Position.h:77
+ Here is the call graph for this function:

◆ IsInRange3d()

bool WorldObject::IsInRange3d ( float  x,
float  y,
float  z,
float  minRange,
float  maxRange 
) const
1192 {
1193  float dx = GetPositionX() - x;
1194  float dy = GetPositionY() - y;
1195  float dz = GetPositionZ() - z;
1196  float distsq = dx*dx + dy*dy + dz*dz;
1197 
1198  float sizefactor = GetCombatReach();
1199 
1200  // check only for real range
1201  if (minRange > 0.0f)
1202  {
1203  float mindist = minRange + sizefactor;
1204  if (distsq < mindist * mindist)
1205  return false;
1206  }
1207 
1208  float maxdist = maxRange + sizefactor;
1209  return distsq < maxdist * maxdist;
1210 }
virtual float GetCombatReach() const
Definition: Object.h:452
float GetPositionY() const
Definition: Position.h:78
float GetPositionZ() const
Definition: Position.h:79
float GetPositionX() const
Definition: Position.h:77
+ Here is the call graph for this function:

◆ IsInvisibleDueToDespawn()

virtual bool WorldObject::IsInvisibleDueToDespawn ( ) const
inlineprotectedvirtual

Reimplemented in Creature, and GameObject.

750 { return false; }
+ Here is the caller graph for this function:

◆ IsInWorldPvpZone()

bool WorldObject::IsInWorldPvpZone ( ) const
936 {
937  switch (GetZoneId())
938  {
939  case 4197: // Wintergrasp
940  case 5095: // Tol Barad
941  case 6941: // Ashran
942  return true;
943  break;
944  default:
945  return false;
946  break;
947  }
948 }
uint32 GetZoneId() const
Definition: Object.h:479
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isNeedNotify()

bool WorldObject::isNeedNotify ( uint16  f) const
inline
662 { return (m_notifyflags & f) != 0; }
uint16 m_notifyflags
Definition: Object.h:761
+ Here is the caller graph for this function:

◆ IsNeutralToAll()

bool WorldObject::IsNeutralToAll ( ) const
2718 {
2719  FactionTemplateEntry const* my_faction = GetFactionTemplateEntry();
2720  if (!my_faction->Faction)
2721  return true;
2722 
2723  FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->Faction);
2724  if (raw_faction && raw_faction->ReputationIndex >= 0)
2725  return false;
2726 
2727  return my_faction->IsNeutralToAll();
2728 }
int16 ReputationIndex
Definition: DB2Structure.h:1437
bool IsNeutralToAll() const
Definition: DB2Structure.h:1504
Definition: DB2Structure.h:1459
Definition: DB2Structure.h:1431
uint16 Faction
Definition: DB2Structure.h:1462
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Object.cpp:2532
DB2Storage< FactionEntry > sFactionStore("Faction.db2", FactionLoadInfo::Instance())
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsNeverVisibleFor()

virtual bool WorldObject::IsNeverVisibleFor ( WorldObject const *  ) const
inlineprotectedvirtual

Reimplemented in Player, GameObject, and AreaTrigger.

748 { return !IsInWorld() || IsDestroyedObject(); }
bool IsInWorld() const
Definition: Object.h:151
bool IsDestroyedObject() const
Definition: Object.h:192
+ Here is the caller graph for this function:

◆ IsOutdoors()

bool WorldObject::IsOutdoors ( ) const
inline
483 { return m_outdoors; }
bool m_outdoors
Definition: Object.h:738
+ Here is the caller graph for this function:

◆ IsPermanentWorldObject()

bool WorldObject::IsPermanentWorldObject ( ) const
inline
673 { return m_isWorldObject; }
bool const m_isWorldObject
Definition: Object.h:728
+ Here is the caller graph for this function:

◆ IsPrivateObject()

bool WorldObject::IsPrivateObject ( ) const
inline
713 { return !_privateObjectOwner.IsEmpty(); }
bool IsEmpty() const
Definition: ObjectGuid.h:310
ObjectGuid _privateObjectOwner
Definition: Object.h:763
+ Here is the caller graph for this function:

◆ IsSelfOrInSameMap()

bool WorldObject::IsSelfOrInSameMap ( WorldObject const *  obj) const
1017 {
1018  if (this == obj)
1019  return true;
1020  return IsInMap(obj);
1021 }
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1023
+ Here is the call graph for this function:

◆ IsValidAssistTarget()

bool WorldObject::IsValidAssistTarget ( WorldObject const *  target,
SpellInfo const *  bySpell = nullptr 
) const
3028 {
3029  ASSERT(target);
3030 
3031  // some negative spells can be casted at friendly target
3032  bool isNegativeSpell = bySpell && !bySpell->IsPositive();
3033 
3034  // can assist to self
3035  if (this == target)
3036  return true;
3037 
3038  // can't assist unattackable units
3039  Unit const* unitTarget = target->ToUnit();
3040  if (unitTarget && unitTarget->HasUnitState(UNIT_STATE_UNATTACKABLE))
3041  return false;
3042 
3043  // can't assist GMs
3044  if (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())
3045  return false;
3046 
3047  // can't assist own vehicle or passenger
3048  Unit const* unit = ToUnit();
3049  if (unit && unitTarget && unit->GetVehicle())
3050  {
3051  if (unit->IsOnVehicle(unitTarget))
3052  return false;
3053 
3054  if (unit->GetVehicleBase()->IsOnVehicle(unitTarget))
3055  return false;
3056  }
3057 
3058  // can't assist invisible
3059  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT)) && !CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea()))
3060  return false;
3061 
3062  // can't assist dead
3063  if ((!bySpell || !bySpell->IsAllowingDeadTarget()) && unitTarget && !unitTarget->IsAlive())
3064  return false;
3065 
3066  // can't assist untargetable
3067  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE_2))
3068  return false;
3069 
3070  if (unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_UNINTERACTIBLE))
3071  return false;
3072 
3073  // check flags for negative spells
3074  if (isNegativeSpell && unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_ON_TAXI | UNIT_FLAG_NOT_ATTACKABLE_1))
3075  return false;
3076 
3077  if (isNegativeSpell || !bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_ASSIST_IMMUNE_PC))
3078  {
3079  if (unit && unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
3080  {
3081  if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR8_ATTACK_IGNORE_IMMUNE_TO_PC_FLAG))
3082  if (unitTarget && unitTarget->IsImmuneToPC())
3083  return false;
3084  }
3085  else
3086  {
3087  if (unitTarget && unitTarget->IsImmuneToNPC())
3088  return false;
3089  }
3090  }
3091 
3092  // can't assist non-friendly targets
3093  if (GetReactionTo(target) < REP_NEUTRAL && target->GetReactionTo(this) < REP_NEUTRAL && (!ToCreature() || !(ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)))
3094  return false;
3095 
3096  // PvP case
3097  if (unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
3098  {
3099  if (unit && unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
3100  {
3101  Player const* selfPlayerOwner = GetAffectingPlayer();
3102  Player const* targetPlayerOwner = unitTarget->GetAffectingPlayer();
3103  if (selfPlayerOwner && targetPlayerOwner)
3104  {
3105  // can't assist player which is dueling someone
3106  if (selfPlayerOwner != targetPlayerOwner && targetPlayerOwner->duel)
3107  return false;
3108  }
3109  // can't assist player in ffa_pvp zone from outside
3110  if (unitTarget->IsFFAPvP() && !unit->IsFFAPvP())
3111  return false;
3112 
3113  // can't assist player out of sanctuary from sanctuary if has pvp enabled
3114  if (unitTarget->IsPvP())
3115  if (unit->IsInSanctuary() && !unitTarget->IsInSanctuary())
3116  return false;
3117  }
3118  }
3119  // PvC case - player can assist creature only if has specific type flags
3120  // !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) &&
3121  else if (unit && unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
3122  {
3123  if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_ASSIST_IMMUNE_PC))
3124  if (unitTarget && !unitTarget->IsPvP())
3125  if (Creature const* creatureTarget = target->ToCreature())
3126  return ((creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) || (creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST));
3127  }
3128 
3129  return true;
3130 }
bool IsPvP() const
Definition: Unit.h:987
Definition: SharedDefines.h:632
Definition: SharedDefines.h:653
Definition: UnitDefines.h:150
Unit * GetVehicleBase() const
Definition: Unit.cpp:11437
ReputationRank GetReactionTo(WorldObject const *target) const
Definition: Object.cpp:2560
Player * GetAffectingPlayer() const
Definition: Object.cpp:2137
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:207
Definition: Creature.h:69
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1418
Vehicle * GetVehicle() const
Definition: Unit.h:1801
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:948
Definition: SharedDefines.h:191
bool IsInSanctuary() const
Definition: Unit.h:986
Definition: UnitDefines.h:126
Definition: UnitDefines.h:132
Definition: UnitDefines.h:141
Definition: SharedDefines.h:642
bool IsAlive() const
Definition: Unit.h:1251
Definition: SharedDefines.h:4568
std::unique_ptr< DuelInfo > duel
Definition: Player.h:1956
bool HasUnitState(const uint32 f) const
Definition: Unit.h:850
bool IsImmuneToNPC() const
Definition: Unit.h:1145
Definition: UnitDefines.h:145
Definition: SharedDefines.h:4582
static Creature * ToCreature(Object *o)
Definition: Object.h:204
bool IsImmuneToPC() const
Definition: Unit.h:1142
Definition: UnitDefines.h:128
Definition: ObjectGuid.h:40
Creature * ToCreature()
Definition: Object.h:206
bool IsOnVehicle(Unit const *vehicle) const
Definition: Unit.cpp:11432
#define ASSERT
Definition: Errors.h:68
static Unit * ToUnit(Object *o)
Definition: Object.h:210
Definition: Unit.h:280
Definition: Unit.h:746
Definition: Player.h:1131
Unit * ToUnit()
Definition: Object.h:212
bool IsFFAPvP() const
Definition: Unit.h:988
uint32 type_flags
Definition: CreatureData.h:434
Definition: SharedDefines.h:734
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsValidAttackTarget()

bool WorldObject::IsValidAttackTarget ( WorldObject const *  target,
SpellInfo const *  bySpell = nullptr 
) const
2878 {
2879  ASSERT(target);
2880 
2881  // some positive spells can be casted at hostile target
2882  bool isPositiveSpell = bySpell && bySpell->IsPositive();
2883 
2884  // can't attack self (spells can, attribute check)
2885  if (!bySpell && this == target)
2886  return false;
2887 
2888  // can't attack unattackable units
2889  Unit const* unitTarget = target->ToUnit();
2890  if (unitTarget && unitTarget->HasUnitState(UNIT_STATE_UNATTACKABLE))
2891  return false;
2892 
2893  // can't attack GMs
2894  if (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())
2895  return false;
2896 
2897  Unit const* unit = ToUnit();
2898  // visibility checks (only units)
2899  if (unit)
2900  {
2901  // can't attack invisible
2902  if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_IGNORE_PHASE_SHIFT))
2903  {
2904  if (!unit->CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea()))
2905  return false;
2906  }
2907  }
2908 
2909  // can't attack dead
2910  if ((!bySpell || !bySpell->IsAllowingDeadTarget()) && unitTarget && !unitTarget->IsAlive())
2911  return false;
2912 
2913  // can't attack untargetable
2914  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE_2))
2915  return false;
2916 
2917  if (unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_UNINTERACTIBLE))
2918  return false;
2919 
2920  if (Player const* playerAttacker = ToPlayer())
2921  {
2922  if (playerAttacker->HasPlayerFlag(PLAYER_FLAGS_UBER))
2923  return false;
2924  }
2925 
2926  // check flags
2928  return false;
2929 
2930  Unit const* unitOrOwner = unit;
2931  GameObject const* go = ToGameObject();
2932  if (go && go->GetGoType() == GAMEOBJECT_TYPE_TRAP)
2933  unitOrOwner = go->GetOwner();
2934 
2935  // ignore immunity flags when assisting
2936  if (unitOrOwner && unitTarget && !(isPositiveSpell && bySpell->HasAttribute(SPELL_ATTR6_CAN_ASSIST_IMMUNE_PC)))
2937  {
2938  if (!unitOrOwner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitTarget->IsImmuneToNPC())
2939  return false;
2940 
2941  if (!unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitOrOwner->IsImmuneToNPC())
2942  return false;
2943 
2944  if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR8_ATTACK_IGNORE_IMMUNE_TO_PC_FLAG))
2945  {
2946  if (unitOrOwner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitTarget->IsImmuneToPC())
2947  return false;
2948 
2949  if (unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitOrOwner->IsImmuneToPC())
2950  return false;
2951  }
2952  }
2953 
2954  // CvC case - can attack each other only when one of them is hostile
2955  if (unit && !unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitTarget && !unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
2956  return IsHostileTo(unitTarget) || unitTarget->IsHostileTo(this);
2957 
2958  // Traps without owner or with NPC owner versus Creature case - can attack to creature only when one of them is hostile
2959  if (go && go->GetGoType() == GAMEOBJECT_TYPE_TRAP)
2960  {
2961  Unit const* goOwner = go->GetOwner();
2962  if (!goOwner || !goOwner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
2963  if (unitTarget && !unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED))
2964  return IsHostileTo(unitTarget) || unitTarget->IsHostileTo(this);
2965  }
2966 
2967  // PvP, PvC, CvP case
2968  // can't attack friendly targets
2969  if (IsFriendlyTo(target) || target->IsFriendlyTo(this))
2970  return false;
2971 
2972  Player const* playerAffectingAttacker = unit && unit->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) ? GetAffectingPlayer() : go ? GetAffectingPlayer() : nullptr;
2973  Player const* playerAffectingTarget = unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) ? unitTarget->GetAffectingPlayer() : nullptr;
2974 
2975  // Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar)
2976  if ((playerAffectingAttacker && !playerAffectingTarget) || (!playerAffectingAttacker && playerAffectingTarget))
2977  {
2978  Player const* player = playerAffectingAttacker ? playerAffectingAttacker : playerAffectingTarget;
2979 
2980  if (Unit const* creature = playerAffectingAttacker ? unitTarget : unit)
2981  {
2982  if (creature->IsContestedGuard() && player->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
2983  return true;
2984 
2985  if (FactionTemplateEntry const* factionTemplate = creature->GetFactionTemplateEntry())
2986  {
2987  if (!(player->GetReputationMgr().GetForcedRankIfAny(factionTemplate)))
2988  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->Faction))
2989  if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry))
2990  if (!repState->Flags.HasFlag(ReputationFlags::AtWar))
2991  return false;
2992 
2993  }
2994  }
2995  }
2996 
2997  Creature const* creatureAttacker = ToCreature();
2998  if (creatureAttacker && (creatureAttacker->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT))
2999  return false;
3000 
3001  if (playerAffectingAttacker && playerAffectingTarget)
3002  if (playerAffectingAttacker->duel && playerAffectingAttacker->duel->Opponent == playerAffectingTarget && playerAffectingAttacker->duel->State == DUEL_STATE_IN_PROGRESS)
3003  return true;
3004 
3005  // PvP case - can't attack when attacker or target are in sanctuary
3006  // however, 13850 client doesn't allow to attack when one of the unit's has sanctuary flag and is pvp
3007  if (unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && unitOrOwner && unitOrOwner->HasUnitFlag(UNIT_FLAG_PLAYER_CONTROLLED) && (unitTarget->IsInSanctuary() || unitOrOwner->IsInSanctuary()))
3008  return false;
3009 
3010  // additional checks - only PvP case
3011  if (playerAffectingAttacker && playerAffectingTarget)
3012  {
3013  if (playerAffectingTarget->IsPvP() || (bySpell && bySpell->HasAttribute(SPELL_ATTR5_IGNORE_AREA_EFFECT_PVP_CHECK)))
3014  return true;
3015 
3016  if (playerAffectingAttacker->IsFFAPvP() && playerAffectingTarget->IsFFAPvP())
3017  return true;
3018 
3019  return playerAffectingAttacker->HasPvpFlag(UNIT_BYTE2_FLAG_UNK1) ||
3020  playerAffectingTarget->HasPvpFlag(UNIT_BYTE2_FLAG_UNK1);
3021  }
3022 
3023  return true;
3024 }
bool IsPvP() const
Definition: Unit.h:987
Definition: Player.h:461
Definition: SharedDefines.h:632
ReputationRank const * GetForcedRankIfAny(FactionTemplateEntry const *factionTemplateEntry) const
Definition: ReputationMgr.cpp:215
Definition: SharedDefines.h:653
Definition: UnitDefines.h:85
Definition: UnitDefines.h:150
Definition: SharedDefines.h:598
Player * GetAffectingPlayer() const
Definition: Object.cpp:2137
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:207
Definition: Creature.h:69
bool HasPlayerFlag(PlayerFlags flags) const
Definition: Player.h:2706
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1418
GameObject * ToGameObject()
Definition: Object.h:218
FactionState const * GetState(FactionEntry const *factionEntry) const
Definition: ReputationMgr.cpp:86
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:948
bool IsInSanctuary() const
Definition: Unit.h:986
Player * ToPlayer()
Definition: Object.h:200
Definition: UnitDefines.h:126
bool HasPvpFlag(UnitPVPStateFlags flags) const
Definition: Unit.h:981
Definition: Player.h:384
Definition: UnitDefines.h:132
Definition: UnitDefines.h:141
Definition: SharedDefines.h:642
Unit * GetOwner() const
Definition: Object.cpp:2105
GameobjectTypes GetGoType() const
Definition: GameObject.h:237
bool IsAlive() const
Definition: Unit.h:1251
std::unique_ptr< DuelInfo > duel
Definition: Player.h:1956
bool HasUnitState(const uint32 f) const
Definition: Unit.h:850
bool IsImmuneToNPC() const
Definition: Unit.h:1145
Definition: UnitDefines.h:145
Definition: SharedDefines.h:4582
Definition: GameObject.h:125
Definition: DB2Structure.h:1459
ReputationMgr & GetReputationMgr()
Definition: Player.h:2230
Definition: DB2Structure.h:1431
bool IsFriendlyTo(WorldObject const *target) const
Definition: Object.cpp:2699
bool IsImmuneToPC() const
Definition: Unit.h:1142
Definition: UnitDefines.h:128
Definition: ObjectGuid.h:40
Creature * ToCreature()
Definition: Object.h:206
DB2Storage< FactionEntry > sFactionStore("Faction.db2", FactionLoadInfo::Instance())
#define ASSERT
Definition: Errors.h:68
static Unit * ToUnit(Object *o)
Definition: Object.h:210
bool IsHostileTo(WorldObject const *target) const
Definition: Object.cpp:2694
Definition: Player.h:472
Definition: Unit.h:280
Definition: Unit.h:746
Definition: Player.h:1131
Definition: SharedDefines.h:2738
Definition: ReputationMgr.h:52
Unit * ToUnit()
Definition: Object.h:212
bool IsFFAPvP() const
Definition: Unit.h:988
uint32 type_flags
Definition: CreatureData.h:434
Definition: SharedDefines.h:734
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsVisibilityOverridden()

bool WorldObject::IsVisibilityOverridden ( ) const
inline
670 { return m_visibilityDistanceOverride.has_value(); }
Optional< float > m_visibilityDistanceOverride
Definition: Object.h:727
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsWithinDist()

bool WorldObject::IsWithinDist ( WorldObject const *  obj,
float  dist2compare,
bool  is3D = true 
) const
1051 {
1052  return obj && _IsWithinDist(obj, dist2compare, is3D);
1053 }
virtual bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:964
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsWithinDist2d() [1/2]

bool WorldObject::IsWithinDist2d ( float  x,
float  y,
float  dist 
) const
1041 {
1042  return IsInDist2d(x, y, dist + GetCombatReach());
1043 }
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:141
virtual float GetCombatReach() const
Definition: Object.h:452
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsWithinDist2d() [2/2]

bool WorldObject::IsWithinDist2d ( Position const *  pos,
float  dist 
) const
1046 {
1047  return IsInDist2d(pos, dist + GetCombatReach());
1048 }
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:141
virtual float GetCombatReach() const
Definition: Object.h:452
+ Here is the call graph for this function:

◆ IsWithinDist3d() [1/2]

bool WorldObject::IsWithinDist3d ( float  x,
float  y,
float  z,
float  dist 
) const
1031 {
1032  return IsInDist(x, y, z, dist + GetCombatReach());
1033 }
bool IsInDist(float x, float y, float z, float dist) const
Definition: Position.h:144
virtual float GetCombatReach() const
Definition: Object.h:452
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsWithinDist3d() [2/2]

bool WorldObject::IsWithinDist3d ( Position const *  pos,
float  dist 
) const
1036 {
1037  return IsInDist(pos, dist + GetCombatReach());
1038 }
bool IsInDist(float x, float y, float z, float dist) const
Definition: Position.h:144
virtual float GetCombatReach() const
Definition: Object.h:452
+ Here is the call graph for this function:

◆ IsWithinDistInMap()

bool WorldObject::IsWithinDistInMap ( WorldObject const *  obj,
float  dist2compare,
bool  is3D = true,
bool  incOwnRadius = true,
bool  incTargetRadius = true 
) const
1056 {
1057  return obj && IsInMap(obj) && IsInPhase(obj) && _IsWithinDist(obj, dist2compare, is3D, incOwnRadius, incTargetRadius);
1058 }
bool IsInPhase(WorldObject const *obj) const
Definition: Object.h:461
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1023
virtual bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:964
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsWithinLOS()

bool WorldObject::IsWithinLOS ( float  x,
float  y,
float  z,
LineOfSightChecks  checks = LINEOFSIGHT_ALL_CHECKS,
VMAP::ModelIgnoreFlags  ignoreFlags = VMAP::ModelIgnoreFlags::Nothing 
) const
1070 {
1071  if (IsInWorld())
1072  {
1073  oz += GetCollisionHeight();
1074  float x, y, z;
1075  if (GetTypeId() == TYPEID_PLAYER)
1076  {
1077  GetPosition(x, y, z);
1078  z += GetCollisionHeight();
1079  }
1080  else
1081  GetHitSpherePointFor({ ox, oy, oz }, x, y, z);
1082 
1083  return GetMap()->isInLineOfSight(GetPhaseShift(), x, y, z, ox, oy, oz, checks, ignoreFlags);
1084  }
1085 
1086  return true;
1087 }
TypeID GetTypeId() const
Definition: Object.h:170
Position GetPosition() const
Definition: Position.h:85
virtual float GetCollisionHeight() const
Definition: Object.h:698
bool IsInWorld() const
Definition: Object.h:151
Map * GetMap() const
Definition: Object.h:555
PhaseShift & GetPhaseShift()
Definition: Object.h:470
bool isInLineOfSight(PhaseShift const &phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
Definition: Map.cpp:3018
Definition: ObjectGuid.h:40
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1060
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsWithinLOSInMap()

bool WorldObject::IsWithinLOSInMap ( WorldObject const *  obj,
LineOfSightChecks  checks = LINEOFSIGHT_ALL_CHECKS,
VMAP::ModelIgnoreFlags  ignoreFlags = VMAP::ModelIgnoreFlags::Nothing 
) const
1090 {
1091  if (!IsInMap(obj))
1092  return false;
1093 
1094  float ox, oy, oz;
1095  if (obj->GetTypeId() == TYPEID_PLAYER)
1096  {
1097  obj->GetPosition(ox, oy, oz);
1098  oz += GetCollisionHeight();
1099  }
1100  else
1101  obj->GetHitSpherePointFor({ GetPositionX(), GetPositionY(), GetPositionZ() + GetCollisionHeight() }, ox, oy, oz);
1102 
1103  float x, y, z;
1104  if (GetTypeId() == TYPEID_PLAYER)
1105  {
1106  GetPosition(x, y, z);
1107  z += GetCollisionHeight();
1108  }
1109  else
1110  GetHitSpherePointFor({ obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ() + obj->GetCollisionHeight() }, x, y, z);
1111 
1112  return GetMap()->isInLineOfSight(GetPhaseShift(), x, y, z, ox, oy, oz, checks, ignoreFlags);
1113 }
TypeID GetTypeId() const
Definition: Object.h:170
Position GetPosition() const
Definition: Position.h:85
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1023
virtual float GetCollisionHeight() const
Definition: Object.h:698
float GetPositionY() const
Definition: Position.h:78
Map * GetMap() const
Definition: Object.h:555
PhaseShift & GetPhaseShift()
Definition: Object.h:470
float GetPositionZ() const
Definition: Position.h:79
bool isInLineOfSight(PhaseShift const &phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
Definition: Map.cpp:3018
float GetPositionX() const
Definition: Position.h:77
Definition: ObjectGuid.h:40
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1060
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsWorldObject()

bool WorldObject::IsWorldObject ( ) const
842 {
843  if (m_isWorldObject)
844  return true;
845 
846  if (ToCreature() && ToCreature()->m_isTempWorldObject)
847  return true;
848 
849  return false;
850 }
Creature * ToCreature()
Definition: Object.h:206
bool const m_isWorldObject
Definition: Object.h:728
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MagicSpellHitResult()

SpellMissInfo WorldObject::MagicSpellHitResult ( Unit victim,
SpellInfo const *  spellInfo 
) const
2379 {
2380  // Can`t miss on dead target (on skinning for example)
2381  if (!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER)
2382  return SPELL_MISS_NONE;
2383 
2384  if (spellInfo->HasAttribute(SPELL_ATTR3_NO_AVOIDANCE))
2385  return SPELL_MISS_NONE;
2386 
2387  float missChance = [&]()
2388  {
2389  if (spellInfo->HasAttribute(SPELL_ATTR7_NO_ATTACK_MISS))
2390  return 0.0f;
2391 
2392  SpellSchoolMask schoolMask = spellInfo->GetSchoolMask();
2393  // PvP - PvE spell misschances per leveldif > 2
2394  int32 lchance = victim->GetTypeId() == TYPEID_PLAYER ? 7 : 11;
2395  int32 thisLevel = GetLevelForTarget(victim);
2396  if (GetTypeId() == TYPEID_UNIT && ToCreature()->IsTrigger())
2397  thisLevel = std::max<int32>(thisLevel, spellInfo->SpellLevel);
2398  int32 leveldif = int32(victim->GetLevelForTarget(this)) - thisLevel;
2399  int32 levelBasedHitDiff = leveldif;
2400 
2401  // Base hit chance from attacker and victim levels
2402  int32 modHitChance = 100;
2403  if (levelBasedHitDiff >= 0)
2404  {
2405  if (victim->GetTypeId() != TYPEID_PLAYER)
2406  {
2407  modHitChance = 94 - 3 * std::min(levelBasedHitDiff, 3);
2408  levelBasedHitDiff -= 3;
2409  }
2410  else
2411  {
2412  modHitChance = 96 - std::min(levelBasedHitDiff, 2);
2413  levelBasedHitDiff -= 2;
2414  }
2415  if (levelBasedHitDiff > 0)
2416  modHitChance -= lchance * std::min(levelBasedHitDiff, 7);
2417  }
2418  else
2419  modHitChance = 97 - levelBasedHitDiff;
2420 
2421  // Spellmod from SpellModOp::HitChance
2422  if (Player* modOwner = GetSpellModOwner())
2423  modOwner->ApplySpellMod(spellInfo, SpellModOp::HitChance, modHitChance);
2424 
2425  // Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will ignore target's avoidance effects
2426  if (!spellInfo->HasAttribute(SPELL_ATTR3_ALWAYS_HIT))
2427  {
2428  // Chance hit from victim SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE auras
2429  modHitChance += victim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask);
2430  }
2431 
2432  float HitChance = modHitChance;
2433  // Increase hit chance from attacker SPELL_AURA_MOD_SPELL_HIT_CHANCE and attacker ratings
2434  if (Unit const* unit = ToUnit())
2435  HitChance += unit->m_modSpellHitChance;
2436 
2437  RoundToInterval(HitChance, 0.0f, 100.0f);
2438 
2439  return 100.0f - HitChance;
2440  }();
2441 
2442  int32 tmp = int32(missChance * 100.0f);
2443 
2444  int32 rand = irand(0, 9999);
2445  if (tmp > 0 && rand < tmp)
2446  return SPELL_MISS_MISS;
2447 
2448  // Chance resist mechanic (select max value from every mechanic spell effect)
2449  int32 resist_chance = victim->GetMechanicResistChance(spellInfo) * 100;
2450 
2451  // Roll chance
2452  if (resist_chance > 0 && rand < (tmp += resist_chance))
2453  return SPELL_MISS_RESIST;
2454 
2455  // cast by caster in front of victim
2456  if (!victim->HasUnitState(UNIT_STATE_CONTROLLED) && (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)))
2457  {
2458  int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100;
2459  if (deflect_chance > 0 && rand < (tmp += deflect_chance))
2460  return SPELL_MISS_DEFLECT;
2461  }
2462 
2463  return SPELL_MISS_NONE;
2464 }
TypeID GetTypeId() const
Definition: Object.h:170
T RoundToInterval(T &num, T floor, T ceil)
Definition: Util.h:92
Definition: SharedDefines.h:536
Definition: SharedDefines.h:691
virtual uint8 GetLevelForTarget(WorldObject const *) const
Definition: Object.h:531
Definition: ObjectGuid.h:39
Definition: SharedDefines.h:2687
Definition: SpellAuraDefines.h:382
#define M_PI
Definition: Common.h:157
int32 GetTotalAuraModifierByMiscMask(AuraType auraType, uint32 misc_mask) const
Definition: Unit.cpp:4805
SpellSchoolMask
Definition: SharedDefines.h:310
bool HasInArc(float arcangle, Position const *pos, float border=2.0f) const
Definition: Position.cpp:99
Definition: SharedDefines.h:2688
bool IsAlive() const
Definition: Unit.h:1251
bool HasUnitState(const uint32 f) const
Definition: Unit.h:850
int32 GetTotalAuraModifier(AuraType auraType) const
Definition: Unit.cpp:4785
int32_t int32
Definition: Define.h:139
Definition: SpellAuraDefines.h:280
Definition: SharedDefines.h:2695
int32 GetMechanicResistChance(SpellInfo const *spellInfo) const
Definition: Unit.cpp:2352
Definition: SharedDefines.h:2686
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4530
Definition: SharedDefines.h:524
Definition: ObjectGuid.h:40
Creature * ToCreature()
Definition: Object.h:206
uint8 GetLevelForTarget(WorldObject const *) const override
Definition: Unit.h:864