Jump to content

Spell Shield shenanigans


Recommended Posts

This cropped up while I was in the middle of the Unseeing Eye quest. After fusing the two halves of the Rift Device, I directed my Spell Shielded PC to use the device against the beholder as it spawned. For some reason, however, the Spell Shield (spwi519.spl) prevented the Rift Device (misc5c.itm) from creating the depleted version in my PC's inventory. As a result, the quest broke.

 

Anyone know why this might be? Does Spell Shield have something against opcode #122 [item: Create Inventory Item]? I performed a bit of an experiment and by removing #226 [spell: Immunity Secondary Type Decrement] from Spell Shield the Rift Device worked properly.

Link to comment

Got it. The Rift Device's lone ability header (responsible for dealing the fire damage, creating the depleted version, etc.) was being flagged as a magical attack. That's why Spell Shield was preventing the depleted version from being created in the caster's inventory.

 

I've got to say, I'm kind of surprised this hasn't come up before, or more often, at least. (I wasn't terribly thorough in my forum search.) Spell Shield is known Anti-Magic Ray repellent, so I would've expected more encounters with this issue. You do, after all, acquire the Rift Device in the middle of a beholder nest.

 

Anyway, some code to sort the issue out...

 

COPY_EXISTING ~misc5c.itm~ ~override~
READ_LONG 0x64 ~ab_off~
READ_SHORT 0x68 ~ab_num~
FOR (i=0; i<ab_num; ++i) BEGIN
	READ_BYTE (ab_off + i*0x38) ~ab_type~
	READ_ASCII (ab_off + i*0x38 + 0x04) ~ab_icon~
	PATCH_IF (ab_type = 3) AND ("%ab_icon%" STRING_EQUAL_CASE "IMISC5C") BEGIN
		WRITE_BYTE (ab_off + i*0x38 + 0x19) 0
	END
END
BUT_ONLY

Fully tested. I wasn't sure what would be the best way to narrow down the relevant header, though--in case for some bizarre reason someone decides to add some extra ones--so any feedback on that front would be much appreciated.

Link to comment

It struck me this evening how to revise this fix, in a more to-the-point fashion, hopefully. Here's the working code:

 

// Rift Device: Clear magic attack sectype from ability headers meant to spawn the item's depleted version, to prevent conflict with Spell Shield.

COPY_EXISTING ~misc5c.itm~ ~override~ // Rift Device
READ_LONG 0x64 ~ab_off~
READ_SHORT 0x68 ~ab_num~
READ_LONG 0x6a ~fx_off~
FOR (i=0; i<ab_num; ++i) BEGIN // Cycle ability headers
	READ_BYTE (ab_off + i*0x38) ~ab_type~
	READ_BYTE (ab_off + i*0x38 + 0x19) ~sectype~
	PATCH_IF (ab_type = 3) AND (sectype = 4) BEGIN // Type: Magical; Secondary type: Magic attack
		READ_SHORT (ab_off + i*0x38 + 0x1e) ~fx_num~
		READ_SHORT (ab_off + i*0x38 + 0x20) ~fx_idx~
		FOR (j=0; j<fx_num; ++j) BEGIN  // Cycle extended effects
			READ_SHORT (fx_off + (fx_idx + j)*0x30) ~opcode~
			READ_ASCII (fx_off + (fx_idx + j)*0x30 + 0x14) ~resource~
			PATCH_IF (opcode = 122) AND ("%resource%" STRING_EQUAL_CASE "misc5z") BEGIN // Opcode: Create inventory item [122]; Resource: Rift Device (depleted)
				WRITE_BYTE (ab_off + i*0x38 + 0x19) 0 // Clear assigned secondary type from parent header
			END
		END
	END
END
BUT_ONLY

Link to comment

Archived

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

×
×
  • Create New...