From 3aa125ceda0cbf78b74ab96e73568f99ccd90324 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Tue, 3 Jul 2018 00:53:52 +0300 Subject: [PATCH] [Server] Add script functions for getting a summoner's refId and indexes --- apps/openmw-mp/Script/Functions/Objects.cpp | 15 +++++++++ apps/openmw-mp/Script/Functions/Objects.hpp | 35 ++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/apps/openmw-mp/Script/Functions/Objects.cpp b/apps/openmw-mp/Script/Functions/Objects.cpp index d12c48ff3..2fa5a6852 100644 --- a/apps/openmw-mp/Script/Functions/Objects.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -128,6 +128,21 @@ bool ObjectFunctions::DoesObjectHavePlayerSummoner(unsigned int i) noexcept return readObjectList->baseObjects.at(i).master.isPlayer; } +const char *ObjectFunctions::GetObjectSummonerRefId(unsigned int i) noexcept +{ + return readObjectList->baseObjects.at(i).master.refId.c_str(); +} + +int ObjectFunctions::GetObjectSummonerRefNumIndex(unsigned int i) noexcept +{ + return readObjectList->baseObjects.at(i).master.refNumIndex; +} + +int ObjectFunctions::GetObjectSummonerMpNum(unsigned int i) noexcept +{ + return readObjectList->baseObjects.at(i).master.mpNum; +} + double ObjectFunctions::GetObjectPosX(unsigned int i) noexcept { return readObjectList->baseObjects.at(i).position.pos[0]; diff --git a/apps/openmw-mp/Script/Functions/Objects.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp index d9a3d1a8f..519bcc92c 100644 --- a/apps/openmw-mp/Script/Functions/Objects.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -24,9 +24,14 @@ {"GetObjectState", ObjectFunctions::GetObjectState},\ {"GetObjectDoorState", ObjectFunctions::GetObjectDoorState},\ {"GetObjectLockLevel", ObjectFunctions::GetObjectLockLevel},\ + \ {"GetObjectSummonState", ObjectFunctions::GetObjectSummonState},\ {"GetObjectSummonDuration", ObjectFunctions::GetObjectSummonDuration},\ {"DoesObjectHavePlayerSummoner", ObjectFunctions::DoesObjectHavePlayerSummoner},\ + {"GetObjectSummonerRefId", ObjectFunctions::GetObjectSummonerRefId},\ + {"GetObjectSummonerRefNumIndex", ObjectFunctions::GetObjectSummonerRefNumIndex},\ + {"GetObjectSummonerMpNum", ObjectFunctions::GetObjectSummonerMpNum},\ + \ {"GetObjectPosX", ObjectFunctions::GetObjectPosX},\ {"GetObjectPosY", ObjectFunctions::GetObjectPosY},\ {"GetObjectPosZ", ObjectFunctions::GetObjectPosZ},\ @@ -281,10 +286,38 @@ public: * * Only living actors can be summoned. * - * \return The summon state. + * \return Whether a player is the summoner of the object. */ static bool DoesObjectHavePlayerSummoner(unsigned int i) noexcept; + + /** + * \brief Get the refId of the summoner of the object at a certain index in the read object + * list's object changes. + * + * \param i The index of the summoner. + * \return The refNumIndex. + */ + static const char *GetObjectSummonerRefId(unsigned int i) noexcept; + + /** + * \brief Get the refNumIndex of the summoner of the object at a certain index in the read object + * list's object changes. + * + * \param i The index of the summoner. + * \return The refNumIndex. + */ + static int GetObjectSummonerRefNumIndex(unsigned int i) noexcept; + + /** + * \brief Get the mpNum of the summoner of the object at a certain index in the read object list's + * object changes. + * + * \param i The index of the summoner. + * \return The mpNum. + */ + static int GetObjectSummonerMpNum(unsigned int i) noexcept; + /** * \brief Get the X position of the object at a certain index in the read object list's object * changes.