From 851d1eae28960cdbbfa302c8f7be817527bc8400 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Wed, 30 Oct 2024 01:42:19 -0700 Subject: [PATCH] feat: Add Make an Impression with Performance to BAM This requires a feat. It's not the same as the alt skill check, as it's necessary to select which skill to use. So it should be another action, but only show if the feat is present. --- .../feature/macros/basicActionMacros.ts | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/module/feature/macros/basicActionMacros.ts b/src/module/feature/macros/basicActionMacros.ts index ffc940319..ebbbae8ce 100644 --- a/src/module/feature/macros/basicActionMacros.ts +++ b/src/module/feature/macros/basicActionMacros.ts @@ -90,21 +90,31 @@ function createButtonData( } type MacroAction = { + // These are supplied for each supported action + actionType: "basic" | "skill_untrained" | "skill_trained" | "other"; + // Skill name or blank for non-skill actions skill: StatisticSlug | ""; // The altSkillAndFeat stuff should really be more flexible. Maybe look at what SkillActions did for prereqs? altSkillAndFeat?: { skill: StatisticSlug; feat: string }[]; + // Localized name to appear in menu name: string; + // Path to icon icon: string; + // Object to use when action is selected action: Function | Action | ActionVariant | undefined; + // Optional parameters for an Action.use() call for Action or ActionVariant type actions + options?: Partial; + // Module needed for action to be present (external macros) module?: string; + // Feat needed to for action to be present + feat?: string; + + // These are all filled in based on the action and actor data best?: number; whoIsBest?: string; showMAP?: boolean; showExploration?: boolean; showDowntime?: boolean; - // Optional parameters for an Action.use() call - options?: Partial; - actionType?: "basic" | "skill_untrained" | "skill_trained" | "other"; }; /** @@ -116,15 +126,16 @@ type MacroAction = { */ function prepareActions(selectedActor: ActorPF2e, bamActions: MacroAction[]): MacroAction[] { const showUnusable = game.settings.get(MODULENAME, "bamShowUnusable"); + const hasFeat = (slug: string) => selectedActor.itemTypes.feat.some((feat) => feat.slug === slug); const actionsToUse = bamActions .filter((x) => { const hasSkill = selectedActor.skills?.[x.skill]?.rank ?? 0 > 0; const hasAltSkillAndFeat = x.altSkillAndFeat?.some( - (y) => - selectedActor.skills?.[y.skill].rank && - selectedActor.itemTypes.feat.some((feat) => feat.slug === y.feat), + (y) => selectedActor.skills?.[y.skill].rank && hasFeat(y.feat), ); + if (x.module && !game.modules.get(x.module)?.active) return false; + if (x.feat && !hasFeat(x.feat)) return false; return ( showUnusable || @@ -135,7 +146,6 @@ function prepareActions(selectedActor: ActorPF2e, bamActions: MacroAction[]): Ma hasAltSkillAndFeat ); }) - .filter((m) => (m.module ? game.modules.get(m.module)?.active : true)) .sort((a, b) => a.name.localeCompare(b.name, game.i18n.lang)); actionsToUse.forEach((x) => { @@ -452,6 +462,18 @@ export async function basicActionMacros() { action: game.pf2e.actions.get("make-an-impression"), icon: "icons/environment/people/commoner.webp", }, + { + actionType: "skill_trained", + name: + game.i18n.localize(`${MODULENAME}.macros.basicActionMacros.actions.MakeAnImpression`) + + " - " + + game.i18n.localize("PF2E.Skill.Performance"), + skill: "performance", + action: game.pf2e.actions.get("make-an-impression"), + options: { statistic: "performance" }, + icon: "icons/environment/people/commoner.webp", + feat: "impressive-performance", + }, { actionType: "skill_trained", name: game.i18n.localize(`${MODULENAME}.macros.basicActionMacros.actions.ManeuverInFlight`),