From f65f9964181a5cbf86dd510d947cce0bbf94f630 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sat, 15 Jul 2017 11:09:28 +0300 Subject: [PATCH] [Server] Add script functions for werewolf states --- apps/openmw-mp/Script/Functions/Factions.cpp | 2 +- apps/openmw-mp/Script/Functions/Mechanics.cpp | 26 +++++++++++++++++++ apps/openmw-mp/Script/Functions/Mechanics.hpp | 14 +++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Factions.cpp b/apps/openmw-mp/Script/Functions/Factions.cpp index 04736a3f1..d606a9f61 100644 --- a/apps/openmw-mp/Script/Functions/Factions.cpp +++ b/apps/openmw-mp/Script/Functions/Factions.cpp @@ -55,7 +55,7 @@ int FactionFunctions::GetFactionRank(unsigned short pid, unsigned int i) noexcep bool FactionFunctions::GetFactionExpelledState(unsigned short pid, unsigned int i) noexcept { Player *player; - GET_PLAYER(pid, player, 0); + GET_PLAYER(pid, player, false); return player->factionChanges.factions.at(i).isExpelled; } diff --git a/apps/openmw-mp/Script/Functions/Mechanics.cpp b/apps/openmw-mp/Script/Functions/Mechanics.cpp index b0a430c22..62dcc33ae 100644 --- a/apps/openmw-mp/Script/Functions/Mechanics.cpp +++ b/apps/openmw-mp/Script/Functions/Mechanics.cpp @@ -7,6 +7,32 @@ #include using namespace std; +bool MechanicsFunctions::IsWerewolf(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0); + + return player->isWerewolf; +} + +void MechanicsFunctions::SetWerewolfState(unsigned short pid, bool isWerewolf) +{ + Player *player; + GET_PLAYER(pid, player, ); + + player->isWerewolf = isWerewolf; +} + +void MechanicsFunctions::SendShapeshift(unsigned short pid) +{ + Player *player; + GET_PLAYER(pid, player, ); + + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT)->setPlayer(player); + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT)->Send(false); + mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT)->Send(true); +} + void MechanicsFunctions::Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases, const char* jailProgressText, const char* jailEndText) noexcept { diff --git a/apps/openmw-mp/Script/Functions/Mechanics.hpp b/apps/openmw-mp/Script/Functions/Mechanics.hpp index 05e2bda68..80bc4d544 100644 --- a/apps/openmw-mp/Script/Functions/Mechanics.hpp +++ b/apps/openmw-mp/Script/Functions/Mechanics.hpp @@ -4,13 +4,25 @@ #include "../Types.hpp" #define MECHANICSAPI \ - {"Jail", MechanicsFunctions::Jail},\ + {"IsWerewolf", MechanicsFunctions::IsWerewolf},\ \ + {"SetWerewolfState", MechanicsFunctions::SetWerewolfState},\ + \ + {"SendShapeshift", MechanicsFunctions::SendShapeshift},\ + \ + {"Jail", MechanicsFunctions::Jail},\ {"Resurrect", MechanicsFunctions::Resurrect} class MechanicsFunctions { public: + + static bool IsWerewolf(unsigned short pid) noexcept; + + static void SetWerewolfState(unsigned short pid, bool isWerewolf); + + static void SendShapeshift(unsigned short pid); + static void Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation = false, bool ignoreJailSkillIncreases = false, const char* jailProgressText = "", const char* jailEndText = "") noexcept;