feat: Added ItemGround class
+ Added onPlayerTakeItem and onPlayerDropItem events
This commit is contained in:
@@ -141,6 +141,7 @@ addEvent('onPlayerCommand')
|
||||
addEvent('onPlayerDamage')
|
||||
addEvent('onPlayerDead')
|
||||
addEvent('onPlayerDisconnect')
|
||||
addEvent('onPlayerDropItem')
|
||||
addEvent('onPlayerEnterWorld')
|
||||
addEvent('onPlayerJoin')
|
||||
addEvent('onPlayerMessage')
|
||||
@@ -149,6 +150,7 @@ addEvent('onPlayerRespawn')
|
||||
addEvent('onPlayerShoot')
|
||||
addEvent('onPlayerSpellCast')
|
||||
addEvent('onPlayerSpellSetup')
|
||||
addEvent('onPlayerTakeItem')
|
||||
addEvent('onPlayerTeleport')
|
||||
addEvent('onPlayerToggleFaceAni')
|
||||
|
||||
|
||||
35
g2o/items.py
Normal file
35
g2o/items.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import sqg2o
|
||||
|
||||
class ItemGround(sqg2o.ItemGround):
|
||||
def __init__(self):
|
||||
return super().__init__()
|
||||
|
||||
def getPosition() -> tuple:
|
||||
return super().getPosition()
|
||||
|
||||
def getRotation() -> tuple:
|
||||
return super().getRotation()
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return super().id
|
||||
|
||||
@property
|
||||
def instance(self):
|
||||
return super().instance
|
||||
|
||||
@property
|
||||
def amount(self):
|
||||
return super().amount
|
||||
|
||||
@property
|
||||
def world(self):
|
||||
return super().world
|
||||
|
||||
@property
|
||||
def virtualWorld(self):
|
||||
return super().virtualWorld
|
||||
|
||||
@virtualWorld.setter
|
||||
def virtualWorld(self, value):
|
||||
super().virtualWorld = value
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "Array.h"
|
||||
#include "Property.h"
|
||||
|
||||
namespace nonut::g2o
|
||||
namespace nonut
|
||||
{
|
||||
#define GET_SLOT(slot, type) slot = arrayWrapper.get<type>(#slot)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "Utils.h"
|
||||
|
||||
namespace nonut::g2o
|
||||
namespace nonut
|
||||
{
|
||||
struct GameTime : CustomType
|
||||
{
|
||||
|
||||
61
src/bind.cpp
61
src/bind.cpp
@@ -1,6 +1,7 @@
|
||||
#include <pybind11/embed.h>
|
||||
#include "classes/py/Packet.h"
|
||||
#include "classes/py/DamageDescription.h"
|
||||
#include "classes/py/ItemGround.h"
|
||||
#include <NoNut/core/Constant.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
@@ -9,28 +10,28 @@ PYBIND11_EMBEDDED_MODULE(sqg2o, m) {
|
||||
|
||||
py::class_<PyPacket>(m, "Packet")
|
||||
.def(py::init<>())
|
||||
.def("reset", &PyPacket::reset)
|
||||
.def("send", &PyPacket::send)
|
||||
.def("sendToAll", &PyPacket::sendToAll)
|
||||
.def("writeInt8", &PyPacket::writeInt8)
|
||||
.def("writeUInt8", &PyPacket::writeUInt8)
|
||||
.def("writeInt16", &PyPacket::writeInt16)
|
||||
.def("writeUInt16", &PyPacket::writeUInt16)
|
||||
.def("writeInt32", &PyPacket::writeInt32)
|
||||
.def("writeUInt32", &PyPacket::writeUInt32)
|
||||
.def("writeFloat", &PyPacket::writeFloat)
|
||||
.def("writeBool", &PyPacket::writeBool)
|
||||
.def("writeString", &PyPacket::writeString)
|
||||
.def("readInt8", &PyPacket::readInt8)
|
||||
.def("readUInt8", &PyPacket::readUInt8)
|
||||
.def("readInt16", &PyPacket::readInt16)
|
||||
.def("readUInt16", &PyPacket::readUInt16)
|
||||
.def("readInt32", &PyPacket::readInt32)
|
||||
.def("readUInt32", &PyPacket::readUInt32)
|
||||
.def("readFloat", &PyPacket::readFloat)
|
||||
.def("readBool", &PyPacket::readBool)
|
||||
.def("readString", &PyPacket::readString)
|
||||
.def("__del__", &PyPacket::del)
|
||||
.def("reset", &PyPacket::reset)
|
||||
.def("send", &PyPacket::send)
|
||||
.def("sendToAll", &PyPacket::sendToAll)
|
||||
.def("writeInt8", &PyPacket::writeInt8)
|
||||
.def("writeUInt8", &PyPacket::writeUInt8)
|
||||
.def("writeInt16", &PyPacket::writeInt16)
|
||||
.def("writeUInt16", &PyPacket::writeUInt16)
|
||||
.def("writeInt32", &PyPacket::writeInt32)
|
||||
.def("writeUInt32", &PyPacket::writeUInt32)
|
||||
.def("writeFloat", &PyPacket::writeFloat)
|
||||
.def("writeBool", &PyPacket::writeBool)
|
||||
.def("writeString", &PyPacket::writeString)
|
||||
.def("readInt8", &PyPacket::readInt8)
|
||||
.def("readUInt8", &PyPacket::readUInt8)
|
||||
.def("readInt16", &PyPacket::readInt16)
|
||||
.def("readUInt16", &PyPacket::readUInt16)
|
||||
.def("readInt32", &PyPacket::readInt32)
|
||||
.def("readUInt32", &PyPacket::readUInt32)
|
||||
.def("readFloat", &PyPacket::readFloat)
|
||||
.def("readBool", &PyPacket::readBool)
|
||||
.def("readString", &PyPacket::readString)
|
||||
.def("__del__", &PyPacket::del)
|
||||
|
||||
.def_property_readonly("bitsUsed", &PyPacket::getBitsUsed)
|
||||
.def_property_readonly("bytesUsed", &PyPacket::getBytesUsed);
|
||||
@@ -49,4 +50,20 @@ PYBIND11_EMBEDDED_MODULE(sqg2o, m) {
|
||||
.def_property("spell_id", &PyDamageDescription::getSpellId, &PyDamageDescription::setSpellId, py::return_value_policy::reference_internal)
|
||||
.def_property("spell_level", &PyDamageDescription::getSpellLevel, &PyDamageDescription::setSpellLevel, py::return_value_policy::reference_internal)
|
||||
.def_property("node", &PyDamageDescription::getNode, &PyDamageDescription::setNode, py::return_value_policy::reference_internal);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PyItemGround>(m, "ItemGround")
|
||||
.def(py::init<>())
|
||||
.def("__del__", &PyItemGround::del)
|
||||
|
||||
.def("getPosition", &PyItemGround::getPosition)
|
||||
.def("getRotation", &PyItemGround::getRotation)
|
||||
|
||||
.def_property_readonly("id", &PyItemGround::getId)
|
||||
.def_property_readonly("instance", &PyItemGround::getInstance)
|
||||
.def_property_readonly("amount", &PyItemGround::getAmount)
|
||||
.def_property_readonly("world", &PyItemGround::getWorld)
|
||||
|
||||
.def_property("virtualWorld", &PyItemGround::getVirtualWorld, &PyItemGround::setVirtualWorld, py::return_value_policy::reference_internal);
|
||||
}
|
||||
32
src/classes/py/ItemGround.h
Normal file
32
src/classes/py/ItemGround.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _PY_ITEMGROUND_H_
|
||||
#define _PY_ITEMGROUND_H_
|
||||
|
||||
#include <pybind11/embed.h>
|
||||
#include <classes/sq/ItemGround.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
class PyItemGround
|
||||
{
|
||||
private:
|
||||
nonut::ItemGround *sqobj;
|
||||
|
||||
public:
|
||||
PyItemGround() { sqobj = new nonut::ItemGround(); };
|
||||
PyItemGround(SQObject obj) { sqobj = new nonut::ItemGround(obj); }
|
||||
|
||||
py::tuple getPosition() { return py::make_tuple(sqobj->getPosition().toTuple()); }
|
||||
py::tuple getRotation() { return py::make_tuple(sqobj->getRotation().toTuple()); }
|
||||
|
||||
nonut::Int getId() { return sqobj->id; }
|
||||
nonut::String getInstance() { return sqobj->instance; }
|
||||
nonut::Int getAmount() { return sqobj->amount; }
|
||||
nonut::String getWorld() { return sqobj->world; }
|
||||
nonut::Int getVirtualWorld() { return sqobj->virtualWorld; }
|
||||
|
||||
void setVirtualWorld(nonut::Int value) { sqobj->virtualWorld = value; }
|
||||
|
||||
void del() { delete sqobj; }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -13,7 +13,6 @@ namespace nonut
|
||||
DamageDescription();
|
||||
explicit DamageDescription(SQObject object);
|
||||
|
||||
// Properties
|
||||
Property<Int> flags;
|
||||
Property<Int> damage;
|
||||
Property<String> item_instance;
|
||||
|
||||
34
src/classes/sq/ItemGround.cpp
Normal file
34
src/classes/sq/ItemGround.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include <NoNut/core/CommonHeader.h>
|
||||
#include "ItemGround.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
ItemGround::ItemGround() :
|
||||
Class("ItemGround"),
|
||||
|
||||
METHOD_CTOR(getPosition),
|
||||
METHOD_CTOR(getRotation),
|
||||
|
||||
PROPERTY_CTOR(id),
|
||||
PROPERTY_CTOR(instance),
|
||||
PROPERTY_CTOR(amount),
|
||||
PROPERTY_CTOR(world),
|
||||
PROPERTY_CTOR(virtualWorld)
|
||||
{
|
||||
classCtor();
|
||||
}
|
||||
|
||||
ItemGround::ItemGround(SQObject object) :
|
||||
Class("ItemGround", object),
|
||||
|
||||
METHOD_CTOR(getPosition),
|
||||
METHOD_CTOR(getRotation),
|
||||
|
||||
PROPERTY_CTOR(id),
|
||||
PROPERTY_CTOR(instance),
|
||||
PROPERTY_CTOR(amount),
|
||||
PROPERTY_CTOR(world),
|
||||
PROPERTY_CTOR(virtualWorld)
|
||||
{
|
||||
}
|
||||
}
|
||||
28
src/classes/sq/ItemGround.h
Normal file
28
src/classes/sq/ItemGround.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef _ITEMGROUND_H
|
||||
#define _ITEMGROUND_H
|
||||
#include <string>
|
||||
|
||||
#include <NoNut/core/Class.h>
|
||||
#include <NoNut/core/CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class ItemGround : public Class
|
||||
{
|
||||
public:
|
||||
ItemGround();
|
||||
explicit ItemGround(SQObject object);
|
||||
|
||||
Function<nonut::Position3d> getPosition;
|
||||
Function<nonut::Position3d> getRotation;
|
||||
|
||||
// Properties
|
||||
Property<Int> id;
|
||||
Property<String> instance;
|
||||
Property<Int> amount;
|
||||
Property<String> world;
|
||||
Property<Int> virtualWorld;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -64,6 +64,7 @@ void registerSquirrelEvents()
|
||||
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);
|
||||
@@ -72,6 +73,7 @@ void registerSquirrelEvents()
|
||||
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);
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ 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);
|
||||
@@ -43,6 +44,7 @@ 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);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <pybind11/embed.h>
|
||||
#include "NoNut/core/Utils.h"
|
||||
#include <classes/py/DamageDescription.h>
|
||||
#include <classes/py/ItemGround.h>
|
||||
#include "sqevents.h"
|
||||
|
||||
namespace py = pybind11;
|
||||
@@ -183,6 +184,20 @@ SQInteger sq_onPlayerDisconnect(HSQUIRRELVM vm)
|
||||
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;
|
||||
@@ -291,6 +306,20 @@ SQInteger sq_onPlayerSpellSetup(HSQUIRRELVM vm)
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user