Skip to content

Commit

Permalink
feat: auto-bloodied flags
Browse files Browse the repository at this point in the history
A pair of flags for actors:
dracsTools.autoBloodied.ignore -> auto bloodied/dead ignores this actor completely
dracsTools.autoBloodied.npcDiesLikePC -> NPC will go unconscious like a PC on 0 hits
  • Loading branch information
draconas1 committed Jul 22, 2024
1 parent 5538f7d commit eb807d4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion module/hooks/auto-bloodied-dead.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export async function setBloodiedDeadOnHPChange(actor, change, options, userId)
// only fire if the HP changed
if(change.system?.attributes?.hp?.hasOwnProperty('value')) {
DnD4eTools.log(false, "Firing bloodied update for " + game.users.get(userId).name)

if (actor.flags.dracsTools?.autoBloodied?.ignore) {
DnD4eTools.log(false, "Actor has auto-bloodied ignored")
return;
}

const newHP = change.system.attributes.hp.value
const maxHP = actor.system.attributes.hp.max
if (!maxHP) {
Expand All @@ -31,7 +37,8 @@ export async function setBloodiedDeadOnHPChange(actor, change, options, userId)

if (game.settings.get(DnD4eTools.ID, DnD4eTools.SETTINGS.DEAD_ICON)) {
if (newHP <= 0) {
if (actor.type === 'NPC') {
let treatlikePC = actor.flags.dracsTools?.autoBloodied?.npcDiesLikePC
if (actor.type === 'NPC' && !treatlikePC) {
DnD4eTools.log(false, "NPC Dead!")
await deleteIfPresent(bloodied, actor)
await setIfNotPresent(dead, actor)
Expand Down

0 comments on commit eb807d4

Please sign in to comment.