Skip to content

Commit

Permalink
Acquire modifier adjustments for Volley penalty (#15610)
Browse files Browse the repository at this point in the history
  • Loading branch information
stwlam authored Jul 28, 2024
1 parent c96b0f7 commit 6e63427
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/module/actor/character/elemental-blast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class ElementalBlast {
config,
damageType,
}: CreateModifiedItemParams): AbilityItemPF2e<CharacterPF2e> | null {
const { item } = this;
const item = this.item;
if (!item) return null;

const traits = ((): ActionTrait[] => {
Expand All @@ -299,10 +299,12 @@ class ElementalBlast {
}

#createAttackStatistic(statistic: Statistic, item: AbilityItemPF2e<ActorPF2e>): Statistic {
const newDomain = "elemental-blast-attack-roll";
const domains = [...statistic.check.domains, newDomain];
return statistic.extend({
check: {
domains: ["elemental-blast-attack-roll"],
modifiers: AttackTraitHelpers.createAttackModifiers({ item }),
domains: [newDomain],
modifiers: AttackTraitHelpers.createAttackModifiers({ item, domains }),
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/module/actor/character/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class PCAttackTraitHelpers extends AttackTraitHelpers {
}
});

return [...super.createAttackModifiers({ item }), ...pcSpecificModifiers];
return [...super.createAttackModifiers({ item, domains }), ...pcSpecificModifiers];
}
}

Expand Down
11 changes: 9 additions & 2 deletions src/module/actor/creature/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ModifierPF2e } from "@actor/modifiers.ts";
import { ImmunityType } from "@actor/types.ts";
import type { AbilityItemPF2e, MeleePF2e, WeaponPF2e } from "@item";
import { ConditionPF2e } from "@item";
import { extractModifierAdjustments } from "@module/rules/helpers.ts";
import { Predicate } from "@system/predication.ts";
import { ErrorPF2e } from "@util";

Expand All @@ -19,8 +20,8 @@ class AttackTraitHelpers {
return trait.replace(/-d?\d{1,3}$/, "");
}

static createAttackModifiers({ item }: CreateAttackModifiersParams): ModifierPF2e[] {
const { actor } = item;
static createAttackModifiers({ item, domains }: CreateAttackModifiersParams): ModifierPF2e[] {
const actor = item.actor;
if (!actor) throw ErrorPF2e("The weapon must be embedded");

return item.system.traits.value.flatMap((trait) => {
Expand All @@ -41,6 +42,11 @@ class AttackTraitHelpers {
{ lte: ["target:distance", penaltyRange] },
{ not: "self:ignore-volley-penalty" },
),
adjustments: extractModifierAdjustments(
actor.synthetics.modifierAdjustments,
domains,
unannotatedTrait,
),
});
}
case "sweep": {
Expand Down Expand Up @@ -70,6 +76,7 @@ class AttackTraitHelpers {

interface CreateAttackModifiersParams {
item: AbilityItemPF2e<ActorPF2e> | WeaponPF2e<ActorPF2e> | MeleePF2e<ActorPF2e>;
domains: string[];
}

/** Set immunities for creatures with traits call for them */
Expand Down
2 changes: 1 addition & 1 deletion src/module/actor/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function strikeFromMeleeItem(item: MeleePF2e<ActorPF2e>): NPCStrike {
];

modifiers.push(...extractModifiers(synthetics, domains));
modifiers.push(...AttackTraitHelpers.createAttackModifiers({ item }));
modifiers.push(...AttackTraitHelpers.createAttackModifiers({ item, domains }));

const attackEffects: Record<string, string | undefined> = CONFIG.PF2E.attackEffects;
const additionalEffects = item.attackEffects.map((tag) => {
Expand Down

0 comments on commit 6e63427

Please sign in to comment.