From 47b666c1f96dbeb08944f4b5153440addfbfd8ce Mon Sep 17 00:00:00 2001 From: David Cernat Date: Sun, 1 Dec 2019 10:12:13 +0200 Subject: [PATCH] [Server] Add ObjectFunctions for setting summoner identity for spawns --- apps/openmw-mp/Script/Functions/Objects.cpp | 23 +++++++++++++++++- apps/openmw-mp/Script/Functions/Objects.hpp | 27 +++++++++++++++++++++ 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 0ed8f1c53..8a6d9757c 100644 --- a/apps/openmw-mp/Script/Functions/Objects.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -409,13 +409,34 @@ void ObjectFunctions::SetObjectSummonDuration(float summonDuration) noexcept tempObject.summonDuration = summonDuration; } +void ObjectFunctions::SetObjectSummonerPid(unsigned short pid) noexcept +{ + Player *player; + GET_PLAYER(pid, player, ); + + tempObject.master.isPlayer = true; + tempObject.master.guid = player->guid; +} + +void ObjectFunctions::SetObjectSummonerRefNum(int refNum) noexcept +{ + tempObject.master.isPlayer = false; + tempObject.master.refNum = refNum; +} + +void ObjectFunctions::SetObjectSummonerMpNum(int mpNum) noexcept +{ + tempObject.master.isPlayer = false; + tempObject.master.mpNum = mpNum; +} + void ObjectFunctions::SetObjectActivatingPid(unsigned short pid) noexcept { Player *player; GET_PLAYER(pid, player, ); - tempObject.activatingActor.guid = player->guid; tempObject.activatingActor.isPlayer = true; + tempObject.activatingActor.guid = player->guid; } void ObjectFunctions::SetObjectDoorState(int doorState) noexcept diff --git a/apps/openmw-mp/Script/Functions/Objects.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp index 737c7a53a..759fe4684 100644 --- a/apps/openmw-mp/Script/Functions/Objects.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -88,6 +88,9 @@ \ {"SetObjectSummonState", ObjectFunctions::SetObjectSummonState},\ {"SetObjectSummonDuration", ObjectFunctions::SetObjectSummonDuration},\ + {"SetObjectSummonerPid", ObjectFunctions::SetObjectSummonerPid},\ + {"SetObjectSummonerRefNum", ObjectFunctions::SetObjectSummonerRefNum},\ + {"SetObjectSummonerMpNum", ObjectFunctions::SetObjectSummonerMpNum},\ \ {"SetObjectActivatingPid", ObjectFunctions::SetObjectActivatingPid},\ \ @@ -789,6 +792,30 @@ public: */ static void SetObjectSummonDuration(float summonDuration) noexcept; + /** + * \brief Set the player ID of the summoner of the temporary object stored on the server. + * + * \param pid The player ID of the summoner. + * \return void + */ + static void SetObjectSummonerPid(unsigned short pid) noexcept; + + /** + * \brief Set the refNum of the actor summoner of the temporary object stored on the server. + * + * \param refNum The refNum of the summoner. + * \return void + */ + static void SetObjectSummonerRefNum(int refNum) noexcept; + + /** + * \brief Set the mpNum of the actor summoner of the temporary object stored on the server. + * + * \param mpNum The mpNum of the summoner. + * \return void + */ + static void SetObjectSummonerMpNum(int mpNum) noexcept; + /** * \brief Set the player ID of the player activating the temporary object stored on the * server. Currently only used for ObjectActivate packets.