aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Conditions/ConditionMgr.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2025-06-20 23:09:01 +0200
committerShauren <shauren.trinity@gmail.com>2025-06-20 23:09:01 +0200
commit952f3227108bac415d01f898963ee65bd4d58123 (patch)
tree23d6f167ed3e1bbd9504646cc04da568ebb686ab /src/server/game/Conditions/ConditionMgr.cpp
parent7c9884c15e1f388b8e8e4b59dea57ab431dc1e6e (diff)
Core/Conditions: Implemented new condition source type CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE
Diffstat (limited to 'src/server/game/Conditions/ConditionMgr.cpp')
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index a3d603474e3..68b4a27896c 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -95,7 +95,8 @@ char const* const ConditionMgr::StaticSourceTypeData[CONDITION_SOURCE_TYPE_MAX_D
"Object Visibility (by ID)",
"Spawn Group",
"Player Condition",
- "Skill Line Ability"
+ "Skill Line Ability",
+ "Player Choice Response"
};
ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[CONDITION_MAX] =
@@ -1228,6 +1229,17 @@ bool ConditionMgr::IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32
return true;
}
+bool ConditionMgr::IsObjectMeetingPlayerChoiceResponseConditions(uint32 playerChoiceId, int32 playerChoiceResponseId, Player const* player) const
+{
+ auto itr = ConditionStore[CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE].find({ .SourceGroup = playerChoiceId, .SourceEntry = playerChoiceResponseId, .SourceId = 0 });
+ if (itr != ConditionStore[CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE].end())
+ {
+ TC_LOG_DEBUG("condition", "GetConditionsForNpcVendor: found conditions for creature entry {} item {}", playerChoiceId, playerChoiceResponseId);
+ return IsObjectMeetToConditions(player, *itr->second);
+ }
+ return true;
+}
+
bool ConditionMgr::IsSpellUsedInSpellClickConditions(uint32 spellId) const
{
return SpellsUsedInSpellClickConditions.find(spellId) != SpellsUsedInSpellClickConditions.end();
@@ -2093,6 +2105,21 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond) const
}
break;
}
+ case CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE:
+ {
+ PlayerChoice const* playerChoice = sObjectMgr->GetPlayerChoice(cond->SourceGroup);
+ if (!playerChoice)
+ {
+ TC_LOG_ERROR("sql.sql", "{} SourceGroup in `condition` table, does not exist in `playerchoice`, ignoring.", cond->ToString());
+ return false;
+ }
+ if (!playerChoice->GetResponse(cond->SourceEntry))
+ {
+ TC_LOG_ERROR("sql.sql", "{} SourceEntry in `condition` table, does not exist in `playerchoice_response`, ignoring.", cond->ToString());
+ return false;
+ }
+ break;
+ }
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
case CONDITION_SOURCE_TYPE_SMART_EVENT: