Skip to content

Commit

Permalink
RE CV, add residence rooms to door rando
Browse files Browse the repository at this point in the history
  • Loading branch information
IntelOrca committed Feb 17, 2024
1 parent 65b0c42 commit cf1f469
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 43 deletions.
1 change: 1 addition & 0 deletions IntelOrca.Biohazard.BioRand/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
43 changes: 24 additions & 19 deletions IntelOrca.Biohazard.BioRand/RECV/ReCvDoorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -88,9 +97,5 @@ public void Patch(GameData gameData, RdtId rtdId, int offset, byte value)

rrdt.Patches.Add(new KeyValuePair<int, byte>(offset, value));
}

public void End(RandoConfig config, GameData gameData, Map map)
{
}
}
}
11 changes: 6 additions & 5 deletions IntelOrca.Biohazard.BioRand/RECV/ReCvRandomiser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions IntelOrca.Biohazard.BioRand/Rdt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
132 changes: 113 additions & 19 deletions IntelOrca.Biohazard.BioRand/data/recv/rdt.json
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@
{
"id": 0,
"target": "2020",
"entranceId": 2
"entranceId": 0
},
{
"id": 2,
Expand All @@ -686,7 +686,7 @@
{
"id": 1,
"target": "20C0",
"entranceId": 0
"entranceId": 2
}
],
"items": [
Expand Down Expand Up @@ -1052,7 +1052,7 @@
"20C0": {
"doorRando": [
{
"nop": [ "0x1580B4-0x158142" ]
"nop": [ "0x1580B4-0x1580D8", "0x1580FE-0x158142" ]
}
],
"doors": [
Expand All @@ -1063,7 +1063,8 @@
},
{
"id": 2,
"target": "2000"
"target": "2000",
"entranceId": 0
},
{
"id": 1,
Expand Down Expand Up @@ -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": [
Expand All @@ -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": [
Expand All @@ -1182,9 +1203,16 @@
]
},
"3020": {
"doorRando": [
{
"nop": [ "0x12902E-0x129056" ]
}
],
"doors": [
{
"target": "3010"
"id": 0,
"target": "3010",
"entranceId": 0
}
],
"items": [
Expand All @@ -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": [
Expand All @@ -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": [
Expand All @@ -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": [
Expand All @@ -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": [
Expand Down Expand Up @@ -1319,9 +1406,16 @@
]
},
"3070": {
"doorRando": [
{
"nop": [ "0x832AC-0x832E4" ]
}
],
"doors": [
{
"target": "3060"
"id": 5,
"target": "3060",
"entranceId": 0
}
],
"items": [
Expand Down

0 comments on commit cf1f469

Please sign in to comment.