Jump to content

help with SPLPROT.2da and bit-equality


Recommended Posts

I'm trying to reproduce the APR effects of WSPATCK as weapon equipping effects - my modified version in which each proficiency point gets you an extra 1/2 APR bonus (including mastery and high mastery):

 

 

ACTION_FOR_EACH apr IN ~1~ ~7~ ~2~ ~8~ ~3~ ~9~ ~4~ ~10~ ~5~ BEGIN
  CREATE EFF ~d5papr%apr%~
    WRITE_LONG 0x10 171
    WRITE_LONG 0x14 1
    WRITE_LONG 0x1c %apr%
    WRITE_LONG 0x20 1
    WRITE_LONG 0x24 2
    WRITE_LONG 0x28 0
    WRITE_SHORT 0x2c 100
    WRITE_LONG 0x90 1
    WRITE_EVALUATED_ASCII 0x94 ~D5PAPR%apr%~ #8
END

COPY_EXISTING ~splprot.2da~ ~override~
  COUNT_2DA_COLS cols
  COUNT_2DA_ROWS 4 splprot_rows
BUT_ONLY

OUTER_SET prof_row = (%splprot_rows% - 89)

ACTION_FOR_EACH prof_stat IN ~89~ ~90~ ~91~ ~92~ ~93~ ~94~ ~95~ ~96~ ~97~ ~98~ ~99~ ~100~ ~101~ ~102~ ~103~ ~104~ ~105~ ~106~ ~107~ BEGIN
    APPEND ~splprot.2da~ ~PROF_%prof_stat%_BIT%TAB%%prof_stat%%TAB%-1%TAB%11~
END

COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
  PATCH_IF (~%SOURCE_SIZE%~ > ~0x71~) BEGIN
    READ_BYTE 0x31 prof
    PATCH_FOR_EACH weap_prof IN ~89~ ~90~ ~91~ ~92~ ~93~ ~94~ ~95~ ~96~ ~97~ ~98~ ~99~ ~100~ ~101~ ~102~ ~103~ ~104~ ~105~ ~106~ ~107~ BEGIN
      PATCH_IF (%prof% = %weap_prof%) BEGIN
        SET this_row = (%weap_prof% + %prof_row%)
        LPF DELETE_EFFECT INT_VAR match_opcode = 1 match_parameter2 = 1 match_timing = 2 END
        LPF ADD_ITEM_EQEFFECT INT_VAR insert_point = 0 opcode = 177 target = 1 parameter2 = 2 timing = 2 STR_VAR resource = ~D5PAPR8~ END
        LPF ADD_ITEM_EQEFFECT INT_VAR insert_point = 0 opcode = 177 target = 1 parameter2 = 2 timing = 2 STR_VAR resource = ~D5PAPR2~ END
        LPF ADD_ITEM_EQEFFECT INT_VAR insert_point = 0 opcode = 177 target = 1 parameter2 = 2 timing = 2 STR_VAR resource = ~D5PAPR7~ END
        LPF ADD_ITEM_EQEFFECT INT_VAR insert_point = 0 opcode = 177 target = 1 parameter2 = 2 timing = 2 STR_VAR resource = ~D5PAPR1~ END
        LPF ADD_ITEM_EQEFFECT INT_VAR insert_point = 0 opcode = 318 target = 1 parameter1 = 4 parameter2 = %this_row% timing = 2 STR_VAR resource = ~D5PAPR8~ END
        LPF ADD_ITEM_EQEFFECT INT_VAR insert_point = 0 opcode = 318 target = 1 parameter1 = 3 parameter2 = %this_row% timing = 2 STR_VAR resource = ~D5PAPR2~ END
        LPF ADD_ITEM_EQEFFECT INT_VAR insert_point = 0 opcode = 318 target = 1 parameter1 = 2 parameter2 = %this_row% timing = 2 STR_VAR resource = ~D5PAPR7~ END
      END
    END
  END
BUT_ONLY

 

I used RELATION = 11 in SPLPROT because it says over here: "11 - binary less (stat doesn't contain all the bits of value)"

 

In a nutshell, what this does is apply effects that say "set APR to 3/2," "set APR to 2," and "set SPR to 5/2." But before those effects there are effects that say "if you don't have exactly 2 proficiency points, then you are immune to the 3/2 APR effect; if you don't have 3 points, you are immune to the 2 APR effect; and if you don't have 4 points, you are immune to the 5/2 APR effect." The jump from 2 prof points to 3 should make APR go from 3/2 to 2... the 318 effect that checks for 2 points should return false, and thus make you immune to the 3/2 APR setting. I guess because 3 is bit-equal to 2, it is returning true. But I though using RELATION 11 would prevent that.

 

I know the quickest and dirtiest way to fix this would be to simply have the higher APR effect come later, so it supersedes the earlier one. But that's pretty dirty. I'd prefer to make sure the equipping effect accurately assesses your proficiency.

 

(Using bit-equality here... I don't want to use simple equality because I want to make sure that some mod using the upper bytes of the proficiency stats doesn't screw this up.)

Link to comment

I need this:

- If stat != 2 (bit2), then resist effect A

- If stat != 3 (bit2 + bit1), resist effect B

- If stat != 4 (bit3), resist effect C

 

What I'm really trying to achieve is much simpler in concept:

- If stat = 2, apply effect A

- If stat = 3, apply effect B

- If stat = 4, apply effect C

 

...but unfortunately there's no way to do that with timing mode 2, so we need to resort to double negatives instead.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...