From cf1f4693c07913c10c0d90a7aa8de16d3099071c Mon Sep 17 00:00:00 2001 From: Ted John Date: Sat, 17 Feb 2024 21:30:07 +0000 Subject: [PATCH] RE CV, add residence rooms to door rando --- IntelOrca.Biohazard.BioRand/Map.cs | 1 + .../RECV/ReCvDoorHelper.cs | 43 +++--- .../RECV/ReCvRandomiser.cs | 11 +- IntelOrca.Biohazard.BioRand/Rdt.cs | 4 + .../data/recv/rdt.json | 132 +++++++++++++++--- 5 files changed, 148 insertions(+), 43 deletions(-) diff --git a/IntelOrca.Biohazard.BioRand/Map.cs b/IntelOrca.Biohazard.BioRand/Map.cs index 83cfd3ae..7163977d 100644 --- a/IntelOrca.Biohazard.BioRand/Map.cs +++ b/IntelOrca.Biohazard.BioRand/Map.cs @@ -91,6 +91,7 @@ public class MapRoomDoor public int Texture { get; set; } public int? Special { get; set; } public int? Id { get; set; } + public int? AltId { get; set; } public JsonElement[]? Offsets { get; set; } public byte? Cut { get; set; } public MapRoomDoorEntrance? Entrance { get; set; } diff --git a/IntelOrca.Biohazard.BioRand/RECV/ReCvDoorHelper.cs b/IntelOrca.Biohazard.BioRand/RECV/ReCvDoorHelper.cs index 9df9bebf..c961b1b4 100644 --- a/IntelOrca.Biohazard.BioRand/RECV/ReCvDoorHelper.cs +++ b/IntelOrca.Biohazard.BioRand/RECV/ReCvDoorHelper.cs @@ -16,27 +16,32 @@ public void Begin(RandoConfig config, GameData gameData, Map map) Nop(gameData, RdtId.Parse("1000"), 0x18CD74); Nop(gameData, RdtId.Parse("1000"), 0x18DB7C); - // Force version of 102 and 103 where you can get briefcase and use medal - Nop(gameData, RdtId.Parse("1010"), 0x3EF2C); // Force RDT1021 to load - Nop(gameData, RdtId.Parse("1010"), 0x3EF38, 0x3EF4C); // Force RDT1021 to load - Nop(gameData, RdtId.Parse("1010"), 0x3EF50, 0x3EF5A); // Force RDT1021 to load - Nop(gameData, RdtId.Parse("1050"), 0x1DF2AA, 0x1DF2BE); // Force RDT1031 to load - Nop(gameData, RdtId.Parse("1050"), 0x1DF2C2, 0x1DF2CC); // Force RDT1031 to load - // OverrideDoor(gameData, RdtId.Parse("1030"), 1, RdtId.Parse("1021"), 1); + if (!config.RandomDoors) + { + // Force version of 102 and 103 where you can get briefcase and use medal + Nop(gameData, RdtId.Parse("1010"), 0x3EF2C); // Force RDT1021 to load + Nop(gameData, RdtId.Parse("1010"), 0x3EF38, 0x3EF4C); // Force RDT1021 to load + Nop(gameData, RdtId.Parse("1010"), 0x3EF50, 0x3EF5A); // Force RDT1021 to load + Nop(gameData, RdtId.Parse("1050"), 0x1DF2AA, 0x1DF2BE); // Force RDT1031 to load + Nop(gameData, RdtId.Parse("1050"), 0x1DF2C2, 0x1DF2CC); // Force RDT1031 to load + } // Force window cutscene on item interaction Nop(gameData, RdtId.Parse("1070"), 0x1819AE); - // Delete Steve/Alfred cutscene - Nop(gameData, RdtId.Parse("3050"), 0x15F288, 0x15F2DA); - Nop(gameData, RdtId.Parse("3050"), 0x15EEDC, 0x15EEF6); + if (!config.RandomDoors) + { + // Delete Steve/Alfred cutscene + Nop(gameData, RdtId.Parse("3050"), 0x15F288, 0x15F2DA); + Nop(gameData, RdtId.Parse("3050"), 0x15EEDC, 0x15EEF6); - // Softlock can occur if you enter 305 via ladder without picking up silver key - Patch(gameData, RdtId.Parse("3060"), 0x70A10 + 6, 0x00); + // Softlock can occur if you enter 305 via ladder without picking up silver key + Patch(gameData, RdtId.Parse("3060"), 0x70A10 + 6, 0x00); - // Change condition for going into 4011 so that it happens straight after Alfred cutscene - Patch(gameData, RdtId.Parse("4080"), 0x9F86C + 2, 0xC5); - Patch(gameData, RdtId.Parse("40F0"), 0x7241C + 2, 0xC5); + // Change condition for going into 4011 so that it happens straight after Alfred cutscene + Patch(gameData, RdtId.Parse("4080"), 0x9F86C + 2, 0xC5); + Patch(gameData, RdtId.Parse("40F0"), 0x7241C + 2, 0xC5); + } // Force Steve to appear at airport Nop(gameData, RdtId.Parse("5000"), 0x187778, 0x18777A); @@ -53,6 +58,10 @@ public void Begin(RandoConfig config, GameData gameData, Map map) } } + public void End(RandoConfig config, GameData gameData, Map map) + { + } + private void SetFlag(GameData gameData, RdtId rtdId, byte kind, int index, byte value) { var rrdt = gameData.GetRdt(rtdId); @@ -88,9 +97,5 @@ public void Patch(GameData gameData, RdtId rtdId, int offset, byte value) rrdt.Patches.Add(new KeyValuePair(offset, value)); } - - public void End(RandoConfig config, GameData gameData, Map map) - { - } } } diff --git a/IntelOrca.Biohazard.BioRand/RECV/ReCvRandomiser.cs b/IntelOrca.Biohazard.BioRand/RECV/ReCvRandomiser.cs index 2a681f45..82d06b0d 100644 --- a/IntelOrca.Biohazard.BioRand/RECV/ReCvRandomiser.cs +++ b/IntelOrca.Biohazard.BioRand/RECV/ReCvRandomiser.cs @@ -13,6 +13,7 @@ namespace IntelOrca.Biohazard.BioRand.RECV public class ReCvRandomiser : BaseRandomiser { private AfsFile? _rdxAfs; + private AfsFile? _systemAfs; private RandomizedRdt[] _rdts = new RandomizedRdt[205]; private byte[] _elf = new byte[0]; @@ -129,20 +130,20 @@ public override void Generate(RandoConfig config, IRandoProgress progress, FileR UdfEditor? udfEditor = null; try { - FileIdentifier? afsFileId; + FileIdentifier? rdxAfsFileId; FileIdentifier? elfFileId; using (progress.BeginTask(null, "Reading ISO file")) { udfEditor = new Ps2IsoTools.UDF.UdfEditor(input, output); - afsFileId = udfEditor.GetFileByName("RDX_LNK.AFS"); - if (afsFileId == null) + rdxAfsFileId = udfEditor.GetFileByName("RDX_LNK.AFS"); + if (rdxAfsFileId == null) throw new BioRandUserException("RDX_LNK.AFS not found in ISO"); elfFileId = udfEditor.GetFileByName("SLUS_201.84"); if (elfFileId == null) throw new BioRandUserException("SLUS_201.84 not found in ISO"); - _rdxAfs = ReadRdxAfs(udfEditor, afsFileId); + _rdxAfs = ReadRdxAfs(udfEditor, rdxAfsFileId); _elf = ReadFile(udfEditor, elfFileId); } @@ -172,7 +173,7 @@ public override void Generate(RandoConfig config, IRandoProgress progress, FileR using (progress.BeginTask(null, "Creating ISO file")) { - udfEditor.ReplaceFileStream(afsFileId, new MemoryStream(_rdxAfs!.Data.ToArray())); + udfEditor.ReplaceFileStream(rdxAfsFileId, new MemoryStream(_rdxAfs!.Data.ToArray())); udfEditor.ReplaceFileStream(elfFileId, new MemoryStream(_elf)); udfEditor.Rebuild(output); } diff --git a/IntelOrca.Biohazard.BioRand/Rdt.cs b/IntelOrca.Biohazard.BioRand/Rdt.cs index ea4b3f65..23c2701b 100644 --- a/IntelOrca.Biohazard.BioRand/Rdt.cs +++ b/IntelOrca.Biohazard.BioRand/Rdt.cs @@ -76,6 +76,10 @@ internal void SetDoorTarget(PlayEdge edge, RdtId target, DoorEntrance destinatio if (offsets.Length == 0) { OverrideDoor(id, target, (byte)destination.Id!.Value); + if (edge.Raw.AltId is int altId) + { + OverrideDoor(altId, target, (byte)destination.Id!.Value); + } } } else diff --git a/IntelOrca.Biohazard.BioRand/data/recv/rdt.json b/IntelOrca.Biohazard.BioRand/data/recv/rdt.json index 34200271..59c1edab 100644 --- a/IntelOrca.Biohazard.BioRand/data/recv/rdt.json +++ b/IntelOrca.Biohazard.BioRand/data/recv/rdt.json @@ -676,7 +676,7 @@ { "id": 0, "target": "2020", - "entranceId": 2 + "entranceId": 0 }, { "id": 2, @@ -686,7 +686,7 @@ { "id": 1, "target": "20C0", - "entranceId": 0 + "entranceId": 2 } ], "items": [ @@ -1052,7 +1052,7 @@ "20C0": { "doorRando": [ { - "nop": [ "0x1580B4-0x158142" ] + "nop": [ "0x1580B4-0x1580D8", "0x1580FE-0x158142" ] } ], "doors": [ @@ -1063,7 +1063,8 @@ }, { "id": 2, - "target": "2000" + "target": "2000", + "entranceId": 0 }, { "id": 1, @@ -1137,12 +1138,21 @@ ] }, "3000": { + "doorRando": [ + { + "nop": [ "0x14F1E6-0x14F26E" ] + } + ], "doors": [ { - "target": "20A0" + "id": 0, + "target": "20A0", + "entranceId": 0 }, { - "target": "3010" + "id": 3, + "target": "3010", + "entranceId": 1 } ], "items": [ @@ -1155,15 +1165,26 @@ ] }, "3010": { + "doorRando": [ + { + "nop": [ "0x8E668-0x8E6C8" ] + } + ], "doors": [ { - "target": "3000" + "id": 1, + "target": "3000", + "entranceId": 0 }, { - "target": "3020" + "id": 2, + "target": "3020", + "entranceId": 1 }, { - "target": "3030" + "id": 6, + "target": "3030", + "entranceId": 2 } ], "items": [ @@ -1182,9 +1203,16 @@ ] }, "3020": { + "doorRando": [ + { + "nop": [ "0x12902E-0x129056" ] + } + ], "doors": [ { - "target": "3010" + "id": 0, + "target": "3010", + "entranceId": 0 } ], "items": [ @@ -1211,15 +1239,26 @@ ] }, "3030": { + "doorRando": [ + { + "nop": [ "0x1597F4-0x159858" ] + } + ], "doors": [ { - "target": "3010" + "id": 1, + "target": "3010", + "entranceId": 0 }, { - "target": "3040" + "id": 0, + "target": "3040", + "entranceId": 1 }, { - "target": "3050" + "id": 2, + "target": "3050", + "entranceId": 2 } ], "items": [ @@ -1238,13 +1277,27 @@ ] }, "3040": { + "doorRando": [ + { + "nop": [ "0x1652D4-0x16532E" ] + } + ], "doors": [ { - "target": "3030" + "id": 1, + "target": "3030", + "entranceId": 0 }, { + "id": 0, + "target": "3050", + "entranceId": 1 + }, + { + "id": 2, "target": "3060", - "requires": [ 61, 78 ] + "requires": [ 61, 78 ], + "entranceId": 2 } ], "items": [ @@ -1257,9 +1310,27 @@ ] }, "3050": { + "doorRando": [ + { + "nop": [ "0x15F2DE-0x15F33A", "0x15F33C-0x15F3AE" ] + } + ], "doors": [ { - "target": "3030" + "id": 0, + "target": "3030", + "entranceId": 0 + }, + { + "id": 1, + "target": "3040", + "entranceId": 1 + }, + { + "id": 2, + "target": "3060", + "lock": "side", + "entranceId": 2 } ], "items": [ @@ -1282,13 +1353,29 @@ ] }, "3060": { + "doorRando": [ + { + "nop": [ "0x7098E-0x70A62" ] + } + ], "doors": [ { - "target": "3040" + "id": 8, + "altId": 9, + "target": "3040", + "entranceId": 0 + }, + { + "id": 9, + "target": "3050", + "doorRando": false, + "entranceId": 2 }, { + "id": 10, "target": "3070", - "requires": [ 119 ] + "requires": [ 119 ], + "entranceId": 1 } ], "items": [ @@ -1319,9 +1406,16 @@ ] }, "3070": { + "doorRando": [ + { + "nop": [ "0x832AC-0x832E4" ] + } + ], "doors": [ { - "target": "3060" + "id": 5, + "target": "3060", + "entranceId": 0 } ], "items": [