Core/PacketIO: Implemented CMSG_CONVERSATION_LINE_STARTED (#27036)

* Added OnConversationLineStarted hook to ConversationScripts
* Added example for Defender of Azeroth conversation
This commit is contained in:
ModoX
2021-10-12 00:16:20 +02:00
committed by GitHub
parent 9b036b8fe0
commit 6d9ce8e8ba
10 changed files with 94 additions and 2 deletions

View File

@@ -0,0 +1,18 @@
--
DELETE FROM `conversation_line_template` WHERE `Id` IN (32915, 32916, 32917, 32918, 32919, 32926);
INSERT INTO `conversation_line_template` (`Id`, `StartTime`, `UiCameraID`, `ActorIdx`, `Flags`, `VerifiedBuild`) VALUES
(32915, 0, 0, 0, 0, 40120),
(32916, 9878, 0, 0, 0, 40120),
(32917, 22389, 0, 0, 0, 40120),
(32918, 33855, 0, 0, 0, 40120),
(32919, 43842, 0, 0, 0, 40120),
(32926, 55409, 0, 1, 1, 40120);
DELETE FROM `conversation_template` WHERE `Id`=13254;
INSERT INTO `conversation_template` (`Id`, `FirstLineID`, `LastLineEndTime`, `TextureKitId`, `ScriptName`, `VerifiedBuild`) VALUES
(13254, 32915, 55409, 0, 'conversation_allied_race_dk_defender_of_azeroth', 40120);
DELETE FROM `conversation_actors` WHERE (`ConversationId`=13254 AND `Idx`=0);
INSERT INTO `conversation_actors` (`ConversationId`, `ConversationActorId`, `ConversationActorGuid`, `Idx`, `VerifiedBuild`) VALUES
-- (13254, 0, 0, 1, 40120), -- Full: 0x0800040000000000FFFFFFFFFFFFFFFF Player/0 R1/S16777215 Map: 0 (Eastern Kingdoms) Low: 1099511627775
(13254, 74042, 1050053, 0, 40120); -- Full: 0x203AF51F209DEB400009E0000059DA73 Creature/0 R3773/S2528 Map: 2297 (Icecrown Citadel (8.3)) Entry: 161709 (Highlord Darion Mograine) Low: 5888627

View File

@@ -123,7 +123,7 @@ bool Conversation::Create(ObjectGuid::LowType lowGuid, uint32 conversationEntry,
SetObjectScale(1.0f);
SetUpdateFieldValue(m_values.ModifyValue(&Conversation::m_conversationData).ModifyValue(&UF::ConversationData::LastLineEndTime), conversationTemplate->LastLineEndTime);
_duration = conversationTemplate->LastLineEndTime;
_duration = conversationTemplate->LastLineEndTime + 10 * IN_MILLISECONDS;
_textureKitId = conversationTemplate->TextureKitId;
for (ConversationActor const& actor : conversationTemplate->Actors)

View File

@@ -25,6 +25,7 @@
#include "CinematicMgr.h"
#include "ClientConfigPackets.h"
#include "Common.h"
#include "Conversation.h"
#include "Corpse.h"
#include "DatabaseEnv.h"
#include "DB2Stores.h"
@@ -1161,3 +1162,9 @@ void WorldSession::HandleCloseInteraction(WorldPackets::Misc::CloseInteraction&
if (_player->PlayerTalkClass->GetInteractionData().SourceGuid == closeInteraction.SourceGuid)
_player->PlayerTalkClass->GetInteractionData().Reset();
}
void WorldSession::HandleConversationLineStarted(WorldPackets::Misc::ConversationLineStarted& conversationLineStarted)
{
if (Conversation* convo = ObjectAccessor::GetConversation(*_player, conversationLineStarted.ConversationGUID))
sScriptMgr->OnConversationLineStarted(convo, conversationLineStarted.LineID, _player);
}

View File

@@ -2171,6 +2171,15 @@ void ScriptMgr::OnConversationCreate(Conversation* conversation, Unit* creator)
tmpscript->OnConversationCreate(conversation, creator);
}
void ScriptMgr::OnConversationLineStarted(Conversation* conversation, uint32 lineId, Player* sender)
{
ASSERT(conversation);
ASSERT(sender);
GET_SCRIPT(ConversationScript, conversation->GetScriptId(), tmpscript);
tmpscript->OnConversationLineStarted(conversation, lineId, sender);
}
// Scene
void ScriptMgr::OnSceneStart(Player* player, uint32 sceneInstanceID, SceneTemplate const* sceneTemplate)
{

View File

@@ -828,6 +828,9 @@ class TC_GAME_API ConversationScript : public ScriptObject
// Called when Conversation is created but not added to Map yet.
virtual void OnConversationCreate(Conversation* /*conversation*/, Unit* /*creator*/) { }
// Called when player sends CMSG_CONVERSATION_LINE_STARTED with valid conversation guid
virtual void OnConversationLineStarted(Conversation* /*conversation*/, uint32 /*lineId*/, Player* /*sender*/) { }
};
class TC_GAME_API SceneScript : public ScriptObject
@@ -1132,6 +1135,7 @@ class TC_GAME_API ScriptMgr
public: /* ConversationScript */
void OnConversationCreate(Conversation* conversation, Unit* creator);
void OnConversationLineStarted(Conversation* conversation, uint32 lineId, Player* sender);
public: /* SceneScript */

View File

@@ -722,3 +722,9 @@ WorldPacket const* WorldPackets::Misc::StartTimer::Write()
return &_worldPacket;
}
void WorldPackets::Misc::ConversationLineStarted::Read()
{
_worldPacket >> ConversationGUID;
_worldPacket >> LineID;
}

