summaryrefslogtreecommitdiff
path: root/packets/map_server/moving_entity_appeared_packet.gd
blob: 4ff9a9e615cf64065758664ed97ac871d1a78009 (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
## rAthena References:
## - ZC_NOTIFY_MOVEENTRY11
## - clif_set_unit_walking
class_name MovingEntityAppearedPacket
extends Packet


const HEADER := 0x09fd
const BYTE_LENGTH := 0


## Byte Type: u16
## Byte Length: 2
var packet_length: int

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

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

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

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

## Byte Type: u16
## Byte Length: 2
var body_state: int

## Byte Type: u16
## Byte Length: 2
var health_state: int

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

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

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

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

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

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

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

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

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

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

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

## Byte Type: u16
## Byte Length: 2
var head_direction: int

## Byte Type: u16
## Byte Length: 2
var robe: int

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

## Byte Type: u16
## Byte Length: 2
var emblem_version: int

## Byte Type: u16
## Byte Length: 2
var honor: int

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

## Byte Type: u8
## Byte Length: 1
var is_pk_mode_on: bool

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

## Byte Type: u8
## Byte Length: 6
var position: PackedByteArray

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

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

## Byte Type: u16
## Byte Length: 2
var c_level: int

## Byte Type: u16
## Byte Length: 2
var font: int

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

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

## Byte Type: u8
## Byte Length: 1
var is_boss: bool

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

## Byte Length: 24
var name: String


func get_size() -> Vector2:
	return Vector2(
		size_x,
		size_y
	)


static func from_bytes(pbytes: PackedByteArray) -> MovingEntityAppearedPacket:
	var bytes := ByteStream.from_bytes(pbytes)
	
	var packet = MovingEntityAppearedPacket.new()
	
	bytes.advance(2) # skip header
	
	packet.packet_length = bytes.decode_u16()
	packet.object_type = bytes.decode_u8()
	packet.entity_id = bytes.decode_u32()
	packet.group_id = bytes.decode_u32()
	packet.movement_speed = bytes.decode_u16()
	packet.body_state = bytes.decode_u16()
	packet.health_state = bytes.decode_u16()
	packet.effect_state = bytes.decode_u32()
	packet.job = bytes.decode_u16()
	packet.head = bytes.decode_u16()
	packet.weapon = bytes.decode_u32()
	packet.shield = bytes.decode_u32()
	packet.accessory = bytes.decode_u16()
	packet.move_start_time = bytes.decode_u32()
	packet.accessory2 = bytes.decode_u16()
	packet.accessory3 = bytes.decode_u16()
	packet.head_palette = bytes.decode_u16()
	packet.body_palette = bytes.decode_u16()
	packet.head_direction = bytes.decode_u16()
	packet.robe = bytes.decode_u16()
	packet.guild_id = bytes.decode_u32()
	packet.emblem_version = bytes.decode_u16()
	packet.honor = bytes.decode_u16()
	packet.virtue = bytes.decode_u32()
	packet.is_pk_mode_on = bytes.decode_u8()
	packet.gender = bytes.decode_u8()
	packet.position = bytes.get_buffer(6).bytes
	packet.size_x = bytes.decode_u8()
	packet.size_y = bytes.decode_u8()
	packet.c_level = bytes.decode_u16()
	packet.font = bytes.decode_u16()
	packet.maximum_health_points = bytes.decode_s32()
	packet.health_points = bytes.decode_s32()
	packet.is_boss = bytes.decode_u8()
	packet.body = bytes.decode_u16()
	packet.name = bytes.get_string_from_utf8(24)
	
	return packet