TrinityCore
CreatureAIImpl.h File Reference
#include "Random.h"
#include <type_traits>
#include <functional>
+ Include dependency graph for CreatureAIImpl.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  AISpellInfoType
 

Macros

#define AI_DEFAULT_COOLDOWN   5000
 

Enumerations

enum  AITarget {
  AITARGET_SELF, AITARGET_VICTIM, AITARGET_ENEMY, AITARGET_ALLY,
  AITARGET_BUFF, AITARGET_DEBUFF
}
 
enum  AICondition { AICOND_AGGRO, AICOND_COMBAT, AICOND_DIE }
 
enum  SelectTargetType : uint8 {
  SELECT_TARGET_DONTCARE = 0, SELECT_TARGET_SELF, SELECT_TARGET_SINGLE_ENEMY, SELECT_TARGET_AOE_ENEMY,
  SELECT_TARGET_ANY_ENEMY, SELECT_TARGET_SINGLE_FRIEND, SELECT_TARGET_AOE_FRIEND, SELECT_TARGET_ANY_FRIEND
}
 
enum  SelectEffect : uint8 { SELECT_EFFECT_DONTCARE = 0, SELECT_EFFECT_DAMAGE, SELECT_EFFECT_HEALING, SELECT_EFFECT_AURA }
 

Functions

template<typename First , typename Second , typename... Rest>
enum Difficulty uint8 First const & RAND (First const &first, Second const &second, Rest const &... rest)
 
AISpellInfoTypeGetAISpellInfo (uint32 spellId, Difficulty difficulty)
 
TC_GAME_API bool InstanceHasScript (WorldObject const *obj, char const *scriptName)
 
template<class AI , class T >
AI * GetInstanceAI (T *obj, char const *scriptName)
 

Macro Definition Documentation

◆ AI_DEFAULT_COOLDOWN

#define AI_DEFAULT_COOLDOWN   5000

Enumeration Type Documentation

◆ AICondition

Enumerator
AICOND_AGGRO 
AICOND_COMBAT 
AICOND_DIE 
45 {
49 };
Definition: CreatureAIImpl.h:46
Definition: CreatureAIImpl.h:48
Definition: CreatureAIImpl.h:47

◆ AITarget

enum AITarget
Enumerator
AITARGET_SELF 
AITARGET_VICTIM 
AITARGET_ENEMY 
AITARGET_ALLY 
AITARGET_BUFF 
AITARGET_DEBUFF 
35 {
42 };
Definition: CreatureAIImpl.h:41
Definition: CreatureAIImpl.h:38
Definition: CreatureAIImpl.h:40
Definition: CreatureAIImpl.h:39
Definition: CreatureAIImpl.h:36
Definition: CreatureAIImpl.h:37

◆ SelectEffect

Enumerator
SELECT_EFFECT_DONTCARE 
SELECT_EFFECT_DAMAGE 
SELECT_EFFECT_HEALING 
SELECT_EFFECT_AURA 
67  : uint8
68 {
69  SELECT_EFFECT_DONTCARE = 0, // All spell effects allowed
70  SELECT_EFFECT_DAMAGE, // Spell does damage
71  SELECT_EFFECT_HEALING, // Spell does healing
72  SELECT_EFFECT_AURA // Spell applies an aura
73 };
Definition: CreatureAIImpl.h:69
Definition: CreatureAIImpl.h:72
Definition: CreatureAIImpl.h:71
Definition: CreatureAIImpl.h:70
uint8_t uint8
Definition: Define.h:145

◆ SelectTargetType

Enumerator
SELECT_TARGET_DONTCARE 
SELECT_TARGET_SELF 
SELECT_TARGET_SINGLE_ENEMY 
SELECT_TARGET_AOE_ENEMY 
SELECT_TARGET_ANY_ENEMY 
SELECT_TARGET_SINGLE_FRIEND 
SELECT_TARGET_AOE_FRIEND 
SELECT_TARGET_ANY_FRIEND 
54  : uint8
55 {
56  SELECT_TARGET_DONTCARE = 0, // All target types allowed
57  SELECT_TARGET_SELF, // Only Self casting
58  SELECT_TARGET_SINGLE_ENEMY, // Only Single Enemy
59  SELECT_TARGET_AOE_ENEMY, // Only AoE Enemy
60  SELECT_TARGET_ANY_ENEMY, // AoE or Single Enemy
61  SELECT_TARGET_SINGLE_FRIEND, // Only Single Friend
62  SELECT_TARGET_AOE_FRIEND, // Only AoE Friend
63  SELECT_TARGET_ANY_FRIEND // AoE or Single Friend
64 };
Definition: CreatureAIImpl.h:62
Definition: CreatureAIImpl.h:59
Definition: CreatureAIImpl.h:60
Definition: CreatureAIImpl.h:61
Definition: CreatureAIImpl.h:57
Definition: CreatureAIImpl.h:56
uint8_t uint8
Definition: Define.h:145
Definition: CreatureAIImpl.h:63
Definition: CreatureAIImpl.h:58

Function Documentation

◆ GetAISpellInfo()

AISpellInfoType* GetAISpellInfo ( uint32  spellId,
Difficulty  difficulty 
)
39 {
40  return Trinity::Containers::MapGetValuePtr(UnitAI::AISpellInfo, { spellId, difficulty });
41 }
auto MapGetValuePtr(M &map, typename M::key_type const &key) -> decltype(AddressOrSelf(map.find(key) ->second))
Definition: Containers.h:259
static std::unordered_map< std::pair< uint32, Difficulty >, AISpellInfoType > AISpellInfo
Definition: UnitAI.h:330
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetInstanceAI()

template<class AI , class T >
AI* GetInstanceAI ( T *  obj,
char const *  scriptName 
)
95 {
96  if (InstanceHasScript(obj, scriptName))
97  return new AI(obj);
98 
99  return nullptr;
100 }
TC_GAME_API bool InstanceHasScript(WorldObject const *obj, char const *scriptName)
Definition: InstanceScript.cpp:938
+ Here is the call graph for this function:

◆ InstanceHasScript()

TC_GAME_API bool InstanceHasScript ( WorldObject const *  obj,
char const *  scriptName 
)
939 {
940  if (InstanceMap* instance = obj->GetMap()->ToInstanceMap())
941  return instance->GetScriptName() == scriptName;
942 
943  return false;
944 }
Definition: Map.h:945
InstanceMap * ToInstanceMap()
Definition: Map.h:528
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RAND()

template<typename First , typename Second , typename... Rest>
enum Difficulty uint8 First const& RAND ( First const &  first,
Second const &  second,
Rest const &...  rest 
)
inline
29 {
30  std::reference_wrapper<typename std::add_const<First>::type> const pack[] = { first, second, rest... };
31  return pack[urand(0, sizeof...(rest) + 1)].get();
32 }
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function: