Jump to content

Overwrite->patch conversions


Wisp

Recommended Posts

I would say I did this for the fun of it, but it'll be a long time before I want to write another worldmap patch.

 

First out we have the cyclopean worldmap fix. I won't pretend it's very pretty (in particular, the LAA array could probably be compacted into a couple of lines of hard code, at the expense of portability). The whole thing would probably benefit from putting the arrays into an external tp* file and including it before the patch.

The code is based on the differences between the fixpack worldmaps and the vanilla worldmap. The output should have the same content as the fixpack worldmaps, except this code will add links from ar1400 and ar1404 to ar1300, which are missing in the fixpack worldmaps.

By "node" I mean the four North, East etc thingies in the area entry. The code will not work well with worldmaps where the link indexing does not follow the standard counter-clockwise pattern.

//SoA worldmap fix
//Old flags, set to 0 by code if value matches
OUTER_SET $are_flags(AR2000) = 4
OUTER_SET $are_flags(AR1700) = 4
OUTER_SET $are_flags(AR2600) = 6
OUTER_SET $are_flags(AR1800) = 6
OUTER_SET $are_flags(AR1600) = 6
OUTER_SET $are_flags(AR2800) = 6

//Links that should be deleted (%area% %node% %target%)
OUTER_SET $delete_links(AR1100 2 AR1200) = 0 //duplicate, delete second link
OUTER_SET $delete_links(AR0020 0 AR1400) = 0 //duplicate, delete second link
OUTER_SET $delete_links(AR0020 1 AR1000) = 1
OUTER_SET $delete_links(AR0020 1 AR0800) = 1
OUTER_SET $delete_links(AR0020 1 AR0700) = 1
OUTER_SET $delete_links(AR0020 1 AR1100) = 1
OUTER_SET $delete_links(AR0020 2 AR1000) = 1
OUTER_SET $delete_links(AR0020 2 AR0800) = 1
OUTER_SET $delete_links(AR0020 2 AR0700) = 1
OUTER_SET $delete_links(AR0020 2 AR1100) = 1

//Which array of links that should be checked for each area and node
OUTER_SPRINT $LAA(AR1100 0) AR1100_LINKS
OUTER_SPRINT $LAA(AR1100 1) AR1100_LINKS
OUTER_SPRINT $LAA(AR1100 2) AR1100_LINKS
OUTER_SPRINT $LAA(AR1100 3) AR1100_LINKS
OUTER_SPRINT $LAA(AR1400 0) AR1400_LINKS
OUTER_SPRINT $LAA(AR1400 1) AR1400_LINKS
OUTER_SPRINT $LAA(AR1400 2) AR1400_LINKS
OUTER_SPRINT $LAA(AR1400 3) AR1400_LINKS
OUTER_SPRINT $LAA(AR1300 0) AR1300_LINKS
OUTER_SPRINT $LAA(AR1300 1) AR1300_LINKS
OUTER_SPRINT $LAA(AR1300 2) AR1300_LINKS
OUTER_SPRINT $LAA(AR1300 3) AR1300_LINKS
OUTER_SPRINT $LAA(AR1200 0) AR1200_LINKS
OUTER_SPRINT $LAA(AR1200 1) AR1200_LINKS
OUTER_SPRINT $LAA(AR1200 2) AR1200_LINKS
OUTER_SPRINT $LAA(AR1200 3) AR1200_LINKS
OUTER_SPRINT $LAA(AR0020 0) AR0020_LINKS
OUTER_SPRINT $LAA(AR0020 3) AR0020_LINKS
OUTER_SPRINT $LAA(AR1404 0) AR1404_LINKS
OUTER_SPRINT $LAA(AR1404 1) AR1404_LINKS
OUTER_SPRINT $LAA(AR1404 2) AR1404_LINKS
OUTER_SPRINT $LAA(AR1404 3) AR1404_LINKS
OUTER_SPRINT $LAA(AR1304 0) AR1304_LINKS
OUTER_SPRINT $LAA(AR1304 1) AR1304_LINKS
OUTER_SPRINT $LAA(AR1304 2) AR1304_LINKS
OUTER_SPRINT $LAA(AR1304 3) AR1304_LINKS
OUTER_SPRINT $LAA(AR2000 0) AR2000_LINKS
OUTER_SPRINT $LAA(AR2000 1) AR2000_LINKS
OUTER_SPRINT $LAA(AR2000 2) AR2000_LINKS
OUTER_SPRINT $LAA(AR2000 3) AR2000_LINKS
OUTER_SPRINT $LAA(AR1900 0) AR1900_LINKS
OUTER_SPRINT $LAA(AR1900 1) AR1900_LINKS
OUTER_SPRINT $LAA(AR1900 2) AR1900_LINKS
OUTER_SPRINT $LAA(AR1900 3) AR1900_LINKS
OUTER_SPRINT $LAA(AR1700 0) AR1700_LINKS
OUTER_SPRINT $LAA(AR1700 1) AR1700_LINKS
OUTER_SPRINT $LAA(AR1700 2) AR1700_LINKS
OUTER_SPRINT $LAA(AR1700 3) AR1700_LINKS
OUTER_SPRINT $LAA(AR2500 0) AR2500_LINKS
OUTER_SPRINT $LAA(AR2500 1) AR2500_LINKS
OUTER_SPRINT $LAA(AR2500 2) AR2500_LINKS
OUTER_SPRINT $LAA(AR2500 3) AR2500_LINKS
OUTER_SPRINT $LAA(AR2600 0) AR2600_LINKS
OUTER_SPRINT $LAA(AR2600 1) AR2600_LINKS
OUTER_SPRINT $LAA(AR2600 2) AR2600_LINKS
OUTER_SPRINT $LAA(AR2600 3) AR2600_LINKS
OUTER_SPRINT $LAA(AR1800 0) AR1800_LINKS
OUTER_SPRINT $LAA(AR1800 1) AR1800_LINKS
OUTER_SPRINT $LAA(AR1800 2) AR1800_LINKS
OUTER_SPRINT $LAA(AR1800 3) AR1800_LINKS

