Jump to content

Removing Nat 1 & 20s


Recommended Posts

Managed to piece it together using opcodes 301 and 362. Thanks to CamDawg for providing the TP2 code template for patching effects.

To remove guaranteed hits on Nat 20s (or 18, 19, depending on crit range) [Will also remove crits altogether]:

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
  READ_BYTE   0x33 fx_flag
  READ_LONG  0x2c4 fx_off
  READ_LONG  0x2c8 fx_num
  WRITE_LONG 0x2c8 (fx_num + 1)
  // fix offsets after inserted effects
  PATCH_FOR_EACH offset IN 0x2a0 0x2a8 0x2b0 0x2b8 0x2bc BEGIN
    READ_LONG offset offset_val
    PATCH_IF (fx_off <= offset_val) BEGIN
      WRITE_LONG offset (offset_val + 0x30 + (fx_flag * 0xd8))
    END
  END
  INSERT_BYTES fx_off (0x30 + (fx_flag * 0xd8))
  WRITE_SHORT (fx_off +        (fx_flag * 0x08)) 301
  WRITE_BYTE  (fx_off + 0x02 + (fx_flag * 0x0a)) 1
  WRITE_LONG  (fx_off + 0x04 + (fx_flag * 0x10)) 0xfffffffd
  WRITE_BYTE  (fx_off + 0x0c + (fx_flag * 0x10)) 9
  WRITE_BYTE  (fx_off + 0x12 + (fx_flag * 0x12)) 100
  BUT_ONLY

and to remove guaranteed misses on Nat 1s:

COPY_EXISTING_REGEXP GLOB ~^.+\.cre$~ ~override~
  READ_BYTE   0x33 fx_flag
  READ_LONG  0x2c4 fx_off
  READ_LONG  0x2c8 fx_num
  WRITE_LONG 0x2c8 (fx_num + 1)
  // fix offsets after inserted effects
  PATCH_FOR_EACH offset IN 0x2a0 0x2a8 0x2b0 0x2b8 0x2bc BEGIN
    READ_LONG offset offset_val
    PATCH_IF (fx_off <= offset_val) BEGIN
      WRITE_LONG offset (offset_val + 0x30 + (fx_flag * 0xd8))
    END
  END
  INSERT_BYTES fx_off (0x30 + (fx_flag * 0xd8))
  WRITE_SHORT (fx_off +        (fx_flag * 0x08)) 362
  WRITE_BYTE  (fx_off + 0x02 + (fx_flag * 0x0a)) 1
  WRITE_LONG  (fx_off + 0x04 + (fx_flag * 0x10)) 0xffffffff
  WRITE_BYTE  (fx_off + 0x0c + (fx_flag * 0x10)) 9
  WRITE_BYTE  (fx_off + 0x12 + (fx_flag * 0x12)) 100
  BUT_ONLY

Cheerios!

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