Core/SAI: Add SAI action to create a conversation (#26169)

This commit is contained in:
Matan Shukry
2021-02-27 12:22:55 +02:00
committed by GitHub
parent 87ec98dd21
commit 0996d60944
3 changed files with 37 additions and 1 deletions

View File

@@ -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;

View File

@@ -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:

View File

@@ -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