([BG2] bug) Elven sleep/charm resistance
Elves and half-elves are not receiving their innate sleep and charm resistance; 90% for elves and 30% for half-elves.
This works by inserting a bunch of targeted EFFs (attached) before sleep and charm effects with one-second immunities at the above probabilities to prevent the spells from going into effect.
This works by inserting a bunch of targeted EFFs (attached) before sleep and charm effects with one-second immunities at the above probabilities to prevent the spells from going into effect.
// elven sleep/charm immunity
COPY_EXISTING ~clck07.itm~ ~override~ // cloak of the nymph
~clck08.itm~ ~override~ // algernon's cloak
~gorwom1.itm~ ~override~ // undroppable nalmissra weapon - charm effect
~hgnymph.itm~ ~override~ // undroppable nymph weapon - charm effect
~misc2p.itm~ ~override~ // grager's harp
~psdclaw.itm~ ~override~ // ToB pseudodragon melee weapon
~ring03.itm~ ~override~ // Ring of Animal Friendship
~spcl311.spl~ ~override~ // ranger charm animal
~spcl641.spl~ ~override~ // charm person or animal (unused?)
~spin108.spl~ ~override~ // charm animal (elminster version)
~spin119.spl~ ~override~ // charm person (elminster version)
~spin883.spl~ ~override~ // vampire domination
~spin966.spl~ ~override~ // troll sleep
~spin980.spl~ ~override~ // beholder charm person
~spin985.spl~ ~override~ // beholder domination
~sppr102.spl~ ~override~ // command
~sppr204.spl~ ~override~ // charm person or mammal
~sppr512.spl~ ~override~ // greater command
~sppr982.spl~ ~override~ // dire charm (trap)
~spwi104.spl~ ~override~ // charm person
~spwi116.spl~ ~override~ // sleep
~spwi316.spl~ ~override~ // dire charm
~spwi506.spl~ ~override~ // domination
~spwi929.spl~ ~override~ // succubus charm male
~spwi930.spl~ ~override~ // succubus charm female
~spwi943.spl~ ~override~ // sirine dire charm
~spwm179.spl~ ~override~ // wild surge charm
~spwm187.spl~ ~override~ // wild surge sleep
~wand08.itm~ ~override~ // wand of sleep
READ_LONG 0x64 "abil_off" ELSE 0
READ_SHORT 0x68 "abil_num" ELSE 0
READ_LONG 0x6a "fx_off" ELSE 0
PATCH_IF ("%SOURCE_FILE%" STRING_COMPARE_REGEXP "^.+\.spl" = 0) BEGIN
SET "abil_length" = 0x28
END ELSE BEGIN
SET "abil_length" = 0x38
END
SET "fx_delta" = 0
FOR (index = 0 ; index < abil_num ; index = index + 1) BEGIN // start iterating through abilities
READ_SHORT ("%abil_off%" + 0x1e + ("%abil_length%" * "%index%")) "abil_fx_num"
READ_SHORT ("%abil_off%" + 0x20 + ("%abil_length%" * "%index%")) "abil_fx_idx"
SET "abil_fx_idx" = ("%abil_fx_idx%" + "%fx_delta%")
WRITE_SHORT ("%abil_off%" + 0x20 + ("%abil_length%" * "%index%")) ("%abil_fx_idx%")
FOR (index2 = 0 ; index2 < abil_fx_num ; index2 = index2 + 1) BEGIN
READ_SHORT ("%fx_off%" + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "opcode"
PATCH_IF (("%opcode%" = 39) OR ("%opcode%" = 5)) BEGIN // if there's a sleep or charm opcode
READ_BYTE ("%fx_off%" + 0x02 + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "target"
READ_BYTE ("%fx_off%" + 0x12 + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "prob1"
READ_BYTE ("%fx_off%" + 0x13 + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "prob2"
PATCH_IF ("%opcode%" = 5) BEGIN // if charm
SET "new_fx" = 14
END ELSE BEGIN
SET "new_fx" = 10
END
SET "fx_delta" = "%fx_delta%" + "%new_fx%"
FOR (index4 = 2 ; index4 < 4 ; index4 = index4 + 1) BEGIN
FOR (index3 = 0 ; index3 < (("%new_fx%" / 2)) ; index3 = index3 + 1) BEGIN
INSERT_BYTES ("%fx_off%" + (0x30 * "%abil_fx_idx%")) 0x30 // insert new effect
WRITE_SHORT ("%fx_off%" + (0x30 * "%abil_fx_idx%")) 177 // use eff file
WRITE_BYTE ("%fx_off%" + 0x02 + (0x30 * "%abil_fx_idx%")) "%target%" // preserve target
WRITE_LONG ("%fx_off%" + 0x04 + (0x30 * "%abil_fx_idx%")) "%index4%" // elf or half elf
WRITE_LONG ("%fx_off%" + 0x08 + (0x30 * "%abil_fx_idx%")) 4 // race.ids
WRITE_BYTE ("%fx_off%" + 0x12 + (0x30 * "%abil_fx_idx%")) ("%prob2%" + ((21 - ("%index4%" * 6)) * ("%prob1%" - "%prob2%") / 10)) // 90%
WRITE_BYTE ("%fx_off%" + 0x13 + (0x30 * "%abil_fx_idx%")) "%prob2%" // base prob
WRITE_EVALUATED_ASCII ("%fx_off%" + 0x14 + (0x30 * "%abil_fx_idx%")) ~cdelfcm%index3%~ // eff file
PATCH_IF ("%opcode%" = 39) BEGIN
WRITE_ASCII ("%fx_off%" + 0x19 + (0x30 * "%abil_fx_idx%")) ~sl~ #2 // eff file
END
END
END
SET "index2" = "%index2%" + "%new_fx%"
SET "abil_fx_num" = "%abil_fx_num%" + "%new_fx%"
END
END
WRITE_SHORT ("%abil_off%" + 0x1e + ("%abil_length%" * "%index%")) "%abil_fx_num%"
END
BUT_ONLY_IF_IT_CHANGES
Post edited by Tanthalas on
1
Comments
Potentially fixed - @CamDawg's fix and files have been applied. 15 attempts to charm Agnasia all failed and only 5 of 10 worked on Jaheira, though one was a roll save
notes:
1. the new effects use the CD* name space, but this is how @CamDawg supplied them.
2. it would be cool to have a new opcode which applies a whole spell instead of one-by-one effects.
Its a lot easier to charm Khalid than it is to charm Xan.
Its a lot easier to sleep Khalid than it is to sleep Kivan.
@SethDavis, @CamDawg
One problem though, when Elves resist Sleep, they still get the "Kivan/Xan/Elf - sleep" message as if they hadn't resisted it.
When sleep works (regardless of the target's race) we get two messages:
Target - Sleep
Target - Unconscious
Are the "Display String- Sleep" disables happening in immunities batches elsewhere? Planning another batch for this or something? Or are we anticipating a new opcode on this one? To send this one on maybe we can make a new thread for the opcode request...
Thank you, thank you, be sure to tip your waitresses.
@camDawg's code should fix the lingering issues with this.
Confirmed Fixed in Build 0924.