diff --git a/apps/openmw-mp/Networking.cpp b/apps/openmw-mp/Networking.cpp index c6c09d9a9..08f4e34b8 100644 --- a/apps/openmw-mp/Networking.cpp +++ b/apps/openmw-mp/Networking.cpp @@ -459,37 +459,45 @@ void Networking::processWorldPacket(RakNet::Packet *packet) break; } - case ID_OBJECT_LOCK: + case ID_OBJECT_SCALE: { - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK from %s", + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_SCALE from %s", player->npc.mName.c_str()); myPacket->Read(worldEvent); myPacket->Send(worldEvent, true); + Script::Call( + player->getId(), + worldEvent->cell.getDescription().c_str()); + break; } - case ID_OBJECT_UNLOCK: + case ID_OBJECT_LOCK: { - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_UNLOCK from %s", + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK from %s", player->npc.mName.c_str()); myPacket->Read(worldEvent); myPacket->Send(worldEvent, true); + Script::Call( + player->getId(), + worldEvent->cell.getDescription().c_str()); + break; } - case ID_OBJECT_SCALE: + case ID_OBJECT_UNLOCK: { - LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_SCALE from %s", + LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_UNLOCK from %s", player->npc.mName.c_str()); myPacket->Read(worldEvent); myPacket->Send(worldEvent, true); - Script::Call( + Script::Call( player->getId(), worldEvent->cell.getDescription().c_str()); @@ -559,6 +567,10 @@ void Networking::processWorldPacket(RakNet::Packet *packet) myPacket->Read(worldEvent); myPacket->Send(worldEvent, true); + Script::Call( + player->getId(), + worldEvent->cell.getDescription().c_str()); + break; } diff --git a/apps/openmw-mp/Script/Functions/World.cpp b/apps/openmw-mp/Script/Functions/World.cpp index 59e30b33f..80f97e2e8 100644 --- a/apps/openmw-mp/Script/Functions/World.cpp +++ b/apps/openmw-mp/Script/Functions/World.cpp @@ -35,8 +35,10 @@ void WorldFunctions::AddWorldObject() noexcept worldObject.refNumIndex = tempWorldObject.refNumIndex; worldObject.count = tempWorldObject.count; worldObject.goldValue = tempWorldObject.goldValue; - worldObject.pos = tempWorldObject.pos; worldObject.scale = tempWorldObject.scale; + worldObject.state = tempWorldObject.state; + worldObject.lockLevel = tempWorldObject.lockLevel; + worldObject.pos = tempWorldObject.pos; worldEvent->objectChanges.objects.push_back(worldObject); } @@ -89,6 +91,16 @@ void WorldFunctions::SetObjectScale(int scale) noexcept tempWorldObject.scale = scale; } +void WorldFunctions::SetObjectState(int state) noexcept +{ + tempWorldObject.state = state; +} + +void WorldFunctions::SetObjectLockLevel(int lockLevel) noexcept +{ + tempWorldObject.lockLevel = lockLevel; +} + void WorldFunctions::SetObjectPosition(double x, double y, double z) noexcept { tempWorldObject.pos.pos[0] = x; @@ -133,6 +145,16 @@ int WorldFunctions::GetObjectScale(unsigned int i) noexcept return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(i).scale; } +int WorldFunctions::GetObjectState(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(i).state; +} + +int WorldFunctions::GetObjectLockLevel(unsigned int i) noexcept +{ + return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(i).lockLevel; +} + double WorldFunctions::GetObjectPosX(unsigned int i) noexcept { return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(i).pos.pos[0]; @@ -178,6 +200,21 @@ void WorldFunctions::SendObjectScale() noexcept mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_SCALE)->Send(worldEvent, worldEvent->guid); } +void WorldFunctions::SendObjectLock() noexcept +{ + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_LOCK)->Send(worldEvent, worldEvent->guid); +} + +void WorldFunctions::SendObjectUnlock() noexcept +{ + mwmp::Networking::get().getWorldController()->GetPacket(ID_OBJECT_UNLOCK)->Send(worldEvent, worldEvent->guid); +} + +void WorldFunctions::SendDoorState() noexcept +{ + mwmp::Networking::get().getWorldController()->GetPacket(ID_DOOR_STATE)->Send(worldEvent, worldEvent->guid); +} + void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept { Player *player; diff --git a/apps/openmw-mp/Script/Functions/World.hpp b/apps/openmw-mp/Script/Functions/World.hpp index 642f4b0b4..153dba320 100644 --- a/apps/openmw-mp/Script/Functions/World.hpp +++ b/apps/openmw-mp/Script/Functions/World.hpp @@ -12,6 +12,8 @@ {"SetObjectCount", WorldFunctions::SetObjectCount},\ {"SetObjectGoldValue", WorldFunctions::SetObjectGoldValue},\ {"SetObjectScale", WorldFunctions::SetObjectScale},\ + {"SetObjectState", WorldFunctions::SetObjectState},\ + {"SetObjectLockLevel", WorldFunctions::SetObjectLockLevel},\ {"SetObjectPosition", WorldFunctions::SetObjectPosition},\ {"SetObjectRotation", WorldFunctions::SetObjectRotation},\ \ @@ -22,6 +24,8 @@ {"GetObjectCount", WorldFunctions::GetObjectCount},\ {"GetObjectGoldValue", WorldFunctions::GetObjectGoldValue},\ {"GetObjectScale", WorldFunctions::GetObjectScale},\ + {"GetObjectState", WorldFunctions::GetObjectState},\ + {"GetObjectLockLevel", WorldFunctions::GetObjectLockLevel},\ {"GetObjectPosX", WorldFunctions::GetObjectPosX},\ {"GetObjectPosY", WorldFunctions::GetObjectPosY},\ {"GetObjectPosZ", WorldFunctions::GetObjectPosZ},\ @@ -32,6 +36,9 @@ {"SendObjectDelete", WorldFunctions::SendObjectDelete},\ {"SendObjectPlace", WorldFunctions::SendObjectPlace},\ {"SendObjectScale", WorldFunctions::SendObjectScale},\ + {"SendObjectLock", WorldFunctions::SendObjectLock},\ + {"SendObjectUnlock", WorldFunctions::SendObjectUnlock},\ + {"SendDoorState", WorldFunctions::SendDoorState},\ \ {"SetHour", WorldFunctions::SetHour},\ {"SetMonth", WorldFunctions::SetMonth},\ @@ -51,6 +58,8 @@ public: static void SetObjectCount(int count) noexcept; static void SetObjectGoldValue(int goldValue) noexcept; static void SetObjectScale(int scale) noexcept; + static void SetObjectState(int scale) noexcept; + static void SetObjectLockLevel(int lockLevel) noexcept; static void SetObjectPosition(double x, double y, double z) noexcept; static void SetObjectRotation(double x, double y, double z) noexcept; @@ -61,6 +70,8 @@ public: static int GetObjectCount(unsigned int i) noexcept; static int GetObjectGoldValue(unsigned int i) noexcept; static int GetObjectScale(unsigned int i) noexcept; + static int GetObjectState(unsigned int i) noexcept; + static int GetObjectLockLevel(unsigned int i) noexcept; static double GetObjectPosX(unsigned int i) noexcept; static double GetObjectPosY(unsigned int i) noexcept; static double GetObjectPosZ(unsigned int i) noexcept; @@ -71,6 +82,9 @@ public: static void SendObjectDelete() noexcept; static void SendObjectPlace() noexcept; static void SendObjectScale() noexcept; + static void SendObjectLock() noexcept; + static void SendObjectUnlock() noexcept; + static void SendDoorState() noexcept; static void SetHour(unsigned short pid, double hour) noexcept; static void SetMonth(unsigned short pid, int month) noexcept; diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index be9fe6aaf..63dde0d90 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -120,6 +120,9 @@ public: {"OnObjectPlace", Function()}, {"OnObjectDelete", Function()}, {"OnObjectScale", Function()}, + {"OnObjectLock", Function()}, + {"OnObjectUnlock", Function()}, + {"OnDoorState", Function()}, {"OnPlayerSendMessage", Function()}, {"OnPlayerEndCharGen", Function()}, {"OnGUIAction", Function()}