Skip to content

[(BG2) BUG] Restore and fix opcode 243 (0824)

AndreaColomboAndreaColombo Member Posts: 5,524
edited September 2012 in Fixed
This bug fix request was originally posted by @Wisp (*cues @Bhryaen for some winking*) in the Feature Request forum and got buried within the 400+ other requests, so I thought I'd report it here (the original post can be found here.

CURRENT BEHAVIOR:

Effect 243 (Drain item charges) used to work in SoA, but it was buggy and sometimes it would destroy items seemingly at random, even ones without charges (including quest items). Bioware "fixed" this in ToB by simply disabling the entire effect.

It would be ever so nice if this effect could be restored to working order (sans the bugs). Additionally, I think it would be neat if the effect could be expanded to take the number of charges to be drained as its parameter 2 (currently thought to be unused).


EXPECTED BEHAVIOR:

Expected/desired behaviour is adapted from the spell description of the summon nishruu spell and presented in a IESDP-like format:


243 (0x0F3) Item: Drain Item Charges [243]
Parameter #1: Item Type
Parameter #2: Number to Drain
Description:
Magical items matching the 'Item Type' value on the targeted creature(s) will have their charges drained by Number to Drain. Non-recharging items drained of all their charges are destroyed.

Known values for 'Item Type' are:
0 Magical items excluding weapons
1 Magical items including weapons

