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

@ -363,9 +363,37 @@ namespace RacesOfValheim
ItemDrop unarmed = player.m_unarmedWeapon;
float perHit = unarmed != null ? unarmed.m_itemData.m_shared.m_attack.m_attackAdrenaline : 1f;
// The Fenrir forms trade cheaper swings for a faster bar; the other races' forms do not.
if (FenrirForms.LocalInForm(player)) perHit *= FenrirConfig.FormAdrenalineMultiplier.Value;
player.AddAdrenaline(perHit * character.m_enemyAdrenalineMultiplier * scale);
}
/// <summary>
/// Charges a form attack's stamina the way vanilla charges a weapon's (Attack.GetAttackStamina):
/// the equipment modifier, status effects (meads, race passives), then up to a third off with
/// the attack's skill. Without enough, the attack does not start and the stamina bar flashes,
/// as it does for a weapon. A cost of 0 is free and always goes through.
/// </summary>
/// <returns>True if the attack may start; the stamina is already spent.</returns>
public static bool TrySpendStamina(Player player, float baseCost, Skills.SkillType skill)
{
if (player == null || baseCost <= 0f) return true;
float cost = baseCost * (1f + player.GetEquipmentAttackStaminaModifier());
player.GetSEMan().ModifyAttackStaminaUsage(cost, ref cost);
cost -= cost * 0.33f * player.GetSkillFactor(skill);
if (cost <= 0f) return true;
if (!player.HaveStamina(cost + 0.1f))
{
if (player == Player.m_localPlayer && Hud.instance != null) Hud.instance.StaminaBarEmptyFlash();
return false;
}
player.UseStamina(cost);
return true;
}
public static void LogHit(string form, IDestructible target, float damage)
{
if (!FenrirConfig.DebugFormHits.Value) return;