35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
/**
|
|
* 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}.`);
|