[(BG2, BGEE) bug] Spell Shield duration (0824)
Spell Shield lacks headers, so it always lasted a static 48 rounds instead of 3 rds/level per its description:
// spell shield does not have listed durations due to missing ability headers
COPY_EXISTING ~spwi519.spl~ ~override~
READ_LONG 0x64 "abil_off"
READ_SHORT 0x68 "abil_num"
READ_LONG 0x6a "fx_off"
READ_SHORT 0x70 "fx_num"
FOR (index = 0 ; index < abil_num ; index = index + 1) BEGIN // first fix existing effects
READ_SHORT ("%abil_off%" + 0x10 + ("%index%" * 0x28)) "min_lev"
PATCH_IF ("%min_lev%" = 1) BEGIN
SET "min_lev" = 11
END
READ_SHORT ("%abil_off%" + 0x1e + ("%index%" * 0x28)) "abil_fx_num"
READ_SHORT ("%abil_off%" + 0x20 + ("%index%" * 0x28)) "abil_fx_idx"
FOR (index2 = 0 ; index2 < abil_fx_num ; index2 = index2 + 1) BEGIN
READ_LONG ("%fx_off%" + 0x0e + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "duration"
PATCH_IF ("%duration%" > 5) BEGIN // longer than one round
WRITE_LONG ("%fx_off%" + 0x0d + (0x30 * ("%abil_fx_idx%" + "%index2%"))) 0 // no dispel/bypass resistance
WRITE_LONG ("%fx_off%" + 0x0e + (0x30 * ("%abil_fx_idx%" + "%index2%"))) (18 * "%min_lev%") // corrects duration
END
END
END
FOR (index3 = min_lev + 1 ; index3 < 21 ; index3 = index3 + 1) BEGIN
READ_ASCII ("%fx_off%" + (0x30 * "%abil_fx_idx%")) "effects" ("%abil_fx_num%" * 0x30) // reads whole block of effects from last ability
READ_ASCII ("%abil_off%" + (0x28 * ("%abil_num%" - 1))) "ability" (0x28) // reads last ability
SET "abil_fx_idx" = "%abil_fx_idx%" + "%abil_fx_num%"
INSERT_BYTES ("%fx_off%" + (0x30 * "%abil_fx_idx%")) ("%abil_fx_num%" * 0x30) // inserts bytes
WRITE_ASCIIE ("%fx_off%" + (0x30 * "%abil_fx_idx%")) "%effects%" // clones existing effects
FOR (index4 = 0 ; index4 < abil_fx_num ; index4 = index4 + 1) BEGIN // loop to adjust effects by min level
READ_LONG ("%fx_off%" + 0x0e + (0x30 * ("%abil_fx_idx%" + "%index4%"))) "duration"
PATCH_IF ("%duration%" > 5) BEGIN // longer than one round
WRITE_LONG ("%fx_off%" + 0x0e + (0x30 * ("%abil_fx_idx%" + "%index4%"))) (18 * "%index3%") // corrects duration
END
END
INSERT_BYTES ("%abil_off%" + ("%abil_num%" * 0x28)) 0x28 // inserts bytes
WRITE_ASCIIE ("%abil_off%" + ("%abil_num%" * 0x28)) "%ability%" // clones existing ability
WRITE_SHORT ("%abil_off%" + 0x10 + ("%abil_num%" * 0x28)) ("%index3%") // minimum level
WRITE_SHORT ("%abil_off%" + 0x20 + ("%abil_num%" * 0x28)) "%abil_fx_idx%"
SET "fx_off" = ("%fx_off%" + 0x28)
SET "abil_num" = ("%abil_num%" + 1)
END
WRITE_LONG 0x6a "%fx_off%"
WRITE_SHORT 0x68 "%abil_num%"
BUT_ONLY_IF_IT_CHANGES
Post edited by Bhryaen on
0
Comments
SPWI519's duration for Spell type deflection and Play sound (Effects #4,5) are as follows: