COPY_EXISTING ~SAVEWIZ.2DA~ ~override/SAVEWIZ.2DA~
REPLACE_TEXTUALLY ~2DA V1.0~ ~2DA_V1.0~
REPLACE_TEXTUALLY ~ 1 ~ ~dummy 1 ~
SET "col" = 40
WHILE ("%col%" > 20) BEGIN
SET_2DA_ENTRY 1 "%col%" 41 ~8~
SET_2DA_ENTRY 2 "%col%" 41 ~3~
SET_2DA_ENTRY 3 "%col%" 41 ~5~
SET_2DA_ENTRY 4 "%col%" 41 ~7~
SET_2DA_ENTRY 5 "%col%" 41 ~4~
SET "col" = ("%col%" - 1)
END
REPLACE_TEXTUALLY ~2DA_V1.0~ ~2DA V1.0~
REPLACE_TEXTUALLY ~dummy~ ~ ~The WHILE loop does the real work, and it's framed with a couple of R_T to protect the header formating. The whole snippet did alright for me, but when I sent it to a friend, he complained that the R_T part didn't work and the header formating was screwed up (he's at v153, while I'm still at v148 (being a Mac head, I didn't dare to compile a new version yet)). Any comments/suggestions? Then there's these two snippets. Both yield the same result (changing the color of the Dragon Helm to something easier on the eyes) and work alright for me:
COPY_EXISTING ~helm21.itm~ ~override/helm21.itm~
READ_SHORT 0x6A "fxoffset"
READ_SHORT 0x70 "#fx"
WHILE ("%#fx%" > 0) BEGIN
READ_SHORT ("%fxoffset%" + ("%#fx%" - 1) * 0x30) "fxtype"
READ_LONG ("%fxoffset%" + ("%#fx%" - 1) * 0x30 + 0x8) "fxpara2"
SET "patch" = 1
WHILE ("%fxtype%" = 7)
AND (("%fxpara2%" = 53) OR ("%fxpara2%" = 48))
AND "%patch%" BEGIN
WRITE_LONG ("%fxoffset%" + ("%#fx%" - 1) * 0x30 + 0x4) 0x65
SET "patch" = 0
END
SET "#fx" = ("%#fx%" - 1)
ENDThe first one, above, closely follows Idobek's wonderful tutorial. Yet, there's some redundancy in there, namely four "%#fx%" - 1. So, I slightly changed it, into this:COPY_EXISTING ~helm21.itm~ ~override/helm21.itm~
READ_SHORT 0x6A "fxoffset"
READ_SHORT 0x70 "#fx"
WHILE ("%#fx%" > 0) BEGIN
SET "patch" = 1
SET "#fx" = ("%#fx%" - 1)
READ_SHORT ("%fxoffset%" + "%#fx%" * 0x30) "fxtype"
READ_LONG ("%fxoffset%" + "%#fx%" * 0x30 + 0x8) "fxpara2"
WHILE ("%fxtype%" = 7)
AND (("%fxpara2%" = 53) OR ("%fxpara2%" = 48))
AND "%patch%" BEGIN
WRITE_LONG ("%fxoffset%" + "%#fx%" * 0x30 + 0x4) 0x65
SET "patch" = 0
END
ENDHere I've moved the SET "#fx" = ("%#fx%" - 1) right to the beginning of the loop, so that I need to do the calculation only once. It seems to be working for me, yet the question remains: how safe is this? Can I be certain that the SET is always executed before the subsequent READ commands? Any comments/suggestions?Cheers, Armin


Find content
Not Telling
