forked from mirror/openmw-tes3mp
[Server] Add script functions for dialogue
This commit is contained in:
parent
7ec431ce3d
commit
dbdb11b5f0
5 changed files with 93 additions and 13 deletions
|
@ -78,9 +78,9 @@ set(SERVER
|
|||
Script/Functions/Actors.cpp Script/Functions/World.cpp Script/Functions/Miscellaneous.cpp
|
||||
|
||||
Script/Functions/Cells.cpp Script/Functions/CharClass.cpp Script/Functions/Chat.cpp
|
||||
Script/Functions/Factions.cpp Script/Functions/GUI.cpp Script/Functions/Items.cpp
|
||||
Script/Functions/Positions.cpp Script/Functions/Quests.cpp Script/Functions/Spells.cpp
|
||||
Script/Functions/Stats.cpp Script/Functions/Timer.cpp
|
||||
Script/Functions/Dialogue.cpp Script/Functions/Factions.cpp Script/Functions/GUI.cpp
|
||||
Script/Functions/Items.cpp Script/Functions/Positions.cpp Script/Functions/Quests.cpp
|
||||
Script/Functions/Spells.cpp Script/Functions/Stats.cpp Script/Functions/Timer.cpp
|
||||
|
||||
ProcessorInitializer.cpp PlayerProcessor.cpp ActorProcessor.cpp WorldProcessor.cpp
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
mwmp::SpellbookChanges spellbookChangesBuffer;
|
||||
mwmp::JournalChanges journalChangesBuffer;
|
||||
mwmp::FactionChanges factionChangesBuffer;
|
||||
mwmp::TopicChanges topicChangesBuffer;
|
||||
|
||||
private:
|
||||
CellController::TContainer cells;
|
||||
|
|
49
apps/openmw-mp/Script/Functions/Dialogue.cpp
Normal file
49
apps/openmw-mp/Script/Functions/Dialogue.cpp
Normal file
|
@ -0,0 +1,49 @@
|
|||
#include "Dialogue.hpp"
|
||||
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
||||
#include <components/openmw-mp/NetworkMessages.hpp>
|
||||
#include <apps/openmw-mp/Networking.hpp>
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
using namespace mwmp;
|
||||
|
||||
unsigned int DialogueFunctions::GetTopicChangesSize(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
return player->topicChanges.count;
|
||||
}
|
||||
|
||||
void DialogueFunctions::AddTopic(unsigned short pid, const char* topicId) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
mwmp::Topic topic;
|
||||
topic.topicId = topicId;
|
||||
|
||||
player->topicChangesBuffer.topics.push_back(topic);
|
||||
}
|
||||
|
||||
const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int i) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, "");
|
||||
|
||||
if (i >= player->topicChanges.count)
|
||||
return "invalid";
|
||||
|
||||
return player->topicChanges.topics.at(i).topicId.c_str();
|
||||
}
|
||||
|
||||
void DialogueFunctions::SendTopicChanges(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
std::swap(player->topicChanges, player->topicChangesBuffer);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->setPlayer(player);
|
||||
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->Send(false);
|
||||
player->topicChanges = std::move(player->topicChangesBuffer);
|
||||
player->topicChangesBuffer.topics.clear();
|
||||
}
|
28
apps/openmw-mp/Script/Functions/Dialogue.hpp
Normal file
28
apps/openmw-mp/Script/Functions/Dialogue.hpp
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef OPENMW_DIALOGUEAPI_HPP
|
||||
#define OPENMW_DIALOGUEAPI_HPP
|
||||
|
||||
#define DIALOGUEAPI \
|
||||
{"GetTopicChangesSize", DialogueFunctions::GetTopicChangesSize},\
|
||||
\
|
||||
{"AddTopic", DialogueFunctions::AddTopic},\
|
||||
\
|
||||
{"GetTopicId", DialogueFunctions::GetTopicId},\
|
||||
\
|
||||
{"SendTopicChanges", DialogueFunctions::SendTopicChanges}
|
||||
|
||||
class DialogueFunctions
|
||||
{
|
||||
public:
|
||||
|
||||
static unsigned int GetTopicChangesSize(unsigned short pid) noexcept;
|
||||
|
||||
static void AddTopic(unsigned short pid, const char* topicId) noexcept;
|
||||
|
||||
static const char *GetTopicId(unsigned short pid, unsigned int i) noexcept;
|
||||
|
||||
static void SendTopicChanges(unsigned short pid) noexcept;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif //OPENMW_DIALOGUEAPI_HPP
|
|
@ -5,18 +5,19 @@
|
|||
#ifndef SCRIPTFUNCTIONS_HPP
|
||||
#define SCRIPTFUNCTIONS_HPP
|
||||
|
||||
#include <Script/Functions/CharClass.hpp>
|
||||
#include <Script/Functions/Positions.hpp>
|
||||
#include <Script/Functions/Cells.hpp>
|
||||
#include <Script/Functions/GUI.hpp>
|
||||
#include <Script/Functions/Stats.hpp>
|
||||
#include <Script/Functions/Items.hpp>
|
||||
#include <Script/Functions/Quests.hpp>
|
||||
#include <Script/Functions/Factions.hpp>
|
||||
#include <Script/Functions/Spells.hpp>
|
||||
#include <Script/Functions/Actors.hpp>
|
||||
#include <Script/Functions/World.hpp>
|
||||
#include <Script/Functions/Cells.hpp>
|
||||
#include <Script/Functions/CharClass.hpp>
|
||||
#include <Script/Functions/Dialogue.hpp>
|
||||
#include <Script/Functions/Factions.hpp>
|
||||
#include <Script/Functions/GUI.hpp>
|
||||
#include <Script/Functions/Items.hpp>
|
||||
#include <Script/Functions/Miscellaneous.hpp>
|
||||
#include <Script/Functions/Positions.hpp>
|
||||
#include <Script/Functions/Quests.hpp>
|
||||
#include <Script/Functions/Spells.hpp>
|
||||
#include <Script/Functions/Stats.hpp>
|
||||
#include <Script/Functions/World.hpp>
|
||||
#include <RakNetTypes.h>
|
||||
//#include <amx/amx.h>
|
||||
#include <tuple>
|
||||
|
@ -104,6 +105,7 @@ public:
|
|||
ITEMAPI,
|
||||
QUESTAPI,
|
||||
FACTIONAPI,
|
||||
DIALOGUEAPI,
|
||||
SPELLAPI,
|
||||
GUIAPI,
|
||||
CHARCLASSAPI,
|
||||
|
|
Loading…
Reference in a new issue