aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatan Shukry <matanshukry@gmail.com>2021-02-27 12:22:55 +0200
committerGitHub <noreply@github.com>2021-02-27 11:22:55 +0100
commit0996d60944dba87f89f393541c009dedeccb45a4 (patch)
tree9447da2610fc1281f43962a34ea73124aba1c56e
parent87ec98dd216d22a1dfd7d7623813049649eb715f (diff)
Core/SAI: Add SAI action to create a conversation (#26169)
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp19
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp11
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h8
3 files changed, 37 insertions, 1 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index d0f77855045..a8fcc5a0c88 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -2362,6 +2362,25 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;
}
+ case SMART_ACTION_TALK_CONVERSATION:
+ {
+ if (WorldObject* baseObject = GetBaseObject())
+ {
+ for (WorldObject* const target : targets)
+ {
+ if (Player* playerTarget = target->ToPlayer())
+ {
+ Conversation* conversation = Conversation::CreateConversation(e.action.conversation.id, playerTarget,
+ *playerTarget, { playerTarget->GetGUID() }, nullptr);
+ if (!conversation)
+ TC_LOG_WARN("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_TALK_CONVERSATION: id %u, baseObject %s, target %s - failed to create",
+ e.action.conversation.id, baseObject->GetName().c_str(), playerTarget->GetName().c_str());
+ }
+ }
+ }
+
+ break;
+ }
default:
TC_LOG_ERROR("sql.sql", "SmartScript::ProcessAction: Entry " SI64FMTD " SourceType %u, Event %u, Unhandled Action type %u", 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 0a0ad9aa821..fba5afff02c 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -18,6 +18,7 @@
#include "SmartScriptMgr.h"
#include "AreaTriggerDataStore.h"
#include "AreaTriggerTemplate.h"
+#include "ConversationDataStore.h"
#include "CreatureTextMgr.h"
#include "DB2Stores.h"
#include "DatabaseEnv.h"
@@ -1571,6 +1572,16 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
break;
}
+ case SMART_ACTION_TALK_CONVERSATION:
+ {
+ if (!sConversationDataStore->GetConversationTemplate(e.action.conversation.id))
+ {
+ TC_LOG_ERROR("sql.sql", "SmartAIMgr: SMART_ACTION_TALK_CONVERSATION Entry " SI64FMTD " SourceType %u Event %u Action %u uses invalid entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.conversation.id);
+ return false;
+ }
+
+ break;
+ }
case SMART_ACTION_FOLLOW:
case SMART_ACTION_SET_ORIENTATION:
case SMART_ACTION_STORE_TARGET_LIST:
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index 007d5918d7f..edada851a59 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -594,7 +594,8 @@ enum SMART_ACTION
SMART_ACTION_PLAY_CINEMATIC = 135, // reserved for future uses
SMART_ACTION_SET_MOVEMENT_SPEED = 136, // movementType, speedInteger, speedFraction
SMART_ACTION_PLAY_SPELL_VISUAL_KIT = 137, // spellVisualKitId, kitType (unknown values, copypaste from packet dumps), duration
- SMART_ACTION_END = 138
+ SMART_ACTION_TALK_CONVERSATION = 143, // conversation_template.id
+ SMART_ACTION_END = 144
};
enum class SmartActionSummonCreatureFlags
@@ -1182,6 +1183,11 @@ struct SmartAction
uint32 duration;
} spellVisualKit;
+ struct
+ {
+ uint32 id;
+ } conversation;
+
//! Note for any new future actions
//! All parameters must have type uint32