diff --git a/apps/openmw-mp/Script/Functions/Dialogue.cpp b/apps/openmw-mp/Script/Functions/Dialogue.cpp index 02339cca5..eacf21dcb 100644 --- a/apps/openmw-mp/Script/Functions/Dialogue.cpp +++ b/apps/openmw-mp/Script/Functions/Dialogue.cpp @@ -68,3 +68,15 @@ void DialogueFunctions::PlayAnimation(unsigned short pid, const char* groupname, mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ANIM_PLAY)->Send(false); mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ANIM_PLAY)->Send(true); } + +void DialogueFunctions::PlaySpeech(unsigned short pid, const char* sound) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + + player->sound = sound; + + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPEECH)->setPlayer(player); + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPEECH)->Send(false); + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPEECH)->Send(true); +} diff --git a/apps/openmw-mp/Script/Functions/Dialogue.hpp b/apps/openmw-mp/Script/Functions/Dialogue.hpp index 70a1731b0..fe135e5a5 100644 --- a/apps/openmw-mp/Script/Functions/Dialogue.hpp +++ b/apps/openmw-mp/Script/Functions/Dialogue.hpp @@ -12,7 +12,8 @@ \ {"SendTopicChanges", DialogueFunctions::SendTopicChanges},\ \ - {"PlayAnimation", DialogueFunctions::PlayAnimation} + {"PlayAnimation", DialogueFunctions::PlayAnimation},\ + {"PlaySpeech", DialogueFunctions::PlaySpeech} class DialogueFunctions { @@ -65,6 +66,7 @@ public: static void SendTopicChanges(unsigned short pid, bool toOthers = false) noexcept; static void PlayAnimation(unsigned short pid, const char* groupname, int mode = 0, int count = 1, bool persist = false) noexcept; + static void PlaySpeech(unsigned short pid, const char* sound) noexcept; private: diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index a3e39fff0..d4fddab80 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -7,11 +7,14 @@ #include #include "../mwbase/environment.hpp" - -#include "../mwgui/windowmanagerimp.hpp" +#include "../mwbase/soundmanager.hpp" #include "../mwclass/npc.hpp" +#include "../mwdialogue/dialoguemanagerimp.hpp" + +#include "../mwgui/windowmanagerimp.hpp" + #include "../mwinput/inputmanagerimp.hpp" #include "../mwmechanics/actor.hpp" @@ -289,6 +292,15 @@ void DedicatedPlayer::playAnimation() animation.groupname, animation.mode, animation.count, animation.persist); } +void DedicatedPlayer::playSpeech() +{ + MWBase::Environment::get().getSoundManager()->say(getPtr(), sound); + + MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); + if (winMgr->getSubtitlesEnabled()) + winMgr->messageBox(MWBase::Environment::get().getDialogueManager()->getVoiceCaption(sound), MWGui::ShowInDialogueMode_Never); +} + MWWorld::Ptr DedicatedPlayer::getPtr() { return ptr; diff --git a/apps/openmw/mwmp/DedicatedPlayer.hpp b/apps/openmw/mwmp/DedicatedPlayer.hpp index d016b63b1..781748fb8 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.hpp +++ b/apps/openmw/mwmp/DedicatedPlayer.hpp @@ -44,6 +44,7 @@ namespace mwmp void setMarkerState(bool state); void playAnimation(); + void playSpeech(); MWWorld::Ptr getPtr(); MWWorld::Ptr getLiveCellPtr(); diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index c7ecf8bf2..956bad587 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -7,6 +7,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/journal.hpp" +#include "../mwbase/soundmanager.hpp" #include "../mwclass/creature.hpp" #include "../mwclass/npc.hpp" @@ -1452,3 +1453,12 @@ void LocalPlayer::playAnimation() MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(getPlayerPtr(), animation.groupname, animation.mode, animation.count, animation.persist); } + +void LocalPlayer::playSpeech() +{ + MWBase::Environment::get().getSoundManager()->say(getPlayerPtr(), sound); + + MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); + if (winMgr->getSubtitlesEnabled()) + winMgr->messageBox(MWBase::Environment::get().getDialogueManager()->getVoiceCaption(sound), MWGui::ShowInDialogueMode_Never); +} diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index fc4d9aaf0..30b3f9aab 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -91,6 +91,7 @@ namespace mwmp void storeCurrentContainer(const MWWorld::Ptr& container, bool loot); void playAnimation(); + void playSpeech(); private: Networking *getNetworking(); diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerSpeech.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerSpeech.hpp index b4e2bab8a..ace5174df 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerSpeech.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerSpeech.hpp @@ -15,7 +15,13 @@ namespace mwmp virtual void Do(PlayerPacket &packet, BasePlayer *player) { - // Placeholder to be filled in later + if (isLocal()) + { + LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_SPEECH about LocalPlayer from server"); + static_cast(player)->playSpeech(); + } + else if (player != 0) + static_cast(player)->playSpeech(); } }; } diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index 2a877202f..d96936a6d 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -271,6 +271,7 @@ namespace mwmp CGStage charGenStage; std::string passw; + std::string sound; Animation animation; bool isWerewolf; diff --git a/components/openmw-mp/Packets/Player/PacketPlayerSpeech.cpp b/components/openmw-mp/Packets/Player/PacketPlayerSpeech.cpp index 38b30be5f..7f4a24cfc 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerSpeech.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerSpeech.cpp @@ -10,5 +10,5 @@ void mwmp::PacketPlayerSpeech::Packet(RakNet::BitStream *bs, bool send) { PlayerPacket::Packet(bs, send); - // Placeholder to be filled in later + RW(player->sound, send); }