18#ifndef TRINITY_UNITAI_H
19#define TRINITY_UNITAI_H
27#define CAST_AI(a, b) (dynamic_cast<a*>(b))
28#define ENSURE_AI(a,b) (EnsureAI<a>(b))
30template<
class T,
class U>
33 T* cast_ai =
dynamic_cast<T*
>(ai);
67 bool operator()(
Unit const* target)
const;
83 bool operator()(
Unit const* target)
const;
97 bool operator()(
Unit const* target)
const;
109 bool operator()(
Unit const* target)
const;
121 FarthestTargetSelector(
Unit const* unit,
float dist,
bool playerOnly,
bool inLos) : _me(unit), _dist(dist), _playerOnly(playerOnly), _inLos(inLos) {}
122 bool operator()(
Unit const* target)
const;
140 virtual void AttackStart(
Unit* );
143 virtual void InitializeAI();
151 virtual void OnCharmed(
bool isNew);
174 template<
class PREDICATE>
177 std::list<Unit*> targetList;
178 SelectTargetList(targetList, std::numeric_limits<uint32>::max(), targetType, offset, predicate);
180 return FinalizeTargetSelection(targetList, targetType);
193 void SelectTargetList(std::list<Unit*>& targetList,
uint32 num,
SelectTargetMethod targetType,
uint32 offset = 0,
float dist = 0.0f,
bool playerOnly =
false,
bool withTank =
true,
int32 aura = 0);
198 template <
class PREDICATE>
201 if (!PrepareTargetListSelection(targetList, targetType, offset))
205 targetList.remove_if([&predicate](
Unit* target) {
return !predicate(target); });
207 FinalizeTargetListSelection(targetList, num, targetType);
237 void AttackStartCaster(
Unit* victim,
float dist);
245 float DoGetSpellMaxRange(
uint32 spellId,
bool positive =
false);
249 void DoMeleeAttackIfReady();
250 bool DoSpellAttackIfReady(
uint32 spell);
253 static void FillAISpellInfo();
std::string GetDebugInfo()
static ObjectGuid const Empty
virtual void HealReceived(Unit *, uint32 &)
virtual void SetData(uint32, uint32)
virtual void DoAction(int32)
virtual void JustEnteredCombat(Unit *)
virtual void SpellInterrupted(uint32, uint32)
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset, PREDICATE const &predicate)
virtual bool CanAIAttack(Unit const *) const
virtual uint32 GetData(uint32) const
void SelectTargetList(std::list< Unit * > &targetList, uint32 num, SelectTargetMethod targetType, uint32 offset, PREDICATE const &predicate)
UnitAI & operator=(UnitAI const &right)=delete
virtual ObjectGuid GetGUID(int32=0) const
virtual void DamageTaken(Unit *, uint32 &, DamageEffectType, SpellInfo const *)
virtual void OnGameEvent(bool, uint16)
virtual void JustExitedCombat()
virtual void HealDone(Unit *, uint32 &)
virtual void DamageDealt(Unit *, uint32 &, DamageEffectType)
virtual void UpdateAI(uint32 diff)=0
UnitAI(UnitAI const &right)=delete
static AISpellInfoType * AISpellInfo
virtual void SetGUID(ObjectGuid const &, int32=0)
SpellCastResult DoCastAOE(uint32 spellId, CastSpellExtraArgs const &args={})
virtual bool ShouldSparWith(Unit const *) const
FarthestTargetSelector(Unit const *unit, float dist, bool playerOnly, bool inLos)
NonTankTargetSelector(Unit *source, bool playerOnly=true)
SpellInfo const * _spellInfo