Skip to content

Fix rested carry weight shard losing comfort bonus - #34

Merged
MidnightsFX merged 6 commits into
MidnightsFX:mainfrom
ElKameleon:fix-rested-carry-weight
Oct 2, 2026
Merged

MidnightsFX merged 6 commits into
MidnightsFX:mainfrom
ElKameleon:fix-rested-carry-weight

Conversation

@ElKameleon

Copy link
Copy Markdown

Summary

GainMaxCarryWeightFromRested currently calls Player.GetComfortLevel() when carry weight is calculated.

Because that value represents the player's current environmental comfort, the shard bonus decreases or disappears after leaving the comfort area even though the Rested status effect is still active.

This change stores the comfort level associated with the current Rested effect and uses that value for the carry weight bonus instead.

Behavior

  • Captures the player's comfort level when Rested is created/refreshed.
  • A higher-comfort refresh increases the stored value.
  • A lower-comfort refresh does not reduce the existing Rested comfort value.
  • Leaving the comfort area no longer changes the shard bonus.
  • The stored value is cleared when Rested ends.
  • Shard equipment changes still affect the bonus immediately through the existing magic effect lookup.

Testing

Tested against Valheim 1.0.16 and Epic Loot 0.14.13.

Verified:

  • Resting at Comfort 3 with +5 carry weight per Rested level gives +15 carry weight.
  • The +15 persists after leaving the comfort area.
  • Refreshing Rested at a higher comfort level increases the bonus.
  • Refreshing at a lower comfort level does not reduce it.
  • Removing/re-equipping the shard updates the bonus normally.
  • Expiring/removing Rested removes the bonus.
  • No relevant errors or Harmony failures appeared in the BepInEx log.

@tvongaza

tvongaza commented Oct 1, 2026

Copy link
Copy Markdown

For visibility before this merges: a follow-up test found that the stored Rested comfort can survive a character change, because SEMan.OnDestroy does not call Stop on the old effect. This follow-up PR ties the comfort to its status-effect instance. In a Valheim 1.0.16 native A/B, this branch gave the new comfort-2 Player 340 carry instead of 310; the follow-up gave 310. The runner and results are available for review.

tvongaza and others added 2 commits September 30, 2026 23:51
Merge follow up changes that scope cached comfort to the active SE_Rested instance and clear it on both Stop and OnDestroy.

This prevents Rested comfort from leaking across character changes while preserving the intended carry weight behavior.
@ElKameleon

Copy link
Copy Markdown
Author

Follow-up testing found a character switch lifecycle edge case where the cached Rested comfort could carry over to a new SE_Rested instance. I’ve merged the follow-up fix, which scopes the cached comfort to the active Rested effect and clears it on both Stop and OnDestroy.
The intended behavior is unchanged: the carry-weight bonus still follows the comfort stored with the Rested buff instead of the player’s current nearby comfort.

@MidnightsFX
MidnightsFX merged commit dc85ab2 into MidnightsFX:main Oct 2, 2026
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.

3 participants