mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-18 00:18:43 +01:00
Core/SAI: Add SAI action to create a conversation (#26169)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user