diff options
author | ModoX <moardox@gmail.com> | 2025-07-17 13:23:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-17 13:23:24 +0200 |
commit | e9e7059a23618e58e57dc3b24eb218505ca3f746 (patch) | |
tree | 6aed1d69ed179a7a9d91e37bffbb6c6db9093ab2 /src/server | |
parent | 0cb2932e84fa297056b63caa2c983e3bb365d392 (diff) |
Core/SAI: Implemented action type SMART_ACTION_DESTROY_CONVERSATION (#31133)
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 23 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.cpp | 12 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.h | 10 |
3 files changed, 44 insertions, 1 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index d089abc9ca7..dd4c844bd27 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -2644,6 +2644,29 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } break; } + case SMART_ACTION_DESTROY_CONVERSATION: + { + auto work = [&](Conversation* conversation) + { + if (conversation->GetEntry() != e.action.destroyConversation.id) + return; + + if (conversation->IsPrivateObject()) + { + if (!e.action.destroyConversation.isPrivate + || !advstd::ranges::contains(targets, conversation->GetPrivateObjectOwner(), [](WorldObject const* target) { return target->GetGUID(); })) + return; + } + else if (e.action.destroyConversation.isPrivate) + return; + + conversation->Remove(); + }; + + Trinity::ConversationWorker worker(PhasingHandler::GetAlwaysVisiblePhaseShift(), work); + Cell::VisitGridObjects(GetBaseObject(), worker, float(e.action.destroyConversation.range)); + break; + } default: TC_LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry {} SourceType {}, Event {}, Unhandled Action type {}", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); break; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index 4e2750ee62f..471740a625e 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -1029,6 +1029,7 @@ bool SmartAIMgr::CheckUnusedActionParams(SmartScriptHolder const& e) case SMART_ACTION_DO_ACTION: return sizeof(SmartAction::doAction); case SMART_ACTION_COMPLETE_QUEST: return sizeof(SmartAction::quest); case SMART_ACTION_CREDIT_QUEST_OBJECTIVE_TALK_TO: return NO_PARAMS; + case SMART_ACTION_DESTROY_CONVERSATION: return sizeof(SmartAction::destroyConversation); default: TC_LOG_WARN("sql.sql", "SmartAIMgr: Entry {} SourceType {} Event {} Action {} is using an action with no unused params specified in SmartAIMgr::CheckUnusedActionParams(), please report this.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); @@ -2467,6 +2468,17 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) } break; } + case SMART_ACTION_DESTROY_CONVERSATION: + { + if (!sConversationDataStore->GetConversationTemplate(e.action.destroyConversation.id)) + { + TC_LOG_ERROR("sql.sql", "SmartAIMgr: SMART_ACTION_DESTROY_CONVERSATION Entry {} SourceType {} Event {} Action {} uses invalid entry {}, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.destroyConversation.id); + return false; + } + + TC_SAI_IS_BOOLEAN_VALID(e, e.action.destroyConversation.isPrivate); + break; + } // Unused case SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: case SMART_ACTION_CALL_GROUPEVENTHAPPENS: diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index ac69660cae5..577e2b23389 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -607,7 +607,8 @@ enum SMART_ACTION SMART_ACTION_DO_ACTION = 151, // actionId SMART_ACTION_COMPLETE_QUEST = 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) SMART_ACTION_CREDIT_QUEST_OBJECTIVE_TALK_TO = 153, - SMART_ACTION_END = 154 + SMART_ACTION_DESTROY_CONVERSATION = 154, // conversation_template.id, isPrivate, range + SMART_ACTION_END = 155 }; enum class SmartActionSummonCreatureFlags @@ -1242,6 +1243,13 @@ struct SmartAction uint32 actionId; } doAction; + struct + { + uint32 id; + SAIBool isPrivate; + uint32 range; + } destroyConversation; + //! Note for any new future actions //! All parameters must have type uint32 |