refactor: Refactorized whole project structure

This commit is contained in:
AURUMVORXX
2025-01-24 22:36:25 +03:00
parent d50f55086b
commit a479b5f85d
321 changed files with 288 additions and 219 deletions

View File

View File

@@ -0,0 +1,42 @@
import sqg2o
class Daedalus:
"""
This class represents Daedalus scripting interface.
Original: [Daedalus](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-classes/game/Daedalus/)
"""
@staticmethod
def index(value : str) -> int:
"""
This method will get the daedalus symbol index by its name.
**Parameters:**
* `str` **name**: the name of the daedalus symbol.
**Returns `int`:**
the daedalus symbol index number.
"""
return sqg2o.Daedalus.index(value)
@staticmethod
def symbol(value : str) -> dict:
"""
This method will get the daedalus symbol by its name.
**Parameters:**
* `str` **name**: the name of the daedalus symbol.
**Returns `dict`:**
the daedalus symbol (empty if there's no symbol with given name)
"""
return sqg2o.Daedalus.symbol(value)
@staticmethod
def instance(value : str) -> dict:
"""
This method will get the all of the daedalus instance variables.
**Parameters:**
* `str` **instanceName**: the name of the daedalus instance.
**Returns `dict`:**
the object containing all of the daedalus instance variables.
"""
return sqg2o.Daedalus.instance(value)

View File

@@ -0,0 +1,86 @@
import sqg2o
class DamageDescription(sqg2o.DamageDescription):
"""
This class represents damage information.
Original: [DamageDescription](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-classes/item/DamageDescription//)
## `int` flags
Represents the damage flags.
## `int` damage
Represents the total damage taken.
## `str` item_instance *(read-only)*
!!! note
Can be empty if there is no weapon.
Represents the weapon instance used to deal damage.
## `int` distance
Represents the total distance, calculated from origin point to target.
## `int` spell_id
Represents the spell id.
## `int` spell_level
Represents the level of chargeable spells.
## `str` node
!!! note
Can be empty if there was no projectile.
Represents the name of the node hit by a point projectile.
"""
def __init__(self):
return super().__init__()
@property
def item_instance(self):
return super().item_instance
@property
def flags(self):
return super().flags
@flags.setter
def flags(self, value):
super().flags = value
@property
def damage(self):
return super().damage
@damage.setter
def damage(self, value):
super().damage = value
@property
def distance(self):
return super().distance
@distance.setter
def distance(self, value):
super().distance = value
@property
def spell_id(self):
return super().spell_id
@spell_id.setter
def spell_id(self, value):
super().spell_id = value
@property
def spell_level(self):
return super().spell_level
@spell_level.setter
def spell_level(self, value):
super().spell_level = value
@property
def node(self):
return super().node
@node.setter
def node(self, value):
super().node = value

110
python/g2o/classes/items.py Normal file
View File

@@ -0,0 +1,110 @@
import sqg2o
class ItemsGround:
"""
This class represents item ground manager.
Original: [ItemsGround](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-classes/item/ItemsGround/)
"""
@staticmethod
def getById(id : int):
"""
This method will retrieve the item ground object by its unique id.
**Parameters:**
* `int` **itemGroundId**: the unique item ground id.
**Returns `ItemGround`:**
the item ground object or `throws an exception` if the object cannot be found.
"""
return sqg2o.ItemsGround.getById(id)
@staticmethod
def create(data : dict) -> int:
"""
This method will create the item ground.
**Parameters:**
* `dict {instance, amount=1, physicsEnabled=false position={x=0,y=0,z=0}, rotation={x=0,y=0,z=0}, world=CONFIG_WORLD, virtualWorld=0}`:
* `string` **instance**: the scripting instance of game item.
* `bool` **physicsEnabled**: the physics state of the item ground.
* `dict {x, y, z}` **position**: the position of the item ground in the world.
* `dict {x, y, z}` **rotation**: the rotation of the item ground in the world.
* `string` **world**: the world the item ground is in (.ZEN file path).
* `int` **virtualWorld**: the virtual world id in range <0, 65535>.
**Returns `int`:**
the item ground id.
"""
return sqg2o.ItemsGround.create(data)
@staticmethod
def destroy(id : int):
"""
This method will destroy the item ground by it's unique id.
**Parameters:**
* `int` **itemGroundId**: the item ground unique id.
"""
sqg2o.ItemsGround.destroy(id)
class ItemGround(sqg2o.ItemGround):
"""
This class represents item on the ground.
Original: [ItemGround](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-classes/item/ItemGround//)
## `int` id *(read-only)*
Represents the unique id of the item ground.
## `str` instance *(read-only)*
Represents the item instance of the item ground.
## `int` amount *(read-only)*
Represents the item amount of item ground.
## `str` world *(read-only)*
Represents the item ground world (.ZEN file path).
## `int` virtualWorld
Represents the virtual world of item ground.
"""
def __init__(self):
return super().__init__()
def getPosition() -> tuple:
"""
This method will get the item ground position on the world.
**Returns `tuple(float, float, float)`:**
`X-Y-Z` item ground position on the world.
"""
return super().getPosition()
def getRotation() -> tuple:
"""
This method will get the item ground rotation on the world.
**Returns `tuple(float, float, float)`:**
`X-Y-Z` item ground roration on the world.
"""
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

