TrinityCore
WorldObject Class Referenceabstract

#include <Object.h>

Public Member Functions

virtual ~WorldObject ()
 
virtual void Update (uint32)
 
void AddToWorld () override
 
void RemoveFromWorld () override
 
void GetNearPoint2D (float &x, float &y, float distance, float absAngle) const
 
void GetNearPoint (WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
 
void GetClosePoint (float &x, float &y, float &z, float size, float distance2d=0, float angle=0) const
 
void MovePosition (Position &pos, float dist, float angle)
 
Position GetNearPosition (float dist, float angle)
 
void MovePositionToFirstCollision (Position &pos, float dist, float angle)
 
Position GetFirstCollisionPosition (float dist, float angle)
 
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) 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 IsOutdoors () const
 
bool IsInWorldPvpZone () 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)
 
virtual void SaveRespawnTime (uint32=0, bool=true)
 
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 ()
 
ZoneScriptGetZoneScript () const
 
ScenarioGetScenario () const
 
TempSummonSummonCreature (uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
 
TempSummonSummonCreature (uint32 entry, Position const &pos, TempSummonType despawnType, Milliseconds const &despawnTime, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
 
TempSummonSummonCreature (uint32 entry, float x, float y, float z, float o=0, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
 
GameObjectSummonGameObject (uint32 entry, Position const &pos, QuaternionData const &rot, uint32 respawnTime, GOSummonType summonType=GO_SUMMON_TIMED_OR_CORPSE_DESPAWN)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, QuaternionData const &rot, uint32 respawnTime)
 
CreatureSummonTrigger (float x, float y, float z, float ang, uint32 dur, 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) 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
 
void CastSpell (SpellCastTargets const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
 
void CastSpell (WorldObject *target, uint32 spellId, CastSpellExtraArgs const &args={ })
 
void CastSpell (Position const &dest, uint32 spellId, CastSpellExtraArgs const &args={ })
 
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) const
 
void DestroyForNearbyPlayers ()
 
virtual void UpdateObjectVisibility (bool forced=true)
 
virtual void UpdateObjectVisibilityOnCreate ()
 
void UpdatePositionData ()
 
void BuildUpdate (UpdateDataMapType &) override
 
void 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
 
TransportGetTransport () 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 (Transport *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
 
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
 
- 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 AddDynamicFlag (uint32 flag)
 
void RemoveDynamicFlag (uint32 flag)
 
void SetDynamicFlags (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
 
virtual void ClearUpdateMask (bool remove)
 
virtual bool hasQuest (uint32) const
 
virtual bool hasInvolvedQuest (uint32) const
 
void SetIsNewObject (bool enable)
 
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 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
 
- 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 orientation)
 
void Relocate (Position const &pos)
 
void Relocate (Position const *pos)
 
void RelocateOffset (Position const &offset)
 
void SetOrientation (float orientation)
 
float GetPositionX () const
 
float GetPositionY () const
 
float GetPositionZ () const
 
float GetOrientation () const
 
void GetPosition (float &x, float &y) const
 
void GetPosition (float &x, float &y, float &z) const
 
void GetPosition (float &x, float &y, float &z, float &o) const
 
Position GetPosition () const
 
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 GetExactDist2d (const float x, const float y) const
 
float GetExactDist2dSq (Position const &pos) const
 
float GetExactDist2d (Position const &pos) const
 
float GetExactDist2dSq (Position const *pos) const
 
float GetExactDist2d (Position const *pos) const
 
float GetExactDistSq (float x, float y, float z) const
 
float GetExactDist (float x, float y, float z) const
 
float GetExactDistSq (Position const &pos) const
 
float GetExactDist (Position const &pos) const
 
float GetExactDistSq (Position const *pos) const
 
float GetExactDist (Position const *pos) const
 
void GetPositionOffsetTo (Position const &endPos, Position &retOffset) const
 
Position GetPositionWithOffset (Position const &offset) const
 
float GetAngle (Position const *pos) const
 
float GetAngle (Position const &pos) const
 
float GetAngle (float x, float y) const
 
float GetRelativeAngle (Position const *pos) const
 
float GetRelativeAngle (float x, float y) const
 
void GetSinCos (float x, float y, float &vsin, float &vcos) const
 
bool IsInDist2d (float x, float y, float dist) const
 
bool IsInDist2d (Position const *pos, float dist) const
 
bool IsInDist (float x, float y, float z, float dist) const
 
bool IsInDist (Position const &pos, float dist) const
 
bool 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, Optional< float > orientation=Optional< float >()) const
 
bool HasInLine (Position const *pos, float objSize, float width, Optional< float > orientation=Optional< float >()) 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 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 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) 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
 
Transportm_transport
 
uint32 m_zoneId
 
uint32 m_areaId
 
float m_staticFloorZ
 
bool m_outdoors
 
- 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
 
bool CanNeverSee (WorldObject const *obj) const
 
virtual bool CanAlwaysSee (WorldObject const *) const
 
bool CanDetect (WorldObject const *obj, bool ignoreStealth, bool checkAlert=false) const
 
bool CanDetectInvisibilityOf (WorldObject const *obj) const
 
bool CanDetectStealthOf (WorldObject const *obj, bool checkAlert=false) const
 

Private Attributes

Mapm_currMap
 
uint32 m_InstanceId
 
PhaseShift _phaseShift
 
PhaseShift _suppressedPhaseShift
 
int32 _dbPhase
 
uint16 m_notifyflags
 
ObjectGuid _privateObjectOwner
 

Constructor & Destructor Documentation

◆ WorldObject()

WorldObject::WorldObject ( bool  isWorldObject)
explicitprotected
855 m_movementInfo(), m_name(), m_isActive(false), m_isFarVisible(false), m_isWorldObject(isWorldObject), m_zoneScript(nullptr),
857 _dbPhase(0), m_notifyflags(0)
858 {
861 }
Map * m_currMap
Definition: Object.h:713
#define VMAP_INVALID_HEIGHT
Definition: IVMapManager.h:50
MovementInfo m_movementInfo
Definition: Object.h:658
std::string m_name
Definition: Object.h:685
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:530
void SetValue(FLAG_TYPE flag, T_VALUES value)
Definition: Object.h:402
float m_staticFloorZ
Definition: Object.h:698
bool m_isFarVisible
Definition: Object.h:687
uint32 m_InstanceId
Definition: Object.h:715
Definition: SharedDefines.h:2295
uint16 m_notifyflags
Definition: Object.h:720
Definition: SharedDefines.h:2296
int32 _dbPhase
Definition: Object.h:718
WorldLocation(uint32 mapId=MAPID_INVALID, float x=0.f, float y=0.f, float z=0.f, float o=0.f)
Definition: Position.h:232
ZoneScript * m_zoneScript
Definition: Object.h:690
bool m_isActive
Definition: Object.h:686
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:531
Transport * m_transport
Definition: Object.h:693
uint32 m_zoneId
Definition: Object.h:696
Object()
Definition: Object.cpp:65
Definition: SharedDefines.h:2288
uint32 m_areaId
Definition: Object.h:697
bool const m_isWorldObject
Definition: Object.h:689
uint32 LastUsedScriptID
Definition: Object.h:644
+ Here is the call graph for this function:

◆ ~WorldObject()

WorldObject::~WorldObject ( )
virtual
77 {
78  // this may happen because there are many !create/delete
79  if (IsWorldObject() && m_currMap)
80  {
81  if (GetTypeId() == TYPEID_CORPSE)
82  {
83  TC_LOG_FATAL("misc", "WorldObject::~WorldObject Corpse Type: %d (%s) deleted but still in map!!",
84  ToCorpse()->GetType(), GetGUID().ToString().c_str());
85  ABORT();
86  }
87  ResetMap();
88  }
89 }
virtual void ResetMap()
Definition: Object.cpp:1712
Map * m_currMap
Definition: Object.h:713
bool IsWorldObject() const
Definition: Object.cpp:871
TypeID GetTypeId() const
Definition: Object.h:167
Definition: ObjectGuid.h:44
ObjectGuid const & GetGUID() const
Definition: Object.h:154
#define TC_LOG_FATAL(filterType__,...)
Definition: Log.h:189
Corpse * ToCorpse()
Definition: Object.h:208
#define ABORT
Definition: Errors.h:60
std::string ToString() const
Definition: Position.cpp:189
+ 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.

1004 {
1005  float sizefactor = 0;
1006  sizefactor += incOwnRadius ? GetCombatReach() : 0.0f;
1007  sizefactor += incTargetRadius ? obj->GetCombatReach() : 0.0f;
1008  float maxdist = dist2compare + sizefactor;
1009 
1010  Position const* thisOrTransport = this;
1011  Position const* objOrObjTransport = obj;
1012 
1013  if (GetTransport() && obj->GetTransport() && obj->GetTransport()->GetGUID() == GetTransport()->GetGUID())
1014  {
1015  thisOrTransport = &m_movementInfo.transport.pos;
1016  objOrObjTransport = &obj->m_movementInfo.transport.pos;
1017  }
1018 
1019  if (is3D)
1020  return thisOrTransport->IsInDist(objOrObjTransport, maxdist);
1021  else
1022  return thisOrTransport->IsInDist2d(objOrObjTransport, maxdist);
1023 }
bool IsInDist(float x, float y, float z, float dist) const
Definition: Position.h:209
Transport * GetTransport() const
Definition: Object.h:647
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:199
MovementInfo m_movementInfo
Definition: Object.h:658
virtual float GetCombatReach() const
Definition: Object.h:432
struct MovementInfo::TransportInfo transport
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Position pos
Definition: MovementInfo.h:49
Definition: Position.h:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddObjectToRemoveList()

void WorldObject::AddObjectToRemoveList ( )
1725 {
1726  Map* map = FindMap();
1727  if (!map)
1728  {
1729  TC_LOG_ERROR("misc", "Object (Entry: %u %s) at attempt add to move list not have valid map (Id: %u).", GetEntry(), GetGUID().ToString().c_str(), GetMapId());
1730  return;
1731  }
1732 
1733  map->AddObjectToRemoveList(this);
1734 }
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
void AddObjectToRemoveList(WorldObject *obj)
Definition: Map.cpp:3581
ObjectGuid const & GetGUID() const
Definition: Object.h:154
Definition: Map.h:248
Map * FindMap() const
Definition: Object.h:536
uint32 GetEntry() const
Definition: Object.h:155
uint32 GetMapId() const
Definition: Position.h:252
std::string ToString() const
Definition: Position.cpp:189
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddToNotify()

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

◆ AddToObjectUpdate()

void WorldObject::AddToObjectUpdate ( )
overridevirtual

Implements Object.

3301 {
3302  GetMap()->AddUpdateObject(this);
3303 }
Map * GetMap() const
Definition: Object.h:535
void AddUpdateObject(Object *obj)
Definition: Map.h:568
+ Here is the call graph for this function:

◆ AddToWorld()

void WorldObject::AddToWorld ( )
overridevirtual

Reimplemented from Object.

Reimplemented in Player, Unit, and Pet.

959 {
962 }
PhaseShift _phaseShift
Definition: Object.h:716
float GetPositionY() const
Definition: Position.h:102
Map * GetMap() const
Definition: Object.h:535
float GetPositionZ() const
Definition: Position.h:103
uint32 m_zoneId
Definition: Object.h:696
virtual void AddToWorld()
Definition: Object.cpp:114
float GetPositionX() const
Definition: Position.h:101
void GetZoneAndAreaId(PhaseShift const &phaseShift, uint32 &zoneid, uint32 &areaid, float x, float y, float z)
Definition: Map.cpp:2676
uint32 m_areaId
Definition: Object.h:697
+ 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
2135 {
2136  if (Player* modOwner = GetSpellModOwner())
2137  {
2138  modOwner->ApplySpellMod(spellInfo, SpellModOp::Points, value);
2139  switch (effIndex)
2140  {
2141  case EFFECT_0:
2142  modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex0, value);
2143  break;
2144  case EFFECT_1:
2145  modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex1, value);
2146  break;
2147  case EFFECT_2:
2148  modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex2, value);
2149  break;
2150  case EFFECT_3:
2151  modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex3, value);
2152  break;
2153  case EFFECT_4:
2154  modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex4, value);
2155  break;
2156  }
2157  }
2158  return value;
2159 }
Definition: SharedDefines.h:30
Definition: SharedDefines.h:32
Definition: SharedDefines.h:28
Definition: SharedDefines.h:29
Player * GetSpellModOwner() const
Definition: Object.cpp:2073
Definition: SharedDefines.h:31
Definition: Player.h:1056
+ 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.

3292 {
3293  WorldObjectChangeAccumulator notifier(*this, data_map);
3294  //we must build packets for all visible players
3295  Cell::VisitWorldObjects(this, notifier, GetVisibilityRange());
3296 
3297  ClearUpdateMask(false);
3298 }
virtual void ClearUpdateMask(bool remove)
Definition: Object.cpp:793
Definition: Object.cpp:3221
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:193
float GetVisibilityRange() const
Definition: Object.cpp:1376
+ Here is the call graph for this function:

◆ CalcSpellDuration()

int32 WorldObject::CalcSpellDuration ( SpellInfo const *  spellInfo) const
2162 {
2163  uint8 comboPoints = 0;
2164  if (Unit const* unit = ToUnit())
2165  comboPoints = unit->GetPower(POWER_COMBO_POINTS);
2166 
2167  int32 minduration = spellInfo->GetDuration();
2168  int32 maxduration = spellInfo->GetMaxDuration();
2169 
2170  int32 duration;
2171  if (comboPoints && minduration != -1 && minduration != maxduration)
2172  duration = minduration + int32((maxduration - minduration) * comboPoints / 5);
2173  else
2174  duration = minduration;
2175 
2176  return duration;
2177 }
Definition: SharedDefines.h:269
int32_t int32
Definition: Define.h:148
uint8_t uint8
Definition: Define.h:154
Definition: Unit.h:736
Unit * ToUnit()
Definition: Object.h:200
+ 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
2099 {
2100  if (variance)
2101  *variance = 0.0f;
2102 
2103  return spellEffectInfo.CalcValue(this, basePoints, target, variance, castItemId, itemLevel);
2104 }
+ 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.

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

◆ CanDetect()

