a.greene Posted October 7 Posted October 7 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 Quote
lynx Posted October 7 Posted October 7 (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 October 7 by lynx Quote
a.greene Posted October 7 Author Posted October 7 (edited) @lynx hmmm good point, to be fair I'm not sure, I've been scouring the forums and other mods for code. Edited October 7 by a.greene Quote
argent77 Posted October 7 Posted October 7 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 Quote
Recommended Posts
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.