Fixed weapon effects being presented when it's no the weapon itself

This commit is contained in:
WBHarry 2026-01-15 14:57:42 +01:00
parent 622d11a1cc
commit 8ebaf7672f
3 changed files with 22 additions and 6 deletions

View file

@ -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);
}

View file

@ -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 [];
}

View file

@ -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);
}