Jump to content

[b12] Make Barbarian Into a Class and dwhpbm.2da

Recommended Posts

While installing Tweaks Anthology on top of ToF, the HP components failed with this message:

ERROR: cannot convert rolls or %rolls% to an integer
ERROR: [dwhpbm.2da] -> [override/dwhpbm.2da] Patching Failed (COPY) (Not_found)

dwhpbm.2da is created by "Make Barbarian Into a Class", and when I opened that file, I find only this:

2DA V1.0

I'm guessting dwhpbm.2da is supposed to carry the new barbarian hp progression. To compare, the vanilla hpbarb.2da has a table such as:

1        12       1        0
2        12       1        0
Link to comment
Posted (edited)

Okay, looks like building that table didn't go right. %somespace% is definitely a failure to evaluate a variable; presumably, that should translate into some amount of whitespace so that header row looks pretty. But that, at least, is probably just a cosmetic error; the header row shouldn't contain any actual data, and failing to evaluate that data didn't change the number of entries in it. The complete lack of any actual data in the table may also be an issue; it's a stub with only the headers, which is a bad sign if we're ever going to read data from it.

Now, what is that table supposed to be? After all, hpbarb.2da already exists, and hpclass.2da assigns a hit point table to each class and kit. The "hpbm" label suggests it's for the barbarian/mage multiclass, much like hpfm.2da is for the fighter/mage multiclass. Except those multiclass tables are never actually used, and kits with larger HD pools than their base class don't get those in a multiclass (though that can't come up in the vanilla rules). But they're still in the standard format for an HP table.

Still, I'm not ruling out the possibility that this is part of a much trickier scheme. Time to look at the code (barbarian_class.tpa), and find where this table is created. It's assigned to all the barbarian multiclasses, and ... here.

	OUTER_FOR (level=1;level<=40;++level) BEGIN
		OUTER_SET $barb_mc_hp("%level%" "SIDES")=10
		OUTER_SET $barb_mc_hp("%level%" "ROLLS")=1
		OUTER_SET $barb_mc_hp("%level%" "MODIFIER")=level>=10?2:0
	LAF 2da_write STR_VAR file=dwhpbm.2da path="override" array=barb_hp_array default=0 END

Hmm. We just defined an array barb_mc_hp. Which has the standard format. And then didn't use it. Instead we used barb_hp_array, which is not otherwise mentioned in the file. So it's being defined somewhere else... I don't know where, and it would probably take a long time to find, but this particular error should be fixed by just using the newly defined array as was presumably intended.

I suspect the only reason this didn't completely break on its own is that part I mentioned above - the multiclass hp** tables are never actually used to generate HP numbers, and only affect the "Class Hit points/Level" display in the character sheet.

Edited by jmerry
Link to comment

I decided to test this component on a clean install (BGEE with SoD, beta 12 of ToF). Nothing else except DLCMerger installed.

ERROR: [.../stratagems-inline/blank] -> [override/dwhpbm.2da] Patching Failed (COPY) (Failure("Unknown return value: keys1_BGT_VAR"))

Install failed. It looks like the only way installation of "Make Barbarian a Class" succeeds at all is if barb_hp_array is defined in some other component first. (Obvious fix: use barb_mc_hp to define dwhpbm.2da instead, since that's the array that was just built.)

Looking back at previous versions ... beta 10 had the optimistic message "HP table for barbarian multiclass is generated properly". And indeed, that was an improvement. But unfortunately, that was only a fix for one of the bugs on that line. The "file" argument was updated to include the extension, while the mistaken "array" argument slipped through unnoticed.

Edited by jmerry
Link to comment

Update: after that failed install, I loaded up that game to test something else ... and the character creation screen had erroneous junk on it (For a dwarf, the class options included "Fighter{K=0,C=2}" and "Cleric{K=0,C=3}"). It didn't even uninstall cleanly when erroring out.

To reinforce the point, here's the WeiDU log:

// Log of Currently Installed WeiDU Mods
// The top of the file is the 'oldest' mod
// ~TP2_File~ #language_number #component_number // [Subcomponent Name -> ] Component Name [ : Version]
~DLCMERGER/DLCMERGER.TP2~ #0 #1 // Merge DLC into game -> Merge "Siege of Dragonspear" DLC: 1.3
// Recently Uninstalled: ~DW_TALENTS/DW_TALENTS.TP2~ #0 #40000 // Eliminate class/race restrictions and most class/ability score restrictions: Beta 12

[Sequence: in round one, I installed the restriction-removal component and then failed to install the barbarian class component. In round two, I uninstalled the restriction-removal component and then failed to install the barbarian class component]

In the rollback process of the failed install, the changes to dialog.tlk didn't roll back properly. The backup failed and those extra bits on class names (which would normally be hidden by ToF's UI hacks) became visible.

Edited by jmerry
Link to comment

OK, there are two things going on. Firstly, you're absolutely right about barb_mc_hp and barb_hp_array - just a typo. Second, the 2da_write function isn't being careful enough to sanitize empty arrays (like the nonexistent barb_hp_array) - WEIDU has some hardcoded bad behavior when you try to return an empty array, and you need to guard against it explicitly; 2da_write isn't doing so. That's how the random rubbish ends up in the 2da file - it's a previously-read array.

I can't reproduce the install failure (much less the failure to roll back dialog patching, which looks like a WEIDU error) but I guess it doesn't matter too much since the underlying cause is clear (and fixed locally). Thanks for the detective work.

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.

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