diff options
Diffstat (limited to 'packets')
-rw-r--r-- | packets/achievement_data.gd | 50 | ||||
-rw-r--r-- | packets/achievement_list_packet.gd | 48 | ||||
-rw-r--r-- | packets/achievement_update_packet.gd | 39 | ||||
-rw-r--r-- | packets/change_map_packet.gd | 35 | ||||
-rw-r--r-- | packets/character_selection_failed_packet.gd | 19 | ||||
-rw-r--r-- | packets/character_server_keep_alive_packet.gd | 22 | ||||
-rw-r--r-- | packets/friend.gd | 40 | ||||
-rw-r--r-- | packets/friend_list_packet.gd | 23 | ||||
-rw-r--r-- | packets/login_server_keep_alive_packet.gd | 22 | ||||
-rw-r--r-- | packets/map_server_login_success_packet.gd | 4 | ||||
-rw-r--r-- | packets/send_chat_message_packet.gd | 26 | ||||
-rw-r--r-- | packets/server_message_packet.gd | 25 | ||||
-rw-r--r-- | packets/update_critical_weight_packet.gd | 19 |
13 files changed, 370 insertions, 2 deletions
diff --git a/packets/achievement_data.gd b/packets/achievement_data.gd new file mode 100644 index 0000000..a26633f --- /dev/null +++ b/packets/achievement_data.gd @@ -0,0 +1,50 @@ +class_name AchievementData +extends PacketChunk + + +const BYTE_LENGTH := 50 + + +## Byte Type: u32 +## Byte Length: 4 +var achievement_id: int + +## Byte Type: u8 +## Byte Length: 1 +var is_completed: bool + +## Byte Type: u32 +## Byte Length: 4 * 10 +var objectives: PackedByteArray + +## Byte Type: u32 +## Byte Length: 4 +var completion_timestamp: int + +## Byte Type: u8 +## Byte Length: 1 +var got_rewarded: bool + + +static func from_bytes(bytes: PackedByteArray) -> AchievementData: + var achievement_data = AchievementData.new() + + achievement_data.achievement_id = bytes.decode_u32(0) + achievement_data.is_completed = bytes.decode_u8(4) + achievement_data.objectives = bytes.slice(5, 5 + 40) + achievement_data.completion_timestamp = bytes.decode_u32(45) + achievement_data.got_rewarded = bytes.decode_u8(49) + + return achievement_data + + +static func array_from_bytes(bytes: PackedByteArray) -> Array[AchievementData]: + var array: Array[AchievementData] = [] + + var offset = 0 + while offset < bytes.size(): + var chunk = from_bytes(bytes.slice(offset)) + array.append(chunk) + offset += chunk.byte_length + + return array diff --git a/packets/achievement_list_packet.gd b/packets/achievement_list_packet.gd new file mode 100644 index 0000000..ed09184 --- /dev/null +++ b/packets/achievement_list_packet.gd @@ -0,0 +1,48 @@ +## rAthena References: +## - ZC_ALL_ACH_LIST +class_name AchievementListPacket +extends Packet + + +const HEADER := 0x0a23 +const BYTE_LENGTH := 0 + + +## Byte Type: u16 +## Byte Length: 2 +var packet_length: int + +## Byte Type: u32 +## Byte Length: 4 +var achievement_count: int + +## Byte Type: u32 +## Byte Length: 4 +var total_score: int + +## Byte Type: u16 +## Byte Length: 2 +var level: int + +## Byte Type: u32 +## Byte Length: 4 +var achievement_experience: int + +## Byte Type: u32 +## Byte Length: 4 +var achievement_experience_to_next_level: int + +var achievement_data: Array[AchievementData] + + +static func from_bytes(bytes: PackedByteArray) -> AchievementListPacket: + var packet = AchievementListPacket.new() + + packet.achievement_count = bytes.decode_u32(4) + packet.total_score = bytes.decode_u32(8) + packet.level = bytes.decode_u16(12) + packet.achievement_experience = bytes.decode_u32(14) + packet.achievement_experience_to_next_level = bytes.decode_u32(18) + packet.achievement_data = AchievementData.array_from_bytes(bytes.slice(22)) + + return packet diff --git a/packets/achievement_update_packet.gd b/packets/achievement_update_packet.gd new file mode 100644 index 0000000..9b33273 --- /dev/null +++ b/packets/achievement_update_packet.gd @@ -0,0 +1,39 @@ +## rAthena References: +## - ZC_ACH_UPDATE +class_name AchievementUpdatePacket +extends Packet + + +const HEADER := 0x0a24 +const BYTE_LENGTH := 66 + + +## Byte Type: u32 +## Byte Length: 4 +var total_score: int + +## Byte Type: u16 +## Byte Length: 2 +var level: int + +## Byte Type: u32 +## Byte Length: 4 +var achievement_experience: int + +## Byte Type: u32 +## Byte Length: 4 +var achievement_experience_to_next_level: int + +var achievement_data: AchievementData + + +static func from_bytes(bytes: PackedByteArray) -> AchievementUpdatePacket: + var packet = AchievementUpdatePacket.new() + + packet.total_score = bytes.decode_u32(2) + packet.level = bytes.decode_u16(6) + packet.achievement_experience = bytes.decode_u32(8) + packet.achievement_experience_to_next_level = bytes.decode_u32(12) + packet.achievement_data = AchievementData.from_bytes(bytes.slice(16)) + + return packet diff --git a/packets/change_map_packet.gd b/packets/change_map_packet.gd new file mode 100644 index 0000000..beee821 --- /dev/null +++ b/packets/change_map_packet.gd @@ -0,0 +1,35 @@ +## rAthena References: +## - ZC_NPCACK_MAPMOVE +class_name ChangeMapPacket +extends Packet + + +const HEADER := 0x0091 +const BYTE_LENGTH := 22 + + +## Byte Type: u8 +## Byte Length: 16 +var map_name: String + +## Byte Type: u16 +## Byte Length: 2 +var position_x: int + +## Byte Type: u16 +## Byte Length: 2 +var position_y: int + + +func get_position() -> Vector2: + return Vector2(position_x, position_y) + + +static func from_bytes(bytes: PackedByteArray): + var packet = ChangeMapPacket.new() + + packet.map_name = bytes.slice(2, 2 + 16).get_string_from_utf8() + packet.position_x = bytes.decode_u16(18) + packet.position_x = bytes.decode_u16(20) + + return packet diff --git a/packets/character_selection_failed_packet.gd b/packets/character_selection_failed_packet.gd new file mode 100644 index 0000000..5f6cb8a --- /dev/null +++ b/packets/character_selection_failed_packet.gd @@ -0,0 +1,19 @@ +class_name CharacterSelectionFailedPacket +extends Packet + + +const HEADER := 0x006c +const BYTE_LENGTH := 3 + + +## Byte Type: u8 +## Byte Length: 1 +var reason: int + + +static func from_bytes(bytes: PackedByteArray): + var packet = CharacterSelectionFailedPacket.new() + + packet.reason = bytes.decode_u8(2) + + return packet diff --git a/packets/character_server_keep_alive_packet.gd b/packets/character_server_keep_alive_packet.gd new file mode 100644 index 0000000..81f918c --- /dev/null +++ b/packets/character_server_keep_alive_packet.gd @@ -0,0 +1,22 @@ +## rAthena References: +class_name CharacterServerKeepAlivePacket +extends Packet + + +const HEADER := 0x0187 +const BYTE_LENGTH := 6 + + +## Byte Type: u32 +## Byte Length: 4 +var account_id: int + + +func to_bytes(): + var payload = PackedByteArray([]) + payload.resize(4) + + # rAthena never reads this value, so just set it to 0 + payload.encode_u32(0, 0) + + return get_header() + payload diff --git a/packets/friend.gd b/packets/friend.gd new file mode 100644 index 0000000..70120fe --- /dev/null +++ b/packets/friend.gd @@ -0,0 +1,40 @@ +class_name Friend +extends PacketChunk + + +const BYTE_LENGTH := 32 + + +## Byte Type: u32 +## Byte Length: 4 +var account_id: int + +## Byte Type: u32 +## Byte Length: 4 +var character_id: int + +## Byte Type: u8 +## Byte Length: 24 +var name: String + + +static func from_bytes(bytes: PackedByteArray): + var quest = Friend.new() + + quest.account_id = bytes.decode_u32(0) + quest.character_id = bytes.decode_u32(4) + quest.name = bytes.slice(8, 8 + 24).get_string_from_utf8() + + return quest + + +static func array_from_bytes(bytes: PackedByteArray) -> Array[Friend]: + var array: Array[Friend] = [] + + var offset = 0 + while offset < bytes.size(): + var chunk = from_bytes(bytes.slice(offset)) + array.append(chunk) + offset += chunk.byte_length + + return array diff --git a/packets/friend_list_packet.gd b/packets/friend_list_packet.gd new file mode 100644 index 0000000..ab419f5 --- /dev/null +++ b/packets/friend_list_packet.gd @@ -0,0 +1,23 @@ +## rAthena References: +## - ZC_FRIENDS_LIST +class_name FriendListPacket +extends Packet + + +const HEADER := 0x0201 +const BYTE_LENGTH := 0 + + +## Byte Type: u16 +## Byte Length: 2 +var packet_length: int + +var friends: Array[Friend] + + +static func from_bytes(bytes: PackedByteArray): + var packet = FriendListPacket.new() + + packet.friends = Friend.array_from_bytes(bytes.slice(4)) + + return packet diff --git a/packets/login_server_keep_alive_packet.gd b/packets/login_server_keep_alive_packet.gd new file mode 100644 index 0000000..db0eedb --- /dev/null +++ b/packets/login_server_keep_alive_packet.gd @@ -0,0 +1,22 @@ +## rAthena References: +## - CA_CONNECT_INFO_CHANGED ? +class_name LoginServerKeepAlivePacket +extends Packet + + +const HEADER := 0x0200 +const BYTE_LENGTH := 26 + + +## Byte Type: u8 +## Byte Length: 24 +var user_name: String + + +func to_bytes(): + var payload = PackedByteArray([]) + + payload += user_name.to_utf8_buffer() + payload.resize(BYTE_LENGTH - 2) + + return get_header() + payload diff --git a/packets/map_server_login_success_packet.gd b/packets/map_server_login_success_packet.gd index a6cbdae..9b70428 100644 --- a/packets/map_server_login_success_packet.gd +++ b/packets/map_server_login_success_packet.gd @@ -6,7 +6,7 @@ extends Packet const HEADER := 0x02eb -const BYTE_LENGTH := 14 +const BYTE_LENGTH := 13 ## Byte Type: u32 @@ -46,6 +46,6 @@ static func from_bytes(bytes: PackedByteArray): packet.position = bytes.slice(6, 6 + 3) packet.ignored = bytes.slice(9, 9 + 2) packet.font = bytes.decode_u16(11) - packet.gender = bytes.decode_u8(13) + #packet.gender = bytes.decode_u8(13) return packet diff --git a/packets/send_chat_message_packet.gd b/packets/send_chat_message_packet.gd new file mode 100644 index 0000000..6bb6b14 --- /dev/null +++ b/packets/send_chat_message_packet.gd @@ -0,0 +1,26 @@ +## rAthena References: +## - +class_name SendChatMessagePacket +extends Packet + + +const HEADER := 0x00f3 +const BYTE_LENGTH := 0 + + +## Byte Type: u16 +## Byte Length: 2 +var packet_length: int + +## Byte Type: u8 +## Byte Length: variable +var message: String + + +func to_bytes(): + var payload = PackedByteArray([]) + + payload = message.to_utf8_buffer() + PackedByteArray([0]) + print(message) + print(get_header(4 + payload.size()) + payload) + return get_header(4 + payload.size()) + payload diff --git a/packets/server_message_packet.gd b/packets/server_message_packet.gd new file mode 100644 index 0000000..9b8d846 --- /dev/null +++ b/packets/server_message_packet.gd @@ -0,0 +1,25 @@ +## rAthena References: +## - clif_displaymessage +class_name ServerMessagePacket +extends Packet + + +const HEADER := 0x008e +const BYTE_LENGTH := 0 + + +## Byte Type: u16 +## Byte Length: 2 +var packet_length: int + +## Byte Type: u8 +## Byte Length: variable +var message: String + + +static func from_bytes(bytes: PackedByteArray): + var packet = ServerMessagePacket.new() + + packet.message = bytes.slice(4).get_string_from_utf8() + + return packet diff --git a/packets/update_critical_weight_packet.gd b/packets/update_critical_weight_packet.gd new file mode 100644 index 0000000..03fb273 --- /dev/null +++ b/packets/update_critical_weight_packet.gd @@ -0,0 +1,19 @@ +class_name UpdateCriticalWeightPacket +extends Packet + + +const HEADER := 0x0ade +const BYTE_LENGTH := 6 + + +## Byte Type: u32 +## Byte Length: 4 +var weight: int + + +static func from_bytes(bytes: PackedByteArray) -> UpdateCriticalWeightPacket: + var packet = UpdateCriticalWeightPacket.new() + + packet.weight = bytes.decode_u32(2) + + return packet |