aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorModoX <moardox@gmail.com>2021-10-12 00:16:20 +0200
committerGitHub <noreply@github.com>2021-10-12 00:16:20 +0200
commit6d9ce8e8baa100ecc7650d0ae56037c131bab2e0 (patch)
tree911d162cb936f3e7bc7c79dfe79b7f6002aee8a7
parent9b036b8fe0c443acd882de9faf615abe89dad691 (diff)
Core/PacketIO: Implemented CMSG_CONVERSATION_LINE_STARTED (#27036)
* Added OnConversationLineStarted hook to ConversationScripts * Added example for Defender of Azeroth conversation
-rw-r--r--sql/updates/world/master/2021_10_12_00_world.sql18
-rw-r--r--src/server/game/Entities/Conversation/Conversation.cpp2
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp7
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp9
-rw-r--r--src/server/game/Scripting/ScriptMgr.h4
-rw-r--r--src/server/game/Server/Packets/MiscPackets.cpp6
-rw-r--r--src/server/game/Server/Packets/MiscPackets.h11
-rw-r--r--src/server/game/Server/Protocol/Opcodes.cpp2
-rw-r--r--src/server/game/Server/WorldSession.h2
-rw-r--r--src/server/scripts/World/conversation_scripts.cpp35
10 files changed, 94 insertions, 2 deletions
diff --git a/sql/updates/world/master/2021_10_12_00_world.sql b/sql/updates/world/master/2021_10_12_00_world.sql
new file mode 100644
index 00000000000..160a65769ec
--- /dev/null
+++ b/sql/updates/world/master/2021_10_12_00_world.sql
@@ -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
diff --git a/src/server/game/Entities/Conversation/Conversation.cpp b/src/server/game/Entities/Conversation/Conversation.cpp
index 826d6dac525..2d8a0621d31 100644
--- a/src/server/game/Entities/Conversation/Conversation.cpp
+++ b/src/server/game/Entities/Conversation/Conversation.cpp
@@ -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)
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index 0f8ad12a769..e7431a92e9a 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -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);
+}
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index a74251922c3..fc7ac25b3da 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -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)
{
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index bd3e383572c..9b4bd01e2b6 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -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 */
diff --git a/src/server/game/Server/Packets/MiscPackets.cpp b/src/server/game/Server/Packets/MiscPackets.cpp
index dec97e556ab..cb998d0b62d 100644
--- a/src/server/game/Server/Packets/MiscPackets.cpp
+++ b/src/server/game/Server/Packets/MiscPackets.cpp
@@ -722,3 +722,9 @@ WorldPacket const* WorldPackets::Misc::StartTimer::Write()
return &_worldPacket;
}
+
+void WorldPackets::Misc::ConversationLineStarted::Read()
+{
+ _worldPacket >> ConversationGUID;
+ _worldPacket >> LineID;
+}
diff --git a/src/server/game/Server/Packets/MiscPackets.h b/src/server/game/Server/Packets/MiscPackets.h
index 7b0e25514ae..ebad7696cc2 100644
--- a/src/server/game/Server/Packets/MiscPackets.h
+++ b/src/server/game/Server/Packets/MiscPackets.h
@@ -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;
+ };
}
}
diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp
index cad41a689a6..1fd3c2b0acf 100644
--- a/src/server/game/Server/Protocol/Opcodes.cpp
+++ b/src/server/game/Server/Protocol/Opcodes.cpp
@@ -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);
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 93c6ee84f66..c9e36d54e88 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -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);
diff --git a/src/server/scripts/World/conversation_scripts.cpp b/src/server/scripts/World/conversation_scripts.cpp
index 9d237f0502f..6d5de609e63 100644
--- a/src/server/scripts/World/conversation_scripts.cpp
+++ b/src/server/scripts/World/conversation_scripts.cpp
@@ -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();
}