From 90faf48b05337764c22eaddee535f7fbb3b44d23 Mon Sep 17 00:00:00 2001 From: WBHarry <89362246+WBHarry@users.noreply.github.com> Date: Sat, 2 Aug 2025 04:43:54 +0200 Subject: [PATCH] Fixed so that spellcast attacks use that modifier (#509) --- module/data/actor/character.mjs | 11 +++++++++-- module/data/fields/action/rollField.mjs | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index e0bbcc03..83311c96 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -323,9 +323,16 @@ export default class DhCharacter extends BaseDataActor { return !(this.class.value || this.class.subclass || this.ancestry || this.community); } - get spellcastModifier() { + get spellcastModifierTrait() { const subClasses = this.parent.items.filter(x => x.type === 'subclass') ?? []; - return Math.max(subClasses?.map(sc => this.traits[sc.system.spellcastingTrait]?.value)); + const modifiers = subClasses + ?.map(sc => ({ ...this.traits[sc.system.spellcastingTrait], key: sc.system.spellcastingTrait })) + .filter(x => x); + return modifiers.sort((a, b) => a.value - b.value)[0]; + } + + get spellcastModifier() { + return this.spellcastModifierTrait?.value ?? 0; } get spellcastingModifiers() { diff --git a/module/data/fields/action/rollField.mjs b/module/data/fields/action/rollField.mjs index 7522ebc5..d53dfa6c 100644 --- a/module/data/fields/action/rollField.mjs +++ b/module/data/fields/action/rollField.mjs @@ -72,9 +72,13 @@ export class DHActionRollData extends foundry.abstract.DataModel { if (!this.parent?.actor) return modifiers; switch (this.parent.actor.type) { case 'character': + const spellcastingTrait = + this.type === 'spellcast' + ? (this.parent.actor?.system?.spellcastModifierTrait?.key ?? 'agility') + : null; const trait = this.useDefault || !this.trait - ? (this.parent.item.system.attack.roll.trait ?? 'agility') + ? (spellcastingTrait ?? this.parent.item.system.attack.roll.trait ?? 'agility') : this.trait; if ( this.type === CONFIG.DH.GENERAL.rollTypes.attack.id ||