From 645a21af218eb7a4d7f254a5cf7fa227e50fb5ff Mon Sep 17 00:00:00 2001 From: Stanislav Zhukov Date: Sat, 16 Jul 2016 16:19:35 +0800 Subject: [PATCH] Added new script functions for lua compatibility GetPosX, GetPosY, GetPosZ GetAngleX, GetAngleY, GetAngleZ --- .../Script/Functions/Translocations.cpp | 48 +++++++++++++++++++ apps/openmw-mp/Script/ScriptFunctions.hpp | 12 +++++ 2 files changed, 60 insertions(+) diff --git a/apps/openmw-mp/Script/Functions/Translocations.cpp b/apps/openmw-mp/Script/Functions/Translocations.cpp index 0660eb22a..20808b648 100644 --- a/apps/openmw-mp/Script/Functions/Translocations.cpp +++ b/apps/openmw-mp/Script/Functions/Translocations.cpp @@ -24,6 +24,30 @@ void ScriptFunctions::GetPos(unsigned short pid, float *x, float *y, float *z) n *z = player->Position()->pos[2]; } +double ScriptFunctions::GetPosX(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0.0f); + + return player->Position()->pos[0]; +} + +double ScriptFunctions::GetPosY(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0.0f); + + return player->Position()->pos[1]; +} + +double ScriptFunctions::GetPosZ(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0.0f); + + return player->Position()->pos[2]; +} + void ScriptFunctions::SetPos(unsigned short pid, float x, float y, float z) noexcept { Player *player; @@ -92,6 +116,30 @@ void ScriptFunctions::GetAngle(unsigned short pid, float *x, float *y, float *z) *z = player->Position()->rot[2]; } +double ScriptFunctions::GetAngleX(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0.0f); + + return player->Position()->rot[0]; +} + +double ScriptFunctions::GetAngleY(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0.0f); + + return player->Position()->rot[1]; +} + +double ScriptFunctions::GetAngleZ(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, 0.0f); + + return player->Position()->rot[2]; +} + void ScriptFunctions::SetAngle(unsigned short pid, float x, float y, float z) noexcept { Player *player; diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index 550d3bba3..002cd15c9 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -33,10 +33,16 @@ public: static boost::any CallPublic(const char *name, ...) noexcept; static void GetPos(unsigned short pid, float *x, float *y, float *z) noexcept; + static double GetPosX(unsigned short pid) noexcept; + static double GetPosY(unsigned short pid) noexcept; + static double GetPosZ(unsigned short pid) noexcept; static void SetPos(unsigned short pid, float x, float y, float z) noexcept; static void GetAngle(unsigned short pid, float *x, float *y, float *z) noexcept; + static double GetAngleX(unsigned short pid) noexcept; + static double GetAngleY(unsigned short pid) noexcept; + static double GetAngleZ(unsigned short pid) noexcept; static void SetAngle(unsigned short pid, float x, float y, float z) noexcept; static void SetCell(unsigned short pid, const char *name) noexcept; @@ -139,9 +145,15 @@ public: {"StopServer", ScriptFunctions::StopServer}, {"GetPos", ScriptFunctions::GetPos}, + {"GetPosX", ScriptFunctions::GetPosX}, + {"GetPosY", ScriptFunctions::GetPosY}, + {"GetPosZ", ScriptFunctions::GetPosZ}, {"SetPos", ScriptFunctions::SetPos}, {"GetAngle", ScriptFunctions::GetAngle}, + {"GetAngleX", ScriptFunctions::GetAngleX}, + {"GetAngleY", ScriptFunctions::GetAngleY}, + {"GetAngleZ", ScriptFunctions::GetAngleZ}, {"SetAngle", ScriptFunctions::SetAngle}, {"GetCell", ScriptFunctions::GetCell},