Jump to content

Spell shield/Protection from Magic Energy Icons


Recommended Posts

Credit where credit's due: this bug was found by the Refinements guys (TG Maestro, Littiz, and the bigg) and fixed in their mod.

 

The spell shield opcode is hardcoded to display portrait icon #73. Unfortunately, #73 is the protection from magic energy icon and #123 is the spell shield icon. Since this hardcoded, we work around it by swapping the icons in the bam file and any references to them in spells and items--which turns out to be one spell.

 

// spell shield is hardcoded to display icon #73 which is currently protection from magical energy; need to swap
// see also statdesc.2da, spwi606.spl
COPY ~bg2fixpack/bam/states.bam~  ~override~ // game screen portrait icons
COPY ~bg2fixpack/bam/states2.bam~ ~override~ // record sheet icons

// spell shield is hardcoded to display icon #73 which is currently protection from magical energy; need to swap
// see also states.bam, states2.bam, spwi606.spl
COPY_EXISTING ~statdesc.2da~ ~override~
 REPLACE_TEXTUALLY ~^\(73[%tab% ]+\)[0-9]+~ ~\126228~
 REPLACE_TEXTUALLY ~^\(123[%tab% ]+\)[0-9]+~ ~\18286~
 BUT_ONLY_IF_IT_CHANGES

// spell shield is hardcoded to display icon #73 which is currently protection from magical energy; need to swap
// see also statdesc.2da, states.bam, states2.bam
COPY_EXISTING ~spwi606.spl~ ~override~
 READ_LONG  0x64 "abil_off"
 READ_SHORT 0x68 "abil_num"
 READ_LONG  0x6a "fx_off"
 FOR (index = 0; index < abil_num; index = index + 1) BEGIN
READ_SHORT ("%abil_off%" + 0x1e + (0x28 * "%index%")) "abil_fx_num"
READ_SHORT ("%abil_off%" + 0x20 + (0x28 * "%index%")) "abil_fx_idx"
FOR (index2 = 0; index2 < abil_fx_num; index2 = index2 + 1) BEGIN
  READ_SHORT ("%fx_off%" +		(0x30 * ("%abil_fx_idx%" + "%index2%"))) "opcode"
  READ_LONG  ("%fx_off%" + 0x08 + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "icon"
  PATCH_IF (("%opcode%" = 142) AND ("%icon%" = 73)) BEGIN // display old pro-magic energy icon
	WRITE_LONG ("%fx_off%" + 0x08 + (0x30 * ("%abil_fx_idx%" + "%index2%"))) 123 // change to new pro-magic energy icon
  END
END
 END
 BUT_ONLY_IF_IT_CHANGES

Link to comment

I actually standardized the dispellability too (I hope you don't need to rewrite that patch!) :)

COPY_EXISTING ~spwi519.spl~  ~override~
 READ_SHORT  0x68 "hc" ELSE 0x0
 PATCH_IF ("hc" = 0x1) THEN BEGIN
READ_LONG   0x64 "ho"
READ_LONG   0x6a "eo"
READ_SHORT ("ho" + 0x1e) "ec"
READ_ASCII "ho" ~hd~ (0x28)
READ_ASCII "eo" ~fx~ (0x30 * "ec")
DELETE_BYTES 0x72 (SOURCE_SIZE - 0x72)
SET "ei" = 0x00
WRITE_LONG  0x6e 0x00
SET "hc" = 0x14
WRITE_SHORT 0x68 "hc"
SET "eo" = ("ho" + (0x28 * "hc"))
WRITE_LONG 0x6a "eo"
INSERT_BYTES "ho" (0x28 * "hc")
FOR ("i1" = 0x00; "i1" < "hc"; "i1" += 0x01) BEGIN
  WRITE_ASCIIE ("ho" + ("i1" * 0x28) + 0x00) ~%hd%~
  WRITE_SHORT  ("ho" + ("i1" * 0x28) + 0x10) ("i1" + 0x1)
  WRITE_SHORT  ("ho" + ("i1" * 0x28) + 0x20) "ei"
  SET "ei" += "ec"
END
INSERT_BYTES "eo" (0x30 * "ec" * "hc")
INNER_PATCH_SAVE ~fx~ ~%fx%~ BEGIN
  FOR ("i1" = 0x00; "i1" < (0x30 * "ec"); "i1" += 0x30) BEGIN
	WRITE_BYTE ("i1" + 0x0d) 0x00 // not dispellable
  END
END
FOR ("i1" = 0x00; "i1" < "hc"; "i1" += 0x01) BEGIN
  INNER_PATCH_SAVE ~fx~ ~%fx%~ BEGIN
	FOR ("i2" = 0x00; "i2" < (0x30 * "ec"); "i2" += 0x30) BEGIN
	  READ_LONG  ("i2" + 0x0e) "dr"
	  WRITE_LONG ("i2" + 0x0e) ("dr" > 0x6 ? (("i1" + 0x01) * 0x12) : "dr")
	END
  END
  WRITE_ASCIIE ("eo" + ("i1" * 0x30 * "ec")) ~%fx%~
END
 END
BUT_ONLY

 

/edit

 

bah, what am I thinking, of course you saved a copy. Never mind.

Link to comment

Archived

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

×
×
  • Create New...