mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:23:51 +00:00
[Server] Add script functions & callbacks for locking, unlocking & doors
This commit is contained in:
parent
1808cf815f
commit
018b0e6699
4 changed files with 79 additions and 13 deletions
|
@ -459,6 +459,21 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ID_OBJECT_SCALE:
|
||||||
|
{
|
||||||
|
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<Script::CallbackIdentity("OnObjectScale")>(
|
||||||
|
player->getId(),
|
||||||
|
worldEvent->cell.getDescription().c_str());
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ID_OBJECT_LOCK:
|
case ID_OBJECT_LOCK:
|
||||||
{
|
{
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK from %s",
|
LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Received ID_OBJECT_LOCK from %s",
|
||||||
|
@ -467,6 +482,10 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
|
||||||
myPacket->Read(worldEvent);
|
myPacket->Read(worldEvent);
|
||||||
myPacket->Send(worldEvent, true);
|
myPacket->Send(worldEvent, true);
|
||||||
|
|
||||||
|
Script::Call<Script::CallbackIdentity("OnObjectLock")>(
|
||||||
|
player->getId(),
|
||||||
|
worldEvent->cell.getDescription().c_str());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -478,18 +497,7 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
|
||||||
myPacket->Read(worldEvent);
|
myPacket->Read(worldEvent);
|
||||||
myPacket->Send(worldEvent, true);
|
myPacket->Send(worldEvent, true);
|
||||||
|
|
||||||
break;
|
Script::Call<Script::CallbackIdentity("OnObjectUnlock")>(
|
||||||
}
|
|
||||||
|
|
||||||
case ID_OBJECT_SCALE:
|
|
||||||
{
|
|
||||||
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<Script::CallbackIdentity("OnObjectScale")>(
|
|
||||||
player->getId(),
|
player->getId(),
|
||||||
worldEvent->cell.getDescription().c_str());
|
worldEvent->cell.getDescription().c_str());
|
||||||
|
|
||||||
|
@ -559,6 +567,10 @@ void Networking::processWorldPacket(RakNet::Packet *packet)
|
||||||
myPacket->Read(worldEvent);
|
myPacket->Read(worldEvent);
|
||||||
myPacket->Send(worldEvent, true);
|
myPacket->Send(worldEvent, true);
|
||||||
|
|
||||||
|
Script::Call<Script::CallbackIdentity("OnDoorState")>(
|
||||||
|
player->getId(),
|
||||||
|
worldEvent->cell.getDescription().c_str());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,10 @@ void WorldFunctions::AddWorldObject() noexcept
|
||||||
worldObject.refNumIndex = tempWorldObject.refNumIndex;
|
worldObject.refNumIndex = tempWorldObject.refNumIndex;
|
||||||
worldObject.count = tempWorldObject.count;
|
worldObject.count = tempWorldObject.count;
|
||||||
worldObject.goldValue = tempWorldObject.goldValue;
|
worldObject.goldValue = tempWorldObject.goldValue;
|
||||||
worldObject.pos = tempWorldObject.pos;
|
|
||||||
worldObject.scale = tempWorldObject.scale;
|
worldObject.scale = tempWorldObject.scale;
|
||||||
|
worldObject.state = tempWorldObject.state;
|
||||||
|
worldObject.lockLevel = tempWorldObject.lockLevel;
|
||||||
|
worldObject.pos = tempWorldObject.pos;
|
||||||
|
|
||||||
worldEvent->objectChanges.objects.push_back(worldObject);
|
worldEvent->objectChanges.objects.push_back(worldObject);
|
||||||
}
|
}
|
||||||
|
@ -89,6 +91,16 @@ void WorldFunctions::SetObjectScale(int scale) noexcept
|
||||||
tempWorldObject.scale = scale;
|
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
|
void WorldFunctions::SetObjectPosition(double x, double y, double z) noexcept
|
||||||
{
|
{
|
||||||
tempWorldObject.pos.pos[0] = x;
|
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;
|
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
|
double WorldFunctions::GetObjectPosX(unsigned int i) noexcept
|
||||||
{
|
{
|
||||||
return mwmp::Networking::getPtr()->getLastEvent()->objectChanges.objects.at(i).pos.pos[0];
|
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);
|
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
|
void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept
|
||||||
{
|
{
|
||||||
Player *player;
|
Player *player;
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
{"SetObjectCount", WorldFunctions::SetObjectCount},\
|
{"SetObjectCount", WorldFunctions::SetObjectCount},\
|
||||||
{"SetObjectGoldValue", WorldFunctions::SetObjectGoldValue},\
|
{"SetObjectGoldValue", WorldFunctions::SetObjectGoldValue},\
|
||||||
{"SetObjectScale", WorldFunctions::SetObjectScale},\
|
{"SetObjectScale", WorldFunctions::SetObjectScale},\
|
||||||
|
{"SetObjectState", WorldFunctions::SetObjectState},\
|
||||||
|
{"SetObjectLockLevel", WorldFunctions::SetObjectLockLevel},\
|
||||||
{"SetObjectPosition", WorldFunctions::SetObjectPosition},\
|
{"SetObjectPosition", WorldFunctions::SetObjectPosition},\
|
||||||
{"SetObjectRotation", WorldFunctions::SetObjectRotation},\
|
{"SetObjectRotation", WorldFunctions::SetObjectRotation},\
|
||||||
\
|
\
|
||||||
|
@ -22,6 +24,8 @@
|
||||||
{"GetObjectCount", WorldFunctions::GetObjectCount},\
|
{"GetObjectCount", WorldFunctions::GetObjectCount},\
|
||||||
{"GetObjectGoldValue", WorldFunctions::GetObjectGoldValue},\
|
{"GetObjectGoldValue", WorldFunctions::GetObjectGoldValue},\
|
||||||
{"GetObjectScale", WorldFunctions::GetObjectScale},\
|
{"GetObjectScale", WorldFunctions::GetObjectScale},\
|
||||||
|
{"GetObjectState", WorldFunctions::GetObjectState},\
|
||||||
|
{"GetObjectLockLevel", WorldFunctions::GetObjectLockLevel},\
|
||||||
{"GetObjectPosX", WorldFunctions::GetObjectPosX},\
|
{"GetObjectPosX", WorldFunctions::GetObjectPosX},\
|
||||||
{"GetObjectPosY", WorldFunctions::GetObjectPosY},\
|
{"GetObjectPosY", WorldFunctions::GetObjectPosY},\
|
||||||
{"GetObjectPosZ", WorldFunctions::GetObjectPosZ},\
|
{"GetObjectPosZ", WorldFunctions::GetObjectPosZ},\
|
||||||
|
@ -32,6 +36,9 @@
|
||||||
{"SendObjectDelete", WorldFunctions::SendObjectDelete},\
|
{"SendObjectDelete", WorldFunctions::SendObjectDelete},\
|
||||||
{"SendObjectPlace", WorldFunctions::SendObjectPlace},\
|
{"SendObjectPlace", WorldFunctions::SendObjectPlace},\
|
||||||
{"SendObjectScale", WorldFunctions::SendObjectScale},\
|
{"SendObjectScale", WorldFunctions::SendObjectScale},\
|
||||||
|
{"SendObjectLock", WorldFunctions::SendObjectLock},\
|
||||||
|
{"SendObjectUnlock", WorldFunctions::SendObjectUnlock},\
|
||||||
|
{"SendDoorState", WorldFunctions::SendDoorState},\
|
||||||
\
|
\
|
||||||
{"SetHour", WorldFunctions::SetHour},\
|
{"SetHour", WorldFunctions::SetHour},\
|
||||||
{"SetMonth", WorldFunctions::SetMonth},\
|
{"SetMonth", WorldFunctions::SetMonth},\
|
||||||
|
@ -51,6 +58,8 @@ public:
|
||||||
static void SetObjectCount(int count) noexcept;
|
static void SetObjectCount(int count) noexcept;
|
||||||
static void SetObjectGoldValue(int goldValue) noexcept;
|
static void SetObjectGoldValue(int goldValue) noexcept;
|
||||||
static void SetObjectScale(int scale) 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 SetObjectPosition(double x, double y, double z) noexcept;
|
||||||
static void SetObjectRotation(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 GetObjectCount(unsigned int i) noexcept;
|
||||||
static int GetObjectGoldValue(unsigned int i) noexcept;
|
static int GetObjectGoldValue(unsigned int i) noexcept;
|
||||||
static int GetObjectScale(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 GetObjectPosX(unsigned int i) noexcept;
|
||||||
static double GetObjectPosY(unsigned int i) noexcept;
|
static double GetObjectPosY(unsigned int i) noexcept;
|
||||||
static double GetObjectPosZ(unsigned int i) noexcept;
|
static double GetObjectPosZ(unsigned int i) noexcept;
|
||||||
|
@ -71,6 +82,9 @@ public:
|
||||||
static void SendObjectDelete() noexcept;
|
static void SendObjectDelete() noexcept;
|
||||||
static void SendObjectPlace() noexcept;
|
static void SendObjectPlace() noexcept;
|
||||||
static void SendObjectScale() 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 SetHour(unsigned short pid, double hour) noexcept;
|
||||||
static void SetMonth(unsigned short pid, int month) noexcept;
|
static void SetMonth(unsigned short pid, int month) noexcept;
|
||||||
|
|
|
@ -120,6 +120,9 @@ public:
|
||||||
{"OnObjectPlace", Function<void, unsigned short, const char*>()},
|
{"OnObjectPlace", Function<void, unsigned short, const char*>()},
|
||||||
{"OnObjectDelete", Function<void, unsigned short, const char*>()},
|
{"OnObjectDelete", Function<void, unsigned short, const char*>()},
|
||||||
{"OnObjectScale", Function<void, unsigned short, const char*>()},
|
{"OnObjectScale", Function<void, unsigned short, const char*>()},
|
||||||
|
{"OnObjectLock", Function<void, unsigned short, const char*>()},
|
||||||
|
{"OnObjectUnlock", Function<void, unsigned short, const char*>()},
|
||||||
|
{"OnDoorState", Function<void, unsigned short, const char*>()},
|
||||||
{"OnPlayerSendMessage", Function<bool, unsigned short, const char*>()},
|
{"OnPlayerSendMessage", Function<bool, unsigned short, const char*>()},
|
||||||
{"OnPlayerEndCharGen", Function<void, unsigned short>()},
|
{"OnPlayerEndCharGen", Function<void, unsigned short>()},
|
||||||
{"OnGUIAction", Function<void, unsigned short, int, const char*>()}
|
{"OnGUIAction", Function<void, unsigned short, int, const char*>()}
|
||||||
|
|
Loading…
Reference in a new issue