bool WorldObject::CanDetect ( WorldObject const *  obj,
bool  ignoreStealth,
bool  checkAlert = false 
) const
private
1530 {
1531  WorldObject const* seer = this;
1532 
1533  // Pets don't have detection, they use the detection of their masters
1534  if (Unit const* thisUnit = ToUnit())
1535  if (Unit* controller = thisUnit->GetCharmerOrOwner())
1536  seer = controller;
1537 
1538  if (obj->IsAlwaysDetectableFor(seer))
1539  return true;
1540 
1541  if (!ignoreStealth && !seer->CanDetectInvisibilityOf(obj))
1542  return false;
1543 
1544  if (!ignoreStealth && !seer->CanDetectStealthOf(obj, checkAlert))
1545  return false;
1546 
1547  return true;
1548 }
bool CanDetectInvisibilityOf(WorldObject const *obj) const
Definition: Object.cpp:1550
Definition: Object.h:410
bool CanDetectStealthOf(WorldObject const *obj, bool checkAlert=false) const
Definition: Object.cpp:1574
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:5795
Definition: Unit.h:736
Unit * ToUnit()
Definition: Object.h:200
+ 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
1551 {
1552  uint32 mask = obj->m_invisibility.GetFlags() & m_invisibilityDetect.GetFlags();
1553 
1554  // Check for not detected types
1555  if (mask != obj->m_invisibility.GetFlags())
1556  return false;
1557 
1558  for (uint32 i = 0; i < TOTAL_INVISIBILITY_TYPES; ++i)
1559  {
1560  if (!(mask & (1 << i)))
1561  continue;
1562 
1563  int32 objInvisibilityValue = obj->m_invisibility.GetValue(InvisibilityType(i));
1564  int32 ownInvisibilityDetectValue = m_invisibilityDetect.GetValue(InvisibilityType(i));
1565 
1566  // Too low value to detect
1567  if (ownInvisibilityDetectValue < objInvisibilityValue)
1568  return false;
1569  }
1570 
1571  return true;
1572 }
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:401
FlaggedValuesArray32< int32, uint32, InvisibilityType, TOTAL_INVISIBILITY_TYPES > m_invisibilityDetect
Definition: Object.h:528
InvisibilityType
Definition: SharedDefines.h:2241
int32_t int32
Definition: Define.h:148
uint32_t uint32
Definition: Define.h:152
Definition: SharedDefines.h:2282
T_FLAGS GetFlags() const
Definition: Object.h:396
+ 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
1575 {
1576  // Combat reach is the minimal distance (both in front and behind),
1577  // and it is also used in the range calculation.
1578  // One stealth point increases the visibility range by 0.3 yard.
1579 
1580  if (!obj->m_stealth.GetFlags())
1581  return true;
1582 
1583  float distance = GetExactDist(obj);
1584  float combatReach = 0.0f;
1585 
1586  Unit const* unit = ToUnit();
1587  if (unit)
1588  combatReach = unit->GetCombatReach();
1589 
1590  if (distance < combatReach)
1591  return true;
1592 
1593  if (!HasInArc(float(M_PI), obj))
1594  return false;
1595 
1596  GameObject const* go = obj->ToGameObject();
1597  for (uint32 i = 0; i < TOTAL_STEALTH_TYPES; ++i)
1598  {
1599  if (!(obj->m_stealth.GetFlags() & (1 << i)))
1600  continue;
1601 
1603  return true;
1604 
1605  // Starting points
1606  int32 detectionValue = 30;
1607 
1608  // Level difference: 5 point / level, starting from level 1.
1609  // There may be spells for this and the starting points too, but
1610  // not in the DBCs of the client.
1611  detectionValue += int32(GetLevelForTarget(obj) - 1) * 5;
1612 
1613  // Apply modifiers
1614  detectionValue += m_stealthDetect.GetValue(StealthType(i));
1615  if (go)
1616  if (Unit* owner = go->GetOwner())
1617  detectionValue -= int32(owner->GetLevelForTarget(this) - 1) * 5;
1618 
1619  detectionValue -= obj->m_stealth.GetValue(StealthType(i));
1620 
1621  // Calculate max distance
1622  float visibilityRange = float(detectionValue) * 0.3f + combatReach;
1623 
1624  // If this unit is an NPC then player detect range doesn't apply
1625  if (unit && unit->GetTypeId() == TYPEID_PLAYER && visibilityRange > MAX_PLAYER_STEALTH_DETECT_RANGE)
1626  visibilityRange = MAX_PLAYER_STEALTH_DETECT_RANGE;
1627 
1628  // When checking for alert state, look 8% further, and then 1.5 yards more than that.
1629  if (checkAlert)
1630  visibilityRange += (visibilityRange * 0.08f) + 1.5f;
1631 
1632  // If checking for alert, and creature's visibility range is greater than aggro distance, No alert
1633  Unit const* tunit = obj->ToUnit();
1634  if (checkAlert && unit && unit->ToCreature() && visibilityRange >= unit->ToCreature()->GetAttackDistance(tunit) + unit->ToCreature()->m_CombatDistance)
1635  return false;
1636 
1637  if (distance > visibilityRange)
1638  return false;
1639  }
1640 
1641  return true;
1642 }
float GetCombatReach() const override
Definition: Unit.h:791
Definition: SpellAuraDefines.h:316
TypeID GetTypeId() const
Definition: Object.h:167
float GetAttackDistance(Unit const *player) const
Definition: Creature.cpp:2044
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:401
bool HasInArc(float arcangle, Position const *pos, float border=2.0f, Optional< float > orientation=Optional< float >()) const
Definition: Position.cpp:157
virtual uint8 GetLevelForTarget(WorldObject const *) const
Definition: Object.h:510
bool HasAuraTypeWithMiscvalue(AuraType auratype, int32 miscvalue) const
Definition: Unit.cpp:4442
FlaggedValuesArray32< int32, uint32, StealthType, TOTAL_STEALTH_TYPES > m_stealthDetect
Definition: Object.h:525
#define M_PI
Definition: Common.h:134
GameObject * ToGameObject()
Definition: Object.h:204
Unit * GetOwner() const
Definition: Object.cpp:2030
int32_t int32
Definition: Define.h:148
uint32_t uint32
Definition: Define.h:152
Definition: GameObject.h:81
StealthType
Definition: SharedDefines.h:2233
#define MAX_PLAYER_STEALTH_DETECT_RANGE
Definition: Unit.h:734
Definition: ObjectGuid.h:40
Creature * ToCreature()
Definition: Object.h:196
Definition: SharedDefines.h:2238
Definition: Unit.h:736
float m_CombatDistance
Definition: Creature.h:335
Unit * ToUnit()
Definition: Object.h:200
float GetExactDist(float x, float y, float z) const
Definition: Position.cpp:57
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CanNeverSee()

bool WorldObject::CanNeverSee ( WorldObject const *  obj) const
private
1525 {
1526  return GetMap() != obj->GetMap() || !IsInPhase(obj);
1527 }
bool IsInPhase(WorldObject const *obj) const
Definition: Object.h:441
Map * GetMap() const
Definition: Object.h:535
+ 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
1436 {
1437  if (this == obj)
1438  return true;
1439 
1440  if (obj->IsNeverVisibleFor(this) || CanNeverSee(obj))
1441  return false;
1442 
1443  if (obj->IsAlwaysVisibleFor(this) || CanAlwaysSee(obj))
1444  return true;
1445 
1446  if (!obj->CheckPrivateObjectOwnerVisibility(this))
1447  return false;
1448 
1449  bool corpseVisibility = false;
1450  if (distanceCheck)
1451  {
1452  bool corpseCheck = false;
1453  if (Player const* thisPlayer = ToPlayer())
1454  {
1455  if (thisPlayer->isDead() && thisPlayer->GetHealth() > 0 && // Cheap way to check for ghost state
1457  {
1458  if (Corpse* corpse = thisPlayer->GetCorpse())
1459  {
1460  corpseCheck = true;
1461  if (corpse->IsWithinDist(thisPlayer, GetSightRange(obj), false))
1462  if (corpse->IsWithinDist(obj, GetSightRange(obj), false))
1463  corpseVisibility = true;
1464  }
1465  }
1466 
1467  if (Unit const* target = obj->ToUnit())
1468  {
1469  // Don't allow to detect vehicle accessories if you can't see vehicle
1470  if (Unit const* vehicle = target->GetVehicleBase())
1471  if (!thisPlayer->HaveAtClient(vehicle))
1472  return false;
1473  }
1474  }
1475 
1476  WorldObject const* viewpoint = this;
1477  if (Player const* player = ToPlayer())
1478  viewpoint = player->GetViewpoint();
1479 
1480  if (!viewpoint)
1481  viewpoint = this;
1482 
1483  if (!corpseCheck && !viewpoint->IsWithinDist(obj, GetSightRange(obj), false))
1484  return false;
1485  }
1486 
1487  // GM visibility off or hidden NPC
1488  if (!obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM))
1489  {
1490  // Stop checking other things for GMs
1492  return true;
1493  }
1494  else
1495  return m_serverSideVisibilityDetect.GetValue(SERVERSIDE_VISIBILITY_GM) >= obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GM);
1496 
1497  // Ghost players, Spirit Healers, and some other NPCs
1498  if (!corpseVisibility && !(obj->m_serverSideVisibility.GetValue(SERVERSIDE_VISIBILITY_GHOST) & m_serverSideVisibilityDetect.GetValue(SERVERSIDE_VISIBILITY_GHOST)))
1499  {
1500  // Alive players can see dead players in some cases, but other objects can't do that
1501  if (Player const* thisPlayer = ToPlayer())
1502  {
1503  if (Player const* objPlayer = obj->ToPlayer())
1504  {
1505  if (thisPlayer->GetTeam() != objPlayer->GetTeam() || !thisPlayer->IsGroupVisibleFor(objPlayer))
1506  return false;
1507  }
1508  else
1509  return false;
1510  }
1511  else
1512  return false;
1513  }
1514 
1515  if (obj->IsInvisibleDueToDespawn())
1516  return false;
1517 
1518  if (!CanDetect(obj, ignoreStealth, checkAlert))
1519  return false;
1520 
1521  return true;
1522 }
Definition: Corpse.h:50
Unit * GetVehicleBase() const
Definition: Unit.cpp:11176
T_VALUES GetValue(FLAG_TYPE flag) const
Definition: Object.h:401
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibility
Definition: Object.h:530
Definition: Object.h:410
Player * ToPlayer()
Definition: Object.h:192
Definition: SharedDefines.h:2296
Definition: SharedDefines.h:2287
float GetSightRange(WorldObject const *target=nullptr) const
Definition: Object.cpp:1386
bool CanNeverSee(WorldObject const *obj) const
Definition: Object.cpp:1524
FlaggedValuesArray32< int32, uint32, ServerSideVisibilityType, TOTAL_SERVERSIDE_VISIBILITY_TYPES > m_serverSideVisibilityDetect
Definition: Object.h:531
bool IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1089
virtual bool CanAlwaysSee(WorldObject const *) const
Definition: Object.h:727
Definition: SharedDefines.h:2288
Definition: Unit.h:736
Definition: Player.h:1056
bool CanDetect(WorldObject const *obj, bool ignoreStealth, bool checkAlert=false) const
Definition: Object.cpp:1529
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CastSpell() [1/3]

void WorldObject::CastSpell ( SpellCastTargets const &  targets,
uint32  spellId,
CastSpellExtraArgs const &  args = { } 
)
2632 {
2633  SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId, args.CastDifficulty != DIFFICULTY_NONE ? args.CastDifficulty : GetMap()->GetDifficultyID());
2634  if (!info)
2635  {
2636  TC_LOG_ERROR("entities.unit", "CastSpell: unknown spell %u by caster %s", spellId, GetGUID().ToString().c_str());
2637  return;
2638  }
2639 
2640  Spell* spell = new Spell(this, info, args.TriggerFlags, args.OriginalCaster);
2641  for (auto const& pair : args.SpellValueOverrides)
2642  spell->SetSpellValue(pair.first, pair.second);
2643 
2644  spell->m_CastItem = args.CastItem;
2645  spell->prepare(targets, args.TriggeringAura);
2646 }
Definition: DBCEnums.h:597
Definition: SpellInfo.h:372
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
Item * m_CastItem
Definition: Spell.h:633
Map * GetMap() const
Definition: Object.h:535
ObjectGuid const & GetGUID() const
Definition: Object.h:154
#define sSpellMgr
Definition: SpellMgr.h:790
std::string ToString() const
Definition: Position.cpp:189
void prepare(SpellCastTargets const &targets, AuraEffect const *triggeredByAura=nullptr)
Definition: Spell.cpp:3037
void SetSpellValue(SpellValueMod mod, int32 value)
Definition: Spell.cpp:7738
Definition: Spell.h:348
+ Here is the call graph for this function:

◆ CastSpell() [2/3]