//Links that should be present
ACTION_DEFINE_ARRAY AR1100_LINKS BEGIN AR0020 AR1200 AR1300 AR1304 AR1400 AR1404 AR1900 AR2000 END
ACTION_DEFINE_ARRAY AR1400_LINKS BEGIN AR0020 AR1100 AR1200 AR1300 AR1304 AR1800 AR1900 AR2000 END
ACTION_DEFINE_ARRAY AR1300_LINKS BEGIN AR0020 AR1100 AR1200 AR1400 AR1404 AR1700 AR1800 AR1900 AR2000 AR2500 END
ACTION_DEFINE_ARRAY AR1200_LINKS BEGIN AR0020 AR1100 AR1300 AR1304 AR1400 AR1404 AR1900 AR2000 AR2600 END
ACTION_DEFINE_ARRAY AR0020_LINKS BEGIN AR1100 AR1200 AR1300 AR1304 AR1400 AR1404 AR1700 AR1800 AR1900 AR2000 AR2500 END
ACTION_DEFINE_ARRAY AR1404_LINKS BEGIN AR0020 AR1100 AR1200 AR1300 AR1304 AR1800 AR1900 AR2000 END
ACTION_DEFINE_ARRAY AR1304_LINKS BEGIN AR0020 AR1100 AR1200 AR1400 AR1404 AR1700 AR1800 AR1900 AR2000 AR2500 END
ACTION_DEFINE_ARRAY AR2000_LINKS BEGIN AR0020 AR1100 AR1200 AR1300 AR1304 AR1400 AR1404 AR1800 AR1900 AR2600 END
ACTION_DEFINE_ARRAY AR1900_LINKS BEGIN AR0020 AR1100 AR1200 AR1300 AR1304 AR1400 AR1404 AR2000 END
ACTION_DEFINE_ARRAY AR1700_LINKS BEGIN AR0020 AR1300 AR1304 AR1800 AR2500 AR2600 END
ACTION_DEFINE_ARRAY AR2500_LINKS BEGIN AR0020 AR1700 END
ACTION_DEFINE_ARRAY AR2600_LINKS BEGIN AR1200 AR1700 AR1800 AR2000 END
ACTION_DEFINE_ARRAY AR1800_LINKS BEGIN AR0020 AR1300 AR1304 AR1400 AR1404 AR1700 AR2000 AR2600 END

//Entry point (%area% %target%)
OUTER_SPRINT $entry_point(AR1100 AR1900) ExitW
OUTER_SPRINT $entry_point(AR1100 AR2000) ExitNW
OUTER_SPRINT $entry_point(AR1100 AR1304) ExitSE
OUTER_SPRINT $entry_point(AR1100 AR1404) ExitE
OUTER_SPRINT $entry_point(AR1100 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR1100 AR1200) ExitW
OUTER_SPRINT $entry_point(AR1100 AR1400) ExitW
OUTER_SPRINT $entry_point(AR1400 AR1800) CDExit
OUTER_SPRINT $entry_point(AR1400 AR1900) ExitW
OUTER_SPRINT $entry_point(AR1400 AR2000) ExitNW
OUTER_SPRINT $entry_point(AR1400 AR1304) ExitSE
OUTER_SPRINT $entry_point(AR1400 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR1400 AR1200) ExitW
OUTER_SPRINT $entry_point(AR1400 AR1100) ExitNW
OUTER_SPRINT $entry_point(AR1300 AR1800) CDExit
OUTER_SPRINT $entry_point(AR1300 AR2500) CDExit
OUTER_SPRINT $entry_point(AR1300 AR1700) CDExit
OUTER_SPRINT $entry_point(AR1300 AR1900) ExitW
OUTER_SPRINT $entry_point(AR1300 AR1404) ExitE
OUTER_SPRINT $entry_point(AR1300 AR1400) ExitE
OUTER_SPRINT $entry_point(AR1300 AR2000) ExitNW
OUTER_SPRINT $entry_point(AR1300 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR1300 AR1200) ExitW
OUTER_SPRINT $entry_point(AR1200 AR2600) CDExit
OUTER_SPRINT $entry_point(AR1200 AR1900) ExitW
OUTER_SPRINT $entry_point(AR1200 AR2000) ExitNW
OUTER_SPRINT $entry_point(AR1200 AR1304) ExitSE
OUTER_SPRINT $entry_point(AR1200 AR1404) ExitE
OUTER_SPRINT $entry_point(AR1200 AR1300) ExitSE
OUTER_SPRINT $entry_point(AR1200 AR1400) ExitW
OUTER_SPRINT $entry_point(AR1200 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR1200 AR1100) ExitSE
OUTER_SPRINT $entry_point(AR0020 AR1800) CDExit
OUTER_SPRINT $entry_point(AR0020 AR2500) CDExit
OUTER_SPRINT $entry_point(AR0020 AR1700) CDExit
OUTER_SPRINT $entry_point(AR0020 AR1900) ExitW
OUTER_SPRINT $entry_point(AR0020 AR1400) ExitE
OUTER_SPRINT $entry_point(AR1404 AR1800) CDExit
OUTER_SPRINT $entry_point(AR1404 AR1900) ExitW
OUTER_SPRINT $entry_point(AR1404 AR2000) ExitNW
OUTER_SPRINT $entry_point(AR1404 AR1304) ExitSE
OUTER_SPRINT $entry_point(AR1404 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR1404 AR1200) ExitW
OUTER_SPRINT $entry_point(AR1404 AR1100) ExitNW
OUTER_SPRINT $entry_point(AR1304 AR1800) CDExit
OUTER_SPRINT $entry_point(AR1304 AR2500) CDExit
OUTER_SPRINT $entry_point(AR1304 AR1700) CDExit
OUTER_SPRINT $entry_point(AR1304 AR1900) ExitW
OUTER_SPRINT $entry_point(AR1304 AR2000) ExitNW
OUTER_SPRINT $entry_point(AR1304 AR1404) ExitE
OUTER_SPRINT $entry_point(AR1304 AR1200) ExitW
OUTER_SPRINT $entry_point(AR1304 AR1400) ExitE
OUTER_SPRINT $entry_point(AR1304 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR1304 AR1100) ExitSE
OUTER_SPRINT $entry_point(AR2000 AR1800) CDExit
OUTER_SPRINT $entry_point(AR2000 AR2600) CDExit
OUTER_SPRINT $entry_point(AR2000 AR1304) ExitSE
OUTER_SPRINT $entry_point(AR2000 AR1404) ExitE
OUTER_SPRINT $entry_point(AR2000 AR1400) ExitW
OUTER_SPRINT $entry_point(AR2000 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR2000 AR1200) ExitW
OUTER_SPRINT $entry_point(AR2000 AR1300) ExitSE
OUTER_SPRINT $entry_point(AR2000 AR1100) ExitSE
OUTER_SPRINT $entry_point(AR2000 AR1100) ExitSE
OUTER_SPRINT $entry_point(AR2000 AR1400) ExitW
OUTER_SPRINT $entry_point(AR2000 AR1300) ExitSE
OUTER_SPRINT $entry_point(AR2000 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR2000 AR1404) ExitE
OUTER_SPRINT $entry_point(AR2000 AR1304) ExitSE
OUTER_SPRINT $entry_point(AR2000 AR2600) CDExit
OUTER_SPRINT $entry_point(AR2000 AR1800) CDExit
OUTER_SPRINT $entry_point(AR1900 AR1304) ExitSE
OUTER_SPRINT $entry_point(AR1900 AR1404) ExitE
OUTER_SPRINT $entry_point(AR1900 AR1200) ExitW
OUTER_SPRINT $entry_point(AR1900 AR1300) ExitSE
OUTER_SPRINT $entry_point(AR1900 AR1400) ExitW
OUTER_SPRINT $entry_point(AR1900 AR1100) ExitSE
OUTER_SPRINT $entry_point(AR1900 AR2000) ExitNW
OUTER_SPRINT $entry_point(AR1900 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR1700 AR1800) CDExit
OUTER_SPRINT $entry_point(AR1700 AR2600) CDExit
OUTER_SPRINT $entry_point(AR1700 AR2500) CDExit
OUTER_SPRINT $entry_point(AR1700 AR1304) ExitSE
OUTER_SPRINT $entry_point(AR1700 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR1700 AR1300) ExitSE
OUTER_SPRINT $entry_point(AR2500 AR1700) CDExit
OUTER_SPRINT $entry_point(AR2500 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR2500 AR1300) ExitSE
OUTER_SPRINT $entry_point(AR2500 AR1304) ExitSE
OUTER_SPRINT $entry_point(AR2600 AR1800) CDExit
OUTER_SPRINT $entry_point(AR2600 AR1700) CDExit
OUTER_SPRINT $entry_point(AR2600 AR2000) ExitNW
OUTER_SPRINT $entry_point(AR2600 AR1200) ExitW
OUTER_SPRINT $entry_point(AR1800 AR2600) CDExit
OUTER_SPRINT $entry_point(AR1800 AR1700) CDExit
OUTER_SPRINT $entry_point(AR1800 AR2000) ExitNW
OUTER_SPRINT $entry_point(AR1800 AR1304) ExitSE
OUTER_SPRINT $entry_point(AR1800 AR1404) ExitE
OUTER_SPRINT $entry_point(AR1800 AR0020) ExitNE
OUTER_SPRINT $entry_point(AR1800 AR1300) ExitSE
OUTER_SPRINT $entry_point(AR1800 AR1400) ExitW

