AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
DefaultTargetSelector Struct Reference

#include "UnitAI.h"

Inheritance diagram for DefaultTargetSelector:
Acore::unary_function< Unit *, bool >

Public Member Functions

 DefaultTargetSelector (Unit const *unit, float dist, bool playerOnly, bool withMainTank, int32 aura)
 
bool operator() (Unit const *target) const
 

Public Attributes

Unit const * me
 
float m_dist
 
Unit const * except
 
bool m_playerOnly
 
int32 m_aura
 

Additional Inherited Members

- Public Types inherited from Acore::unary_function< Unit *, bool >
typedef Unitargument_type
 
typedef bool result_type
 

Detailed Description

Constructor & Destructor Documentation

◆ DefaultTargetSelector()

DefaultTargetSelector::DefaultTargetSelector ( Unit const *  unit,
float  dist,
bool  playerOnly,
bool  withMainTank,
int32  aura 
)
inline
55: me(unit), m_dist(dist), except(!withMainTank ? me->GetThreatMgr().GetCurrentVictim() : nullptr), m_playerOnly(playerOnly), m_aura(aura) {}
Unit const * me
Definition: UnitAI.h:44
float m_dist
Definition: UnitAI.h:45
int32 m_aura
Definition: UnitAI.h:48
bool m_playerOnly
Definition: UnitAI.h:47
Unit const * except
Definition: UnitAI.h:46
Unit * GetCurrentVictim() const
Definition: ThreatMgr.h:213
ThreatMgr & GetThreatMgr()
Definition: Unit.h:2157

Member Function Documentation

◆ operator()()

bool DefaultTargetSelector::operator() ( Unit const *  target) const
inline
58 {
59 if (!me)
60 return false;
61
62 if (!target)
63 return false;
64
65 if (target == except)
66 return false;
67
68 if (m_playerOnly && (target->GetTypeId() != TYPEID_PLAYER))
69 return false;
70
71 if (m_dist > 0.0f && !me->IsWithinCombatRange(target, m_dist))
72 return false;
73
74 if (m_dist < 0.0f && me->IsWithinCombatRange(target, -m_dist))
75 return false;
76
77 if (m_aura)
78 {
79 if (m_aura > 0)
80 {
81 if (!target->HasAura(m_aura))
82 return false;
83 }
84 else
85 {
86 if (target->HasAura(-m_aura))
87 return false;
88 }
89 }
90
91 return true;
92 }
@ TYPEID_PLAYER
Definition: ObjectGuid.h:38
bool IsWithinCombatRange(Unit const *obj, float dist2compare) const
Definition: Unit.cpp:667

References except, Object::GetTypeId(), Unit::HasAura(), Unit::IsWithinCombatRange(), m_aura, m_dist, m_playerOnly, me, and TYPEID_PLAYER.

Member Data Documentation

◆ except

Unit const* DefaultTargetSelector::except

Referenced by operator()().

◆ m_aura

int32 DefaultTargetSelector::m_aura

Referenced by operator()().

◆ m_dist

float DefaultTargetSelector::m_dist

Referenced by operator()().

◆ m_playerOnly

bool DefaultTargetSelector::m_playerOnly

Referenced by operator()().

◆ me

Unit const* DefaultTargetSelector::me

Referenced by operator()().