void WorldObject::CastSpell ( WorldObject target,
uint32  spellId,
CastSpellExtraArgs const &  args = { } 
)
2649 {
2650  SpellCastTargets targets;
2651  if (target)
2652  {
2653  if (Unit* unitTarget = target->ToUnit())
2654  targets.SetUnitTarget(unitTarget);
2655  else if (GameObject* goTarget = target->ToGameObject())
2656  targets.SetGOTarget(goTarget);
2657  else
2658  {
2659  TC_LOG_ERROR("entities.unit", "CastSpell: Invalid target %s passed to spell cast by %s", target->GetGUID().ToString().c_str(), GetGUID().ToString().c_str());
2660  return;
2661  }
2662  }
2663  CastSpell(targets, spellId, args);
2664 }
std::string ToString() const
Definition: ObjectGuid.cpp:238
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
GameObject * ToGameObject()
Definition: Object.h:204
ObjectGuid const & GetGUID() const
Definition: Object.h:154
void SetGOTarget(GameObject *target)
Definition: Spell.cpp:254
void SetUnitTarget(Unit *target)
Definition: Spell.cpp:228
Definition: GameObject.h:81
Definition: Spell.h:220
void CastSpell(SpellCastTargets const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2631
Definition: Unit.h:736
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:

◆ CastSpell() [3/3]

void WorldObject::CastSpell ( Position const &  dest,
uint32  spellId,
CastSpellExtraArgs const &  args = { } 
)
2667 {
2668  SpellCastTargets targets;
2669  targets.SetDst(dest);
2670  CastSpell(targets, spellId, args);
2671 }
Definition: Spell.h:220
void CastSpell(SpellCastTargets const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition: Object.cpp:2631
void SetDst(float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
Definition: Spell.cpp:375
+ Here is the call graph for this function:

◆ CheckPrivateObjectOwnerVisibility()

bool WorldObject::CheckPrivateObjectOwnerVisibility ( WorldObject const *  seer) const
1416 {
1417  if (!IsPrivateObject())
1418  return true;
1419 
1420  // Owner of this private object
1421  if (_privateObjectOwner == seer->GetGUID())
1422  return true;
1423 
1424  // Another private object of the same owner
1425  if (_privateObjectOwner == seer->GetPrivateObjectOwner())
1426  return true;
1427 
1428  if (Player const* playerSeer = seer->ToPlayer())
1429  if (playerSeer->IsInGroup(_privateObjectOwner))
1430  return true;
1431 
1432  return false;
1433 }
Player * ToPlayer()
Definition: Object.h:192
bool IsPrivateObject() const
Definition: Object.h:679
ObjectGuid _privateObjectOwner
Definition: Object.h:722
Definition: Player.h:1056
+ 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.

933 {
934  if (IsInWorld())
935  RemoveFromWorld();
936 
937  if (Transport* transport = GetTransport())
938  transport->RemovePassenger(this);
939 }
Transport * GetTransport() const
Definition: Object.h:647
bool IsInWorld() const
Definition: Object.h:149
Definition: Transport.h:27
void RemoveFromWorld() override
Definition: Object.cpp:964
+ 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
3188 {
3189  if (!IsInWorld())
3190  return;
3191 
3192  std::list<Player*> targets;
3195  Cell::VisitWorldObjects(this, searcher, GetVisibilityRange());
3196  for (std::list<Player*>::const_iterator iter = targets.begin(); iter != targets.end(); ++iter)
3197  {
3198  Player* player = (*iter);
3199 
3200  if (player == this)
3201  continue;
3202 
3203  if (!player->HaveAtClient(this))
3204  continue;
3205 
3206  if (isType(TYPEMASK_UNIT) && ToUnit()->GetCharmerGUID() == player->GetGUID())
3207  continue;
3208 
3209  DestroyForPlayer(player);
3210  player->m_clientGUIDs.erase(GetGUID());
3211  }
3212 }
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1229
Definition: GridNotifiers.h:1356
bool HaveAtClient(Object const *u) const
Definition: Player.cpp:23770
bool IsInWorld() const
Definition: Object.h:149
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:193
Definition: GridNotifiers.h:596
Definition: ObjectGuid.h:59
virtual void DestroyForPlayer(Player *target) const
Definition: Object.cpp:277
ObjectGuid const & GetGUID() const
Definition: Object.h:154
bool isType(uint16 mask) const
Definition: Object.h:168
float GetVisibilityRange() const
Definition: Object.cpp:1376
GuidUnorderedSet m_clientGUIDs
Definition: Player.h:2363
Definition: Player.h:1056
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindMap()

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

◆ FindNearestCreature()

Creature * WorldObject::FindNearestCreature ( uint32  entry,
float  range,
bool  alive = true 
) const
1985 {
1986  Creature* creature = nullptr;
1987  Trinity::NearestCreatureEntryWithLiveStateInObjectRangeCheck checker(*this, entry, alive, range);
1989  Cell::VisitAllObjects(this, searcher, range);
1990  return creature;
1991 }
Definition: Creature.h:61
Definition: GridNotifiers.h:529
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:205
+ Here is the call graph for this function:

◆ FindNearestGameObject()

GameObject * WorldObject::FindNearestGameObject ( uint32  entry,
float  range 
) const
1994 {
1995  GameObject* go = nullptr;
1996  Trinity::NearestGameObjectEntryInObjectRangeCheck checker(*this, entry, range);
1998  Cell::VisitGridObjects(this, searcher, range);
1999  return go;
2000 }
Definition: GridNotifiers.h:406
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:181
Definition: GameObject.h:81
+ 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
2003 {
2004  GameObject* go = nullptr;
2005  Trinity::NearestGameObjectTypeInObjectRangeCheck checker(*this, type, range);
2007  Cell::VisitGridObjects(this, searcher, range);
2008  return go;
2009 }
Definition: GridNotifiers.h:406
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:181
Definition: GameObject.h:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAffectingPlayer()

Player * WorldObject::GetAffectingPlayer ( ) const
2063 {
2064  if (!GetCharmerOrOwnerGUID())
2065  return const_cast<WorldObject*>(this)->ToPlayer();
2066 
2067  if (Unit* owner = GetCharmerOrOwner())
2068  return owner->GetCharmerOrOwnerPlayerOrPlayerItself();
2069 
2070  return nullptr;
2071 }
Definition: Object.h:410
Player * ToPlayer()
Definition: Object.h:192
virtual ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Object.h:558
Unit * GetCharmerOrOwner() const
Definition: Object.cpp:2035
Player * GetCharmerOrOwnerPlayerOrPlayerItself() const
Definition: Object.cpp:2053
Definition: Unit.h:736
+ 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.

674 { return 0; }

◆ GetAreaId()

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

◆ GetCastSpellXSpellVisualId()

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

Reimplemented in Unit.

2947 {
2948  return spellInfo->GetSpellXSpellVisualId(this);
2949 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCharmerOrOwner()

Unit * WorldObject::GetCharmerOrOwner ( ) const
2036 {
2037  if (Unit const* unit = ToUnit())
2038  return unit->GetCharmerOrOwner();
2039  else if (GameObject const* go = ToGameObject())
2040  return go->GetOwner();
2041 
2042  return nullptr;
2043 }
GameObject * ToGameObject()
Definition: Object.h:204
Definition: GameObject.h:81
Definition: Unit.h:736
Unit * ToUnit()
Definition: Object.h:200
+ 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.

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

◆ GetCharmerOrOwnerOrOwnGUID()

ObjectGuid WorldObject::GetCharmerOrOwnerOrOwnGUID ( ) const
2023 {
2025  if (!guid.IsEmpty())
2026  return guid;
2027  return GetGUID();
2028 }
ObjectGuid const & GetGUID() const
Definition: Object.h:154
virtual ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Object.h:558
bool IsEmpty() const
Definition: ObjectGuid.h:299
Definition: ObjectGuid.h:248
+ Here is the call graph for this function:

◆ GetCharmerOrOwnerOrSelf()

Unit * WorldObject::GetCharmerOrOwnerOrSelf ( ) const
2046 {
2047  if (Unit* u = GetCharmerOrOwner())
2048  return u;
2049 
2050  return const_cast<WorldObject*>(this)->ToUnit();
2051 }
Definition: Object.h:410
Unit * GetCharmerOrOwner() const
Definition: Object.cpp:2035
Definition: Unit.h:736
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCharmerOrOwnerPlayerOrPlayerItself()

Player * WorldObject::GetCharmerOrOwnerPlayerOrPlayerItself ( ) const
2054 {
2056  if (guid.IsPlayer())
2057  return ObjectAccessor::GetPlayer(*this, guid);
2058 
2059  return const_cast<WorldObject*>(this)->ToPlayer();
2060 }
Definition: Object.h:410
Player * ToPlayer()
Definition: Object.h:192
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:229
virtual ObjectGuid GetCharmerOrOwnerGUID() const
Definition: Object.h:558
bool IsPlayer() const
Definition: ObjectGuid.h:306
Definition: ObjectGuid.h:248
+ 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  angle = 0 
) const
3021 {
3022  // angle calculated from current orientation
3023  GetNearPoint(nullptr, x, y, z, size, distance2d, GetOrientation() + angle);
3024 }
float GetOrientation() const
Definition: Position.h:104
constexpr auto size(const C &c)
Definition: advstd.h:89
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
Definition: Object.cpp:2984
+ 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.

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

◆ GetCombatReach()

virtual float WorldObject::GetCombatReach ( ) const
inlinevirtual

Reimplemented in Unit.

432 { 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
3048 {
3049  // angle to face `obj` to `this` using distance includes size of `obj`
3050  GetNearPoint(obj, x, y, z, obj->GetCombatReach(), distance2d, GetAngle(obj));
3051 }
float GetAngle(Position const *pos) const
Definition: Position.cpp:85
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float searcher_size, float distance2d, float absAngle) const
Definition: Object.cpp:2984
+ 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
2961 {
2962  Trinity::AllCreaturesOfEntryInRange check(this, entry, maxSearchRange);
2963  Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(this, creatureContainer, check);
2964  Cell::VisitGridObjects(this, searcher, maxSearchRange);
2965 }
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:181
Definition: GridNotifiers.h:544
Definition: GridNotifiers.h:1457
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDBPhase()

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

◆ GetDistance() [1/3]

float WorldObject::GetDistance ( WorldObject const *  obj) const
1026 {
1027  float d = GetExactDist(obj) - GetCombatReach() - obj->GetCombatReach();
1028  return d > 0.0f ? d : 0.0f;
1029 }
virtual float GetCombatReach() const
Definition: Object.h:432
float GetExactDist(float x, float y, float z) const
Definition: Position.cpp:57
+ 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
1032 {
1033  float d = GetExactDist(&pos) - GetCombatReach();
1034  return d > 0.0f ? d : 0.0f;
1035 }
virtual float GetCombatReach() const
Definition: Object.h:432
float GetExactDist(float x, float y, float z) const
Definition: Position.cpp:57
+ Here is the call graph for this function:

◆ GetDistance() [3/3]

float WorldObject::GetDistance ( float  x,
float  y,
float  z 
) const
1038 {
1039  float d = GetExactDist(x, y, z) - GetCombatReach();
1040  return d > 0.0f ? d : 0.0f;
1041 }
virtual float GetCombatReach() const
Definition: Object.h:432
float GetExactDist(float x, float y, float z) const
Definition: Position.cpp:57
+ Here is the call graph for this function:

◆ GetDistance2d() [1/2]

float WorldObject::GetDistance2d ( WorldObject const *  obj) const
1044 {
1045  float d = GetExactDist2d(obj) - GetCombatReach() - obj->GetCombatReach();
1046  return d > 0.0f ? d : 0.0f;
1047 }
virtual float GetCombatReach() const
Definition: Object.h:432
float GetExactDist2d(const float x, const float y) const
Definition: Position.cpp:47
+ 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
1050 {
1051  float d = GetExactDist2d(x, y) - GetCombatReach();
1052  return d > 0.0f ? d : 0.0f;
1053 }
virtual float GetCombatReach() const
Definition: Object.h:432
float GetExactDist2d(const float x, const float y) const
Definition: Position.cpp:47
+ Here is the call graph for this function:

◆ GetDistanceOrder()

bool WorldObject::GetDistanceOrder ( WorldObject const *  obj1,
WorldObject const *  obj2,
bool  is3D = true 
) const
1163 {
1164  float dx1 = GetPositionX() - obj1->GetPositionX();
1165  float dy1 = GetPositionY() - obj1->GetPositionY();
1166  float distsq1 = dx1*dx1 + dy1*dy1;
1167  if (is3D)
1168  {
1169  float dz1 = GetPositionZ() - obj1->GetPositionZ();
1170  distsq1 += dz1*dz1;
1171  }
1172 
1173  float dx2 = GetPositionX() - obj2->GetPositionX();
1174  float dy2 = GetPositionY() - obj2->GetPositionY();
1175  float distsq2 = dx2*dx2 + dy2*dy2;
1176  if (is3D)
1177  {
1178  float dz2 = GetPositionZ() - obj2->GetPositionZ();
1179  distsq2 += dz2*dz2;
1180  }
1181 
1182  return distsq1 < distsq2;
1183 }
float GetPositionY() const
Definition: Position.h:102
float GetPositionZ() const
Definition: Position.h:103
float GetPositionX() const
Definition: Position.h:101
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDistanceZ()

float WorldObject::GetDistanceZ ( WorldObject const *  obj) const
996 {
997  float dz = std::fabs(GetPositionZ() - obj->GetPositionZ());
998  float sizefactor = GetCombatReach() + obj->GetCombatReach();
999  float dist = dz - sizefactor;
1000  return (dist > 0 ? dist : 0);
1001 }
virtual float GetCombatReach() const
Definition: Object.h:432
float GetPositionZ() const
Definition: Position.h:103
+ 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, and Conversation.

+ Here is the caller graph for this function:

◆ GetFactionReactionTo()

ReputationRank WorldObject::GetFactionReactionTo ( FactionTemplateEntry const *  factionTemplateEntry,
WorldObject const *  target 
)
static
2549 {
2550  // always neutral when no template entry found
2551  if (!factionTemplateEntry)
2552  return REP_NEUTRAL;
2553 
2554  FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry();
2555  if (!targetFactionTemplateEntry)
2556  return REP_NEUTRAL;
2557 
2558  if (Player const* targetPlayerOwner = target->GetAffectingPlayer())
2559  {
2560  // check contested flags
2561  if (factionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD
2562  && targetPlayerOwner->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
2563  return REP_HOSTILE;
2564  if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(factionTemplateEntry))
2565  return *repRank;
2566  if (target->IsUnit() && !target->ToUnit()->HasUnitFlag2(UNIT_FLAG2_IGNORE_REPUTATION))
2567  {
2568  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplateEntry->Faction))
2569  {
2570  if (factionEntry->CanHaveReputation())
2571  {
2572  // CvP case - check reputation, don't allow state higher than neutral when at war
2573  ReputationRank repRank = targetPlayerOwner->GetReputationMgr().GetRank(factionEntry);
2574  if (targetPlayerOwner->GetReputationMgr().IsAtWar(factionEntry))
2575  repRank = std::min(REP_NEUTRAL, repRank);
2576  return repRank;
2577  }
2578  }
2579  }
2580  }
2581 
2582  // common faction based check
2583  if (factionTemplateEntry->IsHostileTo(targetFactionTemplateEntry))
2584  return REP_HOSTILE;
2585  if (factionTemplateEntry->IsFriendlyTo(targetFactionTemplateEntry))
2586  return REP_FRIENDLY;
2587  if (targetFactionTemplateEntry->IsFriendlyTo(factionTemplateEntry))
2588  return REP_FRIENDLY;
2589  if (factionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_HOSTILE_BY_DEFAULT)
2590  return REP_HOSTILE;
2591  // neutral by default
2592  return REP_NEUTRAL;
2593 }
Definition: Player.h:430
ReputationRank
Definition: SharedDefines.h:184
Player * GetAffectingPlayer() const
Definition: Object.cpp:2062
Definition: SharedDefines.h:189
Definition: SharedDefines.h:190
Definition: SharedDefines.h:187
Definition: DBCEnums.h:685
Definition: UnitDefines.h:159
Definition: DB2Structure.h:1428
Definition: DB2Structure.h:1400
bool IsFriendlyTo(FactionTemplateEntry const *entry) const
Definition: DB2Structure.h:1442
DB2Storage< FactionEntry > sFactionStore("Faction.db2", FactionLoadInfo::Instance())
Definition: Player.h:1056
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFactionTemplateEntry()

FactionTemplateEntry const * WorldObject::GetFactionTemplateEntry ( ) const
2443 {
2444  FactionTemplateEntry const* entry = sFactionTemplateStore.LookupEntry(GetFaction());
2445  if (!entry)
2446  {
2447  if (Player const* player = ToPlayer())
2448  TC_LOG_ERROR("entities", "Player %s has invalid faction (faction template id) #%u", player->GetName().c_str(), GetFaction());
2449  else if (Creature const* creature = ToCreature())
2450  TC_LOG_ERROR("entities", "Creature (template id: %u) has invalid faction (faction template id) #%u", creature->GetCreatureTemplate()->Entry, GetFaction());
2451  else if (GameObject const* go = ToGameObject())
2452  TC_LOG_ERROR("entities", "GameObject (template id: %u) has invalid faction (faction template id) #%u", go->GetGOInfo()->entry, GetFaction());
2453  else
2454  TC_LOG_ERROR("entities", "WorldObject (name: %s, type: %u) has invalid faction (faction template id) #%u", GetName().c_str(), uint32(GetTypeId()), GetFaction());
2455  }
2456 
2457  return entry;
2458 }
TypeID GetTypeId() const
Definition: Object.h:167
virtual uint32 GetFaction() const =0
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:186
Definition: Creature.h:61
GameObject * ToGameObject()
Definition: Object.h:204
Player * ToPlayer()
Definition: Object.h:192
std::string const & GetName() const
Definition: Object.h:467
uint32_t uint32
Definition: Define.h:152
Definition: GameObject.h:81
DB2Storage< FactionTemplateEntry > sFactionTemplateStore("FactionTemplate.db2", FactionTemplateLoadInfo::Instance())
Definition: DB2Structure.h:1428
Creature * ToCreature()
Definition: Object.h:196
Definition: Player.h:1056
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFirstCollisionPosition()

Position WorldObject::GetFirstCollisionPosition ( float  dist,
float  angle 
)
3034 {
3035  Position pos = GetPosition();
3036  MovePositionToFirstCollision(pos, dist, angle);
3037  return pos;
3038 }
Position GetPosition() const
Definition: Position.h:121
void MovePositionToFirstCollision(Position &pos, float dist, float angle)
Definition: Object.cpp:3099
Definition: Position.h:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetFloorZ()

float WorldObject::GetFloorZ ( ) const
3318 {
3319  if (!IsInWorld())
3320  return m_staticFloorZ;
3322 }
virtual float GetCollisionHeight() const
Definition: Object.h:666
bool IsInWorld() const
Definition: Object.h:149
float m_staticFloorZ
Definition: Object.h:698
float GetGameObjectFloor(PhaseShift const &phaseShift, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.h:505
float GetPositionY() const
Definition: Position.h:102
Map * GetMap() const
Definition: Object.h:535
PhaseShift & GetPhaseShift()
Definition: Object.h:450
float GetPositionZ() const
Definition: Position.h:103
float GetPositionX() const
Definition: Position.h:101
+ 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
2953 {
2954  Trinity::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
2955  Trinity::GameObjectListSearcher<Trinity::AllGameObjectsWithEntryInRange> searcher(this, gameObjectContainer, check);
2956  Cell::VisitGridObjects(this, searcher, maxSearchRange);
2957 }
Definition: GridNotifiers.h:421
Definition: GridNotifiers.h:1438
static void VisitGridObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:181
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGridActivationRange()

float WorldObject::GetGridActivationRange ( ) const
1361 {
1362  if (isActiveObject())
1363  {
1364  if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->GetCinematicMgr()->IsOnCinematic())
1365  return std::max(DEFAULT_VISIBILITY_INSTANCE, GetMap()->GetVisibilityRange());
1366 
1367  return GetMap()->GetVisibilityRange();
1368  }
1369 
1370  if (Creature const* thisCreature = ToCreature())
1371  return thisCreature->m_SightDistance;
1372 
1373  return 0.0f;
1374 }
float GetVisibilityRange() const
Definition: Map.h:279
TypeID GetTypeId() const
Definition: Object.h:167
bool isActiveObject() const
Definition: Object.h:634
Definition: Creature.h:61
Player * ToPlayer()
Definition: Object.h:192
Map * GetMap() const
Definition: Object.h:535
float GetVisibilityRange() const
Definition: Object.cpp:1376
#define DEFAULT_VISIBILITY_INSTANCE
Definition: ObjectDefines.h:36
Definition: ObjectGuid.h:40
Creature * ToCreature()
Definition: Object.h:196
+ 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
1100 {
1101  G3D::Vector3 vThis(GetPositionX(), GetPositionY(), GetPositionZ() + GetCollisionHeight());
1102  G3D::Vector3 vObj(dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ());
1103  G3D::Vector3 contactPoint = vThis + (vObj - vThis).directionOrZero() * std::min(dest.GetExactDist(GetPosition()), GetCombatReach());
1104 
1105  return Position(contactPoint.x, contactPoint.y, contactPoint.z, GetAngle(contactPoint.x, contactPoint.y));
1106 }
float GetAngle(Position const *pos) const
Definition: Position.cpp:85
Position GetPosition() const
Definition: Position.h:121
virtual float GetCollisionHeight() const
Definition: Object.h:666
virtual float GetCombatReach() const
Definition: Object.h:432
float GetPositionY() const
Definition: Position.h:102
Position(float x=0, float y=0, float z=0, float o=0)
Definition: Position.h:30
float GetPositionZ() const
Definition: Position.h:103
float GetPositionX() const
Definition: Position.h:101
+ 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
1155 {
1156  Position pos = GetHitSpherePointFor(dest);
1157  x = pos.GetPositionX();
1158  y = pos.GetPositionY();
1159  z = pos.GetPositionZ();
1160 }
float GetPositionY() const
Definition: Position.h:102
float GetPositionZ() const
Definition: Position.h:103
float GetPositionX() const
Definition: Position.h:101
Definition: Position.h:28
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1099
+ Here is the call graph for this function:

◆ GetInstanceId()

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

◆ GetInstanceScript()

InstanceScript * WorldObject::GetInstanceScript ( ) const
990 {
991  Map* map = GetMap();
992  return map->IsDungeon() ? ((InstanceMap*)map)->GetInstanceScript() : nullptr;
993 }
bool IsDungeon() const
Definition: Map.cpp:4240
Map * GetMap() const
Definition: Object.h:535
Definition: Map.h:860
Definition: Map.h:248
+ Here is the call graph for this function:

◆ GetLevelForTarget()

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

Reimplemented in Unit, GameObject, and Creature.

510 { return 1; }
+ 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
2910 {
2911  // Patch 1.2 notes: Spell Reflection no longer reflects abilities
2912  if (spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR1_CANT_BE_REDIRECTED) || spellInfo->HasAttribute(SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY))
2913  return victim;
2914 
2916  for (AuraEffect const* aurEff : magnetAuras)
2917  {
2918  if (Unit* magnet = aurEff->GetBase()->GetCaster())
2919  {
2920  if (spellInfo->CheckExplicitTarget(this, magnet) == SPELL_CAST_OK && IsValidAttackTarget(magnet, spellInfo))
2921  {
2923  if (spellInfo->HasHitDelay())
2924  {
2925  // Set up missile speed based delay
2926  float hitDelay = spellInfo->LaunchDelay;
2927  if (spellInfo->HasAttribute(SPELL_ATTR9_SPECIAL_DELAY_CALCULATION))
2928  hitDelay += spellInfo->Speed;
2929  else if (spellInfo->Speed > 0.0f)
2930  hitDelay += std::max(victim->GetDistance(this), 5.0f) / spellInfo->Speed;
2931 
2932  uint32 delay = uint32(std::floor(hitDelay * 1000.0f));
2933  // Schedule charge drop
2934  aurEff->GetBase()->DropChargeDelayed(delay, AURA_REMOVE_BY_EXPIRE);
2935  }
2936  else
2937  aurEff->GetBase()->DropCharge(AURA_REMOVE_BY_EXPIRE);
2938 
2939  return magnet;
2940  }
2941  }
2942  }
2943  return victim;
2944 }
Definition: SpellAuraDefines.h:184
Definition: SpellAuraEffects.h:28
Definition: SharedDefines.h:704
bool IsValidAttackTarget(WorldObject const *target, SpellInfo const *bySpell=nullptr) const
Definition: Object.cpp:2674
Definition: SharedDefines.h:380
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:754
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1365
uint32_t uint32
Definition: Define.h:152
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1025
Definition: SpellAuraDefines.h:69
Definition: SharedDefines.h:405
Definition: SharedDefines.h:415
Definition: Unit.h:736
Definition: SharedDefines.h:1697
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetMap()

