AR1010: Restored.
The patch installs correctly over itself (obviously, you wouldn't want to do this, but the patch does not fail or corrupt the file if it's not in its default state, so we should be safe to patch AR1008, AR1009, and AR1010 that have been modified in any fashion by any mod). We may get an in-game crash if somebody completely rewrote all the entrances and triggers, but I doubt even that would break it.
The patch installs correctly over Fields of the Dead (after decompressing all 10 billion files). Nobody would want to do this, but the changes actually look like it could just get dumped on top of FotD. The autosave flag isn't set for FotD transition to AR1010 from AR1009, but I don't want to special case an AR1010 check in the flags update code (unless you want it). The transition from 1008 to 1009, 1010 to 1008, and 1010 to 1009 will be marked party-required, as expected. We preserve Echon's exit point from AR1010 to AR1009, and correctly add a new transition to AR1008 from AR1010. All of his other changes are untouched, and do not appear to conflict with anything we add.
I'm going to wiki the code, but you should choose a component title, move it to where you want in the Tp2, and you'll need to add the code to copy the WED file and the BMPs to the override folder (remove my ### todo comments when you edit).
The goods////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ### icelus : choose component title and move it to the order you'd like in the Tp2
BEGIN ~poT-terceS tnenopmoC~
// ### icelus : need to copy WED, HT.BMP, LM.BMP, and SR.BMP
// AR1010.TIS and AR1010.MOS already included with TotSC
COPY_EXISTING AR1008.ARE OVERRIDE
AR1009.ARE OVERRIDE
PATCH_IF (SOURCE_SIZE > 0x11c) BEGIN
PATCH_IF !("%SOURCE_RES%" STRING_COMPARE_CASE "AR1009") BEGIN
// Remove Dezkiel from AR1009 (he's now in AR1010)
READ_LONG 0x54 actOff
FOR (READ_SHORT 0x58 numAct; numAct > 0x0; numAct -= 0x1) BEGIN
READ_ASCII actOff + 0x80 char
PATCH_IF !("%char%" STRING_COMPARE_CASE "DEZKIE") BEGIN
WRITE_LONG actOff + 0x28 0x0 // Disable Dezkiel in AR1009
END
actOff += 0x110
END
END
// Make default transitions autosave; enable travel to AR1010
READ_LONG 0x5c trigOff
FOR (READ_SHORT 0x5a numTrig; numTrig > 0x0; numTrig -= 0x1) BEGIN
READ_SHORT trigOff + 0x20 type
PATCH_IF (type == 0x2) BEGIN
READ_ASCII trigOff + 0x38 destAre
PATCH_IF (!("%destAre%" STRING_COMPARE_CASE "AR1008") ||
!("%destAre%" STRING_COMPARE_CASE "AR1009")) BEGIN
READ_BYTE trigOff + 0x60 flag
WRITE_BYTE trigOff + 0x60 flag | 0x4 // Add party-required flag
END
END
PATCH_IF !("%SOURCE_RES%" STRING_COMPARE_CASE "AR1009") BEGIN
READ_ASCII trigOff name
PATCH_IF !("%name%" STRING_COMPARE_CASE "DOOR1010") BEGIN
WRITE_ASCII trigOff + 0x38 AR1010 #8 // Set destination area to AR1010
END
END
trigOff += 0xc4
END
// Update number of entrances
READ_LONG 0x6c numEntr
WRITE_LONG 0x6c numEntr + 0x1
// Add exit points to AR1008 and AR1009
READ_LONG 0x68 entrOff
entrOff += numEntr * 0x68 // Added as last entrance in file
INSERT_BYTES entrOff 0x68
WRITE_ASCII entrOff EXIT1010 // Entrance name
PATCH_IF !("%SOURCE_RES%" STRING_COMPARE_CASE "AR1008") BEGIN
WRITE_SHORT entrOff + 0x20 842 // Location X
WRITE_SHORT entrOff + 0x22 307 // Location Y
WRITE_SHORT entrOff + 0x24 15 // Facing direction
END ELSE BEGIN // AR1009 patch
WRITE_SHORT entrOff + 0x20 697 // Location X
WRITE_SHORT entrOff + 0x22 259 // Location Y
END
READ_LONG 0x54 actOff
PATCH_IF (actOff > entrOff) BEGIN
WRITE_LONG 0x54 actOff + 0x68
END
READ_LONG 0x5c trigOff
PATCH_IF (trigOff > entrOff) BEGIN
WRITE_LONG 0x5c trigOff + 0x68
END
READ_LONG 0x60 sptOff
PATCH_IF (sptOff > entrOff) BEGIN
WRITE_LONG 0x60 sptOff + 0x68
END
READ_LONG 0x68 entrOff
PATCH_IF (entrOff > entrOff) BEGIN
WRITE_LONG 0x68 entrOff + 0x68
END
READ_LONG 0x70 contOff
PATCH_IF !(contOff < entrOff) BEGIN
WRITE_LONG 0x70 contOff + 0x68
END
READ_LONG 0x78 itmOff
PATCH_IF !(itmOff < entrOff) BEGIN
WRITE_LONG 0x78 itmOff + 0x68
END
READ_LONG 0x7c vertOff
PATCH_IF !(vertOff < entrOff) BEGIN
WRITE_LONG 0x7c vertOff + 0x68
END
READ_LONG 0x84 ambOff
PATCH_IF !(ambOff < entrOff) BEGIN
WRITE_LONG 0x84 ambOff + 0x68
END
READ_LONG 0x88 varOff
PATCH_IF !(varOff < entrOff) BEGIN
WRITE_LONG 0x88 varOff + 0x68
END
READ_LONG 0xa0 explOff
PATCH_IF !(explOff < entrOff) BEGIN
WRITE_LONG 0xa0 explOff + 0x68
END
READ_LONG 0xa8 doorOff
PATCH_IF !(doorOff < entrOff) BEGIN
WRITE_LONG 0xa8 doorOff + 0x68
END
READ_LONG 0xb0 animOff
PATCH_IF !(animOff < entrOff) BEGIN
WRITE_LONG 0xb0 animOff + 0x68
END
READ_LONG 0xb8 tobjOff
PATCH_IF !(tobjOff < entrOff) BEGIN
WRITE_LONG 0xb8 tobjOff + 0x68
END
READ_LONG 0xbc musOff
PATCH_IF !(musOff < entrOff) BEGIN
WRITE_LONG 0xbc musOff + 0x68
END
READ_LONG 0xc0 rspnOff
PATCH_IF !(rspnOff < entrOff) BEGIN
WRITE_LONG 0xc0 rspnOff + 0x68
END
READ_LONG 0xc4 mapnOff
READ_LONG 0xc8 numMapn
PATCH_IF (!(mapnOff < entrOff) && numMapn) BEGIN
WRITE_LONG 0xc4 mapnOff + 0x68
END
END
BUT_ONLY_IF_IT_CHANGES
COPY_EXISTING AR1010.ARE OVERRIDE
PATCH_IF (SOURCE_SIZE > 0x11c) BEGIN
// Update number of vertices
READ_SHORT 0x80 numVert
WRITE_SHORT 0x80 numVert + 0x4
// Add vertices for new transition
READ_LONG 0x7c vertOff
vertOff += numVert * 0x4
INSERT_BYTES vertOff 0x10
WRITE_SHORT vertOff 478 // Location X (Vertex 0)
WRITE_SHORT vertOff + 0x2 2719 // Location Y (Vertex 0)
WRITE_SHORT vertOff + 0x4 545 // Location X (Vertex 1)
WRITE_SHORT vertOff + 0x6 2762 // Location Y (Vertex 1)
WRITE_SHORT vertOff + 0x8 497 // Location X (Vertex 2)
WRITE_SHORT vertOff + 0xa 2815 // Location Y (Vertex 2)
WRITE_SHORT vertOff + 0xc 345 // Location X (Vertex 3)
WRITE_SHORT vertOff + 0xe 2815 // Location Y (Vertex 3)
// Update number of triggers
READ_SHORT 0x5a numTrig
WRITE_SHORT 0x5a numTrig + 0x1
// Update triggers offset, if required
READ_LONG 0x5c trigOff
PATCH_IF (trigOff > vertOff) BEGIN
WRITE_LONG 0x5c trigOff + 0x10
trigOff += trigOff + 0x10
END
// Make default transitions autosave
FOR (i = numTrig; i > 0x0; i -= 0x1) BEGIN
READ_SHORT trigOff + 0x20 type
PATCH_IF (type == 0x2) BEGIN
READ_ASCII trigOff + 0x38 destAre
PATCH_IF !("%destAre%" STRING_COMPARE_CASE "AR1009") BEGIN
READ_BYTE trigOff + 0x60 flag
WRITE_BYTE trigOff + 0x60 flag | 0x4 // Add party-required flag
END
END
trigOff += 0xc4
END
// Add usable transition to AR1008
READ_LONG 0x5c trigOff
trigOff += numTrig * 0xc4
INSERT_BYTES trigOff 0xc4
WRITE_ASCII trigOff DOOR1008 // Trigger name
WRITE_ASCII trigOff + 0x38 AR1008 // Destination area
WRITE_ASCII trigOff + 0x40 EXIT1010 // Destination exit point
WRITE_LONG trigOff + 0x2c numVert // Vertex index
WRITE_LONG trigOff + 0x34 28 // Trigger cursor
WRITE_LONG trigOff + 0x60 4 // Flags: party-required
WRITE_LONG trigOff + 0x64 BNOT 0x0 // Activation text
WRITE_SHORT trigOff + 0x20 2 // Trigger type
WRITE_SHORT trigOff + 0x22 345 // Leftmost point
WRITE_SHORT trigOff + 0x24 2719 // Topmost point
WRITE_SHORT trigOff + 0x26 545 // Rightmost point
WRITE_SHORT trigOff + 0x28 2815 // Bottommost point
WRITE_SHORT trigOff + 0x2a 4 // Number of vertices
WRITE_SHORT trigOff + 0x70 609 // Location X
WRITE_SHORT trigOff + 0x72 2643 // Location Y
READ_LONG 0x54 actOff
PATCH_IF (actOff > trigOff) BEGIN
WRITE_LONG 0x54 (actOff > vertOff) ? actOff + 0xd4 : actOff + 0xc4
END
READ_LONG 0x5c trigOff
PATCH_IF (trigOff > trigOff) BEGIN
WRITE_LONG 0x5c (trigOff > vertOff) ? trigOff + 0xd4 : trigOff + 0xc4
END
READ_LONG 0x60 sptOff
PATCH_IF (sptOff > trigOff) BEGIN
WRITE_LONG 0x60 (sptOff > vertOff) ? sptOff + 0xd4 : sptOff + 0xc4
END
READ_LONG 0x68 entrOff
PATCH_IF (entrOff > trigOff) BEGIN
WRITE_LONG 0x68 (entrOff > vertOff) ? entrOff + 0xd4 : entrOff + 0xc4
END
READ_LONG 0x70 contOff
PATCH_IF !(contOff < trigOff) BEGIN
WRITE_LONG 0x70 (contOff > vertOff) ? contOff + 0xd4 : contOff + 0xc4
END
READ_LONG 0x78 itmOff
PATCH_IF !(itmOff < trigOff) BEGIN
WRITE_LONG 0x78 (itmOff > vertOff) ? itmOff + 0xd4 : itmOff + 0xc4
END
READ_LONG 0x7c vertOff
PATCH_IF !(vertOff < trigOff) BEGIN
WRITE_LONG 0x7c (vertOff > vertOff) ? vertOff + 0xd4 : vertOff + 0xc4
END
READ_LONG 0x84 ambOff
PATCH_IF !(ambOff < trigOff) BEGIN
WRITE_LONG 0x84 !(ambOff < vertOff) ? ambOff + 0xd4 : ambOff + 0xc4
END
READ_LONG 0x88 varOff
PATCH_IF !(varOff < trigOff) BEGIN
WRITE_LONG 0x88 !(varOff < vertOff) ? varOff + 0xd4 : varOff + 0xc4
END
READ_LONG 0xa0 explOff
PATCH_IF !(explOff < trigOff) BEGIN
WRITE_LONG 0xa0 !(explOff < vertOff) ? explOff + 0xd4 : explOff + 0xc4
END
READ_LONG 0xa8 doorOff
PATCH_IF !(doorOff < trigOff) BEGIN
WRITE_LONG 0xa8 !(doorOff < vertOff) ? doorOff + 0xd4 : doorOff + 0xc4
END
READ_LONG 0xb0 animOff
PATCH_IF !(animOff < trigOff) BEGIN
WRITE_LONG 0xb0 !(animOff < vertOff) ? animOff + 0xd4 : animOff + 0xc4
END
READ_LONG 0xb8 tobjOff
PATCH_IF !(tobjOff < trigOff) BEGIN
WRITE_LONG 0xb8 !(tobjOff < vertOff) ? tobjOff + 0xd4 : tobjOff + 0xc4
END
READ_LONG 0xbc musOff
PATCH_IF !(musOff < trigOff) BEGIN
WRITE_LONG 0xbc !(musOff < vertOff) ? musOff + 0xd4 : musOff + 0xc4
END
READ_LONG 0xc0 rspnOff
PATCH_IF !(rspnOff < trigOff) BEGIN
WRITE_LONG 0xc0 !(rspnOff < vertOff) ? rspnOff + 0xd4 : rspnOff + 0xc4
END
READ_LONG 0xc4 mapnOff
READ_LONG 0xc8 numMapn
PATCH_IF (!(mapnOff < trigOff) && numMapn) BEGIN
WRITE_LONG 0xc4 !(mapnOff < vertOff) ? mapnOff + 0xd4 : mapnOff + 0xc4
END
END
BUT_ONLY_IF_IT_CHANGES
Let me know if you have any suggestions or any concerns about the patch (from here on, it'll be fairly easy to make modifications).