const api = game.modules.get("dxcufgbs-death-trigger").api;
api.findTriggers(actor); // the actor's items that count as death triggers → Item[]
await api.alert(actor); // posts the GM alert card for this actor now, whatever its HP → the ChatMessage, or null if it has no death triggers
api.triggerStatus(item); // → { trigger, reason, detail }; reason: "always" | "never" | "list" | "none"
api.hpPathFor(actor); // the HP path inside actor.system the module watches, e.g. "attributes.hp.value"
api.getList(); // the world's list ({ version, triggerTypes, features }), or null before it is set up
api.isListed("Undead Fortitude"); // a name or an item → true / false
await api.addToList(item); // GM: adds the item (or a name) to the list → true if it was added
await api.removeFromList(item); // GM: removes the entries matching that name or item (see Remove above) → true if any were removed
api.exportList(); // GM: downloads the list as death-triggers-<world id>.json
await api.importList(); // GM: opens the file picker and the Yes/No warning → true if the list was replaced
await api.resetList(); // GM: replaces the world's list with the default list, without asking → true when done
await api.configureItem(item); // GM: opens the Automatic / Always / Never dialog for this item
alert(actor, triggers)takes an optional array of items to show on the card (default:findTriggers(actor)). It doesn't check HP, the Only check non-player creatures setting or whether the creature was already alerted. Any user can call it; the card is always whispered to the GMs.- GM calls do nothing for players (they return
false, or nothing forexportListandconfigureItem).addToListalso returnsfalsewhen the name is already in the list. List changes show a notification. triggerStatus(item): the item's own Always / Never setting wins, then the list. Whenreasonis"list",detailis the name of the matching list entry.removeFromListworks like Remove in the context menu; see The Death Trigger List.
From another module
The API is set in the module's ready hook, so it isn't there during init or setup, and depending on load order it may not be there yet when your own ready runs. Look it up when you need it, and make it optional:
function deathTriggers(actor) {
const api = game.modules.get("dxcufgbs-death-trigger")?.api; // undefined when the module is missing or not enabled
return api ? api.findTriggers(actor) : [];
}
Add { "id": "dxcufgbs-death-trigger", "type": "module" } to relationships.recommends in your module.json.
Reacting to an alert
The module calls no hooks of its own. To react to an alert, watch for its chat card. It is whispered to the GMs, so it only reaches GM clients:
Hooks.on("createChatMessage", async message => {
if (!message.getFlag("dxcufgbs-death-trigger", "alert")) return;
const actor = await fromUuid(message.getFlag("dxcufgbs-death-trigger", "actorUuid"));
const itemUuids = message.getFlag("dxcufgbs-death-trigger", "itemUuids"); // the features on the card
console.log(`${actor?.name} dropped to 0 HP with ${itemUuids.length} death trigger(s)`);
});
Data
flags.dxcufgbs-death-trigger.triggeron Items:true(always a death trigger),false(never), unset (follow the list). See Excluding Features.flags.dxcufgbs-death-triggeron the alert card:alert: true,actorUuid(the creature) anditemUuids(the features on the card).- The list (what
getList()returns, what Export writes and Import reads):{ "version", "triggerTypes", "features" }, whereversionis the list version (2 for the current default list) andtriggerTypesnames the trigger types. Each feature needs aname;matchis"exact"(the default) or"contains", andaliasesis an optional array of other names that match too.ididentifies the entry; the other fields (type,owner,edition,source,trigger,effect, …) only describe it. Import refuses a file without afeaturesarray or with an entry that has no name. In the module's default list, entries added after the first version carrylistVersion.
This page mirrors the Death Trigger Alerts wiki on GitHub.