aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWyrserth <wyrserth@protonmail.com>2019-06-19 15:19:17 +0200
committerGiacomo Pozzoni <giacomopoz@gmail.com>2019-06-19 15:19:17 +0200
commita88d5f54d61664dec9493b73cb9efb021e218169 (patch)
tree033922398c347b57e9877e1ccd6e7a0d799c3477 /src
parent6a0a800535f6de9f6028a5375abfaf1dae8c7c28 (diff)
Core/Conditions: implement CONDITION_QUEST_OBJECTIVE_PROGRESS to allow to apply conditions based on the player's quest objective progress (#23438)
* Core/Conditions: implement CONDITION_QUEST_OBJECTIVE_PROGRESS to allow to apply conditions based on the player's quest objective progress. * Update ConditionMgr.cpp
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp144
-rw-r--r--src/server/game/Conditions/ConditionMgr.h103
2 files changed, 148 insertions, 99 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index 71ee0029477..df88362328a 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -67,54 +67,56 @@ char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX]
ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[CONDITION_MAX] =
{
- { "None", false, false, false },
- { "Aura", true, true, true },
- { "Item Stored", true, true, true },
- { "Item Equipped", true, false, false },
- { "Zone", true, false, false },
- { "Reputation", true, true, false },
- { "Team", true, false, false },
- { "Skill", true, true, false },
- { "Quest Rewarded", true, false, false },
- { "Quest Taken", true, false, false },
- { "Drunken", true, false, false },
- { "WorldState", true, true, false },
- { "Active Event", true, false, false },
- { "Instance Info", true, true, true },
- { "Quest None", true, false, false },
- { "Class", true, false, false },
- { "Race", true, false, false },
- { "Achievement", true, false, false },
- { "Title", true, false, false },
- { "SpawnMask", true, false, false },
- { "Gender", true, false, false },
- { "Unit State", true, false, false },
- { "Map", true, false, false },
- { "Area", true, false, false },
- { "CreatureType", true, false, false },
- { "Spell Known", true, false, false },
- { "PhaseMask", true, false, false },
- { "Level", true, true, false },
- { "Quest Completed", true, false, false },
- { "Near Creature", true, true, true },
- { "Near GameObject", true, true, false },
- { "Object Entry or Guid", true, true, true },
- { "Object TypeMask", true, false, false },
- { "Relation", true, true, false },
- { "Reaction", true, true, false },
- { "Distance", true, true, true },
- { "Alive", false, false, false },
- { "Health Value", true, true, false },
- { "Health Pct", true, true, false },
- { "Realm Achievement", true, false, false },
- { "In Water", false, false, false },
- { "Terrain Swap", false, false, false },
- { "Sit/stand state", true, true, false },
- { "Daily Quest Completed",true, false, false },
- { "Charmed", false, false, false },
- { "Pet type", true, false, false },
- { "On Taxi", false, false, false },
- { "Quest state mask", true, true, false }
+ { "None", false, false, false },
+ { "Aura", true, true, true },
+ { "Item Stored", true, true, true },
+ { "Item Equipped", true, false, false },
+ { "Zone", true, false, false },
+ { "Reputation", true, true, false },
+ { "Team", true, false, false },
+ { "Skill", true, true, false },
+ { "Quest Rewarded", true, false, false },
+ { "Quest Taken", true, false, false },
+ { "Drunken", true, false, false },
+ { "WorldState", true, true, false },
+ { "Active Event", true, false, false },
+ { "Instance Info", true, true, true },
+ { "Quest None", true, false, false },
+ { "Class", true, false, false },
+ { "Race", true, false, false },
+ { "Achievement", true, false, false },
+ { "Title", true, false, false },
+ { "SpawnMask", true, false, false },
+ { "Gender", true, false, false },
+ { "Unit State", true, false, false },
+ { "Map", true, false, false },
+ { "Area", true, false, false },
+ { "CreatureType", true, false, false },
+ { "Spell Known", true, false, false },
+ { "PhaseMask", true, false, false },
+ { "Level", true, true, false },
+ { "Quest Completed", true, false, false },
+ { "Near Creature", true, true, true },
+ { "Near GameObject", true, true, false },
+ { "Object Entry or Guid", true, true, true },
+ { "Object TypeMask", true, false, false },
+ { "Relation", true, true, false },
+ { "Reaction", true, true, false },
+ { "Distance", true, true, true },
+ { "Alive", false, false, false },
+ { "Health Value", true, true, false },
+ { "Health Pct", true, true, false },
+ { "Realm Achievement", true, false, false },
+ { "In Water", false, false, false },
+ { "Terrain Swap", false, false, false },
+ { "Sit/stand state", true, true, false },
+ { "Daily Quest Completed", true, false, false },
+ { "Charmed", false, false, false },
+ { "Pet type", true, false, false },
+ { "On Taxi", false, false, false },
+ { "Quest state mask", true, true, false },
+ { "Quest objective progress", true, true, true },
+ { "Is Gamemaster", true, false, false }
};
// Checks if object meets the condition
@@ -499,6 +501,21 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) const
}
break;
}
+ case CONDITION_QUEST_OBJECTIVE_PROGRESS:
+ {
+ if (Player* player = object->ToPlayer())
+ {
+ const Quest* quest = sObjectMgr->GetQuestTemplate(ConditionValue1);
+ uint16 log_slot = player->FindQuestSlot(quest->GetQuestId());
+ uint32 progressCount = 0;
+ if (log_slot < MAX_QUEST_LOG_SIZE)
+ progressCount = player->GetQuestSlotCounter(log_slot, ConditionValue2);
+ if (progressCount == ConditionValue3)
+ condMeets = true;
+ }
+ break;
+ }
+
case CONDITION_GAMEMASTER:
{
if (Player* player = object->ToPlayer())
@@ -697,6 +714,9 @@ uint32 Condition::GetSearcherTypeMaskForCondition() const
case CONDITION_QUESTSTATE:
mask |= GRID_MAP_TYPE_MASK_PLAYER;
break;
+ case CONDITION_QUEST_OBJECTIVE_PROGRESS:
+ mask |= GRID_MAP_TYPE_MASK_PLAYER;
+ break;
case CONDITION_GAMEMASTER:
mask |= GRID_MAP_TYPE_MASK_PLAYER;
break;
@@ -2270,6 +2290,34 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) const
return false;
}
break;
+ case CONDITION_QUEST_OBJECTIVE_PROGRESS:
+ {
+ const Quest* quest = sObjectMgr->GetQuestTemplate(cond->ConditionValue1);
+ if (!quest)
+ {
+ TC_LOG_ERROR("sql.sql", "%s points to non-existing quest (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
+ return false;
+ }
+
+ if (cond->ConditionValue2 < 0 || cond->ConditionValue2 > 3)
+ {
+ TC_LOG_ERROR("sql.sql", "%s has out-of-range quest objective index specified (%u), it must be a number between 0 and 3. skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
+ return false;
+ }
+
+ if (quest->RequiredNpcOrGo[cond->ConditionValue2] == 0)
+ {
+ TC_LOG_ERROR("sql.sql", "%s has quest objective %u for quest %u, but the field RequiredNPCOrGo%u is 0, skipped.", cond->ToString(true).c_str(), cond->ConditionValue2, cond->ConditionValue1, cond->ConditionValue2);
+ return false;
+ }
+
+ if (cond->ConditionValue3 > quest->RequiredNpcOrGoCount[cond->ConditionValue2])
+ {
+ TC_LOG_ERROR("sql.sql", "%s has quest objective count %u in value3, but quest %u has a maximum objective count of %u in RequiredNPCOrGOCount%u, skipped.", cond->ToString(true).c_str(), cond->ConditionValue3, cond->ConditionValue2, quest->RequiredNpcOrGoCount[cond->ConditionValue2], cond->ConditionValue2);
+ return false;
+ }
+ break;
+ }
case CONDITION_IN_WATER:
case CONDITION_CHARMED:
case CONDITION_TAXI:
diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
index d3e6b7824cd..3e99d6acaed 100644
--- a/src/server/game/Conditions/ConditionMgr.h
+++ b/src/server/game/Conditions/ConditionMgr.h
@@ -33,57 +33,58 @@ class LootTemplate;
struct Condition;
enum ConditionTypes
-{ // 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_WORLD_STATE = 11, // index value 0 true if world has the value for the index
- CONDITION_ACTIVE_EVENT = 12, // event_id 0 0 true if event is active
- CONDITION_INSTANCE_INFO = 13, // entry data type true if the instance info defined by type (enum InstanceInfo) equals data.
- 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_TITLE = 18, // title id 0 0 true if player has title
- CONDITION_SPAWNMASK = 19, // spawnMask 0 0 true if in spawnMask
- CONDITION_GENDER = 20, // gender 0 0 true if player's gender is equal to gender
- CONDITION_UNIT_STATE = 21, // unitState 0 0 true if unit has unitState
- 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_CREATURE_TYPE = 24, // cinfo.type 0 0 true if creature_template.type = value1
- CONDITION_SPELL = 25, // spell_id 0 0 true if player has learned spell
- CONDITION_PHASEMASK = 26, // phasemask 0 0 true if object is in phasemask
- 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 dead (0/1) 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_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
- 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_REALM_ACHIEVEMENT = 39, // achievement_id 0 0 true if realm achievement is complete
- CONDITION_IN_WATER = 40, // 0 0 0 true if unit in water
- CONDITION_TERRAIN_SWAP = 41, // only for master branch
- CONDITION_STAND_STATE = 42, // stateType state 0 true if unit matches specified sitstate (0,x: has exactly state x; 1,0: any standing state; 1,1: any sitting state;)
- CONDITION_DAILY_QUEST_DONE = 43, // quest id 0 0 true if daily quest has been completed for the day
- CONDITION_CHARMED = 44, // 0 0 0 true if unit is currently charmed
- CONDITION_PET_TYPE = 45, // mask 0 0 true if player has a pet of given type(s)
- CONDITION_TAXI = 46, // 0 0 0 true if player is on taxi
- CONDITION_QUESTSTATE = 47, // quest_id state_mask 0 true if player is in any of the provided quest states for the quest (1 = not taken, 2 = completed, 8 = in progress, 32 = failed, 64 = rewarded)
- CONDITION_GAMEMASTER = 48, // canBeGM 0 0 true if player is gamemaster (or can be gamemaster)
- CONDITION_MAX = 49 // MAX
+{ // 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_WORLD_STATE = 11, // index value 0 true if world has the value for the index
+ CONDITION_ACTIVE_EVENT = 12, // event_id 0 0 true if event is active
+ CONDITION_INSTANCE_INFO = 13, // entry data type true if the instance info defined by type (enum InstanceInfo) equals data.
+ 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_TITLE = 18, // title id 0 0 true if player has title
+ CONDITION_SPAWNMASK = 19, // spawnMask 0 0 true if in spawnMask
+ CONDITION_GENDER = 20, // gender 0 0 true if player's gender is equal to gender
+ CONDITION_UNIT_STATE = 21, // unitState 0 0 true if unit has unitState
+ 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_CREATURE_TYPE = 24, // cinfo.type 0 0 true if creature_template.type = value1
+ CONDITION_SPELL = 25, // spell_id 0 0 true if player has learned spell
+ CONDITION_PHASEMASK = 26, // phasemask 0 0 true if object is in phasemask
+ 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 dead (0/1) 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_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
+ 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_REALM_ACHIEVEMENT = 39, // achievement_id 0 0 true if realm achievement is complete
+ CONDITION_IN_WATER = 40, // 0 0 0 true if unit in water
+ CONDITION_TERRAIN_SWAP = 41, // only for master branch
+ CONDITION_STAND_STATE = 42, // stateType state 0 true if unit matches specified sitstate (0,x: has exactly state x; 1,0: any standing state; 1,1: any sitting state;)
+ CONDITION_DAILY_QUEST_DONE = 43, // quest id 0 0 true if daily quest has been completed for the day
+ CONDITION_CHARMED = 44, // 0 0 0 true if unit is currently charmed
+ CONDITION_PET_TYPE = 45, // mask 0 0 true if player has a pet of given type(s)
+ CONDITION_TAXI = 46, // 0 0 0 true if player is on taxi
+ CONDITION_QUESTSTATE = 47, // quest_id state_mask 0 true if player is in any of the provided quest states for the quest (1 = not taken, 2 = completed, 8 = in progress, 32 = failed, 64 = rewarded)
+ CONDITION_QUEST_OBJECTIVE_PROGRESS = 48, // quest_id objectiveIndex objectiveCount true if player has reached the specified objectiveCount quest progress for the objectiveIndex for the specified quest
+ CONDITION_GAMEMASTER = 49, // canBeGM 0 0 true if player is gamemaster (or can be gamemaster)
+ CONDITION_MAX = 50 // MAX
};
/*! Documentation on implementing a new ConditionSourceType: