diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index 0919f0c5..5086757d 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -712,7 +712,7 @@ export default class CharacterSheet extends DHBaseActorSheet { headerTitle: game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', { ability: abilityLabel }), - effects: Array.from(await this.document.allApplicableEffects()), + effects: await game.system.api.data.actions.actionsTypes.base.getEffects(this.document), roll: { trait: button.dataset.attribute, type: 'trait' diff --git a/module/applications/sheets/api/application-mixin.mjs b/module/applications/sheets/api/application-mixin.mjs index 7276316f..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 = Array.from(await this.document.allApplicableEffects()); + 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 1e449ee8..4e699f79 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; - await this.addEffects(config); + config.effects = await game.system.api.data.actions.actionsTypes.base.getEffects(this.actor, this.item); if (Hooks.call(`${CONFIG.DH.id}.preUseAction`, this, config) === false) return; @@ -266,14 +266,26 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel return config; } - /** */ - async addEffects(config) { - let effects = []; - if (this.actor) { - effects = Array.from(await this.actor.allApplicableEffects()); - } + /** + * 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 []; - config.effects = effects; + return Array.from(await actor.allApplicableEffects()).filter(effect => { + /* Effects on weapons only ever apply for the weapon itself */ + if (effect.parent.type === 'weapon') { + /* Unless they're secondary - then they apply only to other primary weapons */ + if (effect.parent.system.secondary) { + if (effectParent?.type !== 'weapon' || effectParent?.system.secondary) return false; + } else if (effectParent?.id !== effect.parent.id) return false; + } + + return !effect.isSuppressed; + }); } /** diff --git a/module/documents/chatMessage.mjs b/module/documents/chatMessage.mjs index e61d613e..e03c3cf0 100644 --- a/module/documents/chatMessage.mjs +++ b/module/documents/chatMessage.mjs @@ -167,7 +167,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 game.system.api.data.actions.actionsTypes.base.getEffects(actor, item); await this.system.action.workflow.get('damage')?.execute(config, this._id, true); } @@ -201,7 +203,16 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelectedOrPerm')); this.consumeOnSuccess(); - this.system.action?.workflow.get('applyDamage')?.execute(config, targets, true); + if (this.system.action) this.system.action.workflow.get('applyDamage')?.execute(config, targets, true); + else { + for (const target of targets) { + const actor = await foundry.utils.fromUuid(target.actorId); + if (!actor) continue; + + if (this.system.hasHealing) actor.takeHealing(this.system.damage); + else actor.takeDamage(this.system.damage); + } + } } async onRollSave(event) { diff --git a/src/packs/items/weapons/weapon_Advanced_Greatstaff_4UzxqfkwF8gDSdu7.json b/src/packs/items/weapons/weapon_Advanced_Greatstaff_4UzxqfkwF8gDSdu7.json index 6ce54823..c66354c2 100644 --- a/src/packs/items/weapons/weapon_Advanced_Greatstaff_4UzxqfkwF8gDSdu7.json +++ b/src/packs/items/weapons/weapon_Advanced_Greatstaff_4UzxqfkwF8gDSdu7.json @@ -113,18 +113,7 @@ "name": "Powerful", "description": "On a successful attack, roll an additional damage die and discard the lowest result.", "img": "icons/magic/control/buff-flight-wings-runes-red-yellow.webp", - "changes": [ - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" - } - ], + "changes": [], "_id": "sGVVxSM68Fmr1sSM", "type": "base", "system": {}, diff --git a/src/packs/items/weapons/weapon_Advanced_Greatsword_MAC6YWTo4lzSotQc.json b/src/packs/items/weapons/weapon_Advanced_Greatsword_MAC6YWTo4lzSotQc.json index fe3fff0e..71226630 100644 --- a/src/packs/items/weapons/weapon_Advanced_Greatsword_MAC6YWTo4lzSotQc.json +++ b/src/packs/items/weapons/weapon_Advanced_Greatsword_MAC6YWTo4lzSotQc.json @@ -118,16 +118,6 @@ "key": "system.evasion", "mode": 2, "value": "-1" - }, - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" } ], "_id": "E0PjC15OP55vIype", diff --git a/src/packs/items/weapons/weapon_Double_Flail_xm1yU7k58fMgXxRR.json b/src/packs/items/weapons/weapon_Double_Flail_xm1yU7k58fMgXxRR.json index 2e00f9c1..a118b399 100644 --- a/src/packs/items/weapons/weapon_Double_Flail_xm1yU7k58fMgXxRR.json +++ b/src/packs/items/weapons/weapon_Double_Flail_xm1yU7k58fMgXxRR.json @@ -113,18 +113,7 @@ "name": "Powerful", "description": "On a successful attack, roll an additional damage die and discard the lowest result.", "img": "icons/magic/control/buff-flight-wings-runes-red-yellow.webp", - "changes": [ - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" - } - ], + "changes": [], "_id": "DCie5eR1dZH2Qvln", "type": "base", "system": {}, diff --git a/src/packs/items/weapons/weapon_Elder_Bow_JdWcn9W1edhAEInL.json b/src/packs/items/weapons/weapon_Elder_Bow_JdWcn9W1edhAEInL.json index b6437781..35659402 100644 --- a/src/packs/items/weapons/weapon_Elder_Bow_JdWcn9W1edhAEInL.json +++ b/src/packs/items/weapons/weapon_Elder_Bow_JdWcn9W1edhAEInL.json @@ -113,18 +113,7 @@ "name": "Powerful", "description": "On a successful attack, roll an additional damage die and discard the lowest result.", "img": "icons/magic/control/buff-flight-wings-runes-red-yellow.webp", - "changes": [ - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" - } - ], + "changes": [], "_id": "sZ1XotFlGdkPPDG4", "type": "base", "system": {}, diff --git a/src/packs/items/weapons/weapon_Floating_Bladeshards_3vti3xfo0wJND7ew.json b/src/packs/items/weapons/weapon_Floating_Bladeshards_3vti3xfo0wJND7ew.json index fa7b7d45..232f26e9 100644 --- a/src/packs/items/weapons/weapon_Floating_Bladeshards_3vti3xfo0wJND7ew.json +++ b/src/packs/items/weapons/weapon_Floating_Bladeshards_3vti3xfo0wJND7ew.json @@ -113,18 +113,7 @@ "name": "Powerful", "description": "On a successful attack, roll an additional damage die and discard the lowest result.", "img": "icons/magic/control/buff-flight-wings-runes-red-yellow.webp", - "changes": [ - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" - } - ], + "changes": [], "_id": "T831j6kZiMnpMNmv", "type": "base", "system": {}, diff --git a/src/packs/items/weapons/weapon_Gilded_Falchion_VwcOgqnzjf9LBj2S.json b/src/packs/items/weapons/weapon_Gilded_Falchion_VwcOgqnzjf9LBj2S.json index 551dcf56..ee8afebc 100644 --- a/src/packs/items/weapons/weapon_Gilded_Falchion_VwcOgqnzjf9LBj2S.json +++ b/src/packs/items/weapons/weapon_Gilded_Falchion_VwcOgqnzjf9LBj2S.json @@ -113,18 +113,7 @@ "name": "Powerful", "description": "On a successful attack, roll an additional damage die and discard the lowest result.", "img": "icons/magic/control/buff-flight-wings-runes-red-yellow.webp", - "changes": [ - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" - } - ], + "changes": [], "_id": "ir4iKLIQ4CH1Qckn", "type": "base", "system": {}, diff --git a/src/packs/items/weapons/weapon_Greatbow_MXBpbqQsZFln4rZk.json b/src/packs/items/weapons/weapon_Greatbow_MXBpbqQsZFln4rZk.json index f97e5432..f56e77c7 100644 --- a/src/packs/items/weapons/weapon_Greatbow_MXBpbqQsZFln4rZk.json +++ b/src/packs/items/weapons/weapon_Greatbow_MXBpbqQsZFln4rZk.json @@ -113,18 +113,7 @@ "name": "Powerful", "description": "On a successful attack, roll an additional damage die and discard the lowest result.", "img": "icons/magic/control/buff-flight-wings-runes-red-yellow.webp", - "changes": [ - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" - } - ], + "changes": [], "_id": "K4VgrDjVj1U1m9Ie", "type": "base", "system": {}, diff --git a/src/packs/items/weapons/weapon_Greatstaff_Yk8pTEmyLLi4095S.json b/src/packs/items/weapons/weapon_Greatstaff_Yk8pTEmyLLi4095S.json index 0fbfc2b4..66c12e5e 100644 --- a/src/packs/items/weapons/weapon_Greatstaff_Yk8pTEmyLLi4095S.json +++ b/src/packs/items/weapons/weapon_Greatstaff_Yk8pTEmyLLi4095S.json @@ -113,18 +113,7 @@ "name": "Powerful", "description": "On a successful attack, roll an additional damage die and discard the lowest result.", "img": "icons/magic/control/buff-flight-wings-runes-red-yellow.webp", - "changes": [ - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" - } - ], + "changes": [], "_id": "904orawScurM9GjG", "type": "base", "system": {}, diff --git a/src/packs/items/weapons/weapon_Greatsword_70ysaFJDREwTgvZa.json b/src/packs/items/weapons/weapon_Greatsword_70ysaFJDREwTgvZa.json index 4707e397..f60e438d 100644 --- a/src/packs/items/weapons/weapon_Greatsword_70ysaFJDREwTgvZa.json +++ b/src/packs/items/weapons/weapon_Greatsword_70ysaFJDREwTgvZa.json @@ -118,16 +118,6 @@ "key": "system.evasion", "mode": 2, "value": "-1" - }, - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" } ], "_id": "cffkpiwGpEGhjiUC", diff --git a/src/packs/items/weapons/weapon_Improved_Greatstaff_LCuTrYXi4lhg6LqW.json b/src/packs/items/weapons/weapon_Improved_Greatstaff_LCuTrYXi4lhg6LqW.json index 5faa0b0e..cf1bdf63 100644 --- a/src/packs/items/weapons/weapon_Improved_Greatstaff_LCuTrYXi4lhg6LqW.json +++ b/src/packs/items/weapons/weapon_Improved_Greatstaff_LCuTrYXi4lhg6LqW.json @@ -113,18 +113,7 @@ "name": "Powerful", "description": "On a successful attack, roll an additional damage die and discard the lowest result.", "img": "icons/magic/control/buff-flight-wings-runes-red-yellow.webp", - "changes": [ - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" - } - ], + "changes": [], "_id": "hnayB09P25ZW3gVY", "type": "base", "system": {}, diff --git a/src/packs/items/weapons/weapon_Improved_Greatsword_FPX4ouDrxXiQ5MDf.json b/src/packs/items/weapons/weapon_Improved_Greatsword_FPX4ouDrxXiQ5MDf.json index f8407b13..f71e5ea6 100644 --- a/src/packs/items/weapons/weapon_Improved_Greatsword_FPX4ouDrxXiQ5MDf.json +++ b/src/packs/items/weapons/weapon_Improved_Greatsword_FPX4ouDrxXiQ5MDf.json @@ -118,16 +118,6 @@ "key": "system.evasion", "mode": 2, "value": "-1" - }, - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" } ], "_id": "2nl35v8sPAudiOIb", diff --git a/src/packs/items/weapons/weapon_Legendary_Greatstaff_jDtvEabkHY1GFgfc.json b/src/packs/items/weapons/weapon_Legendary_Greatstaff_jDtvEabkHY1GFgfc.json index 0d317f0d..a5ea82f9 100644 --- a/src/packs/items/weapons/weapon_Legendary_Greatstaff_jDtvEabkHY1GFgfc.json +++ b/src/packs/items/weapons/weapon_Legendary_Greatstaff_jDtvEabkHY1GFgfc.json @@ -113,18 +113,7 @@ "name": "Powerful", "description": "On a successful attack, roll an additional damage die and discard the lowest result.", "img": "icons/magic/control/buff-flight-wings-runes-red-yellow.webp", - "changes": [ - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" - } - ], + "changes": [], "_id": "OV1Ly7vX4owBUgLQ", "type": "base", "system": {}, diff --git a/src/packs/items/weapons/weapon_Legendary_Greatsword_zMZ46F9VR7zdTxb9.json b/src/packs/items/weapons/weapon_Legendary_Greatsword_zMZ46F9VR7zdTxb9.json index fb7a2ed3..840e7ec7 100644 --- a/src/packs/items/weapons/weapon_Legendary_Greatsword_zMZ46F9VR7zdTxb9.json +++ b/src/packs/items/weapons/weapon_Legendary_Greatsword_zMZ46F9VR7zdTxb9.json @@ -118,16 +118,6 @@ "key": "system.evasion", "mode": 2, "value": "-1" - }, - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" } ], "_id": "oRCiXSElN5xufUfn", diff --git a/src/packs/items/weapons/weapon_Mage_Orb_XKBmBUEoGLdLcuqQ.json b/src/packs/items/weapons/weapon_Mage_Orb_XKBmBUEoGLdLcuqQ.json index 8d3fd741..3b5983f5 100644 --- a/src/packs/items/weapons/weapon_Mage_Orb_XKBmBUEoGLdLcuqQ.json +++ b/src/packs/items/weapons/weapon_Mage_Orb_XKBmBUEoGLdLcuqQ.json @@ -113,18 +113,7 @@ "name": "Powerful", "description": "On a successful attack, roll an additional damage die and discard the lowest result.", "img": "icons/magic/control/buff-flight-wings-runes-red-yellow.webp", - "changes": [ - { - "key": "system.bonuses.damage.primaryWeapon.extraDice", - "mode": 2, - "value": "1" - }, - { - "key": "system.rules.weapon.dropLowestDamageDice", - "mode": 5, - "value": "1" - } - ], + "changes": [], "_id": "2J6vzNUel78JFypp", "type": "base", "system": {}, diff --git a/system.json b/system.json index 2e216dc1..f9131987 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "id": "daggerheart", "title": "Daggerheart", "description": "An unofficial implementation of the Daggerheart system", - "version": "1.5.1", + "version": "1.5.2", "compatibility": { "minimum": "13.346", "verified": "13.351",