//Travel time between two areas
<<<<<<<< inlined/2das/are/not/gauche.2da
AR0400 AR1000 0
AR1100 AR1900 2
AR1100 AR2000 2
AR1100 AR1304 3
AR1100 AR1404 1
AR1100 AR0020 5
AR1100 AR1200 1
AR1100 AR1300 3
AR1100 AR1400 1
AR1400 AR1800 2
AR1400 AR1900 3
AR1400 AR2000 2
AR1400 AR1304 2
AR1400 AR0020 4
AR1400 AR1200 2
AR1300 AR1800 2
AR1300 AR2500 3
AR1300 AR1700 2
AR1300 AR1900 4
AR1300 AR1404 2
AR1300 AR0020 2
AR1300 AR1400 2
AR1300 AR2000 3
AR1300 AR1200 4
AR1200 AR2600 2
AR1200 AR1900 1
AR1200 AR2000 2
AR1200 AR1304 4
AR1200 AR1404 2
AR1200 AR0020 6
AR0020 AR1800 3
AR0020 AR2500 3
AR0020 AR1700 3
AR0020 AR1900 6
AR0020 AR1304 2
AR0020 AR1404 4
AR1404 AR1800 2
AR1404 AR1900 3
AR1404 AR2000 2
AR1404 AR1304 2
AR1304 AR1800 2
AR1304 AR2500 3
AR1304 AR1700 2
AR1304 AR1900 4
AR1304 AR2000 3
AR2000 AR1800 1
AR2000 AR2600 1
AR2000 AR0020 5
AR1900 AR2000 2
AR1700 AR1800 1
AR1700 AR2600 1
AR1700 AR2500 2
AR2600 AR1800 1
>>>>>>>>

COPY - "inlined/2das/are/not/gauche.2da" "inlined/2das/are/not/gauche.2da"
 COUNT_2DA_ROWS 3 num_rows
 FOR (i=0;i<num_rows;i+=1) BEGIN
READ_2DA_ENTRY i 0 3 entry1
READ_2DA_ENTRY i 1 3 entry2
READ_2DA_ENTRY i 2 3 entry3
SET $time("%entry1%" "%entry2%") = entry3
SET $time("%entry2%" "%entry1%") = entry3
 END

//Defualt entry location (%area% %target%)
OUTER_SET $default_loc(AR1100 AR1404) = 1
OUTER_SET $default_loc(AR1100 AR1300) = 8
OUTER_SET $default_loc(AR1400 AR1100) = 1
OUTER_SET $default_loc(AR1300 AR1404) = 2
OUTER_SET $default_loc(AR1200 AR1100) = 1
OUTER_SET $default_loc(AR0020 AR1900) = 4
OUTER_SET $default_loc(AR0020 AR1404) = 1
OUTER_SET $default_loc(AR0020 AR0300) = 4
OUTER_SET $default_loc(AR0020 AR1400) = 1
OUTER_SET $default_loc(AR0020 AR2000) = 1
OUTER_SET $default_loc(AR1404 AR2000) = 4
OUTER_SET $default_loc(AR1404 AR1304) = 4
OUTER_SET $default_loc(AR1304 AR1404) = 8
OUTER_SET $default_loc(AR1304 AR1400) = 8
OUTER_SET $default_loc(AR2000 AR1900) = 1
OUTER_SET $default_loc(AR2000 AR0020) = 1
OUTER_SET $default_loc(AR2000 AR1200) = 1
OUTER_SET $default_loc(AR2000 AR1300) = 1
OUTER_SET $default_loc(AR2000 AR1100) = 1
OUTER_SET $default_loc(AR1900 AR0020) = 1
OUTER_SET $default_loc(AR1700 AR1800) = 4
OUTER_SET $default_loc(AR1700 AR2600) = 4
OUTER_SET $default_loc(AR1700 AR2500) = 4
OUTER_SET $default_loc(AR1700 AR1304) = 2
OUTER_SET $default_loc(AR1700 AR0020) = 4
OUTER_SET $default_loc(AR2500 AR1700) = 2
OUTER_SET $default_loc(AR2500 AR0020) = 2
OUTER_SET $default_loc(AR2500 AR1300) = 2
OUTER_SET $default_loc(AR2500 AR1304) = 2
OUTER_SET $default_loc(AR2600 AR1700) = 2
OUTER_SET $default_loc(AR2600 AR1200) = 2
OUTER_SET $default_loc(AR1800 AR2000) = 2
OUTER_SET $default_loc(AR1800 AR1304) = 8
OUTER_SET $default_loc(AR1800 AR1404) = 8
OUTER_SET $default_loc(AR1800 AR0020) = 2
OUTER_SET $default_loc(AR1800 AR1300) = 4

