Skip to content

Write the perk effect function parameters Mutagen reads - #718

Open
WhiskyTangoFawks wants to merge 4 commits into
Mutagen-Modding:devfrom
WhiskyTangoFawks:fix/perk-entry-point-function-parameters
Open

WhiskyTangoFawks wants to merge 4 commits into
Mutagen-Modding:devfrom
WhiskyTangoFawks:fix/perk-entry-point-function-parameters

Conversation

@WhiskyTangoFawks

@WhiskyTangoFawks WhiskyTangoFawks commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

xEdit defines EPFB, EPF2 and EPF3 as function parameters any perk effect can carry, and Mutagen reads them onto every effect. Its writers wrote EPFB only for an entry point and EPF2 and EPF3 only for an activate choice, so a rewrite dropped them from any other effect. Separately, a Fallout 4 Add Activate Choice entry point with no EPF3 (e.g. FTS_FastTravelSettlement.esp) threw on read, though APerkEffect.Flags is already nullable, and its writer threw on a null Flags.

  • Fallout 4 and Starfield write each of EPFB, EPF2 and EPF3 for any effect that holds it, in xEdit's order. An activate choice without EPF3 reads as null Flags, from a full import and from an overlay, and null Flags writes no EPF3.
  • Skyrim writes EPF2 and EPF3 for any effect that holds them, in xEdit's order. APerkEffect.Flags is now nullable, as in Fallout 4 and Starfield, and holds a value exactly when EPF3 is present.
  • The activate choice's own ButtonLabel and Flags initialisers go; the code after the switch already assigns both for every effect.

Breaking: Skyrim's IAPerkEffectGetter.Flags is IPerkScriptFlagGetter?, and a new Skyrim effect has no Flags.

Behaviour change for code-built records: an effect of any kind that sets PerkEntryID, ButtonLabel or Flags now writes them, where before they were dropped. An activate choice with null Flags writes no EPF3, where before Fallout 4 and Starfield threw and Skyrim wrote an all-zero EPF3.

Still read and discarded, unchanged: EPFT and EPFD on a quest or ability effect. Fallout 4's masters and a 500-plugin Fallout 4 load order carry neither.

PerkFunctionParametersTests covers, for Fallout 4 and Starfield, an ability carrying the parameters and an activate choice with and without EPF3, by full import, overlay, and write then reread through the other path. For Skyrim, whose full import and overlay share one effect parser, it covers an ability with a button label, and an ability and an activate choice with and without EPF3, by write then reread.

WhiskyTangoFawks and others added 2 commits October 24, 2026 15:27
xEdit defines EPFB, EPF2 and EPF3 as function parameters any perk effect can
carry, and Mutagen reads them onto every effect. Its writers wrote EPFB only
for an entry point and EPF2 and EPF3 only for an activate choice, so a rewrite
dropped them from any other effect. A Fallout 4 Add Activate Choice entry
point that left out EPF3 also threw on read, though APerkEffect.Flags is
already nullable, and its writer threw on a null Flags.

- Fallout 4 and Starfield write each of the three for any effect that holds
  it. An activate choice without EPF3 reads as null Flags, from a full import
  and from an overlay, and a choice with null Flags writes no EPF3 rather than
  throwing.
- Skyrim writes EPF2 for any effect that holds it. Its Flags is a non-nullable
  PerkScriptFlag, so the model cannot say whether an effect had EPF3, and EPF3
  stays written for an activate choice alone. Skyrim already took EPF3 as
  optional on read.
- The activate choice's own ButtonLabel and Flags initialisers go: the code
  after the switch assigns both for every effect.
- EPFT and EPFD on a quest or ability effect are still read and discarded.
  Fallout 4's masters and a 500-plugin Fallout 4 load order carry neither.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Fallout 4, Skyrim and Starfield tests build the perk effects through
the API, write the mod to the test file system and reread it, in place of
hand-assembled bytes and the copied parse and write helpers.

The perk writers test for an entry point effect once: the shared EPFB,
EPF2 and EPF3 writes move into one method, called between an entry
point's EPFT and EPFD and on its own for every other effect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WhiskyTangoFawks
WhiskyTangoFawks force-pushed the fix/perk-entry-point-function-parameters branch from 20603d3 to 824fc1f Compare October 24, 2026 14:56

@Noggog Noggog left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making it nullable, as in Fallout 4 and Starfield, would close that, at the cost of an API change. Happy to do that here or separately if you'd like.

These types of API changes are acceptable within reason. Throw em in. In my view they're in a separate category than API changes to say, ILinkCache. Record definitions will always be evolving over time, realistically. Nature of this specific beast

WhiskyTangoFawks and others added 2 commits October 31, 2026 06:25
Skyrim's APerkEffect.Flags was a non-nullable PerkScriptFlag, so the model
could not say whether an effect held EPF3, and the writer wrote it for an
activate choice alone. A rewrite dropped EPF3 from any other effect, and
gave an activate choice without one an all-zero EPF3.

Flags is now nullable, as in Fallout 4 and Starfield, as review agreed. It
holds a value exactly when EPF3 is present, and EPF3 is written after EPF2
for any effect that holds it, in xEdit's order. APerkEffect_Generated.cs is
the Skyrim generator's output.

Breaking: IAPerkEffectGetter.Flags is IPerkScriptFlagGetter?, and a new
effect has no Flags.

Built by CI rather than locally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The activate choice is the one Skyrim effect whose EPF3 behaviour changed:
a choice without Flags now writes no EPF3 where it wrote an all-zero one.
Fallout 4 and Starfield already test both cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@WhiskyTangoFawks

Copy link
Copy Markdown
Contributor Author

Done: Skyrim's Flags is now nullable, so any effect keeps its EPF3, and an activate choice without one no longer gains an all-zero EPF3 on write. PerkFunctionParametersTests covers an ability and an activate choice with and without it for Skyrim.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants