Rename covers the folder, all seven filenames and every identifier, status effect name and display string. Valheim's own Dverger/dvergr prefab references are untouched - the names never collided. The race id is what sits in m_customData and the ZDO, so renaming it alone would have handed every existing character the selection menu again. DvergarRace migrates the old id on spawn, before anything else reads it. Runic Spark is modelled on Skadi's Ice Affinity and deliberately shares its shape: live from the base tier and growing a flat step per progression state, so +2 at Base through +16 after Fader. Lightning rather than frost, and like Skadi's it rides every blow rather than melee only. AddFlat gained the elemental channels while it was there - lightning would otherwise have landed in generic damage. The Trol remote-sync trace fired on a two-second timer for as long as a remote player existed, which in the main menu is forever: Player.m_localPlayer is null there, so the character preview counts as remote and it never stopped. Keyed on the state it reports instead, so it still catches a remote player being sized wrongly without narrating an idle menu.
86 lines
3.9 KiB
C#
86 lines
3.9 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
/// <summary>
|
|
/// Turns a boss progression state into the set of Dvergar perks active at that tier, the same
|
|
/// way SkeletonProgression and SkadiProgression do for their races.
|
|
///
|
|
/// Nothing is decided here - every figure comes out of DvergarConfig - so the tuning pass can
|
|
/// happen without touching a single patch.
|
|
/// </summary>
|
|
public static class DvergarProgression
|
|
{
|
|
public struct DvergarRules
|
|
{
|
|
/// <summary>Points subtracted from max health at this tier.</summary>
|
|
public float HealthMalus;
|
|
|
|
/// <summary>Lightning added to every blow at this tier. Live from the base tier.</summary>
|
|
public float ElementalDamage;
|
|
|
|
/// <summary>Weapon skills the Dvergar is at home with, already filtered by tier.</summary>
|
|
public List<DvergarConfig.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 DvergarRules[] cache = new DvergarRules[BossProgressionManager.MaxState + 1];
|
|
private static readonly bool[] cached = new bool[BossProgressionManager.MaxState + 1];
|
|
|
|
public static DvergarRules GetRules(int state)
|
|
{
|
|
state = Mathf.Clamp(state, BossProgressionManager.MinState, BossProgressionManager.MaxState);
|
|
if (cached[state]) return cache[state];
|
|
|
|
List<DvergarConfig.WeaponAffinity> affinities = new List<DvergarConfig.WeaponAffinity>();
|
|
foreach (DvergarConfig.WeaponAffinity affinity in DvergarConfig.WeaponAffinities)
|
|
{
|
|
if (state >= affinity.UnlockState) affinities.Add(affinity);
|
|
}
|
|
|
|
DvergarRules rules = new DvergarRules
|
|
{
|
|
HealthMalus = DvergarConfig.Lookup(DvergarConfig.HealthMalusByState, state),
|
|
ElementalDamage = DvergarConfig.ElementalDamagePerState * state,
|
|
Affinities = affinities,
|
|
MiningAffinity = state >= DvergarConfig.MiningAffinityState,
|
|
SmithingDiscount = DvergarConfig.Lookup(DvergarConfig.SmithingDiscountByState, state),
|
|
TraderBuyDiscount = DvergarConfig.Lookup(DvergarConfig.TraderBuyDiscountByState, state),
|
|
TraderSellBonus = DvergarConfig.Lookup(DvergarConfig.TraderSellBonusByState, state),
|
|
RunicPing = state >= DvergarConfig.RunicPingState,
|
|
RunicOvercharge = state >= DvergarConfig.RunicOverchargeState
|
|
};
|
|
|
|
cache[state] = rules;
|
|
cached[state] = true;
|
|
return rules;
|
|
}
|
|
|
|
/// <summary>Rules for whatever tier the local player is currently on.</summary>
|
|
public static DvergarRules Current => GetRules(BossProgressionManager.GetCurrentProgressionState());
|
|
|
|
/// <summary>
|
|
/// The affinity covering a weapon skill at the current tier, or null when the Dvergar 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 DvergarConfig.WeaponAffinity? GetAffinity(Skills.SkillType skill, int state)
|
|
{
|
|
DvergarRules rules = GetRules(state);
|
|
foreach (DvergarConfig.WeaponAffinity affinity in rules.Affinities)
|
|
{
|
|
if (affinity.Skill == skill) return affinity;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
}
|