//Random encounter area 0 (%area% %target%)
OUTER_SPRINT $area0(AR0300 AR0500) AR0046
OUTER_SPRINT $area0(AR0300 AR0400) AR0046
OUTER_SPRINT $area0(AR0800 AR0020) AR0041
OUTER_SPRINT $area0(AR1100 AR1404) AR0043
OUTER_SPRINT $area0(AR1100 AR1300) AR0043
OUTER_SPRINT $area0(AR1100 AR1400) AR0043
OUTER_SPRINT $area0(AR1100 AR2000) AR0043
OUTER_SPRINT $area0(AR1100 AR1304) AR0043
OUTER_SPRINT $area0(AR1100 AR0020) AR0043
OUTER_SPRINT $area0(AR1100 AR1200) AR0043
OUTER_SPRINT $area0(AR1400 AR0020) AR0043
OUTER_SPRINT $area0(AR1400 AR1100) AR0043
OUTER_SPRINT $area0(AR1300 AR0020) AR0043
OUTER_SPRINT $area0(AR1300 AR1200) AR0043
OUTER_SPRINT $area0(AR1300 AR1100) AR0043
OUTER_SPRINT $area0(AR1300 AR2000) AR0043
OUTER_SPRINT $area0(AR1200 AR2000) AR0043
OUTER_SPRINT $area0(AR1200 AR0020) AR0043
OUTER_SPRINT $area0(AR1200 AR1100) AR0043
OUTER_SPRINT $area0(AR1200 AR1300) AR0043
OUTER_SPRINT $area0(AR1200 AR1304) AR0043
OUTER_SPRINT $area0(AR0020 AR1304) AR0043
OUTER_SPRINT $area0(AR0020 AR1404) AR0043
OUTER_SPRINT $area0(AR0020 AR1200) AR0043
OUTER_SPRINT $area0(AR0020 AR1100) AR0043
OUTER_SPRINT $area0(AR0020 AR0900) AR0046
OUTER_SPRINT $area0(AR0020 AR0500) AR0042
OUTER_SPRINT $area0(AR0020 AR0300) AR0041
OUTER_SPRINT $area0(AR0020 AR0400) AR0046
OUTER_SPRINT $area0(AR0020 AR1400) AR0043
OUTER_SPRINT $area0(AR0020 AR1900) AR0043
OUTER_SPRINT $area0(AR0020 AR1700) AR0043
OUTER_SPRINT $area0(AR1404 AR0020) AR0043
OUTER_SPRINT $area0(AR1404 AR1100) AR0043
OUTER_SPRINT $area0(AR1304 AR0020) AR0043
OUTER_SPRINT $area0(AR1304 AR1200) AR0043
OUTER_SPRINT $area0(AR1304 AR1100) AR0043
OUTER_SPRINT $area0(AR2000 AR1900) AR0043
OUTER_SPRINT $area0(AR2000 AR0020) AR0043
OUTER_SPRINT $area0(AR2000 AR1200) AR0043
OUTER_SPRINT $area0(AR2000 AR1300) AR0043
OUTER_SPRINT $area0(AR2000 AR1100) AR0043
OUTER_SPRINT $area0(AR1900 AR2000) AR0043
OUTER_SPRINT $area0(AR1900 AR0020) AR0043
OUTER_SPRINT $area0(AR1700 AR1800) AR0043
OUTER_SPRINT $area0(AR1700 AR2500) AR0043
OUTER_SPRINT $area0(AR2500 AR1700) AR2601
OUTER_SPRINT $area0(AR2500 AR0020) AR2601
OUTER_SPRINT $area0(AR2500 AR1300) AR2601
OUTER_SPRINT $area0(AR2500 AR1304) AR2601
OUTER_SPRINT $area0(AR2600 AR1700) AR0043
OUTER_SPRINT $area0(AR1800 AR2600) AR0043
OUTER_SPRINT $area0(AR1800 AR1700) AR0043

//Random encounter area 3 (%area% %target%)
OUTER_SPRINT $area3(AR0700 AR0400) AR0046
OUTER_SPRINT $area3(AR0300 AR0400) AR0045
OUTER_SPRINT $area3(AR0300 AR0020) AR0041
OUTER_SPRINT $area3(AR0300 AR0500) AR0046
OUTER_SPRINT $area3(AR0300 AR1000) AR0041
OUTER_SPRINT $area3(AR0500 AR0900) AR0041
OUTER_SPRINT $area3(AR0500 AR0020) AR0046
OUTER_SPRINT $area3(AR0800 AR0020) AR0045
OUTER_SPRINT $area3(AR0900 AR0400) AR0045
OUTER_SPRINT $area3(AR0900 AR0700) AR0046
OUTER_SPRINT $area3(AR0900 AR0020) AR0046
OUTER_SPRINT $area3(AR0900 AR0500) AR0041
OUTER_SPRINT $area3(AR0900 AR0300) AR0045
OUTER_SPRINT $area3(AR1000 AR0400) AR0046
OUTER_SPRINT $area3(AR1000 AR0800) AR0041
OUTER_SPRINT $area3(AR1000 AR0020) AR0041
OUTER_SPRINT $area3(AR1000 AR0300) AR0041

//Random encounter probabilities (%area% %target%)
OUTER_SET $prob(AR0020 AR2500) = 5
OUTER_SET $prob(AR0020 AR2000) = 100
OUTER_SET $prob(AR0020 AR1404) = 50
OUTER_SET $prob(AR0020 AR1200) = 50
OUTER_SET $prob(AR0020 AR1300) = 100
OUTER_SET $prob(AR0020 AR1400) = 67
OUTER_SET $prob(AR0020 AR1100) = 25
OUTER_SET $prob(AR1404 AR1900) = 103
OUTER_SET $prob(AR1404 AR1304) = 104
OUTER_SET $prob(AR1404 AR1900) = 103
OUTER_SET $prob(AR1404 AR1304) = 104
OUTER_SET $prob(AR2500 AR1700) = 101
OUTER_SET $prob(AR2500 AR0020) = 101
OUTER_SET $prob(AR2500 AR1300) = 101
OUTER_SET $prob(AR2500 AR1304) = 101

//Some nodes have different random encounter areas, even though starting area and target area are the same (%area% %node% %target%)
OUTER_SPRINT $fine_tuning_are0(AR0300 0 AR0500) AR0046
OUTER_SPRINT $fine_tuning_are0(AR0300 3 AR0400) AR0046
OUTER_SPRINT $fine_tuning_are0(AR0800 2 AR0020) AR0041

OUTER_SPRINT $fine_tuning_are3(AR0400 0 AR0300) AR0045
OUTER_SPRINT $fine_tuning_are3(AR0400 0 AR0900) AR0045
OUTER_SPRINT $fine_tuning_are3(AR0400 0 AR0500) AR0045
OUTER_SPRINT $fine_tuning_are3(AR0400 0 AR0800) AR0041
OUTER_SPRINT $fine_tuning_are3(AR0400 0 AR1000) AR0046
OUTER_SPRINT $fine_tuning_are3(AR0400 3 AR1000) AR0046
OUTER_SPRINT $fine_tuning_are3(AR0400 3 AR0800) AR0041
OUTER_SPRINT $fine_tuning_are3(AR0400 3 AR0900) AR0045
OUTER_SPRINT $fine_tuning_are3(AR0400 2 AR0700) AR0046
OUTER_SPRINT $fine_tuning_are3(AR0400 2 AR0500) AR0045
OUTER_SPRINT $fine_tuning_are3(AR0400 2 AR0800) AR0041
OUTER_SPRINT $fine_tuning_are3(AR0400 2 AR1000) AR0046

COPY_EXISTING worldmap.wmp override
 READ_LONG 0x30 num_are
 READ_LONG 0x34 are_off
 READ_LONG 0x38 link_off
 FOR (i=0;i<num_are;i+=1) BEGIN //Index existing areas and zero flags
READ_ASCII are_off + 0xf0*i area
TO_UPPER area
SET $are_idx("%area%") = i
PATCH_IF VARIABLE_IS_SET $are_flags("%area%") BEGIN
  READ_LONG are_off + 0xf0*i + 0x30 flags
  WRITE_LONG are_off + 0xf0*i + 0x30 $are_flags("%area%") = flags ? 0 : flags
END
 END
 FOR (i=0;i<num_are;i+=1) BEGIN //Delete links and add links
READ_ASCII are_off + 0xf0*i area
TO_UPPER area
PATCH_FOR_EACH j IN 0 3 2 1 BEGIN
  delta = 0
  READ_LONG are_off + 0xf0*i + 0x50 + 0x8*j link_idx
  READ_LONG are_off + 0xf0*i + 0x54 + 0x8*j link_num
  FOR (k=0;k<link_num;k+=1) BEGIN
	READ_LONG link_off + 0xd8*(link_idx + k) target_idx
	READ_ASCII are_off + 0xf0*target_idx target
	TO_UPPER target
	SET $ela("%area%" "%j%" "%target%") = 1
	PATCH_IF VARIABLE_IS_SET $delete_links("%area%" "%j%" "%target%") BEGIN
	  PATCH_IF $delete_links("%area%" "%j%" "%target%") = 1 BEGIN
		DELETE_BYTES link_off + 0xd8*(link_idx + k) 0xd8
		delta -= 1
		k -= 1
		link_num -= 1
		SET $delete_links("%area%" "%j%" "%target%") = 2
	  END
	  PATCH_IF $delete_links("%area%" "%j%" "%target%") = 0 BEGIN
		SET $delete_links("%area%" "%j%" "%target%") = 1
	  END
	END
  END
  PATCH_IF VARIABLE_IS_SET $LAA("%area%" "%j%") BEGIN
	SPRINT array $LAA("%area%" "%j%")
	PHP_EACH "%array%" AS int => link BEGIN
	  PATCH_IF NOT VARIABLE_IS_SET $ela("%area%" "%j%" "%link%") BEGIN
		INSERT_BYTES link_off + 0xd8*(link_idx + link_num) 0xd8
		WRITE_LONG   link_off + 0xd8*(link_idx + link_num) $are_idx("%link%")
		WRITE_LONG   link_off + 0xd8*(link_idx + link_num) + 0x28 1
		WRITE_ASCII  link_off + 0xd8*(link_idx + link_num) + 0x2c AR0043 #8
		delta += 1
		link_num += 1
	  END
	END
  END
  PATCH_IF FILE_EXISTS_IN_GAME mel01.cre AND "%area%" STRING_EQUAL_CASE AR2500 BEGIN
	PATCH_FOR_EACH keep IN AR1300 AR1304 BEGIN
	  PATCH_IF NOT VARIABLE_IS_SET $ela("%area%" "%j%" "%keep%") BEGIN
		INSERT_BYTES link_off + 0xd8*(link_idx + link_num) 0xd8
		WRITE_LONG   link_off + 0xd8*(link_idx + link_num) $are_idx("%keep%")
		WRITE_LONG   link_off + 0xd8*(link_idx + link_num) + 0x28 1
		delta += 1
		link_num += 1
	  END
	END
  END
  PATCH_IF delta != 0 BEGIN
	WRITE_LONG are_off + 0xf0*i + 0x54 + 0x8*j link_num
	READ_LONG 0x3c g_link_num
	WRITE_LONG 0x3c g_link_num + delta
	FOR (l=0;l<num_are;l+=1) BEGIN
	  READ_ASCII are_off + 0xf0*l cur_are
	  PATCH_FOR_EACH m IN 0 3 2 1 BEGIN
		READ_LONG are_off + 0xf0*l + 0x50 + 0x8*m link_idx2
		PATCH_IF link_idx2 >= link_idx AND !("%area%" STRING_EQUAL_CASE "%cur_are%" AND m = j) BEGIN
		  WRITE_LONG are_off + 0xf0*l + 0x50 + 0x8*m link_idx2 + delta
		END
	  END
	END
  END
END
 END
 FOR (i=0;i<num_are;i+=1) BEGIN //Tweak links, both new ones and old ones
READ_ASCII are_off + 0xf0*i area
TO_UPPER area
FOR (j=0;j<4;j+=1) BEGIN
  READ_LONG are_off + 0xf0*i + 0x50 + 0x8*j link_idx
  READ_LONG are_off + 0xf0*i + 0x54 + 0x8*j num_link
  FOR (k=0;k<num_link;k+=1) BEGIN
	READ_LONG link_off + 0xd8*(link_idx + k) target_idx
	READ_ASCII are_off + 0xf0*target_idx target
	TO_UPPER target
	PATCH_IF VARIABLE_IS_SET $entry_point("%area%" "%target%") BEGIN
	  WRITE_ASCIIE link_off + 0xd8*(link_idx + k) + 0x04 $entry_point("%area%" "%target%") #32
	END
	PATCH_IF VARIABLE_IS_SET $time("%area%" "%target%") BEGIN
	  WRITE_LONG   link_off + 0xd8*(link_idx + k) + 0x24 $time("%area%" "%target%")
	END
	PATCH_IF VARIABLE_IS_SET $default_loc("%area%" "%target%") BEGIN
	  WRITE_LONG   link_off + 0xd8*(link_idx + k) + 0x28 $default_loc("%area%" "%target%")
	END
	PATCH_IF VARIABLE_IS_SET $area0("%area%" "%target%") BEGIN
	  WRITE_ASCIIE link_off + 0xd8*(link_idx + k) + 0x2c $area0("%area%" "%target%") #8
	END
	PATCH_IF VARIABLE_IS_SET $area3("%area%" "%target%") BEGIN
	  WRITE_ASCIIE link_off + 0xd8*(link_idx + k) + 0x44 $area3("%area%" "%target%") #8
	  WRITE_ASCII  link_off + 0xd8*(link_idx + k) + 0x2c "" #8
	END
	PATCH_IF VARIABLE_IS_SET $prob("%area%" "%target%") BEGIN
	  WRITE_LONG   link_off + 0xd8*(link_idx + k) + 0x54 $prob("%area%" "%target%")
	END
	PATCH_IF VARIABLE_IS_SET $fine_tuning_are0("%area%" "%j%" "%target%") BEGIN
	  WRITE_ASCIIE link_off + 0xd8*(link_idx + k) + 0x2c $fine_tuning_are0("%area%" "%j%" "%target%") #8
	  WRITE_ASCII  link_off + 0xd8*(link_idx + k) + 0x44 "" #8
	END
	PATCH_IF VARIABLE_IS_SET $fine_tuning_are3("%area%" "%j%" "%target%") BEGIN
	  WRITE_ASCIIE link_off + 0xd8*(link_idx + k) + 0x44 $fine_tuning_are3("%area%" "%j%" "%target%") #8
	END
  END
END
 END
BUT_ONLY

 

Next we have states.bam and states2.bam. This code will switch the 73rd icon with the 123rd icon by switching the indices in the lookup table. Maybe this isn't a good idea (though I don't see why it wouldn't be) but it's a lot easier than swapping the actual frame data (which is what has been done to the fixpack files). However, the code does not verify the frame data before switching the indices, so it's entirely possible to undo someone else's fix. Given the lack of IMAGE_APPROXIMATELY_EQUAL or similar, I don't see an easy way around this. I guess you could try only patching if the md5 sum matches that of the vanilla file or something like that.

//Switches the icon of the 73rd cycle with the one of the 123rd cycle
COPY_EXISTING states.bam override
		  states2.bam override
 READ_SHORT 0x8  num_frame
 READ_LONG  0xc  frame_off
 READ_LONG  0x14 look_off
 PATCH_FOR_EACH cycle IN 73 123 BEGIN
READ_SHORT frame_off + 0xc*num_frame + 0x4*(0x41 + cycle) + 0x2 cfi //65 first cycles are garbage
READ_SHORT look_off + 0x2*cfi frame_idx
SET $frame("%cycle%") = frame_idx
SET $cfi("%cycle%") = cfi
 END
 PHP_EACH frame AS entry => idx BEGIN
cycle = entry = 73 ? 123 : 73
WRITE_SHORT look_off + 0x2*$cfi("%cycle%") idx
 END
BUT_ONLY

 

Lastly we have the fix to Azuredge. The unused bytes, the Slay effects and the Use EFF equipping effect are deleted if present. Three new Use EFF effects are added to both abilities unless they are already present.

COPY_EXISTING ax1h10.itm override
 READ_LONG  0x64 ab_off
 READ_SHORT 0x68 num_ab
 READ_LONG  0x6a fx_off
 READ_SHORT 0x70 num_fx
 t_num_fx = num_fx
 FOR (i=0;i<num_ab;i+=1) BEGIN
READ_SHORT ab_off + 0x38*i + 0x1e num_l_fx
t_num_fx += num_l_fx
 END
 PATCH_IF 0x72 + num_ab*0x38 + 0x30*t_num_fx < BUFFER_LENGTH BEGIN
DELETE_BYTES 0x72 + num_ab*0x38 + 0x30*t_num_fx BUFFER_LENGTH - (0x72 + num_ab*0x38 + 0x30*t_num_fx)
 END
 FOR (i=0;i<num_fx;i+=1) BEGIN
READ_SHORT fx_off + 0x30*i fx_type
READ_ASCII fx_off + 0x30*i + 0x14 resref
PATCH_IF fx_type = 177 AND "%resref%" STRING_EQUAL_CASE macedisr BEGIN
  DELETE_BYTES fx_off + 0x30*i 0x30
  num_fx -= 1
  i -= 1
  WRITE_SHORT 0x70 num_fx
END
 END
 FOR (i=0;i<num_ab;i+=1) BEGIN
READ_SHORT  ab_off + 0x38*i + 0x1e num_l_fx
WRITE_SHORT ab_off + 0x38*i + 0x20 num_fx
FOR (j=0;j<num_l_fx;j+=1) BEGIN
  READ_SHORT fx_off + 0x30*(j + num_fx) fx_type
  READ_ASCII fx_off + 0x30*(j + num_fx) + 0x14 resref
  PATCH_IF fx_type = 177 AND ("%resref%" STRING_EQUAL_CASE unddam4 OR "%resref%" STRING_EQUAL_CASE mesdie OR "%resref%" STRING_EQUAL_CASE die) BEGIN
	SET $ax1h10("%resref%" "%i%") = 1
  END
  PATCH_IF fx_type = 55 BEGIN
	DELETE_BYTES fx_off + 0x30*(j + num_fx) 0x30
	num_l_fx -= 1
	j -= 1
  END
