Jump to content

[QUESTION] How to filter by magical flag?


Recommended Posts

Posted

Hi, I'm trying to remove critical hit protection from all non-magical helmets, but my code doesn't seem to be filtering by the magical flag.

Any assistance would be appreciated.

COPY_EXISTING_REGEXP "^.+\.itm" override   
  PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN
    READ_SHORT 0x1c type
    READ_BYTE 0x18 flags
      PATCH_IF (type = 7) BEGIN
        PATCH_IF (flags BOR BIT6) BEGIN
          PATCH_IF ( (flags & 4) = 4 ) BEGIN	
          WRITE_BYTE 0x1b THIS | 2 
        END
      END
    END  
  END  
BUT_ONLY_IF_IT_CHANGES

 

Posted (edited)
        PATCH_IF (flags BOR BIT6) BEGIN
          PATCH_IF ( (flags & 4) = 4 ) BEGIN	



grrr @ forum, but that part of the code looks suspicious. Why two checks?
Edited by lynx
Posted (edited)

@lynx hmmm good point, to be fair I'm not sure, I've been scouring the forums and other mods for code.

Edited by a.greene
Posted
20 minutes ago, a.greene said:
        PATCH_IF (flags BOR BIT6) BEGIN
          PATCH_IF ( (flags & 4) = 4 ) BEGIN	
          WRITE_BYTE 0x1b THIS | 2 
        END

The first IF condition for flags will always return true because the result of the condition is always non-zero. I would also combine both flags checks into a single condition. The code would look like this:

        PATCH_IF ( (flags BAND (BIT2 BOR BIT6)) = BIT2 ) BEGIN  // is "Droppable" and not "Magical"
          WRITE_BYTE 0x1b (THIS BOR BIT1)   // enable "toggle critical hits"
        END

 

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...