From 8ebaf7672ffbb068729f4ec270730d865b98241e Mon Sep 17 00:00:00 2001 From: WBHarry Date: Thu, 15 Jan 2026 14:57:42 +0100 Subject: [PATCH] Fixed weapon effects being presented when it's no the weapon itself --- .../sheets/api/application-mixin.mjs | 5 ++++- module/data/action/baseAction.mjs | 19 +++++++++++++++---- module/documents/chatMessage.mjs | 4 +++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/module/applications/sheets/api/application-mixin.mjs b/module/applications/sheets/api/application-mixin.mjs index 0f171b7d..b590de86 100644 --- a/module/applications/sheets/api/application-mixin.mjs +++ b/module/applications/sheets/api/application-mixin.mjs @@ -505,7 +505,10 @@ export default function DHApplicationMixin(Base) { const doc = await getDocFromElement(target), action = doc?.system?.attack ?? doc; const config = action.prepareConfig(event); - config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(this.document); + config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects( + this.document, + doc + ); config.hasRoll = false; return action && action.workflow.get('damage').execute(config, null, true); } diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index 93ddf34f..2110e316 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -198,7 +198,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel let config = this.prepareConfig(event); if (!config) return; - config.effects = await DHBaseAction.getEffects(this.actor); + config.effects = await DHBaseAction.getEffects(this.actor, this.item); if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return; @@ -266,9 +266,20 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel return config; } - /** */ - static async getEffects(actor) { - if (actor) return Array.from(await actor.allApplicableEffects()).filter(x => !x.isSuppressed); + /** + * Get the all potentially applicable effects on the actor + * @param {DHActor} actor The actor performing the action + * @param {DHItem|DhActor} effectParent The parent of the effect + * @returns {DhActiveEffect[]} + */ + static async getEffects(actor, effectParent) { + if (actor) + return Array.from(await actor.allApplicableEffects()).filter(effect => { + /* Effects on weapons only ever apply for the weapon itself */ + if (effect.parent.type === 'weapon' && effectparent?.id !== effect.parent.id) return false; + return !effect.isSuppressed; + }); + return []; } diff --git a/module/documents/chatMessage.mjs b/module/documents/chatMessage.mjs index d85bcb45..3bbc6c8b 100644 --- a/module/documents/chatMessage.mjs +++ b/module/documents/chatMessage.mjs @@ -158,7 +158,9 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { const config = foundry.utils.deepClone(this.system); config.event = event; if (this.system.action) { - await this.system.action.addEffects(config); + const actor = await foundry.utils.fromUuid(config.source.actor); + const item = actor?.items.get(config.source.item) ?? null; + config.effects = await await game.system.api.data.actions.actionsTypes.base.getEffects(actor, item); await this.system.action.workflow.get('damage')?.execute(config, this._id, true); }