([BG2, BGEE] bug) Detect evil (0813)
Straight outta Compton the Fixpack:
Per its description, Detect Evil is only supposed to work within the visual range of the caster. Also, the magic resistance of creatures was supposed to make the spell ineffective, but it only prompted 'magic resistance' messages from evil magic-resistant creatures--meaning the player effectively learned their alignment anyway. Detect Evil is now limited to sight range and will return 'magic resistance' strings for any creature (good, neutral, or evil) that passes a magic resistance roll, eliminating the de-facto effectiveness against evil MR creatures.
This one was a bit tricky, but the basic idea is to change detect evil to 1) use a new projectile with the correct range 2) subject it to an MR check and 3) shuffle the actual evil detection to a secondary spell that gets applied only if MR doesn't protect the target.
Per its description, Detect Evil is only supposed to work within the visual range of the caster. Also, the magic resistance of creatures was supposed to make the spell ineffective, but it only prompted 'magic resistance' messages from evil magic-resistant creatures--meaning the player effectively learned their alignment anyway. Detect Evil is now limited to sight range and will return 'magic resistance' strings for any creature (good, neutral, or evil) that passes a magic resistance roll, eliminating the de-facto effectiveness against evil MR creatures.
This one was a bit tricky, but the basic idea is to change detect evil to 1) use a new projectile with the correct range 2) subject it to an MR check and 3) shuffle the actual evil detection to a secondary spell that gets applied only if MR doesn't protect the target.
// new projectile to correct detect evil range; see ohdetevl.spl for additional changes
COPY_EXISTING ~fireball.pro~ ~override/ohdetevl.pro~
WRITE_SHORT 0x206 512 // radius
WRITE_BYTE 0x217 255 // no explosion effect
ADD_PROJECTILE ~override/ohdetevl.pro~
// many detect evil issues; new ohdetevl projectile solves range issue; use a 'shell spell' trick to get proper MR checking
COPY_EXISTING ~sppr104.spl~ ~override/ohdetevl.spl~
LPF DELETE_SPELL_EFFECT INT_VAR opcode_to_delete = 141 END
WRITE_LONG NAME1 0xffffffff
WRITE_LONG NAME2 0xffffffff
READ_LONG 0x64 "abil_off"
READ_SHORT 0x68 "abil_num"
READ_LONG 0x6a "fx_off"
FOR (index = 0; index < abil_num; index = index + 1) BEGIN // loop through abilities
WRITE_BYTE ("%abil_off%" + 0x0c + ("%index%" * 0x28)) 1 // target: living actor
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 // looks for effects for abilities
WRITE_BYTE ("%fx_off%" + 0x02 + (("%abil_fx_idx%" + "%index2%") * 0x30)) 2 // target: preset target
END
END
COPY_EXISTING ~spcl212.spl~ ~override~ // detect evil (paladin innate)
~spin120.spl~ ~override~ // detect evil (bhaalspawn innate)
~sppr104.spl~ ~override~ // detect evil (cleric spell)
~spwi202.spl~ ~override~ // detect evil (mage spell)
READ_LONG 0x64 "abil_off"
READ_SHORT 0x68 "abil_num"
READ_LONG 0x6a "fx_off"
FOR (index = 0; index < abil_num; index = index + 1) BEGIN // loop through abilities
WRITE_BYTE ("%abil_off%" + 0x0e + ("%index%" * 0x28)) 5 // target: caster
WRITE_SHORT ("%abil_off%" + 0x26 + ("%index%" * 0x28)) "%ohdetevl%" // custom projectile
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 // looks for effects for abilities
READ_SHORT ("%fx_off%" + (("%abil_fx_idx%" + "%index2%") * 0x30)) "opcode"
PATCH_IF ("%opcode%" = 115) BEGIN // detect alignment
WRITE_SHORT ("%fx_off%" + (("%abil_fx_idx%" + "%index2%") * 0x30)) 146 // opcode: cast spell
WRITE_BYTE ("%fx_off%" + 0x02 + (("%abil_fx_idx%" + "%index2%") * 0x30)) 2 // target: preset target
WRITE_BYTE ("%fx_off%" + 0x03 + (("%abil_fx_idx%" + "%index2%") * 0x30)) 0 // power
WRITE_LONG ("%fx_off%" + 0x04 + (("%abil_fx_idx%" + "%index2%") * 0x30)) 1 // cast at level
WRITE_LONG ("%fx_off%" + 0x08 + (("%abil_fx_idx%" + "%index2%") * 0x30)) 1 // cast instantly: yes
WRITE_ASCII ("%fx_off%" + 0x14 + (("%abil_fx_idx%" + "%index2%") * 0x30)) ~ohdetevl~ // spell to cast
END
END
END
BUT_ONLY_IF_IT_CHANGES
Post edited by Bhryaen on
0
Comments
To test this we need someone with real magic resistance... @CamDawg are there any in bg1?
at least kobolds showed up as evil and tutors didn't.
Ok, elmin1 is a good testcase with his 100% magic resistance... scary! My dimwit paladin will charge.
Appropriate comic: http://www.giantitp.com/comics/oots0281.html
I used Detect Evil and Tethoril resisted it.
Only people in the visual range of my character were checked.