30
python/g2o/classes/mds.py Normal file
View File

@@ -0,0 +1,30 @@
import sqg2o
class Mds:
"""
This class represents mds manager for conversion between mds id & mds instance. This manager will work for every registered mds in `mds.xml` file.
Original: [Mds](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/shared-classes/mds/Mds/)
"""
@staticmethod
def id(mdsName : str) -> int:
"""
This method will convert the mds name to mds id.
**Parameters:**
* `str` **mdsName**: the mds name, e.g: `"HumanS_Sprint.mds"`.
**Returns `int`:**
the unique mds id.
"""
return sqg2o.Mds.id(mdsName)
@staticmethod
def name(mdsId : int) -> str:
"""
This method will convert the mds id to mds name.
**Parameters:**
* `int` **mdsId**: the mds id.
**Returns `str`:**
the mds name, e.g: `"HumanS_Sprint.mds"`.
"""
return sqg2o.Mds.name(mdsId)

View File

@@ -0,0 +1,196 @@
import sqg2o
class Packet(sqg2o.Packet):
"""
This class represents data packet that gets send over the network.
Original: [Packet](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-classes/network/Packet/)
## `int` bitsUsed *(read-only)*
Represents the total number of bits used by the script packet data.
## `int` bytesUsed *(read-only)*
Represents the total number of bytes used by the script packet data.
"""
def __init__(self):
return super().__init__()
def reset(self):
"""
This method will clear the packet data, making it empty.
"""
return super().reset()
def send(self, playerid : int, reliability : int):
"""
This method will send the packet data to the specified player.
**Parameters:**
* `int` **playerid**: the id of the player to whom you want to send the packet.
* `int` **reliability**: the reliability type, for more information see [Reliability](../../constants/reliability.md).
"""
return super().send(playerid, reliability)
def sendToAll(self, reliability : int):
"""
This method will send the packet data to the specified player.
**Parameters:**
* `int` **reliability**: the reliability type, for more information see [Reliability](../../constants/reliability.md).
"""
return super().send(playerid, reliability)
def writeInt8(self, value : int):
"""
This method will append signed int8 value to the packet. (1 byte)
**Parameters:**
* `int` **value**: the number value in range -128 to 127.
"""
return super().writeInt8(value)
def writeUInt8(self, value : int):
"""
This method will append unsigned int8 value to the packet. (1 byte)
**Parameters:**
* `int` **value**: the number value in range 0 to 255.
"""
return super().writeInt8(value)
def writeInt16(self, value : int):
"""
This method will append signed int16 value to the packet. (2 bytes)
**Parameters:**
* `int` **value**: the number value in range -32768 to 32767.
"""
return super().writeInt16(value)
def writeUInt16(self, value : int):
"""
This method will append unsigned int16 value to the packet. (2 bytes)
**Parameters:**
* `int` **value**: the number value in range 0 to 65535.
"""
return super().writeInt16(value)
def writeInt32(self, value : int):
"""
This method will append signed int32 value to the packet. (4 bytes)
**Parameters:**
* `int` **value**: the number value in range -2147483648 to 2147483647.
"""
return super().writeInt32(value)
def writeUInt32(self, value : int):
"""
!!! note
By default squirrel uses int32 values, which means that this method behaves exactly the same as [writeInt32](Packet.md#g2o.classes.packets.Packet.writeInt32) in scripts.
This method will append unsigned int32 value to the packet. (4 bytes)
**Parameters:**
* `int` **value**: the number value in range 0 to 4294967295.
"""
return super().writeInt32(value)
def writeBool(self, value : bool):
"""
This method will append boolean value to the packet. (1 bit)
**Parameters:**
* `bool` **value**: the boolean value.
"""
return super().writeBool(value)
def writeFloat(self, value : float):
"""
This method will append float value to the packet. (4 bytes)
**Parameters:**
* `float` **value**: the number value.
"""
return super().writeFloat(value)
def writeString(self, value : str):
"""
!!! note
The amount of bytes appended to the packet depends on the length of string, 1 byte = 1 char.
This method will append string value to the packet.
**Parameters:**
* `str` **value**: the text value.
"""
return super().writeString(value)
def readInt8(self,) -> int:
"""
This method will get signed int8 value from the packet. (1 byte)
**Returns `int`:**
the number value in range -128 to 127.
"""
return super().readInt8()
def readUInt8(self,) -> int:
"""
This method will get unsigned int8 value from the packet. (1 byte)
**Returns `int`:**
the number value in range 0 to 255.
"""
return super().readInt8()
def readInt16(self) -> int:
"""
This method will get signed int16 value from the packet. (2 bytes)
**Returns `int`:**
the number value in range -32768 to 32767.
"""
return super().readInt16()
def readUInt16(self) -> int:
"""
This method will get unsigned int16 value from the packet. (2 bytes)
**Returns `int`:**
the number value in range 0 to 65535.
"""
return super().readInt16()
def readInt32(self) -> int:
"""
This method will get signed int32 value from the packet. (4 bytes)
**Returns `int`:**
the number value in range -2147483648 to 2147483647.
"""
return super().readInt32()
def readUInt32(self) -> int:
"""
This method will get unsigned int32 value from the packet. (4 bytes)
**Returns `int`:**
the number value in range 0 to 4294967295.
"""
return super().readInt32()
def readBool(self) -> bool:
"""
This method will get signed int8 value from the packet. (1 byte)
**Returns `bool`:**
the boolean value.
"""
return super().readBool()
def readFloat(self) -> float:
"""
This method will get float value from the packet. (4 bytes)
**Returns `float`:**
the number value.
"""
return super().readFloat()
def readString(self) -> str:
"""
!!! note
The amount of bytes appended to the packet depends on the length of string, 1 byte = 1 char.
This method will get string value from the packet.
**Returns `str`:**
the text value.
"""
return super().readString()
@property
def bitsUsed(self):
return super().bitsUsed
@property
def bytesUsed(self):
return super().bytesUsed