Map* WorldObject::GetMap ( ) const
inline
535 { ASSERT(m_currMap); return m_currMap; }
Map * m_currMap
Definition: Object.h:713
#define ASSERT
Definition: Errors.h:57

◆ GetMapHeight()

float WorldObject::GetMapHeight ( float  x,
float  y,
float  z,
bool  vmap = true,
float  distanceToSearch = 50.0f 
) const
3333 {
3334  if (z != MAX_HEIGHT)
3335  z += GetCollisionHeight();
3336 
3337  return GetMap()->GetHeight(GetPhaseShift(), x, y, z, vmap, distanceToSearch);
3338 }
float GetHeight(PhaseShift const &phaseShift, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
Definition: Map.h:498
virtual float GetCollisionHeight() const
Definition: Object.h:666
Map * GetMap() const
Definition: Object.h:535
PhaseShift & GetPhaseShift()
Definition: Object.h:450
#define MAX_HEIGHT
Definition: Map.h:208
+ 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
3325 {
3326  if (Unit const* unit = ToUnit())
3327  return GetMap()->GetWaterOrGroundLevel(GetPhaseShift(), x, y, z, ground, !unit->HasAuraType(SPELL_AURA_WATER_WALK), GetCollisionHeight());
3328 
3329  return z;
3330 }
Definition: SpellAuraDefines.h:192
virtual float GetCollisionHeight() const
Definition: Object.h:666
Map * GetMap() const
Definition: Object.h:535
PhaseShift & GetPhaseShift()
Definition: Object.h:450
float GetWaterOrGroundLevel(PhaseShift const &phaseShift, float x, float y, float z, float *ground=nullptr, bool swim=false, float collisionHeight=2.03128f)
Definition: Map.cpp:2464
Definition: Unit.h:736
Unit * ToUnit()
Definition: Object.h:200
+ 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.

676 { return 0; }

◆ GetMovementAnimKitId()

virtual uint16 WorldObject::GetMovementAnimKitId ( ) const
inlinevirtual

Reimplemented in Unit.

675 { return 0; }

◆ GetName()

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

◆ GetNameForLocaleIdx()

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

Implements Object.

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

◆ GetNearPoint()

void WorldObject::GetNearPoint ( WorldObject const *  searcher,
float &  x,
float &  y,
float &  z,
float  searcher_size,
float  distance2d,
float  absAngle 
) const
2985 {
2986  GetNearPoint2D(x, y, distance2d+searcher_size, absAngle);
2987  z = GetPositionZ();
2988  // Should "searcher" be used instead of "this" when updating z coordinate ?
2989  UpdateAllowedPositionZ(x, y, z);
2990 
2991  // if detection disabled, return first point
2992  if (!sWorld->getBoolConfig(CONFIG_DETECT_POS_COLLISION))
2993  return;
2994 
2995  // return if the point is already in LoS
2996  if (IsWithinLOS(x, y, z))
2997  return;
2998 
2999  // remember first point
3000  float first_x = x;
3001  float first_y = y;
3002  float first_z = z;
3003 
3004  // loop in a circle to look for a point in LoS using small steps
3005  for (float angle = float(M_PI) / 8; angle < float(M_PI) * 2; angle += float(M_PI) / 8)
3006  {
3007  GetNearPoint2D(x, y, distance2d + searcher_size, absAngle + angle);
3008  z = GetPositionZ();
3009  UpdateAllowedPositionZ(x, y, z);
3010  if (IsWithinLOS(x, y, z))
3011  return;
3012  }
3013 
3014  // still not in LoS, give up and return first position found
3015  x = first_x;
3016  y = first_y;
3017  z = first_z;
3018 }
Definition: World.h:126
#define sWorld
Definition: World.h:925
#define M_PI
Definition: Common.h:134
void UpdateAllowedPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1314
void GetNearPoint2D(float &x, float &y, float distance, float absAngle) const
Definition: Object.cpp:2975
float GetPositionZ() const
Definition: Position.h:103
bool IsWithinLOS(float x, float y, float z, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
Definition: Object.cpp:1108
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNearPoint2D()

void WorldObject::GetNearPoint2D ( float &  x,
float &  y,
float  distance,
float  absAngle 
) const
2976 {
2977  x = GetPositionX() + (GetCombatReach() + distance2d) * std::cos(absAngle);
2978  y = GetPositionY() + (GetCombatReach() + distance2d) * std::sin(absAngle);
2979 
2982 }
virtual float GetCombatReach() const
Definition: Object.h:432
float GetPositionY() const
Definition: Position.h:102
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:212
float GetPositionX() const
Definition: Position.h:101
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNearPosition()

Position WorldObject::GetNearPosition ( float  dist,
float  angle 
)
3027 {
3028  Position pos = GetPosition();
3029  MovePosition(pos, dist, angle);
3030  return pos;
3031 }
void MovePosition(Position &pos, float dist, float angle)
Definition: Object.cpp:3053
Position GetPosition() const
Definition: Position.h:121
Definition: Position.h:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNotifyFlags()

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

◆ GetOwner()

Unit * WorldObject::GetOwner ( ) const
2031 {
2032  return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
2033 }
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:208
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, and Conversation.

+ Here is the caller graph for this function:

◆ GetPhaseShift() [1/2]

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

◆ GetPhaseShift() [2/2]

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

◆ GetPlayerListInGrid()

template<typename Container >
template TC_GAME_API void WorldObject::GetPlayerListInGrid ( Container &  playerContainer,
float  maxSearchRange 
) const
2969 {
2970  Trinity::AnyPlayerInObjectRangeCheck checker(this, maxSearchRange);
2971  Trinity::PlayerListSearcher<Trinity::AnyPlayerInObjectRangeCheck> searcher(this, playerContainer, checker);
2972  Cell::VisitWorldObjects(this, searcher, maxSearchRange);
2973 }
Definition: GridNotifiers.h:1356
static void VisitWorldObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition: CellImpl.h:193
Definition: GridNotifiers.h:596
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetPrivateObjectOwner()

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

◆ GetRandomNearPosition()

Position WorldObject::GetRandomNearPosition ( float  radius)
3041 {
3042  Position pos = GetPosition();
3043  MovePosition(pos, radius * (float)rand_norm(), (float)rand_norm() * static_cast<float>(2 * M_PI));
3044  return pos;
3045 }
void MovePosition(Position &pos, float dist, float angle)
Definition: Object.cpp:3053
Position GetPosition() const
Definition: Position.h:121
double rand_norm()
Definition: Random.cpp:78
#define M_PI
Definition: Common.h:134
Definition: Position.h:28
+ 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
1279 {
1280  if (!distance)
1281  {
1282  pos.GetPosition(rand_x, rand_y, rand_z);
1283  return;
1284  }
1285 
1286  // angle to face `obj` to `this`
1287  float angle = (float)rand_norm()*static_cast<float>(2*M_PI);
1288  float new_dist = (float)rand_norm() + (float)rand_norm();
1289  new_dist = distance * (new_dist > 1 ? new_dist - 2 : new_dist);
1290 
1291  rand_x = pos.m_positionX + new_dist * std::cos(angle);
1292  rand_y = pos.m_positionY + new_dist * std::sin(angle);
1293  rand_z = pos.m_positionZ;
1294 
1297  UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available
1298 }
double rand_norm()
Definition: Random.cpp:78
#define M_PI
Definition: Common.h:134
void NormalizeMapCoord(float &c)
Definition: GridDefines.h:212
void UpdateGroundPositionZ(float x, float y, float &z) const
Definition: Object.cpp:1307
+ 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
1301 {
1302  float x, y, z;
1303  GetRandomPoint(srcPos, distance, x, y, z);
1304  return Position(x, y, z, GetOrientation());
1305 }
float GetOrientation() const
Definition: Position.h:104
Position(float x=0, float y=0, float z=0, float o=0)
Definition: Position.h:30
void GetRandomPoint(Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const
Definition: Object.cpp:1278
+ Here is the call graph for this function:

◆ GetReactionTo()

ReputationRank WorldObject::GetReactionTo ( WorldObject const *  target) const
2462 {
2463  // always friendly to self
2464  if (this == target)
2465  return REP_FRIENDLY;
2466 
2467  // always friendly to charmer or owner
2469  return REP_FRIENDLY;
2470 
2471  Player const* selfPlayerOwner = GetAffectingPlayer();
2472  Player const* targetPlayerOwner = target->GetAffectingPlayer();
2473 
2474  // check forced reputation to support SPELL_AURA_FORCE_REACTION
2475  if (selfPlayerOwner)
2476  {
2477  if (FactionTemplateEntry const* targetFactionTemplateEntry = target->GetFactionTemplateEntry())
2478  if (ReputationRank const* repRank = selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry))
2479  return *repRank;
2480  }
2481  else if (targetPlayerOwner)
2482  {
2483  if (FactionTemplateEntry const* selfFactionTemplateEntry = GetFactionTemplateEntry())
2484  if (ReputationRank const* repRank = targetPlayerOwner->GetReputationMgr().GetForcedRankIfAny(selfFactionTemplateEntry))
2485  return *repRank;
2486  }
2487 
2488  Unit const* unit = ToUnit();
2489  Unit const* targetUnit = target->ToUnit();
2490  if (unit && unit->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE))
2491  {
2492  if (targetUnit && targetUnit->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE))
2493  {
2494  if (selfPlayerOwner && targetPlayerOwner)
2495  {
2496  // always friendly to other unit controlled by player, or to the player himself
2497  if (selfPlayerOwner == targetPlayerOwner)
2498  return REP_FRIENDLY;
2499 
2500  // duel - always hostile to opponent
2501  if (selfPlayerOwner->duel && selfPlayerOwner->duel->opponent == targetPlayerOwner && selfPlayerOwner->duel->startTime != 0)
2502  return REP_HOSTILE;
2503 
2504  // same group - checks dependant only on our faction - skip FFA_PVP for example
2505  if (selfPlayerOwner->IsInRaidWith(targetPlayerOwner))
2506  return REP_FRIENDLY; // return true to allow config option AllowTwoSide.Interaction.Group to work
2507  // however client seems to allow mixed group parties, because in 13850 client it works like:
2508  // return GetFactionReactionTo(GetFactionTemplateEntry(), target);
2509  }
2510 
2511  // check FFA_PVP
2512  if (unit->IsFFAPvP() && targetUnit->IsFFAPvP())
2513  return REP_HOSTILE;
2514 
2515  if (selfPlayerOwner)
2516  {
2517  if (FactionTemplateEntry const* targetFactionTemplateEntry = targetUnit->GetFactionTemplateEntry())
2518  {
2519  if (ReputationRank const* repRank = selfPlayerOwner->GetReputationMgr().GetForcedRankIfAny(targetFactionTemplateEntry))
2520  return *repRank;
2521  if (!selfPlayerOwner->HasUnitFlag2(UNIT_FLAG2_IGNORE_REPUTATION))
2522  {
2523  if (FactionEntry const* targetFactionEntry = sFactionStore.LookupEntry(targetFactionTemplateEntry->Faction))
2524  {
2525  if (targetFactionEntry->CanHaveReputation())
2526  {
2527  // check contested flags
2528  if (targetFactionTemplateEntry->Flags & FACTION_TEMPLATE_FLAG_CONTESTED_GUARD
2529  && selfPlayerOwner->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
2530  return REP_HOSTILE;
2531 
2532  // if faction has reputation, hostile state depends only from AtWar state
2533  if (selfPlayerOwner->GetReputationMgr().IsAtWar(targetFactionEntry))
2534  return REP_HOSTILE;
2535  return REP_FRIENDLY;
2536  }
2537  }
2538  }
2539  }
2540  }
2541  }
2542  }
2543 
2544  // do checks dependant only on our faction
2546 }
Definition: Player.h:430
ReputationRank const * GetForcedRankIfAny(FactionTemplateEntry const *factionTemplateEntry) const
Definition: ReputationMgr.cpp:214
time_t startTime
Definition: Player.h:362
ReputationRank
Definition: SharedDefines.h:184
DuelInfo * duel
Definition: Player.h:1864
bool IsAtWar(uint32 faction_id) const
Definition: ReputationMgr.cpp:90
Player * GetAffectingPlayer() const
Definition: Object.cpp:2062
bool HasPlayerFlag(PlayerFlags flags) const
Definition: Player.h:2573
static ReputationRank GetFactionReactionTo(FactionTemplateEntry const *factionTemplateEntry, WorldObject const *target)
Definition: Object.cpp:2548
bool HasUnitFlag2(UnitFlags2 flags) const
Definition: Unit.h:929
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:925
Definition: SharedDefines.h:190
Definition: SharedDefines.h:187
Definition: UnitDefines.h:122
Definition: DBCEnums.h:685
Definition: UnitDefines.h:159
Definition: DB2Structure.h:1428
ReputationMgr & GetReputationMgr()
Definition: Player.h:2119
Definition: DB2Structure.h:1400
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Object.cpp:2442
Unit * GetCharmerOrOwnerOrSelf() const
Definition: Object.cpp:2045
Player * opponent
Definition: Player.h:360
DB2Storage< FactionEntry > sFactionStore("Faction.db2", FactionLoadInfo::Instance())
Definition: Unit.h:736
Definition: Player.h:1056
Unit * ToUnit()
Definition: Object.h:200
bool IsFFAPvP() const
Definition: Unit.h:961
bool IsInRaidWith(Unit const *unit) const
Definition: Unit.cpp:11226
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetScenario()

Scenario * WorldObject::GetScenario ( ) const
1870 {
1871  if (IsInWorld())
1872  if (InstanceMap* instanceMap = GetMap()->ToInstanceMap())
1873  return instanceMap->GetInstanceScenario();
1874 
1875  return nullptr;
1876 }
bool IsInWorld() const
Definition: Object.h:149
Map * GetMap() const
Definition: Object.h:535
Definition: Map.h:860
+ 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
1387 {
1388  if (ToUnit())
1389  {
1390  if (ToPlayer())
1391  {
1392  if (target && target->IsVisibilityOverridden() && !target->ToPlayer())
1393  return *target->m_visibilityDistanceOverride;
1394  else if (target && target->IsFarVisible() && !target->ToPlayer())
1395  return MAX_VISIBILITY_DISTANCE;
1396  else if (ToPlayer()->GetCinematicMgr()->IsOnCinematic())
1398  else
1399  return GetMap()->GetVisibilityRange();
1400  }
1401  else if (ToCreature())
1402  return ToCreature()->m_SightDistance;
1403  else
1404  return SIGHT_RANGE_UNIT;
1405  }
1406 
1407  if (ToDynObject() && isActiveObject())
1408  {
1409  return GetMap()->GetVisibilityRange();
1410  }
1411 
1412  return 0.0f;
1413 }
float GetVisibilityRange() const
Definition: Map.h:279
#define SIGHT_RANGE_UNIT
Definition: ObjectDefines.h:29
bool isActiveObject() const
Definition: Object.h:634
DynamicObject * ToDynObject()
Definition: Object.h:212
Player * ToPlayer()
Definition: Object.h:192
Map * GetMap() const
Definition: Object.h:535
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:196
float m_SightDistance
Definition: Creature.h:335
Unit * ToUnit()
Definition: Object.h:200
CinematicMgr * GetCinematicMgr() const
Definition: Player.h:1420
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSpellMaxRangeForTarget()

float WorldObject::GetSpellMaxRangeForTarget ( Unit const *  target,
SpellInfo const *  spellInfo 
) const
2107 {
2108  if (!spellInfo->RangeEntry)
2109  return 0.f;
2110 
2111  if (spellInfo->RangeEntry->RangeMax[0] == spellInfo->RangeEntry->RangeMax[1])
2112  return spellInfo->GetMaxRange();
2113 
2114  if (!target)
2115  return spellInfo->GetMaxRange(true);
2116 
2117  return spellInfo->GetMaxRange(!IsHostileTo(target));
2118 }
bool IsHostileTo(WorldObject const *target) const
Definition: Object.cpp:2595
+ 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
2121 {
2122  if (!spellInfo->RangeEntry)
2123  return 0.f;
2124 
2125  if (spellInfo->RangeEntry->RangeMin[0] == spellInfo->RangeEntry->RangeMin[1])
2126  return spellInfo->GetMinRange();
2127 
2128  if (!target)
2129  return spellInfo->GetMinRange(true);
2130 
2131  return spellInfo->GetMinRange(!IsHostileTo(target));
2132 }
bool IsHostileTo(WorldObject const *target) const
Definition: Object.cpp:2595
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSpellModOwner()

Player * WorldObject::GetSpellModOwner ( ) const
2074 {
2075  if (Player* player = const_cast<WorldObject*>(this)->ToPlayer())
2076  return player;
2077 
2078  if (GetTypeId() == TYPEID_UNIT)
2079  {
2080  Creature const* creature = ToCreature();
2081  if (creature->IsPet() || creature->IsTotem())
2082  {
2083  if (Unit* owner = creature->GetOwner())
2084  return owner->ToPlayer();
2085  }
2086  }
2087  else if (GetTypeId() == TYPEID_GAMEOBJECT)
2088  {
2089  GameObject const* go = ToGameObject();
2090  if (Unit* owner = go->GetOwner())
2091  return owner->ToPlayer();
2092  }
2093 
2094  return nullptr;
2095 }
bool IsTotem() const
Definition: Unit.h:840
TypeID GetTypeId() const
Definition: Object.h:167
Definition: ObjectGuid.h:39
Definition: Creature.h:61
GameObject * ToGameObject()
Definition: Object.h:204
Player * ToPlayer()
Definition: Object.h:192
Unit * GetOwner() const
Definition: Object.cpp:2030
bool IsPet() const
Definition: Unit.h:838
Definition: ObjectGuid.h:42
Definition: GameObject.h:81
Creature * ToCreature()
Definition: Object.h:196
Definition: Unit.h:736
Definition: Player.h:1056
+ 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, and Conversation.

663 { return GetOrientation(); }
float GetOrientation() const
Definition: Position.h:104

◆ GetStationaryX()

virtual float WorldObject::GetStationaryX ( ) const
inlinevirtual

Reimplemented in GameObject, and Conversation.

660 { return GetPositionX(); }
float GetPositionX() const
Definition: Position.h:101

◆ GetStationaryY()

virtual float WorldObject::GetStationaryY ( ) const
inlinevirtual

Reimplemented in GameObject, and Conversation.

661 { return GetPositionY(); }
float GetPositionY() const
Definition: Position.h:102

◆ GetStationaryZ()

virtual float WorldObject::GetStationaryZ ( ) const
inlinevirtual

Reimplemented in GameObject, and Conversation.

662 { return GetPositionZ(); }
float GetPositionZ() const
Definition: Position.h:103

◆ GetSuppressedPhaseShift() [1/2]

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

◆ GetSuppressedPhaseShift() [2/2]

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

◆ GetTransGUID()

ObjectGuid WorldObject::GetTransGUID ( ) const
virtual

Reimplemented in Unit.

3311 {
3312  if (GetTransport())
3313  return GetTransport()->GetGUID();
3314  return ObjectGuid::Empty;
3315 }
Transport * GetTransport() const
Definition: Object.h:647
static ObjectGuid const Empty
Definition: ObjectGuid.h:255
ObjectGuid const & GetGUID() const
Definition: Object.h:154
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetTransOffset()

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

◆ GetTransOffsetO()

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

◆ GetTransOffsetX()

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

◆ GetTransOffsetY()

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

◆ GetTransOffsetZ()

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

◆ GetTransport()

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

◆ GetTransSeat()

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

◆ GetTransTime()

uint32 WorldObject::GetTransTime ( ) const
inline
653 { return m_movementInfo.transport.time; }
MovementInfo m_movementInfo
Definition: Object.h:658
struct MovementInfo::TransportInfo transport
uint32 time
Definition: MovementInfo.h:51

◆ GetVisibilityRange()

float WorldObject::GetVisibilityRange ( ) const
1377 {
1378  if (IsVisibilityOverridden() && !ToPlayer())
1380  else if (IsFarVisible() && !ToPlayer())
1381  return MAX_VISIBILITY_DISTANCE;
1382  else
1383  return GetMap()->GetVisibilityRange();
1384 }
bool IsFarVisible() const
Definition: Object.h:636
float GetVisibilityRange() const
Definition: Map.h:279
bool IsVisibilityOverridden() const
Definition: Object.h:638
Player * ToPlayer()
Definition: Object.h:192
Map * GetMap() const
Definition: Object.h:535
Optional< float > m_visibilityDistanceOverride
Definition: Object.h:688
#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
461 { zoneid = m_zoneId, areaid = m_areaId; }
uint32 m_zoneId
Definition: Object.h:696
uint32 m_areaId
Definition: Object.h:697
+ Here is the caller graph for this function:

◆ GetZoneId()

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

◆ GetZoneScript()

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

◆ InSamePhase()

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

◆ isActiveObject()

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

◆ IsAlwaysDetectableFor()

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

Reimplemented in Player, and Unit.

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

◆ IsAlwaysVisibleFor()

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

Reimplemented in Unit, and GameObject.

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

◆ IsFarVisible()

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

◆ IsFriendlyTo()

bool WorldObject::IsFriendlyTo ( WorldObject const *  target) const
2601 {
2602  return GetReactionTo(target) >= REP_FRIENDLY;
2603 }
ReputationRank GetReactionTo(WorldObject const *target) const
Definition: Object.cpp:2461
Definition: SharedDefines.h:190
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsHostileTo()

bool WorldObject::IsHostileTo ( WorldObject const *  target) const
2596 {
2597  return GetReactionTo(target) <= REP_HOSTILE;
2598 }
ReputationRank GetReactionTo(WorldObject const *target) const
Definition: Object.cpp:2461
Definition: SharedDefines.h:187
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsHostileToPlayers()

bool WorldObject::IsHostileToPlayers ( ) const
2606 {
2607  FactionTemplateEntry const* my_faction = GetFactionTemplateEntry();
2608  if (!my_faction->Faction)
2609  return false;
2610 
2611  FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->Faction);
2612  if (raw_faction && raw_faction->ReputationIndex >= 0)
2613  return false;
2614 
2615  return my_faction->IsHostileToPlayers();
2616 }
int16 ReputationIndex
Definition: DB2Structure.h:1406
Definition: DB2Structure.h:1428
Definition: DB2Structure.h:1400
uint16 Faction
Definition: DB2Structure.h:1431
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Object.cpp:2442
bool IsHostileToPlayers() const
Definition: DB2Structure.h:1472
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
1274 {
1275  return !HasInArc(2 * float(M_PI) - arc, target);
1276 }
bool HasInArc(float arcangle, Position const *pos, float border=2.0f, Optional< float > orientation=Optional< float >()) const
Definition: Position.cpp:157
#define M_PI
Definition: Common.h:134
+ 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
1252 {
1253  float dist = GetExactDist2d(pos1);
1254 
1255  // not using sqrt() for performance
1256  if ((dist * dist) >= pos1.GetExactDist2dSq(pos2))
1257  return false;
1258 
1259  if (!size)
1260  size = GetCombatReach() / 2;
1261 
1262  float angle = pos1.GetAngle(pos2);
1263 
1264  // not using sqrt() for performance
1265  return (size * size) >= GetExactDist2dSq(pos1.GetPositionX() + std::cos(angle) * dist, pos1.GetPositionY() + std::sin(angle) * dist);
1266 }
virtual float GetCombatReach() const
Definition: Object.h:432
constexpr auto size(const C &c)
Definition: advstd.h:89
float GetExactDist2dSq(const float x, const float y) const
Definition: Position.h:134
float GetExactDist2d(const float x, const float y) const
Definition: Position.cpp:47
+ 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
500 { return obj1 && obj2 && IsInBetween(obj1->GetPosition(), obj2->GetPosition(), size); }
bool IsInBetween(Position const &pos1, Position const &pos2, float size=0) const
Definition: Object.cpp:1251
constexpr auto size(const C &c)
Definition: advstd.h:89
+ 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
1269 {
1270  return HasInArc(arc, target);
1271 }
bool HasInArc(float arcangle, Position const *pos, float border=2.0f, Optional< float > orientation=Optional< float >()) const
Definition: Position.cpp:157
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInMap()

