From 06184773b9cc936a0959be388f03549abe38c6a8 Mon Sep 17 00:00:00 2001 From: Dapoulp <74197441+Dapoulp@users.noreply.github.com> Date: Tue, 12 Aug 2025 18:37:16 +0200 Subject: [PATCH] direct damage (#873) --- lang/en.json | 20 +++++++++++++++----- module/data/action/baseAction.mjs | 1 + module/data/chat-message/adversaryRoll.mjs | 1 + module/data/fields/action/damageField.mjs | 3 ++- module/documents/actor.mjs | 3 ++- module/documents/chatMessage.mjs | 2 +- styles/less/global/elements.less | 4 ++++ templates/actionTypes/damage.hbs | 11 ++++++++--- templates/ui/chat/parts/damage-part.hbs | 6 +++--- 9 files changed, 37 insertions(+), 14 deletions(-) diff --git a/lang/en.json b/lang/en.json index e5f09217..a66cbbc3 100755 --- a/lang/en.json +++ b/lang/en.json @@ -846,6 +846,11 @@ "magical": { "name": "Magical", "abbreviation": "Mag" + }, + "direct": { + "name": "Direct Damage", + "short": "Direct", + "abbreviation": "Dir" } }, "DeathMoves": { @@ -895,23 +900,28 @@ "HealingType": { "hitPoints": { "name": "Hit Points", - "abbreviation": "HP" + "abbreviation": "HP", + "inChatRoll": "Damage" }, "stress": { "name": "Stress", - "abbreviation": "STR" + "abbreviation": "STR", + "inChatRoll": "Stress" }, "hope": { "name": "Hope", - "abbreviation": "HO" + "abbreviation": "HO", + "inChatRoll": "Hope" }, "armor": { "name": "Armor Slot", - "abbreviation": "AS" + "abbreviation": "AS", + "inChatRoll": "Armor Slot" }, "fear": { "name": "Fear", - "abbreviation": "FR" + "abbreviation": "FR", + "inChatRoll": "Fear" } }, "ItemResourceProgression": { diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index a886bf49..43850196 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -177,6 +177,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel hasDamage: this.damage?.parts?.length && this.type !== 'healing', hasHealing: this.damage?.parts?.length && this.type === 'healing', hasEffect: !!this.effects?.length, + isDirect: !!this.damage?.direct, hasSave: this.hasSave, selectedRollMode: game.settings.get('core', 'rollMode'), isFastForward: event.shiftKey, diff --git a/module/data/chat-message/adversaryRoll.mjs b/module/data/chat-message/adversaryRoll.mjs index 337acf5b..8e4b7414 100644 --- a/module/data/chat-message/adversaryRoll.mjs +++ b/module/data/chat-message/adversaryRoll.mjs @@ -29,6 +29,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel { hasEffect: new fields.BooleanField({ initial: false }), hasSave: new fields.BooleanField({ initial: false }), hasTarget: new fields.BooleanField({ initial: false }), + isDirect: new fields.BooleanField({ initial: false }), isCritical: new fields.BooleanField({ initial: false }), onSave: new fields.StringField(), source: new fields.SchemaField({ diff --git a/module/data/fields/action/damageField.mjs b/module/data/fields/action/damageField.mjs index 9e9e4b16..44ac70f1 100644 --- a/module/data/fields/action/damageField.mjs +++ b/module/data/fields/action/damageField.mjs @@ -9,7 +9,8 @@ export default class DamageField extends fields.SchemaField { includeBase: new fields.BooleanField({ initial: false, label: 'DAGGERHEART.ACTIONS.Settings.includeBase.label' - }) + }), + direct: new fields.BooleanField({ initial: false, label: "DAGGERHEART.CONFIG.DamageType.direct.name" }) }; super(damageFields, options, context); } diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index c75db559..6421d6bd 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -517,7 +517,7 @@ export default class DhpActor extends Actor { return canUseArmor || canUseStress; } - async takeDamage(damages) { + async takeDamage(damages, isDirect = false) { if (Hooks.call(`${CONFIG.DH.id}.preTakeDamage`, this, damages) === false) return null; if (this.type === 'companion') { @@ -548,6 +548,7 @@ export default class DhpActor extends Actor { hpDamage.value = this.convertDamageToThreshold(hpDamage.value); if ( this.type === 'character' && + !isDirect && this.system.armor && this.#canReduceDamage(hpDamage.value, hpDamage.damageTypes) ) { diff --git a/module/documents/chatMessage.mjs b/module/documents/chatMessage.mjs index 2b10e251..80bafc98 100644 --- a/module/documents/chatMessage.mjs +++ b/module/documents/chatMessage.mjs @@ -138,7 +138,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { this.consumeOnSuccess(); if (this.system.hasHealing) target.actor.takeHealing(damages); - else target.actor.takeDamage(damages); + else target.actor.takeDamage(damages, this.system.isDirect); } } diff --git a/styles/less/global/elements.less b/styles/less/global/elements.less index 4c0243f6..b583d470 100755 --- a/styles/less/global/elements.less +++ b/styles/less/global/elements.less @@ -344,6 +344,10 @@ width: 100%; gap: 5px; + &.space-between { + justify-content: space-between; + } + .btn { padding-top: 15px; } diff --git a/templates/actionTypes/damage.hbs b/templates/actionTypes/damage.hbs index a3abdf19..3ff4c142 100644 --- a/templates/actionTypes/damage.hbs +++ b/templates/actionTypes/damage.hbs @@ -8,9 +8,14 @@ {{/if}} {{#unless (eq path 'system.attack.')}}{{/unless}} - {{#if @root.hasBaseDamage}} - {{formField @root.fields.damage.fields.includeBase value=@root.source.damage.includeBase name="damage.includeBase" classes="checkbox" localize=true }} - {{/if}} +
+ {{#if @root.hasBaseDamage}} + {{formField @root.fields.damage.fields.includeBase value=@root.source.damage.includeBase name="damage.includeBase" classes="checkbox" localize=true }} + {{/if}} + {{#unless (eq @root.source.type 'healing')}} + {{formField @root.fields.damage.fields.direct value=@root.source.damage.direct name="damage.direct" localize=true classes="checkbox"}} + {{/unless}} +
{{#each source.parts as |dmg index|}} {{#if (and @root.hasBaseDamage @root.source.damage.includeBase)}} {{setVar 'realIndex' (add index -1)}} diff --git a/templates/ui/chat/parts/damage-part.hbs b/templates/ui/chat/parts/damage-part.hbs index 232b1303..346e9621 100644 --- a/templates/ui/chat/parts/damage-part.hbs +++ b/templates/ui/chat/parts/damage-part.hbs @@ -3,7 +3,7 @@
{{#each damage as | roll index | }} -
{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.name')}}: {{total}}
+
{{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.inChatRoll')}}: {{total}}
{{/each}}
@@ -12,8 +12,8 @@
{{#each damage as | roll index | }}
- - {{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.name')}}
{{localize "DAGGERHEART.GENERAL.total"}}: {{roll.total}}
+ {{log @root}} + {{localize (concat 'DAGGERHEART.CONFIG.HealingType.' index '.inChatRoll')}}
{{localize "DAGGERHEART.GENERAL.total"}}: {{roll.total}}
{{#if (and (eq index "hitPoints")../isDirect)}}
{{localize "DAGGERHEART.CONFIG.DamageType.direct.short"}}
{{/if}}
{{#each roll.parts}} {{#if damageTypes.length}}