Skip to content

Try to return creature's raw XP value if level is not available for PF2E difficulty calc - #334

Open
rocketgarden wants to merge 1 commit into
Obsidian-TTRPG-Community:mainfrom
rocketgarden:patch-1
Open

Try to return creature's raw XP value if level is not available for PF2E difficulty calc#334
rocketgarden wants to merge 1 commit into
Obsidian-TTRPG-Community:mainfrom
rocketgarden:patch-1

Conversation

@rocketgarden

Copy link
Copy Markdown

Pull Request Description

Using pf2e difficulty calculations doesn't work when using inline creatures that specify their XP value. There is no (documented) way to specify level in the inline encounter builder. Since the difficulty logic attempts to use the lvl field to re-derive the xp, an xp/difficulty of "0" is reported for inline-defined creatures.

This change adds an intermediate fallback of returning creature.xp if the lvl is unavailable, but still falls back to 0 if xp is also undefined/null.

Tradeoff/Downside: These hard-coded XP values don't update against average party level. So e.g. if a user inputs inline XP values based on a party level of 3 and the party levels up to 4, the encounter difficulty & xp budget will be incorrect. This is arguably bad but no worse than the current behavior, which is incorrect or no difficulty ratings ever. The ideal fix for this would be allowing the user to specify a level/cr instead/in-addition to xp, but that's a bigger scope.

Changes Proposed

  • Change the lvl == null case to return creature.xp before returning 0
  • Thus allowing users to hardcode/override XP values for inline pf2e encounter creatures

Checklist

  • I have read the contribution guidelines and code of conduct.
  • I have tested the changes locally and they are working as expected.
  • I have added appropriate comments and documentation for the code changes.
  • My code follows the coding style and standards of this project.
  • I have rebased my branch on the latest main (or master) branch.
  • All tests (if applicable) have passed successfully.
  • I have run linters and fixed any issues.
  • I have checked for any potential security issues or vulnerabilities.

Additional Notes

I am not familiar or invested enough in Obsidian plugin development (yet?) to be able to build and test my change locally. This just seemed like it might be more useful and expeditious than submitting an Issue.

…F2E difficulty calc

Using pf2e difficulty calculations doesn't work when using inline creatures that specify their XP value. There is no (documented) way to specify level in the inline encounter builder. Since the difficulty logic attempts to use the lvl field to re-derive the xp, an xp/difficulty of "0" is reported for inline-defined creatures.

This change adds an intermediate fallback of returning `creature.xp` if the lvl is unavailable, but still falls back to `0` if `xp` is also undefined/null
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.

1 participant