public Reload convertMBONtoFBReload(Reload reload) { if (reload.game_Ver == Reload.game_ver.FB) { throw new Exception("This reload JSON is already in FB format!"); } List <Reload_FB> reload_FBs = new List <Reload_FB>(); List <Reload_MBON> reload_MBONs = reload.reload_MBON; for (int i = 0; i < reload_MBONs.Count(); i++) { Reload_MBON reload_MBON = reload_MBONs[i]; Reload_FB reload_FB = new Reload_FB(); reload_FB.hash = reload_MBON.hash; reload_FB.ammo_type = reload_MBON.ammo_type; reload_FB.max_ammo = reload_MBON.max_ammo; reload_FB.initial_ammo = reload_MBON.initial_ammo; reload_FB.timed_duration_frame = reload_MBON.timed_duration_frame; reload_FB.unk_0x10 = reload_MBON.unk_0x10; reload_FB.reload_type = reload_MBON.reload_type; reload_FB.cooldown_duration_frame = reload_MBON.cooldown_duration_frame; reload_FB.reload_duration_frame = reload_MBON.reload_duration_frame; reload_FB.assault_burst_reload_duration_frame = reload_MBON.burst_reload_duration_frame; uint ori_burst_reload_duration_frame = reload_MBON.burst_reload_duration_frame; // S burst is usually burst duration frame / 3 OR more strictly, burst_replenish_rate_multiplier. uint S_burst_reload_duration_frame = (uint)(ori_burst_reload_duration_frame / reload_MBON.s_burst_reload_rate_multiplier); // Assign the / 3 value to blast burst reload. reload_FB.blast_burst_reload_duration_frame = S_burst_reload_duration_frame; reload_FB.unk_0x28 = S_burst_reload_duration_frame; reload_FB.unk_0x2C = S_burst_reload_duration_frame; reload_FB.inactive_unk_0x30 = reload_MBON.inactive_unk_0x24; reload_FB.inactive_cooldown_duration_frame = reload_MBON.inactive_cooldown_duration_frame; reload_FB.inactive_reload_duration_frame = reload_MBON.inactive_reload_duration_frame; reload_FB.inactive_assault_burst_reload_duration_frame = reload_MBON.inactive_burst_reload_duration_frame; reload_FB.inactive_blast_burst_reload_duration_frame = S_burst_reload_duration_frame; reload_FB.inactive_unk_0x44 = S_burst_reload_duration_frame; reload_FB.inactive_unk_0x48 = S_burst_reload_duration_frame; reload_FB.burst_replenish = reload_MBON.burst_replenish; reload_FB.unk_0x50 = reload_MBON.unk_0x48; reload_FB.unk_0x54 = reload_MBON.unk_0x4C; reload_FB.unk_0x58 = reload_MBON.unk_0x50; reload_FB.charge_input = reload_MBON.charge_input; reload_FB.charge_duration_frame = reload_MBON.charge_duration_frame; reload_FB.assault_burst_charge_duration_frame = reload_MBON.burst_charge_duration_frame; uint ori_burst_charge_duration_frame = reload_MBON.burst_charge_duration_frame; // S burst is usually burst_charge_duration_frame / 2. uint S_burst_charge_duration_frame = (ori_burst_charge_duration_frame / 2); // Assign the / 2 value to blast burst reload. reload_FB.blast_burst_charge_duration_frame = S_burst_charge_duration_frame; reload_FB.unk_0x6C = S_burst_charge_duration_frame; reload_FB.unk_0x70 = S_burst_charge_duration_frame; reload_FB.release_charge_duration_frame = reload_MBON.release_charge_duration_frame; reload_FB.max_charge_level = reload_MBON.max_charge_level; reload_FB.unk_0x7C = reload_MBON.unk_0x7C; reload_FB.unk_0x80 = reload_MBON.unk_0x80; reload_FBs.Add(reload_FB); } reload.game_Ver = Reload.game_ver.FB; reload.reload_MBON = null; reload.reload_FB = reload_FBs; return(reload); }
public void parse_Reload_MBON() { FileStream fs = File.OpenRead(Properties.Settings.Default.ReloadBinaryFilePath); List <uint> hash_list = new List <uint>(); Reload reload = new Reload(); List <Reload_MBON> reload_MBONs = new List <Reload_MBON>(); reload.game_Ver = Reload.game_ver.MBON; uint magic_hash = readUIntBigEndian(fs); uint unk_0x4 = readUIntBigEndian(fs); // Always 0x22 for some reason uint unit_ID = readUIntBigEndian(fs); reload.magic_hash = magic_hash; reload.unit_ID = unit_ID; uint total_ammo_count = readUIntBigEndian(fs); // Always 3 more than normal ammo, with the last 3 constantly the same. uint real_ammo_count = readUIntBigEndian(fs); // The real ammo count that we care. if (real_ammo_count > 16) { throw new Exception("real ammo count > 16!"); } for (int i = 0; i < 3; i++) { uint is0 = readUIntBigEndian(fs); if (is0 != 0) { throw new Exception("Not 0!"); } } uint hash_pos = (uint)fs.Position; for (int i = 0; i < real_ammo_count; i++) { uint hash = readUIntBigEndian(fs); hash_list.Add(hash); } fs.Seek(hash_pos + 0x40, SeekOrigin.Begin); uint info_pos = (uint)fs.Position + (total_ammo_count * 0x4); for (int i = 0; i < total_ammo_count; i++) { Reload_MBON reload_MBON = new Reload_MBON(); reload_MBON.hash = readUIntBigEndian(fs); uint return_pos = (uint)fs.Position; fs.Seek(info_pos + (i * 0x84), SeekOrigin.Begin); uint ammo_type = readUIntBigEndian(fs); bool isAmmoType = Enum.IsDefined(typeof(ammo_type_enum), (int)ammo_type); if (!isAmmoType && (i < total_ammo_count - 3)) { throw new Exception("Unidentified Ammo Type!"); } reload_MBON.ammo_type = (ammo_type_enum)ammo_type; reload_MBON.max_ammo = readUIntBigEndian(fs); reload_MBON.initial_ammo = readUIntBigEndian(fs); reload_MBON.timed_duration_frame = readUIntBigEndian(fs); reload_MBON.unk_0x10 = readUIntBigEndian(fs); uint reload_type = readUIntBigEndian(fs); bool isReloadType = Enum.IsDefined(typeof(reload_type_enum), (int)reload_type); if (!isReloadType && (i < total_ammo_count - 3)) { throw new Exception("Unidentified Reload Type!"); } reload_MBON.reload_type = (reload_type_enum)reload_type; reload_MBON.cooldown_duration_frame = readUIntBigEndian(fs); reload_MBON.reload_duration_frame = readUIntBigEndian(fs); reload_MBON.burst_reload_duration_frame = readUIntBigEndian(fs); reload_MBON.inactive_unk_0x24 = readUIntBigEndian(fs); reload_MBON.inactive_cooldown_duration_frame = readUIntBigEndian(fs); reload_MBON.inactive_reload_duration_frame = readUIntBigEndian(fs); reload_MBON.inactive_burst_reload_duration_frame = readUIntBigEndian(fs); reload_MBON.burst_replenish = readUIntBigEndian(fs); reload_MBON.s_burst_reload_rate_multiplier = readFloat(fs, true); //if (reload_MBON.unk_0x38 != 3 && (i < total_ammo_count - 3)) //throw new Exception("0x38 not 3!"); reload_MBON.unk_0x3C = readFloat(fs, true); if (reload_MBON.unk_0x3C != 1 && (i < total_ammo_count - 3)) { throw new Exception("0x3C not 1!"); } reload_MBON.unk_0x40 = readFloat(fs, true); //if (reload_MBON.unk_0x40 != 1 && (i < total_ammo_count - 3)) //throw new Exception("0x40 not 1!"); reload_MBON.unk_0x44 = readFloat(fs, true); if (reload_MBON.unk_0x44 != 1 && (i < total_ammo_count - 3)) { throw new Exception("0x44 not 1!"); } reload_MBON.unk_0x48 = readUIntBigEndian(fs); reload_MBON.unk_0x4C = readUIntBigEndian(fs); reload_MBON.unk_0x50 = readUIntBigEndian(fs); reload_MBON.unk_0x54 = readUIntBigEndian(fs); uint charge_input = readUIntBigEndian(fs); bool isChargeInput = Enum.IsDefined(typeof(charge_input_enum), (int)charge_input); //if (!isChargeInput && (i < total_ammo_count - 3)) //throw new Exception("Unidentified Charge Type!"); reload_MBON.charge_input = (charge_input_enum)charge_input; reload_MBON.charge_duration_frame = readUIntBigEndian(fs); reload_MBON.burst_charge_duration_frame = readUIntBigEndian(fs); reload_MBON.release_charge_duration_frame = readUIntBigEndian(fs); reload_MBON.unk_0x68 = readFloat(fs, true); if ((reload_MBON.unk_0x68 != 2 && reload_MBON.unk_0x68 != 0 && reload_MBON.unk_0x68 != 1) && (i < total_ammo_count - 3)) { // 1 - Zeta Gundam, 1270689065 throw new Exception("Unidentified 0x68"); } reload_MBON.unk_0x6C = readFloat(fs, true); if ((reload_MBON.unk_0x6C != 1 && reload_MBON.unk_0x6C != 0) && (i < total_ammo_count - 3)) { throw new Exception("Unidentified 0x6C"); } reload_MBON.unk_0x70 = readFloat(fs, true); if ((reload_MBON.unk_0x70 != 2 && reload_MBON.unk_0x70 != 0 && reload_MBON.unk_0x70 != 4 && reload_MBON.unk_0x70 != 5 && reload_MBON.unk_0x70 != 1) && (i < total_ammo_count - 3)) { // 1 = 00 Gundam, 276112298 // 4 = Char's Gelgoog, 1645609885 // 5 = GP01, 603925848 throw new Exception("Unidentified 0x70"); } reload_MBON.unk_0x74 = readFloat(fs, true); if ((reload_MBON.unk_0x74 != 1 && reload_MBON.unk_0x74 != 0) && (i < total_ammo_count - 3)) { throw new Exception("Unidentified 0x74"); } reload_MBON.max_charge_level = readUIntBigEndian(fs); reload_MBON.unk_0x7C = readUIntBigEndian(fs); reload_MBON.unk_0x80 = readUIntBigEndian(fs); reload_MBONs.Add(reload_MBON); fs.Seek(return_pos, SeekOrigin.Begin); } reload.reload_MBON = reload_MBONs; if (Properties.Settings.Default.convertMBONReload) { reload = convertMBONtoFBReload(reload); } // Save JSON string JSON = JsonConvert.SerializeObject(reload, Formatting.Indented); string fileName = Path.GetFileNameWithoutExtension(Properties.Settings.Default.ReloadBinaryFilePath); string outputPath = Properties.Settings.Default.outputReloadJSONFolderPath + @"\" + fileName + @"_Reload.JSON"; StreamWriter fsJSON = File.CreateText(outputPath); fsJSON.Write(JSON); fsJSON.Close(); }