Skip to content

[(BGEE, BG2) bug] Holy smite (0813)

CamDawgCamDawg Member, Developer Posts: 3,438
edited August 2012 in Fixed
By convention, BG2 spells cap at level 20. Holy Smite is capped at level 19, and had some mistargeted/mistimed effects when cast at levels 6 or 7.

Another ugly, old but functional patch.
// holy smite missing level 20 abilities, a few effects mistargeted and/or wrong duration at lev 6, 7
COPY_EXISTING ~sppr313.spl~ ~override~
READ_LONG 0x64 "abil_off"
READ_SHORT 0x68 "abil_num"
READ_LONG 0x6a "fx_off"
SET "orig_abil" = "%abil_num%"
SET "delta" = 0
SET "loops" = 0
SET "min_lev" = 0
WHILE ("%abil_num%" > 0) BEGIN // grabs last ability (lev 19) and does patching for lev 6, 7 abilities
SET "abil_num" = ("%abil_num%" - 1)
READ_SHORT ("%abil_off%" + 0x10 + (0x28 * "%abil_num%")) "level"
PATCH_IF ("%min_lev%" = 0) BEGIN
SET "min_lev" = "%level%" // sets min_lev to use last ability
END
PATCH_IF (("%level%" = 6) OR ("%level%" = 7)) BEGIN
READ_SHORT ("%abil_off%" + 0x1e + (0x28 * "%abil_num%")) "abil_fx_num"
READ_SHORT ("%abil_off%" + 0x20 + (0x28 * "%abil_num%")) "abil_fx_idx"
WHILE ("%abil_fx_num%" > 0) BEGIN
SET "abil_fx_num" = ("%abil_fx_num%" - 1)
READ_ASCII ("%fx_off%" + 0x14 + (0x30 * ("%abil_fx_idx%" + "%abil_fx_num%"))) "eff_file"
PATCH_IF ("%eff_file%" STRING_COMPARE_CASE "hitinvwa" = 0) BEGIN
WRITE_BYTE ("%fx_off%" + 0x0c + (0x30 * ("%abil_fx_idx%" + "%abil_fx_num%"))) 1 // instant/permanent
END ELSE
PATCH_IF ("%eff_file%" STRING_COMPARE_CASE "blind" = 0) BEGIN
WRITE_BYTE ("%fx_off%" + 0x0c + (0x30 * ("%abil_fx_idx%" + "%abil_fx_num%"))) 0 // instant/limited
WRITE_LONG ("%fx_off%" + 0x0e + (0x30 * ("%abil_fx_idx%" + "%abil_fx_num%"))) 6 // duration
END
END
END
END
PATCH_IF ("%min_lev%" < 20) BEGIN
INSERT_BYTES "%fx_off%" 0x28
SET "delta" = 1
READ_ASCII ("%fx_off%" - 0x28) "abil_clone" (0x28) // reads entire ability as block
READ_SHORT (("%fx_off%" - 0x28) + 0x1e) "abil_fx_num"
READ_SHORT (("%fx_off%" - 0x28) + 0x20) "abil_fx_idx"
END
WHILE ("%delta%" > "%loops%") BEGIN // this clones the lev 19 abilities to the lev 20 one
WRITE_EVALUATED_ASCII (("%fx_off%" + (0x28 * "%loops%")) ) "%abil_clone%"
WRITE_SHORT (("%fx_off%" + (0x28 * "%loops%")) + 0x10) ("%min_lev%" + 1 + "%loops%")
WRITE_SHORT (("%fx_off%" + (0x28 * "%loops%")) + 0x1e) "%abil_fx_num%"
WRITE_SHORT (("%fx_off%" + (0x28 * "%loops%")) + 0x20) ("%abil_fx_idx%" + (("%loops%" + 1) * "%abil_fx_num%"))
SET "loops" = ("%loops%" + 1)
END
WRITE_SHORT 0x68 ("%orig_abil%" + "%delta%")
SET "fx_off" = ("%fx_off%" + (0x28 * "%delta%"))
WRITE_LONG 0x6a "%fx_off%"
INSERT_BYTES ("%fx_off%" + (0x30 * ("%abil_fx_num%" + "%abil_fx_idx%"))) (0x30 * ("%delta%" * "%abil_fx_num%"))
WHILE ("%delta%" > 0) BEGIN
SET "loops" = "%abil_fx_num%"
WHILE ("%loops%" > 0) BEGIN
SET "loops" = ("%loops%" - 1)
READ_ASCII ("%fx_off%" + 0x00 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "clone" (0x30)
WRITE_EVALUATED_ASCII ("%fx_off%" + 0x00 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%clone%"
READ_ASCII ("%fx_off%" + 0x14 + (0x30 * ("%loops%" + "%abil_fx_idx%"))) "eff_again"
PATCH_IF ("%eff_again%" STRING_COMPARE_CASE "sp313l19" = 0) BEGIN
WRITE_ASCII ("%fx_off%" + 0x14 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) ~sp313l20~
END ELSE BEGIN
WRITE_EVALUATED_ASCII ("%fx_off%" + 0x14 + (0x30 * ("%loops%" + "%abil_fx_idx%")) + ("%delta%" * (0x30 * "%abil_fx_num%"))) "%eff_again%"
END
END
SET "delta" = ("%delta%" - 1)
END
BUT_ONLY_IF_IT_CHANGES
Post edited by Bhryaen on
AndreaColombo

Comments

  • KeithSKeithS Member Posts: 623
    Adding...
  • CamDawgCamDawg Member, Developer Posts: 3,438
    This also needs a new eff for level 20:
    // new eff needed for level 20 holy smite
    COPY_EXISTING ~SP313L19.EFF~ ~override/SP313L20.EFF~
    WRITE_LONG 0x38 20
    AndreaColombo
  • TanthalasTanthalas Member Posts: 6,738
    And another tag @KeithS
  • KeithSKeithS Member Posts: 623
    Gotcha
  • NathanNathan Member Posts: 1,007
    Verified, this fix has been included internally and should be present in the next build.
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    Confirmed fixed
    with comments to @CamDawg
    level 20 header - lol, we fix all bg2ee bugs now?
    Btw, by level 20 damage is 40d2, save for half. Which is considerably larger than 20d4
    This isn't such a big difference on lower levels, but you used to fix these things before
  • CamDawgCamDawg Member, Developer Posts: 3,438
    Argh, @Avenger_teambg. Where were you when we were writing Fixpack so we could have fixed this years ago?
    // holy smite/unholy blight damage fixes, part 1
    COPY_EXISTING ~sp313l05.eff~ ~override~
    ~sp313l06.eff~ ~override~
    ~sp313l07.eff~ ~override~
    ~sp313l08.eff~ ~override~
    ~sp313l09.eff~ ~override~
    ~sp313l10.eff~ ~override~
    WRITE_LONG 0x3c 4 // dice size 2 > 4
    BUT_ONLY

    // holy smite/unholy blight damage fixes, part 2
    OUTER_SET "dicethrown" = 2
    COPY_EXISTING ~sp313l05.eff~ ~override/sp313l02.eff~
    ~sp313l06.eff~ ~override/sp313l03.eff~
    ~sp313l07.eff~ ~override/sp313l04.eff~
    WRITE_LONG 0x38 "%dicethrown%" // # dice
    SET "dicethrown" = ("%dicethrown%" + 1)

    // holy smite/unholy blight damage fixes, part 3
    COPY_EXISTING ~sppr313.spl~ ~override~ // holy smite
    ~sppr314.spl~ ~override~ // unholy blight
    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
    READ_SHORT ("%abil_off%" + 0x10 + (0x28 * "%index%")) "level"
    READ_SHORT ("%abil_off%" + 0x1e + (0x28 * "%index%")) "abil_fx_num"
    READ_SHORT ("%abil_off%" + 0x20 + (0x28 * "%index%")) "abil_fx_idx"
    PATCH_IF ("%level%" = 1) BEGIN SET "level" = 5 END
    FOR (index2 = 0 ; index2 < abil_fx_num ; index2 = index2 + 1) BEGIN
    READ_ASCII ("%fx_off%" + 0x14 + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "eff_file"
    PATCH_IF ("%eff_file%" STRING_COMPARE_REGEXP "SP313L[012][0-9]" = 0) BEGIN // if damage eff
    READ_LONG ("%fx_off%" + 0x24 + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "save"
    SET "efflev" = (("%level%" + "%save%") / 2)
    PATCH_IF ("%efflev%" = 10) BEGIN
    WRITE_ASCIIE ("%fx_off%" + 0x1a + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "%efflev%"
    END ELSE BEGIN
    WRITE_ASCIIE ("%fx_off%" + 0x1a + (0x30 * ("%abil_fx_idx%" + "%index2%"))) "0%efflev%"
    END
    END
    END
    END
    BUT_ONLY
    This needs to go after the existing sppr313 patch. The new sp313l20.eff is no longer needed, nor the existing sp313l11 - sp313l19 effs.
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    edited August 2012
    Whoa, i'm not sure how my comment resulted in the removal of about a dozen of files, but if it works, then i'm happy. And, while you worked on fixpack, i likely worked on gemrb, lol.
  • BhryaenBhryaen Member Posts: 2,874
    edited August 2012
    Moving to Confirmed Not Fixed where the @Avenger_teambg-inspired fix can be applied. :-)
  • SethDavisSethDavis Member Posts: 1,812
    Potentially fixed - the new code has been added after the old and the creation of the new eff has been removed
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    Confirmed fixed - works perfectly with fewer resources.
    Now i see what you did @CamDawg
    SP313L11.EFF and above could be scrapped (left out from the next biffing round) if needed.
  • TanthalasTanthalas Member Posts: 6,738
    Well, I have no idea how code works.

    But sp313L2 to sp313l10 all seem to have the correct damage in NI.

    However:

    @CamDawg, @Avenger_teambg, @SethDavis

    What happens now is that when the target fails its save you get damage shown twice in the battle log, when they succeed in their save you only get one line of damage in the battle log. Is this because of the new way this spell is used?
  • CamDawgCamDawg Member, Developer Posts: 3,438
    Tanthalas said:

    Well, I have no idea how code works.
    What happens now is that when the target fails its save you get damage shown twice in the battle log, when they succeed in their save you only get one line of damage in the battle log. Is this because of the new way this spell is used?

    @Tanthalas
    I'm pretty sure that's how all damage with save-for-half works. You'll either get two damage messages or a damage and save vs. whatever.
  • lansounetlansounet Member Posts: 1,182
    Agree with @CamDawg since they're actually 2 separate damage effects. One you can't save against and the other you can save to negate
  • TanthalasTanthalas Member Posts: 6,738
    edited August 2012
    Ok, thanks for the clarifying that for me.

    This one is Confirmed Fixed.
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    @Tanthalas The BioWare branch of the engine has no 'save for half' feature, so they hacked all such cases into 2 separate damage effects. The Blackisle branch of the engines contain save for half feature, but as far as i remember they are implemented different ways. I'm pretty sure that the IWD2 way is the best.
  • AndreaColomboAndreaColombo Member Posts: 5,524
    @Avenger_teambg - do you think it would be particularly hacky to implement the IWD2 approach into BG:EE? Since it's supposed to be "the best version of Baldur's Gate possible", might as well gather all the best implementations of the I.E. around ;-)
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    No, it is a clean implementation of using an unused bit combination (99% unused) in the damage opcode.
    In damage opcode, the lowest 2 bits of param2 determine the damage method:
    00 - normal value
    01 - set hp to value
    10 - percentage
    11 - profit!

    @SethDavis knows, if this combo (11) could be used for save for half damage, or not.
    AndreaColomboSethDavislolien
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    The PST method is lame. They always save for half, except when the resource field is filled with 'NEG'.
    That is ugly.
    AndreaColombololien
  • SethDavisSethDavis Member Posts: 1,812
    @Avenger_teambg - That should be possible, though it'll cause some awkwardness with odd numbers.
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    SethDavis said:

    @Avenger_teambg - That should be possible, though it'll cause some awkwardness with odd numbers.

    What do you mean by odd numbers?
    You mean you cannot decide to round up or down?
  • SethDavisSethDavis Member Posts: 1,812
    @Avenger_teambg - It'll probably round down, just sleepy enough this morning to point out things that probably don't need to be pointed out :)
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    I promise i won't nitpick either case :D
Sign In or Register to comment.