dnd5e
dnd5e copied to clipboard
Feature request actor.calcluateDamage
After the call to dnd5e.preCalculateDamage, damage.active is force set to {} / {active: "Immunity", multiplier: 0). In midi-qol I have occasion to want to configure some of the actives during the preCalculateDamage hook, so that multipliers can be applied prior to damage modification.
Would it be possible to have damage.active initialised to {} prior to the call to dnd5e.preCalculateDamage?
Hmm, what is your intention here exactly? Do you want us to not squash any changes made to active
during preCalculateDamage
? If you set active.multiplier
to 2
during preCalculateDamage
, are you thinking we'll then modify that value (so if you doubled during pre-calc and then halved during our modification it would end up as 1
)?
The exact change I would like is that if in calculateDamage, damage.active is already defined don't initialise it to {}. And yes, I'd expect that you base other calculations off the multiplier that was set in preCalc, so in you example the changes made in preCalc would be do double the damage.value and set the multiplier. If the calculateDamage has a half damage the damage.value would end up as the original value and the multiplier would end up being 1.
Which would entail changing
let damageMultiplier = multiplier;
to
let damageMultiplier = (damage.active?.multiplier ?? 1) * multiplier;
The specific example I have is computing damage when the target has saved. According to at least one rules interpretation the correct order of damage calc should be saves -> modifications -> resistance/immunity. Currently if I pass options.multiplier the order will be modifications/resistance/saves.
There is also an interpretation that says what is currently being done is correct, so I also have the case of simply setting the multiplier in options during precalculate damage (thanks for the change to make that possible by the way).
So I'm looking to implement the changes due to saves in the preCalculateDamage hook.
I have code to set the multiplier/active/actual damage for each damage item according to the save, but the multiplier per damage item get overwritten (and the active.saved that I set), however the calculated damage is correct.
@tposney Let me know if this does what you need: https://github.com/foundryvtt/dnd5e/pull/3491
Looks like exactly what I wanted - many thanks.