I wanted to get this done, so: the following can replace the BG1UB code in a future version. For Tutu, you should be able to just replace AR0224 and AR0226 with FW (or whatever), make sure that the container name and coordinates are OK in the Tutu ARE files, and change the item references to whatever they are in Tutu. For fun, I decided to do a random replacement of a single body in the container in AR0226 that has two bodies. It should default to the second one (the one replaced now), but hopefully it will change if any mod that touches this area is installed. I checked to make sure the patch works on default BG area files, but you'll want to double-check and check the Tutu conversion. The patch will match a container by either name or exact coordinates (I don't know if FotD changes these areas or not), so it should be safe.COPY_EXISTING AR0224.ARE OVERRIDE
PATCH_IF (SOURCE_SIZE > 0xd4) BEGIN
READ_LONG 0x70 contOff // Offset to containers
READ_LONG 0x78 itmOff // Offset to item list
FOR (READ_SHORT 0x74 numCont; numCont; numCont -= 0x1) BEGIN
READ_ASCII contOff contName (11) // Container name
READ_SHORT contOff + 0x20 contXloc // Container X location
READ_SHORT contOff + 0x22 contYloc // Container Y location
// Check by name and location, in case name is modified by FotD
PATCH_IF (!("%contName%" STRING_COMPARE_CASE "CONTAINER 1") ||
((contXloc == 1924) && (contYloc == 1888))) BEGIN
READ_LONG contOff + 0x40 itmIdx // Index of first item in list
myItmOff = itmOff + (itmIdx * 0x14)
FOR (READ_LONG contOff + 0x44 itmCnt; itmCnt; itmCnt -= 0x1) BEGIN
READ_ASCII myItmOff itmRef // Item resource reference
PATCH_IF !("%itmRef%" STRING_COMPARE_CASE "MISC80") BEGIN
WRITE_ASCII myItmOff MISC79 #8 // Female body
END
myItmOff += 0x14
END
END
contOff += 0xc0
END
END
BUT_ONLY_IF_IT_CHANGES
COPY_EXISTING AR0226.ARE OVERRIDE
PATCH_IF (SOURCE_SIZE > 0xd4) BEGIN
READ_LONG 0x70 contOff // Offset to containers
READ_LONG 0x78 itmOff // Offset to item list
FOR (READ_SHORT 0x74 numCont; numCont; numCont -= 0x1) BEGIN
READ_ASCII contOff contName (11) // Container name
READ_SHORT contOff + 0x20 contXloc // Container X location
READ_SHORT contOff + 0x22 contYloc // Container Y location
// Check by name and location, in case name is modified by FotD
PATCH_IF (!("%contName%" STRING_COMPARE_CASE "CONTAINER 1") ||
((contXloc == 827) && (contYloc == 1509))) BEGIN
READ_LONG contOff + 0x40 itmIdx // Index of first item in list
myItmOff = itmOff + (itmIdx * 0x14)
FOR (READ_LONG contOff + 0x44 itmCnt; itmCnt; itmCnt -= 0x1) BEGIN
READ_ASCII myItmOff itmRef // Item resource reference
PATCH_IF !("%itmRef%" STRING_COMPARE_CASE "MISC80") BEGIN
WRITE_ASCII myItmOff UBFEBODY
END
myItmOff += 0x14
END
END ELSE
PATCH_IF (!("%contName%" STRING_COMPARE_CASE "CONTAINER 4") ||
((contXloc == 398) && (contYloc == 1414))) BEGIN
READ_LONG contOff + 0x40 itmIdx // Index of first item in list
READ_LONG contOff + 0x44 itmCnt // Number of items
READ_SHORT 0x76 numItm // Total number of items
myItmOff = itmOff + (itmIdx * 0x14)
PATCH_RANDOM_SEED myItmOff << (numItm / itmCnt)
bodyCount = 0x0
// Make sure there's more than one body before deciding which to replace
FOR (i = itmCnt; i; i -= 0x1) BEGIN
READ_ASCII myItmOff itmRef // Item resource reference
PATCH_IF !("%itmRef%" STRING_COMPARE_CASE "MISC80") BEGIN
bodyCount += 0x1 // Count those bodies!
END
myItmOff += 0x14
END
PATCH_IF (bodyCount) BEGIN
PATCH_IF (bodyCount > 1) BEGIN
theBody = RANDOM(1 bodyCount) // Random body replacement
END ELSE theBody = 0x1
myItmOff = itmOff + (itmIdx * 0x14)
bodyCount = 0x1
FOR (i = itmCnt; i; i -= 0x1) BEGIN
READ_ASCII myItmOff itmRef // Item resource reference
PATCH_IF !("%itmRef%" STRING_COMPARE_CASE "MISC80") BEGIN
PATCH_IF (bodyCount == theBody) BEGIN
WRITE_ASCII myItmOff MISC79 #8 // Female body
END
bodyCount += 0x1
END
myItmOff += 0x14
END
END
END
contOff += 0xc0
END
END
BUT_ONLY_IF_IT_CHANGES