OregonCore  revision 3611e8a-git
Your Favourite TBC server
ConditionMgr.h File Reference
#include "LootMgr.h"

Go to the source code of this file.

Classes

struct  ConditionSourceInfo
 
struct  Condition
 
class  ConditionMgr
 
struct  ConditionMgr::ConditionTypeInfo
 

Macros

#define CONDITION_MAX   39
 
#define COMP_TYPE_MAX   5
 
#define RELATION_MAX   6
 
#define sConditionMgr   Oregon::Singleton<ConditionMgr>::Instance()
 

Typedefs

typedef std::list< Condition * > ConditionList
 
typedef std::map< uint32, ConditionListConditionTypeContainer
 
typedef std::map< ConditionSourceType, ConditionTypeContainerConditionContainer
 
typedef std::map< std::pair< int32, uint32 >, ConditionTypeContainerSmartEventConditionContainer
 
typedef std::map< uint32, ConditionListConditionReferenceContainer
 

Enumerations

enum  ConditionType {
  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_SPELL_SCRIPT_TARGET = 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_UNUSED_26 = 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
}
 
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_SCRIPT_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_MAX = 23
}
 
enum  ComparisionType {
  COMP_TYPE_EQ = 0, COMP_TYPE_HIGH, COMP_TYPE_LOW, COMP_TYPE_HIGH_EQ,
  COMP_TYPE_LOW_EQ
}
 
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_DATA64, INSTANCE_INFO_BOSS_STATE }
 
enum  MaxConditionTargets { MAX_CONDITION_TARGETS = 3 }
 

Functions

template<class T >
bool CompareValues (ComparisionType type, T val1, T val2)
 

Macro Definition Documentation

#define COMP_TYPE_MAX   5

Definition at line 139 of file ConditionMgr.h.

Referenced by ConditionMgr::isConditionTypeValid().

#define CONDITION_MAX   39

Definition at line 72 of file ConditionMgr.h.

Referenced by ConditionMgr::isConditionTypeValid(), and Condition::ToString().

#define RELATION_MAX   6

Definition at line 152 of file ConditionMgr.h.

Typedef Documentation

Definition at line 225 of file ConditionMgr.h.

typedef std::list<Condition*> ConditionList

Definition at line 223 of file ConditionMgr.h.

Definition at line 228 of file ConditionMgr.h.

Definition at line 224 of file ConditionMgr.h.

Definition at line 226 of file ConditionMgr.h.

Enumeration Type Documentation

Enumerator
COMP_TYPE_EQ 
COMP_TYPE_HIGH 
COMP_TYPE_LOW 
COMP_TYPE_HIGH_EQ 
COMP_TYPE_LOW_EQ 

Definition at line 130 of file ConditionMgr.h.

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 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.

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

Step 6: 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 7: Implement loading for your source type in ConditionMgr::LoadConditions.

Step 8: 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_SCRIPT_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_MAX 

Definition at line 101 of file ConditionMgr.h.

102 {
119  CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE = 16, // Not used in 2.4.3
121  CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT = 18, // Not used in 2.4.3
124  CONDITION_SOURCE_TYPE_VEHICLE_SPELL = 21, // Not used in 2.4.3
126 
127  CONDITION_SOURCE_TYPE_MAX = 23 //MAX
128 };
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_SPELL_SCRIPT_TARGET 
CONDITION_TITLE 
CONDITION_SPAWNMASK 
CONDITION_GENDER 
CONDITION_UNIT_STATE 
CONDITION_MAPID 
CONDITION_AREAID 
CONDITION_CREATURE_TYPE 
CONDITION_SPELL 
CONDITION_UNUSED_26 
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 

Definition at line 29 of file ConditionMgr.h.

