TrinityCore
Loading...
Searching...
No Matches
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
23
class
SpellInfo
;
24
class
Unit
;
25
26
enum
Powers
:
int8
;
27
28
// EnumUtils: DESCRIBE THIS
29
enum 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
39
enum class
SelectTargetMethod
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
49
struct
TC_GAME_API
DefaultTargetSelector
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
59
private
:
60
Unit
const
*
_me
;
61
float
_dist
;
62
bool
_playerOnly
;
63
Unit
const
*
_exception
;
64
int32
_aura
;
65
};
66
67
// Target selector for spell casts checking range, auras and attributes
69
struct
TC_GAME_API
SpellTargetSelector
70
{
71
SpellTargetSelector
(
Unit
* caster,
uint32
spellId);
72
bool
operator()(
Unit
const
* target)
const
;
73
74
private
:
75
Unit
const
*
_caster
;
76
SpellInfo
const
*
_spellInfo
;
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
82
struct
TC_GAME_API
NonTankTargetSelector
83
{
84
NonTankTargetSelector
(
Unit
* source,
bool
playerOnly =
true
) : _source(source), _playerOnly(playerOnly) { }
85
bool
operator()(
Unit
const
* target)
const
;
86
87
private
:
88
Unit
*
_source
;
89
bool
_playerOnly
;
90
};
91
92
// Simple selector for units using mana
93
struct
TC_GAME_API
PowerUsersSelector
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
98
private
:
99
Unit
const
*
_me
;
100
Powers
const
_power
;
101
float
const
_dist
;
102
bool
const
_playerOnly
;
103
};
104
105
struct
TC_GAME_API
FarthestTargetSelector
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
110
private
:
111
Unit
const
*
_me
;
112
float
_dist
;
113
bool
_playerOnly
;
114
bool
_inLos
;
115
};
116
117
#endif
// TRINITYCORE_UNIT_AI_COMMON_H
Define.h
TC_GAME_API
#define TC_GAME_API
Definition
Define.h:129
int8
int8_t int8
Definition
Define.h:152
int32
int32_t int32
Definition
Define.h:150
uint32
uint32_t uint32
Definition
Define.h:154
Powers
Powers
Definition
SharedDefines.h:293
SelectTargetMethod
SelectTargetMethod
Definition
UnitAICommon.h:40
SelectTargetMethod::MinThreat
@ MinThreat
SelectTargetMethod::MaxDistance
@ MaxDistance
SelectTargetMethod::MinDistance
@ MinDistance
SelectTargetMethod::Random
@ Random
SelectTargetMethod::MaxThreat
@ MaxThreat
EvadeReason
EvadeReason
Definition
UnitAICommon.h:30
EvadeReason::NoHostiles
@ NoHostiles
EvadeReason::Other
@ Other
EvadeReason::SequenceBreak
@ SequenceBreak
EvadeReason::NoPath
@ NoPath
EvadeReason::Boundary
@ Boundary
SpellInfo
Definition
SpellInfo.h:324
Unit
Definition
Unit.h:635
DefaultTargetSelector
Definition
UnitAICommon.h:50
DefaultTargetSelector::_playerOnly
bool _playerOnly
Definition
UnitAICommon.h:62
DefaultTargetSelector::_dist
float _dist
Definition
UnitAICommon.h:61
DefaultTargetSelector::_me
Unit const * _me
Definition
UnitAICommon.h:60
DefaultTargetSelector::_aura
int32 _aura
Definition
UnitAICommon.h:64
DefaultTargetSelector::_exception
Unit const * _exception
Definition
UnitAICommon.h:63
FarthestTargetSelector
Definition
UnitAICommon.h:106
FarthestTargetSelector::FarthestTargetSelector
FarthestTargetSelector(Unit const *unit, float dist, bool playerOnly, bool inLos)
Definition
UnitAICommon.h:107
FarthestTargetSelector::_me
Unit const * _me
Definition
UnitAICommon.h:111
FarthestTargetSelector::_dist
float _dist
Definition
UnitAICommon.h:112
FarthestTargetSelector::_playerOnly
bool _playerOnly
Definition
UnitAICommon.h:113
FarthestTargetSelector::_inLos
bool _inLos
Definition
UnitAICommon.h:114
NonTankTargetSelector
Definition
UnitAICommon.h:83
NonTankTargetSelector::NonTankTargetSelector
NonTankTargetSelector(Unit *source, bool playerOnly=true)
Definition
UnitAICommon.h:84
NonTankTargetSelector::_playerOnly
bool _playerOnly
Definition
UnitAICommon.h:89
NonTankTargetSelector::_source
Unit * _source
Definition
UnitAICommon.h:88
PowerUsersSelector
Definition
UnitAICommon.h:94
PowerUsersSelector::_dist
float const _dist
Definition
UnitAICommon.h:101
PowerUsersSelector::_me
Unit const * _me
Definition
UnitAICommon.h:99
PowerUsersSelector::_power
Powers const _power
Definition
UnitAICommon.h:100
PowerUsersSelector::PowerUsersSelector
PowerUsersSelector(Unit const *unit, Powers power, float dist, bool playerOnly)
Definition
UnitAICommon.h:95
PowerUsersSelector::_playerOnly
bool const _playerOnly
Definition
UnitAICommon.h:102
SpellTargetSelector
Definition
UnitAICommon.h:70
SpellTargetSelector::_spellInfo
SpellInfo const * _spellInfo
Definition
UnitAICommon.h:76
SpellTargetSelector::_caster
Unit const * _caster
Definition
UnitAICommon.h:75
server
game
AI
CoreAI
UnitAICommon.h
Generated on Sun May 10 2026 02:08:52 for TrinityCore by
1.9.8