END
PATCH_FOR_EACH resref IN unddam4 mesdie die BEGIN
  PATCH_IF !VARIABLE_IS_SET $ax1h10("%resref%" "%i%") BEGIN
	INSERT_BYTES fx_off + 0x30*num_fx 0x30
	WRITE_SHORT  fx_off + 0x30*num_fx 177
	WRITE_BYTE   fx_off + 0x30*num_fx + 0x2 2
	WRITE_LONG   fx_off + 0x30*num_fx + 0x4 4
	WRITE_LONG   fx_off + 0x30*num_fx + 0x8 3
	WRITE_BYTE   fx_off + 0x30*num_fx + 0xc 1
	WRITE_BYTE   fx_off + 0x30*num_fx + 0xd 2
	WRITE_BYTE   fx_off + 0x30*num_fx + 0x12 100
	WRITE_ASCIIE fx_off + 0x30*num_fx + 0x14 "%resref%" #8
	num_l_fx += 1
  END
END
WRITE_SHORT ab_off + 0x38*i + 0x1e num_l_fx
num_fx += num_l_fx
 END
BUT_ONLY

 

The remaining files to be overwritten by Fixpack would probably be harder to patch (and patching those files is probably of even lower priority, if such a thing is possible).

Link to comment
Would it surprise you to know I'm actually a student of chemistry (who hadn't written an honest line of code until I started modding BG2 ~18 months ago)?
That absolutely wins the day. I was a student of chemistry too. Who, coincidentally enough, hadn't written a single line of code until BG modding either :blush:

 

Hey, that makes a total of three chemists in a single thread!

Link to comment

It's nice for you to do this, and I'd certainly suggest passing it along to mod authors who make world map changes on installs where it would be recommended to install the fixpack afterward (so they could just patch it and tell the user to NOT install the fixpack's version), but I can tell you now that this will never be incorporated into the official release. It's too much code that'd have to be maintained for something that I neither use locally (I used to incorporate Cam's changes, but then I decided I didn't like them for some reason, so I no longer bother) nor fully ever looked at all the changes.

 

We'll never modify BAMs (nor MOS nor .exe nor KEY nor TIS nor BMP nor <other binary blob>) via TP2. I totally don't want to ever have to support it.

 

Azuredge was done simply because there was some corruption issue or other (something about the Baldurdash version or whatever that made it easier to copy than to patch). I don't even remember why Cam did it this way, but it could probably be rolled into a patch (if you test it with the Bdash and vanilla versions and it works, it may wind up in a new version (assuming there ever is one), either as a straight copy if I had to do it or if DavidW wanted to rewrite it).

Link to comment
Guest temujin.
It's nice for you to do this, and I'd certainly suggest passing it along to mod authors who make world map changes on installs where it would be recommended to install the fixpack afterward (so they could just patch it and tell the user to NOT install the fixpack's version), but I can tell you now that this will never be incorporated into the official release. It's too much code that'd have to be maintained for something that I neither use locally (I used to incorporate Cam's changes, but then I decided I didn't like them for some reason, so I no longer bother) nor fully ever looked at all the changes.

not sure i follow you here, but just to make sure... the only reason the fixpack has been overwriting the world map all these years was because you didn't like maintining too much code? :D

 

come on now, this is not a good excuse...

 

and if that's the case, why did you & Cam & others bother writing robust code for the rest of the fixpack (since it's obviously too much to maintain)?

 

i noticed BGT has this same overwriting silliness when it comes to the world map with basically the same excuse.

 

seriously, why does patching the world map make people so uncomfortable? :devil:

 

 

it's a matter of principle, devSin. a lot of people look at the fixpack's code as a base for learning and doing things 'the right way' and this base shouldn't contain bad practices. :blush:

Link to comment
Guest temujin.
The code is based on the differences between the fixpack worldmaps and the vanilla worldmap.

are these differences documented somewhere?

 

 

cool stuff, btw.

 

s203.gif

Link to comment
We'll never modify BAMs (nor MOS nor .exe nor KEY nor TIS nor BMP nor <other binary blob>) via TP2. I totally don't want to ever have to support it.
Well, nobody rewrites graphics, only restructures them, so I see no big deal here.

 

seriously, why does patching the world map make people so uncomfortable?
Too much info to deal with, I guess. Even more that with ARE files, though it may depend.
Link to comment
but I can tell you now that this will never be incorporated into the official release.

Yeah, I figured it would never be included anywhere.

Azuredge was done simply because there was some corruption issue or other (something about the Baldurdash version or whatever that made it easier to copy than to patch). I don't even remember why Cam did it this way, but it could probably be rolled into a patch (if you test it with the Bdash and vanilla versions and it works, it may wind up in a new version (assuming there ever is one), either as a straight copy if I had to do it or if DavidW wanted to rewrite it).
As far as I can tell, the corruption issue is merely that the item has 10 effects but only 9 of them are indexed. I think I'll have another look at it to make sure I didn't miss anything and test the resulting file a bit more.
The code is based on the differences between the fixpack worldmaps and the vanilla worldmap.

are these differences documented somewhere?

Well, as you probably know, there are some differences listed in the Fixpack documentation, but that's really just the tip of the iceberg. I wrote some tp2 code to compare two worldmaps, but the unabridged list of differences produced by that is really huge.

Link to comment
As far as I can tell, the corruption issue is merely that the item has 10 effects but only 9 of them are indexed. I think I'll have another look at it to make sure I didn't miss anything and test the resulting file a bit more.
That was the problem with the vanilla item, but I think Cam chose to not patch it in the fixpack because it could be one of several different possible items depending on which mods were installed (of course, the fixpack should go first anyway).

 

not sure i follow you here, but just to make sure... the only reason the fixpack has been overwriting the world map all these years was because you didn't like maintining too much code? ???
No, the reason future updates won't include such a patch is because I refuse to be responsible for it when something goes wrong (and something always does). Not least because even I'm not sure of all the changes that the world map update makes.

 

Keep in mind that none of this new shit even existed when the core work was done. Conditionals had to be packed in dummy WHILE loops (no, FOR was not yet supported) and stuff like that because WeiDU could basically only READ (and Wes had only just fixed the bug where WeiDU would only evaluate patch READs one single time at the very beginning of an action, behavior that heavily influenced a lot of the early code using READ) and WRITE. So matters of principle can suck it. :-)

 

We did what we did because it's what allowed us to get the most fixes out to players with the least occurrence of failures in the limited time we had to devote to it. If people want a "best practices" mecca (which the fixpack can no longer fulfill anyway as the majority of the code is now at least a few years dated), they can start one on the wiki now that it works again.

Link to comment

Updated Azuredge fix:

 