I do not know what is exactly feasible, but conceivably this effect could limit itself to draining charges from ability headers of type 3 (magical ability), and only destroying the item if the word at 0x24 in the ability header is not 3 (i.e., don't destroy recharging items) and if said charge count reaches 0 as a result of the drain.

NB. If the number-to-drain bit is implemented, the existing uses of this effect need to be amended to have a non-zero value for parameter 2. For reference, these are nishruu.itm, spellh01.itm, golmag01.itm, spin550.spl and spwm140.spl.
Post edited by Bhryaen on
IgneousBhryaenAvenger_teambg

Comments

  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    I agree. It should just drain charges of charged items and everyone is happy.
  • SethDavisSethDavis Member Posts: 1,812
    edited July 2012
    Ok, drain has been restored, it only drains abilities of type 3 and won't destroy items that recharge.

    However, there is a note here that explained that the function was horribly messed up to avoid destroying items like "Familiar, weapon bits etc...". Can someone provide me with a list of item types that should not be destroyed please?
    AndreaColombo
  • AndreaColomboAndreaColombo Member Posts: 5,524
    SethDavis said:

    Can someone provide me with a list of item types that should not be destroyed please?

    I summon @Wisp and @CamDawg to trust them with this task, with @Avenger_teambg's blessing ;-)
  • WispWisp Member Posts: 1,102
    edited July 2012
    Oh, puke. I completely overlooked that. A quick glance suggests familiars are the most egregious problem, but there are also quest scrolls and some others. Would it be acceptable to add four more checks that would need to be satisfied before anything is done to the item?
    The three first would be for flags at 0x18 in the ITM header:
    The first would be for the 'unsellable' flag (bit 0). No draining if this flag is set.
    The second would be for the 'droppable' flag (bit 2). No draining unless this flag is set.
    The third check would be for the 'magical' flag (bit 6). No draining unless this flag is set.

    The fourth check would be for item category/type (word at 0x1c in the SPL header). I will have to get back to you on which exact categories should be eligible, or left alone.

    You would still have problems with most non-spell scrolls and some other items, but you can conceivably get around that by deleting the header in those cases.

    (I can see why Bioware just disabled it.)
    AndreaColomboBhryaen
  • CamDawgCamDawg Member, Developer Posts: 3,438
    I think @Wisp has this covered. The droppable flag by itself should hopefully address most of these issues.

    This won't matter too much with BGEE, but when we start getting nishruus running around BG2EE we'll have some fun.
  • SethDavisSethDavis Member Posts: 1,812
    @Wisp - I'm guessing you mean ITM header?

    K, I can make those checks.
    AndreaColombo
  • WispWisp Member Posts: 1,102
    edited July 2012
    @SethDavis
    Yeah, ITM. Sorry. Maybe bit 5 as well? (frankly, I don't know what it does) Scratch that. It is set for all sorts of items.
  • CamDawgCamDawg Member, Developer Posts: 3,438
    edited July 2012
    I think it originally also checked to see if the item in question had abilities. I recall nishruus eating gems because a lot of them had default (0) abilities, which were leftovers required in BG1 so they could stack. I think it ignored items unless they had a default (0) or magical (3) ability.
  • CuvCuv Member, Developer Posts: 2,535
    Oooh! think I remember that... eating Rogue Stones. Think I remember wanting to go back to the Twisted Rune... but the rogue stone was gone/eaten by a nishruu and I couldnt get in.
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    edited July 2012
    Yeah, familiars are: nonmagical, undroppable AND critical. So despite their 'charge' they will be saved.
    The charge removal type could be specific too. As far as we know it could be 0,1,2,3. And only 1/2 should destroy an item.
  • SethDavisSethDavis Member Posts: 1,812
    ooooooooooook, bonus - items now actually get their flags set properly when created.

    And the checks are made as well. My precious kitty was totally unscathed by the mean old nishruu, but my wand of monster summoning was not so lucky.
    CuvAvenger_teambgAndreaColombo
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    @SetDavis try the rogue stones too :D
    My install still has these stones with magic expendable abilities.
    Well, at least gems are not 'magical', so they will be save, despite these redundant, excess, useless, etc... abilities.
  • WispWisp Member Posts: 1,102
    With the three flag checks we look to be covered for BG1.
    In BG2 we potentially run into problems with the Tome of Infinite Spells (MISC3A*), some droppable creature items (CARSOMYR, CHALCY3) [set to undroppable in the CRE, I assume] and the Blood of Quallo's Friend (MISC98).
    The Tome of Infinite Spells may be an acceptable loss. The creature items could probably be set to undroppable in the ITM, and maybe MISC98 should be unsellable?
    AndreaColombo
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    The blood of quallo's friend should be set to critical (unsellable/indestructible)
    AndreaColombo
  • SethDavisSethDavis Member Posts: 1,812
    Rogue stones survive to be mauled by the cat as well. As far as I can tell they don't have the magical flag set.
  • TanthalasTanthalas Member Posts: 6,738
    I have no idea if we can actually test this one in the game or not.
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    edited August 2012
    Confirmed working...
    Nishruu has an invalid item: nishruu. So, testing will need some other item...
    I just made a wand which triggers spwm140 (a relevant one because of Neera)

    It didn't seem to affect potions, but did affect wands. Also, it didn't destroy the last charge of wands. Which isn't a problem. The effect won't destroy items, just deplete them (one by one) almost totally.
    So it is a kind of (optimal) middle ground between not working and being a total nuisance.
  • TanthalasTanthalas Member Posts: 6,738
    @Avenger_teambg
    I can just drop this in my override right?
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    Unzipped, yes.
  • TanthalasTanthalas Member Posts: 6,738
    @Avenger_teambg

    I'm not sure what should be destroyed by this but I basically spawned Dorn, gave him a bunch of wands and then used your wand on him. All his equipment survived except the wands. Is this a vaild test?

    Note: If a wand was in a quickslot, it was destroyed (no wand in the inventory screen) but it would still retain the wand icon in the quick-item slot on the main screen. Only way to remove the icon was to either put something else there or just click on the empty slot in the inventory screen.
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    edited August 2012
    Aww, then this is slightly bugiferous. I thought my last charge remained, that's why it didn't vanish.
    @SethDavis - try to update the action bar if an item was destroyed - just like you would do with a destroy item opcode.
  • SethDavisSethDavis Member Posts: 1,812
    edited August 2012
    @Avenger_teambg - Alright, I'll try to get that working

    [EDIT] Potentially fixed - Messed with the update check to handle removed items differently than items that still had charges/weren't affected.
    Post edited by SethDavis on
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    edited August 2012
    Confirmed fixed! This is one more thing you won't have to worry about when going over to BG2EE.
    Cuv
  • TanthalasTanthalas Member Posts: 6,738
    Confirmed Fixed for me too.
Sign In or Register to comment.