106
python/g2o/classes/sky.py Normal file
View File

@@ -0,0 +1,106 @@
import sqg2o
class SkyMeta(type):
@property
def weather(self):
return sqg2o.Sky.weather
@weather.setter
def weather(self, value):
sqg2o.Sky.weather
@property
def raining(self):
return sqg2o.Sky.raining
@raining.setter
def raining(self, value):
sqg2o.Sky.raining = value
@property
def renderLightning(self):
return sqg2o.Sky.renderLightning
@renderLightning.setter
def renderLightning(self, value):
sqg2o.Sky.renderLightning = value
@property
def windScale(self):
return sqg2o.Sky.windScale
@windScale.setter
def windScale(self, value):
sqg2o.Sky.windScale = value
@property
def dontRain(self):
return sqg2o.Sky.dontRain
@dontRain.setter
def dontRain(self, value):
sqg2o.Sky.dontRain = value
class Sky(metaclass=SkyMeta):
"""
This class represents data packet that gets send over the network.
Original: [Sky](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-classes/game/Sky/)
## `int` weather
Represents the sky weather. For more information see [Weather Constants](../../constants/weather.md)
## `bool` raining
Represents the raining/snowing state.
## `bool` renderLightning
Represents the lightning feature during raining state.
Lightning will only be rendered during raining and when weatherWeight is larger than 0.5
## `float` windScale
Represents the sky wind scale used during raining/snowing.
## `bool` dontRain
Represents the sky dontRain feature.
When it's enabled, the rain/snow won't fall.
"""
@staticmethod
def setRainStartTime(hour : int, minute : int):
"""
This method will set the sky weather time when it starts raining/snowing.
**Parameters:**
* `int` **hour**: the sky weather raining start hour.
* `int` **minute**: the sky weather raining start min.
"""
sqg2o.Sky.setRainStartTime(hour, minute)
@staticmethod
def setRainStopTime(hour : int, minute : int):
"""
This method will set the sky weather time when it stops raining/snowing.
**Parameters:**
* `int` **hour**: the sky weather raining stop hour.
* `int` **minute**: the sky weather raining stop min.
"""
sqg2o.Sky.setRainStopTime(hour, minute)
@staticmethod
def getRainStartTime() -> dict:
"""
This method will get the sky weather time when it starts raining/snowing.
**Returns `dict`:**
* `int` **hour**: the sky weather raining start hour.
* `int` **minute**: the sky weather raining start min.
"""
return sqg2o.Sky.getRainStartTime()
@staticmethod
def getRainStopTime() -> dict:
"""
This method will get the sky weather time when it stops raining/snowing.
**Returns `dict`:**
* `int` **hour**: the sky weather raining stop hour.
* `int` **minute**: the sky weather raining stop min.
"""
return sqg2o.Sky.getRainStopTime()

48
python/g2o/classes/way.py Normal file
View File

@@ -0,0 +1,48 @@
import sqg2o
class Way(sqg2o.Way):
"""
This class represents Way constructed from waypoints.
Original: [Way](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/server-classes/waypoint/Way/)
## `str` start *(read-only)*
Represents the start waypoint for Way.
## `str` end *(read-only)*
Represents the end waypoint for Way.
"""
def __init__(self, world : str, startWp : str, endWp : str):
"""
## Parameters
`str` **world**: the name of the world from config.xml.
`str` **startWp**: the name of the start waypoint.
`str` **endWp**: the name of the end waypoint.
"""
return super().__init__(world, startWp, endWp)
def getWaypoints(self) -> list:
"""
This method will get the all waypoints between startWp & endWp.
## Returns
`list [str]`: the list containing the names of all of the Way waypoints.
"""
return super().getWaypoints()
def getCountWaypoints(self):
"""
This method will get the number of waypoints between start waypoint & end waypoint.
## Returns
`int`: the number of waypoints.
"""
return super().getCountWaypoints()
@property
def start(self):
return super().start
@property
def end(self):
return super().end