Skip to content

[EpicLoot] GainMaxCarryWeightFromRested uses current environmental comfort instead of Rested comfort #756

Description

@ElKameleon

Epic Loot version

0.14.13

Description

The GainMaxCarryWeightFromRested shard effect appears to use the player's current environmental comfort level instead of the comfort level that generated their active Rested buff.

Because of this, the carry-weight bonus works while the player is standing inside a comfort area, then disappears after leaving the area even though the Rested status effect is still active.

This looks like it may simply be a wrong accessor / small oversight in the implementation.

Steps to reproduce

  1. Equip an item containing GainMaxCarryWeightFromRested.
  2. Get Rested inside a comfort area.
  3. Observe the increased maximum carry weight.
  4. Leave the comfort area while the Rested buff is still active.
  5. The carry-weight bonus disappears once the player's current environmental comfort drops.

Controlled test

I reproduced this with a fresh character to eliminate other carry-weight modifiers.

Test setup:

  • Base carry weight: 300
  • Comfort level: 3
  • Shard effect: +5 Carry Weight per Rested Level

Expected:

300 + (3 × 5) = 315

The intended behavior would therefore be:

At Comfort 3 while Rested:          315
Outside the comfort area, Rested:   315
After Rested expires:               300

Suspected cause

In:

EpicLoot/src/Magic/MagicItemEffects/Shards/GainMaxCarryWeightFromRested.cs

the code first correctly checks whether the player has the Rested status:

if (!seman.HaveStatusEffect(SEMan.s_statusEffectRested))
{
    return;
}

It then obtains the comfort level using:

var comfortLevel = player.GetComfortLevel();

Player.GetComfortLevel() represents the player's current environmental comfort. That value changes as the player moves away from comfort sources.

As a result, the effect effectively behaves like:

while Rested:
    carry bonus = current nearby comfort × shard bonus

rather than:

while Rested:
    carry bonus = comfort that generated Rested × shard bonus

Possible fix

The active SE_Rested already contains the TTL that was calculated from the comfort level when Rested was applied/refreshed.

The original Rested comfort can therefore be reconstructed from the active status effect:

var rested = seman.GetStatusEffect(SEMan.s_statusEffectRested) as SE_Rested;

if (rested == null)
{
    return;
}

var comfortLevel = 1 + UnityEngine.Mathf.RoundToInt(
    (rested.m_ttl - rested.m_baseTTL) /
    rested.m_TTLPerComfortLevel);

if (comfortLevel <= 0)
{
    return;
}

limit += perComfort * comfortLevel;

So the relevant change would be roughly:

- if (!seman.HaveStatusEffect(SEMan.s_statusEffectRested))
- {
-     return;
- }
-
- var comfortLevel = player.GetComfortLevel();
+ var rested = seman.GetStatusEffect(SEMan.s_statusEffectRested) as SE_Rested;
+
+ if (rested == null)
+ {
+     return;
+ }
+
+ var comfortLevel = 1 + UnityEngine.Mathf.RoundToInt(
+     (rested.m_ttl - rested.m_baseTTL) /
+     rested.m_TTLPerComfortLevel);

Testing the proposed behavior

I tested the equivalent calculation against Epic Loot 0.14.13.

With:

Base carry:       300
Comfort:          3
Shard bonus:      +5 per Rested level

the result was:

Inside the comfort area:            315
Outside the comfort area:           315
Rested still active outside:        315

This matches the shard description and preserves the bonus based on the comfort level that generated the current Rested buff.

The final remaining behavior is that the bonus disappears when Rested expires, returning the character to the normal carry limit.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions