diff --git a/ChangeLog.md b/ChangeLog.md index 3d0cf6d..83147a5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,8 +1,9 @@ -# v4.0.8 -* look for midi-qol flag to determine if perception disadvantage is already present before adding a -5 penalty to passive perception in dim light +# v4.1.0 +* dnd5e: look for midi-qol flag to determine if perception disadvantage is already present before adding a -5 penalty to passive perception in dim light +* pf1: allow GMs to specify a value other than 10 for take-10 passive spot option # v4.0.7 -* v12 compatability +* v12 compatibility # v4.0.6 * Handle tokens without skills (like vehicles) diff --git a/languages/en.json b/languages/en.json index 22cc710..e2f368e 100644 --- a/languages/en.json +++ b/languages/en.json @@ -112,9 +112,9 @@ }, "pf1": { "name": "Pathfinder", - "spotTake10": { - "name": "Perception take-10", - "hint": "If no banked perception roll is available, assume the Perception take-10 result for the visibility test. If disabled, Hidden tokens will not be seen without a banked perception roll." + "passiveSpotOffset": { + "name": "Assumed roll for passive spotting", + "hint": "If no banked perception roll is available, assume this value for the d20 in the visibility test. Typically, -99 to auto-fail or 10 for a take-10 result." } }, "pf2e": { diff --git a/languages/fr.json b/languages/fr.json index 8534b79..0bea3b3 100644 --- a/languages/fr.json +++ b/languages/fr.json @@ -112,9 +112,9 @@ }, "pf1": { "name": "Pathfinder", - "spotTake10": { - "name": "Test de perception-10", - "hint": "If no banked perception roll is available, assume the Perception take-10 result for the visibility test. If disabled, Hidden tokens will not be seen without a banked perception roll." + "passiveSpotOffset": { + "name": "Assumed roll for passive spotting", + "hint": "If no banked perception roll is available, assume this value for the d20 in the visibility test. Typically, -99 to auto-fail or 10 for a take-10 result." } }, "pf2e": { diff --git a/languages/pt-BR.json b/languages/pt-BR.json index 12a4477..0d377f0 100644 --- a/languages/pt-BR.json +++ b/languages/pt-BR.json @@ -112,9 +112,9 @@ }, "pf1": { "name": "Pathfinder", - "spotTake10": { - "name": "Percepção pegue-10", - "hint": "Se nenhum efeito Percebendo estiver ativo, assuma o resultado de Percepção - 10 para o teste de visibilidade. Se desativado, os tokens Escondidos não serão vistos sem um efeito Percebendo ativo." + "passiveSpotOffset": { + "name": "Assumed roll for passive spotting", + "hint": "If no banked perception roll is available, assume this value for the d20 in the visibility test. Typically, -99 to auto-fail or 10 for a take-10 result." } }, "pf2e": { diff --git a/scripts/hooks.js b/scripts/hooks.js index 8eec09c..a9c033b 100644 --- a/scripts/hooks.js +++ b/scripts/hooks.js @@ -6,7 +6,7 @@ function migrate(moduleVersion, oldVersion) { return moduleVersion; } -Hooks.once('setup', () => { +Hooks.once('init', () => { const module = game.modules.get(Stealthy.MODULE_ID); const moduleVersion = module.version; @@ -21,7 +21,6 @@ Hooks.once('setup', () => { stealthy.stealthToActor = value; } }); - stealthy.stealthToActor = game.settings.get(Stealthy.MODULE_ID, 'stealthToActor'); game.settings.register(Stealthy.MODULE_ID, 'perceptionToActor', { name: game.i18n.localize("stealthy.perceptionToActor.name"), @@ -34,7 +33,6 @@ Hooks.once('setup', () => { stealthy.perceptionToActor = value; } }); - stealthy.perceptionToActor = game.settings.get(Stealthy.MODULE_ID, 'perceptionToActor'); game.settings.register(Stealthy.MODULE_ID, 'friendlyStealth', { name: game.i18n.localize("stealthy.friendlyStealth.name"), @@ -177,12 +175,6 @@ Hooks.once('setup', () => { } } }); - const schemaVersion = game.settings.get(Stealthy.MODULE_ID, 'schema'); - if (schemaVersion !== moduleVersion) { - Hooks.once('ready', () => { - game.settings.set(Stealthy.MODULE_ID, 'schema', migrate(moduleVersion, schemaVersion)); - }); - } game.settings.register(Stealthy.MODULE_ID, 'activeSpot', { scope: 'world', @@ -190,11 +182,29 @@ Hooks.once('setup', () => { type: Boolean, default: true, }); - stealthy.bankingPerception = game.settings.get(Stealthy.MODULE_ID, 'activeSpot'); Stealthy.log(`Initialized ${moduleVersion}`); }); +Hooks.once('setup', () => { + const module = game.modules.get(Stealthy.MODULE_ID); + const moduleVersion = module.version; + + stealthy.stealthToActor = game.settings.get(Stealthy.MODULE_ID, 'stealthToActor'); + stealthy.perceptionToActor = game.settings.get(Stealthy.MODULE_ID, 'perceptionToActor'); + + const schemaVersion = game.settings.get(Stealthy.MODULE_ID, 'schema'); + if (schemaVersion !== moduleVersion) { + Hooks.once('ready', () => { + game.settings.set(Stealthy.MODULE_ID, 'schema', migrate(moduleVersion, schemaVersion)); + }); + } + + stealthy.bankingPerception = game.settings.get(Stealthy.MODULE_ID, 'activeSpot'); + + Stealthy.log(`Setup ${moduleVersion}`); +}); + const LIGHT_ICONS = { bright: '', dim: '', diff --git a/scripts/systems/dnd5e.js b/scripts/systems/dnd5e.js index e62529b..557daa0 100644 --- a/scripts/systems/dnd5e.js +++ b/scripts/systems/dnd5e.js @@ -31,55 +31,53 @@ class Engine5e extends Engine { } }); - Hooks.once('setup', () => { - game.settings.register(Stealthy.MODULE_ID, 'perceptionDisadvantage', { - name: game.i18n.localize("stealthy.dnd5e.perceptionDisadvantage.name"), - hint: game.i18n.localize("stealthy.dnd5e.perceptionDisadvantage.hint"), - scope: 'world', - config: true, - type: Boolean, - default: true, - }); - - game.settings.register(Stealthy.MODULE_ID, 'stealthKey', { - name: game.i18n.localize("stealthy.dnd5e.stealthKey.name"), - hint: game.i18n.localize("stealthy.dnd5e.stealthKey.hint"), - scope: 'world', - config: true, - type: String, - default: 'ste' - }); - - game.settings.register(Stealthy.MODULE_ID, 'perceptionKey', { - name: game.i18n.localize("stealthy.dnd5e.perceptionKey.name"), - hint: game.i18n.localize("stealthy.dnd5e.perceptionKey.hint"), - scope: 'world', - config: true, - type: String, - default: 'prc' - }); - - game.settings.register(Stealthy.MODULE_ID, 'ignorePassiveFloor', { - name: game.i18n.localize("stealthy.dnd5e.ignorePassiveFloor.name"), - hint: game.i18n.localize("stealthy.dnd5e.ignorePassiveFloor.hint"), - scope: 'world', - config: true, - type: Boolean, - default: false, - }); - - game.settings.register(Stealthy.MODULE_ID, 'friendlyUmbralSight', { - name: game.i18n.localize("stealthy.dnd5e.friendlyUmbralSight.name"), - scope: 'world', - config: false, - type: String, - choices: { - 'allow': game.i18n.localize("stealthy.dnd5e.friendlyUmbralSight.allow"), - 'inCombat': game.i18n.localize("stealthy.dnd5e.friendlyUmbralSight.inCombat"), - 'ignore': game.i18n.localize("stealthy.dnd5e.friendlyUmbralSight.ignore") - }, - default: 'inCombat' - }); + game.settings.register(Stealthy.MODULE_ID, 'perceptionDisadvantage', { + name: game.i18n.localize("stealthy.dnd5e.perceptionDisadvantage.name"), + hint: game.i18n.localize("stealthy.dnd5e.perceptionDisadvantage.hint"), + scope: 'world', + config: true, + type: Boolean, + default: true, + }); + + game.settings.register(Stealthy.MODULE_ID, 'stealthKey', { + name: game.i18n.localize("stealthy.dnd5e.stealthKey.name"), + hint: game.i18n.localize("stealthy.dnd5e.stealthKey.hint"), + scope: 'world', + config: true, + type: String, + default: 'ste' + }); + + game.settings.register(Stealthy.MODULE_ID, 'perceptionKey', { + name: game.i18n.localize("stealthy.dnd5e.perceptionKey.name"), + hint: game.i18n.localize("stealthy.dnd5e.perceptionKey.hint"), + scope: 'world', + config: true, + type: String, + default: 'prc' + }); + + game.settings.register(Stealthy.MODULE_ID, 'ignorePassiveFloor', { + name: game.i18n.localize("stealthy.dnd5e.ignorePassiveFloor.name"), + hint: game.i18n.localize("stealthy.dnd5e.ignorePassiveFloor.hint"), + scope: 'world', + config: true, + type: Boolean, + default: false, + }); + + game.settings.register(Stealthy.MODULE_ID, 'friendlyUmbralSight', { + name: game.i18n.localize("stealthy.dnd5e.friendlyUmbralSight.name"), + scope: 'world', + config: false, + type: String, + choices: { + 'allow': game.i18n.localize("stealthy.dnd5e.friendlyUmbralSight.allow"), + 'inCombat': game.i18n.localize("stealthy.dnd5e.friendlyUmbralSight.inCombat"), + 'ignore': game.i18n.localize("stealthy.dnd5e.friendlyUmbralSight.ignore") + }, + default: 'inCombat' }); Hooks.on('dnd5e.rollSkill', async (actor, roll, skill) => { diff --git a/scripts/systems/pf1.js b/scripts/systems/pf1.js index f149342..03a6ccc 100644 --- a/scripts/systems/pf1.js +++ b/scripts/systems/pf1.js @@ -5,16 +5,31 @@ export class EnginePF1 extends Engine { constructor() { super(); + game.settings.register(Stealthy.MODULE_ID, 'spotTake10', { + scope: 'world', + config: false, + type: Boolean, + default: false, + }); + + game.settings.register(Stealthy.MODULE_ID, 'passiveSpotOffset', { + name: game.i18n.localize("stealthy.pf1.passiveSpotOffset.name"), + hint: game.i18n.localize("stealthy.pf1.passiveSpotOffset.hint"), + scope: 'world', + config: true, + type: Number, + default: -999, + }); - Hooks.once('setup', () => { - game.settings.register(Stealthy.MODULE_ID, 'spotTake10', { - name: game.i18n.localize("stealthy.pf1.spotTake10.name"), - hint: game.i18n.localize("stealthy.pf1.spotTake10.hint"), - scope: 'world', - config: true, - type: Boolean, - default: false, - }); + Hooks.once('ready', () => { + const offset = game.settings.get(Stealthy.MODULE_ID, 'passiveSpotOffset'); + if (offset === -999) { + game.settings.set( + Stealthy.MODULE_ID, + 'passiveSpotOffset', + game.settings.get(Stealthy.MODULE_ID, 'spotTake10') ? 10 : -99 + ) + } }); Hooks.on('pf1ActorRollSkill', async (actor, message, skill) => { @@ -54,11 +69,11 @@ export class EnginePF1 extends Engine { getPerceptionFlag(token) { const flag = super.getPerceptionFlag(token); if (flag) return flag; - if (!game.settings.get(Stealthy.MODULE_ID, 'spotTake10')) return undefined; + const offset = game.settings.get(Stealthy.MODULE_ID, 'passiveSpotOffset'); return { token, passive: true, - perception: 10 + token.actor.system?.skills?.per?.mod ?? -110 + perception: offset + (token.actor.system?.skills?.per?.mod ?? 0) }; }