2017-05-24 20:22:43 +00:00
|
|
|
#include "Dialogue.hpp"
|
2017-08-18 04:13:08 +00:00
|
|
|
|
2017-05-24 20:22:43 +00:00
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
2017-08-18 04:13:08 +00:00
|
|
|
|
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
2017-05-24 20:22:43 +00:00
|
|
|
#include <apps/openmw-mp/Networking.hpp>
|
|
|
|
|
|
|
|
using namespace mwmp;
|
|
|
|
|
2018-10-02 23:26:47 +00:00
|
|
|
void DialogueFunctions::ClearTopicChanges(unsigned short pid) noexcept
|
2017-07-07 06:25:48 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
2019-10-22 22:24:13 +00:00
|
|
|
player->topicChanges.clear();
|
2017-07-07 06:25:48 +00:00
|
|
|
}
|
|
|
|
|
2017-05-24 20:22:43 +00:00
|
|
|
unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, 0);
|
|
|
|
|
2019-10-22 22:24:13 +00:00
|
|
|
return player->topicChanges.size();
|
2017-05-24 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
mwmp::Topic topic;
|
|
|
|
topic.topicId = topicId;
|
|
|
|
|
2019-10-22 22:24:13 +00:00
|
|
|
player->topicChanges.push_back(topic);
|
2017-05-24 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
2018-07-24 17:14:51 +00:00
|
|
|
const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int index) noexcept
|
2017-05-24 20:22:43 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, "");
|
|
|
|
|
2019-10-22 22:24:13 +00:00
|
|
|
if (index >= player->topicChanges.size())
|
2017-05-24 20:22:43 +00:00
|
|
|
return "invalid";
|
|
|
|
|
2019-10-22 22:24:13 +00:00
|
|
|
return player->topicChanges.at(index).topicId.c_str();
|
2017-05-24 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
2018-07-07 17:08:59 +00:00
|
|
|
void DialogueFunctions::SendTopicChanges(unsigned short pid, bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept
|
2017-05-24 20:22:43 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
2018-07-07 15:29:31 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC);
|
|
|
|
packet->setPlayer(player);
|
|
|
|
|
2018-07-07 17:08:59 +00:00
|
|
|
if (!skipAttachedPlayer)
|
2018-07-07 15:29:31 +00:00
|
|
|
packet->Send(false);
|
|
|
|
if (sendToOtherPlayers)
|
|
|
|
packet->Send(true);
|
2017-05-24 20:22:43 +00:00
|
|
|
}
|
2017-10-27 06:10:29 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2017-12-29 04:17:45 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ANIM_PLAY);
|
|
|
|
packet->setPlayer(player);
|
2018-07-07 15:29:31 +00:00
|
|
|
|
2017-12-29 04:17:45 +00:00
|
|
|
packet->Send(false);
|
|
|
|
player->sendToLoaded(packet);
|
2017-10-27 06:10:29 +00:00
|
|
|
}
|
2017-10-31 13:19:14 +00:00
|
|
|
|
|
|
|
void DialogueFunctions::PlaySpeech(unsigned short pid, const char* sound) noexcept
|
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player, );
|
|
|
|
|
|
|
|
player->sound = sound;
|
|
|
|
|
2017-12-29 04:17:45 +00:00
|
|
|
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPEECH);
|
|
|
|
packet->setPlayer(player);
|
2018-07-07 15:29:31 +00:00
|
|
|
|
2017-12-29 04:17:45 +00:00
|
|
|
packet->Send(false);
|
|
|
|
player->sendToLoaded(packet);
|
2017-10-31 13:19:14 +00:00
|
|
|
}
|
2018-10-02 23:26:47 +00:00
|
|
|
|
|
|
|
// All methods below are deprecated versions of methods from above
|
|
|
|
|
|
|
|
void DialogueFunctions::InitializeTopicChanges(unsigned short pid) noexcept
|
|
|
|
{
|
|
|
|
ClearTopicChanges(pid);
|
|
|
|
}
|