Core/Db/Conditions: Add new condition types:

- CONDITION_OBJECT_ENTRY
- CONDITION_TYPE_MASK
- CONDITION_RELATION_TO
- CONDITION_REACTION_TO
- CONDITION_DISTANCE_TO
- CONDITION_ALIVE
- CONDITION_HP_VAL
- CONDITION_HP_PCT
This commit is contained in:
QAston
2012-02-11 15:17:33 +01:00
parent 53458b4508
commit 784d58c023
3 changed files with 317 additions and 174 deletions
+80 -41
View File
@@ -29,49 +29,47 @@ class LootTemplate;
struct Condition;
enum ConditionType
{ // value1 value2 value3
CONDITION_NONE = 0, // 0 0 0 always true
CONDITION_AURA = 1, // spell_id effindex use target? true if player (or target, if value3) has aura of spell_id with effect effindex
CONDITION_ITEM = 2, // item_id count bank true if has #count of item_ids (if 'bank' is set it searches in bank slots too)
CONDITION_ITEM_EQUIPPED = 3, // item_id 0 0 true if has item_id equipped
CONDITION_ZONEID = 4, // zone_id 0 0 true if in zone_id
CONDITION_REPUTATION_RANK = 5, // faction_id min_rank 0 true if has min_rank for faction_id
CONDITION_TEAM = 6, // player_team 0, 0 469 - Alliance, 67 - Horde)
CONDITION_SKILL = 7, // skill_id skill_value 0 true if has skill_value for skill_id
CONDITION_QUESTREWARDED = 8, // quest_id 0 0 true if quest_id was rewarded before
CONDITION_QUESTTAKEN = 9, // quest_id 0, 0 true while quest active
CONDITION_DRUNKENSTATE = 10, // DrunkenState 0, 0 true if player is drunk enough
{ // value1 value2 value3
CONDITION_NONE = 0, // 0 0 0 always true
CONDITION_AURA = 1, // spell_id effindex use target? true if player (or target, if value3) has aura of spell_id with effect effindex
CONDITION_ITEM = 2, // item_id count bank true if has #count of item_ids (if 'bank' is set it searches in bank slots too)
CONDITION_ITEM_EQUIPPED = 3, // item_id 0 0 true if has item_id equipped
CONDITION_ZONEID = 4, // zone_id 0 0 true if in zone_id
CONDITION_REPUTATION_RANK = 5, // faction_id rankMask 0 true if has min_rank for faction_id
CONDITION_TEAM = 6, // player_team 0, 0 469 - Alliance, 67 - Horde)
CONDITION_SKILL = 7, // skill_id skill_value 0 true if has skill_value for skill_id
CONDITION_QUESTREWARDED = 8, // quest_id 0 0 true if quest_id was rewarded before
CONDITION_QUESTTAKEN = 9, // quest_id 0, 0 true while quest active
CONDITION_DRUNKENSTATE = 10, // DrunkenState 0, 0 true if player is drunk enough
CONDITION_UNUSED_11 = 11,
CONDITION_ACTIVE_EVENT = 12, // event_id 0 0 true if event is active
CONDITION_INSTANCE_DATA = 13, // entry data 0 true if data is set in current instance
CONDITION_QUEST_NONE = 14, // quest_id 0 0 true if doesn't have quest saved
CONDITION_CLASS = 15, // class 0 0 true if player's class is equal to class
CONDITION_RACE = 16, // race 0 0 true if player's race is equal to race
CONDITION_ACHIEVEMENT = 17, // achievement_id 0 0 true if achievement is complete
CONDITION_ACTIVE_EVENT = 12, // event_id 0 0 true if event is active
CONDITION_INSTANCE_DATA = 13, // entry data 0 true if data is set in current instance
CONDITION_QUEST_NONE = 14, // quest_id 0 0 true if doesn't have quest saved
CONDITION_CLASS = 15, // class 0 0 true if player's class is equal to class
CONDITION_RACE = 16, // race 0 0 true if player's race is equal to race
CONDITION_ACHIEVEMENT = 17, // achievement_id 0 0 true if achievement is complete
CONDITION_SPELL_SCRIPT_TARGET = 18, // SpellScriptTargetType, TargetEntry, 0
CONDITION_CREATURE_TARGET = 19, // creature entry 0 0 true if current target is creature with value1 entry
CONDITION_TARGET_HEALTH_BELOW_PCT = 20, // 0-100 0 0 true if target's health is below value1 percent, false if over or no target
CONDITION_TARGET_RANGE = 21, // minDistance maxDist 0 true if target is closer then minDist and further then maxDist or if max is 0 then max dist is infinit
CONDITION_MAPID = 22, // map_id 0 0 true if in map_id
CONDITION_AREAID = 23, // area_id 0 0 true if in area_id
CONDITION_ITEM_TARGET = 24, // ItemRequiredTargetType, TargetEntry, 0
CONDITION_SPELL = 25, // spell_id 0 0 true if player has learned spell
CONDITION_CREATURE_TARGET = 19, // creature entry 0 0 true if current target is creature with value1 entry
CONDITION_TARGET_HEALTH_BELOW_PCT = 20, // 0-100 0 0 true if target's health is below value1 percent, false if over or no target
CONDITION_TARGET_RANGE = 21, // minDistance maxDist 0 true if target is closer then minDist and further then maxDist or if max is 0 then max dist is infinit
CONDITION_MAPID = 22, // map_id 0 0 true if in map_id
CONDITION_AREAID = 23, // area_id 0 0 true if in area_id
CONDITION_ITEM_TARGET = 24, // ItemRequiredTargetType, TargetEntry, 0
CONDITION_SPELL = 25, // spell_id 0 0 true if player has learned spell
CONDITION_UNUSED_26 = 26,
CONDITION_LEVEL = 27, // level opt 0 true if unit's level is equal to param1 (param2 can modify the statement)
CONDITION_QUEST_COMPLETE = 28, // quest_id 0 0 true if player has quest_id with all objectives complete, but not yet rewarded
CONDITION_NEAR_CREATURE = 29, // creature entry distance 0 true if there is a creature of entry in range
CONDITION_NEAR_GAMEOBJECT = 30, // gameobject entry distance 0 true if there is a gameobject of entry in range
CONDITION_MAX = 31 // MAX
};
enum LevelConditionType
{
LVL_COND_EQ,
LVL_COND_HIGH,
LVL_COND_LOW,
LVL_COND_HIGH_EQ,
LVL_COND_LOW_EQ,
LVL_COND_MAX
CONDITION_LEVEL = 27, // level ComparisonType 0 true if unit's level is equal to param1 (param2 can modify the statement)
CONDITION_QUEST_COMPLETE = 28, // quest_id 0 0 true if player has quest_id with all objectives complete, but not yet rewarded
CONDITION_NEAR_CREATURE = 29, // creature entry distance 0 true if there is a creature of entry in range
CONDITION_NEAR_GAMEOBJECT = 30, // gameobject entry distance 0 true if there is a gameobject of entry in range
CONDITION_OBJECT_ENTRY = 31, // TypeID entry 0 true if object is type TypeID and the entry is 0 or matches entry of the object
CONDITION_TYPE_MASK = 32, // TypeMask 0 0 true if object is type object's TypeMask matches provided TypeMask
CONDITION_RELATION_TO = 33, // ConditionTarget RelationType 0 true if object is in given relation with object specified by ConditionTarget
CONDITION_REACTION_TO = 34, // ConditionTarget rankMask 0 true if object's reaction matches rankMask object specified by ConditionTarget
CONDITION_DISTANCE_TO = 35, // ConditionTarget distance ComparisonType true if object and ConditionTarget are within distance given by parameters
CONDITION_ALIVE = 36, // 0 0 0 true if unit is alive
CONDITION_HP_VAL = 37, // hpVal ComparisonType 0 true if unit's hp matches given value
CONDITION_HP_PCT = 38, // hpPct ComparisonType 0 true if unit's hp matches given pct
CONDITION_MAX = 39 // MAX
};
enum ConditionSourceType
@@ -102,6 +100,26 @@ enum ConditionSourceType
CONDITION_SOURCE_TYPE_MAX = 23 //MAX
};
enum ComparisionType
{
COMP_TYPE_EQ = 0,
COMP_TYPE_HIGH,
COMP_TYPE_LOW,
COMP_TYPE_HIGH_EQ,
COMP_TYPE_LOW_EQ,
COMP_TYPE_MAX
};
enum RelationType
{
RELATION_SELF = 0,
RELATION_IN_PARTY,
RELATION_IN_RAID_OR_PARTY,
RELATION_OWNED_BY,
RELATION_PASSENGER_OF,
RELATION_MAX
};
enum
{
MAX_CONDITION_TARGETS = 3,
@@ -109,7 +127,7 @@ enum
struct ConditionSourceInfo
{
WorldObject* mConditionTargets[MAX_CONDITION_TARGETS];
WorldObject* mConditionTargets[MAX_CONDITION_TARGETS]; // an array of targets available for conditions
Condition* mLastFailedCondition;
ConditionSourceInfo(WorldObject* target0, WorldObject* target1 = NULL, WorldObject* target2 = NULL)
{
@@ -156,6 +174,7 @@ struct Condition
bool Meets(ConditionSourceInfo& sourceInfo);
bool isLoaded() const { return mConditionType > CONDITION_NONE || mReferenceId; }
uint32 GetMaxAvailableConditionTargets();
};
typedef std::list<Condition*> ConditionList;
@@ -221,6 +240,26 @@ class ConditionMgr
SmartEventConditionContainer SmartEventConditionStore;
};
template <class T> bool CompareValues(ComparisionType type, T val1, T val2)
{
switch (type)
{
case COMP_TYPE_EQ:
return val1 == val2;
case COMP_TYPE_HIGH:
return val1 > val2;
case COMP_TYPE_LOW:
return val1 < val2;
case COMP_TYPE_HIGH_EQ:
return val1 >= val2;
case COMP_TYPE_LOW_EQ:
return val1 <= val2;
}
// incorrect parameter
ASSERT(false);
return false;
}
#define sConditionMgr ACE_Singleton<ConditionMgr, ACE_Null_Mutex>::instance()
#endif