PDA

View Full Version : Improving critical damage parsing (4E dnd)



Facjad
November 2nd, 2025, 01:09
Hello,

I learned just now by searching in the code that the bonus critical damage for weapons in 4E are actually parsed by the system when added to a character sheet. The problem is that the field needs to end with "critical damage". It so happens that the items in the 4E compendium do not contain the keyword "critical", so that that field is always ignored by the system.

I think it would improve QoL of 4E users to just change the following on line 781 of manager_char.lua :
local nStarts, nEnds, sDice, sDmgType = string.find(sCritical, "%+(%d[d%+%d%s]*)%s?(%a*)%scritical%sdamage");
instead, use something like :
local nStarts, nEnds, sDice, sDmgType = string.find(sCritical, "%+?(%d[d%+%d%s]*)%s?(%a-)%s?c?r?i?t?i?c?a?l?%sdamage");

In other words, make the " critical" optional, and also the "+" at the beginning while we're at it.

This would make the system a lot more flexible.

Thanks in advance !

Edit: in hindsight, %s?c?r?i?t?i?c?a?l? is probably a bad idea, but (%scritical)? didn't work, I'm not very well versed in lua regexp...

Moon Wizard
November 4th, 2025, 05:31
Unfortunately, it's more complicated than that; because the critical text can contain special cases.

These are from the original 4E PHB:
"+5d6 critical damage, or +5d8 critical damage if you have combat advantage"
"+4d8 critical damage, or +4d12 critical damage against dragons"
"+5d6 radiant critical damage, and you can spend a healing surge"

So, technically, the compendium output should be updated to match the original PHB format. I'll see if I can make it a little smarter, if I can figure out the logic.

Regards,
JPG

Facjad
November 4th, 2025, 20:48
That's weird, because in the rulebooks, it is not written like that, it is just "+1d8 damage per plus", which I would naturally convert to "+4d8 damage" in case of a +4 weapon.
65720

Moon Wizard
November 4th, 2025, 23:23
Huh, then it must have been from the first parser (which is long gone); which is where I got my original data modules.

Regards,
JPG