Jump to content

Spell level immunity items


Nythrun

Recommended Posts

COPY_EXISTING ~aurstaf.itm~  ~override~ // Aurumach Rilmani's Staff of the Ram
		  ~bazpatrg.itm~ ~override~ // Ring (unused)
		  ~demilich.itm~ ~override~ // Demilich immunity item
		  ~demogorg.itm~ ~override~ // Demogorgon's Weapon
		  ~finmel01.itm~ ~override~ // Amelyssan's immunity item
		  ~fsspir.itm~   ~override~ // Helmite Ghost immunity item
		  ~holdring.itm~ ~override~ // Ring (several ToB statues)
		  ~invulner.itm~ ~override~ // Ring (several unkillable ToB critters)
		  ~lich.itm~	 ~override~ // Lich immunity item
	   // ~mageamul.itm~ ~override~ // Necklace (unused, and too much of a mess to patch)
		  ~misc73.itm~   ~override~ // the Horn of Kazgaroth
		  ~potn33.itm~   ~override~ // Potion of Magic Blocking (unused)
		  ~rakring.itm~  ~override~ // Rakshasa immunity item
		  ~ravag03.itm~  ~override~ // the Ravager's immunity item
		  ~scrl07.itm~   ~override~ // Protection from Magic Scroll
		  ~spellh01.itm~ ~override~ // Spellhaunt immunity item
 PATCH_IF (%SOURCE_SIZE% > 0x71) THEN BEGIN
READ_LONG  0x64 "ho"
READ_SHORT 0x68 "hc"
READ_LONG  0x6a "eo"
READ_SHORT 0x6e "gi"
READ_SHORT 0x70 "gc"
PATCH_IF ("ho" > "eo") THEN BEGIN
  READ_ASCII   "ho"   "headers"	  (0x38 * "hc")
  DELETE_BYTES "ho"   (0x38 * "hc")
  INSERT_BYTES 0x72   (0x38 * "hc")
  WRITE_ASCIIE 0x72   "%headers%"	(0x38 * "hc")
  SET		  "ho" = 0x72
  WRITE_LONG   0x64   "ho"
  SET		  "eo" = ("eo" + (0x38 * "hc"))
  WRITE_LONG   0x6a   "eo"
