From caf089fada81bdbfb533a0720b506fc4cd7b1e3d Mon Sep 17 00:00:00 2001 From: Eligarf Date: Fri, 6 Jan 2023 09:08:40 -0800 Subject: [PATCH] V2.1 (#61) * Dnd4e supported * Fixed bug in PF1 where it used the wrong actor source for the take-10 perception tests * Organize keys in language file --- ChangeLog.md | 3 ++- README.md | 2 +- module.json | 4 ++-- scripts/stealthy.js | 8 ++++---- scripts/systems/dnd4e.js | 9 ++++----- scripts/systems/dnd5e.js | 12 ++++++++++-- scripts/systems/pf1.js | 6 +++--- scripts/systems/pf2e.js | 8 ++++---- 8 files changed, 30 insertions(+), 22 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index ca52c2a..651c38b 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,6 @@ -# Pending +# v2.1.0 * Dnd4e supported +* Fixed bug in PF1 where it used the wrong actor source for the take-10 perception tests * Organize keys in language file # v2.0.0 diff --git a/README.md b/README.md index 8800f37..d4b97fd 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ controlled.forEach(token => { *Remove Spot is the same with a 'stealthy.spot.label' substitution* ## pf2e -In progress. There are complications getting Stealthy to work in PF2e since the Active Effect system has been overridden and there are complications with how DetectionMode.testVisibility results are handled. +In progress. There are complications getting Stealthy to work in PF2e given the level of customization within that system. # Limitations diff --git a/module.json b/module.json index 2a68d9a..7d07b5c 100644 --- a/module.json +++ b/module.json @@ -12,7 +12,7 @@ "flags": {} } ], - "version": "2.0.0", + "version": "2.1.0", "compatibility": { "minimum": "10.291", "verified": "10.291" @@ -55,7 +55,7 @@ } ], "socket": true, - "download": "https://github.com/Eligarf/stealthy/releases/download/v2.0.0/stealthy.zip", + "download": "https://github.com/Eligarf/stealthy/releases/download/v2.1.0/stealthy.zip", "changelog": "https://raw.githubusercontent.com/eligarf/stealthy/release/ChangeLog.md", "url": "https://github.com/Eligarf/stealthy", "manifest": "https://github.com/Eligarf/stealthy/releases/latest/download/module.json", diff --git a/scripts/stealthy.js b/scripts/stealthy.js index 3e49370..f9b4d6d 100644 --- a/scripts/stealthy.js +++ b/scripts/stealthy.js @@ -54,7 +54,7 @@ export class StealthyBaseEngine { return wrapped(visionSource, mode, config); } - makeHiddenEffect(label) { + makeHiddenEffectMaker(label) { return (flag, source) => { let hidden = { label, @@ -86,14 +86,14 @@ export class StealthyBaseEngine { }; } - makeSpotEffect(label) { + makeSpotEffectMaker(label) { return (flag, source) => ({ label, icon: 'icons/commodities/biological/eye-blue.webp', - duration: { turns: 1, seconds: 6 }, flags: { convenientDescription: game.i18n.localize("stealthy.spot.description"), - stealthy: flag + stealthy: flag, + core: { statusId: '1' }, }, }); } diff --git a/scripts/systems/dnd4e.js b/scripts/systems/dnd4e.js index f0658bd..f96dcd8 100644 --- a/scripts/systems/dnd4e.js +++ b/scripts/systems/dnd4e.js @@ -22,11 +22,10 @@ export class StealthyDnd4e extends StealthyBaseEngine { isHidden(visionSource, hiddenEffect, target, config) { // Never gets called, neither do the patches for the v10 vision modes // dead in the water - Stealthy.log('StealthyDnd4e', { visionSource, hidden: hiddenEffect, target, config }); const source = visionSource.object?.actor; - const stealth = hiddenEffect.flags.stealthy?.hidden ?? (10 + actor.system.skills.stl.total); + const stealth = hiddenEffect.flags.stealthy?.hidden ?? (10 + target.system.skills.stl.total); const spotEffect = this.findSpotEffect(source); - const perception = spotEffect?.flags.stealthy?.spot ?? (10 + actor.system.skills.prc.total); + const perception = spotEffect?.flags.stealthy?.spot ?? (10 + source.system.skills.prc.total); if (perception <= stealth) { Stealthy.log(`${visionSource.object.name}'s ${perception} can't see ${config.object.name}'s ${stealth}`); @@ -67,7 +66,7 @@ export class StealthyDnd4e extends StealthyBaseEngine { label, actor, flag: { spot: message.rolls[0].total }, - makeEffect: this.makeSpotEffect(label) + makeEffect: this.makeSpotEffectMaker(label) }); } @@ -81,7 +80,7 @@ export class StealthyDnd4e extends StealthyBaseEngine { label, actor, flag: { hidden: message.rolls[0].total }, - makeEffect: this.makeHiddenEffect(label) + makeEffect: this.makeHiddenEffectMaker(label) }); } } diff --git a/scripts/systems/dnd5e.js b/scripts/systems/dnd5e.js index 138abb2..e803d08 100644 --- a/scripts/systems/dnd5e.js +++ b/scripts/systems/dnd5e.js @@ -62,6 +62,14 @@ export class Stealthy5e extends StealthyBaseEngine { return super.basicVision(wrapped, visionSource, mode, config); } + makeSpotEffectMaker(label) { + return (flag, source) => { + let effect = super.makeSpotEffectMaker(label)(flag, source); + effect.duration = { turns: 1, seconds: 6 }; + return effect; + }; + } + getHiddenFlagAndValue(actor, effect) { const value = effect.flags.stealthy?.hidden ?? actor.system.skills.ste.passive; return { flag: { hidden: value }, value }; @@ -124,7 +132,7 @@ export class Stealthy5e extends StealthyBaseEngine { label, actor, flag: { spot: perception }, - makeEffect: this.makeSpotEffect(label) + makeEffect: this.makeSpotEffectMaker(label) }); } @@ -136,7 +144,7 @@ export class Stealthy5e extends StealthyBaseEngine { label, actor, flag: { hidden: roll.total }, - makeEffect: this.makeHiddenEffect(label) + makeEffect: this.makeHiddenEffectMaker(label) }); } diff --git a/scripts/systems/pf1.js b/scripts/systems/pf1.js index 8aaa2b3..ae4a5c1 100644 --- a/scripts/systems/pf1.js +++ b/scripts/systems/pf1.js @@ -23,7 +23,7 @@ export class StealthyPF1 extends StealthyBaseEngine { const source = visionSource.object?.actor; const stealth = hiddenEffect.flags.stealthy?.hidden ?? (10 + target.system.skills.ste.mod); const spotEffect = this.findSpotEffect(source); - const perception = spotEffect?.flags.stealthy?.spot ?? (10 + target.system.skills.per.mod); + const perception = spotEffect?.flags.stealthy?.spot ?? (10 + source.system.skills.per.mod); if (perception <= stealth) { Stealthy.log(`${visionSource.object.name}'s ${perception} can't see ${config.object.name}'s ${stealth}`); @@ -62,7 +62,7 @@ export class StealthyPF1 extends StealthyBaseEngine { label, actor, flag: { spot: message.rolls[0].total }, - makeEffect: this.makeSpotEffect(label) + makeEffect: this.makeSpotEffectMaker(label) }); } @@ -74,7 +74,7 @@ export class StealthyPF1 extends StealthyBaseEngine { label, actor, flag: { hidden: message.rolls[0].total }, - makeEffect: this.makeHiddenEffect(label) + makeEffect: this.makeHiddenEffectMaker(label) }); } } diff --git a/scripts/systems/pf2e.js b/scripts/systems/pf2e.js index 194b5a0..e7c5d1b 100644 --- a/scripts/systems/pf2e.js +++ b/scripts/systems/pf2e.js @@ -16,12 +16,12 @@ export class StealthyPF2e extends StealthyBaseEngine { return false; } - makeHiddenEffect(label) { - console.error(`'${game.system.id}' can't make a Hidden effect. Heavy lifting goes here.`); + makeHiddenEffectMaker(label) { + console.error(`'${game.system.id}' can't make a Hidden effect maker. Heavy lifting goes here.`); } - makeSpotEffect(label) { - console.error(`'${game.system.id}' can't make a Spot effect. Heavy lifting goes here.`); + makeSpotEffectMaker(label) { + console.error(`'${game.system.id}' can't make a Spot effect maker. Heavy lifting goes here.`); } async updateOrCreateEffect({ label, actor, flag, makeEffect }) {