COPY_EXISTING ax1h10.itm override
 READ_LONG  0x64 ab_off
 READ_SHORT 0x68 num_ab
 READ_LONG  0x6a fx_off
 READ_SHORT 0x70 num_fx
 t_num_fx = num_fx
 CLEAR_ARRAY ab_array
 GET_OFFSET_ARRAY ab_array 0x64 4 0x68 2 0 0 0x38
 PHP_EACH ab_array AS int => goa_ab_off BEGIN
CLEAR_ARRAY fx_array
GET_OFFSET_ARRAY2 fx_array goa_ab_off 0x6a 4 0x1e 2 0x20 2 0x30
PHP_EACH fx_array AS int => goa_fx_off BEGIN
  t_num_fx += 1
END
 END
 PATCH_IF 0x72 + num_ab*0x38 + 0x30*t_num_fx < BUFFER_LENGTH BEGIN
DELETE_BYTES 0x72 + num_ab*0x38 + 0x30*t_num_fx BUFFER_LENGTH - (0x72 + num_ab*0x38 + 0x30*t_num_fx)
 END
 FOR (i=0;i<num_fx;i+=1) BEGIN
READ_SHORT fx_off + 0x30*i fx_type
READ_ASCII fx_off + 0x30*i + 0x14 resref
PATCH_IF fx_type = 177 AND "%resref%" STRING_EQUAL_CASE macedisr BEGIN
  DELETE_BYTES fx_off + 0x30*i 0x30
  num_fx -= 1
  i -= 1
  WRITE_SHORT 0x70 num_fx
END
 END
 FOR (i=0;i<num_ab;i+=1) BEGIN
READ_BYTE ab_off + 0x38*i ab_type
PATCH_IF ab_type = 2 BEGIN
  WRITE_SHORT ab_off + 0x30*i + 0x18 1 //1 damage die
  WRITE_BYTE  ab_off + 0x30*i + 0x26 1 //allow str bonus
END
READ_SHORT  ab_off + 0x38*i + 0x1e num_l_fx
WRITE_SHORT ab_off + 0x38*i + 0x20 num_fx
FOR (j=0;j<num_l_fx;j+=1) BEGIN
  READ_SHORT fx_off + 0x30*(j + num_fx) fx_type
  READ_ASCII fx_off + 0x30*(j + num_fx) + 0x14 resref
  PATCH_IF fx_type = 177 BEGIN
	TO_LOWER resref
	SET $ax1h10("%resref%" "%i%") = 1
  END
  PATCH_IF fx_type = 55 BEGIN
	DELETE_BYTES fx_off + 0x30*(j + num_fx) 0x30
	j -= 1
	num_l_fx -= 1
  END
END
PATCH_FOR_EACH resref IN unddam4 mesdie die BEGIN
  PATCH_IF !VARIABLE_IS_SET $ax1h10("%resref%" "%i%") BEGIN
	INSERT_BYTES fx_off + 0x30*num_fx 0x30
	WRITE_SHORT  fx_off + 0x30*num_fx 177
	WRITE_BYTE   fx_off + 0x30*num_fx + 0x2 2
	WRITE_LONG   fx_off + 0x30*num_fx + 0x4 4
	WRITE_LONG   fx_off + 0x30*num_fx + 0x8 3
	WRITE_BYTE   fx_off + 0x30*num_fx + 0xc 1
	WRITE_BYTE   fx_off + 0x30*num_fx + 0xd 2
	WRITE_BYTE   fx_off + 0x30*num_fx + 0x12 100
	WRITE_ASCIIE fx_off + 0x30*num_fx + 0x14 "%resref%" #8
	num_l_fx += 1
  END
END
WRITE_SHORT ab_off + 0x38*i + 0x1e num_l_fx
num_fx += num_l_fx
 END
BUT_ONLY

 

New to this revision is fixed damage and strength allowed for the ranged ability and TO_LOWERing of the resrefs put into the array. There's also some completely gratuitous use of GET_OFFSET_ARRAY, in case anyone's curious.

 

It does nothing untoward if it is installed on top of Baldurdash.

 

Edited to include CLEAR_ARRAY.

Link to comment

  GET_OFFSET_ARRAY ab_array 0x64 4 0x68 2 0 0 0x38
 PHP_EACH ab_array AS int => goa_ab_off BEGIN
GET_OFFSET_ARRAY2 fx_array goa_ab_off 0x6a 4 0x1e 2 0x20 2 0x30
PHP_EACH fx_array AS int => goa_fx_off BEGIN
  t_num_fx += 1
END
 END

 

  CLEAR_ARRAY ab_array
 GET_OFFSET_ARRAY ab_array ITM_V10_HEADERS
 PHP_EACH ab_array AS int => goa_ab_off BEGIN
CLEAR_ARRAY fx_array
GET_OFFSET_ARRAY2 fx_array goa_ab_off ITM_V10_HEAD_EFFECTS
PHP_EACH fx_array AS int => goa_fx_off BEGIN
  t_num_fx += 1
END
 END

CLEAR_ARRAY is vital, as GOA/GOA2 doesn't clear arrays by itself and PHP_EACH doesn't care about what's old and what's not either. If you got 5 effects in the 1st header and 3 in the second then for the 1st you'll be fine, but for the 2nd it'll PHP_EACH 3 real ones and 2 from the first header.

 

 

 

So, while this new stuff leave us free from offsets, it's still a pretty bunch of characters to type. I've managed to reduce slightly the overall amount

// codelib.tph
DEFINE_PATCH_MACRO itm_head BEGIN
 CLEAR_ARRAY itm_head
 GET_OFFSET_ARRAY itm_head ITM_V10_HEADERS
END

DEFINE_PATCH_MACRO effects BEGIN
 CLEAR_ARRAY effects
 GET_OFFSET_ARRAY2 effects head_off ITM_V10_HEAD_EFFECTS
END

//setup.tp2
COPY_EXISTING ~itmname.itm~ ~override~
 LPM itm_head PHP_EACH itm_head AS ind => head_off BEGIN
LPM effects PHP_EACH effects AS ind2 => offset BEGIN
  ... // patch list for effects goes here
END
 END

but apparently LAUNCH_PATCH_LOOP would have been the best

COPY_EXISTING ~itmname.itm~ ~override~
 LPL itm_head BEGIN
LPL effects BEGIN
  ... // patch list for effects goes here
END
 END

Link to comment
CLEAR_ARRAY is vital

Oops.

 

So, while this new stuff leave us free from offsets, it's still a pretty bunch of characters to type.

Yeah, I pretty much only used it because it might help someone else understand how it works.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...