Jump to content

How to make weapon equip-able to a kit that cant have it normally?


Recommended Posts

I made a mod to alter the beastmaster kit. One of the changes I made was to restore some of the weapon proficiencies from the base ranger:

Quote

 

    COPY_EXISTING ~WEAPPROF.2DA~ ~override~ // Restores Beast Masters weapon proficiencies

                COUNT_2DA_COLS cols
                READ_2DA_ENTRIES_NOW rows cols
                FOR (row = 0; row < 23; ++row) BEGIN
                    READ_2DA_ENTRY_FORMER rows row 38 ~prof~
                    PATCH_IF ~%prof%~ STRING_EQUAL_CASE ~0~ BEGIN
                      SET_2DA_ENTRY row 38 cols ~2~
                    END
                END

 

In-game I can now put pips into these weapons. But I cant equip them. For example, I can put pips into Longswords, but they have the red background and cant be equipped. 

So where do I need to go to change what weapons can be equipped?

Edited by Enkidu555
Link to comment

Weapon usability is on the weapons themselves. There's one four-byte flag field that covers race, class, and alignment, and four one-byte flag fields for kits. The beastmaster flag is in the second of those kit flag groups. (In all of these cases, setting the flag means that anyone with the specified characteristic can't use the item)

Link to comment
Posted (edited)
40 minutes ago, jmerry said:

Weapon usability is on the weapons themselves. There's one four-byte flag field that covers race, class, and alignment, and four one-byte flag fields for kits. The beastmaster flag is in the second of those kit flag groups. (In all of these cases, setting the flag means that anyone with the specified characteristic can't use the item)

I found it on one... which means I need to have to go through every eligible weapon and change it... you wouldn't happen to know an easy loop to go through them all would you? I searched and found 220 items they cant use.

Each item has a weapon prof field I can probably have it check. I just need to know how to make it check all items.

Edited by Enkidu555
Link to comment
Posted (edited)

Ok so I haven't coded for these games in years so I don't remember a lot. Here's what I have so far for just BG1EE. I know it doesn't work at all but it shows the flow I want it to go:

 

Quote

                FOR (item = 0; item < 2153; ++item) BEGIN //number of items in the game
                    Read ~PLACEHOLDER.ITM~                                                                // No idea how to make it shift through each item or how to make it read the item.
                        FOR (weapon = 89; weapon < 102; ++weapon) BEGIN   // Loops through all the weapons that I want the beastmaster to be proficient in.
                            INT_VAR
                                opcode = 233                                                // Need this to know that im checking opcode #233
                                IF    (Parameter1 = weapon) & (Parameter2 = 0b******1*)   // P1 checks the specific weapon prof. P2 is trying to check that specific bit that means the beastmaster cant use it.
                                    COPY_EXISTING ~PLACEHOLDER.ITM~ ~override/PLACEHOLDER.ITM~
                                        LAUNCH_PATCH_FUNCTION ~ALTER_ITEM_EFFECT~
                                            INT_VAR
                                                opcode = 233
                                                Parameter2 = 0b******0*              // Changes the bit to allow beastmasters to use it.
                                        END
                        END
                END

 

Edited by Enkidu555
Link to comment
Posted (edited)

Ok it installs but when I start a new save... I still cant equip weapons like a battle axe, longsword, etc. 

 

Near Infinity shows nothing in override. So that part of the code is doing nothing.

I think its "PATCH_IF (weapon = 0x**) BEGIN" lines. I tried just copying the battle axe and removing this line and it worked. so for some reason, "weapon" is not the values it should be.

 

For an axe, it should output 0x19. So "PATCH_IF (weapon = 0x19) BEGIN" should work. But it isnt.

 

Quote

    

    COPY_EXISTING_REGEXP ~.*\.itm~ ~override~
        PATCH_IF (SOURCE_SIZE > 0x71) BEGIN // avoid crashing on empty items
        READ_SHORT 0xE9 weapon ELSE 0x0e // checks weapon prof needed. ELSE is for items that go out of bounds

                PATCH_IF (weapon = 0x0f) BEGIN 
                    READ_BYTE 0x2b class // Reads section that says if unusable by beastmaster
                        PATCH_IF ((class BAND 0b00000010)= 0b00000010) BEGIN  // Checks if the weapon is unusable by beastmasters.
                            WRITE_BYTE 0x2b (class BAND 0b11111101)
                        END
                END

            
// skipping similar code
            PATCH_IF (weapon = 0x45) BEGIN
                READ_BYTE 0x2b class
                    PATCH_IF ((class BAND 0b00000010)= 0b00000010) BEGIN  // Checks if the weapon is unusable by beastmasters.
                        WRITE_BYTE 0x2b (class BAND 0b11111101)
                    END
            END
        END     
BUT_ONLY_IF_IT_CHANGES

 

Edited by Enkidu555
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...