END // PATCH_IF nonstandard order
// start looping though each set of abilities
FOR ("i" = 0; "i" < ("hc" + 1); "i" += 1) BEGIN
  PATCH_IF ("i" = "hc") THEN BEGIN
	SET  "ec" = "gc"
	SET  "ei" = "gi"
  END ELSE BEGIN
	READ_SHORT ("ho" + (0x38 * "i") + 0x1e) "ec" ELSE 0
	READ_SHORT ("ho" + (0x38 * "i") + 0x20) "ei" ELSE 0
  END // reading count and index for each chunk of effects
  SET "added_fx" = 0
  // define variables to track what's already present
  SET "l1" = 0
  SET "l2" = 0
  SET "l3" = 0
  SET "l4" = 0
  SET "l5" = 0
  SET "l6" = 0
  SET "l7" = 0
  SET "l8" = 0
  SET "l9" = 0
  SET "entangle" = 0
  SET "silence" = 0
  SET "web" = 0
  SET "stinking_cloud" = 0
  SET "call_lightning" = 0
  SET "glyph_of_warding" = 0
  SET "holy_smite" = 0
  SET "unholy_blight" = 0
  SET "skull_trap" = 0
  SET "cloud_kill" = 0
  SET "blade_barrier" = 0
  SET "death_fog" = 0
  SET "firestorm" = 0
  SET "symbol_fear_divine" = 0
  SET "symbol_stun_divine" = 0
  SET "symbol_death_divine" = 0
  SET "globe_of_blades" = 0
  SET "delayed_blast_fireball" = 0
  SET "incendiary_cloud" = 0
  SET "symbol_fear_arcane" = 0
  SET "symbol_stun_arcane" = 0
  SET "symbol_death_arcane" = 0
  SET "meteor_swarm" = 0
  SET "wish_meteor_swarm" = 0
  SET "wish_knockback" = 0
  SET "wish_horrid_wilting" = 0
  SET "wish_silence" = 0
  FOR ("j" = 0; "j" < "ec"; "j" += 1) BEGIN
	READ_SHORT		(("eo" + (0x30 * ("j" + "ei"))) + 0x00) "opcode"
	READ_LONG		 (("eo" + (0x30 * ("j" + "ei"))) + 0x04) "level"
	READ_ASCII		(("eo" + (0x30 * ("j" + "ei"))) + 0x14) "resref"
	PATCH_IF		  (("opcode" = 0x66) AND
					   ("level" = 0x01)) THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template1" (0x30)
	  SET "l1" = 1
	END ELSE PATCH_IF (("opcode" = 0x66) AND
					   ("level" = 0x02)) THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template2" (0x30)
	  SET "l2" = 1
	END ELSE PATCH_IF (("opcode" = 0x66) AND
					   ("level" = 0x03)) THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template3" (0x30)
	  SET "l3" = 1
	END ELSE PATCH_IF (("opcode" = 0x66) AND
					   ("level" = 0x04))  THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template4" (0x30)
	  SET "l4" = 1
	END ELSE PATCH_IF (("opcode" = 0x66) AND
					   ("level" = 0x05))  THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template5" (0x30)
	  SET "l5" = 1
	END ELSE PATCH_IF (("opcode" = 0x66) AND
					   ("level" = 0x06)   AND
					   ("%SOURCE_RES%" STRING_COMPARE_CASE "potn33")) THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template6" (0x30)
	  SET "l6" = 1
	END ELSE PATCH_IF (("opcode" = 0x66) AND
					   ("level" = 0x07)   AND
					   ("%SOURCE_RES%" STRING_COMPARE_CASE "potn33")) THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template7" (0x30)
	  SET "l7" = 1
	END ELSE PATCH_IF (("opcode" = 0x66) AND
					   ("level" = 0x08)   AND
					   ("%SOURCE_RES%" STRING_COMPARE_CASE "potn33")) THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template8" (0x30)
	  SET "l8" = 1
	END ELSE PATCH_IF (("opcode" = 0x66) AND
					   ("level" = 0x09)   AND
					   ("%SOURCE_RES%" STRING_COMPARE_CASE "potn33")) THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template9" (0x30)
	  SET "l9" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr105")) THEN BEGIN
	  SET "entangle" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr211")) THEN BEGIN
	  SET "silence" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi213")) THEN BEGIN
	  SET "web" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi215")) THEN BEGIN
	  SET "stinking_cloud" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr302")) THEN BEGIN
	  SET "call_lightning" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr304")) THEN BEGIN
	  SET "glyph_of_warding" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr313")) THEN BEGIN
	  SET "holy_smite" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr314")) THEN BEGIN
	  SET "unholy_blight" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi313")) THEN BEGIN
	  SET "skull_trap" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi502")) THEN BEGIN
	  SET "cloud_kill" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr603d")) THEN BEGIN
	  SET "blade_barrier" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi614")) THEN BEGIN
	  SET "death_fog" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr705")) THEN BEGIN
	  SET "firestorm" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr706")) THEN BEGIN
	  SET "symbol_fear_divine" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr718")) THEN BEGIN
	  SET "symbol_stun_divine" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr719")) THEN BEGIN
	  SET "symbol_death_divine" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr725d")) THEN BEGIN
	  SET "globe_of_blades" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi712")) THEN BEGIN
	  SET "delayed_blast_fireball" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi810")) THEN BEGIN
	  SET "incendiary_cloud" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi811")) THEN BEGIN
	  SET "symbol_fear_arcane" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi816")) THEN BEGIN
	  SET "symbol_stun_arcane" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi817")) THEN BEGIN
	  SET "symbol_death_arcane" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi911")) THEN BEGIN
	  SET "meteor_swarm" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwish25")) THEN BEGIN
	  SET "wish_meteor_swarm" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwish27")) THEN BEGIN
	  SET "wish_knockback" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwish32")) THEN BEGIN
	  SET "wish_horrid_wilting" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwish35")) THEN BEGIN
	  SET "wish_silence" = 1
	END
  END // FOR j, scanning effects
  // adding supplementary immunities if not present
  PATCH_IF ("l9" = 1) THEN BEGIN
	PATCH_IF ("wish_silence" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template9%"
	  WRITE_ASCII  (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwish35~
	  SET "added_fx" += 1
	END
	PATCH_IF ("wish_horrid_wilting" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template9%"
	  WRITE_ASCII  (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwish32~
	  SET "added_fx" += 1
	END
	PATCH_IF ("wish_knockback" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template9%"
	  WRITE_ASCII  (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwish27~
	  SET "added_fx" += 1
	END
	PATCH_IF ("wish_meteor_swarm" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template9%"
	  WRITE_ASCII  (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwish25~
	  SET "added_fx" += 1
	END
	PATCH_IF ("meteor_swarm" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template9%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi911~
	  SET "added_fx" += 1
	END
  END
  PATCH_IF ("l8" = 1) THEN BEGIN
	PATCH_IF ("symbol_death_arcane" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template8%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi817~
	  SET "added_fx" += 1
	END
	PATCH_IF ("symbol_stun_arcane" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template8%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi816~
	  SET "added_fx" += 1
	END
	PATCH_IF ("symbol_fear_arcane" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template8%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi811~
	  SET "added_fx" += 1
	END
	PATCH_IF ("incendiary_cloud" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template8%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi810~
	  SET "added_fx" += 1
	END
  END
  PATCH_IF ("l7" = 1) THEN BEGIN
	PATCH_IF ("delayed_blast_fireball" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template7%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi712~
	  SET "added_fx" += 1
	END
	PATCH_IF ("globe_of_blades" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template7%"
	  WRITE_ASCII  (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr725d~
	  SET "added_fx" += 1
	END
	PATCH_IF ("symbol_death_divine" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template7%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr719~
	  SET "added_fx" += 1
	END
	PATCH_IF ("symbol_stun_divine" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template7%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr718~
	  SET "added_fx" += 1
	END
	PATCH_IF ("symbol_fear_divine" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template7%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr706~
	  SET "added_fx" += 1
	END
	PATCH_IF ("firestorm" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template7%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr705~
	  SET "added_fx" += 1
	END
  END
  PATCH_IF ("l6" = 1) THEN BEGIN
	PATCH_IF ("death_fog" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template6%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi614~
	  SET "added_fx" += 1
	END
	PATCH_IF ("blade_barrier" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template6%"
	  WRITE_ASCII  (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr603d~
	  SET "added_fx" += 1
	END
  END
  PATCH_IF ("l5" = 1) THEN BEGIN
	PATCH_IF ("cloud_kill" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template5%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi502~
	  SET "added_fx" += 1
	END
  END
  PATCH_IF ("l3" = 1) THEN BEGIN
	PATCH_IF ("skull_trap" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template3%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi313~
	  SET "added_fx" += 1
	END
	PATCH_IF ("unholy_blight" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template3%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr314~
	  SET "added_fx" += 1
	END
	PATCH_IF ("holy_smite" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template3%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr313~
	  SET "added_fx" += 1
	END
	PATCH_IF ("glyph_of_warding" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template3%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr304~
	  SET "added_fx" += 1
	END
	PATCH_IF ("call_lightning" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template3%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr302~
	  SET "added_fx" += 1
	END
  END
  PATCH_IF ("l2" = 1) THEN BEGIN
	PATCH_IF ("stinking_cloud" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template2%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi215~
	  SET "added_fx" += 1
	END
	PATCH_IF ("web" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template2%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi213~
	  SET "added_fx" += 1
	END
	PATCH_IF ("silence" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template2%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr211~
	  SET "added_fx" += 1
	END
  END
  PATCH_IF ("l1" = 1) THEN BEGIN
	PATCH_IF ("entangle" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template1%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr105~
	  SET "added_fx" += 1
	END
  END
  //
  PATCH_IF ("added_fx" > 0) THEN BEGIN
	FOR ("k" = 0; "k" < "added_fx"; "k" += 1) BEGIN
	  WRITE_SHORT  (("eo" + (0x30 * ("ec" + "ei" + "k"))) + 0x00) 0xce
	  WRITE_LONG   (("eo" + (0x30 * ("ec" + "ei" + "k"))) + 0x04) 0xffffffff
	  WRITE_LONG   (("eo" + (0x30 * ("ec" + "ei" + "k"))) + 0x08) 0x00
	END
  END
  // wrap up by recounting effects
  SET "ec" = ("ec" + "added_fx")
  PATCH_IF (("added_fx" > 0) AND ("i" = "hc")) THEN BEGIN
	WRITE_SHORT 0x70 "ec"
	FOR ("l" = 0; "l" < "hc"; "l" += 1) BEGIN
	  READ_SHORT  ("ho" + (0x38 * "l") + 0x20) "ci"
	  WRITE_SHORT ("ho" + (0x38 * "l") + 0x20) ("ci" + "added_fx")
	END // FOR l, re-index each header
  END ELSE PATCH_IF (("added_fx" > 0) AND ("i" < "hc")) THEN BEGIN
	WRITE_SHORT ("ho" + (0x38 * "i") + 0x1e) "ec"
	FOR ("m" = ("i" + 1); "m" < "hc"; "m" += 1) BEGIN
	  READ_SHORT  ("ho" + (0x38 * "m") + 0x20) "ci"
	  WRITE_SHORT ("ho" + (0x38 * "m") + 0x20) ("ci" + "added_fx")
	END // FOR m, re-index each header
  END // second part of PATCH_IF to recount extended effects
END // FOR i1, extended header/global effect scan
 END // PATCH_IF filesize sanity check
BUT_ONLY_IF_IT_CHANGES // it just might, you never know

Link to comment

BAZPATRG - The patsy ring. Unused.

MAGEAMUL - Leftover crud. Unused.

 

The only spells I bother with for these are

WRITE_ASCII ao + 0x14 SPWI911
WRITE_ASCII ao + 0x14 SPWI817
WRITE_ASCII ao + 0x14 SPWI816
WRITE_ASCII ao + 0x14 SPWI812
WRITE_ASCII ao + 0x14 SPWI811
WRITE_ASCII ao + 0x14 SPWI810
WRITE_ASCII ao + 0x14 SPWI712
WRITE_ASCII ao + 0x14 SPWI711
WRITE_ASCII ao + 0x14 SPWI614
WRITE_ASCII ao + 0x14 SPWI502
WRITE_ASCII ao + 0x14 SPWI421
WRITE_ASCII ao + 0x14 SPWI404
WRITE_ASCII ao + 0x14 SPWI313
WRITE_ASCII ao + 0x14 SPWI215
WRITE_ASCII ao + 0x14 SPWI213
WRITE_ASCII ao + 0x14 SPWI101
WRITE_ASCII ao + 0x14 SPPR720
WRITE_ASCII ao + 0x14 SPPR719
WRITE_ASCII ao + 0x14 SPPR718
WRITE_ASCII ao + 0x14 SPPR706
WRITE_ASCII ao + 0x14 SPPR705
WRITE_ASCII ao + 0x14 SPPR314
WRITE_ASCII ao + 0x14 SPPR313
WRITE_ASCII ao + 0x14 SPPR304
WRITE_ASCII ao + 0x14 SPPR105

It is hopefully safe to assume that no other PC spells will bypass the level immunity, but I can't remember if I artificially limited the selection to only those I felt reasonable (or I just didn't want a billion effects for each spell or item).

Link to comment

Yes.

Probably easier just to repost the lot, then.

COPY_EXISTING ~jwglobe.spl~  ~override~ // Demogorgon Globe of Invulneribility
		  ~spwi406.spl~  ~override~ // Minor Globe of Invulneribility
		  ~spwi602.spl~  ~override~ // Globe of Invulneribility
		  ~spwm126.spl~  ~override~ // Wild Mage Minor Globe, who knows what it's meant to do
 PATCH_IF (%SOURCE_SIZE% > 0x71) THEN BEGIN
READ_LONG  0x64 "ho"
READ_SHORT 0x68 "hc"
READ_LONG  0x6a "eo"
READ_SHORT 0x6e "gi"
READ_SHORT 0x70 "gc"
FOR ("i" = 0; "i" < ("hc" + 1); "i" += 1) BEGIN
  PATCH_IF ("i" = "hc") THEN BEGIN
	SET  "ec" = "gc"
	SET  "ei" = "gi"
  END ELSE BEGIN
	READ_SHORT ("ho" + (0x28 * "i") + 0x1e) "ec" ELSE 0
	READ_SHORT ("ho" + (0x28 * "i") + 0x20) "ei" ELSE 0
  END
  SET "added_fx" = 0
  SET "l1" = 0
  SET "l2" = 0
  SET "l3" = 0
  SET "entangle" = 0
  SET "silence" = 0
  SET "web" = 0
  SET "stinking_cloud" = 0
  SET "call_lightning" = 0
  SET "glyph_of_warding" = 0
  SET "holy_smite" = 0
  SET "unholy_blight" = 0
  SET "skull_trap" = 0
  FOR ("j" = 0; "j" < "ec"; "j" += 1) BEGIN
	READ_SHORT		(("eo" + (0x30 * ("j" + "ei"))) + 0x00) "opcode"
	READ_LONG		 (("eo" + (0x30 * ("j" + "ei"))) + 0x04) "level"
	READ_ASCII		(("eo" + (0x30 * ("j" + "ei"))) + 0x14) "resref"
	PATCH_IF		  (("opcode" = 0x66) AND
					   ("level" = 0x01)) THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template1" (0x30)
	  SET "l1" = 1
	END ELSE PATCH_IF (("opcode" = 0x66) AND
					   ("level" = 0x02)) THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template2" (0x30)
	  SET "l2" = 1
	END ELSE PATCH_IF (("opcode" = 0x66) AND
					   ("level" = 0x03)) THEN BEGIN
	  READ_ASCII	   ("eo" + (0x30 * ("j" + "ei"))) "template3" (0x30)
	  SET "l3" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr105")) THEN BEGIN
	  SET "entangle" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr211")) THEN BEGIN
	  SET "silence" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi213")) THEN BEGIN
	  SET "web" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi215")) THEN BEGIN
	  SET "stinking_cloud" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr302")) THEN BEGIN
	  SET "call_lightning" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr304")) THEN BEGIN
	  SET "glyph_of_warding" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr313")) THEN BEGIN
	  SET "holy_smite" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "sppr314")) THEN BEGIN
	  SET "unholy_blight" = 1
	END ELSE PATCH_IF (("opcode" = 0xce) AND
					   (NOT "%resref%" STRING_COMPARE_CASE "spwi313")) THEN BEGIN
	  SET "skull_trap" = 1
	END
  END // FOR j, scanning effects
  // adding supplementary immunities if not present
  PATCH_IF ("l3" = 1) THEN BEGIN
	PATCH_IF ("skull_trap" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template3%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi313~
	  SET "added_fx" += 1
	END
	PATCH_IF ("unholy_blight" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template3%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr314~
	  SET "added_fx" += 1
	END
	PATCH_IF ("holy_smite" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template3%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr313~
	  SET "added_fx" += 1
	END
	PATCH_IF ("glyph_of_warding" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template3%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr304~
	  SET "added_fx" += 1
	END
	PATCH_IF ("call_lightning" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template3%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr302~
	  SET "added_fx" += 1
	END
  END
  PATCH_IF ("l2" = 1) THEN BEGIN
	PATCH_IF ("stinking_cloud" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template2%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi215~
	  SET "added_fx" += 1
	END
	PATCH_IF ("web" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template2%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~spwi213~
	  SET "added_fx" += 1
	END
	PATCH_IF ("silence" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template2%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr211~
	  SET "added_fx" += 1
	END
  END
  PATCH_IF ("l1" = 1) THEN BEGIN
	PATCH_IF ("entangle" = 0) THEN BEGIN
	  INSERT_BYTES (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) 0x30
	  WRITE_ASCIIE (("eo" + (0x30 * ("ec" + "ei"))) + 0x00) "%template1%"
	  WRITE_ASCIIT (("eo" + (0x30 * ("ec" + "ei"))) + 0x14) ~sppr105~
	  SET "added_fx" += 1
	END
  END
  PATCH_IF ("added_fx" > 0) THEN BEGIN
	FOR ("k" = 0; "k" < "added_fx"; "k" += 1) BEGIN
	  WRITE_SHORT  (("eo" + (0x30 * ("ec" + "ei" + "k"))) + 0x00) 0xce
	  WRITE_LONG   (("eo" + (0x30 * ("ec" + "ei" + "k"))) + 0x04) 0xffffffff
	  WRITE_LONG   (("eo" + (0x30 * ("ec" + "ei" + "k"))) + 0x08) 0x00
	END
  END
  SET "ec" = ("ec" + "added_fx")
  PATCH_IF (("added_fx" > 0) AND ("i" = "hc")) THEN BEGIN
	WRITE_SHORT 0x70 "ec"
	FOR ("l" = 0; "l" < "hc"; "l" += 1) BEGIN
	  READ_SHORT  ("ho" + (0x28 * "l") + 0x20) "ci"
	  WRITE_SHORT ("ho" + (0x28 * "l") + 0x20) ("ci" + "added_fx")
	END
  END ELSE PATCH_IF (("added_fx" > 0) AND ("i" < "hc")) THEN BEGIN
	WRITE_SHORT ("ho" + (0x28 * "i") + 0x1e) "ec"
	FOR ("m" = ("i" + 1); "m" < "hc"; "m" += 1) BEGIN
	  READ_SHORT  ("ho" + (0x28 * "m") + 0x20) "ci"
	  WRITE_SHORT ("ho" + (0x28 * "m") + 0x20) ("ci" + "added_fx")
	END
  END
END
 END
BUT_ONLY_IF_IT_CHANGES

// Staff of Power should actually cast Globe of Invulnerability,
// not some shabby facsimile. Two icons also incorrect.
COPY_EXISTING ~staf12.itm~   ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x71) THEN BEGIN
WRITE_ASCIIT 0x3a ~istaf12~  // correcting inventory icon
READ_LONG	0x64 "ho"
READ_SHORT   0x68 "hc"
READ_LONG	0x6a "eo"
WRITE_ASCIIT ("ho" + (0x38 * 0x00) + 0x04) ~istaf12~ // melee icon
WRITE_BYTE   ("ho" + (0x38 * 0x00) + 0x24) 0x00 // melee charges do not deplete
FOR ("i" = 0; "i" < "hc"; "i" += 1) BEGIN
  READ_SHORT ("ho" + (0x38 * "i") + 0x1e) "ec"
  READ_SHORT ("ho" + (0x38 * "i") + 0x20) "ei"
  FOR ("j" = 0; "j" < "ec"; "j" += 1) BEGIN
	READ_SHORT ("eo" + (0x30 * ("j" + "ei")) + 0x00) "opcode"
	PATCH_IF (("opcode" = 0x66) AND ("ec" > 1)) THEN BEGIN
	  SET "deleted" = ("ec" - 1)
	  SET "ec" = 1
	  WRITE_ASCII  ("ho" + (0x38 * "i" ) + 0x04)  ~spwi602b~ // Icon for Globe of Invulneribility
	  WRITE_SHORT  ("ho" + (0x38 * "i" ) + 0x1e)  0x01 // one ability on this header
	  DELETE_BYTES ("eo" + (0x30 * "ei") + 0x00)  (0x30 * "deleted")
	  WRITE_SHORT  ("eo" + (0x30 * "ei") + 0x00)  0x92 // cast spell
	  WRITE_LONG   ("eo" + (0x30 * "ei") + 0x04)  0x00 // use caster level
	  WRITE_LONG   ("eo" + (0x30 * "ei") + 0x08)  0x00 // normal casting
	  WRITE_BYTE   ("eo" + (0x30 * "ei") + 0x0c)  0x01 // timing: instant/permanent
	  WRITE_BYTE   ("eo" + (0x30 * "ei") + 0x0d)  0x03 // dispel/bypass
	  WRITE_LONG   ("eo" + (0x30 * "ei") + 0x0e)  0x00 // irrelevant duration
	  WRITE_ASCIIT ("eo" + (0x30 * "ei") + 0x14)  ~spwi602~ // Globe of Invulneribility
	  SET "k" = ("i" + 1)
	  WHILE ("k" < "hc") BEGIN
		READ_SHORT  ("ho" + (0x38 * "k") + 0x20) "ci"
		WRITE_SHORT ("ho" + (0x38 * "k") + 0x20) ("ci" - "deleted")
		SET "k" += 1
	  END // WHILE i3, repairing extended header indices
	END // PATCH_IF immunity to spell level located
  END // FOR index2, searching each header's abilities
END // FOR index, searching extended headers
 END // PATCH_IF filesize sanity check
BUT_ONLY_IF_IT_CHANGES // no bad joke for the end of this patch

// Cloak of Mirroring also missing many spell immunity effects
COPY_EXISTING ~clck26.itm~   ~override~
 PATCH_IF (%SOURCE_SIZE% > 0x71) THEN BEGIN
READ_LONG  0x64 "ho" ELSE 0x72
READ_SHORT 0x68 "hc" ELSE 0x00
READ_LONG  0x6a "eo" ELSE 0x72
READ_SHORT 0x6e "gi" ELSE 0x00
READ_SHORT 0x70 "gc" ELSE 0x00
SET "no" = ("eo" + (0x30 * ("gi" + "gc")))
SET "ad" = 0x0f
INSERT_BYTES	"no"   (0x30 * "ad")
  WRITE_ASCIIT ("no" + (0x30 * 0x00) + 0x14) ~sppr302~  // Call Lightning
  WRITE_ASCIIT ("no" + (0x30 * 0x01) + 0x14) ~sppr304~  // Glyph of Warding
  WRITE_ASCIIT ("no" + (0x30 * 0x02) + 0x14) ~sppr313~  // Holy Smite
  WRITE_ASCIIT ("no" + (0x30 * 0x03) + 0x14) ~sppr314~  // Unholy Blight
  WRITE_ASCIIT ("no" + (0x30 * 0x04) + 0x14) ~spwi313~  // Skull Trap
  WRITE_ASCIIT ("no" + (0x30 * 0x05) + 0x14) ~spwi502~  // Cloud Kill
  WRITE_ASCII  ("no" + (0x30 * 0x06) + 0x14) ~sppr603d~ // Blade Barrier
  WRITE_ASCIIT ("no" + (0x30 * 0x07) + 0x14) ~spwi614~  // Death Fog
  WRITE_ASCIIT ("no" + (0x30 * 0x08) + 0x14) ~sppr705~  // Fire Storm
  WRITE_ASCII  ("no" + (0x30 * 0x09) + 0x14) ~sppr725d~ // Globe of Blades
  WRITE_ASCIIT ("no" + (0x30 * 0x0a) + 0x14) ~spwi712~  // Delayed Blast Fireball
  WRITE_ASCIIT ("no" + (0x30 * 0x0b) + 0x14) ~spwi810~  // Incendiary Cloud
  WRITE_ASCIIT ("no" + (0x30 * 0x0c) + 0x14) ~spwi911~  // Meteor Swarm
  WRITE_ASCII  ("no" + (0x30 * 0x0d) + 0x14) ~spwish25~ // Wish Meteor Swarm
  WRITE_ASCII  ("no" + (0x30 * 0x0e) + 0x14) ~spwish32~ // Wish Horrid Wilting
FOR ("i" = 0; "i" < "ad"; "i" += 1) BEGIN
  WRITE_SHORT  ("no" + (0x30 * "i") + 0x00) 0xce	   // immunity to spell
  WRITE_SHORT  ("no" + (0x30 * "i") + 0x02) 0x01	   // target: self
  WRITE_LONG   ("no" + (0x30 * "i") + 0x04) ` 0x00	 // strref displayed
  WRITE_LONG   ("no" + (0x30 * "i") + 0x08) 0x00	   // useless
  WRITE_BYTE   ("no" + (0x30 * "i") + 0x0c) 0x02	   // mode: while equipped
  WRITE_BYTE   ("no" + (0x30 * "i") + 0x12) 0x64	   // minimum prob 100%
END
WRITE_SHORT 0x70 ("gc" + "ad")
PATCH_IF ("hc" > 0) THEN BEGIN
  FOR ("j" = 0; "j" < "hc"; "j" += 1) BEGIN
	READ_SHORT  ("ho" + (0x38 * "j") + 0x20) "ei"
	WRITE_SHORT ("ho" + (0x38 * "j") + 0x20) (("ei" = 0) ? 0x00 : ("ei" + "ad"))
  END
END
 END
BUT_ONLY_IF_IT_CHANGES

Link to comment

Archived

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

×
×
  • Create New...