TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ConditionMgr.h File Reference
#include "Common.h"
+ Include dependency graph for ConditionMgr.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ConditionSourceInfo
 
struct  Condition
 
class  ConditionMgr
 
struct  ConditionMgr::ConditionTypeInfo
 

Macros

#define sConditionMgr   ConditionMgr::instance()
 

Typedefs

typedef std::vector< Condition * > ConditionContainer
 
typedef std::unordered_map
< uint32, ConditionContainer
ConditionsByEntryMap
 
typedef std::array
< ConditionsByEntryMap,
CONDITION_SOURCE_TYPE_MAX
ConditionEntriesByTypeArray
 
typedef std::unordered_map
< uint32, ConditionsByEntryMap
ConditionEntriesByCreatureIdMap
 
typedef std::unordered_map
< std::pair< int32, uint32 >
, ConditionsByEntryMap
SmartEventConditionContainer
 
typedef std::unordered_map
< uint32, ConditionContainer
ConditionReferenceContainer
 

Enumerations

enum  ConditionTypes {
  CONDITION_NONE = 0, CONDITION_AURA = 1, CONDITION_ITEM = 2, CONDITION_ITEM_EQUIPPED = 3,
  CONDITION_ZONEID = 4, CONDITION_REPUTATION_RANK = 5, CONDITION_TEAM = 6, CONDITION_SKILL = 7,
  CONDITION_QUESTREWARDED = 8, CONDITION_QUESTTAKEN = 9, CONDITION_DRUNKENSTATE = 10, CONDITION_WORLD_STATE = 11,
  CONDITION_ACTIVE_EVENT = 12, CONDITION_INSTANCE_INFO = 13, CONDITION_QUEST_NONE = 14, CONDITION_CLASS = 15,
  CONDITION_RACE = 16, CONDITION_ACHIEVEMENT = 17, CONDITION_TITLE = 18, CONDITION_SPAWNMASK = 19,
  CONDITION_GENDER = 20, CONDITION_UNIT_STATE = 21, CONDITION_MAPID = 22, CONDITION_AREAID = 23,
  CONDITION_CREATURE_TYPE = 24, CONDITION_SPELL = 25, CONDITION_PHASEID = 26, CONDITION_LEVEL = 27,
  CONDITION_QUEST_COMPLETE = 28, CONDITION_NEAR_CREATURE = 29, CONDITION_NEAR_GAMEOBJECT = 30, CONDITION_OBJECT_ENTRY_GUID = 31,
  CONDITION_TYPE_MASK = 32, CONDITION_RELATION_TO = 33, CONDITION_REACTION_TO = 34, CONDITION_DISTANCE_TO = 35,
  CONDITION_ALIVE = 36, CONDITION_HP_VAL = 37, CONDITION_HP_PCT = 38, CONDITION_REALM_ACHIEVEMENT = 39,
  CONDITION_IN_WATER = 40, CONDITION_TERRAIN_SWAP = 41, CONDITION_MAX = 42
}
 
enum  ConditionSourceType {
  CONDITION_SOURCE_TYPE_NONE = 0, CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE = 1, CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE = 2, CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE = 3,
  CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE = 4, CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE = 5, CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE = 6, CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE = 7,
  CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE = 8, CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE = 9, CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE = 10, CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE = 11,
  CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE = 12, CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET = 13, CONDITION_SOURCE_TYPE_GOSSIP_MENU = 14, CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION = 15,
  CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE = 16, CONDITION_SOURCE_TYPE_SPELL = 17, CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT = 18, CONDITION_SOURCE_TYPE_QUEST_ACCEPT = 19,
  CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK = 20, CONDITION_SOURCE_TYPE_VEHICLE_SPELL = 21, CONDITION_SOURCE_TYPE_SMART_EVENT = 22, CONDITION_SOURCE_TYPE_NPC_VENDOR = 23,
  CONDITION_SOURCE_TYPE_SPELL_PROC = 24, CONDITION_SOURCE_TYPE_TERRAIN_SWAP = 25, CONDITION_SOURCE_TYPE_PHASE = 26, CONDITION_SOURCE_TYPE_MAX = 27
}
 
enum  RelationType {
  RELATION_SELF = 0, RELATION_IN_PARTY, RELATION_IN_RAID_OR_PARTY, RELATION_OWNED_BY,
  RELATION_PASSENGER_OF, RELATION_CREATED_BY, RELATION_MAX
}
 
enum  InstanceInfo { INSTANCE_INFO_DATA = 0, INSTANCE_INFO_GUID_DATA, INSTANCE_INFO_BOSS_STATE, INSTANCE_INFO_DATA64 }
 
