diff --git a/scripts/misc.js b/scripts/misc.js index 7744e9b..f10dfd6 100644 --- a/scripts/misc.js +++ b/scripts/misc.js @@ -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", + ] +}; diff --git a/scripts/module.js b/scripts/module.js index b72d834..6b216c5 100644 --- a/scripts/module.js +++ b/scripts/module.js @@ -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 () { @@ -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) => { @@ -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); + } + }); }); /**