Skip to content

Commit

Permalink
V2.1 (#61)
Browse files Browse the repository at this point in the history
* Dnd4e supported
* Fixed bug in PF1 where it used the wrong actor source for the take-10 perception tests
* Organize keys in language file
  • Loading branch information
Eligarf authored Jan 6, 2023
1 parent f8d4fdc commit caf089f
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 22 deletions.
3 changes: 2 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"flags": {}
}
],
"version": "2.0.0",
"version": "2.1.0",
"compatibility": {
"minimum": "10.291",
"verified": "10.291"
Expand Down Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions scripts/stealthy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class StealthyBaseEngine {
return wrapped(visionSource, mode, config);
}

makeHiddenEffect(label) {
makeHiddenEffectMaker(label) {
return (flag, source) => {
let hidden = {
label,
Expand Down Expand Up @@ -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' },
},
});
}
Expand Down
9 changes: 4 additions & 5 deletions scripts/systems/dnd4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down Expand Up @@ -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)
});
}

Expand All @@ -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)
});
}
}
Expand Down
12 changes: 10 additions & 2 deletions scripts/systems/dnd5e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down Expand Up @@ -124,7 +132,7 @@ export class Stealthy5e extends StealthyBaseEngine {
label,
actor,
flag: { spot: perception },
makeEffect: this.makeSpotEffect(label)
makeEffect: this.makeSpotEffectMaker(label)
});
}

Expand All @@ -136,7 +144,7 @@ export class Stealthy5e extends StealthyBaseEngine {
label,
actor,
flag: { hidden: roll.total },
makeEffect: this.makeHiddenEffect(label)
makeEffect: this.makeHiddenEffectMaker(label)
});
}

Expand Down
6 changes: 3 additions & 3 deletions scripts/systems/pf1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
Expand Down Expand Up @@ -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)
});
}

Expand All @@ -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)
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/systems/pf2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) {
Expand Down

0 comments on commit caf089f

Please sign in to comment.