From a71dbc7d09d4d88614d49b01f0b61f5194450b55 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 28 Apr 2017 18:44:01 +0300 Subject: [PATCH] [Server] Add script functions for setting actor cells and positions --- apps/openmw-mp/Script/Functions/Actors.cpp | 25 ++++++++++++++++++++++ apps/openmw-mp/Script/Functions/Actors.hpp | 10 ++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/apps/openmw-mp/Script/Functions/Actors.cpp b/apps/openmw-mp/Script/Functions/Actors.cpp index 5b0b14456..41eb543af 100644 --- a/apps/openmw-mp/Script/Functions/Actors.cpp +++ b/apps/openmw-mp/Script/Functions/Actors.cpp @@ -95,6 +95,11 @@ void ActorFunctions::SetScriptActorListAction(unsigned char action) noexcept scriptActorList.action = action; } +void ActorFunctions::SetActorCell(const char* cellDescription) noexcept +{ + tempActor.cell = Utils::getCellFromDescription(cellDescription); +} + void ActorFunctions::SetActorRefId(const char* refId) noexcept { tempActor.refId = refId; @@ -110,6 +115,20 @@ void ActorFunctions::SetActorMpNum(int mpNum) noexcept tempActor.mpNum = mpNum; } +void ActorFunctions::SetActorPosition(double x, double y, double z) noexcept +{ + tempActor.position.pos[0] = x; + tempActor.position.pos[1] = y; + tempActor.position.pos[2] = z; +} + +void ActorFunctions::SetActorRotation(double x, double y, double z) noexcept +{ + tempActor.position.rot[0] = x; + tempActor.position.rot[1] = y; + tempActor.position.rot[2] = z; +} + void ActorFunctions::AddActor() noexcept { scriptActorList.baseActors.push_back(tempActor); @@ -129,3 +148,9 @@ void ActorFunctions::SendActorAuthority() noexcept mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY)->Send(scriptActorList.guid); } +void ActorFunctions::SendActorCellChange() noexcept +{ + mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->setActorList(&scriptActorList); + mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->Send(scriptActorList.guid); +} + diff --git a/apps/openmw-mp/Script/Functions/Actors.hpp b/apps/openmw-mp/Script/Functions/Actors.hpp index f6d2fc15c..282074d1d 100644 --- a/apps/openmw-mp/Script/Functions/Actors.hpp +++ b/apps/openmw-mp/Script/Functions/Actors.hpp @@ -21,14 +21,18 @@ {"SetScriptActorListCell", ActorFunctions::SetScriptActorListCell},\ {"SetScriptActorListAction", ActorFunctions::SetScriptActorListAction},\ \ + {"SetActorCell", ActorFunctions::SetActorCell},\ {"SetActorRefId", ActorFunctions::SetActorRefId},\ {"SetActorRefNumIndex", ActorFunctions::SetActorRefNumIndex},\ {"SetActorMpNum", ActorFunctions::SetActorMpNum},\ + {"SetActorPosition", ActorFunctions::SetActorPosition},\ + {"SetActorRotation", ActorFunctions::SetActorRotation},\ \ {"AddActor", ActorFunctions::AddActor},\ \ {"SendActorList", ActorFunctions::SendActorList},\ - {"SendActorAuthority", ActorFunctions::SendActorAuthority} + {"SendActorAuthority", ActorFunctions::SendActorAuthority},\ + {"SendActorCellChange", ActorFunctions::SendActorCellChange} class ActorFunctions { @@ -53,14 +57,18 @@ public: static void SetScriptActorListCell(const char* cellDescription) noexcept; static void SetScriptActorListAction(unsigned char action) noexcept; + static void SetActorCell(const char* cellDescription) noexcept; static void SetActorRefId(const char* refId) noexcept; static void SetActorRefNumIndex(int refNumIndex) noexcept; static void SetActorMpNum(int mpNum) noexcept; + static void SetActorPosition(double x, double y, double z) noexcept; + static void SetActorRotation(double x, double y, double z) noexcept; static void AddActor() noexcept; static void SendActorList() noexcept; static void SendActorAuthority() noexcept; + static void SendActorCellChange() noexcept; };