Skip to content

Commit

Permalink
0hp will remove auras again
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPrimate committed Jan 14, 2023
1 parent 2ecf75a commit 559f990
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,7 @@ Auras in 5e will support the `isSuppressed` flag, and triggered by attunement an
# 0.5.4

Don't trigger effect removal when times-up expires an effect as it cleans up for us.

# 0.5.5

Going to 0 hp will now remove effects such as Paladin Auras once again.
20 changes: 20 additions & 0 deletions src/AAhelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,26 @@ class AAhelpers {
}
}

static EventHPCheck(event) {
// if this is not a hp/wound check then assune not dead
if (!hasProperty(event, "system.wounds") && !getProperty(event, "system.attributes.hp")) {
return false;
}
switch (game.system.id) {
case "dnd5e": ;
case "sw5e": {
if (getProperty(event, "system.attributes.hp.max") === 0) return true; // dead
if (getProperty(event, "system.attributes.hp.value") > 0) return false; //alive!
else return true; // dead
}
case "swade": {
let { max, value, ignored } = event.system.wounds;
if (value - ignored >= max) return false;
else return true; // dead
}
}
}

static ExtractAuraById(entityId, sceneID) {
if (!AAgm) return;
const MapKey = sceneID;
Expand Down
2 changes: 1 addition & 1 deletion src/AAhooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Hooks.on("canvasReady", (canvas) => {

Hooks.on("preUpdateActor", (actor, update) => {
if (canvas.scene === null) { if (AAdebug) { console.log("Active Auras disabled due to no canvas") } return }
if (AAhelpers.HPCheck(actor)) {
if (AAhelpers.HPCheck(actor) || AAhelpers.EventHPCheck(update)) {
if (AAdebug) console.log("Actor dead, checking for tokens and auras", { actor, update });
const activeTokens = actor.getActiveTokens();
if (activeTokens.length > 0 && AAhelpers.IsAuraToken(activeTokens[0].id, canvas.id)) {
Expand Down
2 changes: 1 addition & 1 deletion src/collateAuras.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function CollateAuras(sceneID, checkAuras, removeAuras, source) {
//Skips over MLT coppied tokens
if (testToken.flags["multilevel-tokens"]) continue;
// applying auras on dead?
if (AAhelpers.HPCheck(testToken) && game.settings.get("ActiveAuras", "dead-aura")) {
if (game.settings.get("ActiveAuras", "dead-aura") && AAhelpers.HPCheck(testToken)) {
if (AAdebug) console.log(`Skipping ${testToken.name}, "DEAD/0hp"`);
continue;
}
Expand Down

0 comments on commit 559f990

Please sign in to comment.