Core/Conditions: Implemented new condition source type CONDITION_SOURCE_TYPE_PLAYER_CHOICE_RESPONSE

Port From (https://github.com/TrinityCore/TrinityCore/commit/952f3227108bac415d01f898963ee65bd4d58123)
This commit is contained in:
Hondacrx
2025-08-18 15:55:25 -04:00
parent ebd9c9e636
commit 5b6c783823
3 changed files with 30 additions and 1 deletions
@@ -106,6 +106,7 @@ namespace Framework.Constants
SpawnGroup = 33,
PlayerCondition = 34,
SkillLineAbility = 35,
PlayerChoiceResponse = 36,
MaxDbAllowed,
ReferenceCondition = MaxDbAllowed,
@@ -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:
+3 -1
View File
@@ -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;