diff --git a/apps/openmw-mp/Script/Functions/Dialogue.cpp b/apps/openmw-mp/Script/Functions/Dialogue.cpp index 13f9811c1..02339cca5 100644 --- a/apps/openmw-mp/Script/Functions/Dialogue.cpp +++ b/apps/openmw-mp/Script/Functions/Dialogue.cpp @@ -53,3 +53,18 @@ void DialogueFunctions::SendTopicChanges(unsigned short pid, bool toOthers) noex mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->setPlayer(player); mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->Send(toOthers); } + +void DialogueFunctions::PlayAnimation(unsigned short pid, const char* groupname, int mode, int count, bool persist) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + + player->animation.groupname = groupname; + player->animation.mode = mode; + player->animation.count = count; + player->animation.persist = persist; + + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ANIM_PLAY)->setPlayer(player); + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ANIM_PLAY)->Send(false); + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ANIM_PLAY)->Send(true); +} diff --git a/apps/openmw-mp/Script/Functions/Dialogue.hpp b/apps/openmw-mp/Script/Functions/Dialogue.hpp index 1813e7ed7..70a1731b0 100644 --- a/apps/openmw-mp/Script/Functions/Dialogue.hpp +++ b/apps/openmw-mp/Script/Functions/Dialogue.hpp @@ -10,7 +10,9 @@ \ {"GetTopicId", DialogueFunctions::GetTopicId},\ \ - {"SendTopicChanges", DialogueFunctions::SendTopicChanges} + {"SendTopicChanges", DialogueFunctions::SendTopicChanges},\ + \ + {"PlayAnimation", DialogueFunctions::PlayAnimation} class DialogueFunctions { @@ -61,6 +63,9 @@ public: * \return void */ 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; + private: }; diff --git a/apps/openmw-mp/Script/Functions/Positions.hpp b/apps/openmw-mp/Script/Functions/Positions.hpp index ae8b8a768..49cb9f863 100644 --- a/apps/openmw-mp/Script/Functions/Positions.hpp +++ b/apps/openmw-mp/Script/Functions/Positions.hpp @@ -11,7 +11,7 @@ \ {"GetPreviousCellPosX", PositionFunctions::GetPreviousCellPosX},\ {"GetPreviousCellPosY", PositionFunctions::GetPreviousCellPosY},\ - {"GetPreviousCellPosZ", PositionFunctions::GetPreviousCellPosZ},\ + {"GetPreviousCellPosZ", PositionFunctions::GetPreviousCellPosZ},\ \ {"GetRot", PositionFunctions::GetRot},\ {"GetRotX", PositionFunctions::GetRotX},\ diff --git a/apps/openmw-mp/Script/Functions/Stats.hpp b/apps/openmw-mp/Script/Functions/Stats.hpp index 8ee0421d7..e046ffb6a 100644 --- a/apps/openmw-mp/Script/Functions/Stats.hpp +++ b/apps/openmw-mp/Script/Functions/Stats.hpp @@ -133,7 +133,7 @@ public: static void SetLevel(unsigned short pid, int value) noexcept; static void SetLevelProgress(unsigned short pid, int value) noexcept; - static void SetHealthBase(unsigned short pid, double value) noexcept; + static void SetHealthBase(unsigned short pid, double value) noexcept; static void SetHealthCurrent(unsigned short pid, double value) noexcept; static void SetMagickaBase(unsigned short pid, double value) noexcept; static void SetMagickaCurrent(unsigned short pid, double value) noexcept; diff --git a/apps/openmw/mwmp/DedicatedPlayer.cpp b/apps/openmw/mwmp/DedicatedPlayer.cpp index f5f8d3bfd..a3e39fff0 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.cpp +++ b/apps/openmw/mwmp/DedicatedPlayer.cpp @@ -283,6 +283,12 @@ void DedicatedPlayer::setMarkerState(bool state) removeMarker(); } +void DedicatedPlayer::playAnimation() +{ + MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(getPtr(), + animation.groupname, animation.mode, animation.count, animation.persist); +} + MWWorld::Ptr DedicatedPlayer::getPtr() { return ptr; diff --git a/apps/openmw/mwmp/DedicatedPlayer.hpp b/apps/openmw/mwmp/DedicatedPlayer.hpp index 212279852..d016b63b1 100644 --- a/apps/openmw/mwmp/DedicatedPlayer.hpp +++ b/apps/openmw/mwmp/DedicatedPlayer.hpp @@ -43,6 +43,8 @@ namespace mwmp void removeMarker(); void setMarkerState(bool state); + void playAnimation(); + MWWorld::Ptr getPtr(); MWWorld::Ptr getLiveCellPtr(); MWWorld::ManualRef* getRef(); diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 71d1de8f7..c7ecf8bf2 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -1446,3 +1446,9 @@ void LocalPlayer::storeCurrentContainer(const MWWorld::Ptr &container, bool loot currentContainer.mpNum = container.getCellRef().getMpNum(); currentContainer.loot = loot; } + +void LocalPlayer::playAnimation() +{ + MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(getPlayerPtr(), + animation.groupname, animation.mode, animation.count, animation.persist); +} diff --git a/apps/openmw/mwmp/LocalPlayer.hpp b/apps/openmw/mwmp/LocalPlayer.hpp index 56302fa31..fc4d9aaf0 100644 --- a/apps/openmw/mwmp/LocalPlayer.hpp +++ b/apps/openmw/mwmp/LocalPlayer.hpp @@ -90,6 +90,8 @@ namespace mwmp void storeCellState(ESM::Cell cell, int stateType); void storeCurrentContainer(const MWWorld::Ptr& container, bool loot); + void playAnimation(); + private: Networking *getNetworking(); MWWorld::Ptr getPlayerPtr(); diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerAnimPlay.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerAnimPlay.hpp index e8b360e5a..d5e022d04 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerAnimPlay.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerAnimPlay.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_ANIM_PLAY about LocalPlayer from server"); + static_cast(player)->playAnimation(); + } + else if (player != 0) + static_cast(player)->playAnimation(); } }; } diff --git a/components/openmw-mp/Base/BasePlayer.hpp b/components/openmw-mp/Base/BasePlayer.hpp index a3fcf3e22..2a877202f 100644 --- a/components/openmw-mp/Base/BasePlayer.hpp +++ b/components/openmw-mp/Base/BasePlayer.hpp @@ -271,6 +271,8 @@ namespace mwmp CGStage charGenStage; std::string passw; + Animation animation; + bool isWerewolf; std::string creatureModel; bool useCreatureName; diff --git a/components/openmw-mp/Packets/Player/PacketPlayerAnimPlay.cpp b/components/openmw-mp/Packets/Player/PacketPlayerAnimPlay.cpp index 34c601673..bcc7562e8 100644 --- a/components/openmw-mp/Packets/Player/PacketPlayerAnimPlay.cpp +++ b/components/openmw-mp/Packets/Player/PacketPlayerAnimPlay.cpp @@ -10,5 +10,8 @@ void mwmp::PacketPlayerAnimPlay::Packet(RakNet::BitStream *bs, bool send) { PlayerPacket::Packet(bs, send); - // Placeholder to be filled in later + RW(player->animation.groupname, send); + RW(player->animation.mode, send); + RW(player->animation.count, send); + RW(player->animation.persist, send); }