Skip to content

Commit

Permalink
updated v10 data paths
Browse files Browse the repository at this point in the history
  • Loading branch information
theripper93 committed Jul 10, 2022
1 parent 15656df commit 826728a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions scripts/BloodSplatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,23 +257,23 @@ 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")
)
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(
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand All @@ -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", {
Expand Down Expand Up @@ -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", {
Expand All @@ -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", {
Expand Down

0 comments on commit 826728a

Please sign in to comment.