Skip to content

Opcode 180 (Can't Use Item) doesn't work

RaduzielRaduziel Member Posts: 4,714
Hello,

Seems like Opcode 180 (Can't Use Item) is broken.

#1 Did a try with it to ban some items from a kit I'm modding: worked fine in BG(2)EE, didn't work in IWDEE.

#2 Did another try with another kit relating to another resource: didn't work in BG(2)EE either.

In situation #1 I was trying to ban the Raise Dead scroll from a priest kit (I'm aware that both games use different resources code).

In situation #2 I was trying to ban the Animate Dead scroll from a wizard kit that has the Necromancer usability flag (this one didn't work in any game).

I made a bug report but decided to make this thread to see if the community has a solution already.

Comments

  • kjeronkjeron Member Posts: 2,367
    Spell Learning is not tied to item usability at all, it's tied to spell usability and your current class (being some form of bard or mage). A Color Spray(alteration) scroll can have every unusability flag checked and ocpode 319, with opcodes 180 and 181 on a Conjurer, and they will still be allowed to scribe it.

    Opcode 180:
    • Only has the option to restrict equipping an item.
    • Has no effect on activating items from the inventory or quickbar.
    • Does not impose a red overlay on the item.
    • Its parameter2 must be zero to function.
    Opcode 181:
    • Parameter2=0: Restricts both equipping an item and inventory activation. An already equipped item may still be activated from the quickbar.
    • Parameter2=1: Restricts just activating the item on yourself or others. Items that target a location or "any point" can still be used (scroll of fireball, oil of fiery burning).
    Opcode 319:
    • Restricts both equipping an item and inventory activation.
    • An already equipped item may still be activated from the quickbar.
  • RaduzielRaduziel Member Posts: 4,714
    @kjeron Always a pleasure to learn from you :)

    My plan was to ban the spell by banning the scroll (as it is the only way for a wizard to learn a spell).

    When I used Opcode 180 p1 was the string "Cannot use item" and p2 was zero. The resource code was the itens resource code (like SCRL63 for Raise Dead in BG(2)EE.

    Using Opcode 181 I used p1 = item code from here and p2 = 0.

    I don't have the faintest idea of how to use Opcode 319 (is it also available in IWDEE?)

    ---

    My objectives are:

    1) For the Undead Predator: ban any weapon that is not listed in the kit's Disadvantages description.

    2) For the Undead Redeemer: ban any item, including scrolls, that simulates the spells they aren't allowed to cast.

    3) For the Undead Slayer: ban Animate Dead (and Summon Shadows in IWDEE)

    For the Predator I was using Opcode 181, for the other two I was using Opcode 180.

    180 partially works for the Redeemer (he couldn't use the Raise Dead scroll in BGEE, for example, but were able to wield the Staff of Moradin's Breath in IWDEE) and doesn't work at all for the Undead Slayer.

    Do you know of a workaround that I can do to achieve these objectives?

    Thank you.
  • kjeronkjeron Member Posts: 2,367
    Opcode 319 works in IWDEE, and would be your best option for #2, and for some of the weapons of #1.
    Opcode 319 works by applying it as a global/equipped effect to the item itself.

    For #1, use 181 as you are now for all undesired categories except Large Swords.
    Then use Opcode 319 for all Katana's, Bastard Swords, Two-handed Swords, and Scimitar/Ninjato/Wakizashi, identifying them by proficiency (assuming I am correctly understanding which weapons you want to restrict):
    COPY_EXISTING_REGEXP ~.*\.itm~ override
      READ_BYTE 0x31 proficiency
      PATCH_MATCH proficiency WITH 
        89 94 95 93  BEGIN // Bastard, Katana, Scimitar, Two-handed
          LPF ADD_ITEM_EQEFFECT
            INT_VAR
              opcode = 319
              target = 1
              parameter1 = (RAUR + 0x4000)  // Undead Predator KITIDS
              parameter2 = 9  // Kit
              timing = 2
              special = RESOLVE_STR_REF (@2) // "Undead Predator"
                //  This text will show up in (un)usability list of the items description, sometimes (depends on item).
          END
        END
        DEFAULT
      END
    BUT_ONLY
    
    For #2 you just need to copy each item individually and add the effect.
    COPY_EXISTING_REGEXP ~itemfile.itm~ override
          LPF ADD_ITEM_EQEFFECT
            INT_VAR
              opcode = 319
              target = 1
              parameter1 = (RAUR + 0x4000)  // Undead Predator KITIDS
              parameter2 = 9  // Kit
              timing = 2
              special = RESOLVE_STR_REF (@2) // "Undead Predator"
                //  This text will show up in (un)usability list of the items description, sometimes (depends on item).
          END
    BUT_ONLY
    
    I don't know of any good solution for #3. Opcode 319 will prevent them from casting the scrolls, but their is no way to selectively restrict spell learning beyond whole schools of spells.
  • GwendolyneGwendolyne Member Posts: 461
    edited July 2017
    Or simply this:
    LPF ~ADD_ITEM_EQEFFECT~ INT_VAR opcode = 319 target = 1 timing = 2 parameter1 = IDS_OF_SYMBOL (~Kit~ ~your kit~) parameter2 = 9 special = RESOLVE_STR_REF (@your kit ref in mixed case) END

    My unicorn rider can't wear plate mail:
    COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
      PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
        READ_BYTE 0x18 flags1
        PATCH_IF ((flags1 & BIT3) = BIT3) BEGIN	// Movable, otherwise useless.
    	READ_ASCII	0x22 animation (2)
    	PATCH_IF ("%animation%" STRING_EQUAL_CASE "4A") BEGIN
    	  LPF ~ADD_ITEM_EQEFFECT~ INT_VAR opcode = 319 target = 1 timing = 2 parameter1 = IDS_OF_SYMBOL (~Kit~ ~GW_UNICORN_RIDER~) parameter2 = 9 special = RESOLVE_STR_REF (@7720002) END	// @7720002 = Unicorn Rider
    	END
        END
      END
    BUT_ONLY
    
  • RaduzielRaduziel Member Posts: 4,714
    Thanks @Gwendolyne and @kjeron !

    Can I combine those with a game check?
    ACTION_IF GAME_IS ~game_identification~ THEN BEGIN

    ~Your awesome scripts~

    END
    Because we have different resources for IWDEE, BGEE and BG2EE/EET.
  • RaduzielRaduziel Member Posts: 4,714
    Worked like a charm (except for the wizard kit, but I won't let it overshadow our glorious victory this day).

    Opcode 181 didn't work, so I banned all the unwanted weapons using @kjeron first code.

    Then I used @Gwendolyne to ban all the armors unwanted.

    And finally, kjeron's second code to ban the resurrection/animate dead items for the Redeemer.

    Now I can finally move on to finish the kitpack and with morer cards under my sleeve.

    Thanks, you guys are awesome. If I ever became rich I swear I'll remember you.
  • The user and all related content has been deleted.
  • kjeronkjeron Member Posts: 2,367
    @subtledoctor Any effect preceding Opcode 147(Learn) prevents the "Write Magic" option from even appearing. Effects proceeding Opcode 147 do work, inlcuding multiple opcode 147's.

    When you have multiple Opcode 147's in a single scroll ability, they will all have a separate chance to be learned, but only the first instance of 147 is checked against restrictions (already known, spell school).

    You can also put opcode 147 in an external EFF called through opcode 177, but in order to be "write-able", it still needs an opcode 147 directly in the scroll ability as its first effect.

    Any spell can be learned through ocpode 147, however, non-wizard spells will always succeed while displaying the "failed" feedback message, and do not check if they are already known.
    Scroll.itm
    Ability 1 = Cast (Spell)
    Ability 2 = 
     - Effect 1 = Learn Spell (Wizard, Level X)
     - Effect 2 = Use EFF (sub1), param1/2 = (kit/class/race/etc..)
     - Effect 3 = Use EFF (sub2), param1/2 = (kit/class/race/etc..)
    
    sub1.eff = Remove Spell
    sub2.eff = Learn Spell(chance) or Give Innate Ability(always)
    The success/fail message would not necessarily be accurate, and you would get double exp when both succeed(unless you use "Give Innate Ability", but otherwise functional.

    Could give a new meaning to the idea of a "Cursed" scroll, by adding detrimental effects when trying to scribe.

    A shame you can't link the effects to the success/fail of the initial scribing, though you can still use Opcode 321 to prevent stacking effects.
Sign In or Register to comment.