jbhaywood / 5e-statblock-importer

A module for FoundryVTT that creates a new actor from any 5e monster or NPC statblock.
MIT License
18 stars 14 forks source link

Add proper support for damage resistance bypasses #60

Closed arbron closed 11 months ago

arbron commented 1 year ago

A few versions ago dnd5e added proper support for resistances like "bludgeoning, piercing, and slashing from nonmagical attacks", but the importer doesn't yet support them.

"dr": {
  "value": ["bludgeoning", "piercing", "slashing"],
  "bypasses": ["magical"]
}
MaxPat931 commented 11 months ago

Changing this line https://github.com/jbhaywood/5e-statblock-importer/blob/ac12be9d5dd3ae071252ec7a6ebb33aadfb9163a/scripts/sbiParser.js#L619 To

const actorData = sbiUtils.assignToObject({}, `data.traits.${typeValue}.bypasses`, "mgc")

should do it

may want to add additional checks for the other bypasses, adamantine and silvered

if (foundLine.toLowerCase().includes("adamantine")) {
                    const actorData = sbiUtils.assignToObject({}, `data.traits.${typeValue}.bypasses`, "ada")
                    await actor.update(actorData);
                }
if (foundLine.toLowerCase().includes("silvered")) {
                    const actorData = sbiUtils.assignToObject({}, `data.traits.${typeValue}.bypasses`, "sil")
                    await actor.update(actorData);
                }