View File

@@ -922,6 +922,17 @@ namespace WorldPackets
Duration<Seconds> TimeLeft;
Duration<Seconds> TotalTime;
};
class ConversationLineStarted final : public ClientPacket
{
public:
ConversationLineStarted(WorldPacket&& packet) : ClientPacket(CMSG_CONVERSATION_LINE_STARTED, std::move(packet)) { }
void Read() override;
ObjectGuid ConversationGUID;
uint32 LineID = 0;
};
}
}

View File

@@ -354,7 +354,7 @@ void OpcodeTable::Initialize()
DEFINE_HANDLER(CMSG_CONSUMABLE_TOKEN_REDEEM_CONFIRMATION, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_CONTRIBUTION_CONTRIBUTE, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_CONTRIBUTION_LAST_UPDATE_REQUEST, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_CONVERSATION_LINE_STARTED, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_CONVERSATION_LINE_STARTED, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleConversationLineStarted);
DEFINE_HANDLER(CMSG_CONVERT_RAID, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleConvertRaidOpcode);
DEFINE_HANDLER(CMSG_COVENANT_RENOWN_REQUEST_CATCHUP_STATE, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL);
DEFINE_HANDLER(CMSG_CREATE_CHARACTER, STATUS_AUTHED, PROCESS_THREADUNSAFE, &WorldSession::HandleCharCreateOpcode);

View File

@@ -517,6 +517,7 @@ namespace WorldPackets
class SetTaxiBenchmarkMode;
class MountSetFavorite;
class CloseInteraction;
class ConversationLineStarted;
}
namespace Movement
@@ -1716,6 +1717,7 @@ class TC_GAME_API WorldSession
void HandleObjectUpdateRescuedOpcode(WorldPackets::Misc::ObjectUpdateRescued& objectUpdateRescued);
void HandleRequestCategoryCooldowns(WorldPackets::Spells::RequestCategoryCooldowns& requestCategoryCooldowns);
void HandleCloseInteraction(WorldPackets::Misc::CloseInteraction& closeInteraction);
void HandleConversationLineStarted(WorldPackets::Misc::ConversationLineStarted& conversationLineStarted);
// Adventure Journal
void HandleAdventureJournalOpenQuest(WorldPackets::AdventureJournal::AdventureJournalOpenQuest& openQuest);

View File

@@ -15,6 +15,41 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptMgr.h"
#include "Conversation.h"
#include "ObjectAccessor.h"
#include "Player.h"
class conversation_allied_race_dk_defender_of_azeroth : public ConversationScript
{
public:
enum DefenderOfAzerothIds : uint32
{
NPC_TALK_TO_YOUR_COMMANDER_CREDIT = 161709,
NPC_LISTEN_TO_YOUR_COMMANDER_CREDIT = 163027,
CONVERSATION_LINE_PLAYER = 32926
};
conversation_allied_race_dk_defender_of_azeroth() : ConversationScript("conversation_allied_race_dk_defender_of_azeroth") { }
void OnConversationCreate(Conversation* conversation, Unit* creator) override
{
conversation->AddActor(ObjectGuid::Create<HighGuid::Player>(0xFFFFFFFFFFFFFFFF), 1);
if (Player* player = creator->ToPlayer())
player->KilledMonsterCredit(NPC_TALK_TO_YOUR_COMMANDER_CREDIT);
}
void OnConversationLineStarted(Conversation* /*conversation*/, uint32 lineId, Player* sender) override
{
if (lineId != CONVERSATION_LINE_PLAYER)
return;
sender->KilledMonsterCredit(NPC_LISTEN_TO_YOUR_COMMANDER_CREDIT);
}
};
void AddSC_conversation_scripts()
{
new conversation_allied_race_dk_defender_of_azeroth();
}