diff --git a/lang/en.json b/lang/en.json index 99a75f83..2efd6d7b 100755 --- a/lang/en.json +++ b/lang/en.json @@ -119,7 +119,8 @@ "deleteTriggerContent": "Are you sure you want to delete the {trigger} trigger?", "advantageState": "Advantage State", "damageOnSave": "Damage on Save", - "useDefaultItemValues": "Use default Item values" + "useDefaultItemValues": "Use default Item values", + "itemDamageIsUsed": "Item Damage Is Used" }, "RollField": { "diceRolling": { @@ -134,7 +135,7 @@ "attackModifier": "Attack Modifier", "attackName": "Attack Name", "criticalThreshold": "Critical Threshold", - "includeBase": { "label": "Include Item Damage" }, + "includeBase": { "label": "Use Item Damage" }, "groupAttack": { "label": "Group Attack" }, "multiplier": "Multiplier", "saveHint": "Set a default Trait to enable Reaction Roll. It can be changed later in Reaction Roll Dialog.", diff --git a/module/applications/dialogs/actionSelectionDialog.mjs b/module/applications/dialogs/actionSelectionDialog.mjs index 6123c970..995c4894 100644 --- a/module/applications/dialogs/actionSelectionDialog.mjs +++ b/module/applications/dialogs/actionSelectionDialog.mjs @@ -72,8 +72,8 @@ export default class ActionSelectionDialog extends HandlebarsApplicationMixin(Ap static async #onChooseAction(event, button) { const { actionId } = button.dataset; - this.#action = this.item.system.actionsList.find(a => a._id === actionId); - Object.defineProperty(this.#event, 'shiftKey', { + this.action = this.item.system.actionsList.find(a => a._id === actionId); + Object.defineProperty(this.event, 'shiftKey', { get() { return event.shiftKey; } diff --git a/module/applications/sheets-configs/action-base-config.mjs b/module/applications/sheets-configs/action-base-config.mjs index 7406b084..a94abb26 100644 --- a/module/applications/sheets-configs/action-base-config.mjs +++ b/module/applications/sheets-configs/action-base-config.mjs @@ -156,7 +156,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) context.openSection = this.openSection; context.tabs = this._getTabs(this.constructor.TABS); context.config = CONFIG.DH; - if (this.action.damage) { + if (this.action.hasDamage) { context.allDamageTypesUsed = !getUnusedDamageTypes(this.action.damage.parts).length; if (this.action.damage.hasOwnProperty('includeBase') && this.action.type === 'attack') @@ -302,7 +302,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2) static addDamage(_event) { if (!this.action.damage.parts) return; - const choices = getUnusedDamageTypes(this.action._source.damage.parts); + const choices = getUnusedDamageTypes(this.action.damage.parts); const content = new foundry.data.fields.StringField({ label: game.i18n.localize('Damage Type'), choices, diff --git a/module/data/action/attackAction.mjs b/module/data/action/attackAction.mjs index c4d07c25..15cc1696 100644 --- a/module/data/action/attackAction.mjs +++ b/module/data/action/attackAction.mjs @@ -1,3 +1,4 @@ +import { DHDamageData } from '../fields/action/damageField.mjs'; import DHDamageAction from './damageAction.mjs'; export default class DHAttackAction extends DHDamageAction { @@ -11,19 +12,8 @@ export default class DHAttackAction extends DHDamageAction { super.prepareData(); if (!!this.item?.system?.attack) { if (this.damage.includeBase) { - const baseDamage = this.getParentHitPointDamage(); - if (baseDamage) { - if (!this.damage.parts.hitPoints) { - this.damage.parts.hitPoints = baseDamage; - } else { - for (const type of baseDamage.type) this.damage.parts.hitPoints.type.add(type); - - this.damage.parts.hitPoints.value.custom = { - enabled: true, - formula: `${baseDamage.value.getFormula()} + ${this.damage.parts.hitPoints.value.getFormula()}` - }; - } - } + const baseDamage = this.getParentDamage(); + this.damage.parts.hitPoints = new DHDamageData(baseDamage); } if (this.roll.useDefault) { this.roll.trait = this.item.system.attack.roll.trait; @@ -32,8 +22,16 @@ export default class DHAttackAction extends DHDamageAction { } } - getParentHitPointDamage() { - return this.item?.system?.attack.damage.parts.hitPoints; + getParentDamage() { + return { + value: { + multiplier: 'prof', + dice: this.item?.system?.attack.damage.parts.hitPoints.value.dice, + bonus: this.item?.system?.attack.damage.parts.hitPoints.value.bonus ?? 0 + }, + type: this.item?.system?.attack.damage.parts.hitPoints.type, + base: true + }; } get damageFormula() { diff --git a/src/packs/domains/domainCard_Book_of_Norai_WtwSWXTRZa7QVvmo.json b/src/packs/domains/domainCard_Book_of_Norai_WtwSWXTRZa7QVvmo.json index 78028bab..f32f380a 100644 --- a/src/packs/domains/domainCard_Book_of_Norai_WtwSWXTRZa7QVvmo.json +++ b/src/packs/domains/domainCard_Book_of_Norai_WtwSWXTRZa7QVvmo.json @@ -91,7 +91,7 @@ "type": "attack", "_id": "GI2VkIcGDOjFRxpT", "systemPath": "actions", - "description": "

Make a Spellcast Roll against a target within Very Far range. On a success, hurl a sphere of fire toward them that explodes on impact.

", + "description": "

Make a Spellcast Roll against a target within Very Far range. On a success, hurl a sphere of fire toward them that explodes on impact. The target and all creatures within Very Close range of them must make a Reaction Roll (13). Targets who fail take d20+5 magic damage using your Proficiency. Targets who succeed take half damage.

@Template[type:emanation|range:vc]

", "chatDisplay": true, "actionType": "action", "cost": [], @@ -101,7 +101,34 @@ "recovery": null }, "damage": { - "parts": {}, + "parts": { + "hitPoints": { + "resultBased": false, + "value": { + "custom": { + "enabled": false + }, + "multiplier": "prof", + "dice": "d20", + "bonus": 5, + "flatMultiplier": 1 + }, + "applyTo": "hitPoints", + "type": [ + "magical" + ], + "base": false, + "valueAlt": { + "multiplier": "prof", + "flatMultiplier": 1, + "dice": "d6", + "bonus": null, + "custom": { + "enabled": false + } + } + } + }, "includeBase": false }, "target": { @@ -124,105 +151,14 @@ }, "useDefault": false }, - "save": { - "trait": null, - "difficulty": 13, - "damageMod": "half" - }, - "name": "Fireball - Cast", - "img": "icons/magic/fire/explosion-fireball-large-red-orange.webp", - "range": "veryFar" - }, - "HJ749c2a8WTjkSHY": { - "type": "attack", - "_id": "HJ749c2a8WTjkSHY", - "systemPath": "actions", - "baseAction": false, - "description": "

The target and all creatures within Very Close range of them must make a Reaction Roll (13). Targets who fail take d20+5 magic damage using your Proficiency. Targets who succeed take half damage.

", - "chatDisplay": true, - "originItem": { - "type": "itemCollection" - }, - "actionType": "action", - "triggers": [], - "areas": [ - { - "name": "Fireball", - "type": "placed", - "shape": "emanation", - "size": "veryClose", - "effects": [] - } - ], - "cost": [], - "uses": { - "value": null, - "max": "", - "recovery": null, - "consumeOnSuccess": false - }, - "damage": { - "parts": { - "hitPoints": { - "applyTo": "hitPoints", - "resultBased": false, - "value": { - "multiplier": "prof", - "flatMultiplier": 1, - "dice": "d20", - "bonus": 5, - "custom": { - "enabled": false, - "formula": "" - } - }, - "valueAlt": { - "multiplier": "flat", - "flatMultiplier": 1, - "dice": "d6", - "bonus": null, - "custom": { - "enabled": false, - "formula": "" - } - }, - "base": false, - "type": [ - "magical" - ] - } - }, - "includeBase": false, - "direct": false - }, - "target": { - "type": "any", - "amount": null - }, - "effects": [], - "roll": { - "type": null, - "trait": null, - "difficulty": null, - "bonus": null, - "advState": "neutral", - "diceRolling": { - "multiplier": "prof", - "flatMultiplier": 1, - "dice": "d6", - "compare": null, - "treshold": null - }, - "useDefault": false - }, "save": { "trait": "agility", "difficulty": 13, "damageMod": "half" }, - "name": "Fireball - Explosion", - "range": "", - "img": "icons/magic/fire/explosion-fireball-large-red-orange.webp" + "name": "Fireball", + "img": "icons/magic/fire/explosion-fireball-large-red-orange.webp", + "range": "veryFar" } }, "attribution": { diff --git a/templates/actionTypes/damage.hbs b/templates/actionTypes/damage.hbs index 03300840..454d0413 100644 --- a/templates/actionTypes/damage.hbs +++ b/templates/actionTypes/damage.hbs @@ -31,40 +31,44 @@ {{/unless}} - {{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base))}} - {{formField ../fields.resultBased value=dmg.resultBased name=(concat "damage.parts." dmg.applyTo ".resultBased") localize=true classes="checkbox"}} - {{/if}} - {{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base) dmg.resultBased)}} -
-
- {{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.hope")}} - {{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path}} -
-
- {{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.fear")}} - {{> formula fields=../fields.valueAlt.fields type=../fields.type dmg=dmg source=dmg.valueAlt target="valueAlt" key=dmg.applyTo path=../path}} -
-
- {{else}} - {{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path}} - {{/if}} - - {{#if (and (eq dmg.applyTo 'hitPoints') (ne @root.source.type 'healing'))}} - {{formField ../fields.type value=dmg.type name=(concat ../path "damage.parts." dmg.applyTo ".type") localize=true}} - {{/if}} - - {{#if ../horde}} -
- {{localize "DAGGERHEART.ACTORS.Adversary.hordeDamage"}} + {{#unless (and @root.source.damage.includeBase (eq key 'hitPoints'))}} + {{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base))}} + {{formField ../fields.resultBased value=dmg.resultBased name=(concat "damage.parts." dmg.applyTo ".resultBased") localize=true classes="checkbox"}} + {{/if}} + {{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base) dmg.resultBased)}}
- - {{formField ../fields.valueAlt.fields.flatMultiplier value=dmg.valueAlt.flatMultiplier name=(concat ../path "damage.parts." dmg.applyTo ".valueAlt.flatMultiplier") label="DAGGERHEART.ACTIONS.Settings.multiplier" classes="inline-child" localize=true }} - {{formField ../fields.valueAlt.fields.dice value=dmg.valueAlt.dice name=(concat ../path "damage.parts." dmg.applyTo ".valueAlt.dice") classes="inline-child" localize=true}} - {{formField ../fields.valueAlt.fields.bonus value=dmg.valueAlt.bonus name=(concat ../path "damage.parts." dmg.applyTo ".valueAlt.bonus") localize=true classes="inline-child"}} +
+ {{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.hope")}} + {{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path}} +
+
+ {{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.fear")}} + {{> formula fields=../fields.valueAlt.fields type=../fields.type dmg=dmg source=dmg.valueAlt target="valueAlt" key=dmg.applyTo path=../path}} +
-
- {{/if}} - + {{else}} + {{> formula fields=../fields.value.fields type=../fields.type dmg=dmg source=dmg.value target="value" key=dmg.applyTo path=../path}} + {{/if}} + + {{#if (and (eq dmg.applyTo 'hitPoints') (ne @root.source.type 'healing'))}} + {{formField ../fields.type value=dmg.type name=(concat ../path "damage.parts." dmg.applyTo ".type") localize=true}} + {{/if}} + + {{#if ../horde}} +
+ {{localize "DAGGERHEART.ACTORS.Adversary.hordeDamage"}} +
+ + {{formField ../fields.valueAlt.fields.flatMultiplier value=dmg.valueAlt.flatMultiplier name=(concat ../path "damage.parts." dmg.applyTo ".valueAlt.flatMultiplier") label="DAGGERHEART.ACTIONS.Settings.multiplier" classes="inline-child" localize=true }} + {{formField ../fields.valueAlt.fields.dice value=dmg.valueAlt.dice name=(concat ../path "damage.parts." dmg.applyTo ".valueAlt.dice") classes="inline-child" localize=true}} + {{formField ../fields.valueAlt.fields.bonus value=dmg.valueAlt.bonus name=(concat ../path "damage.parts." dmg.applyTo ".valueAlt.bonus") localize=true classes="inline-child"}} +
+
+ {{/if}} + + {{else}} + {{localize "DAGGERHEART.ACTIONS.Config.itemDamageIsUsed"}} + {{/unless}} {{/each}}