summaryrefslogtreecommitdiff
path: root/packets/equippable_item_information.gd
blob: 517297b534fc54d87671187c7ad3158f041c84c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
## 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 * 4
var slot: PackedByteArray

## 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: ByteStream):
	var info = EquippableItemInformation.new()
	
	info.index = bytes.decode_u16()
	info.item_id = bytes.decode_u32()
	info.item_type = bytes.decode_u8()
	info.equipped_position = bytes.decode_u32()
	info.equipped_position = bytes.decode_u32()
	info.slot = bytes.get_buffer(4 * 4).bytes
	info.hire_expiration_date = bytes.decode_u32()
	info.bind_on_equip_type = bytes.decode_u16()
	info.w_item_sprite_number = bytes.decode_u16()
	info.option_count = bytes.decode_u8()
	info.option_data = ItemOption.array_from_bytes(
		bytes.get_buffer(5 * ItemOption.BYTE_LENGTH)
	)
	info.refinement_level = bytes.decode_u8()
	info.enchantment_level = bytes.decode_u8()
	info.flags = bytes.decode_u8()
	
	return info


static func array_from_bytes(bytes: ByteStream) -> Array[EquippableItemInformation]:
	var array: Array[EquippableItemInformation] = []
	
	while bytes.available() > 0:
		var chunk = from_bytes(bytes)
		array.append(chunk)
	
	return array