diff --git a/apps/openmw-mp/Script/Functions/Objects.cpp b/apps/openmw-mp/Script/Functions/Objects.cpp index db5b9c16b..89a0ab1e3 100644 --- a/apps/openmw-mp/Script/Functions/Objects.cpp +++ b/apps/openmw-mp/Script/Functions/Objects.cpp @@ -154,6 +154,11 @@ int ObjectFunctions::GetObjectLockLevel(unsigned int index) noexcept return readObjectList->baseObjects.at(index).lockLevel; } +unsigned int ObjectFunctions::GetObjectGoldPool(unsigned int index) noexcept +{ + return readObjectList->baseObjects.at(index).goldPool; +} + bool ObjectFunctions::DoesObjectHavePlayerActivating(unsigned int index) noexcept { return readObjectList->baseObjects.at(index).activatingActor.isPlayer; @@ -460,6 +465,11 @@ void ObjectFunctions::SetObjectLockLevel(int lockLevel) noexcept tempObject.lockLevel = lockLevel; } +void ObjectFunctions::SetObjectGoldPool(int goldPool) noexcept +{ + tempObject.goldPool = goldPool; +} + void ObjectFunctions::SetObjectDisarmState(bool disarmState) noexcept { tempObject.isDisarmed = disarmState; @@ -687,6 +697,17 @@ void ObjectFunctions::SendObjectLock(bool sendToOtherPlayers, bool skipAttachedP packet->Send(true); } +void ObjectFunctions::SendObjectMiscellaneous(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept +{ + mwmp::ObjectPacket* packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_MISCELLANEOUS); + packet->setObjectList(&writeObjectList); + + if (!skipAttachedPlayer) + packet->Send(false); + if (sendToOtherPlayers) + packet->Send(true); +} + void ObjectFunctions::SendObjectRestock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept { mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_RESTOCK); diff --git a/apps/openmw-mp/Script/Functions/Objects.hpp b/apps/openmw-mp/Script/Functions/Objects.hpp index 9e3c17236..ba0d17937 100644 --- a/apps/openmw-mp/Script/Functions/Objects.hpp +++ b/apps/openmw-mp/Script/Functions/Objects.hpp @@ -31,6 +31,7 @@ {"GetObjectState", ObjectFunctions::GetObjectState},\ {"GetObjectDoorState", ObjectFunctions::GetObjectDoorState},\ {"GetObjectLockLevel", ObjectFunctions::GetObjectLockLevel},\ + {"GetObjectGoldPool", ObjectFunctions::GetObjectGoldPool},\ \ {"DoesObjectHavePlayerActivating", ObjectFunctions::DoesObjectHavePlayerActivating},\ {"GetObjectActivatingPid", ObjectFunctions::GetObjectActivatingPid},\ @@ -98,6 +99,7 @@ {"SetObjectScale", ObjectFunctions::SetObjectScale},\ {"SetObjectState", ObjectFunctions::SetObjectState},\ {"SetObjectLockLevel", ObjectFunctions::SetObjectLockLevel},\ + {"SetObjectGoldPool", ObjectFunctions::SetObjectGoldPool},\ {"SetObjectDisarmState", ObjectFunctions::SetObjectDisarmState},\ {"SetObjectDroppedByPlayerState", ObjectFunctions::SetObjectDroppedByPlayerState},\ {"SetObjectPosition", ObjectFunctions::SetObjectPosition},\ @@ -141,6 +143,7 @@ {"SendObjectSpawn", ObjectFunctions::SendObjectSpawn},\ {"SendObjectDelete", ObjectFunctions::SendObjectDelete},\ {"SendObjectLock", ObjectFunctions::SendObjectLock},\ + {"SendObjectMiscellaneous", ObjectFunctions::SendObjectMiscellaneous},\ {"SendObjectRestock", ObjectFunctions::SendObjectRestock},\ {"SendObjectTrap", ObjectFunctions::SendObjectTrap},\ {"SendObjectScale", ObjectFunctions::SendObjectScale},\ @@ -381,6 +384,14 @@ public: */ static int GetObjectLockLevel(unsigned int index) noexcept; + /** + * \brief Get the gold pool of the object at a certain index in the read object list. + * + * \param index The index of the object. + * \return The gold pool. + */ + static unsigned int GetObjectGoldPool(unsigned int index) noexcept; + /** * \brief Check whether the object at a certain index in the read object list has been * activated by a player. @@ -899,6 +910,14 @@ public: */ static void SetObjectLockLevel(int lockLevel) noexcept; + /** + * \brief Set the gold pool of the temporary object stored on the server. + * + * \param goldPool The gold pool. + * \return void + */ + static void SetObjectGoldPool(int goldPool) noexcept; + /** * \brief Set the disarm state of the temporary object stored on the server. * @@ -1202,6 +1221,17 @@ public: */ static void SendObjectLock(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + /** + * \brief Send an ObjectMiscellaneous packet. + * + * \param sendToOtherPlayers Whether this packet should be sent to players other than the + * player attached to the packet (false by default). + * \param skipAttachedPlayer Whether the packet should skip being sent to the player attached + * to the packet (false by default). + * \return void + */ + static void SendObjectMiscellaneous(bool sendToOtherPlayers, bool skipAttachedPlayer) noexcept; + /** * \brief Send an ObjectRestock packet. * diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index a1d539410..8bd689886 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -195,6 +195,7 @@ public: {"OnObjectSpawn", Callback()}, {"OnObjectDelete", Callback()}, {"OnObjectLock", Callback()}, + {"OnObjectMiscellaneous", Callback()}, {"OnObjectRestock", Callback()}, {"OnObjectScale", Callback()}, {"OnObjectSound", Callback()}, diff --git a/apps/openmw-mp/processors/object/ProcessorObjectMiscellaneous.hpp b/apps/openmw-mp/processors/object/ProcessorObjectMiscellaneous.hpp index 6645161b7..65e7220eb 100644 --- a/apps/openmw-mp/processors/object/ProcessorObjectMiscellaneous.hpp +++ b/apps/openmw-mp/processors/object/ProcessorObjectMiscellaneous.hpp @@ -17,8 +17,7 @@ namespace mwmp { LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received %s from %s", strPacketID.c_str(), player.npc.mName.c_str()); - packet.Send(false); - packet.Send(true); + Script::Call(player.getId(), objectList.cell.getDescription().c_str()); } }; }