
VikingLib
Modular combat mechanics, canonical status effects, and damage calculation framework for Valheim.VikingLib
VikingLib is a modular combat mechanics, character statistic, and damage calculation framework for Valheim. It decouples Valheim's combat, poise, status effect, and stat systems from monolithic vanilla methods, providing a deterministic foundation for combat overhauls, RPG progression, weapon packs, and perk mods.

⚠️ Pre-Release (v0.3.0): This framework is in active development. Features, internal APIs, and balance defaults may evolve between minor releases. Back up your character and world saves before testing.
Core Features
VikingLib intercepts and standardizes combat math, poise, status effects, and resource drains through deterministic, server-authoritative pipelines:
- 6-Phase Prioritized Damage Pipeline: Every melee hit, projectile, and environmental impact executes sequentially across 6 phases (
PreCheck,AttackerModifiers,TargetDefenses,Mitigation,Execution,PostHitProcs), supporting multi-target cleave decay (Geometric,Continuous, orVanilla), armor penetration, lethal-hit interception, and damage reflection. - Dual-Space 3-Tier Mathematical Engine: Evaluates character stats across 160+ declarative tokens using strict modifier precedence — Tier 1 (Flat), Tier 2 (Additive %), and Tier 3 (Compounding Multipliers):
Final = (Base + Σ Flat) × max(0, 1 + Σ Increased%) × ∏ Multipliers - Asymptotic Action Efficiency: Stamina, Eitr, health, and durability costs scale smoothly in the denominator (
Effective Cost = Base / ((1 + Σ Efficiency%) × ∏ Multipliers)), ensuring stacked buffs never reduce action costs to zero or flip negative. - Dynamic Poise Scaling & Physical Damage Triad:
- Creature poise thresholds scale dynamically via a square-root health formula (
Poise = k × √MaxHealth × Offset) with configurable coefficient, global multiplier, and sparse per-creature offsets. - Blunt builds stagger/poise, Slash inflicts post-mitigation Bleed slices (supporting
SeverityGatedRefreshandIndependentmodels with dual absolute and max-HP DPS caps), Pierce gains a melee precision multiplier, and Shields retaliate with poise damage on blocks and timed parries. - Displays live amber poise bars and active status effect chips beneath enemy and boss health bars.
- Creature poise thresholds scale dynamically via a square-root health formula (
- Armor Mitigation & Elemental Armor Absorption: Supports both asymptotic
LinearEHP(Damage = Incoming / (1 + Armor / K + Eff)) andVanillaPiecewisearmor formulas, alongside a configurableElementalArmorAbsorptionRatio(0.0–1.0) governing how much physical body armor absorbs elemental and magic damage (Fire, Frost, Lightning, Poison, Spirit). - Status Effects & Logout Persistence: Provides a builder API for stacked, multi-slice, charged, and barrier-capable status effects. Automatically persists active temporary buffs (Forsaken powers, meads, potions, and custom VikingLib effects) across logout and reconnection via
Player.m_customData. - Combat Dossier, Hugin's Compendium & Modular Glossary Sections:
- Toggle or hold
[Shift]over weapon tooltips to inspect combo chains, chained multi-secondary attacks, decoupled bare-hand vs. fist-weapon profiles, cleave ratings, and live stamina/Eitr costs. - Adds a live Character Stats breakdown and trophy-unlocked Creature Combat Dossiers into Hugin's Compendium (
TextsDialog). - Downstream mods can register dedicated custom glossary categories (
CharacterStatsGlossaryPanel.RegisterCustomCategory) with automatic sparse pruning when empty.
- Toggle or hold
- Project Auga Bridge: Zero-dependency soft runtime integration that injects a scrollable Stats tab into Auga's Player panel, adapts VikingLib weapon tooltips, and enriches Auga's Bestiary stat cards with poise thresholds, stagger timers, cleave resistance, and body armor values.
Click to expand Combat Stat Taxonomy (160+ Declarative Tokens)
| Category | Representative Tokens | Description |
|---|---|---|
| Vitals & Recovery | MaxHealth, MaxStamina, MaxEitr, MaxCarryWeight, HealthRegen, StaminaRegen, EitrRegen, FoodDurationMultiplier |
Physical pools, regeneration rates, combat regen delays, and food scaling. |
| Delivery & Stance | DamagePhysical, DamageElemental, DamageMelee, DamageRanged, DamageMagic, DamageOneHanded, DamageTwoHanded |
Umbrella damage multipliers across combat stances and delivery methods. |
| Techniques & Triad | AttackSpeed, CriticalStrikeChance, CriticalStrikeMultiplier, DamageSecondaryAttack, DamageComboFinisher, DamageSneak, CleaveEfficiency, StaggerDamage, SlashBleedPercent, ParryPoiseMultiplier, BowDrawSpeed, CrossbowReloadSpeed |
Modifiers altering attack tempo, multi-crits, bleed/poise mechanics, stealth, and ranged handling. |
| Situational Contexts | DamageAgainstBosses, DamageAgainstStaggered, DamageAgainstAirborne, DamageAgainstAfflicted, DamageExecute, DamageFirstStrike, DamageBerserk, DamageFlawless, DamageAtNight, DamageWhileAirborne |
Dynamic combat context modifiers evaluated in Phase 1 from live attacker/target states. |
| Weapon Families | DamageSwords ... DamageBloodMagic, AttackSpeedSwords ... AttackSpeedBloodMagic (11 families each) |
Per-weapon-family damage and swing-speed mastery multipliers (including decoupled bare-hand/unarmed support). |
| Action Efficiencies | MeleeStaminaEfficiency, RangedStaminaEfficiency, BlockStaminaEfficiency, ToolStaminaEfficiency, AttackEitrEfficiency, DurabilityEfficiency, SprintEfficiency, DodgeEfficiency |
Asymptotic denominator efficiency ratings scaling stamina, Eitr, blood-magic health, and durability costs. |
| Defense & Resistances | BodyArmor, ArmorEfficiency, BluntArmorEfficiency, SlashArmorEfficiency, PierceArmorEfficiency, StaggerResistance, ResistancePhysical, ResistanceElemental, ResistanceSlashing ... ResistanceBleed, ResistanceFall |
Armor efficiency ratings, poise thresholds, and multiplicative damage-taken factors (Taken = Base × ∏ Multipliers, Tier 3 only). |
| On-Hit Resource Recovery | HealthOnKill, StaminaOnKill, EitrOnKill, HealthOnDamageTaken, StaminaOnCauseStagger (3×3 trigger matrix) |
Flat resource restoration triggered on kill, stagger break, or damage taken. |
| Yields, Mounts & Vehicles | MiningYield, WoodcuttingYield, MonsterDropYield, CraftingYield, CookingYield, ForagingYield, HarvestRadius, RidingSpeed, ShipSailSpeed, CartWeightEfficiency |
Multi-drop roll budgets, agricultural reach, mount handling, sailing speed, and cart cargo efficiency. |
Click to expand Developer Console Commands & Diagnostics
VikingLib includes developer commands accessible in the Valheim console (F5):
| Command | Usage | Description |
|---|---|---|
vl_buff |
vl_buff [on | off | clear | laststand] |
Toggles synthetic test buffs across all taxonomy categories (or toggles a Last Stand test handler) on the local player. |
vl_trace |
vl_trace |
Prints a formatted diagnostic breakdown of the most recent combat hit (damage rolls, modifiers, armor, and resistances). |
vl_log |
vl_log [off | player | all] |
Configures live combat telemetry logging to the BepInEx console. |
vl_armor |
vl_armor [linear | piecewise | k <value>] |
Views or switches the active armor mitigation model and LinearEHP scaling constant K. |
vl_se |
vl_se [apply <name> [stacks] [duration] | list | clear [name] | info <name>] |
Inspects, applies, or clears registered VikingLib status effects on the local player. |
vl_dump_attacks |
vl_dump_attacks |
Exports all weapon attack configurations from ObjectDB to VanillaWeaponAttacks.json. |
Click to expand Downstream Mod Integration Guide
Reference VikingLib.dll in your project and declare a hard dependency on com.digitalvikings.vikinglib:
using BepInEx;
using VikingLib.Stats;
using VikingLib.UI;
[BepInPlugin("com.author.mymod", "MyCombatMod", "1.0.0")]
[BepInDependency("com.digitalvikings.vikinglib", BepInDependency.DependencyFlags.HardDependency)]
public class MyModPlugin : BaseUnityPlugin
{
private void Awake()
{
// Declarative character stat modifier (+20% sword damage, Tier 2 Additive)
CharacterStats.DamageSwords.AddIncreased(Player.m_localPlayer, 0.20f, "Swordmaster");
// Type-safe continuous resistance (Tier 3 Multiplier only: -20% fire damage taken)
CharacterStats.ResistanceFire.AddMultiplier(Player.m_localPlayer, 0.80f, "Fire Ward");
// Asymptotic action efficiency (+25% melee stamina efficiency)
CharacterStats.MeleeStaminaEfficiency.AddIncreased(Player.m_localPlayer, 0.25f, "Iron Stamina");
// Register a modular custom glossary section in Hugin's Compendium (auto-pruned when empty)
CharacterStatsGlossaryPanel.RegisterCustomCategory("My Mod Perks", player => new[]
{
("Active Stance", "Swordmaster (+20%)")
}, priority: 50);
}
}
Developed by DigitalVikings.