bool WorldObject::IsInMap ( WorldObject const *  obj) const
1063 {
1064  if (obj)
1065  return IsInWorld() && obj->IsInWorld() && (GetMap() == obj->GetMap());
1066  return false;
1067 }
bool IsInWorld() const
Definition: Object.h:149
Map * GetMap() const
Definition: Object.h:535
+ 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
442  {
443  return GetPhaseShift().CanSee(obj->GetPhaseShift());
444  }
PhaseShift & GetPhaseShift()
Definition: Object.h:450
bool CanSee(PhaseShift const &other) const
Definition: PhaseShift.cpp:101
+ 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
1186 {
1187  float dx = GetPositionX() - obj->GetPositionX();
1188  float dy = GetPositionY() - obj->GetPositionY();
1189  float distsq = dx*dx + dy*dy;
1190  if (is3D)
1191  {
1192  float dz = GetPositionZ() - obj->GetPositionZ();
1193  distsq += dz*dz;
1194  }
1195 
1196  float sizefactor = GetCombatReach() + obj->GetCombatReach();
1197 
1198  // check only for real range
1199  if (minRange > 0.0f)
1200  {
1201  float mindist = minRange + sizefactor;
1202  if (distsq < mindist * mindist)
1203  return false;
1204  }
1205 
1206  float maxdist = maxRange + sizefactor;
1207  return distsq < maxdist * maxdist;
1208 }
virtual float GetCombatReach() const
Definition: Object.h:432
float GetPositionY() const
Definition: Position.h:102
float GetPositionZ() const
Definition: Position.h:103
float GetPositionX() const
Definition: Position.h:101
+ 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
1211 {
1212  float dx = GetPositionX() - x;
1213  float dy = GetPositionY() - y;
1214  float distsq = dx*dx + dy*dy;
1215 
1216  float sizefactor = GetCombatReach();
1217 
1218  // check only for real range
1219  if (minRange > 0.0f)
1220  {
1221  float mindist = minRange + sizefactor;
1222  if (distsq < mindist * mindist)
1223  return false;
1224  }
1225 
1226  float maxdist = maxRange + sizefactor;
1227  return distsq < maxdist * maxdist;
1228 }
virtual float GetCombatReach() const
Definition: Object.h:432
float GetPositionY() const
Definition: Position.h:102
float GetPositionX() const
Definition: Position.h:101
+ Here is the call graph for this function:

