refactor: Refactorized whole project structure
This commit is contained in:
16
source/events/CMakeLists.txt
Normal file
16
source/events/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
target_sources(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
sqevents.cpp
|
||||
sqevents_anticheat.cpp
|
||||
sqevents_general.cpp
|
||||
sqevents_network.cpp
|
||||
sqevents_npc.cpp
|
||||
sqevents_player.cpp
|
||||
)
|
||||
|
||||
target_include_directories(${PYG2O_MODULE_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/
|
||||
)
|
||||
102
source/events/sqevents.cpp
Normal file
102
source/events/sqevents.cpp
Normal file
@@ -0,0 +1,102 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include "sqevents.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
extern py::module_ g2o;
|
||||
extern py::module_ pysys;
|
||||
|
||||
void addEventHandler(const char* eventName, SQFUNCTION closure, unsigned int priority = 9999)
|
||||
{
|
||||
using namespace SqModule;
|
||||
|
||||
Sqrat::Function sq_addEventHandler = Sqrat::RootTable().GetFunction("addEventHandler");
|
||||
|
||||
if (sq_addEventHandler.IsNull())
|
||||
return;
|
||||
|
||||
HSQOBJECT closureHandle;
|
||||
|
||||
sq_newclosure(vm, closure, 0);
|
||||
sq_getstackobj(vm, -1, &closureHandle);
|
||||
|
||||
Sqrat::Function func(vm, Sqrat::RootTable().GetObject(), closureHandle);
|
||||
sq_addEventHandler(eventName, func, priority);
|
||||
|
||||
sq_pop(vm, 1);
|
||||
}
|
||||
|
||||
void callEvent(const char* eventName, py::dict kwargs)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool result = g2o.attr("callEvent")(eventName, **kwargs).cast<bool>();
|
||||
if (result)
|
||||
{
|
||||
Sqrat::RootTable().GetFunction("cancelEvent").Execute();
|
||||
}
|
||||
}
|
||||
catch (py::error_already_set &e)
|
||||
{
|
||||
pysys.attr("stderr").attr("write")(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void registerSquirrelEvents()
|
||||
{
|
||||
addEventHandler("onInit", sq_onInit, 0);
|
||||
addEventHandler("onExit", sq_onExit, 0);
|
||||
addEventHandler("onTick", sq_onTick, 0);
|
||||
addEventHandler("onTime", sq_onTime, 0);
|
||||
addEventHandler("onBan", sq_onBan, 0);
|
||||
addEventHandler("onUnban", sq_onUnban, 0);
|
||||
|
||||
addEventHandler("onPlayerChangeColor", sq_onPlayerChangeColor, 0);
|
||||
addEventHandler("onPlayerChangeFocus", sq_onPlayerChangeFocus, 0);
|
||||
addEventHandler("onPlayerChangeHealth", sq_onPlayerChangeHealth, 0);
|
||||
addEventHandler("onPlayerChangeMana", sq_onPlayerChangeMana, 0);
|
||||
addEventHandler("onPlayerChangeMaxHealth", sq_onPlayerChangeMaxHealth, 0);
|
||||
addEventHandler("onPlayerChangeMaxMana", sq_onPlayerChangeMaxMana, 0);
|
||||
addEventHandler("onPlayerChangeWeaponMode", sq_onPlayerChangeWeaponMode, 0);
|
||||
addEventHandler("onPlayerChangeWorld", sq_onPlayerChangeWorld, 0);
|
||||
|
||||
addEventHandler("onPlayerCommand", sq_onPlayerCommand, 0);
|
||||
addEventHandler("onPlayerDamage", sq_onPlayerDamage, 0);
|
||||
addEventHandler("onPlayerDead", sq_onPlayerDead, 0);
|
||||
addEventHandler("onPlayerDisconnect", sq_onPlayerDisconnect, 0);
|
||||
addEventHandler("onPlayerDropItem", sq_onPlayerDropItem, 0);
|
||||
addEventHandler("onPlayerEnterWorld", sq_onPlayerEnterWorld, 0);
|
||||
addEventHandler("onPlayerJoin", sq_onPlayerJoin, 0);
|
||||
addEventHandler("onPlayerMessage", sq_onPlayerMessage, 0);
|
||||
addEventHandler("onPlayerMobInteract", sq_onPlayerMobInteract, 0);
|
||||
addEventHandler("onPlayerRespawn", sq_onPlayerRespawn, 0);
|
||||
addEventHandler("onPlayerShoot", sq_onPlayerShoot, 0);
|
||||
addEventHandler("onPlayerSpellCast", sq_onPlayerSpellCast, 0);
|
||||
addEventHandler("onPlayerSpellSetup", sq_onPlayerSpellSetup, 0);
|
||||
addEventHandler("onPlayerTakeItem", sq_onPlayerTakeItem, 0);
|
||||
addEventHandler("onPlayerTeleport", sq_onPlayerTeleport, 0);
|
||||
addEventHandler("onPlayerToggleFaceAni", sq_onPlayerToggleFaceAni, 0);
|
||||
|
||||
addEventHandler("onPlayerEquipAmulet", sq_onPlayerEquipAmulet, 0);
|
||||
addEventHandler("onPlayerEquipArmor", sq_onPlayerEquipArmor, 0);
|
||||
addEventHandler("onPlayerEquipBelt", sq_onPlayerEquipBelt, 0);
|
||||
addEventHandler("onPlayerEquipHandItem", sq_onPlayerEquipHandItem, 0);
|
||||
addEventHandler("onPlayerEquipHelmet", sq_onPlayerEquipHelmet, 0);
|
||||
addEventHandler("onPlayerEquipMeleeWeapon", sq_onPlayerEquipMeleeWeapon, 0);
|
||||
addEventHandler("onPlayerEquipRangedWeapon", sq_onPlayerEquipRangedWeapon, 0);
|
||||
addEventHandler("onPlayerEquipRing", sq_onPlayerEquipRing, 0);
|
||||
addEventHandler("onPlayerEquipShield", sq_onPlayerEquipShield, 0);
|
||||
addEventHandler("onPlayerEquipSpell", sq_onPlayerEquipSpell, 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);
|
||||
}
|
||||
63
source/events/sqevents.h
Normal file
63
source/events/sqevents.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef _SQEVENTS_H_
|
||||
#define _SQEVENTS_H
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
void callEvent(const char*, py::dict);
|
||||
|
||||
SQInteger sq_onInit(HSQUIRRELVM);
|
||||
SQInteger sq_onExit(HSQUIRRELVM);
|
||||
SQInteger sq_onTick(HSQUIRRELVM);
|
||||
SQInteger sq_onTime(HSQUIRRELVM);
|
||||
SQInteger sq_onBan(HSQUIRRELVM);
|
||||
SQInteger sq_onUnban(HSQUIRRELVM);
|
||||
|
||||
SQInteger sq_onPlayerChangeColor(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeFocus(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeHealth(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeMana(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeMaxHealth(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeMaxMana(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeWeaponMode(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerChangeWorld(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerCommand(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerDamage(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerDead(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerDisconnect(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerDropItem(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEnterWorld(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipAmulet(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipArmor(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipBelt(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipHandItem(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipHelmet(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipMeleeWeapon(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipRangedWeapon(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipRing(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipShield(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerEquipSpell(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerJoin(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerMessage(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerMobInteract(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerRespawn(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerShoot(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerSpellCast(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerSpellSetup(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerTakeItem(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerTeleport(HSQUIRRELVM);
|
||||
SQInteger sq_onPlayerToggleFaceAni(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();
|
||||
|
||||
#endif
|
||||
17
source/events/sqevents_anticheat.cpp
Normal file
17
source/events/sqevents_anticheat.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <Utils.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;
|
||||
}
|
||||
66
source/events/sqevents_general.cpp
Normal file
66
source/events/sqevents_general.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <Utils.h>
|
||||
#include <CustomTypes.h>
|
||||
#include "sqevents.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
extern py::module_ g2o;
|
||||
|
||||
SQInteger sq_onInit(HSQUIRRELVM vm)
|
||||
{
|
||||
py::object result = g2o.attr("callEvent")("onInit");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onExit(HSQUIRRELVM vm)
|
||||
{
|
||||
py::object result = g2o.attr("callEvent")("onExit");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onTick(HSQUIRRELVM vm)
|
||||
{
|
||||
py::object result = g2o.attr("callEvent")("onTick");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onTime(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger day, hour, min;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &day);
|
||||
nonut::sqGetValue(vm, 3, &hour);
|
||||
nonut::sqGetValue(vm, 4, &min);
|
||||
|
||||
py::dict kwargs = py::dict("day"_a=day, "hour"_a=hour, "min"_a=min);
|
||||
callEvent("onTime", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onBan(HSQUIRRELVM vm)
|
||||
{
|
||||
HSQOBJECT obj;
|
||||
nonut::sqGetValue(vm, 2, &obj);
|
||||
|
||||
nonut::SqDict dictData;
|
||||
dictData.convert(obj);
|
||||
callEvent("onBan", dictData.data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onUnban(HSQUIRRELVM vm)
|
||||
{
|
||||
HSQOBJECT obj;
|
||||
nonut::sqGetValue(vm, 2, &obj);
|
||||
|
||||
nonut::SqDict dictData;
|
||||
dictData.convert(obj);
|
||||
callEvent("onUnban", dictData.data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
24
source/events/sqevents_network.cpp
Normal file
24
source/events/sqevents_network.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <Utils.h>
|
||||
#include "python/Packet.h"
|
||||
#include "sqevents.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
extern py::module_ g2o;
|
||||
|
||||
SQInteger sq_onPacket(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
HSQOBJECT data;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &data);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "data"_a=PyPacket(data));
|
||||
callEvent("onPacket", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
72
source/events/sqevents_npc.cpp
Normal file
72
source/events/sqevents_npc.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <Utils.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, ¤t_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;
|
||||
}
|
||||
512
source/events/sqevents_player.cpp
Normal file
512
source/events/sqevents_player.cpp
Normal file
@@ -0,0 +1,512 @@
|
||||
#include <sqapi.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <Utils.h>
|
||||
#include "python/DamageDescription.h"
|
||||
#include "python/ItemGround.h"
|
||||
#include "sqevents.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
using namespace pybind11::literals;
|
||||
|
||||
extern py::module_ g2o;
|
||||
|
||||
SQInteger sq_onPlayerChangeColor(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, r, g, b;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &r);
|
||||
nonut::sqGetValue(vm, 4, &g);
|
||||
nonut::sqGetValue(vm, 5, &b);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "r"_a=r, "g"_a=g, "b"_a=b);
|
||||
callEvent("onPlayerChangeColor", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeFocus(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldFocusId, newFocusId;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldFocusId);
|
||||
nonut::sqGetValue(vm, 4, &newFocusId);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldFocusId"_a=oldFocusId, "newFocusId"_a=newFocusId);
|
||||
callEvent("onPlayerChangeFocus", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeHealth(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldHP, newHP;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldHP);
|
||||
nonut::sqGetValue(vm, 4, &newHP);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldHP"_a=oldHP, "newHP"_a=newHP);
|
||||
callEvent("onPlayerChangeHealth", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeMana(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldMP, newMP;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldMP);
|
||||
nonut::sqGetValue(vm, 4, &newMP);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldMP"_a=oldMP, "newMP"_a=newMP);
|
||||
callEvent("onPlayerChangeMana", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeMaxHealth(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldMaxHP, newMaxHP;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldMaxHP);
|
||||
nonut::sqGetValue(vm, 4, &newMaxHP);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldMaxHP"_a=oldMaxHP, "newMaxHP"_a=newMaxHP);
|
||||
callEvent("onPlayerChangeMaxHealth", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeMaxMana(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldMaxMP, newMaxMP;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldMaxMP);
|
||||
nonut::sqGetValue(vm, 4, &newMaxMP);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldMaxMP"_a=oldMaxMP, "newMaxMP"_a=newMaxMP);
|
||||
callEvent("onPlayerChangeMaxMana", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeWeaponMode(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, oldWeaponMode, newWeaponMode;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &oldWeaponMode);
|
||||
nonut::sqGetValue(vm, 4, &newWeaponMode);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "oldWeaponMode"_a=oldWeaponMode, "newWeaponMode"_a=newWeaponMode);
|
||||
callEvent("onPlayerChangeWeaponMode", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerChangeWorld(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* world = nullptr;
|
||||
const SQChar* waypoint = nullptr;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &world);
|
||||
nonut::sqGetValue(vm, 4, &waypoint);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "world"_a=world, "waypoint"_a=waypoint);
|
||||
callEvent("onPlayerChangeWorld", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
|
||||
SQInteger sq_onPlayerCommand(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* command;
|
||||
const SQChar* params;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &command);
|
||||
nonut::sqGetValue(vm, 4, ¶ms);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "command"_a=command, "params"_a=params);
|
||||
callEvent("onPlayerCommand", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerDamage(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, killerid;
|
||||
HSQOBJECT sqobj;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &killerid);
|
||||
nonut::sqGetValue(vm, 4, &sqobj);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "killerid"_a=killerid, "description"_a=PyDamageDescription(sqobj));
|
||||
callEvent("onPlayerDamage", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerDead(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, killerid;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &killerid);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "killerid"_a=killerid);
|
||||
callEvent("onPlayerDead", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerDisconnect(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, reason;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &reason);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "reason"_a=reason);
|
||||
callEvent("onPlayerDisconnect", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerDropItem(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
HSQOBJECT sqobj;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &sqobj);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "itemGround"_a=PyItemGround(sqobj));
|
||||
callEvent("onPlayerDropItem", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEnterWorld(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* world;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &world);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "world"_a=world);
|
||||
callEvent("onPlayerEnterWorld", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerJoin(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid);
|
||||
callEvent("onPlayerJoin", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerMessage(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* message;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &message);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "message"_a=message);
|
||||
callEvent("onPlayerMessage", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerMobInteract(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, from, to;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &from);
|
||||
nonut::sqGetValue(vm, 3, &to);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "from"_a=from, "to"_a = to);
|
||||
callEvent("onPlayerMobInteract", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerRespawn(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid);
|
||||
callEvent("onPlayerRespawn", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerShoot(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* munition;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &munition);
|
||||
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "munition"_a=munition);
|
||||
callEvent("onPlayerShoot", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerSpellCast(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance;
|
||||
SQInteger spellLevel;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
nonut::sqGetValue(vm, 4, &spellLevel);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance, "spellLevel"_a=spellLevel);
|
||||
callEvent("onPlayerSpellCast", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerSpellSetup(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerSpellSetup", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerTakeItem(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
HSQOBJECT sqobj;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &sqobj);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "itemGround"_a=PyItemGround(sqobj));
|
||||
callEvent("onPlayerTakeItem", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerTeleport(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* vobName;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &vobName);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "vobName"_a=vobName);
|
||||
callEvent("onPlayerTeleport", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerToggleFaceAni(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* aniName;
|
||||
SQBool toggle;
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &aniName);
|
||||
nonut::sqGetValue(vm, 4, &toggle);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "vobName"_a=aniName, "toggle"_a = toggle);
|
||||
callEvent("onPlayerToggleFaceAni", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
|
||||
SQInteger sq_onPlayerEquipAmulet(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipAmulet", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipArmor(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipArmor", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipBelt(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipBelt", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipHandItem(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, hand;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &hand);
|
||||
if (sq_gettype(vm, 4) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 4, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "hand"_a = hand, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipHandItem", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipHelmet(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipHelmet", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipMeleeWeapon(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipMeleeWeapon", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipRangedWeapon(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipRangedWeapon", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipRing(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, hand;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &hand);
|
||||
if (sq_gettype(vm, 4) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 4, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "hand"_a = hand, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipRing", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipShield(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
if (sq_gettype(vm, 3) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 3, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipShield", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SQInteger sq_onPlayerEquipSpell(HSQUIRRELVM vm)
|
||||
{
|
||||
SQInteger playerid, slotId;
|
||||
const SQChar* instance = "";
|
||||
|
||||
nonut::sqGetValue(vm, 2, &playerid);
|
||||
nonut::sqGetValue(vm, 3, &slotId);
|
||||
if (sq_gettype(vm, 4) != OT_NULL)
|
||||
nonut::sqGetValue(vm, 4, &instance);
|
||||
|
||||
py::dict kwargs = py::dict("playerid"_a=playerid, "slotId"_a = slotId, "instance"_a=instance);
|
||||
callEvent("onPlayerEquipSpell", kwargs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user