summaryrefslogtreecommitdiff
path: root/packets/map_server/broadcast_formatted_message_packet.gd
blob: c66c4f1ff4681be1b2bb9012b2870a7a98bc08a6 (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
## rAthena References:
## - clif_broadcast2
class_name BroadcastFormattedMessagePacket
extends Packet


const HEADER := 0x01c3
const BYTE_LENGTH := 0


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

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

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

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

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

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

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

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

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

## Byte Length: variable
var message: String


func get_font_color() -> Color:
	return Color8(
		font_color_r,
		font_color_g,
		font_color_b,
		255
	)


static func from_bytes(bytes: PackedByteArray) -> BroadcastFormattedMessagePacket:
	var packet = BroadcastFormattedMessagePacket.new()
	
	packet.packet_length = bytes.decode_u16(2)
	packet.font_color_r = bytes.decode_u8(4)
	packet.font_color_g = bytes.decode_u8(5)
	packet.font_color_b = bytes.decode_u8(6)
	packet.font_color_a = bytes.decode_u8(7)
	packet.font_type = bytes.decode_u16(8)
	packet.font_size = bytes.decode_u16(10)
	packet.font_alignment = bytes.decode_u16(12)
	packet.font_y = bytes.decode_u16(14)
	packet.message = bytes.slice(16, packet.packet_length).get_string_from_utf8()
	
	return packet