Compare commits

..

2 commits

Author SHA1 Message Date
WBHarry
276aee4747 Corrected fireball to be two different actions, one for the casting and one for the explosion
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
2026-04-23 00:38:55 +02:00
WBHarry
fae05c24a8
1794 - Include Item Damage (#1827)
* Went ahead and made IncludeItemDamage work again, smashing the formulas together

* .

* Lint fix
2026-04-23 00:22:08 +02:00
6 changed files with 148 additions and 87 deletions

View file

@ -119,8 +119,7 @@
"deleteTriggerContent": "Are you sure you want to delete the {trigger} trigger?", "deleteTriggerContent": "Are you sure you want to delete the {trigger} trigger?",
"advantageState": "Advantage State", "advantageState": "Advantage State",
"damageOnSave": "Damage on Save", "damageOnSave": "Damage on Save",
"useDefaultItemValues": "Use default Item values", "useDefaultItemValues": "Use default Item values"
"itemDamageIsUsed": "Item Damage Is Used"
}, },
"RollField": { "RollField": {
"diceRolling": { "diceRolling": {
@ -135,7 +134,7 @@
"attackModifier": "Attack Modifier", "attackModifier": "Attack Modifier",
"attackName": "Attack Name", "attackName": "Attack Name",
"criticalThreshold": "Critical Threshold", "criticalThreshold": "Critical Threshold",
"includeBase": { "label": "Use Item Damage" }, "includeBase": { "label": "Include Item Damage" },
"groupAttack": { "label": "Group Attack" }, "groupAttack": { "label": "Group Attack" },
"multiplier": "Multiplier", "multiplier": "Multiplier",
"saveHint": "Set a default Trait to enable Reaction Roll. It can be changed later in Reaction Roll Dialog.", "saveHint": "Set a default Trait to enable Reaction Roll. It can be changed later in Reaction Roll Dialog.",

View file

@ -72,8 +72,8 @@ export default class ActionSelectionDialog extends HandlebarsApplicationMixin(Ap
static async #onChooseAction(event, button) { static async #onChooseAction(event, button) {
const { actionId } = button.dataset; const { actionId } = button.dataset;
this.action = this.item.system.actionsList.find(a => a._id === actionId); this.#action = this.item.system.actionsList.find(a => a._id === actionId);
Object.defineProperty(this.event, 'shiftKey', { Object.defineProperty(this.#event, 'shiftKey', {
get() { get() {
return event.shiftKey; return event.shiftKey;
} }

View file

@ -156,7 +156,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
context.openSection = this.openSection; context.openSection = this.openSection;
context.tabs = this._getTabs(this.constructor.TABS); context.tabs = this._getTabs(this.constructor.TABS);
context.config = CONFIG.DH; context.config = CONFIG.DH;
if (this.action.hasDamage) { if (this.action.damage) {
context.allDamageTypesUsed = !getUnusedDamageTypes(this.action.damage.parts).length; context.allDamageTypesUsed = !getUnusedDamageTypes(this.action.damage.parts).length;
if (this.action.damage.hasOwnProperty('includeBase') && this.action.type === 'attack') if (this.action.damage.hasOwnProperty('includeBase') && this.action.type === 'attack')
@ -302,7 +302,7 @@ export default class DHActionBaseConfig extends DaggerheartSheet(ApplicationV2)
static addDamage(_event) { static addDamage(_event) {
if (!this.action.damage.parts) return; if (!this.action.damage.parts) return;
const choices = getUnusedDamageTypes(this.action.damage.parts); const choices = getUnusedDamageTypes(this.action._source.damage.parts);
const content = new foundry.data.fields.StringField({ const content = new foundry.data.fields.StringField({
label: game.i18n.localize('Damage Type'), label: game.i18n.localize('Damage Type'),
choices, choices,

View file

@ -1,4 +1,3 @@
import { DHDamageData } from '../fields/action/damageField.mjs';
import DHDamageAction from './damageAction.mjs'; import DHDamageAction from './damageAction.mjs';
export default class DHAttackAction extends DHDamageAction { export default class DHAttackAction extends DHDamageAction {
@ -12,8 +11,19 @@ export default class DHAttackAction extends DHDamageAction {
super.prepareData(); super.prepareData();
if (!!this.item?.system?.attack) { if (!!this.item?.system?.attack) {
if (this.damage.includeBase) { if (this.damage.includeBase) {
const baseDamage = this.getParentDamage(); const baseDamage = this.getParentHitPointDamage();
this.damage.parts.hitPoints = new DHDamageData(baseDamage); 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()}`
};
}
}
} }
if (this.roll.useDefault) { if (this.roll.useDefault) {
this.roll.trait = this.item.system.attack.roll.trait; this.roll.trait = this.item.system.attack.roll.trait;
@ -22,16 +32,8 @@ export default class DHAttackAction extends DHDamageAction {
} }
} }
getParentDamage() { getParentHitPointDamage() {
return { return this.item?.system?.attack.damage.parts.hitPoints;
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() { get damageFormula() {

View file

@ -91,7 +91,7 @@
"type": "attack", "type": "attack",
"_id": "GI2VkIcGDOjFRxpT", "_id": "GI2VkIcGDOjFRxpT",
"systemPath": "actions", "systemPath": "actions",
"description": "<p class=\"Card-Feature\">Make a <strong>Spellcast Roll</strong> 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<strong> d20+5</strong> magic damage using your Proficiency. Targets who succeed take half damage.</p><p>@Template[type:emanation|range:vc]</p>", "description": "<p class=\"Card-Feature\">Make a <strong>Spellcast Roll</strong> against a target within Very Far range. On a success, hurl a sphere of fire toward them that explodes on impact.</p>",
"chatDisplay": true, "chatDisplay": true,
"actionType": "action", "actionType": "action",
"cost": [], "cost": [],
@ -101,34 +101,7 @@
"recovery": null "recovery": null
}, },
"damage": { "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 "includeBase": false
}, },
"target": { "target": {
@ -151,14 +124,105 @@
}, },
"useDefault": false "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": "<p>The target and all creatures within Very Close range of them must make a Reaction Roll (13). Targets who fail take<strong> d20+5</strong> magic damage using your Proficiency. Targets who succeed take half damage.</p>",
"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": { "save": {
"trait": "agility", "trait": "agility",
"difficulty": 13, "difficulty": 13,
"damageMod": "half" "damageMod": "half"
}, },
"name": "Fireball", "name": "Fireball - Explosion",
"img": "icons/magic/fire/explosion-fireball-large-red-orange.webp", "range": "",
"range": "veryFar" "img": "icons/magic/fire/explosion-fireball-large-red-orange.webp"
} }
}, },
"attribution": { "attribution": {

View file

@ -31,7 +31,6 @@
{{/unless}} {{/unless}}
</legend> </legend>
{{#unless (and @root.source.damage.includeBase (eq key 'hitPoints'))}}
{{#if (and (not @root.isNPC) @root.hasRoll (not dmg.base))}} {{#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"}} {{formField ../fields.resultBased value=dmg.resultBased name=(concat "damage.parts." dmg.applyTo ".resultBased") localize=true classes="checkbox"}}
{{/if}} {{/if}}
@ -66,9 +65,6 @@
</fieldset> </fieldset>
{{/if}} {{/if}}
<input type="hidden" name="{{concat ../path "damage.parts." dmg.applyTo ".base"}}" value="{{dmg.base}}"> <input type="hidden" name="{{concat ../path "damage.parts." dmg.applyTo ".base"}}" value="{{dmg.base}}">
{{else}}
<span class="hint">{{localize "DAGGERHEART.ACTIONS.Config.itemDamageIsUsed"}}</span>
{{/unless}}
</fieldset> </fieldset>
</div> </div>
{{/each}} {{/each}}