30 { // value1 value2 value3
31  CONDITION_NONE = 0, // 0 0 0 always true
32  CONDITION_AURA = 1, // spell_id effindex use target? true if player (or target, if value3) has aura of spell_id with effect effindex
33  CONDITION_ITEM = 2, // item_id count bank true if has #count of item_ids (if 'bank' is set it searches in bank slots too)
34  CONDITION_ITEM_EQUIPPED = 3, // item_id 0 0 true if has item_id equipped
35  CONDITION_ZONEID = 4, // zone_id 0 0 true if in zone_id
36  CONDITION_REPUTATION_RANK = 5, // faction_id min_rank 0 true if has min_rank for faction_id
37  CONDITION_TEAM = 6, // player_team 0, 0 469 - Alliance, 67 - Horde)
38  CONDITION_SKILL = 7, // skill_id skill_value 0 true if has skill_value for skill_id
39  CONDITION_QUESTREWARDED = 8, // quest_id 0 0 true if quest_id was rewarded before
40  CONDITION_QUESTTAKEN = 9, // quest_id 0, 0 true while quest active
41  CONDITION_DRUNKENSTATE = 10, // DrunkenState 0, 0 true if player is drunk enough
42  CONDITION_WORLD_STATE = 11, // index value 0 true if world has the value for the index
43  CONDITION_ACTIVE_EVENT = 12, // event_id 0 0 true if event is active
44  CONDITION_INSTANCE_INFO = 13, // entry data type true if the instance info defined by type (enum InstanceInfo) equals data.
45  CONDITION_QUEST_NONE = 14, // quest_id 0 0 true if doesn't have quest saved
46  CONDITION_CLASS = 15, // class 0 0 true if player's class is equal to class
47  CONDITION_RACE = 16, // race 0 0 true if player's race is equal to race
48  CONDITION_SPELL_SCRIPT_TARGET = 17, // SpellScriptTargetType TargetEntry
49  CONDITION_TITLE = 18, // title id 0 0 true if player has title
50  CONDITION_SPAWNMASK = 19, // spawnMask 0 0 true if in spawnMask
51  CONDITION_GENDER = 20, // gender 0 0 true if player's gender is equal to gender
52  CONDITION_UNIT_STATE = 21, // unitState 0 0 true if unit has unitState
53  CONDITION_MAPID = 22, // map_id 0 0 true if in map_id
54  CONDITION_AREAID = 23, // area_id 0 0 true if in area_id
55  CONDITION_CREATURE_TYPE = 24, // cinfo.type 0 0 true if creature_template.type = value1
56  CONDITION_SPELL = 25, // spell_id 0 0 true if player has learned spell
58  CONDITION_LEVEL = 27, // level opt 0 true if unit's level is equal to param1 (param2 can modify the statement)
59  CONDITION_QUEST_COMPLETE = 28, // quest_id 0 0 true if player has quest_id with all objectives complete, but not yet rewarded
60  CONDITION_NEAR_CREATURE = 29, // creature entry distance dead (0/1) true if there is a creature of entry in range
61  CONDITION_NEAR_GAMEOBJECT = 30, // gameobject entry distance 0 true if there is a gameobject of entry in range
62  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
63  CONDITION_TYPE_MASK = 32, // TypeMask 0 0 true if object is type object's TypeMask matches provided TypeMask
64  CONDITION_RELATION_TO = 33, // ConditionTarget RelationType 0 true if object is in given relation with object specified by ConditionTarget
65  CONDITION_REACTION_TO = 34, // ConditionTarget rankMask 0 true if object's reaction matches rankMask object specified by ConditionTarget
66  CONDITION_DISTANCE_TO = 35, // ConditionTarget distance ComparisonType true if object and ConditionTarget are within distance given by parameters
67  CONDITION_ALIVE = 36, // 0 0 0 true if unit is alive
68  CONDITION_HP_VAL = 37, // hpVal ComparisonType 0 true if unit's hp matches given value
69  CONDITION_HP_PCT = 38, // hpPct ComparisonType 0 true if unit's hp matches given pct
70 };
Enumerator
INSTANCE_INFO_DATA 
INSTANCE_INFO_DATA64 
INSTANCE_INFO_BOSS_STATE 

Definition at line 154 of file ConditionMgr.h.

Enumerator
MAX_CONDITION_TARGETS 

Definition at line 161 of file ConditionMgr.h.

Enumerator
RELATION_SELF 
RELATION_IN_PARTY 
RELATION_IN_RAID_OR_PARTY 
RELATION_OWNED_BY 
RELATION_PASSENGER_OF 
RELATION_CREATED_BY 
RELATION_MAX 

Definition at line 141 of file ConditionMgr.h.

Function Documentation

template<class T >
bool CompareValues ( ComparisionType  type,
val1,
val2 
)

Definition at line 292 of file ConditionMgr.h.

References ASSERT, COMP_TYPE_EQ, COMP_TYPE_HIGH, COMP_TYPE_HIGH_EQ, COMP_TYPE_LOW, and COMP_TYPE_LOW_EQ.

Referenced by Condition::Meets().

293 {
294  switch (type)
295  {
296  case COMP_TYPE_EQ:
297  return val1 == val2;
298  case COMP_TYPE_HIGH:
299  return val1 > val2;
300  case COMP_TYPE_LOW:
301  return val1 < val2;
302  case COMP_TYPE_HIGH_EQ:
303  return val1 >= val2;
304  case COMP_TYPE_LOW_EQ:
305  return val1 <= val2;
306  }
307  // incorrect parameter
308  ASSERT(false);
309  return false;
310 }
#define ASSERT
Definition: Errors.h:33