Merge branch 'feat-form-attack-stamina': Form attacks cost stamina

This commit is contained in:
kanym 2026-10-29 13:22:45 +01:00
commit 62ebc13116
5 changed files with 114 additions and 11 deletions

View file

@ -56,6 +56,10 @@ namespace RacesOfValheim
public static ConfigEntry<float> TrueFormTrollDamageShare;
public static ConfigEntry<float> TrueFormAttackReach;
public static ConfigEntry<bool> TrueFormSlamCrater;
public static ConfigEntry<float> TrueFormPunchStamina;
public static ConfigEntry<float> TrueFormSlamStamina;
public static ConfigEntry<float> TrueFormLogSwingStamina;
public static ConfigEntry<float> TrueFormLogOverheadStamina;
// ─── Log Weapon (tier 7+) ──────────────────────────────────────────────
public static ConfigEntry<float> LogWeaponMaxDurability;
@ -149,6 +153,19 @@ namespace RacesOfValheim
TrueFormSlamCrater = config.Bind(trueForm, "Ground Slam Crater", true,
new ConfigDescription("The ground slam digs into the ground where it lands, like a pickaxe blow. Never inside a ward you have no access to."));
// Priced by the troll's own damage (punch and side log swing 60 blunt, slam and overhead
// log 70), with the slam dearer because it hits all around: vanilla charges a sledge about
// twice a mace for similar damage. An iron mace swing costs 10, an iron sledge 20.
const string staminaNote = " Base stamina, cut by up to a third with the Clubs skill as a club's is. 0 makes it free.";
TrueFormPunchStamina = config.Bind(trueForm, "Punch Stamina", 10f,
new ConfigDescription("Stamina for the punch (Left Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 60f)));
TrueFormSlamStamina = config.Bind(trueForm, "Ground Slam Stamina", 18f,
new ConfigDescription("Stamina for the ground slam (Middle Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 60f)));
TrueFormLogSwingStamina = config.Bind(trueForm, "Log Swing Stamina", 10f,
new ConfigDescription("Stamina for the side swing with a log in hand (Left Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 60f)));
TrueFormLogOverheadStamina = config.Bind(trueForm, "Log Overhead Stamina", 12f,
new ConfigDescription("Stamina for the overhead swing with a log in hand (Middle Mouse)." + staminaNote, new AcceptableValueRange<float>(0f, 60f)));
const string logWeapon = "Trol - Log Weapon";
LogWeaponMaxDurability = config.Bind(logWeapon, "Max Durability", 6f,
new ConfigDescription("Hits a grabbed log weapon survives before breaking, tier 7+.", new AcceptableValueRange<float>(1f, 50f)));

View file

@ -143,6 +143,20 @@ namespace RacesOfValheim
}
}
/// <summary>What a swing costs, by the button pressed. Until these existed every troll
/// blow was free.</summary>
private static float StaminaFor(TrolTrueFormModel.AttackKind kind)
{
switch (kind)
{
case TrolTrueFormModel.AttackKind.Punch: return TrolConfig.TrueFormPunchStamina.Value;
case TrolTrueFormModel.AttackKind.Slam: return TrolConfig.TrueFormSlamStamina.Value;
case TrolTrueFormModel.AttackKind.LogSwingH: return TrolConfig.TrueFormLogSwingStamina.Value;
case TrolTrueFormModel.AttackKind.LogSwingV: return TrolConfig.TrueFormLogOverheadStamina.Value;
default: return 0f;
}
}
private void Play(TrolTrueFormModel.AttackKind kind)
{
TrolTrueFormModel.Profile profile = TrolTrueFormModel.Get(kind);
@ -150,6 +164,7 @@ namespace RacesOfValheim
if (profile == null && kind == TrolTrueFormModel.AttackKind.LogSwingH) profile = TrolTrueFormModel.Get(TrolTrueFormModel.AttackKind.Punch);
if (profile == null && kind == TrolTrueFormModel.AttackKind.LogSwingV) profile = TrolTrueFormModel.Get(TrolTrueFormModel.AttackKind.Slam);
if (profile == null) return;
if (!FormMelee.TrySpendStamina(Player.m_localPlayer, StaminaFor(kind), Skills.SkillType.Clubs)) return;
bool log = kind == TrolTrueFormModel.AttackKind.LogSwingH || kind == TrolTrueFormModel.AttackKind.LogSwingV;
// The slam goes by what the key means, not by the troll's attack type: troll_groundslam