TrinityCore
Loading...
Searching...
No Matches
CreatureAIImpl.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
#ifndef CREATUREAIIMPL_H
18
#define CREATUREAIIMPL_H
19
20
#include "
Random.h
"
21
#include <type_traits>
22
#include <functional>
23
24
class
WorldObject
;
25
26
template
<
typename
First,
typename
Second,
typename
... Rest>
27
inline
First
const
&
RAND
(First
const
& first, Second
const
& second, Rest
const
&... rest)
28
{
29
std::reference_wrapper<typename std::add_const<First>::type>
const
pack[] = { first, second, rest... };
30
return
pack[
urand
(0,
sizeof
...(rest) + 1)].get();
31
}
32
33
enum
AITarget
34
{
35
AITARGET_SELF
,
36
AITARGET_VICTIM
,
37
AITARGET_ENEMY
,
38
AITARGET_ALLY
,
39
AITARGET_BUFF
,
40
AITARGET_DEBUFF
41
};
42
43
enum
AICondition
44
{
45
AICOND_AGGRO
,
46
AICOND_COMBAT
,
47
AICOND_DIE
48
};
49
50
#define AI_DEFAULT_COOLDOWN 5000
51
52
struct
AISpellInfoType
53
{
54
AISpellInfoType
() :
target
(
AITARGET_SELF
),
condition
(
AICOND_COMBAT
)
55
,
cooldown
(
AI_DEFAULT_COOLDOWN
),
realCooldown
(0),
maxRange
(0.0f){ }
56
AITarget
target
;
57
AICondition
condition
;
58
uint32
cooldown
;
59
uint32
realCooldown
;
60
float
maxRange
;
61
};
62
63
AISpellInfoType
*
GetAISpellInfo
(
uint32
i);
64
65
TC_GAME_API
bool
InstanceHasScript
(
WorldObject
const
* obj,
char
const
* scriptName);
66
67
template
<
class
AI,
class
T>
68
AI*
GetInstanceAI
(T* obj,
char
const
* scriptName)
69
{
70
if
(
InstanceHasScript
(obj, scriptName))
71
return
new
AI(obj);
72
73
return
nullptr
;
74
}
75
76
#endif
AITarget
AITarget
Definition
CreatureAIImpl.h:34
AITARGET_ALLY
@ AITARGET_ALLY
Definition
CreatureAIImpl.h:38
AITARGET_BUFF
@ AITARGET_BUFF
Definition
CreatureAIImpl.h:39
AITARGET_SELF
@ AITARGET_SELF
Definition
CreatureAIImpl.h:35
AITARGET_VICTIM
@ AITARGET_VICTIM
Definition
CreatureAIImpl.h:36
AITARGET_ENEMY
@ AITARGET_ENEMY
Definition
CreatureAIImpl.h:37
AITARGET_DEBUFF
@ AITARGET_DEBUFF
Definition
CreatureAIImpl.h:40
InstanceHasScript
TC_GAME_API bool InstanceHasScript(WorldObject const *obj, char const *scriptName)
Definition
InstanceScript.cpp:813
GetAISpellInfo
AISpellInfoType * GetAISpellInfo(uint32 i)
Definition
CreatureAI.cpp:38
AI_DEFAULT_COOLDOWN
#define AI_DEFAULT_COOLDOWN
Definition
CreatureAIImpl.h:50
RAND
First const & RAND(First const &first, Second const &second, Rest const &... rest)
Definition
CreatureAIImpl.h:27
GetInstanceAI
AI * GetInstanceAI(T *obj, char const *scriptName)
Definition
CreatureAIImpl.h:68
AICondition
AICondition
Definition
CreatureAIImpl.h:44
AICOND_COMBAT
@ AICOND_COMBAT
Definition
CreatureAIImpl.h:46
AICOND_AGGRO
@ AICOND_AGGRO
Definition
CreatureAIImpl.h:45
AICOND_DIE
@ AICOND_DIE
Definition
CreatureAIImpl.h:47
TC_GAME_API
#define TC_GAME_API
Definition
Define.h:114
uint32
uint32_t uint32
Definition
Define.h:133
urand
uint32 urand(uint32 min, uint32 max)
Definition
Random.cpp:42
Random.h
WorldObject
Definition
Object.h:337
AISpellInfoType
Definition
CreatureAIImpl.h:53
AISpellInfoType::AISpellInfoType
AISpellInfoType()
Definition
CreatureAIImpl.h:54
AISpellInfoType::realCooldown
uint32 realCooldown
Definition
CreatureAIImpl.h:59
AISpellInfoType::cooldown
uint32 cooldown
Definition
CreatureAIImpl.h:58
AISpellInfoType::target
AITarget target
Definition
CreatureAIImpl.h:56
AISpellInfoType::maxRange
float maxRange
Definition
CreatureAIImpl.h:60
AISpellInfoType::condition
AICondition condition
Definition
CreatureAIImpl.h:57
server
game
AI
CreatureAIImpl.h
Generated on Sun May 10 2026 02:30:13 for TrinityCore by
1.9.8