TrinityCore
UnitAICommon.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITYCORE_UNIT_AI_COMMON_H
19#define TRINITYCORE_UNIT_AI_COMMON_H
20
21#include "Define.h"
22
23class SpellInfo;
24class Unit;
25
26enum Powers : int8;
27
28// EnumUtils: DESCRIBE THIS
29enum class EvadeReason
30{
31 NoHostiles, // the creature's threat list is empty
32 Boundary, // the creature has moved outside its evade boundary
33 NoPath, // the creature was unable to reach its target for over 5 seconds
34 SequenceBreak, // this is a boss and the pre-requisite encounters for engaging it are not defeated yet
35 Other, // anything else
36};
37
38// Selection method used by SelectTarget
40{
41 Random, // just pick a random target
42 MaxThreat, // prefer targets higher in the threat list
43 MinThreat, // prefer targets lower in the threat list
44 MaxDistance, // prefer targets further from us
45 MinDistance // prefer targets closer to us
46};
47
48// default predicate function to select target based on distance, player and/or aura criteria
50{
51 // unit: the reference unit
52 // dist: if 0: ignored, if > 0: maximum distance to the reference unit, if < 0: minimum distance to the reference unit
53 // playerOnly: self explaining
54 // withMainTank: allow current tank to be selected
55 // aura: if 0: ignored, if > 0: the target shall have the aura, if < 0, the target shall NOT have the aura
56 DefaultTargetSelector(Unit const* unit, float dist, bool playerOnly, bool withMainTank, int32 aura);
57 bool operator()(Unit const* target) const;
58
59private:
60 Unit const* _me;
61 float _dist;
65};
66
67// Target selector for spell casts checking range, auras and attributes
70{
71 SpellTargetSelector(Unit* caster, uint32 spellId);
72 bool operator()(Unit const* target) const;
73
74private:
75 Unit const* _caster;
77};
78
79// Very simple target selector, will just skip main target
80// NOTE: When passing to UnitAI::SelectTarget remember to use 0 as position for random selection
81// because tank will not be in the temporary list
83{
84 NonTankTargetSelector(Unit* source, bool playerOnly = true) : _source(source), _playerOnly(playerOnly) { }
85 bool operator()(Unit const* target) const;
86
87private:
90};
91
92// Simple selector for units using mana
94{
95 PowerUsersSelector(Unit const* unit, Powers power, float dist, bool playerOnly) : _me(unit), _power(power), _dist(dist), _playerOnly(playerOnly) { }
96 bool operator()(Unit const* target) const;
97
98private:
99 Unit const* _me;
101 float const _dist;
102 bool const _playerOnly;
103};
104
106{
107 FarthestTargetSelector(Unit const* unit, float dist, bool playerOnly, bool inLos) : _me(unit), _dist(dist), _playerOnly(playerOnly), _inLos(inLos) { }
108 bool operator()(Unit const* target) const;
109
110private:
111 Unit const* _me;
112 float _dist;
114 bool _inLos;
115};
116
117#endif // TRINITYCORE_UNIT_AI_COMMON_H
#define TC_GAME_API
Definition: Define.h:123
int8_t int8
Definition: Define.h:140
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
Powers
SelectTargetMethod
Definition: UnitAICommon.h:40
EvadeReason
Definition: UnitAICommon.h:30
Definition: Unit.h:628
Unit const * _exception
Definition: UnitAICommon.h:63
FarthestTargetSelector(Unit const *unit, float dist, bool playerOnly, bool inLos)
Definition: UnitAICommon.h:107
NonTankTargetSelector(Unit *source, bool playerOnly=true)
Definition: UnitAICommon.h:84
float const _dist
Definition: UnitAICommon.h:101
Unit const * _me
Definition: UnitAICommon.h:99
Powers const _power
Definition: UnitAICommon.h:100
PowerUsersSelector(Unit const *unit, Powers power, float dist, bool playerOnly)
Definition: UnitAICommon.h:95
bool const _playerOnly
Definition: UnitAICommon.h:102
SpellInfo const * _spellInfo
Definition: UnitAICommon.h:76
Unit const * _caster
Definition: UnitAICommon.h:75