From 5b6c783823670d6c9b7f8dccb8037779700988bb Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Mon, 18 Aug 2025 15:55:25 -0400 Subject: [PATCH] Core/Conditions: Implemented new condition source type CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE Port From (https://github.com/TrinityCore/TrinityCore/commit/952f3227108bac415d01f898963ee65bd4d58123) --- Source/Framework/Constants/ConditionConst.cs | 1 + Source/Game/Conditions/ConditionManager.cs | 26 ++++++++++++++++++++ Source/Game/Entities/Player/Player.cs | 4 ++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Source/Framework/Constants/ConditionConst.cs b/Source/Framework/Constants/ConditionConst.cs index 07a899abc..2f49d44df 100644 --- a/Source/Framework/Constants/ConditionConst.cs +++ b/Source/Framework/Constants/ConditionConst.cs @@ -106,6 +106,7 @@ namespace Framework.Constants SpawnGroup = 33, PlayerCondition = 34, SkillLineAbility = 35, + PlayerChoiceResponse = 36, MaxDbAllowed, ReferenceCondition = MaxDbAllowed, diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index 4a639498c..5caa19373 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -290,6 +290,17 @@ namespace Game return true; } + public bool IsObjectMeetingPlayerChoiceResponseConditions(uint playerChoiceId, int playerChoiceResponseId, Player player) + { + var list = ConditionStorage[ConditionSourceType.PlayerChoiceResponse].LookupByKey(new ConditionId(playerChoiceId, playerChoiceResponseId, 0)); + if (list != null) + { + Log.outDebug(LogFilter.Condition, $"GetConditionsForNpcVendor: found conditions for creature entry {playerChoiceId} item {playerChoiceResponseId}"); + return IsObjectMeetToConditions(player, list); + } + return true; + } + public bool IsSpellUsedInSpellClickConditions(uint spellId) { return spellsUsedInSpellClickConditions.Contains(spellId); @@ -1135,6 +1146,21 @@ namespace Game } break; } + case ConditionSourceType.PlayerChoiceResponse: + { + PlayerChoice playerChoice = Global.ObjectMgr.GetPlayerChoice((int)cond.SourceGroup); + if (playerChoice == null) + { + Log.outError(LogFilter.Sql, $"{cond} SourceGroup in `condition` table, does not exist in `playerchoice`, ignoring."); + return false; + } + if (playerChoice.GetResponse(cond.SourceEntry) == null) + { + Log.outError(LogFilter.Sql, $"{cond} SourceEntry in `condition` table, does not exist in `playerchoice_response`, ignoring."); + return false; + } + break; + } case ConditionSourceType.GossipMenu: case ConditionSourceType.GossipMenuOption: case ConditionSourceType.SmartEvent: diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index 50218112d..f02bcf7a2 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -4972,8 +4972,10 @@ namespace Game.Entities for (var i = 0; i < playerChoice.Responses.Count; ++i) { PlayerChoiceResponse playerChoiceResponseTemplate = playerChoice.Responses[i]; - var playerChoiceResponse = new Networking.Packets.PlayerChoiceResponse(); + if (!Global.ConditionMgr.IsObjectMeetingPlayerChoiceResponseConditions((uint)choiceId, playerChoiceResponseTemplate.ResponseId, this)) + continue; + var playerChoiceResponse = new Networking.Packets.PlayerChoiceResponse(); playerChoiceResponse.ResponseID = playerChoiceResponseTemplate.ResponseId; playerChoiceResponse.ResponseIdentifier = playerChoiceResponseTemplate.ResponseIdentifier; playerChoiceResponse.ChoiceArtFileID = playerChoiceResponseTemplate.ChoiceArtFileId;