◆ IsInRange3d()

bool WorldObject::IsInRange3d ( float  x,
float  y,
float  z,
float  minRange,
float  maxRange 
) const
1231 {
1232  float dx = GetPositionX() - x;
1233  float dy = GetPositionY() - y;
1234  float dz = GetPositionZ() - z;
1235  float distsq = dx*dx + dy*dy + dz*dz;
1236 
1237  float sizefactor = GetCombatReach();
1238 
1239  // check only for real range
1240  if (minRange > 0.0f)
1241  {
1242  float mindist = minRange + sizefactor;
1243  if (distsq < mindist * mindist)
1244  return false;
1245  }
1246 
1247  float maxdist = maxRange + sizefactor;
1248  return distsq < maxdist * maxdist;
1249 }
virtual float GetCombatReach() const
Definition: Object.h:432
float GetPositionY() const
Definition: Position.h:102
float GetPositionZ() const
Definition: Position.h:103
float GetPositionX() const
Definition: Position.h:101
+ Here is the call graph for this function:

◆ IsInvisibleDueToDespawn()

virtual bool WorldObject::IsInvisibleDueToDespawn ( ) const
inlineprotectedvirtual

Reimplemented in Creature, and GameObject.

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

◆ IsInWorldPvpZone()

bool WorldObject::IsInWorldPvpZone ( ) const
975 {
976  switch (GetZoneId())
977  {
978  case 4197: // Wintergrasp
979  case 5095: // Tol Barad
980  case 6941: // Ashran
981  return true;
982  break;
983  default:
984  return false;
985  break;
986  }
987 }
uint32 GetZoneId() const
Definition: Object.h:459
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isNeedNotify()

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

◆ IsNeutralToAll()

bool WorldObject::IsNeutralToAll ( ) const
2619 {
2620  FactionTemplateEntry const* my_faction = GetFactionTemplateEntry();
2621  if (!my_faction->Faction)
2622  return true;
2623 
2624  FactionEntry const* raw_faction = sFactionStore.LookupEntry(my_faction->Faction);
2625  if (raw_faction && raw_faction->ReputationIndex >= 0)
2626  return false;
2627 
2628  return my_faction->IsNeutralToAll();
2629 }
int16 ReputationIndex
Definition: DB2Structure.h:1406
bool IsNeutralToAll() const
Definition: DB2Structure.h:1473
Definition: DB2Structure.h:1428
Definition: DB2Structure.h:1400
uint16 Faction
Definition: DB2Structure.h:1431
FactionTemplateEntry const * GetFactionTemplateEntry() const
Definition: Object.cpp:2442
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, AreaTrigger, and Conversation.

707 { return !IsInWorld(); }
bool IsInWorld() const
Definition: Object.h:149
+ Here is the caller graph for this function:

◆ IsOutdoors()

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

◆ IsPermanentWorldObject()

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

◆ IsPrivateObject()

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

◆ IsSelfOrInSameMap()

bool WorldObject::IsSelfOrInSameMap ( WorldObject const *  obj) const
1056 {
1057  if (this == obj)
1058  return true;
1059  return IsInMap(obj);
1060 }
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1062
+ Here is the call graph for this function:

◆ IsValidAssistTarget()

