From 93767cd0bb770c65e006369c0b54377f93c0c27c Mon Sep 17 00:00:00 2001 From: Mike Bloy Date: Sun, 22 Mar 2026 21:37:47 -0500 Subject: [PATCH] changes for swade 5.2.2 --- CHANGELOG.md | 11 +++++ src/module.json | 6 +-- src/module/powers/basePowers.js | 14 +++++- src/module/powers/deflection.js | 21 ++++++++ src/module/rollHelpers.js | 48 +------------------ .../Setting_Adjustments_YSuk1v59tLaL9XUK.json | 4 +- 6 files changed, 51 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 977a954..7f27d25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [4.2.3] + +### Changed + +- Changed Deflection and Glow/Shroud target handling to use existing system + modifiers (`system.stats.globalMods.targetAttack` and friends. +- BREAKING CHANGE: removed special handling for Environmental Weakness and + Environmental Resistance. Use an active effect with a change to + `system.stats.globalMods.targetDamage` instead. +- Updated minimum SWADE version to 5.2.2 + ## [4.2.2] ### Added diff --git a/src/module.json b/src/module.json index 963c05d..5a82618 100644 --- a/src/module.json +++ b/src/module.json @@ -9,7 +9,7 @@ } ], "url": "https://git.bloy.org/foundryvtt/swade-mb-helpers", - "version": "4.2.2", + "version": "4.2.3", "compatibility": { "minimum": "13", "verified": "13" @@ -111,8 +111,8 @@ "type": "system", "manifest": "https://gitlab.com/api/v4/projects/16269883/packages/generic/swade/latest/system.json", "compatibility": { - "minimum": "5.2.0", - "verified": "5.2.0" + "minimum": "5.2.2", + "verified": "5.2.2" } } ], diff --git a/src/module/powers/basePowers.js b/src/module/powers/basePowers.js index d1bd1b8..e2203dd 100644 --- a/src/module/powers/basePowers.js +++ b/src/module/powers/basePowers.js @@ -344,7 +344,7 @@ export class PowerEffect { effects: { none: null, glow: { - name: 'Glow', + name: 'Glow (illumination bonus)', icon: 'icons/magic/light/orb-shadow-blue.webp', changes: [ { @@ -353,6 +353,12 @@ export class PowerEffect { priority: 0, mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, }, + { + key: 'system.stats.globalMods.targetAttack', + value: 1, + priority: 0, + mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, + }, ], }, shroud: { @@ -365,6 +371,12 @@ export class PowerEffect { priority: 0, mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, }, + { + key: 'system.stats.globalMods.targetAttack', + value: -1, + priority: 0, + mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, + }, ], }, }, diff --git a/src/module/powers/deflection.js b/src/module/powers/deflection.js index 463abbb..340b821 100644 --- a/src/module/powers/deflection.js +++ b/src/module/powers/deflection.js @@ -44,6 +44,27 @@ export class DeflectionEffect extends PowerEffect { this.data.affects = this.data.button === 'raise' ? 'all' : this.data.button; } + getPrimaryEffectChanges() { + const changes = super.getPrimaryEffectChanges(); + if (this.data.button === 'raise' || this.data.button === 'melee') { + changes.push({ + key: 'system.stats.globalMods.targetAttackMelee', + value: -2, + priority: 0, + mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, + }); + } + if (this.data.button === 'raise' || this.data.button === 'ranged') { + changes.push({ + key: 'system.stats.globalMods.targetAttackRanged', + value: -2, + priority: 0, + mode: foundry.CONST.ACTIVE_EFFECT_MODES.ADD, + }); + } + return changes; + } + get effectName() { return `Deflection (${this.data.affects})`; } diff --git a/src/module/rollHelpers.js b/src/module/rollHelpers.js index ee4b0f3..da1d399 100644 --- a/src/module/rollHelpers.js +++ b/src/module/rollHelpers.js @@ -109,33 +109,6 @@ export async function preAttackRollModifiers( return; } - // Deflection - if (isMeleeAttack && hasDeflection(targetToken, 'melee')) { - additionalMods.push({ label: 'Target has melee deflection', value: -2 }); - } - if (isMeleeAttack && hasDeflection(targetToken, 'range')) { - additionalMods.push({ label: 'Target has ranged deflection', value: -2 }); - } - if (hasDeflection(targetToken, 'all')) { - additionalMods.push({ label: 'Target has deflection', value: -2 }); - } - - // Glow/Shroud - if (targetHasEffect(targetToken, 'glow')) { - additionalMods.push({ - label: 'Glowing target (negate 1 point of illumination penalty)', - value: 1, - ignore: true, - }); - } - if (targetHasEffect(targetToken, 'shroud')) { - additionalMods.push({ - label: 'Shrouded target', - value: '-1', - ignore: false, - }); - } - // Swat correction const scaleMod = additionalMods.find((m) => m.label === 'SWADE.ScaleDifference'); if (scaleMod && scaleMod.value < 0 && sourceToken.actor.getSingleItemBySwid('swat', 'ability')) { @@ -172,6 +145,7 @@ function removeDuplicateMods(additionalMods, replacementModTitles) { // eslint-disable-next-line no-unused-vars export async function preTraitRollModifiers(actor, trait, roll, modifiers, options) { + console.log('PRE TRAIT ROLL', actor, trait, roll, modifiers, options); const targets = Array.from(game.user.targets); const token = game.canvas.tokens.controlled.length > 0 ? game.canvas.tokens.controlled[0]?.document : null; if (targets.length === 1 && token) { @@ -187,26 +161,6 @@ export async function preDamageRollModifiers(actor, item, roll, modifiers, optio if (targets.length === 1 && token) { const target = targets[0].scene.tokens.get(targets[0].id); _addArcaneModifiers(target, modifiers); - const weaknesses = target.actor.items.filter( - (i) => i.type === 'ability' && i.system.swid.toLowerCase().includes('environmental-weakness'), - ); - if (weaknesses.length > 0) { - modifiers.push( - ...weaknesses.map((i) => { - return { label: i.name, value: '+4', ignore: true }; - }), - ); - } - const resistances = target.actor.items.filter( - (i) => i.type === 'ability' && i.system.swid.toLowerCase().includes('environmental-resistance'), - ); - if (resistances.length > 0) { - modifiers.push( - ...resistances.map((i) => { - return { label: i.name, value: '-4', ignore: true }; - }), - ); - } if ( item.isMeleeWeapon && 'stats' in token.actor.system && diff --git a/src/packsrc/module-docs/Setting_Adjustments_YSuk1v59tLaL9XUK.json b/src/packsrc/module-docs/Setting_Adjustments_YSuk1v59tLaL9XUK.json index 53bfbad..bbffd84 100644 --- a/src/packsrc/module-docs/Setting_Adjustments_YSuk1v59tLaL9XUK.json +++ b/src/packsrc/module-docs/Setting_Adjustments_YSuk1v59tLaL9XUK.json @@ -52,7 +52,7 @@ "image": {}, "text": { "format": 1, - "content": "

