public MainWindow() { var serializer = new TableSerializer(); dynamic table = serializer.Deserialize <Persona5PS3EncounterTable>(@"D:\Modding\Persona 5\Dump\battle\table.pac files\table\ENCOUNT.TBL"); serializer.Serialize(table, @"D:\Modding\Persona 5\Dump\battle\table.pac files\table\ENCOUNT.TBL_"); table = serializer.Deserialize <Persona4.MessageTable>(@"D:\Modding\Persona 3 & 4\Persona4\CVM_BTL\BATTLE\MSG.TBL"); serializer.Serialize(table, @"D:\Modding\Persona 3 & 4\Persona4\CVM_BTL\BATTLE\MSG.TBL_"); InitializeComponent(); }
private static void DeserializeAndSerialize_BinariesShouldBeIdentical_Base <T>(string path, Endianness endianness = Endianness.LittleEndian) { using (var fileStream = File.OpenRead(path)) { var table = TableSerializer.Deserialize <T>(fileStream); using (var memoryStream = new MemoryStream()) { TableSerializer.Serialize(table, memoryStream, endianness); try { using (var test = File.Create("test")) { memoryStream.Position = 0; memoryStream.CopyTo(test); } fileStream.Position = 0; memoryStream.Position = 0; for (int i = 0; i < memoryStream.Length; i++) { Assert.AreEqual(fileStream.ReadByte(), memoryStream.ReadByte(), $"Different byte at {i:X4}"); } } finally { File.Delete("test"); } } } }
private static void RandomizeUnitTable(string tablePath) { var table = TableSerializer.Deserialize <UnitTable>(tablePath); var values = GetTableDistinctValues(table); var unitValues = (Dictionary <string, List <object> >)values[nameof(table.Units)][0]; for (int i = 0; i < table.Units.Length; i++) { ref var unit = ref table.Units[i]; unit.ArcanaId = GetRandom <byte>(unitValues[nameof(unit.ArcanaId)]); unit.Level = GetRandom <byte>(unitValues[nameof(unit.Level)]); unit.Strength = GetRandom <byte>(unitValues[nameof(unit.Strength)]); unit.Magic = GetRandom <byte>(unitValues[nameof(unit.Magic)]); unit.Endurance = GetRandom <byte>(unitValues[nameof(unit.Endurance)]); unit.Agility = GetRandom <byte>(unitValues[nameof(unit.Agility)]); unit.Luck = GetRandom <byte>(unitValues[nameof(unit.Luck)]); for (int j = 0; j < unit.SkillIDs.Length; j++) { unit.SkillIDs[j] = (ushort)Random.Next(0, AtlusTableLib.Persona4.Constants.SKILL_COUNT_REAL - 1); } unit.ExpReward = GetRandom <ushort>(unitValues[nameof(unit.ExpReward)]); unit.YenReward = GetRandom <ushort>(unitValues[nameof(unit.YenReward)]); unit.AttackDamage = GetRandom <ushort>(unitValues[nameof(unit.AttackDamage)]); }
private static void RandomizeAICalculationTableFES(string tablePath) { var table = TableSerializer.Deserialize <AICalculationTableF>(tablePath); table.PlayerAIScript = ScriptRandomizer.RandomizeFlowScript(table.PlayerAIScript); table.BossAIScript = ScriptRandomizer.RandomizeFlowScript(table.BossAIScript); TableSerializer.Serialize(table, tablePath + "_Randomized"); }
public static AnimatedModel Deserialize(GamePlatform p, string data) { AnimatedModel model = new AnimatedModel(); model.nodes = new Node[256]; model.keyframes = new Keyframe[1024]; model.animations = new Animation[128]; AnimatedModelBinding b = new AnimatedModelBinding(); b.p = p; b.m = model; TableSerializer s = new TableSerializer(); s.Deserialize(p, data, b); return(model); }
static void Main(string[] args) { Console.Write("Path to .TBL or folder containing decompiled .txt files: "); string path = Console.ReadLine(); if (File.Exists(path) && Path.GetExtension(path).ToUpper() == ".TBL") { var table = TableSerializer.Deserialize(path, (Game)Enum.Parse(typeof(Game), "Persona5PS3EU")); DumpNameTable(table, Path.GetDirectoryName(path)); } else if (Directory.Exists(path)) { List <string> nameTypes = new List <string> { "ArcanaNames", "SkillNames", "UnitNames", "PersonaNames", "AccessoryNames", "ArmorNames", "ConsumableItemNames", "KeyItemNames", "MaterialNames", "MeleeWeaponNames", "BattleActionNames", "OutfitNames", "SkillCardNames", "ConfidantNames", "PartyMemberLastNames", "PartyMemberFirstNames", "RangedWeaponNames", }; using (FileStream fs = File.Create(Path.Combine(path, "newName.tbl"))) using (EndianBinaryWriter bw = new EndianBinaryWriter(fs, Endianness.BigEndian)) { foreach (string nameType in nameTypes) { int[] tableDataOffsets = UpdateNameTable($"{path}\\{nameType}.txt", out byte[] tableData); //Write size & offsets and pad by 16-byte alignment bw.Write(tableDataOffsets.Count() * 2); byte offsetFiller = 0x00; bw.Write(offsetFiller); bw.Write(offsetFiller); for (int i = 0; i < tableDataOffsets.Count() - 1; i++) { bw.Write(Convert.ToUInt16(tableDataOffsets[i])); } byte[] filler = new byte[AlignmentHelper.GetAlignedDifference(bw.Position, 16)]; bw.Write(filler); //Write size & names and pad by 16-byte alignment bw.Write(tableData.Length); bw.Write(tableData); filler = new byte[AlignmentHelper.GetAlignedDifference(bw.Position, 16)]; bw.Write(filler); } } } }
private static void RandomizeElsaiTable(string tablePath) { string output = tablePath + "_Randomized"; var table = TableSerializer.Deserialize <AtlusTableLib.Persona5.ElsaiTable>(tablePath); var ais = new List <ushort>(); foreach (var ai in table.Segment1) { if (!ais.Contains(ai.AiId)) { ais.Add(ai.AiId); } } for (int i = 0; i < table.Segment1.Length; i++) { ref var ai = ref table.Segment1[i]; ai.AiId = GetRandom(ais); }
public static void Randomize(string path, bool bossRush = false) { string output = path + "_Randomized"; var table = TableSerializer.Deserialize <AtlusTableLib.Persona5.EncounterTable>(path); var encounterTypes = new List <ushort>(); var field02s = new List <ushort>(); var field04s = new List <ushort>(); var field06s = new List <ushort>(); var unitIds = new List <ushort>(); var fieldAndRoomIds = new List <Tuple <ushort, ushort> >(); var musicIds = new List <ushort>(); foreach (var encounter in table.Encounters) { if (!encounterTypes.Contains(encounter.EncounterType)) { encounterTypes.Add(encounter.EncounterType); } if (!field02s.Contains(encounter.Field02)) { field02s.Add(encounter.Field02); } if (!field04s.Contains(encounter.Field04)) { field04s.Add(encounter.Field04); } if (!field06s.Contains(encounter.Field06)) { field06s.Add(encounter.Field06); } for (int i = 0; i < encounter.UnitIDs.Length; i++) { if (!unitIds.Contains(encounter.UnitIDs[i])) { unitIds.Add(encounter.UnitIDs[i]); } } var fieldAndRoomTuple = new Tuple <ushort, ushort>(encounter.FieldId, encounter.RoomId); if (!fieldAndRoomIds.Contains(fieldAndRoomTuple)) { fieldAndRoomIds.Add(fieldAndRoomTuple); } if (!musicIds.Contains(encounter.MusicId)) { musicIds.Add(encounter.MusicId); } } for (int i = 0; i < table.Encounters.Length; i++) { ref var encounter = ref table.Encounters[i]; //encounter.EncounterType = GetRandom(encounterTypes); //encounter.Field02 = GetRandom(field02s); //encounter.Field04 = GetRandom(field04s); //encounter.Field06 = GetRandom(field06s); if (bossRush) { encounter.EncounterType = 0; encounter.Field02 = 0; encounter.Field04 = 0; encounter.Field06 = 0; } /*if (bossRushAlt) * { * for (int j = 0; j < 5; j++) * { * encounter.UnitIDs[j] = 0; * } * * encounter.UnitIDs[0] = (ushort)Random.Next(190, 351); * } * else * {*/ for (int j = 0; j < Random.Next(5); j++) { if (bossRush) { encounter.UnitIDs[j] = (ushort)Random.Next(190, 351); } else { encounter.UnitIDs[j] = GetRandom(unitIds); } } var fieldAndRoomTuple = GetRandom(fieldAndRoomIds); encounter.FieldId = fieldAndRoomTuple.Item1; encounter.RoomId = fieldAndRoomTuple.Item2; encounter.MusicId = GetRandom(musicIds); }
public static AnimatedModel Deserialize(GamePlatform p, string data) { AnimatedModel model = new AnimatedModel(); model.nodes = new Node[256]; model.keyframes = new Keyframe[1024]; model.animations = new Animation[128]; AnimatedModelBinding b = new AnimatedModelBinding(); b.p = p; b.m = model; TableSerializer s = new TableSerializer(); s.Deserialize(p, data, b); return model; }