bool WorldObject::IsValidAssistTarget ( WorldObject const *  target,
SpellInfo const *  bySpell = nullptr 
) const
2808 {
2809  ASSERT(target);
2810 
2811  // some negative spells can be casted at friendly target
2812  bool isNegativeSpell = bySpell && !bySpell->IsPositive();
2813 
2814  // can assist to self
2815  if (this == target)
2816  return true;
2817 
2818  // can't assist unattackable units
2819  Unit const* unitTarget = target->ToUnit();
2820  if (unitTarget && unitTarget->HasUnitState(UNIT_STATE_UNATTACKABLE))
2821  return false;
2822 
2823  // can't assist GMs
2824  if (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())
2825  return false;
2826 
2827  // can't assist own vehicle or passenger
2828  Unit const* unit = ToUnit();
2829  if (unit && unitTarget && unit->GetVehicle())
2830  {
2831  if (unit->IsOnVehicle(unitTarget))
2832  return false;
2833 
2834  if (unit->GetVehicleBase()->IsOnVehicle(unitTarget))
2835  return false;
2836  }
2837 
2838  // can't assist invisible
2839  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE)) && !CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea()))
2840  return false;
2841 
2842  // can't assist dead
2843  if ((!bySpell || !bySpell->IsAllowingDeadTarget()) && unitTarget && !unitTarget->IsAlive())
2844  return false;
2845 
2846  // can't assist untargetable
2847  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE))
2848  return false;
2849 
2850  // check flags for negative spells
2852  return false;
2853 
2854  if (isNegativeSpell || !bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
2855  {
2856  if (unit && unit->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE))
2857  {
2858  if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR8_ATTACK_IGNORE_IMMUNE_TO_PC_FLAG))
2859  if (unitTarget && unitTarget->IsImmuneToPC())
2860  return false;
2861  }
2862  else
2863  {
2864  if (unitTarget && unitTarget->IsImmuneToNPC())
2865  return false;
2866  }
2867  }
2868 
2869  // can't assist non-friendly targets
2870  if (GetReactionTo(target) < REP_NEUTRAL && target->GetReactionTo(this) < REP_NEUTRAL && (!ToCreature() || !(ToCreature()->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT)))
2871  return false;
2872 
2873  // PvP case
2874  if (unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE))
2875  {
2876  Player const* targetPlayerOwner = target->GetAffectingPlayer();
2877  if (unit && unit->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE))
2878  {
2879  Player const* selfPlayerOwner = GetAffectingPlayer();
2880  if (selfPlayerOwner && targetPlayerOwner)
2881  {
2882  // can't assist player which is dueling someone
2883  if (selfPlayerOwner != targetPlayerOwner && targetPlayerOwner->duel)
2884  return false;
2885  }
2886  // can't assist player in ffa_pvp zone from outside
2887  if (unitTarget->IsFFAPvP() && unit && !unit->IsFFAPvP())
2888  return false;
2889 
2890  // can't assist player out of sanctuary from sanctuary if has pvp enabled
2891  if (unitTarget->IsPvP())
2892  if (unit && unit->IsInSanctuary() && !unitTarget->IsInSanctuary())
2893  return false;
2894  }
2895  }
2896  // PvC case - player can assist creature only if has specific type flags
2897  // !target->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE) &&
2898  else if (unit && unit->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE))
2899  {
2900  if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG))
2901  if (unitTarget && !unitTarget->IsPvP())
2902  if (Creature const* creatureTarget = target->ToCreature())
2903  return ((creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT) || (creatureTarget->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_CAN_ASSIST));
2904  }
2905 
2906  return true;
2907 }
bool IsPvP() const
Definition: Unit.h:960
Definition: UnitDefines.h:144
DuelInfo * duel
Definition: Player.h:1864
Unit * GetVehicleBase() const
Definition: Unit.cpp:11176
ReputationRank GetReactionTo(WorldObject const *target) const
Definition: Object.cpp:2461
Player * GetAffectingPlayer() const
Definition: Object.cpp:2062
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:187
Definition: Creature.h:61
Definition: UnitDefines.h:135
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1435
Vehicle * GetVehicle() const
Definition: Unit.h:1749
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:925
Definition: SharedDefines.h:189
bool IsInSanctuary() const
Definition: Unit.h:959
Definition: UnitDefines.h:120
Definition: UnitDefines.h:126
UnitFlags
Definition: UnitDefines.h:117
Definition: SharedDefines.h:595
bool IsAlive() const
Definition: Unit.h:1217
Definition: SharedDefines.h:4429
Definition: UnitDefines.h:122
bool HasUnitState(const uint32 f) const
Definition: Unit.h:830
bool IsImmuneToNPC() const
Definition: Unit.h:1104
Definition: SharedDefines.h:4443
Definition: SharedDefines.h:616
Definition: UnitDefines.h:139
Definition: SharedDefines.h:605
bool IsImmuneToPC() const
Definition: Unit.h:1101
Definition: ObjectGuid.h:40
Definition: SharedDefines.h:695
Creature * ToCreature()
Definition: Object.h:196
bool IsOnVehicle(Unit const *vehicle) const
Definition: Unit.cpp:11171
#define ASSERT
Definition: Errors.h:57
Definition: Unit.h:272
Definition: Unit.h:736
Definition: Player.h:1056
Unit * ToUnit()
Definition: Object.h:200
bool IsFFAPvP() const
Definition: Unit.h:961
uint32 type_flags
Definition: CreatureData.h:407
+ 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
2675 {
2676  ASSERT(target);
2677 
2678  // some positive spells can be casted at hostile target
2679  bool isPositiveSpell = bySpell && bySpell->IsPositive();
2680 
2681  // can't attack self (spells can, attribute check)
2682  if (!bySpell && this == target)
2683  return false;
2684 
2685  // can't attack unattackable units
2686  Unit const* unitTarget = target->ToUnit();
2687  if (unitTarget && unitTarget->HasUnitState(UNIT_STATE_UNATTACKABLE))
2688  return false;
2689 
2690  // can't attack GMs
2691  if (target->GetTypeId() == TYPEID_PLAYER && target->ToPlayer()->IsGameMaster())
2692  return false;
2693 
2694  Unit const* unit = ToUnit();
2695  // visibility checks (only units)
2696  if (unit)
2697  {
2698  // can't attack invisible
2699  if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_INVISIBLE))
2700  {
2701  if (!unit->CanSeeOrDetect(target, bySpell && bySpell->IsAffectingArea()))
2702  return false;
2703  }
2704  }
2705 
2706  // can't attack dead
2707  if ((!bySpell || !bySpell->IsAllowingDeadTarget()) && unitTarget && !unitTarget->IsAlive())
2708  return false;
2709 
2710  // can't attack untargetable
2711  if ((!bySpell || !bySpell->HasAttribute(SPELL_ATTR6_CAN_TARGET_UNTARGETABLE)) && unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_NOT_SELECTABLE))
2712  return false;
2713 
2714  if (Player const* playerAttacker = ToPlayer())
2715  {
2716  if (playerAttacker->HasPlayerFlag(PLAYER_FLAGS_UBER))
2717  return false;
2718  }
2719 
2720  // check flags
2722  return false;
2723 
2724  // ignore immunity flags when assisting
2725  if (!bySpell || (isPositiveSpell && !bySpell->HasAttribute(SPELL_ATTR6_ASSIST_IGNORE_IMMUNE_FLAG)))
2726  {
2727  if (unit && !unit->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE) && unitTarget && unitTarget->IsImmuneToNPC())
2728  return false;
2729 
2730  if (unitTarget && !unitTarget->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE) && unit && unit->IsImmuneToNPC())
2731  return false;
2732 
2733  if (!bySpell || !bySpell->HasAttribute(SPELL_ATTR8_ATTACK_IGNORE_IMMUNE_TO_PC_FLAG))
2734  {
2735  if (unit && unit->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE) && unitTarget && unitTarget->IsImmuneToPC())
2736  return false;
2737 
2738  if (unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE) && unit && unit->IsImmuneToPC())
2739  return false;
2740  }
2741  }
2742 
2743  // CvC case - can attack each other only when one of them is hostile
2744  if (unit && !unit->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE) && unitTarget && !unitTarget->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE))
2745  return IsHostileTo(target) || target->IsHostileTo(this);
2746 
2747  // PvP, PvC, CvP case
2748  // can't attack friendly targets
2749  if (IsFriendlyTo(target) || target->IsFriendlyTo(this))
2750  return false;
2751 
2752  Player const* playerAffectingAttacker = unit && unit->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE) ? GetAffectingPlayer() : nullptr;
2753  Player const* playerAffectingTarget = unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE) ? target->GetAffectingPlayer() : nullptr;
2754 
2755  // Not all neutral creatures can be attacked (even some unfriendly faction does not react aggresive to you, like Sporaggar)
2756  if ((playerAffectingAttacker && !playerAffectingTarget) || (!playerAffectingAttacker && playerAffectingTarget))
2757  {
2758  Player const* player = playerAffectingAttacker ? playerAffectingAttacker : playerAffectingTarget;
2759 
2760  if (Unit const* creature = playerAffectingAttacker ? unitTarget : unit)
2761  {
2762  if (creature->IsContestedGuard() && player->HasPlayerFlag(PLAYER_FLAGS_CONTESTED_PVP))
2763  return true;
2764 
2765  if (FactionTemplateEntry const* factionTemplate = creature->GetFactionTemplateEntry())
2766  {
2767  if (!(player->GetReputationMgr().GetForcedRankIfAny(factionTemplate)))
2768  if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->Faction))
2769  if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry))
2770  if (!repState->Flags.HasFlag(ReputationFlags::AtWar))
2771  return false;
2772 
2773  }
2774  }
2775  }
2776 
2777  Creature const* creatureAttacker = ToCreature();
2778  if (creatureAttacker && (creatureAttacker->GetCreatureTemplate()->type_flags & CREATURE_TYPE_FLAG_TREAT_AS_RAID_UNIT))
2779  return false;
2780 
2781  if (playerAffectingAttacker && playerAffectingTarget)
2782  if (playerAffectingAttacker->duel && playerAffectingAttacker->duel->opponent == playerAffectingTarget && playerAffectingAttacker->duel->startTime != 0)
2783  return true;
2784 
2785  // PvP case - can't attack when attacker or target are in sanctuary
2786  // however, 13850 client doesn't allow to attack when one of the unit's has sanctuary flag and is pvp
2787  if (unitTarget && unitTarget->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE) && unit && unit->HasUnitFlag(UNIT_FLAG_PVP_ATTACKABLE) && (unitTarget->IsInSanctuary() || unit->IsInSanctuary()))
2788  return false;
2789 
2790  // additional checks - only PvP case
2791  if (playerAffectingAttacker && playerAffectingTarget)
2792  {
2793  if (unitTarget->IsPvP())
2794  return true;
2795 
2796  if (unit->IsFFAPvP() && unitTarget->IsFFAPvP())
2797  return true;
2798 
2799  return unit->HasPvpFlag(UNIT_BYTE2_FLAG_UNK1) ||
2800  unitTarget->HasPvpFlag(UNIT_BYTE2_FLAG_UNK1);
2801  }
2802 
2803  return true;
2804 }
bool IsPvP() const
Definition: Unit.h:960
Definition: Player.h:430
ReputationRank const * GetForcedRankIfAny(FactionTemplateEntry const *factionTemplateEntry) const
Definition: ReputationMgr.cpp:214
Definition: UnitDefines.h:84
time_t startTime
Definition: Player.h:362
Definition: UnitDefines.h:144
DuelInfo * duel
Definition: Player.h:1864
Player * GetAffectingPlayer() const
Definition: Object.cpp:2062
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:187
Definition: Creature.h:61
bool HasPlayerFlag(PlayerFlags flags) const
Definition: Player.h:2573
Definition: UnitDefines.h:135
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1435
FactionState const * GetState(FactionEntry const *factionEntry) const
Definition: ReputationMgr.cpp:85
bool HasUnitFlag(UnitFlags flags) const
Definition: Unit.h:925
bool IsInSanctuary() const
Definition: Unit.h:959
Player * ToPlayer()
Definition: Object.h:192
Definition: UnitDefines.h:120
bool HasPvpFlag(UnitPVPStateFlags flags) const
Definition: Unit.h:955
Definition: UnitDefines.h:126
UnitFlags
Definition: UnitDefines.h:117
Definition: SharedDefines.h:595
bool IsAlive() const
Definition: Unit.h:1217
Definition: UnitDefines.h:122
bool HasUnitState(const uint32 f) const
Definition: Unit.h:830
bool IsImmuneToNPC() const
Definition: Unit.h:1104
Definition: SharedDefines.h:4443
Definition: SharedDefines.h:616
Definition: UnitDefines.h:139
Definition: SharedDefines.h:605
Definition: DB2Structure.h:1428
ReputationMgr & GetReputationMgr()
Definition: Player.h:2119
Definition: DB2Structure.h:1400
bool IsFriendlyTo(WorldObject const *target) const
Definition: Object.cpp:2600
bool IsImmuneToPC() const
Definition: Unit.h:1101
Definition: ObjectGuid.h:40
Definition: SharedDefines.h:695
Creature * ToCreature()
Definition: Object.h:196
Player * opponent
Definition: Player.h:360
DB2Storage< FactionEntry > sFactionStore("Faction.db2", FactionLoadInfo::Instance())
#define ASSERT
Definition: Errors.h:57
bool IsHostileTo(WorldObject const *target) const
Definition: Object.cpp:2595
Definition: Player.h:441
Definition: Unit.h:272
Definition: Unit.h:736
Definition: Player.h:1056
Definition: ReputationMgr.h:53
Unit * ToUnit()
Definition: Object.h:200
bool IsFFAPvP() const
Definition: Unit.h:961
uint32 type_flags
Definition: CreatureData.h:407
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsVisibilityOverridden()

bool WorldObject::IsVisibilityOverridden ( ) const
inline
638 { return m_visibilityDistanceOverride.is_initialized(); }
Optional< float > m_visibilityDistanceOverride
Definition: Object.h:688
+ 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
1090 {
1091  return obj && _IsWithinDist(obj, dist2compare, is3D);
1092 }
virtual bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1003
+ 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
1080 {
1081  return IsInDist2d(x, y, dist + GetCombatReach());
1082 }
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:199
virtual float GetCombatReach() const
Definition: Object.h:432
+ 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
1085 {
1086  return IsInDist2d(pos, dist + GetCombatReach());
1087 }
bool IsInDist2d(float x, float y, float dist) const
Definition: Position.h:199
virtual float GetCombatReach() const
Definition: Object.h:432
+ Here is the call graph for this function:

◆ IsWithinDist3d() [1/2]