SWADE Trait and Damage Rolls can now take into account common modifiers based on the target, if there is exactly one attacker and one target. Most will show up on all trait rolls if the target conditions are right. Gang up bonuses will only show up on Fighting rolls.

Any of the proposed modifiers may be ignored by checking the Ignore checkbox. Some modifiers are pre-ignored and must be unchecked to take effect.

The following target conditions are checked for before trait rolls:

  1. Vulnerable - Removed, handled by the system

  2. Deflection (as applied by the Deflection power effect from this module)

  3. Glow/Shroud (as applied by the power effect macros from this module)

  4. Arcane Protection (as applied by the Arcane Protection power effect from this module)

  5. Arcane Resistance

  6. Scale Modifiers, corrected from the system values by taking Swat into account

  7. Correction of system Gang Up modifiers to include Formation Fighter

  8. Range modifiers - Removed, handled by the system.

The following target conditions are checked for before damage rolls:

  1. Arcane Protection (as applied by the Arcane Protection power effect from this module)

  2. Arcane Resistance

  3. Special Abilities with 'weakness' in the swid (ignored by default, +4 damage)

  4. Special Abilities with 'resistance' in the swid (ignored by default, -4 damage)

  5. Gang Up modifiers corrected to include Formation Fighter

" + "content": "

SWADE Trait and Damage Rolls can now take into account common modifiers based on the target, if there is exactly one attacker and one target. Most will show up on all trait rolls if the target conditions are right. Gang up bonuses will only show up on Fighting rolls.

Any of the proposed modifiers may be ignored by checking the Ignore checkbox. Some modifiers are pre-ignored and must be unchecked to take effect.

The following target conditions are checked for before trait rolls:

  1. Vulnerable - Removed, handled by the system

  2. Deflection (as applied by the Deflection power effect from this module) - Removed, handled by the power macro and system modifiers.

  3. Glow/Shroud (as applied by the power effect macros from this module) - Removed, handled by the power macro and system modifiers.

  4. Arcane Protection (as applied by the Arcane Protection power effect from this module)

  5. Arcane Resistance

  6. Scale Modifiers, corrected from the system values by taking Swat into account

  7. Correction of system Gang Up modifiers to include Formation Fighter

  8. Range modifiers - Removed, handled by the system.

The following target conditions are checked for before damage rolls:

  1. Arcane Protection (as applied by the Arcane Protection power effect from this module)

  2. Arcane Resistance

  3. Special Abilities with 'weakness' in the swid (ignored by default, +4 damage) - Removed, properly handled by the system.stats.globalMods.targetDamage global modifier.

  4. Special Abilities with 'resistance' in the swid (ignored by default, -4 damage) - Removed, properly handled by the system.stats.globalMods.targetDamage global modifier.

  5. Gang Up modifiers corrected to include Formation Fighter

" }, "video": { "controls": true, @@ -70,7 +70,7 @@ "systemVersion": "3.2.5", "coreVersion": "13.351", "createdTime": 1703044226574, - "modifiedTime": 1773027249765, + "modifiedTime": 1774233079419, "lastModifiedBy": "sVoCvBU1knmXzoYe", "compendiumSource": null, "duplicateSource": null,