Skip to content

Comments

Fix Armor Expertise resistances on SF2e#21373

Open
surged20 wants to merge 1 commit intofoundryvtt:v13-devfrom
surged20:sf2e-armor-expertise
Open

Fix Armor Expertise resistances on SF2e#21373
surged20 wants to merge 1 commit intofoundryvtt:v13-devfrom
surged20:sf2e-armor-expertise

Conversation

@surged20
Copy link
Contributor

SF2e's Armor Expertise rule element references
@armor.system.traits.config.resilient in its formula, but this property is only set when armor has a resilient-X trait. This caused formula resolution failures on SF2e actors with Armor Expertise when wearing armor without the resilient trait.

Initialize traits.config.resilient to 0 during prepareBaseData to ensure the property is always defined, matching the pattern used by PF2e's system.runes.potency field (which defaults to 0 via schema).

@stwlam stwlam added pr: bugfix sf2e System issues affecting Starfinder 2e labels Jan 30, 2026
@stwlam
Copy link
Collaborator

stwlam commented Jan 30, 2026

Can we update the data field definition? It should cast any null value to 0

@surged20
Copy link
Contributor Author

Can we update the data field definition? It should cast any null value to 0

Yes, I see for melee items, it's using TraitConfigField in MeleeSystemData so this works. But for armor items, it's just using an interface with TraitConfig and so no model initialization logic (so trying this I see I still need an explicit janky {resilient:0} initializer for TraitConfig where that interface is used in document/helpers). It seems it would need a refactor to add something like ArmorSystemData that uses TraitConfigField properly. What's the recommended path here or did I miss something?

@CarlosFdez
Copy link
Collaborator

Late reply but I think running the weapon through the trait config field at certain points is fine as a temporary workaround until weapons are data models.

SF2e's Armor Expertise rule element references
@armor.system.traits.config.resilient in its formula, but this property
is only set when armor has a resilient-X trait. This caused formula
resolution failures on SF2e actors with Armor Expertise when wearing
armor without the resilient trait.

Add `resilient` to TraitConfigField (initial: 0) and run items through
it in prepareBaseData so the field is always initialized.
@surged20 surged20 force-pushed the sf2e-armor-expertise branch from 6ab7625 to 7f493da Compare February 13, 2026 12:25
@surged20
Copy link
Contributor Author

Late reply but I think running the weapon through the trait config field at certain points is fine as a temporary workaround until weapons are data models.

Updated with this approach. I initially tried to add a clean traits helper that's used in addOrUpgradeTrait, but saw the build tooling doesn't like that since it needs to resolve runtime interfaces. Fell back to using the hardcoded init in that helper like with modular.

FWIW, Obodaya (Level 7) is an existing actor that triggers this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: bugfix sf2e System issues affecting Starfinder 2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants