aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Conditions
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
parent7c9884c15e1f388b8e8e4b59dea57ab431dc1e6e (diff)
Core/Conditions: Implemented new condition source type CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE
Diffstat (limited to 'src/server/game/Conditions')
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp29
-rw-r--r--src/server/game/Conditions/ConditionMgr.h2
2 files changed, 30 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:
diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h
index 9980742420b..54eb2344882 100644
--- a/src/server/game/Conditions/ConditionMgr.h
+++ b/src/server/game/Conditions/ConditionMgr.h
@@ -188,6 +188,7 @@ enum ConditionSourceType
CONDITION_SOURCE_TYPE_SPAWN_GROUP = 33,
CONDITION_SOURCE_TYPE_PLAYER_CONDITION = 34,
CONDITION_SOURCE_TYPE_SKILL_LINE_ABILITY = 35,
+ CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE = 36,
CONDITION_SOURCE_TYPE_MAX_DB_ALLOWED,
CONDITION_SOURCE_TYPE_REFERENCE_CONDITION = CONDITION_SOURCE_TYPE_MAX_DB_ALLOWED, // internal, not set in db
@@ -327,6 +328,7 @@ class TC_GAME_API ConditionMgr
bool IsObjectMeetingVehicleSpellConditions(uint32 creatureId, uint32 spellId, Player const* player, Unit const* vehicle) const;
bool IsObjectMeetingSmartEventConditions(int64 entryOrGuid, uint32 eventId, uint32 sourceType, Unit const* unit, WorldObject const* baseObject) const;
bool IsObjectMeetingVendorItemConditions(uint32 creatureId, uint32 itemId, Player const* player, Creature const* vendor) const;
+ bool IsObjectMeetingPlayerChoiceResponseConditions(uint32 playerChoiceId, int32 playerChoiceResponseId, Player const* player) const;
bool IsSpellUsedInSpellClickConditions(uint32 spellId) const;