From 83eace222c52f901e2f6190f52f1e729e49c0aba Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Mon, 11 Nov 2024 11:02:05 -0500 Subject: [PATCH] Core/SAI: Implemented new action SMART_ACTION_CREDIT_QUEST_OBJECTIVE_TALK_TO Port From (https://github.com/TrinityCore/TrinityCore/commit/9261140c9ddc5b15bc2e0abe9d8755552ae74d82) --- Source/Framework/Constants/SmartAIConst.cs | 1 + Source/Game/AI/SmartScripts/SmartAIManager.cs | 12 ++++++++++++ Source/Game/AI/SmartScripts/SmartScript.cs | 15 +++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/Source/Framework/Constants/SmartAIConst.cs b/Source/Framework/Constants/SmartAIConst.cs index 3b318a5e8..f2eeb2b14 100644 --- a/Source/Framework/Constants/SmartAIConst.cs +++ b/Source/Framework/Constants/SmartAIConst.cs @@ -390,6 +390,7 @@ namespace Framework.Constants TriggerGameEvent = 150, // eventId, useSaiTargetAsGameEventSource DoAction = 151, CompleteQuest = 152, // QuestId. Regular quests with objectives can't be completed with this action (only quests with QUEST_FLAGS_COMPLETION_EVENT, QUEST_FLAGS_COMPLETION_AREA_TRIGGER or QUEST_FLAGS_TRACKING_EVENT) + CreditQuestObjectiveTalkTo = 153, End } diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index c9367f43e..e09a3263a 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -816,6 +816,7 @@ namespace Game.AI SmartActions.TriggerGameEvent => Marshal.SizeOf(typeof(SmartAction.TriggerGameEvent)), SmartActions.DoAction => Marshal.SizeOf(typeof(SmartAction.DoAction)), SmartActions.CompleteQuest => Marshal.SizeOf(typeof(SmartAction.Quest)), + SmartActions.CreditQuestObjectiveTalkTo => 0, _ => Marshal.SizeOf(typeof(SmartAction.Raw)), }; @@ -2189,6 +2190,7 @@ namespace Game.AI break; } case SmartActions.CompleteQuest: + { Quest quest = Global.ObjectMgr.GetQuestTemplate(e.Action.quest.questId); if (quest != null) { @@ -2204,6 +2206,16 @@ namespace Game.AI return false; } break; + } + case SmartActions.CreditQuestObjectiveTalkTo: + { + if (e.GetScriptType() != SmartScriptType.Creature) + { + Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses non-valid SourceType (only valid for SourceType {SmartScriptType.Creature}), skipped."); + return false; + } + break; + } // No longer supported case SmartActions.CallAreaexploredoreventhappens: case SmartActions.CallGroupeventhappens: diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 1dff52620..9b6551109 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -2559,6 +2559,21 @@ namespace Game.AI break; } + case SmartActions.CreditQuestObjectiveTalkTo: + { + if (_me == null) + break; + + foreach (WorldObject target in targets) + { + Player player = target?.ToPlayer(); + if (player == null) + continue; + + player.TalkedToCreature(_me.GetEntry(), _me.GetGUID()); + } + break; + } default: Log.outError(LogFilter.Sql, "SmartScript.ProcessAction: Entry {0} SourceType {1}, Event {2}, Unhandled Action type {3}", e.EntryOrGuid, e.GetScriptType(), e.EventId, e.GetActionType()); break;