Skip to content

Commit

Permalink
Suppress abilities granted by features suppressed by a class archetype (
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosFdez authored Mar 12, 2025
1 parent cfbf5d3 commit 5b66d68
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/module/actor/character/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ class CharacterSheetPF2e<TActor extends CharacterPF2e> extends CreatureSheetPF2e
continue;
}

// Skip suppressed items
if (item.suppressed) continue;

// KINETICIST HARD CODE: Show elemental blasts alongside strikes instead of among other actions
// If the user added additional blasts manually, show the duplicates normally
if (actor.flags.pf2e.kineticist && item === elementalBlasts[0]) {
Expand Down
13 changes: 13 additions & 0 deletions src/module/item/ability/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { CraftingAbility } from "@actor/character/crafting/ability.ts";
import { ItemPF2e } from "@item";
import type { ActionCost, Frequency, RawItemChatData } from "@item/base/data/index.ts";
import type { RangeData } from "@item/types.ts";
import type { RuleElementOptions, RuleElementPF2e } from "@module/rules/index.ts";
import type { UserPF2e } from "@module/user/index.ts";
import { sluggify } from "@util";
import type { AbilitySource, AbilitySystemData } from "./data.ts";
Expand All @@ -17,6 +18,9 @@ class AbilityItemPF2e<TParent extends ActorPF2e | null = ActorPF2e | null> exten
/** If this ability can craft, what is the crafting ability */
declare crafting?: CraftingAbility | null;

/** If suppressed, this ability should not be visible on character sheets nor have rule elements */
declare suppressed: boolean;

static override get validTraits(): Record<AbilityTrait, string> {
return CONFIG.PF2E.actionTraits;
}
Expand Down Expand Up @@ -45,6 +49,9 @@ class AbilityItemPF2e<TParent extends ActorPF2e | null = ActorPF2e | null> exten
}

override prepareActorData(): void {
// Exit early if the ability is being suppressed
if (this.suppressed) return;

const actor = this.actor;
if (actor?.isOfType("familiar") && this.system.category === "familiar") {
const slug = this.slug ?? sluggify(this.name);
Expand All @@ -66,6 +73,12 @@ class AbilityItemPF2e<TParent extends ActorPF2e | null = ActorPF2e | null> exten
return rollOptions;
}

/** Overriden to not create rule elements when suppressed */
override prepareRuleElements(options?: Omit<RuleElementOptions, "parent">): RuleElementPF2e[] {
if (this.suppressed) return [];
return super.prepareRuleElements(options);
}

override async getChatData(
this: AbilityItemPF2e<ActorPF2e>,
htmlOptions: EnrichmentOptions = {},
Expand Down
12 changes: 8 additions & 4 deletions src/module/item/feat/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ActorPF2e } from "@actor";
import type { AbilityItemPF2e } from "@item";
import type { FeatPF2e } from "./document.ts";

/**
Expand All @@ -16,10 +17,13 @@ function featCanHaveKeyOptions(feat: FeatPF2e): boolean {
}

/** Recursively suppresses a feat and its granted feats */
function suppressFeats(feats: FeatPF2e[]): void {
for (const feat of feats) {
feat.suppressed = true;
suppressFeats(feat.grants.filter((i): i is FeatPF2e<ActorPF2e> => i.isOfType("feat")));
function suppressFeats(feats: (FeatPF2e | AbilityItemPF2e)[]): void {
for (const featOrAbility of feats) {
featOrAbility.suppressed = true;
const allGrants = Object.values(featOrAbility.flags.pf2e.itemGrants)
.map((g) => featOrAbility.actor?.items.get(g.id))
.filter((i): i is FeatPF2e<ActorPF2e> | AbilityItemPF2e<ActorPF2e> => !!i?.isOfType("action", "feat"));
suppressFeats(allGrants);
}
}

Expand Down

0 comments on commit 5b66d68

Please sign in to comment.