From aeab851ed806878f5ee39b32c2689206c77d9656 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 28 Apr 2017 00:05:12 +0300 Subject: [PATCH] [Server] Add script functions for getting actor position coordinates --- apps/openmw-mp/Script/Functions/Actors.cpp | 30 ++++++++++++++++++++++ apps/openmw-mp/Script/Functions/Actors.hpp | 12 +++++++++ 2 files changed, 42 insertions(+) diff --git a/apps/openmw-mp/Script/Functions/Actors.cpp b/apps/openmw-mp/Script/Functions/Actors.cpp index 8bae87a65..ee3a3fc21 100644 --- a/apps/openmw-mp/Script/Functions/Actors.cpp +++ b/apps/openmw-mp/Script/Functions/Actors.cpp @@ -54,6 +54,36 @@ int ActorFunctions::GetActorMpNum(unsigned int i) noexcept return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).mpNum; } +double ActorFunctions::GetActorPosX(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.pos[0]; +} + +double ActorFunctions::GetActorPosY(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.pos[1]; +} + +double ActorFunctions::GetActorPosZ(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.pos[2]; +} + +double ActorFunctions::GetActorRotX(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.rot[0]; +} + +double ActorFunctions::GetActorRotY(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.rot[1]; +} + +double ActorFunctions::GetActorRotZ(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastActorList()->baseActors.at(i).position.rot[2]; +} + void ActorFunctions::SetScriptActorListCell(const char* cellDescription) noexcept { static std::regex exteriorCellPattern("^(-?\\d+), (-?\\d+)$"); diff --git a/apps/openmw-mp/Script/Functions/Actors.hpp b/apps/openmw-mp/Script/Functions/Actors.hpp index efafd9384..f6d2fc15c 100644 --- a/apps/openmw-mp/Script/Functions/Actors.hpp +++ b/apps/openmw-mp/Script/Functions/Actors.hpp @@ -11,6 +11,12 @@ {"GetActorRefId", ActorFunctions::GetActorRefId},\ {"GetActorRefNumIndex", ActorFunctions::GetActorRefNumIndex},\ {"GetActorMpNum", ActorFunctions::GetActorMpNum},\ + {"GetActorPosX", ActorFunctions::GetActorPosX},\ + {"GetActorPosY", ActorFunctions::GetActorPosY},\ + {"GetActorPosZ", ActorFunctions::GetActorPosZ},\ + {"GetActorRotX", ActorFunctions::GetActorRotX},\ + {"GetActorRotY", ActorFunctions::GetActorRotY},\ + {"GetActorRotZ", ActorFunctions::GetActorRotZ},\ \ {"SetScriptActorListCell", ActorFunctions::SetScriptActorListCell},\ {"SetScriptActorListAction", ActorFunctions::SetScriptActorListAction},\ @@ -37,6 +43,12 @@ public: static const char *GetActorRefId(unsigned int i) noexcept; static int GetActorRefNumIndex(unsigned int i) noexcept; static int GetActorMpNum(unsigned int i) noexcept; + static double GetActorPosX(unsigned int i) noexcept; + static double GetActorPosY(unsigned int i) noexcept; + static double GetActorPosZ(unsigned int i) noexcept; + static double GetActorRotX(unsigned int i) noexcept; + static double GetActorRotY(unsigned int i) noexcept; + static double GetActorRotZ(unsigned int i) noexcept; static void SetScriptActorListCell(const char* cellDescription) noexcept; static void SetScriptActorListAction(unsigned char action) noexcept;