1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 14:36:41 +00:00
openmw-tes3mp/apps/openmw-mp/Script/Functions/Shapeshift.cpp
Koncord 4ca5da5666 [Server] Rework Plugin API, move Lua system to external library
Use LibFFI for Public & Timer APIs
Use "PlayerId" type instead "unsigned short"
Add GetPluginDir() function
2019-02-12 05:29:57 +08:00

86 lines
2 KiB
C++

#include "Shapeshift.h"
#include <components/openmw-mp/NetworkMessages.hpp>
#include <components/openmw-mp/Log.hpp>
#include <apps/openmw-mp/Script/Callbacks.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <iostream>
using namespace std;
extern "C" double ShapeshiftFunctions::GetScale(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0.0f);
return player->scale;
}
extern "C" bool ShapeshiftFunctions::IsWerewolf(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->isWerewolf;
}
extern "C" const char *ShapeshiftFunctions::GetCreatureRefId(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->creatureRefId.c_str();
}
extern "C" bool ShapeshiftFunctions::GetCreatureNameDisplayState(PlayerId pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, 0);
return player->displayCreatureName;
}
extern "C" void ShapeshiftFunctions::SetScale(PlayerId pid, double scale) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
player->scale = scale;
}
extern "C" void ShapeshiftFunctions::SetWerewolfState(PlayerId pid, bool isWerewolf) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
player->isWerewolf = isWerewolf;
}
extern "C" void ShapeshiftFunctions::SetCreatureRefId(PlayerId pid, const char *refId) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
player->creatureRefId = refId;
}
extern "C" void ShapeshiftFunctions::SetCreatureNameDisplayState(PlayerId pid, bool displayState) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
player->displayCreatureName = displayState;
}
extern "C" void ShapeshiftFunctions::SendShapeshift(PlayerId pid)
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT);
packet->setPlayer(player);
packet->Send(false);
packet->Send(true);
}