Jump to content

Spell stacking


Recommended Posts

Several spells stack with themselves and should not. See the patch below for the list. The basic idea of this patch is that it adds a 206 (protection from spell) effect, and it determines the target, duration, etc. from another effect in the spell--display portrait icon was common and had the correct parameters for almost all of these spells; the #33 and #86 opcodes cover the four or so spells that don't have this opcode.

 

// many spells stack with themselves and should not
COPY_EXISTING ~dgfaith.spl~ ~override~ // armor of faith (abazigal)
             ~dgright.spl~ ~override~ // righteous magic (abazigal)
             ~spcl423.spl~ ~override~ // assassin poison weapon ability
             ~spcl907.spl~ ~override~ // hardiness hla
             ~spcl913.spl~ ~override~ // evasion hla
             ~spcl914.spl~ ~override~ // greater evasion hla
             ~spcl917.spl~ ~override~ // avoid death hla
             ~spin943.spl~ ~override~ // blur (air mephit)
             ~sppr111.spl~ ~override~ // armor of faith (priest)
             ~sppr113.spl~ ~override~ // doom
             ~sppr210.spl~ ~override~ // resist fire/cold
             ~sppr306.spl~ ~override~ // protection from fire (priest)
             ~sppr406.spl~ ~override~ // defensive harmony
             ~sppr412.spl~ ~override~ // holy power
             ~sppr513.spl~ ~override~ // righteous magic (priest)
             ~spwi107.spl~ ~override~ // friends
             ~spwi201.spl~ ~override~ // blur (wizard)
             ~spwi319.spl~ ~override~ // protection from fire (wizard)
             ~spwi320.spl~ ~override~ // protection from cold
             ~spwi702.spl~ ~override~ // protection from the elements
 PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN // protects against invalid files
   READ_LONG  0x64 "abil_off"
   READ_SHORT 0x68 "abil_num"
   READ_LONG  0x6a "fx_off"
   SET "loops" = 0
   SET "delta" = 0
   WHILE ("%loops%" < "%abil_num%") BEGIN
     READ_SHORT ("%abil_off%" + 0x1e + (0x28 * "%loops%")) "abil_fx_num"
     READ_SHORT ("%abil_off%" + 0x20 + (0x28 * "%loops%")) "abil_fx_idx"
     SET "abil_fx_idx" = ("%abil_fx_idx%" + "%delta%")
     WRITE_SHORT ("%abil_off%" + 0x20 + (0x28 * "%loops%")) "%abil_fx_idx%"
     SET "subloops" = "%abil_fx_num%"
     WHILE ("%subloops%" > 0) BEGIN
       SET "subloops" = ("%subloops%" - 1)
       READ_SHORT ("%fx_off%" +        (0x30 * ("%abil_fx_idx%" + "%subloops%"))) "opcode"
       READ_BYTE  ("%fx_off%" + 0x0c + (0x30 * ("%abil_fx_idx%" + "%subloops%"))) "timing"
       READ_LONG  ("%fx_off%" + 0x0e + (0x30 * ("%abil_fx_idx%" + "%subloops%"))) "duration"
       PATCH_IF (("%timing%" = 0) AND ("%duration%" > 5) AND // instant/limited and duration greater than a round
                 (("%opcode%" = 33) OR ("%opcode%" = 86) OR ("%opcode%" = 142))) BEGIN
         READ_BYTE  ("%fx_off%" + 0x02 + (0x30 * ("%abil_fx_idx%" + "%subloops%"))) "target"
         READ_BYTE  ("%fx_off%" + 0x0d + (0x30 * ("%abil_fx_idx%" + "%subloops%"))) "bypass"
         SET "subloops" = 0 // kills WHILE loop
       END
     END
     INSERT_BYTES            ("%fx_off%" +        (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) 0x30
       WRITE_SHORT           ("%fx_off%" +        (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) 206             // spell immunity
       WRITE_BYTE            ("%fx_off%" + 0x02 + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) "%target%"      // inherits target
       WRITE_BYTE            ("%fx_off%" + 0x03 + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) 4               // power
       WRITE_BYTE            ("%fx_off%" + 0x0c + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) 0               // instant/limited
       WRITE_BYTE            ("%fx_off%" + 0x0d + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) "%bypass%"      // inherits dispel/MR
       WRITE_LONG            ("%fx_off%" + 0x0e + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) "%duration%"    // inherits duration
       WRITE_BYTE            ("%fx_off%" + 0x12 + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) 100             // probability
       WRITE_EVALUATED_ASCII ("%fx_off%" + 0x14 + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) ~%SOURCE_FILE%~ // spell: self
       WRITE_LONG            ("%fx_off%" + 0x1b + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) 0               // blanks .spl
     SET "delta1" = 1
     SET "delta" = ("%delta%" + "%delta1%")
     WRITE_SHORT ("%abil_off%" + 0x1e + (0x28 * "%loops%")) ("%abil_fx_num%" + "%delta1%")
     SET "loops" = ("%loops%" + 1)
   END
 END
 BUT_ONLY_IF_IT_CHANGES

Link to comment

You'll want to be using %SOURCE_RES%.

 

I'd also suggest:

SAY ("%fx_off%" + 0x04 + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) #74011

Obviously, you'd do @n and add the string to the TRA (so it will work on non-ToB installs), but I don't have the string handy at the moment. Providing visual feedback here is probably a good idea, but it would require separating the NPC spells and the special abilities from the real spells (you don't want to have feedback popping up if Abazigal tries to cast Armor of Faith twice, for instance).

Link to comment

Archived

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

×
×
  • Create New...