enum  MaxConditionTargets { MAX_CONDITION_TARGETS = 3 }
 

Macro Definition Documentation

#define sConditionMgr   ConditionMgr::instance()

Typedef Documentation

typedef std::vector<Condition*> ConditionContainer
typedef std::unordered_map<uint32 , ConditionContainer> ConditionsByEntryMap
typedef std::unordered_map<std::pair<int32, uint32 >, ConditionsByEntryMap> SmartEventConditionContainer

Enumeration Type Documentation

Documentation on implementing a new ConditionSourceType: Step 1: Check for the lowest free ID. Look for CONDITION_SOURCE_TYPE_UNUSED_XX in the enum. Then define the new source type.

Step 2: Determine and map the parameters for the new condition source type.

Step 3: Add a case block to ConditionMgr::isSourceTypeValid with the new condition type and validate the parameters.

Step 4: If your condition can be grouped (determined in step 2), add a rule for it in ConditionMgr::CanHaveSourceGroupSet, following the example of the existing types.

Step 5: Define the maximum available condition targets in ConditionMgr::GetMaxAvailableConditionTargets.

Step 6: Define ConditionSourceType Name in ConditionMgr::StaticSourceTypeData.

The following steps only apply if your condition can be grouped:

Step 7: Determine how you are going to store your conditions. You need to add a new storage container for it in ConditionMgr class, along with a function like: ConditionList GetConditionsForXXXYourNewSourceTypeXXX(parameters...)

The above function should be placed in upper level (practical) code that actually checks the conditions.

Step 8: Implement loading for your source type in ConditionMgr::LoadConditions.

Step 9: Implement memory cleaning for your source type in ConditionMgr::Clean.

Enumerator
CONDITION_SOURCE_TYPE_NONE 
CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE 
CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET 
CONDITION_SOURCE_TYPE_GOSSIP_MENU 
CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION 
CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE 
CONDITION_SOURCE_TYPE_SPELL 
CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT 
CONDITION_SOURCE_TYPE_QUEST_ACCEPT 
CONDITION_SOURCE_TYPE_QUEST_SHOW_MARK 
CONDITION_SOURCE_TYPE_VEHICLE_SPELL 
CONDITION_SOURCE_TYPE_SMART_EVENT 
CONDITION_SOURCE_TYPE_NPC_VENDOR 
CONDITION_SOURCE_TYPE_SPELL_PROC 
CONDITION_SOURCE_TYPE_TERRAIN_SWAP 
CONDITION_SOURCE_TYPE_PHASE 
CONDITION_SOURCE_TYPE_MAX 
126 {
154  CONDITION_SOURCE_TYPE_MAX = 27 // MAX
155 };
Definition: ConditionMgr.h:132
Definition: ConditionMgr.h:134
Definition: ConditionMgr.h:139
Definition: ConditionMgr.h:152
Definition: ConditionMgr.h:150
Definition: ConditionMgr.h:151
Definition: ConditionMgr.h:128
Definition: ConditionMgr.h:146
Definition: ConditionMgr.h:138
Definition: ConditionMgr.h:145
Definition: ConditionMgr.h:137
Definition: ConditionMgr.h:142
Definition: ConditionMgr.h:133
Definition: ConditionMgr.h:154
Definition: ConditionMgr.h:149
Definition: ConditionMgr.h:127
Definition: ConditionMgr.h:141
Definition: ConditionMgr.h:147
Definition: ConditionMgr.h:153
Definition: ConditionMgr.h:144
Definition: ConditionMgr.h:140
Definition: ConditionMgr.h:148
Definition: ConditionMgr.h:130

Documentation on implementing a new ConditionType: Step 1: Check for the lowest free ID. Look for CONDITION_UNUSED_XX in the enum. Then define the new condition type.

Step 2: Determine and map the parameters for the new condition type.

Step 3: Add a case block to ConditionMgr::isConditionTypeValid with the new condition type and validate the parameters.

Step 4: Define the maximum available condition targets in ConditionMgr::GetMaxAvailableConditionTargets.

Step 5: Define the grid searcher mask in Condition::GetSearcherTypeMaskForCondition.

Step 6: Add a case block to ConditionMgr::Meets with the new condition type.

Step 7: Define condition name and expected condition values in ConditionMgr::StaticConditionTypeData.

