diff --git a/src/module/feats/exploit-vulnerability/exploitVulnerability.js b/src/module/feats/exploit-vulnerability/exploitVulnerability.js index 910def0..3a36a34 100644 --- a/src/module/feats/exploit-vulnerability/exploitVulnerability.js +++ b/src/module/feats/exploit-vulnerability/exploitVulnerability.js @@ -87,140 +87,39 @@ async function exploitVuln() { ) ); } - const dc = game.settings.get("pf2e", "proficiencyVariant") - ? { - "-2": 13, - "-1": 13, - ...Object.fromEntries( - Object.entries([ - 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, - 19, 20, 20, 20, 21, 21, 21, 22, 22, - ]) - ), - }[t.actor.level] - : { - "-2": 12, - "-1": 13, - ...Object.fromEntries( - Object.entries([ - 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, - 36, 38, 39, 40, 42, 44, 46, 48, 50, - ]) - ), - }[t.actor.level]; - if (!dc) { - return ui.notifications.warn( - game.i18n.localize( - "pf2e-thaum-vuln.notifications.warn.exploitVulnerability.noMatchingDC" - ) - ); - } - - const rollOptions = sa.getRollOptions(["skill-check", skill.slug]); - - const outcomes = { - criticalSuccess: game.i18n.localize( - "pf2e-thaum-vuln.exploitVulnerability.degreeOfSuccess.criticalSuccess" - ), - success: game.i18n.localize( - "pf2e-thaum-vuln.exploitVulnerability.degreeOfSuccess.success" - ), - failure: game.i18n.localize( - "pf2e-thaum-vuln.exploitVulnerability.degreeOfSuccess.failure" - ), - criticalFailure: game.i18n.localize( - "pf2e-thaum-vuln.exploitVulnerability.degreeOfSuccess.criticalFailure" - ), - }; - - const notes = Object.entries(outcomes).map(([outcome, text]) => ({ - title: game.i18n.localize("PF2E.Check.Result.Degree.Check." + outcome), - text, - outcome: [outcome], - })); - - if (hasFeat(sa, "esoteric-warden")) { - notes.push({ - title: game.i18n.localize("pf2e-thaum-vuln.esotericWarden.name"), - text: game.i18n.localize("pf2e-thaum-vuln.esotericWarden.flavor"), - outcome: ["success", "criticalSuccess"], - }); - } + let notes = []; if (hasFeat(sa, "diverse-lore")) { // todo: put npc identify data in the document and then show secret text for it. // TODO: Error checking for rolling against PCs const dc = - (game.settings.get("pf2e", "proficiencyVariant") - ? { - "-2": 13, - "-1": 13, - ...Object.fromEntries( - Object.entries([ - 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, - 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, - ]) - ), - }[t.actor.level] - : { - "-2": 12, - "-1": 13, - ...Object.fromEntries( - Object.entries([ - 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, - 35, 36, 38, 39, 40, 42, 44, 46, 48, 50, - ]) - ), - }[t.actor.level]) + - game.settings.get("pf2e-thaum-vuln", "esotericLoreModifier"); + 14 + + Math.floor(t.actor.level / 3) + + game.settings.get("pf2e-thaum-vuln", "esotericLoreModifier") + + (game.pf2e.settings.variants.pwol.enabled + ? 0 + : t.actor.level + (t.actor.level < 0)); const diverseLoreDC = dc ? `
Recall Knowledge DC ${dc}` : ""; notes.push({ title: game.i18n.localize("pf2e-thaum-vuln.diverseLore.name"), - text: `${ - game.i18n.localize("pf2e-thaum-vuln.diverseLore.flavor") + diverseLoreDC - }`, + text: + game.i18n.localize("pf2e-thaum-vuln.diverseLore.flavor") + + diverseLoreDC, outcome: ["success", "criticalSuccess"], + predicate: ["feat:diverse-lore"], }); } - const flavor = `${game.i18n.localize( - "pf2e-thaum-vuln.exploitVulnerability.name" - )}: ${skill.label}`; - const checkModifier = new game.pf2e.CheckModifier(flavor, skill); - const traits = ["esoterica", "manipulate", "thaumaturge"]; - const evRoll = await game.pf2e.Check.roll( - checkModifier, - { - actor: sa, - target: { - actor: t.actor, - token: t.document, - }, - type: "skill-check", - options: rollOptions, - notes, - dc: { value: dc }, - traits: traits, - flavor: ` - ${game.i18n.localize( - "pf2e-thaum-vuln.exploitVulnerability.frequency.label" - )} ${game.i18n.localize( - "pf2e-thaum-vuln.exploitVulnerability.frequency.text" - )}
- ${game.i18n.localize( - "pf2e-thaum-vuln.exploitVulnerability.requirements.label" - )} ${game.i18n.localize( - "pf2e-thaum-vuln.exploitVulnerability.requirements.text" - )}
-
-

${game.i18n.localize("pf2e-thaum-vuln.exploitVulnerability.flavor")}

- `, - }, - event - ); + const result = await game.pf2e.actions.get("exploit-vulnerability").use({ + actors: [sa], + target: t.document, + notes, + event, + }); + const evRoll = result[0].roll; const rollDOS = evRoll?.degreeOfSuccess; //Apply effect based on Degrees of success @@ -268,4 +167,42 @@ function preDeleteEffect(a, sa = undefined) { return effects; } +Hooks.once("init", () => { + const hide = game.pf2e.actions.get("hide"); + const SingleCheckAction = Object.getPrototypeOf(hide).constructor; + const notes = [ + "criticalSuccess", + "success", + "failure", + "criticalFailure", + ].map((dos) => ({ + title: game.i18n.localize(`PF2E.Check.Result.Degree.Check.${dos}`), + text: game.i18n.localize( + `pf2e-thaum-vuln.exploitVulnerability.degreeOfSuccess.${dos}` + ), + outcome: [dos], + })); + + notes.push({ + title: game.i18n.localize("pf2e-thaum-vuln.esotericWarden.name"), + text: game.i18n.localize("pf2e-thaum-vuln.esotericWarden.flavor"), + outcome: ["success", "criticalSuccess"], + predicate: ["feat:esoteric-warden"], + }); + + const ExploitVulnerability = new SingleCheckAction({ + cost: 1, + description: "pf2e-thaum-vuln.exploitVulnerability.flavor", + name: "pf2e-thaum-vuln.exploitVulnerability.name", + notes, + rollOptions: ["action:exploit-vulnerability"], + slug: "exploit-vulnerability", + difficultyClass: "exploit-vulnerability", + statistic: "esoteric-lore", + traits: ["esoterica", "manipulate", "thaumaturge"], + }); + + game.pf2e.actions.set("exploit-vulnerability", ExploitVulnerability); +}); + export { exploitVuln, preDeleteEffect };