bool WorldObject::IsWithinDist3d ( float  x,
float  y,
float  z,
float  dist 
) const
1070 {
1071  return IsInDist(x, y, z, dist + GetCombatReach());
1072 }
bool IsInDist(float x, float y, float z, float dist) const
Definition: Position.h:209
virtual float GetCombatReach() const
Definition: Object.h:432
+ 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
1075 {
1076  return IsInDist(pos, dist + GetCombatReach());
1077 }
bool IsInDist(float x, float y, float z, float dist) const
Definition: Position.h:209
virtual float GetCombatReach() const
Definition: Object.h:432
+ 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
1095 {
1096  return obj && IsInMap(obj) && IsInPhase(obj) && _IsWithinDist(obj, dist2compare, is3D, incOwnRadius, incTargetRadius);
1097 }
bool IsInPhase(WorldObject const *obj) const
Definition: Object.h:441
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1062
virtual bool _IsWithinDist(WorldObject const *obj, float dist2compare, bool is3D, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition: Object.cpp:1003
+ 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
1109 {
1110  if (IsInWorld())
1111  {
1112  oz += GetCollisionHeight();
1113  float x, y, z;
1114  if (GetTypeId() == TYPEID_PLAYER)
1115  {
1116  GetPosition(x, y, z);
1117  z += GetCollisionHeight();
1118  }
1119  else
1120  GetHitSpherePointFor({ ox, oy, oz }, x, y, z);
1121 
1122  return GetMap()->isInLineOfSight(GetPhaseShift(), x, y, z, ox, oy, oz, checks, ignoreFlags);
1123  }
1124 
1125  return true;
1126 }
TypeID GetTypeId() const
Definition: Object.h:167
Position GetPosition() const
Definition: Position.h:121
virtual float GetCollisionHeight() const
Definition: Object.h:666
bool IsInWorld() const
Definition: Object.h:149
Map * GetMap() const
Definition: Object.h:535
PhaseShift & GetPhaseShift()
Definition: Object.h:450
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:2897
Definition: ObjectGuid.h:40
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1099
+ 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
1129 {
1130  if (!IsInMap(obj))
1131  return false;
1132 
1133  float ox, oy, oz;
1134  if (obj->GetTypeId() == TYPEID_PLAYER)
1135  {
1136  obj->GetPosition(ox, oy, oz);
1137  oz += GetCollisionHeight();
1138  }
1139  else
1140  obj->GetHitSpherePointFor({ GetPositionX(), GetPositionY(), GetPositionZ() + GetCollisionHeight() }, ox, oy, oz);
1141 
1142  float x, y, z;
1143  if (GetTypeId() == TYPEID_PLAYER)
1144  {
1145  GetPosition(x, y, z);
1146  z += GetCollisionHeight();
1147  }
1148  else
1149  GetHitSpherePointFor({ obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ() + obj->GetCollisionHeight() }, x, y, z);
1150 
1151  return GetMap()->isInLineOfSight(GetPhaseShift(), x, y, z, ox, oy, oz, checks, ignoreFlags);
1152 }
TypeID GetTypeId() const
Definition: Object.h:167
Position GetPosition() const
Definition: Position.h:121
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1062
virtual float GetCollisionHeight() const
Definition: Object.h:666
float GetPositionY() const
Definition: Position.h:102
Map * GetMap() const
Definition: Object.h:535
PhaseShift & GetPhaseShift()
Definition: Object.h:450
float GetPositionZ() const
Definition: Position.h:103
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:2897
float GetPositionX() const
Definition: Position.h:101
Definition: ObjectGuid.h:40
Position GetHitSpherePointFor(Position const &dest) const
Definition: Object.cpp:1099
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsWorldObject()

bool WorldObject::IsWorldObject ( ) const
872 {
873  if (m_isWorldObject)
874  return true;
875 
876  if (ToCreature() && ToCreature()->m_isTempWorldObject)
877  return true;
878 
879  return false;
880 }
Creature * ToCreature()
Definition: Object.h:196
bool const m_isWorldObject
Definition: Object.h:689
+ 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
2300 {
2301  // Can`t miss on dead target (on skinning for example)
2302  if (!victim->IsAlive() && victim->GetTypeId() != TYPEID_PLAYER)
2303  return SPELL_MISS_NONE;
2304 
2305  SpellSchoolMask schoolMask = spellInfo->GetSchoolMask();
2306  // PvP - PvE spell misschances per leveldif > 2
2307  int32 lchance = victim->GetTypeId() == TYPEID_PLAYER ? 7 : 11;
2308  int32 thisLevel = GetLevelForTarget(victim);
2309  if (GetTypeId() == TYPEID_UNIT && ToCreature()->IsTrigger())
2310  thisLevel = std::max<int32>(thisLevel, spellInfo->SpellLevel);
2311  int32 leveldif = int32(victim->GetLevelForTarget(this)) - thisLevel;
2312  int32 levelBasedHitDiff = leveldif;
2313 
2314  // Base hit chance from attacker and victim levels
2315  int32 modHitChance = 100;
2316  if (levelBasedHitDiff >= 0)
2317  {
2318  if (victim->GetTypeId() != TYPEID_PLAYER)
2319  {
2320  modHitChance = 94 - 3 * std::min(levelBasedHitDiff, 3);
2321  levelBasedHitDiff -= 3;
2322  }
2323  else
2324  {
2325  modHitChance = 96 - std::min(levelBasedHitDiff, 2);
2326  levelBasedHitDiff -= 2;
2327  }
2328  if (levelBasedHitDiff > 0)
2329  modHitChance -= lchance * std::min(levelBasedHitDiff, 7);
2330  }
2331  else
2332  modHitChance = 97 - levelBasedHitDiff;
2333 
2334  // Spellmod from SpellModOp::HitChance
2335  if (Player* modOwner = GetSpellModOwner())
2336  modOwner->ApplySpellMod(spellInfo, SpellModOp::HitChance, modHitChance);
2337 
2338  // Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will ignore target's avoidance effects
2339  if (!spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
2340  {
2341  // Chance hit from victim SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE auras
2342  modHitChance += victim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_HIT_CHANCE, schoolMask);
2343  }
2344 
2345  int32 HitChance = modHitChance * 100;
2346  // Increase hit chance from attacker SPELL_AURA_MOD_SPELL_HIT_CHANCE and attacker ratings
2347  if (Unit const* unit = ToUnit())
2348  HitChance += int32(unit->m_modSpellHitChance * 100.0f);
2349 
2350  RoundToInterval(HitChance, 0, 10000);
2351 
2352  int32 tmp = 10000 - HitChance;
2353 
2354  int32 rand = irand(0, 9999);
2355  if (tmp > 0 && rand < tmp)
2356  return SPELL_MISS_MISS;
2357 
2358  // Chance resist mechanic (select max value from every mechanic spell effect)
2359  int32 resist_chance = victim->GetMechanicResistChance(spellInfo) * 100;
2360 
2361  // Roll chance
2362  if (resist_chance > 0 && rand < (tmp += resist_chance))
2363  return SPELL_MISS_RESIST;
2364 
2365  // cast by caster in front of victim
2366  if (!victim->HasUnitState(UNIT_STATE_CONTROLLED) && (victim->HasInArc(float(M_PI), this) || victim->HasAuraType(SPELL_AURA_IGNORE_HIT_DIRECTION)))
2367  {
2368  int32 deflect_chance = victim->GetTotalAuraModifier(SPELL_AURA_DEFLECT_SPELLS) * 100;
2369  if (deflect_chance > 0 && rand < (tmp += deflect_chance))
2370  return SPELL_MISS_DEFLECT;
2371  }
2372 
2373  return SPELL_MISS_NONE;
2374 }
TypeID GetTypeId() const
Definition: Object.h:167
T RoundToInterval(T &num, T floor, T ceil)
Definition: Util.h:95
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4676
bool HasInArc(float arcangle, Position const *pos, float border=2.0f, Optional< float > orientation=Optional< float >()) const
Definition: Position.cpp:157
virtual uint8 GetLevelForTarget(WorldObject const *) const
Definition: Object.h:510
Definition: ObjectGuid.h:39
Definition: SharedDefines.h:2574
Definition: SpellAuraDefines.h:376
#define M_PI
Definition: Common.h:134
SpellSchoolMask
Definition: SharedDefines.h:303
Definition: SharedDefines.h:2575
bool IsAlive() const
Definition: Unit.h:1217
bool HasUnitState(const uint32 f) const
Definition: Unit.h:830
int32_t int32
Definition: Define.h:148
Definition: SpellAuraDefines.h:274
Definition: SharedDefines.h:2582
int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const
Definition: Unit.cpp:4696
int32 GetMechanicResistChance(SpellInfo const *spellInfo) const
Definition: Unit.cpp:2331
Definition: SharedDefines.h:2573
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4428
Definition: ObjectGuid.h:40
Creature * ToCreature()
Definition: Object.h:196
uint8 GetLevelForTarget(WorldObject const *) const override
Definition: Unit.h:844
int32 irand(int32 min, int32 max)
Definition: Random.cpp:40
Player * GetSpellModOwner() const
Definition: Object.cpp:2073
Definition: SpellAuraDefines.h:375
Definition: Unit.h:274
Definition: Unit.h:736
Definition: Player.h:1056
Definition: SharedDefines.h:502
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MeleeSpellHitResult()

SpellMissInfo WorldObject::MeleeSpellHitResult ( Unit victim,
SpellInfo const *  spellInfo 
) const
virtual

Reimplemented in Unit.

2295 {
2296  return SPELL_MISS_NONE;
2297 }
Definition: SharedDefines.h:2573
+ Here is the caller graph for this function:

◆ MeleeSpellMissChance()

float WorldObject::MeleeSpellMissChance ( Unit const *  victim,
WeaponAttackType  attType,
SpellInfo const *  spellInfo 
) const
virtual

Reimplemented in Unit.

2290 {
2291  return 0.0f;
2292 }

◆ ModSpellCastTime()

void WorldObject::ModSpellCastTime ( SpellInfo const *  spellInfo,
int32 castTime,
Spell spell = nullptr 
) const
2245 {
2246  if (!spellInfo || castTime < 0)
2247  return;
2248 
2249  // called from caster
2250  if (Player* modOwner = GetSpellModOwner())
2251  modOwner->ApplySpellMod(spellInfo, SpellModOp::ChangeCastTime, castTime, spell);
2252 
2253  Unit const* unitCaster = ToUnit();
2254  if (!unitCaster)
2255  return;
2256 
2257  if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) &&
2258  ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT))
2259  castTime = unitCaster->CanInstantCast() ? 0 : int32(float(castTime) * unitCaster->m_unitData->ModCastingSpeed);
2260  else if (spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG))
2261  castTime = int32(float(castTime) * unitCaster->m_modAttackSpeedPct[RANGED_ATTACK]);
2262  else if (IsPartOfSkillLine(SKILL_COOKING, spellInfo->Id) && unitCaster->HasAura(67556)) // cooking with Chef Hat.
2263  castTime = 500;
2264 }
bool CanInstantCast() const
Definition: Unit.h:1802
TypeID GetTypeId() const
Definition: Object.h:167
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4418
Definition: SharedDefines.h:380
Definition: ObjectGuid.h:39
Definition: SharedDefines.h:381
Definition: SharedDefines.h:453
UF::UpdateField< UF::UnitData, 0, TYPEID_UNIT > m_unitData
Definition: Unit.h:1826
int32_t int32
Definition: Define.h:148
Definition: SharedDefines.h:5103
Definition: SharedDefines.h:513
float m_modAttackSpeedPct[MAX_ATTACK]
Definition: Unit.h:1516
Definition: ObjectGuid.h:40
Definition: SharedDefines.h:6343
Player * GetSpellModOwner() const
Definition: Object.cpp:2073
Definition: Unit.h:736
Definition: SharedDefines.h:377
Definition: Player.h:1056
Unit * ToUnit()
Definition: Object.h:200
bool IsPartOfSkillLine(uint32 skillId, uint32 spellId)
Definition: SpellMgr.cpp:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ModSpellDuration()

int32 WorldObject::ModSpellDuration ( SpellInfo const *  spellInfo,
WorldObject const *  target,
int32  duration,
bool  positive,
uint32  effectMask 
) const
2180 {
2181  // don't mod permanent auras duration
2182  if (duration < 0)
2183  return duration;
2184 
2185  // some auras are not affected by duration modifiers
2186  if (spellInfo->HasAttribute(SPELL_ATTR7_IGNORE_DURATION_MODS))
2187  return duration;
2188 
2189  // cut duration only of negative effects
2190  Unit const* unitTarget = target->ToUnit();
2191  if (!unitTarget)
2192  return duration;
2193 
2194  if (!positive)
2195  {
2196  int32 mechanicMask = spellInfo->GetSpellMechanicMaskByEffectMask(effectMask);
2197  auto mechanicCheck = [mechanicMask](AuraEffect const* aurEff) -> bool
2198  {
2199  if (mechanicMask & (1 << aurEff->GetMiscValue()))
2200  return true;
2201  return false;
2202  };
2203 
2204  // Find total mod value (negative bonus)
2205  int32 durationMod_always = unitTarget->GetTotalAuraModifier(SPELL_AURA_MECHANIC_DURATION_MOD, mechanicCheck);
2206  // Find max mod (negative bonus)
2207  int32 durationMod_not_stack = unitTarget->GetMaxNegativeAuraModifier(SPELL_AURA_MECHANIC_DURATION_MOD_NOT_STACK, mechanicCheck);
2208 
2209  // Select strongest negative mod
2210  int32 durationMod = std::min(durationMod_always, durationMod_not_stack);
2211  if (durationMod != 0)
2212  AddPct(duration, durationMod);
2213 
2214  // there are only negative mods currently
2215  durationMod_always = unitTarget->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL, spellInfo->Dispel);
2216  durationMod_not_stack = unitTarget->GetMaxNegativeAuraModifierByMiscValue(SPELL_AURA_MOD_AURA_DURATION_BY_DISPEL_NOT_STACK, spellInfo->Dispel);
2217 
2218  durationMod = std::min(durationMod_always, durationMod_not_stack);
2219  if (durationMod != 0)
2220  AddPct(duration, durationMod);
2221  }
2222  else
2223  {
2224  // else positive mods here, there are no currently
2225  // when there will be, change GetTotalAuraModifierByMiscValue to GetMaxPositiveAuraModifierByMiscValue
2226 
2227  // Mixology - duration boost
2228  if (unitTarget->GetTypeId() == TYPEID_PLAYER)
2229  {
2230  if (spellInfo->SpellFamilyName == SPELLFAMILY_POTION && (
2231  sSpellMgr->IsSpellMemberOfSpellGroup(spellInfo->Id, SPELL_GROUP_ELIXIR_BATTLE) ||
2232  sSpellMgr->IsSpellMemberOfSpellGroup(spellInfo->Id, SPELL_GROUP_ELIXIR_GUARDIAN)))
2233  {
2234  SpellEffectInfo const& effect = spellInfo->GetEffect(EFFECT_0);
2235  if (unitTarget->HasAura(53042) && unitTarget->HasSpell(effect.TriggerSpell))
2236  duration *= 2;
2237  }
2238  }
2239  }
2240 
2241  return std::max(duration, 0);
2242 }
Definition: SpellAuraEffects.h:28
TypeID GetTypeId() const
Definition: Object.h:167
Definition: SharedDefines.h:629
Definition: SpellAuraDefines.h:333
int32 GetTotalAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4676
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint32 reqEffMask=0) const
Definition: Unit.cpp:4418
Definition: SharedDefines.h:6056
Definition: SpellAuraDefines.h:320
Definition: SpellAuraDefines.h:322
uint32 TriggerSpell
Definition: SpellInfo.h:289
Definition: SpellAuraDefines.h:334
int32 GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
Definition: Unit.cpp:4766
virtual bool HasSpell(uint32) const
Definition: Unit.h:1126
#define sSpellMgr
Definition: SpellMgr.h:790
Definition: SpellInfo.h:264
int32_t int32
Definition: Define.h:148
Definition: SpellMgr.h:310
Definition: ObjectGuid.h:40
int32 GetMaxNegativeAuraModifier(AuraType auratype) const
Definition: Unit.cpp:4691
Definition: SharedDefines.h:28
T AddPct(T &base, U pct)
Definition: Util.h:83
Definition: SpellMgr.h:311
Definition: Unit.h:736
int32 GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const
Definition: Unit.cpp:4736
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ModSpellDurationTime()

void WorldObject::ModSpellDurationTime ( SpellInfo const *  spellInfo,
int32 durationTime,
Spell spell = nullptr 
) const
2267 {
2268  if (!spellInfo || duration < 0)
2269  return;
2270 
2271  if (spellInfo->IsChanneled() && !spellInfo->HasAttribute(SPELL_ATTR5_HASTE_AFFECT_DURATION))
2272  return;
2273 
2274  // called from caster
2275  if (Player* modOwner = GetSpellModOwner())
2276  modOwner->ApplySpellMod(spellInfo, SpellModOp::ChangeCastTime, duration, spell);
2277 
2278  Unit const* unitCaster = ToUnit();
2279  if (!unitCaster)
2280  return;
2281 
2282  if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) &&
2283  ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT))
2284  duration = int32(float(duration) * unitCaster->m_unitData->ModCastingSpeed);
2285  else if (spellInfo->HasAttribute(SPELL_ATTR0_REQ_AMMO) && !spellInfo->HasAttribute(SPELL_ATTR2_AUTOREPEAT_FLAG))
2286  duration = int32(float(duration) * unitCaster->m_modAttackSpeedPct[RANGED_ATTACK]);
2287 }
Definition: SharedDefines.h:569
TypeID GetTypeId() const
Definition: Object.h:167
Definition: SharedDefines.h:380
Definition: ObjectGuid.h:39
Definition: SharedDefines.h:381
Definition: SharedDefines.h:453
UF::UpdateField< UF::UnitData, 0, TYPEID_UNIT > m_unitData
Definition: Unit.h:1826
int32_t int32
Definition: Define.h:148
Definition: SharedDefines.h:513
float m_modAttackSpeedPct[MAX_ATTACK]
Definition: Unit.h:1516
Definition: ObjectGuid.h:40
Definition: SharedDefines.h:6343
Player * GetSpellModOwner() const
Definition: Object.cpp:2073
Definition: Unit.h:736
Definition: SharedDefines.h:377
Definition: Player.h:1056
Unit * ToUnit()
Definition: Object.h:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ MovePosition()

void WorldObject::MovePosition ( Position pos,
float  dist,
float  angle 
)
3054 {
3055  angle += GetOrientation();
3056  float destx, desty, destz, ground, floor;
3057  destx = pos.m_positionX + dist * std::cos(angle);
3058  desty = pos.m_positionY + dist * std::sin(angle);
3059 
3060  // Prevent invalid coordinates here, position is unchanged
3061  if (!Trinity::IsValidMapCoord(destx, desty, pos.m_positionZ))
3062  {
3063  TC_LOG_FATAL("misc", "WorldObject::MovePosition: Object (Entry: %u %s) has invalid coordinates X: %f and Y: %f were passed!",
3064  GetEntry(), GetGUID().ToString().c_str(), destx, desty);
3065  return;
3066  }
3067 
3068  ground = GetMapHeight(destx, desty, MAX_HEIGHT);
3069  floor = GetMapHeight(destx, desty, pos.m_positionZ);
3070  destz = std::fabs(ground - pos.m_positionZ) <= std::fabs(floor - pos.m_positionZ) ? ground : floor;
3071 
3072  float step = dist/10.0f;
3073 
3074  for (uint8 j = 0; j < 10; ++j)
3075  {
3076  // do not allow too big z changes
3077  if (std::fabs(pos.m_positionZ - destz) > 6)
3078  {
3079  destx -= step * std::cos(angle);
3080  desty -= step * std::sin(angle);
3081  ground = GetMap()->GetHeight(GetPhaseShift(), destx, desty, MAX_HEIGHT, true);
3082  floor = GetMap()->GetHeight(GetPhaseShift(), destx, desty, pos.m_positionZ, true);
3083  destz = std::fabs(ground - pos.m_positionZ) <= std::fabs(floor - pos.m_positionZ) ? ground : floor;
3084  }
3085  // we have correct destz now
3086  else
3087  {
3088  pos.Relocate(destx, desty, destz);
3089  break;
3090  }