Skip to content

WIEDU: How can I target specific opcodes for armor?

CallirgosCallirgos Member Posts: 105
Hi,

I'm using WEIDU to redo some armor values.
Armor typically has 4 values for armor.
I'd like to target a specific value, instead of deleting all of them with one command.
Is this possible?


This is what I have -

COPY_EXISTING ~CHAN04.itm~ ~override~
LPF ~DELETE_ITEM_EQEFFECT~
INT_VAR
opcode_to_delete = 0 // armor bonus
END

How can I specify the above to only be the base armor bonus, or bonus vs piercing, etc. ?

Comments

  • GwendolyneGwendolyne Member Posts: 461
    use DELETE_EFFECT function with match_parameter2 value
  • CamDawgCamDawg Member, Developer Posts: 3,438
    Use DELETE_EFFECT instead, e.g.
    LPF DELETE_EFFECT INT_VAR check_headers = 0 match_opcode = 0 match_parameter2 = BIT4 END
    

    match_parameter2 can be whatever calue you're looking for--BIT4 is the overall armor value, and the other specific modifiers are BIT0 through BIT3 (crushing, missile, piercing, slashing). If you just want to change the value, you can also use ALTER_EFFECT to directly insert a new value:
    LPF ALTER_EFFECT INT_VAR check_headers = 0 match_opcode = 0 match_parameter2 = BIT4 parameter1 = new_value END
    
  • CallirgosCallirgos Member Posts: 105
    edited February 2020
    Thanks.

    What is the "check_headers = 0" doing? What is a "header" here?
    ... maybe it is what creates the matching requirements below?

    "match_opcode = 0" makes sense to me. Because 0 is the opcode for armor bonus, right?
    "match_parameter2" makes sense.

    Could I use ALTER_EFFECT to do math here? For example, could I somehow do +1 to whatever the current value happens to be? That way I could do a pass where I set up all the armors of a given type, then some quick steps to update all the enchanted armors.
  • CamDawgCamDawg Member, Developer Posts: 3,438
    Callirgos wrote: »
    What is the "check_headers = 0" doing? What is a "header" here?

    Near Infinity calls these abilities--for the most part, armor don't have many. check_headers=0 basically means to ignore checking the effects on abilities and instead limit the patch to equipping effects.

    And I probably should have added silent=1 to the patch, otherwise WeiDU will throw warnings at the user if it can't find a matching effect to patch/delete.
    Callirgos wrote: »
    Could I use ALTER_EFFECT to do math here? For example, could I somehow do +1 to whatever the current value happens to be? That way I could do a pass where I set up all the armors of a given type, then some quick steps to update all the enchanted armors.

    Unfortunately, no, you'd have to write a proper loop to read and adjust these on the fly. It's not too difficult to do, but it is an extra step.
    COPY_EXISTING ~chan04.itm~  ~override~
      READ_LONG   0x6a fx_off
      READ_SHORT  0x70 fx_num
      FOR (index = 0; index < fx_num; ++index) BEGIN
        READ_SHORT (fx_off +        (index * 0x30)) opcode
        READ_LONG  (fx_off + 0x08 + (index * 0x30)) parameter2
        PATCH_IF ((opcode = 0) AND (parameter2 = BIT4)) BEGIN
          WRITE_LONG  (fx_off + 0x04 + (index * 0x30)) (THIS + 1) // increases existing parameter1 by 1
        END
      END
      BUT_ONLY
    
Sign In or Register to comment.