1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-20 18:09:40 +00:00

[Server] Add script functions for getting, setting & sending gold pools

This commit is contained in:
David Cernat 2020-05-16 05:23:41 +03:00
parent 23ff7b9610
commit 7833ae9a3f
4 changed files with 53 additions and 2 deletions

View file

@ -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);

View file

@ -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.
*

View file

@ -195,6 +195,7 @@ public:
{"OnObjectSpawn", Callback<unsigned short, const char*>()},
{"OnObjectDelete", Callback<unsigned short, const char*>()},
{"OnObjectLock", Callback<unsigned short, const char*>()},
{"OnObjectMiscellaneous", Callback<unsigned short, const char*>()},
{"OnObjectRestock", Callback<unsigned short, const char*>()},
{"OnObjectScale", Callback<unsigned short, const char*>()},
{"OnObjectSound", Callback<unsigned short, const char*>()},

View file

@ -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<Script::CallbackIdentity("OnObjectMiscellaneous")>(player.getId(), objectList.cell.getDescription().c_str());
}
};
}