fix(trenta): stamina trickles back while a Bonemass Trenta swims
Vanilla Player.UpdateStats stops stamina regen while swimming off the ground, and drowning starts at 0 stamina. The Bonemass unlock only waived the stroke cost, so a Trenta who went into the water empty never got a point back and drowned in water it swims for free. A postfix on UpdateStats adds the regen vanilla held back, with the same formula, times the new Trenta - Bonemass / Swim Stamina Regen (0.1, slow on purpose). The compendium line says so in all three languages.
This commit is contained in:
parent
373b0069dd
commit
fdc0fdcedc
5 changed files with 48 additions and 3 deletions
|
|
@ -46,6 +46,9 @@ namespace RacesOfValheim
|
|||
public static ConfigEntry<float> PurpleRainHealAmount;
|
||||
public static ConfigEntry<float> PurpleRainPoisonDamage;
|
||||
|
||||
// ─── Bonemass (tier 4+, passive) ──────────────────────────────────────
|
||||
public static ConfigEntry<float> SwimStaminaRegen;
|
||||
|
||||
// ─── Last Stand & Thorns (tier 5+) ────────────────────────────────────
|
||||
public static ConfigEntry<float> LastStandMaxArmorBonus;
|
||||
public static ConfigEntry<float> ThornsReflectPercent;
|
||||
|
|
@ -114,6 +117,10 @@ namespace RacesOfValheim
|
|||
PurpleRainPoisonDamage = config.Bind(purpleRain, "Enemy Poison Damage", 40f,
|
||||
new ConfigDescription("Flat poison damage applied to every enemy hit.", new AcceptableValueRange<float>(0f, 200f)));
|
||||
|
||||
const string bonemass = "Trenta - Bonemass";
|
||||
SwimStaminaRegen = config.Bind(bonemass, "Swim Stamina Regen", 0.1f,
|
||||
new ConfigDescription("Share of the normal stamina regen kept while swimming, from Bonemass on. The game stops regen in water entirely, so an empty Trenta used to drown even though swimming is free. 0 is the game's behaviour.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
|
||||
const string lastStand = "Trenta - Last Stand & Thorns";
|
||||
LastStandMaxArmorBonus = config.Bind(lastStand, "Last Stand Max Armor Bonus", 0.5f,
|
||||
new ConfigDescription("Armor multiplier bonus at near-zero health, tier 5+ (0.5 = +50%). Scales down to 0 at full health.", new AcceptableValueRange<float>(0f, 3f)));
|
||||
|
|
|
|||
|
|
@ -125,6 +125,44 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A trickle of stamina regen while swimming, for a Bonemass-tier Trenta. Vanilla's
|
||||
/// Player.UpdateStats stops regen outright while swimming off the ground, and drowning starts
|
||||
/// at 0 stamina, so the free stroke above was not enough: a Trenta who went in empty never
|
||||
/// got a point back and drowned in water it swims for free. The same formula vanilla uses on
|
||||
/// land, times Swim Stamina Regen (slow on purpose).
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "UpdateStats", new[] { typeof(float) })]
|
||||
public static class Trenta_Player_SwimStaminaRegen_Patch
|
||||
{
|
||||
private static readonly AccessTools.FieldRef<Player, float> RegenTimer =
|
||||
AccessTools.FieldRefAccess<Player, float>("m_staminaRegenTimer");
|
||||
|
||||
public static void Postfix(Player __instance, float dt)
|
||||
{
|
||||
if (__instance != Player.m_localPlayer || !TrentaRace.IsTrenta()) return;
|
||||
if (BossProgressionManager.GetCurrentProgressionState() < TrentaConfig.BonemassDefeatedState) return;
|
||||
|
||||
// Only where vanilla held regen at zero for the water alone.
|
||||
if (!__instance.IsSwimming() || __instance.IsOnGround()) return;
|
||||
if (__instance.InAttack() || __instance.InDodge() || __instance.IsEncumbered()) return;
|
||||
|
||||
float share = TrentaConfigManagement.SwimStaminaRegen.Value;
|
||||
if (share <= 0f || RegenTimer(__instance) > 0f) return;
|
||||
|
||||
float max = __instance.GetMaxStamina();
|
||||
float stamina = __instance.GetStamina();
|
||||
if (max <= 0f || stamina >= max) return;
|
||||
|
||||
float regen = __instance.m_staminaRegen +
|
||||
(1f - stamina / max) * __instance.m_staminaRegen * __instance.m_staminaRegenTimeMultiplier;
|
||||
float multiplier = 1f;
|
||||
__instance.GetSEMan().ModifyStaminaRegen(ref multiplier);
|
||||
|
||||
__instance.AddStamina(regen * multiplier * share * dt * Game.m_staminaRegenRate);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Blocks the Wet status effect from ever landing on a Bonemass-tier Trenta.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue