summaryrefslogtreecommitdiff
path: root/packets/character_information.gd
blob: 20e40cd77020df131b97c79811ef245400fa7f82 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
class_name CharacterInformation
extends PacketChunk


## Byte Type: u32
## Byte Length: 4
var character_id: int

## Byte Type: i64
## Byte Length: 8
var experience: int

## Byte Type: i32
## Byte Length: 4
var money: int

## Byte Type: i64
## Byte Length: 8
var job_experience: int

## Byte Type: i32
## Byte Length: 4
var job_level: int

## Byte Type: i32
## Byte Length: 4
var body_state: int

## Byte Type: i32
## Byte Length: 4
var health_state: int

## Byte Type: i32
## Byte Length: 4
var effect_state: int

## Byte Type: i32
## Byte Length: 4
var virtue: int

## Byte Type: i32
## Byte Length: 4
var honor: int

## Byte Type: i16
## Byte Length: 2
var jobpoint: int

## Byte Type: i64
## Byte Length: 8
var health_points: int

## Byte Type: i64
## Byte Length: 8
var maximum_health_points: int

## Byte Type: i64
## Byte Length: 8
var spell_points: int

## Byte Type: i64
## Byte Length: 8
var maximum_spell_points: int

## Byte Type: i16
## Byte Length: 2
var movement_speed: int

## Byte Type: i16
## Byte Length: 2
var job: int

## Byte Type: i16
## Byte Length: 2
var head: int

## Byte Type: i16
## Byte Length: 2
var body: int

## Byte Type: i16
## Byte Length: 2
var weapon: int

## Byte Type: i16
## Byte Length: 2
var level: int

## Byte Type: i16
## Byte Length: 2
var skill_point: int

## Byte Type: i16
## Byte Length: 2
var accessory: int

## Byte Type: i16
## Byte Length: 2
var shield: int

## Byte Type: i16
## Byte Length: 2
var accessory2: int

## Byte Type: i16
## Byte Length: 2
var accessory3: int

## Byte Type: i16
## Byte Length: 2
var head_palette: int

## Byte Type: i16
## Byte Length: 2
var body_palette: int

## Byte Type: u8
## Byte Length: 24
var name: String

## Byte Type: u8
## Byte Length: 1
var strength: int

## Byte Type: u8
## Byte Length: 1
var agility: int

## Byte Type: u8
## Byte Length: 1
var vitality: int

## Byte Type: u8
## Byte Length: 1
var intelligence: int

## Byte Type: u8
## Byte Length: 1
var dexterity: int

## Byte Type: u8
## Byte Length: 1
var luck: int

## Byte Type: u8
## Byte Length: 1
var character_number: int

## Byte Type: u8
## Byte Length: 1
var hair_color: int

## Byte Type: i16
## Byte Length: 2
var b_is_changed_char: int

## Byte Type: u8
## Byte Length: 16
var map_name: String

## Byte Type: i32
## Byte Length: 4
var deletion_reverse_date: int

## Byte Type: i32
## Byte Length: 4
var robe_palette: int

## Byte Type: i32
## Byte Length: 4
var character_slot_change: int

## Byte Type: i32
## Byte Length: 4
var character_name_change: int

## Byte Type: u8
## Byte Length: 1
var gender: Constants.Gender


func _init() -> void:
	byte_length = 175


static func from_bytes(bytes: PackedByteArray):
	var info = CharacterInformation.new()
	
	info.character_id = bytes.decode_u32(0)
	info.experience = bytes.decode_s64(4)
	info.money = bytes.decode_s32(12)
	info.job_experience = bytes.decode_s64(16)
	info.job_level = bytes.decode_s32(24)
	info.body_state = bytes.decode_s32(28)
	info.health_state = bytes.decode_s32(32)
	info.effect_state = bytes.decode_s32(36)
	info.virtue = bytes.decode_s32(40)
	info.honor = bytes.decode_s32(44)
	info.jobpoint = bytes.decode_s16(48)
	info.health_points = bytes.decode_s64(50)
	info.maximum_health_points = bytes.decode_s64(58)
	info.spell_points = bytes.decode_s64(66)
	info.maximum_spell_points = bytes.decode_s64(74)
	info.movement_speed = bytes.decode_s16(82)
	info.job = bytes.decode_s16(84)
	info.head = bytes.decode_s16(86)
	info.body = bytes.decode_s16(88)
	info.weapon = bytes.decode_s16(90)
	info.level = bytes.decode_s16(92)
	info.skill_point = bytes.decode_s16(94)
	info.accessory = bytes.decode_s16(96)
	info.shield = bytes.decode_s16(98)
	info.accessory2 = bytes.decode_s16(100)
	info.accessory3 = bytes.decode_s16(102)
	info.head_palette = bytes.decode_s16(104)
	info.body_palette = bytes.decode_s16(106)
	info.name = bytes.slice(108, 108 + 24).get_string_from_utf8()
	info.strength = bytes.decode_u8(132)
	info.agility = bytes.decode_u8(133)
	info.vitality = bytes.decode_u8(134)
	info.intelligence = bytes.decode_u8(135)
	info.dexterity = bytes.decode_u8(136)
	info.luck = bytes.decode_u8(137)
	info.character_number = bytes.decode_u8(138)
	info.hair_color = bytes.decode_u8(139)
	info.b_is_changed_char = bytes.decode_s16(140)
	info.map_name = bytes.slice(142, 142 + 16).get_string_from_utf8()
	info.deletion_reverse_date = bytes.decode_s32(158)
	info.robe_palette = bytes.decode_s32(162)
	info.character_slot_change = bytes.decode_s32(166)
	info.character_name_change = bytes.decode_s32(170)
	info.gender = bytes.decode_u8(174)
	
	return info


static func array_from_bytes(bytes: PackedByteArray) -> Array:
	var array = []
	
	var offset = 0
	while offset < bytes.size():
		var chunk = from_bytes(bytes.slice(offset))
		array.append(chunk)
		offset += chunk.byte_length
	
	return array