summaryrefslogtreecommitdiff
path: root/packets
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-13 14:53:38 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-13 14:53:38 +0100
commitca4d1945598863d0ce297f4272317e5dd5797f88 (patch)
treec2675b394140a71c7eee04034f087c107dcd7c9c /packets
parenta22381eff3bf2286ee27f4d15ddf4c431ea063be (diff)
next commit
Diffstat (limited to 'packets')
-rw-r--r--packets/equippable_item_information.gd101
-rw-r--r--packets/equippable_item_list_packet.gd32
-rw-r--r--packets/inventory_end_packet.gd26
-rw-r--r--packets/inventory_start_packet.gd32
-rw-r--r--packets/item_option.gd40
-rw-r--r--packets/map_loaded_packet.gd12
-rw-r--r--packets/regular_item_information.gd65
-rw-r--r--packets/regular_item_list_packet.gd32
-rw-r--r--packets/sprite_change_packet.gd37
9 files changed, 377 insertions, 0 deletions
diff --git a/packets/equippable_item_information.gd b/packets/equippable_item_information.gd
new file mode 100644
index 0000000..8ba0629
--- /dev/null
+++ b/packets/equippable_item_information.gd
@@ -0,0 +1,101 @@
+## rAthena References:
+## - EQUIPITEM_INFO
+## - clif_item_equip
+class_name EquippableItemInformation
+extends PacketChunk
+
+
+const BYTE_LENGTH := 22
+
+
+## Byte Type: u16
+## Byte Length: 2
+var index: int
+
+## Byte Type: u32
+## Byte Length: 4
+var item_id: int
+
+## Byte Type: u8
+## Byte Length: 1
+var item_type: int
+
+## Byte Type: u32
+## Byte Length: 4
+var equip_position: int
+
+## Byte Type: u32
+## Byte Length: 4
+var equipped_position: int
+
+## Byte Type: u32
+## Byte Length: 4
+var slot: int
+
+## Byte Type: u32
+## Byte Length: 4
+var hire_expiration_date: int
+
+## Byte Type: u16
+## Byte Length: 2
+var bind_on_equip_type: int
+
+## Byte Type: u16
+## Byte Length: 2
+var w_item_sprite_number: int
+
+## Byte Type: u8
+## Byte Length: 1
+## always 0 ?
+var option_count: int
+
+## Byte Length: 5 * ItemOption.BYTE_LENGTH
+var option_data: Array[ItemOption]
+
+## Byte Type: u8
+## Byte Length: 1
+var refinement_level: int
+
+## Byte Type: u8
+## Byte Length: 1
+var enchantment_level: int
+
+## Byte Type: u8
+## Byte Length: 1
+var flags: int
+
+
+static func from_bytes(bytes: PackedByteArray):
+ var info = EquippableItemInformation.new()
+
+ info.index = bytes.decode_u16(0)
+ info.item_id = bytes.decode_u32(2)
+ info.item_type = bytes.decode_u8(6)
+ info.equipped_position = bytes.decode_u32(7)
+ info.equipped_position = bytes.decode_u32(11)
+ info.slot = bytes.decode_u32(15)
+ info.hire_expiration_date = bytes.decode_u32(19)
+ info.bind_on_equip_type = bytes.decode_u16(23)
+ info.w_item_sprite_number = bytes.decode_u16(25)
+ info.option_count = bytes.decode_u8(27)
+
+ var option_data_end = 28 + (5 * ItemOption.BYTE_LENGTH)
+ info.option_data = ItemOption.array_from_bytes(bytes.slice(28, option_data_end))
+
+ info.refinement_level = bytes.decode_u8(option_data_end)
+ info.enchantment_level = bytes.decode_u8(option_data_end + 1)
+ info.flags = bytes.decode_u8(option_data_end + 2)
+
+ return info
+
+
+static func array_from_bytes(bytes: PackedByteArray) -> Array[EquippableItemInformation]:
+ var array: Array[EquippableItemInformation] = []
+
+ var offset = 0
+ while offset < bytes.size():
+ var chunk = from_bytes(bytes.slice(offset))
+ array.append(chunk)
+ offset += chunk.byte_length
+
+ return array
diff --git a/packets/equippable_item_list_packet.gd b/packets/equippable_item_list_packet.gd
new file mode 100644
index 0000000..9b47202
--- /dev/null
+++ b/packets/equippable_item_list_packet.gd
@@ -0,0 +1,32 @@
+## rAthena References:
+## - clif_inventorylist
+## - packet_itemlist_equip
+class_name EquippableItemListPacket
+extends Packet
+
+
+const HEADER := 0x0b39
+const BYTE_LENGTH := 0
+
+
+
+## Byte Type: u16
+## Byte Length: 2
+var packet_length: int
+
+## Byte Type: u8
+## Byte Length: 1
+var inventory_type: int
+
+## Byte Type: u8
+var item_information: Array[EquippableItemInformation]
+
+
+static func from_bytes(bytes: PackedByteArray) -> EquippableItemListPacket:
+ var packet = EquippableItemListPacket.new()
+
+ packet.packet_length = bytes.decode_u16(2)
+ packet.inventory_type = bytes.decode_u8(4)
+ packet.item_information = EquippableItemInformation.array_from_bytes(bytes.slice(5))
+
+ return packet
diff --git a/packets/inventory_end_packet.gd b/packets/inventory_end_packet.gd
new file mode 100644
index 0000000..d8d313b
--- /dev/null
+++ b/packets/inventory_end_packet.gd
@@ -0,0 +1,26 @@
+## rAthena References:
+## - PACKET_ZC_INVENTORY_END
+## - clif_inventoryEnd
+class_name InventoryEndPacket
+extends Packet
+
+
+const HEADER := 0x0b0b
+const BYTE_LENGTH := 4
+
+
+## Byte Type: u8
+## Byte Length: 1
+var inventory_type: int
+
+## Byte Type: u8
+var flag: int
+
+
+static func from_bytes(bytes: PackedByteArray) -> InventoryEndPacket:
+ var packet = InventoryEndPacket.new()
+
+ packet.inventory_type = bytes.decode_u8(2)
+ packet.flag = bytes.decode_u8(3)
+
+ return packet
diff --git a/packets/inventory_start_packet.gd b/packets/inventory_start_packet.gd
new file mode 100644
index 0000000..2a02731
--- /dev/null
+++ b/packets/inventory_start_packet.gd
@@ -0,0 +1,32 @@
+## rAthena References:
+## - PACKET_ZC_INVENTORY_START
+## - clif_inventoryStart
+class_name InventoryStartPacket
+extends Packet
+
+
+const HEADER := 0x0b08
+const BYTE_LENGTH := 0
+
+
+
+## Byte Type: u16
+## Byte Length: 2
+var packet_length: int
+
+## Byte Type: u8
+## Byte Length: 1
+var inventory_type: int
+
+## Byte Type: u8
+var inventory_name: String
+
+
+static func from_bytes(bytes: PackedByteArray) -> InventoryStartPacket:
+ var packet = InventoryStartPacket.new()
+
+ packet.packet_length = bytes.decode_u16(2)
+ packet.inventory_type = bytes.decode_u8(4)
+ packet.inventory_name = bytes.slice(5).get_string_from_utf8()
+
+ return packet
diff --git a/packets/item_option.gd b/packets/item_option.gd
new file mode 100644
index 0000000..8f59166
--- /dev/null
+++ b/packets/item_option.gd
@@ -0,0 +1,40 @@
+class_name ItemOption
+extends PacketChunk
+
+
+const BYTE_LENGTH := 5
+
+
+## Byte Type: u16
+## Byte Length: 2
+var index: int
+
+## Byte Type: u16
+## Byte Length: 2
+var value: int
+
+## Byte Type: u8
+## Byte Length: 1
+var parameter: int
+
+
+static func from_bytes(bytes: PackedByteArray):
+ var option = ItemOption.new()
+
+ option.index = bytes.decode_u16(0)
+ option.value = bytes.decode_u16(2)
+ option.parameter = bytes.decode_u8(3)
+
+ return option
+
+
+static func array_from_bytes(bytes: PackedByteArray) -> Array[ItemOption]:
+ var array: Array[ItemOption] = []
+
+ var offset = 0
+ while offset < bytes.size():
+ var chunk = from_bytes(bytes.slice(offset))
+ array.append(chunk)
+ offset += chunk.byte_length
+
+ return array
diff --git a/packets/map_loaded_packet.gd b/packets/map_loaded_packet.gd
new file mode 100644
index 0000000..e0f0967
--- /dev/null
+++ b/packets/map_loaded_packet.gd
@@ -0,0 +1,12 @@
+## rAthena References:
+## - clif_parse_LoadEndAck
+class_name MapLoadedPacket
+extends Packet
+
+
+const HEADER := 0x007d
+const BYTE_LENGTH := 2
+
+
+func to_bytes():
+ return get_header()
diff --git a/packets/regular_item_information.gd b/packets/regular_item_information.gd
new file mode 100644
index 0000000..212b341
--- /dev/null
+++ b/packets/regular_item_information.gd
@@ -0,0 +1,65 @@
+class_name RegularItemInformation
+extends PacketChunk
+
+
+const BYTE_LENGTH := 22
+
+
+## Byte Type: u16
+## Byte Length: 2
+var index: int
+
+## Byte Type: u32
+## Byte Length: 4
+var item_id: int
+
+## Byte Type: u8
+## Byte Length: 1
+var item_type: int
+
+## Byte Type: u16
+## Byte Length: 2
+var amount: int
+
+## Byte Type: u32
+## Byte Length: 4
+var equipped_position: int
+
+## Byte Type: u32
+## Byte Length: 4
+var slot: int
+
+## Byte Type: u32
+## Byte Length: 4
+var hire_expiration_date: int
+
+## Byte Type: u8
+## Byte Length: 1
+var flags: int
+
+
+static func from_bytes(bytes: PackedByteArray):
+ var info = RegularItemInformation.new()
+
+ info.index = bytes.decode_u16(0)
+ info.item_id = bytes.decode_u32(2)
+ info.item_type = bytes.decode_u8(6)
+ info.amount = bytes.decode_u16(7)
+ info.equipped_position = bytes.decode_u32(9)
+ info.slot = bytes.decode_u32(13)
+ info.hire_expiration_date = bytes.decode_u32(17)
+ info.flags = bytes.decode_u8(21)
+
+ return info
+
+
+static func array_from_bytes(bytes: PackedByteArray) -> Array[RegularItemInformation]:
+ var array: Array[RegularItemInformation] = []
+
+ var offset = 0
+ while offset < bytes.size():
+ var chunk = from_bytes(bytes.slice(offset))
+ array.append(chunk)
+ offset += chunk.byte_length
+
+ return array
diff --git a/packets/regular_item_list_packet.gd b/packets/regular_item_list_packet.gd
new file mode 100644
index 0000000..3f64d1f
--- /dev/null
+++ b/packets/regular_item_list_packet.gd
@@ -0,0 +1,32 @@
+## rAthena References:
+## - clif_inventorylist
+## - packet_itemlist_normal
+class_name RegularItemListPacket
+extends Packet
+
+
+const HEADER := 0x0b09
+const BYTE_LENGTH := 0
+
+
+
+## Byte Type: u16
+## Byte Length: 2
+var packet_length: int
+
+## Byte Type: u8
+## Byte Length: 1
+var inventory_type: int
+
+## Byte Type: u8
+var item_information: Array[RegularItemInformation]
+
+
+static func from_bytes(bytes: PackedByteArray) -> RegularItemListPacket:
+ var packet = RegularItemListPacket.new()
+
+ packet.packet_length = bytes.decode_u16(2)
+ packet.inventory_type = bytes.decode_u8(4)
+ packet.item_information = RegularItemInformation.array_from_bytes(bytes.slice(5))
+
+ return packet
diff --git a/packets/sprite_change_packet.gd b/packets/sprite_change_packet.gd
new file mode 100644
index 0000000..af6d934
--- /dev/null
+++ b/packets/sprite_change_packet.gd
@@ -0,0 +1,37 @@
+## rAthena References:
+## - PACKET_ZC_SPRITE_CHANGE
+## - clif_sprite_change
+class_name SpriteChangePacket
+extends Packet
+
+
+const HEADER := 0x01d7
+const BYTE_LENGTH := 15
+
+
+## Byte Type: u32
+## Byte Length: 4
+var account_id: int
+
+## Byte Type: u8
+## Byte Length: 1
+var sprite_type: int
+
+## Byte Type: u32
+## Byte Length: 4
+var value: int
+
+## Byte Type: u32
+## Byte Length: 4
+var value2: int
+
+
+static func from_bytes(bytes: PackedByteArray) -> SpriteChangePacket:
+ var packet = SpriteChangePacket.new()
+
+ packet.account_id = bytes.decode_u32(2)
+ packet.sprite_type = bytes.decode_u32(6)
+ packet.value = bytes.decode_u32(7)
+ packet.value2 = bytes.decode_u32(11)
+
+ return packet