TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Trinity::NearestHostileUnitInAttackDistanceCheck Class Reference

#include <GridNotifiers.h>

Public Member Functions

 NearestHostileUnitInAttackDistanceCheck (Creature const *creature, float dist=0)
 
bool operator() (Unit *u)
 
float GetLastRange () const
 

Private Member Functions

 NearestHostileUnitInAttackDistanceCheck (NearestHostileUnitInAttackDistanceCheck const &)
 

Private Attributes

Creature constme
 
float m_range
 
bool m_force
 

Constructor & Destructor Documentation

Trinity::NearestHostileUnitInAttackDistanceCheck::NearestHostileUnitInAttackDistanceCheck ( Creature const creature,
float  dist = 0 
)
inlineexplicit
1037  : me(creature)
1038  {
1039  m_range = (dist == 0 ? 9999 : dist);
1040  m_force = (dist == 0 ? false : true);
1041  }
bool m_force
Definition: GridNotifiers.h:1065
float m_range
Definition: GridNotifiers.h:1064
Creature const * me
Definition: GridNotifiers.h:1063
Trinity::NearestHostileUnitInAttackDistanceCheck::NearestHostileUnitInAttackDistanceCheck ( NearestHostileUnitInAttackDistanceCheck const )
private

Member Function Documentation

float Trinity::NearestHostileUnitInAttackDistanceCheck::GetLastRange ( ) const
inline
1061 { return m_range; }
float m_range
Definition: GridNotifiers.h:1064
bool Trinity::NearestHostileUnitInAttackDistanceCheck::operator() ( Unit u)
inline
1043  {
1044  if (!me->IsWithinDistInMap(u, m_range))
1045  return false;
1046 
1047  if (!me->CanSeeOrDetect(u))
1048  return false;
1049 
1050  if (m_force)
1051  {
1052  if (!me->IsValidAttackTarget(u))
1053  return false;
1054  }
1055  else if (!me->CanStartAttack(u, false))
1056  return false;
1057 
1058  m_range = me->GetDistance(u); // use found unit range as new range limit for next check
1059  return true;
1060  }
bool IsValidAttackTarget(Unit const *target) const
Definition: Unit.cpp:10002
bool m_force
Definition: GridNotifiers.h:1065
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
float m_range
Definition: GridNotifiers.h:1064
bool CanSeeOrDetect(WorldObject const *obj, bool ignoreStealth=false, bool distanceCheck=false, bool checkAlert=false) const
Definition: Object.cpp:1940
bool CanStartAttack(Unit const *u, bool force) const
Definition: Creature.cpp:1525
Creature const * me
Definition: GridNotifiers.h:1063

+ Here is the call graph for this function:

Member Data Documentation

bool Trinity::NearestHostileUnitInAttackDistanceCheck::m_force
private
float Trinity::NearestHostileUnitInAttackDistanceCheck::m_range
private
Creature const* Trinity::NearestHostileUnitInAttackDistanceCheck::me
private

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