Skip to content

Fighter Cleric Usability Flag

GreenerGreener Member Posts: 430
I'm trying to allow fighter clerics to use axes, but I'm struggling with some of the code any thoughts?
COPY_EXISTING_REGEXP GLOB ~ax.*.itm~ ~override~ PATCH_IF (SOURCE_SIZE > 0x71) THEN BEGIN READ_BYTE 0x2f "use" WRITE_BYTE 0x2f ("%use%" BAND "0x4000") END BUT_ONLY_IF_IT_CHANGES

Comments

  • RaduzielRaduziel Member Posts: 4,714
    This is the code that DoF uses... it makes cleric have the same restriction that fighters has (what means none). A think that adapted for your needs it would be
    COPY_EXISTING_REGEXP ~ax.*.itm~ ~override~
    PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
    READ_LONG 0x64 ex_off
    READ_SHORT 0x68 glob_ex
    FOR (j = 0; j < glob_ex; ++j) BEGIN
    READ_SHORT (ex_off + (j * 0x38) + 0x0002) location
    PATCH_IF location = 1 BEGIN
    WRITE_BYTE 0x1e (THIS BAND 0b11111111)
    WRITE_BYTE 0x1f (THIS BAND 0b00001000)
    SET j = glob_ex
    END
    END
    END
    BUT_ONLY_IF_IT_CHANGES
  • GreenerGreener Member Posts: 430
    Raduziel said:

    This is the code that DoF uses... it makes cleric have the same restriction that fighters has (what means none). A think that adapted for your needs it would be

    COPY_EXISTING_REGEXP ~ax.*.itm~ ~override~
    PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
    READ_LONG 0x64 ex_off
    READ_SHORT 0x68 glob_ex
    FOR (j = 0; j < glob_ex; ++j) BEGIN
    READ_SHORT (ex_off + (j * 0x38) + 0x0002) location
    PATCH_IF location = 1 BEGIN
    WRITE_BYTE 0x1e (THIS BAND 0b11111111)
    WRITE_BYTE 0x1f (THIS BAND 0b00001000)
    SET j = glob_ex
    END
    END
    END
    BUT_ONLY_IF_IT_CHANGES
    Thank you
  • ArunsunArunsun Member Posts: 1,592
    edited July 2018
    Here's my take on the code. It should also include custom axes, as well as axes made by Beamdog, as these don't always use the ax prefix:
    COPY_EXISTING_REGEXP GLOB ~^.+\.itm$~ ~override~
    PATCH_IF (SOURCE_SIZE > 0x71) BEGIN
    READ_BYTE 0x1f usability2 //second byte of the usability flags, so bits 8 to 15.
    READ_BYTE 0x1c category //Item Type

    PATCH_IF (category = 25) BEGIN //Checks if the item is an axe, which is category 25. Another way of identifying if an item is an axe is by checking the proficiencies, but these should be equivalent
    WRITE_BYTE 0x1F (usability2 & 0b10111111) //Rewrites usability2 and sets its BIT 6 to 0
    END
    END
    BUT_ONLY_IF_IT_CHANGES
    If you want to allow axes for FMC too, replace 0b10111111 with
    0b00111111, to also set bit 15 (which matches FMC) to 0.

Sign In or Register to comment.