From e8aa9f50886b66d525307a58d71036e6fd3d4aa1 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 28 Nov 2024 18:38:42 +0100 Subject: next commit --- packets/character_information.gd | 246 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 packets/character_information.gd (limited to 'packets/character_information.gd') diff --git a/packets/character_information.gd b/packets/character_information.gd new file mode 100644 index 0000000..20e40cd --- /dev/null +++ b/packets/character_information.gd @@ -0,0 +1,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 -- cgit v1.2.3