diff --git a/lang/en.json b/lang/en.json index e2c94509..4af86abe 100755 --- a/lang/en.json +++ b/lang/en.json @@ -1362,9 +1362,9 @@ "label": "Action Points", "hint": "Automatically give and take Action Points as combatants take their turns." }, - "countdowns": { - "label": "Countdowns", - "hint": "Automatically progress non-custom countdowns" + "hordeDamage": { + "label": "Automatic Horde Damage", + "hint": "Automatically active horde effect to lower damage when reaching half or lower HP." } } }, diff --git a/module/canvas/placeables/token.mjs b/module/canvas/placeables/token.mjs index 9b724dad..967df0f8 100644 --- a/module/canvas/placeables/token.mjs +++ b/module/canvas/placeables/token.mjs @@ -10,7 +10,7 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token { this.effects.overlay = null; // Categorize effects - const activeEffects = Array.from(this.actor.effects); + const activeEffects = this.actor ? Array.from(this.actor.effects).filter(x => !x.disabled) : []; const overlayEffect = activeEffects.findLast(e => e.img && e.getFlag('core', 'overlay')); // Draw effects diff --git a/module/data/action/damageAction.mjs b/module/data/action/damageAction.mjs index 2a83f444..ccd996f7 100644 --- a/module/data/action/damageAction.mjs +++ b/module/data/action/damageAction.mjs @@ -9,8 +9,10 @@ export default class DHDamageAction extends DHBaseAction { const isAdversary = this.actor.type === 'adversary'; if (isAdversary && this.actor.system.type === CONFIG.DH.ACTOR.adversaryTypes.horde.id) { - const halfHP = Math.ceil(this.actor.system.resources.hitPoints.max / 2); - if (this.actor.system.resources.hitPoints.value >= halfHP) return part.valueAlt; + const hasHordeDamage = this.actor.effects.find( + x => x.name === game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label') + ); + if (hasHordeDamage) return part.valueAlt; } return formulaValue; diff --git a/module/data/actor/adversary.mjs b/module/data/actor/adversary.mjs index 8a2d6d52..00a19d05 100644 --- a/module/data/actor/adversary.mjs +++ b/module/data/actor/adversary.mjs @@ -125,7 +125,9 @@ export default class DhpAdversary extends BaseDataActor { await this.parent.createEmbeddedDocuments('ActiveEffect', [ { name: game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label'), - img: 'icons/magic/movement/chevrons-down-yellow.webp' + img: 'icons/magic/movement/chevrons-down-yellow.webp', + disabled: !game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation) + .hordeDamage } ]); } else if (raisedAboveHalf) { diff --git a/module/data/settings/Automation.mjs b/module/data/settings/Automation.mjs index 4291423b..63377b26 100644 --- a/module/data/settings/Automation.mjs +++ b/module/data/settings/Automation.mjs @@ -1,6 +1,4 @@ export default class DhAutomation extends foundry.abstract.DataModel { - static LOCALIZATION_PREFIXES = ['DAGGERHEART.SETTINGS.Automation']; // Doesn't work for some reason - static defineSchema() { const fields = foundry.data.fields; return { @@ -20,6 +18,11 @@ export default class DhAutomation extends foundry.abstract.DataModel { required: true, initial: false, label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.actionPoints.label' + }), + hordeDamage: new fields.BooleanField({ + required: true, + initial: true, + label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.hordeDamage.label' }) }; } diff --git a/templates/settings/automation-settings.hbs b/templates/settings/automation-settings.hbs index 87a48c06..910ace56 100644 --- a/templates/settings/automation-settings.hbs +++ b/templates/settings/automation-settings.hbs @@ -6,7 +6,7 @@ {{formGroup settingFields.schema.fields.actionPoints value=settingFields._source.actionPoints localize=true}} - {{formGroup settingFields.schema.fields.countdowns value=settingFields._source.countdowns localize=true}} + {{formGroup settingFields.schema.fields.hordeDamage value=settingFields._source.hordeDamage localize=true}}