Jump to content

Protection from Fire, Protection From Cold


Recommended Posts

These two spells are missing their level 19 and level 20 spell headers. This patch clones the level 18 header and abilities for both. The stacking bug with these two spells is handled by a separate patch.

 

// protection from fire and protection from cold missing lev 19, 20 abilities
COPY_EXISTING ~spwi319.spl~ ~override~
             ~spwi320.spl~ ~override~
 READ_LONG  0x64 "abil_off"
 READ_SHORT 0x68 "abil_num"
 READ_LONG  0x6a "fx_off"
 SET "delta" = 0
 SET "loops" = 0
 PATCH_IF ("%abil_num%" > 0) BEGIN // grabs last ability (lev 18)
   READ_SHORT (("%fx_off%" - 0x28) + 0x10) "min_lev"
 END
 PATCH_IF ("%min_lev%" < 19) BEGIN
   INSERT_BYTES "%fx_off%" 0x50
   SET "delta" = 2
   READ_LONG  (("%fx_off%" - 0x28)       ) "abil_clone1"
   READ_LONG  (("%fx_off%" - 0x28) + 0x04) "abil_clone2"
   READ_LONG  (("%fx_off%" - 0x28) + 0x08) "abil_clone3"
   READ_LONG  (("%fx_off%" - 0x28) + 0x0c) "abil_clone4"
   READ_LONG  (("%fx_off%" - 0x28) + 0x12) "abil_clone5"
   READ_LONG  (("%fx_off%" - 0x28) + 0x16) "abil_clone6"
   READ_LONG  (("%fx_off%" - 0x28) + 0x1a) "abil_clone7"
   READ_SHORT (("%fx_off%" - 0x28) + 0x1e) "abil_fx_num"
   READ_SHORT (("%fx_off%" - 0x28) + 0x20) "abil_fx_idx"
   READ_LONG  (("%fx_off%" - 0x28) + 0x22) "abil_clone8"
   READ_SHORT (("%fx_off%" - 0x28) + 0x26) "abil_clone9"
 END
 WHILE ("%delta%" > "%loops%") BEGIN // this clones the lev 18 abilities to the two new lev 19, 20 ones
   WRITE_LONG  (("%fx_off%" + (0x28 * "%loops%"))       ) "%abil_clone1%"
   WRITE_LONG  (("%fx_off%" + (0x28 * "%loops%")) + 0x04) "%abil_clone2%"
   WRITE_LONG  (("%fx_off%" + (0x28 * "%loops%")) + 0x08) "%abil_clone3%"
   WRITE_LONG  (("%fx_off%" + (0x28 * "%loops%")) + 0x0c) "%abil_clone4%"
   WRITE_SHORT (("%fx_off%" + (0x28 * "%loops%")) + 0x10) ("%min_lev%" + 1 + "%loops%")
   WRITE_LONG  (("%fx_off%" + (0x28 * "%loops%")) + 0x12) "%abil_clone5%"
   WRITE_LONG  (("%fx_off%" + (0x28 * "%loops%")) + 0x16) "%abil_clone6%"
   WRITE_LONG  (("%fx_off%" + (0x28 * "%loops%")) + 0x1a) "%abil_clone7%"
   WRITE_SHORT (("%fx_off%" + (0x28 * "%loops%")) + 0x1e) "%abil_fx_num%"
   WRITE_SHORT (("%fx_off%" + (0x28 * "%loops%")) + 0x20) ("%abil_fx_idx%" + (("%loops%" + 1) * "%abil_fx_num%"))
   WRITE_LONG  (("%fx_off%" + (0x28 * "%loops%")) + 0x22) "%abil_clone8%"
   WRITE_SHORT (("%fx_off%" + (0x28 * "%loops%")) + 0x26) "%abil_clone9%"
   SET "loops" = ("%loops%" + 1)
 END
 WRITE_SHORT 0x68 ("%abil_num%" + "%delta%")
 SET "fx_off" = ("%fx_off%" + (0x28 * "%delta%"))
 WRITE_LONG  0x6a "%fx_off%"
 INSERT_BYTES ("%fx_off%" + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) (0x30 * (2 * "%abil_fx_num%"))
 WHILE ("%delta%" > 0) BEGIN
   SET "loops" = "%abil_fx_num%"
   WHILE ("%loops%" > 0) BEGIN
     SET "loops" = ("%loops%" - 1)
     READ_LONG   ("%fx_off%" + 0x00 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_LONG  ("%fx_off%" + 0x00 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG   ("%fx_off%" + 0x04 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_LONG  ("%fx_off%" + 0x04 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG   ("%fx_off%" + 0x08 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_LONG  ("%fx_off%" + 0x08 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_SHORT  ("%fx_off%" + 0x0c + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_SHORT ("%fx_off%" + 0x0c + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG  ("%fx_off%" + 0x0e + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "duration"
     PATCH_IF ("%duration%" > 5) BEGIN
       WRITE_LONG ("%fx_off%" + 0x0e + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) ("%duration%" + ("%delta%" * 60))
     END ELSE BEGIN
       WRITE_LONG ("%fx_off%" + 0x0e + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%duration%"
     END
     READ_SHORT  ("%fx_off%" + 0x12 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_SHORT ("%fx_off%" + 0x12 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG   ("%fx_off%" + 0x14 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_LONG  ("%fx_off%" + 0x14 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG   ("%fx_off%" + 0x18 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_LONG  ("%fx_off%" + 0x18 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG   ("%fx_off%" + 0x1c + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_LONG  ("%fx_off%" + 0x1c + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG   ("%fx_off%" + 0x20 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_LONG  ("%fx_off%" + 0x20 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG   ("%fx_off%" + 0x24 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_LONG  ("%fx_off%" + 0x24 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG   ("%fx_off%" + 0x28 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_LONG  ("%fx_off%" + 0x28 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG   ("%fx_off%" + 0x2c + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone"
     WRITE_LONG  ("%fx_off%" + 0x2c + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
   END
   SET "delta" = ("%delta%" - 1)
 END
 BUT_ONLY_IF_IT_CHANGES

Link to comment
Check my patches; this can all be done with READ_ASCII (range) and WRITE_EVALUATED_ASCII #range now (you can copy and write the entire effect list, rather than each field).

I considered that, but would WeiDU's propensity for changing lowercase to uppercase affect this if it thought these variables were ASCII (i.e. if it hits a random byte that is a letter value)? If not, then hot damn, that saves a ton of steps.

Link to comment

No. WeiDU copies the "string" as-is, and performs absolutely no case transformation on the value read or written.

 

The copy is 8-bit clean, so all characters are preserved (I usually refer to the use of ()s as READ_RANGE, and #s as WRITE_RANGE, as there's no limit to what you can copy with the ASCII variants).

 

I don't know if the version of my fix pack you have is still doing 4-byte read/writes with it's %cloneEffect%s (I think I last updated the package sometime this month (I edit the old thread); it will be doing the read/write ranges for sure).

Link to comment

See how much simpler it is now? :) Included in alpha 3.

 

// protection from fire and protection from cold missing lev 19, 20 abilities
COPY_EXISTING ~spwi319.spl~ ~override~
             ~spwi320.spl~ ~override~
 READ_LONG  0x64 "abil_off"
 READ_SHORT 0x68 "abil_num"
 READ_LONG  0x6a "fx_off"
 SET "delta" = 0
 SET "loops" = 0
 PATCH_IF ("%abil_num%" > 0) BEGIN // grabs last ability (lev 18)
   READ_SHORT (("%fx_off%" - 0x28) + 0x10) "min_lev"
 END
 PATCH_IF ("%min_lev%" < 19) BEGIN
   INSERT_BYTES "%fx_off%" 0x50
   SET "delta" = 2
   READ_ASCII (("%fx_off%" - 0x28)       ) "abil_clone" (0x28)
   READ_SHORT (("%fx_off%" - 0x28) + 0x1e) "abil_fx_num"
   READ_SHORT (("%fx_off%" - 0x28) + 0x20) "abil_fx_idx"
 END
 WHILE ("%delta%" > "%loops%") BEGIN // this clones the lev 18 abilities to the two new lev 19, 20 ones
   WRITE_EVALUATED_ASCII (("%fx_off%" + (0x28 * "%loops%"))       ) "%abil_clone%"
   WRITE_SHORT (("%fx_off%" + (0x28 * "%loops%")) + 0x10) ("%min_lev%" + 1 + "%loops%")
   WRITE_SHORT (("%fx_off%" + (0x28 * "%loops%")) + 0x1e) "%abil_fx_num%"
   WRITE_SHORT (("%fx_off%" + (0x28 * "%loops%")) + 0x20) ("%abil_fx_idx%" + (("%loops%" + 1) * "%abil_fx_num%"))
   SET "loops" = ("%loops%" + 1)
 END
 WRITE_SHORT 0x68 ("%abil_num%" + "%delta%")
 SET "fx_off" = ("%fx_off%" + (0x28 * "%delta%"))
 WRITE_LONG  0x6a "%fx_off%"
 INSERT_BYTES ("%fx_off%" + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) (0x30 * (2 * "%abil_fx_num%"))
 WHILE ("%delta%" > 0) BEGIN
   SET "loops" = "%abil_fx_num%"
   WHILE ("%loops%" > 0) BEGIN
     SET "loops" = ("%loops%" - 1)
     READ_ASCII  ("%fx_off%" + 0x00 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone" (0x30)
     WRITE_EVALUATED_ASCII ("%fx_off%" + 0x00 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
     READ_LONG  ("%fx_off%" + 0x0e + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "duration"
     PATCH_IF ("%duration%" > 5) BEGIN
       WRITE_LONG ("%fx_off%" + 0x0e + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) ("%duration%" + ("%delta%" * 60))
     END ELSE BEGIN
       WRITE_LONG ("%fx_off%" + 0x0e + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%duration%"
     END
   END
   SET "delta" = ("%delta%" - 1)
 END
 BUT_ONLY_IF_IT_CHANGES

Link to comment

Archived

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

×
×
  • Create New...