track HP in chat

This commit is contained in:
centron\schwoerer
2025-11-14 09:25:31 +01:00
parent 15355c35ea
commit 5669aa75ca
6 changed files with 905 additions and 259 deletions

34
macro_stop-hp-tracking.js Normal file
View File

@@ -0,0 +1,34 @@
/**
* Deactivate HP tracking for the configured actor.
* Use after running macro_activate-hp-tracking.js to stop logging.
*/
const TARGET_ACTOR = game.actors.getName("Zeratal") ?? null;
const ACTOR_ID = TARGET_ACTOR?.id ?? "put-actor-id-here";
if (!ACTOR_ID || ACTOR_ID === "put-actor-id-here") {
return ui.notifications.warn("Set ACTOR_ID before running the macro.");
}
game.pf1 ??= {};
game.pf1.hpLogger ??= {};
const logKey = `pf1-hp-log-${ACTOR_ID}`;
const handler = game.pf1.hpLogger[logKey];
if (!handler) {
return ui.notifications.info(`No HP tracking hook found for ${TARGET_ACTOR?.name ?? ACTOR_ID}.`);
}
Hooks.off("updateActor", handler);
delete game.pf1.hpLogger[logKey];
if (game.pf1.hpLogger.sources instanceof Map) {
game.pf1.hpLogger.sources.delete(ACTOR_ID);
}
if (game.pf1.hpLogger.current) {
delete game.pf1.hpLogger.current[ACTOR_ID];
}
const actorName = game.actors.get(ACTOR_ID)?.name ?? TARGET_ACTOR?.name ?? ACTOR_ID;
ui.notifications.info(`HP tracking disabled for ${actorName}.`);