summaryrefslogtreecommitdiff
path: root/packets/map_server/navigate_to_target_packet.gd
blob: c41847031a032bc333a09542dab20a2edf3d3c25 (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
## rAthena References:
## - clif_navigateTo
class_name NavigateToTargetPacket
extends Packet


const HEADER := 0x08e2
const BYTE_LENGTH := 27


## Byte Type: u8 [br]
## Byte Length: 1 [br]
## 0: Coordinates [br]
## 1: Coordinates - but fails if you're already on the map [br]
## 3: Monster
var target_type: int

## Byte Type: u8 [br]
## Byte Length: 1
var flags: int

## Byte Type: u8 [br]
## Byte Length: 1
var hide_window: int

## Byte Type: u8 [br]
## Byte Length: 16
var map_name: String

## Byte Type: u16 [br]
## Byte Length: 2
var target_position_x: int

## Byte Type: u16 [br]
## Byte Length: 2
var target_position_y: int

## Byte Type: u16 [br]
## Byte Length: 2
var target_monster_id: int


func get_target_position() -> Vector2:
	return Vector2(target_position_x, target_position_y)


static func from_bytes(bytes: PackedByteArray) -> NavigateToTargetPacket:
	var packet = NavigateToTargetPacket.new()
	
	packet.target_type = bytes.decode_u8(2)
	packet.flags = bytes.decode_u8(3)
	packet.hide_window = bytes.decode_u8(4)
	packet.map_name = bytes.slice(5, 5 + 16).get_string_from_utf8()
	packet.target_position_x = bytes.decode_u16(21)
	packet.target_position_y = bytes.decode_u16(23)
	packet.target_monster_id = bytes.decode_u16(25)
	
	return packet