feat(dvergur): add the Dvergur race scaffold
An eighth race built on the existing per-race pattern: a MonoBehaviour driver registered from Awake, a progression table keyed on the boss state, an SE_Stats carrier, and Harmony patches for the individual perks. The helmet slot stays free. Whatever the player equips keeps every one of its stats and only its mesh is swapped for the dvergr hood, which is the Skeleton's helmet handling turned into a replacement rather than a plain hide. Every percentage the spec left open lives in DvergurConfig as a named value and is marked TODO there, so tuning the race never means touching the logic. The knobs are static readonly rather than const so that switching a perk off with a zero does not fold its guard into dead code.
This commit is contained in:
parent
4cd452d187
commit
3ec51aeb45
10 changed files with 1365 additions and 1 deletions
82
JotunnModStub/Dvergur/DvergurProgression.cs
Normal file
82
JotunnModStub/Dvergur/DvergurProgression.cs
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// Turns a boss progression state into the set of Dvergur perks active at that tier, the same
|
||||
/// way SkeletonProgression and SkadiProgression do for their races.
|
||||
///
|
||||
/// Nothing is decided here - every figure comes out of DvergurConfig - so the tuning pass can
|
||||
/// happen without touching a single patch.
|
||||
/// </summary>
|
||||
public static class DvergurProgression
|
||||
{
|
||||
public struct DvergurRules
|
||||
{
|
||||
/// <summary>Points subtracted from max health at this tier.</summary>
|
||||
public float HealthMalus;
|
||||
|
||||
/// <summary>Weapon skills the Dvergur is at home with, already filtered by tier.</summary>
|
||||
public List<DvergurConfig.WeaponAffinity> Affinities;
|
||||
|
||||
public bool MiningAffinity;
|
||||
public float SmithingDiscount;
|
||||
public float TraderBuyDiscount;
|
||||
public float TraderSellBonus;
|
||||
public bool RunicPing;
|
||||
public bool RunicOvercharge;
|
||||
}
|
||||
|
||||
// GetRules runs from Update loops and from damage patches, so the per-state result is
|
||||
// built once and handed back on every later call.
|
||||
private static readonly DvergurRules[] cache = new DvergurRules[BossProgressionManager.MaxState + 1];
|
||||
private static readonly bool[] cached = new bool[BossProgressionManager.MaxState + 1];
|
||||
|
||||
public static DvergurRules GetRules(int state)
|
||||
{
|
||||
state = Mathf.Clamp(state, BossProgressionManager.MinState, BossProgressionManager.MaxState);
|
||||
if (cached[state]) return cache[state];
|
||||
|
||||
List<DvergurConfig.WeaponAffinity> affinities = new List<DvergurConfig.WeaponAffinity>();
|
||||
foreach (DvergurConfig.WeaponAffinity affinity in DvergurConfig.WeaponAffinities)
|
||||
{
|
||||
if (state >= affinity.UnlockState) affinities.Add(affinity);
|
||||
}
|
||||
|
||||
DvergurRules rules = new DvergurRules
|
||||
{
|
||||
HealthMalus = DvergurConfig.Lookup(DvergurConfig.HealthMalusByState, state),
|
||||
Affinities = affinities,
|
||||
MiningAffinity = state >= DvergurConfig.MiningAffinityState,
|
||||
SmithingDiscount = DvergurConfig.Lookup(DvergurConfig.SmithingDiscountByState, state),
|
||||
TraderBuyDiscount = DvergurConfig.Lookup(DvergurConfig.TraderBuyDiscountByState, state),
|
||||
TraderSellBonus = DvergurConfig.Lookup(DvergurConfig.TraderSellBonusByState, state),
|
||||
RunicPing = state >= DvergurConfig.RunicPingState,
|
||||
RunicOvercharge = state >= DvergurConfig.RunicOverchargeState
|
||||
};
|
||||
|
||||
cache[state] = rules;
|
||||
cached[state] = true;
|
||||
return rules;
|
||||
}
|
||||
|
||||
/// <summary>Rules for whatever tier the local player is currently on.</summary>
|
||||
public static DvergurRules Current => GetRules(BossProgressionManager.GetCurrentProgressionState());
|
||||
|
||||
/// <summary>
|
||||
/// The affinity covering a weapon skill at the current tier, or null when the Dvergur has
|
||||
/// no particular feel for it. Mining counts as an affinity for stamina purposes only, so
|
||||
/// it is deliberately not part of this list.
|
||||
/// </summary>
|
||||
public static DvergurConfig.WeaponAffinity? GetAffinity(Skills.SkillType skill, int state)
|
||||
{
|
||||
DvergurRules rules = GetRules(state);
|
||||
foreach (DvergurConfig.WeaponAffinity affinity in rules.Affinities)
|
||||
{
|
||||
if (affinity.Skill == skill) return affinity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue