diff --git a/scripts/BloodSplatter.js b/scripts/BloodSplatter.js index 4d90fb8..b0049db 100644 --- a/scripts/BloodSplatter.js +++ b/scripts/BloodSplatter.js @@ -257,8 +257,8 @@ class BloodSplatter { static belowTreshold(actor) { if (!actor) return false; - const hpMax = BloodSplatter.getHpMax(actor.data); - const hpVal = BloodSplatter.getHpVal(actor.data); + const hpMax = BloodSplatter.getHpMax(actor); + const hpVal = BloodSplatter.getHpVal(actor); if ( (100 * hpVal) / hpMax <= game.settings.get("splatter", "bloodsplatterThreshold") @@ -266,14 +266,14 @@ class BloodSplatter { return true; return false; } - static getHpVal(actorData) { + static getHpVal(actor) { return getProperty( - actorData, + actor.system ?? actor, game.settings.get("splatter", "currentHp") ); } - static getHpMax(actorData) { - return getProperty(actorData, game.settings.get("splatter", "maxHp")); + static getHpMax(actor) { + return getProperty(actor.system ?? actor, game.settings.get("splatter", "maxHp")); } static getCreatureType(actorData) { return getProperty( @@ -336,7 +336,7 @@ class BloodSplatter { return useWounds ? BloodSplatter.getImpactScaleWounds(actor, updates, diff) : BloodSplatter.getImpactScaleStandard(actor, updates, diff); } static getImpactScaleStandard(actor, updates, diff) { - const hpMax = BloodSplatter.getHpMax(actor.data); + const hpMax = BloodSplatter.getHpMax(actor); const oldHpVal = diff.oldHpVal; //BloodSplatter.getHpVal(actor.data); const hpVal = BloodSplatter.getHpVal(updates); const impactScale = (oldHpVal - hpVal) / hpMax + 0.7; @@ -350,7 +350,7 @@ class BloodSplatter { } } static getImpactScaleWounds(actor, updates, diff) { - const hpMax = BloodSplatter.getHpMax(actor.data); + const hpMax = BloodSplatter.getHpMax(actor); const oldHpVal = diff.oldHpVal; //BloodSplatter.getHpVal(actor.data); const hpVal = BloodSplatter.getHpVal(updates); const impactScale = (hpVal - oldHpVal) / hpMax + 0.7; @@ -401,7 +401,7 @@ Hooks.once("socketlib.ready", () => { }); Hooks.on("preUpdateActor", function (actor, updates, diff) { - diff.oldHpVal = BloodSplatter.getHpVal(actor.data); + diff.oldHpVal = BloodSplatter.getHpVal(actor); }); Hooks.on("updateActor", function (actor, updates, diff) { diff --git a/scripts/config.js b/scripts/config.js index a86eb42..167d36a 100644 --- a/scripts/config.js +++ b/scripts/config.js @@ -226,7 +226,7 @@ Hooks.once("init", function () { scope: "world", config: true, type: String, - default: "data.details.type.value", + default: "details.type.value", }); game.settings.register("splatter", "creatureTypeCustom", { @@ -235,7 +235,7 @@ Hooks.once("init", function () { scope: "world", config: true, type: String, - default: "data.details.type.custom", + default: "details.type.custom", }); game.settings.register("splatter", "BloodSheetData", { @@ -273,7 +273,7 @@ Hooks.once("init", function () { scope: "world", config: true, type: String, - default: "data.attributes.hp.value", + default: "attributes.hp.value", }); game.settings.register("splatter", "maxHp", { @@ -282,7 +282,7 @@ Hooks.once("init", function () { scope: "world", config: true, type: String, - default: "data.attributes.hp.max", + default: "attributes.hp.max", }); game.settings.register("splatter", "useWounds", {