Lavaeolous / PF1-StatBlock-Converter-Module

FoundryVTT Module to convert PF1 Statblocks into Foundry Actors (PC or NPC).
MIT License
14 stars 12 forks source link

BAB not calculating beyond 1st level #506

Closed RobTheDM closed 2 years ago

RobTheDM commented 2 years ago

It seems that when any creature or NPC is imported, the BAB for their class(es) doesn't calculate beyond 1st level despite how many levels or HD they have. The only fix I've found is going in and removing the classes and readding them from the compendium. And I know it wasn't always doing this, the issue seems relatively new. I've ran into the issue now with multiple statblocks, both imported from the statblock library module and directly copy/pasted from aonprd.

Lavaeolous commented 2 years ago

I'll check if some of the recent updates to the pathfinder system broke something on my end! Thanks for letting me know

RobTheDM commented 2 years ago

Actually now that I've encountered this several more times, it looks like the root issue is it's not counting levels beyond the 1st one. So if you import something with 10 levels of fighter, it just thinks they're level 1. Something with 8 undead HD, nah that's just a 1 HD undead. The last day or two, everything I've imported has had this issue. So something recent must have broken it. It's easy enough to manually fix now that I'm aware of it at least.

mkahvi commented 2 years ago

This seems to be because the class records item.data.data.hitDice which is not a thing, deleting that made everything work fine. I just can't find where in the code it does that, it doesn't seem to do it, but it was in the output.

mkahvi commented 2 years ago

If I had to guess, SBC is currently fetching documents from compendiums and pushing those documents raw for updates, instead of using .toObject() on them to strip derived data and such out.

Yet that's not true. This is weird.

Edit: Regardless, this little macro fixes the BAB problem at least:

actor.itemTypes.class.forEach(cls => cls.update({"data.-=hitDice": null}));
mkahvi commented 2 years ago

Alright, I found the cause.

Item.toObject(false) seems to also include getter values for some reason, which makes it include hitDice getter's value.

Best solution I feel is to transition to plain .toObject() and use item.data.update() to set values on the temporary items.

This also eliminates storing a lot of derived and supposed-to-be-temporary data.

Lavaeolous commented 2 years ago

Yeah, i think that may be artifacts remaining from the transition to v0.8 of foundry, see #439. It seems to work with toObject() now, so the change is fine with me!