feat: Added remaining server-side events

+ onPlayerUseCheat, all NPC related events
This commit is contained in:
AURUMVORXX
2024-11-06 11:36:08 +03:00
parent d235a28a1d
commit d54bd06fef
5 changed files with 116 additions and 1 deletions

View File

@@ -165,4 +165,12 @@ addEvent('onPlayerEquipRing')
addEvent('onPlayerEquipShield') addEvent('onPlayerEquipShield')
addEvent('onPlayerEquipSpell') addEvent('onPlayerEquipSpell')
addEvent('onPacket') addEvent('onPacket')
addEvent('onPlayerUseCheat')
addEvent('onNpcActionFinished')
addEvent('onNpcActionSent')
addEvent('onNpcChangeHostPlayer')
addEvent('onNpcCreated')
addEvent('onNpcDestroyed')

View File

@@ -89,4 +89,12 @@ void registerSquirrelEvents()
addEventHandler("onPlayerEquipSpell", sq_onPlayerEquipSpell, 0); addEventHandler("onPlayerEquipSpell", sq_onPlayerEquipSpell, 0);
addEventHandler("onPacket", sq_onPacket, 0); addEventHandler("onPacket", sq_onPacket, 0);
addEventHandler("onPlayerUseCheat", sq_onPlayerUseCheat, 0);
addEventHandler("onNpcActionFinished", sq_onNpcActionFinished, 0);
addEventHandler("onNpcActionSent", sq_onNpcActionSent, 0);
addEventHandler("onNpcChangeHostPlayer", sq_onNpcChangeHostPlayer, 0);
addEventHandler("onNpcCreated", sq_onNpcCreated, 0);
addEventHandler("onNpcDestroyed", sq_onNpcDestroyed, 0);
} }

View File

@@ -50,6 +50,14 @@ SQInteger sq_onPlayerToggleFaceAni(HSQUIRRELVM);
SQInteger sq_onPacket(HSQUIRRELVM); SQInteger sq_onPacket(HSQUIRRELVM);
SQInteger sq_onPlayerUseCheat(HSQUIRRELVM);
SQInteger sq_onNpcActionFinished(HSQUIRRELVM);
SQInteger sq_onNpcActionSent(HSQUIRRELVM);
SQInteger sq_onNpcChangeHostPlayer(HSQUIRRELVM);
SQInteger sq_onNpcCreated(HSQUIRRELVM);
SQInteger sq_onNpcDestroyed(HSQUIRRELVM);
void registerSquirrelEvents(); void registerSquirrelEvents();
#endif #endif

View File

@@ -0,0 +1,18 @@
#include <sqapi.h>
#include <pybind11/embed.h>
#include "NoNut/core/Utils.h"
#include "sqcontainers.h"
#include "sqevents.h"
SQInteger sq_onPlayerUseCheat(HSQUIRRELVM vm)
{
SQInteger playerid, type;
nonut::sqGetValue(vm, 2, &playerid);
nonut::sqGetValue(vm, 3, &type);
py::dict kwargs = py::dict("playerid"_a=playerid, "type"_a=type);
callEvent("onPlayerUseCheat", kwargs);
return 0;
}

View File

@@ -0,0 +1,73 @@
#include <sqapi.h>
#include <pybind11/embed.h>
#include "NoNut/core/Utils.h"
#include "sqcontainers.h"
#include "sqevents.h"
SQInteger sq_onNpcActionFinished(HSQUIRRELVM vm)
{
SQInteger npc_id, action_type, action_id;
SQBool result;
nonut::sqGetValue(vm, 2, &npc_id);
nonut::sqGetValue(vm, 3, &action_type);
nonut::sqGetValue(vm, 4, &action_id);
nonut::sqGetValue(vm, 5, &result);
py::dict kwargs = py::dict("npc_id"_a=npc_id, "action_type"_a=action_type, "action_id"_a=action_id, "result"_a=result);
callEvent("onNpcActionFinished", kwargs);
return 0;
}
SQInteger sq_onNpcActionSent(HSQUIRRELVM vm)
{
SQInteger npc_id, action_type, action_id;
nonut::sqGetValue(vm, 2, &npc_id);
nonut::sqGetValue(vm, 3, &action_type);
nonut::sqGetValue(vm, 4, &action_id);
py::dict kwargs = py::dict("npc_id"_a=npc_id, "action_type"_a=action_type, "action_id"_a=action_id);
callEvent("onNpcActionSent", kwargs);
return 0;
}
SQInteger sq_onNpcChangeHostPlayer(HSQUIRRELVM vm)
{
SQInteger npc_id, current_id, previous_id;
nonut::sqGetValue(vm, 2, &npc_id);
nonut::sqGetValue(vm, 3, &current_id);
nonut::sqGetValue(vm, 4, &previous_id);
py::dict kwargs = py::dict("npc_id"_a=npc_id, "current_id"_a=current_id, "previous_id"_a=previous_id);
callEvent("onNpcChangeHostPlayer", kwargs);
return 0;
}
SQInteger sq_onNpcCreated(HSQUIRRELVM vm)
{
SQInteger npc_id;
nonut::sqGetValue(vm, 2, &npc_id);
py::dict kwargs = py::dict("npc_id"_a=npc_id);
callEvent("onNpcCreated", kwargs);
return 0;
}
SQInteger sq_onNpcDestroyed(HSQUIRRELVM vm)
{
SQInteger npc_id;
nonut::sqGetValue(vm, 2, &npc_id);
py::dict kwargs = py::dict("npc_id"_a=npc_id);
callEvent("onNpcDestroyed", kwargs);
return 0;
}