Jump to content

Spell Shield


Demivrgvs

Recommended Posts

have you looked into this? I'd like to know for sure, but I believe DS would simply patch the primary spell in the same way, not affecting at all the end result.
As I've already said before several times, I neither can find a logical reason to patch antimagic, nor have my tests shown the need of it. DS failing to correctly patch shell spells will only prevent PCs from ending up with a ton of ballast zero effects on them. Failing to increase needlessly to size of file is not only bug-free, but rather bug-fixing.

 

Unless someone can demonstrate that antimagic indeed must be patched, it's safe to assume the opposite. So far I discovered no such demonstration in any AI mod. It's not in Ascension or Big Picture. It does present in Oversight, which ironically enough makes absolutely no use of DS at all. In other words, no AI mod uses it.

 

 

The code below patches only designated spells. I can modify it to patch everything that is an antimagic stuff, though I think it's better to keep it as it is.

// adding new sectype

COPY_EXISTING ~msectype.2da~ ~override~
 COUNT_2DA_ROWS 2 rows
 INSERT_2DA_ROW rows 2 ~SpellShield string_z~
 REPLACE ~string_z~ ~Spell Shield Dispelled~  // you can use @123 instead of ~blah-blah~ here
 sectype=rows - 1
COPY_EXISTING ~spwi519.spl~ ~override~
 WRITE_BYTE 0x27 sectype
 opcode_to_delete = 226
 LAUNCH_PATCH_MACRO DELETE_SPELL_EFFECT

/////////////////////////////////////////////////////

// patching antimagic

ACTION_FOR_EACH spell IN
 ~spwi321~ // spell thrust
 ~spwi419~ // secret word
 ~spwi513~ // breach
 ~spwi608~ // pierce magic
 ~spwi704~ // ruby ray of reversal
 ~spwi705~ // khelben warding whip
 ~spwi805~ // pierce shield
 ~spwi903~ // spellstrike
BEGIN

 COPY_EXISTING ~spwi519.spl~ ~override~ // spell shield
 LAUNCH_PATCH_FUNCTION ADD_SPELL_EFFECT INT_VAR
opcode=206
target=1
duration=150 // note: it doesn't matter much that I skip READing it, the code is for testing anyway
power=5
 STR_VAR resource = EVALUATE_BUFFER ~%spell%b~ END


 COPY_EXISTING ~%spell%.spl~ ~override/%spell%b.spl~
WRITE_ASCII 0x8 ~~ (8) // clearing out the name
READ_LONG 0x64  ab_off
READ_SHORT 0x68 ab_num
FOR (i=0;i<ab_num;i+=1) BEGIN
  WRITE_SHORT (ab_off+i*0x28+0x0c) 1 // target = creature
  WRITE_SHORT (ab_off+i*0x28+0x26) 1 // projectile = none
END


 COPY_EXISTING ~%spell%.spl~ ~override~			  // modifying the original
READ_LONG 0x34  level
READ_LONG 0x64  ab_off
READ_SHORT 0x68 ab_num
READ_LONG 0x6a  ef_off
READ_SHORT 0x70 cast_num // global effects aka casting features

total_eff=cast_num
FOR (i=0;i<ab_num;i+=1) BEGIN
  READ_SHORT  (ab_off+i*0x28+0x1e) ef_num  // effect number
  total_eff+=ef_num
END

DELETE_BYTES ef_off (total_eff*0x30)
DELETE_BYTES ab_off ((ab_num - 1)*0x28)
WRITE_SHORT 0x68 1
WRITE_LONG 0x6a  (ef_off - (ab_num - 1)*0x28)
WRITE_SHORT 0x70 0

WRITE_SHORT (ab_off+0x1e) 2
WRITE_SHORT (ab_off+0x20) 0
WRITE_SHORT (ab_off+0x10) 1 // level required

offset=(ef_off - (ab_num - 1)*0x28)
INSERT_BYTES offset 0x60

WRITE_SHORT (offset+0x00) 146	 // opcode = cast spell on creature
WRITE_BYTE  (offset+0x02) 2	   // target = pre-target
WRITE_BYTE  (offset+0x03) level   // power level = spell level
WRITE_LONG  (offset+0x04) 0	   // parameter 1 = caster's level
WRITE_LONG  (offset+0x08) 1	   // parameter 2 = instant
WRITE_BYTE  (offset+0x0c) 1	   // timing mode = permanent
WRITE_BYTE  (offset+0x12) 100	 // probability 1 = 100%
WRITE_BYTE  (offset+0x13) 0	   // probability 2 = 0%
WRITE_ASCIIE (offset+0x14) ~%spell%b~ (8)

READ_ASCII offset ~clone~ (0x30)
WRITE_ASCIIE (offset+0x30) ~%clone%~ 
WRITE_ASCIIE (offset+0x44) ~%spell%c~


 COPY_EXISTING ~%spell%.spl~ ~override/%spell%c.spl~
WRITE_ASCII 0x8 ~~ (8) // clearing out the name
READ_LONG 0x64  ab_off
READ_LONG 0x6a  ef_off
WRITE_SHORT (ab_off+0x1e) 1
WRITE_SHORT (ab_off+0x26) 1
DELETE_BYTES (ef_off+0x30) 0x30

WRITE_SHORT ef_off 230		  // opcode = remove one sectype
WRITE_LONG (ef_off+0x4) 9	   // max level = 9
WRITE_LONG (ef_off+0x8) sectype // sectype = the 'spell shield' entry in msectype.2da
WRITE_ASCII (ef_off+0x14) ~~ (8)

END

Link to comment
have you looked into this? I'd like to know for sure, but I believe DS would simply patch the primary spell in the same way, not affecting at all the end result.
As I've already said before several times, I neither can find a logical reason to patch antimagic, nor have my tests shown the need of it. DS failing to correctly patch shell spells will only prevent PCs from ending up with a ton of ballast zero effects on them. Failing to increase needlessly to size of file is not only bug-free, but rather bug-fixing.

 

I'm glad someone's confirmed that. I'll take it out of the next release of DS, then.

 

PS: Unless I'm missing something, that code is incomplete. I don't see how Spell Shield is so far going to prevent the antimagic spells from taking down your defences. Doesn't it need to grant immunity to all the

"%spell%b" spells?

Link to comment
Unless I'm missing something, that code is incomplete. I don't see how Spell Shield is so far going to prevent the antimagic spells from taking down your defences. Doesn't it need to grant immunity to all the

"%spell%b" spells?

The first block under AFE. But dammit, I've put the wrong timing there...
Link to comment

Archived

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

×
×
  • Create New...