Jump to content

[QUESTION] How to increase damage for all items in one class?


Recommended Posts

Good morning I'm trying to increase the damage for all spears from 1d6 to 1d8, for some reason while I'm copying all spears the patch is failing to change the dice size? Any ideas?

Thank you

BEGIN ~Restore Two-Handed Spear Damage (PnP)~

ACTION_IF FILE_EXISTS_IN_GAME ~enginest.2da~ BEGIN

COPY_EXISTING_REGEXP ~SPER.*\.ITM~ ~override~
PATCH_IF SOURCE_SIZE > 0x2d3 BEGIN        
LPF ALTER_ITEM_HEADER INT_VAR header_type = 1 dicesize = 8 END
END
END
Link to comment

And what are you basing that "fail to change" on? The descriptions? Because the damage listing there is part of the text; it's not auto-generated, and you'll want to update the description too.

Also, just grabbing items based on the file name is flawed; you'll miss spears like KUOSPER or SAHSPEAR or x#kispr. (The first two are in the base game, while the third is added by the BG1 NPC Project.) If I were making this component - and it's something I've thought about - I'd use a combination of the item's category and proficiency fields to identify what items are spears.

Link to comment

@jmerry I ended up using the following, although suggestions are always appreciated..

BEGIN ~Restore Two-Handed Spear Damage (PnP)~

ACTION_IF FILE_EXISTS_IN_GAME ~enginest.2da~ BEGIN

COPY_EXISTING_REGEXP "^.+\.itm" override
PATCH_IF SOURCE_SIZE > 0x71 BEGIN
READ_BYTE 0x31 prof
READ_SHORT 0x1c type
PATCH_IF (prof = 98) BEGIN	
LPF ALTER_ITEM_HEADER INT_VAR header_type = 1 dicesize = 8 dicenumber = 1 END
FOR (index = 0x54 ; index >= 0x50 ; index -= 4) BEGIN
READ_LONG index valid
PATCH_IF (valid < 2147483646) AND (valid >= 0) BEGIN
READ_STRREF index description
PATCH_IF (~%description%~ STRING_CONTAINS_REGEXP ~1d6~) = 0 BEGIN
INNER_PATCH_SAVE new_desc ~%description%~ BEGIN
REPLACE_TEXTUALLY ~1d6~ ~1d8~ END
SAY_EVALUATED index ~%new_desc%~
END
END
END
END
END
END

 

Link to comment

Oh, ack. Please tell me that your actual code has indentation, and that just got stripped when you copied it over here?

On your description change - it's possible for "1d6" to show up in more than just the primary weapon damage listing. And it does, for Ixil's Spike +6.

Quote

With shaft and tip reunited, Ixil's Spike is a fearsome weapon. During the battle, the head can detach to pin opponents to the ground even as a new head magically reforms on the end of the spear.

STATISTICS:

Equipped abilities:
– Free Action

Combat abilities:
– Hit target is pinned for 3 rounds and takes an additional 1d6+5 piercing damage each round (Save vs. Paralysis negates)

THAC0: +6
Damage: 1d6+6 (piercing)
Speed Factor: 1 
Proficiency Type: Spear 
Type: Two-handed
Requires:
 5 Strength

Weight: 5

Flavor-wise, that spear is effectively hitting again every round the target is pinned. So then, I'd let both instances of "1d6" in the description change, and update the dice size on the additional piercing damage effects accordingly. Either just for this one spear, or generalize to any effects that deal dice-based piercing damage.

Luckily, there aren't any other d6-based damage effects on spears (with descriptions) in standard BGEE/BG2EE. The only other dice-based damage effect I could spot was a 2d4 magic damage from the Shadowed Spear in SoD.

Edited by jmerry
Link to comment
Guest morpheus562

@a.greene please feel free to look over my Forgotten Armament code (NWN2 Style Weapons component) for how to update all spears to 1d8 base damage (and an additional +1d8 crit damage) and update all descriptions while accounting for the nuances that @jmerry references.

Link to comment
On 6/21/2023 at 2:36 PM, jmerry said:

Oh, ack. Please tell me that your actual code has indentation, and that just got stripped when you copied it over here?

This reminds me of back in WarCraft 3, some modders would use an "optimizer" that stripped all indentation and comments while changing all their function and variable names to combinations of "i"s and lower-case "L"s, so everything would look like "function IIiliIliI" and "function illIiIlili" and so on. Was always a blast to trawl through such "optimized" code - losing just indentation seems quaint in comparison.

Link to comment

@Bartimaeus I'm pretty new at this...

Is this satisfactory?

BEGIN ~Restore Two-Handed Spear Damage (PnP)~

ACTION_IF FILE_EXISTS_IN_GAME ~enginest.2da~ BEGIN
  COPY_EXISTING_REGEXP "^.+\.itm" override
    PATCH_IF SOURCE_SIZE > 0x71 BEGIN
      READ_BYTE 0x31 prof
      READ_SHORT 0x1c type
      PATCH_IF (prof = 98) BEGIN	
        LPF ALTER_ITEM_HEADER INT_VAR header_type = 1 dicesize = 8 dicenumber = 1 END
        FOR (index = 0x54 ; index >= 0x50 ; index -= 4) BEGIN
          READ_LONG index valid
          PATCH_IF (valid < 2147483646) AND (valid >= 0) BEGIN
            READ_STRREF index description
            PATCH_IF (~%description%~ STRING_CONTAINS_REGEXP ~1d6~) = 0 BEGIN
              INNER_PATCH_SAVE new_desc ~%description%~ BEGIN
                REPLACE_TEXTUALLY ~1d6~ ~1d8~ 
              END
              SAY_EVALUATED index ~%new_desc%~
            END
          END
        END
      END
    END
    BUT_ONLY_IF_IT_CHANGES
END

 

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