Skip to content

Commit

Permalink
Added Condition animation as well
Browse files Browse the repository at this point in the history
closes #2
  • Loading branch information
ChasarooniZ committed Jun 26, 2024
1 parent 260e040 commit 04f395f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
45 changes: 44 additions & 1 deletion scripts/misc.js
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
export const MODULE_ID = 'pf2e-reactive-token-ring';
export const MODULE_ID = "pf2e-reactive-token-ring";
export const CONDITIONS = {
POSITIVE: [
"concealed",
"hidden",
"invisible",
"quickened",
"undetected",
],
NEGATIVE: [
"blinded",
"clumsy",
"confused",
"controlled",
"dazzled",
"deafened",
"doomed",
"drained",
"dying",
"encumbered",
"enfeebled",
"fascinated",
"fatigued",
"fleeing",
"frightened",
"grabbed",
"immobilized",
"off-guard",
"paralyzed",
"persistent-damage",
"petrified",
"prone",
"restrained",
"sickened",
"slowed",
"stunned",
"stupefied",
],
DEAD: [
"dead",
"unconscious",
"wounded",
]
};
16 changes: 15 additions & 1 deletion scripts/module.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MODULE_ID } from "./misc.js";
import { CONDITIONS, MODULE_ID } from "./misc.js";
import { registerSettings } from "./settings.js";

Hooks.once("init", async function () {
Expand All @@ -11,6 +11,8 @@ const COLORS = {
PURPLE: "#9370DB",
WHITE: "#FFFFFF",
DEEPSKYBLUE: "#00BFFF",
ORANGE: "#FFA500",
PINK: "#FF69B4",
};
Hooks.once("ready", async function () {
Hooks.on("updateActor", async (actor, update, status, _userID) => {
Expand Down Expand Up @@ -51,6 +53,18 @@ Hooks.once("ready", async function () {
flashColor(token, color, getAnimationChanges("target", { token }));
}
});
Hooks.on("applyTokenStatusEffect", async (token, name, _unknown) => {
const conditions = [...token.actor.conditions.#conditionsHad];
const isAdded = conditions.includes(name);
//condition was added
if (CONDITIONS.POSITIVE.includes(name)) {
if (isAdded) flashColor(token, COLORS.PINK);

//condition was removed
} else if (CONDITIONS.NEGATIVE.includes(name)) {
if (isAdded) flashColor(token, COLORS.ORANGE);
}
});
});

/**
Expand Down

0 comments on commit 04f395f

Please sign in to comment.