Enumerator
CONDITION_NONE 
CONDITION_AURA 
CONDITION_ITEM 
CONDITION_ITEM_EQUIPPED 
CONDITION_ZONEID 
CONDITION_REPUTATION_RANK 
CONDITION_TEAM 
CONDITION_SKILL 
CONDITION_QUESTREWARDED 
CONDITION_QUESTTAKEN 
CONDITION_DRUNKENSTATE 
CONDITION_WORLD_STATE 
CONDITION_ACTIVE_EVENT 
CONDITION_INSTANCE_INFO 
CONDITION_QUEST_NONE 
CONDITION_CLASS 
CONDITION_RACE 
CONDITION_ACHIEVEMENT 
CONDITION_TITLE 
CONDITION_SPAWNMASK 
CONDITION_GENDER 
CONDITION_UNIT_STATE 
CONDITION_MAPID 
CONDITION_AREAID 
CONDITION_CREATURE_TYPE 
CONDITION_SPELL 
CONDITION_PHASEID 
CONDITION_LEVEL 
CONDITION_QUEST_COMPLETE 
CONDITION_NEAR_CREATURE 
CONDITION_NEAR_GAMEOBJECT 
CONDITION_OBJECT_ENTRY_GUID 
CONDITION_TYPE_MASK 
CONDITION_RELATION_TO 
CONDITION_REACTION_TO 
CONDITION_DISTANCE_TO 
CONDITION_ALIVE 
CONDITION_HP_VAL 
CONDITION_HP_PCT 
CONDITION_REALM_ACHIEVEMENT 
CONDITION_IN_WATER 
CONDITION_TERRAIN_SWAP 
CONDITION_MAX 
50 { // value1 value2 value3
51  CONDITION_NONE = 0, // 0 0 0 always true
52  CONDITION_AURA = 1, // spell_id effindex 0 true if target has aura of spell_id with effect effindex
53  CONDITION_ITEM = 2, // item_id count bank true if has #count of item_ids (if 'bank' is set it searches in bank slots too)
54  CONDITION_ITEM_EQUIPPED = 3, // item_id 0 0 true if has item_id equipped
55  CONDITION_ZONEID = 4, // zone_id 0 0 true if in zone_id
56  CONDITION_REPUTATION_RANK = 5, // faction_id rankMask 0 true if has min_rank for faction_id
57  CONDITION_TEAM = 6, // player_team 0, 0 469 - Alliance, 67 - Horde)
58  CONDITION_SKILL = 7, // skill_id skill_value 0 true if has skill_value for skill_id
59  CONDITION_QUESTREWARDED = 8, // quest_id 0 0 true if quest_id was rewarded before
60  CONDITION_QUESTTAKEN = 9, // quest_id 0, 0 true while quest active
61  CONDITION_DRUNKENSTATE = 10, // DrunkenState 0, 0 true if player is drunk enough
62  CONDITION_WORLD_STATE = 11, // index value 0 true if world has the value for the index
63  CONDITION_ACTIVE_EVENT = 12, // event_id 0 0 true if event is active
64  CONDITION_INSTANCE_INFO = 13, // entry data type true if the instance info defined by type (enum InstanceInfo) equals data.
65  CONDITION_QUEST_NONE = 14, // quest_id 0 0 true if doesn't have quest saved
66  CONDITION_CLASS = 15, // class 0 0 true if player's class is equal to class
67  CONDITION_RACE = 16, // race 0 0 true if player's race is equal to race
68  CONDITION_ACHIEVEMENT = 17, // achievement_id 0 0 true if achievement is complete
69  CONDITION_TITLE = 18, // title id 0 0 true if player has title
70  CONDITION_SPAWNMASK = 19, // spawnMask 0 0 true if in spawnMask
71  CONDITION_GENDER = 20, // gender 0 0 true if player's gender is equal to gender
72  CONDITION_UNIT_STATE = 21, // unitState 0 0 true if unit has unitState
73  CONDITION_MAPID = 22, // map_id 0 0 true if in map_id
74  CONDITION_AREAID = 23, // area_id 0 0 true if in area_id
75  CONDITION_CREATURE_TYPE = 24, // cinfo.type 0 0 true if creature_template.type = value1
76  CONDITION_SPELL = 25, // spell_id 0 0 true if player has learned spell
77  CONDITION_PHASEID = 26, // phaseid 0 0 true if object is in phaseid
78  CONDITION_LEVEL = 27, // level ComparisonType 0 true if unit's level is equal to param1 (param2 can modify the statement)
79  CONDITION_QUEST_COMPLETE = 28, // quest_id 0 0 true if player has quest_id with all objectives complete, but not yet rewarded
80  CONDITION_NEAR_CREATURE = 29, // creature entry distance dead (0/1) true if there is a creature of entry in range
81  CONDITION_NEAR_GAMEOBJECT = 30, // gameobject entry distance 0 true if there is a gameobject of entry in range
82  CONDITION_OBJECT_ENTRY_GUID = 31, // TypeID entry guid true if object is type TypeID and the entry is 0 or matches entry of the object or matches guid of the object
83  CONDITION_TYPE_MASK = 32, // TypeMask 0 0 true if object is type object's TypeMask matches provided TypeMask
84  CONDITION_RELATION_TO = 33, // ConditionTarget RelationType 0 true if object is in given relation with object specified by ConditionTarget
85  CONDITION_REACTION_TO = 34, // ConditionTarget rankMask 0 true if object's reaction matches rankMask object specified by ConditionTarget
86  CONDITION_DISTANCE_TO = 35, // ConditionTarget distance ComparisonType true if object and ConditionTarget are within distance given by parameters
87  CONDITION_ALIVE = 36, // 0 0 0 true if unit is alive
88  CONDITION_HP_VAL = 37, // hpVal ComparisonType 0 true if unit's hp matches given value
89  CONDITION_HP_PCT = 38, // hpPct ComparisonType 0 true if unit's hp matches given pct
90  CONDITION_REALM_ACHIEVEMENT = 39, // achievement_id 0 0 true if realm achievement is complete
91  CONDITION_IN_WATER = 40, // 0 0 0 true if unit in water
92  CONDITION_TERRAIN_SWAP = 41, // terrainSwap 0 0 true if object is in terrainswap
93  CONDITION_MAX = 42 // MAX
94 };
Definition: ConditionMgr.h:67
Definition: ConditionMgr.h:55
Definition: ConditionMgr.h:81
Definition: ConditionMgr.h:52
Definition: ConditionMgr.h:83
Definition: ConditionMgr.h:69
Definition: ConditionMgr.h:75
Definition: ConditionMgr.h:59
Definition: ConditionMgr.h:85
Definition: ConditionMgr.h:91
Definition: ConditionMgr.h:62
Definition: ConditionMgr.h:72
Definition: ConditionMgr.h:92
Definition: ConditionMgr.h:76
Definition: ConditionMgr.h:56
Definition: ConditionMgr.h:80
Definition: ConditionMgr.h:93
Definition: ConditionMgr.h:70
Definition: ConditionMgr.h:54
Definition: ConditionMgr.h:61
Definition: ConditionMgr.h:73
Definition: ConditionMgr.h:64
Definition: ConditionMgr.h:66
Definition: ConditionMgr.h:51
Definition: ConditionMgr.h:78
Definition: ConditionMgr.h:58
Definition: ConditionMgr.h:57
Definition: ConditionMgr.h:90
Definition: ConditionMgr.h:87
Definition: ConditionMgr.h:77
Definition: ConditionMgr.h:71
Definition: ConditionMgr.h:86
Definition: ConditionMgr.h:79
Definition: ConditionMgr.h:63
Definition: ConditionMgr.h:88
Definition: ConditionMgr.h:74
Definition: ConditionMgr.h:84
Definition: ConditionMgr.h:89
Definition: ConditionMgr.h:60
Definition: ConditionMgr.h:53
Definition: ConditionMgr.h:68
Definition: ConditionMgr.h:82
Definition: ConditionMgr.h:65
Enumerator
INSTANCE_INFO_DATA 
INSTANCE_INFO_GUID_DATA 
INSTANCE_INFO_BOSS_STATE 
INSTANCE_INFO_DATA64 
169 {
170  INSTANCE_INFO_DATA = 0,
174 };
Definition: ConditionMgr.h:173
Definition: ConditionMgr.h:172
Definition: ConditionMgr.h:171
Definition: ConditionMgr.h:170
Enumerator
MAX_CONDITION_TARGETS 
177 {
179 };
Definition: ConditionMgr.h:178
Enumerator
RELATION_SELF 
RELATION_IN_PARTY 
RELATION_IN_RAID_OR_PARTY 
RELATION_OWNED_BY 
RELATION_PASSENGER_OF 
RELATION_CREATED_BY 
RELATION_MAX 
158 {
159  RELATION_SELF = 0,
166 };
Definition: ConditionMgr.h:162
Definition: ConditionMgr.h:163
Definition: ConditionMgr.h:159
Definition: ConditionMgr.h:165
Definition: ConditionMgr.h:161
Definition: ConditionMgr.h:160
Definition: ConditionMgr.h:164