diff --git a/.gitignore b/.gitignore index d5d2cff..f7973c2 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ Thumbs.db # Windows shortcuts hold an absolute path to the machine that made them, so they # resolve for nobody else who clones this repo. *.lnk + +# How to setup Configuration Manager +CONFIGURATION-MANAGER-HOWTO.md \ No newline at end of file diff --git a/JotunnModStub/Aswid/AswidConfig.cs b/JotunnModStub/Aswid/AswidConfig.cs new file mode 100644 index 0000000..a50f8c8 --- /dev/null +++ b/JotunnModStub/Aswid/AswidConfig.cs @@ -0,0 +1,133 @@ +using UnityEngine; +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// Every tunable number and keybind behind the Aswid's abilities, bound as BepInEx ConfigEntry + /// so they show up in Configuration Manager without touching code - see + /// CONFIGURATION-MANAGER-HOWTO.md. Bound once, from RacesOfValheim.Awake(). One section per + /// topic (matches SkadiConfig's layout) rather than one shared section, so each shows up as + /// its own entry in Configuration Manager's category list. + /// + /// Tier-gate thresholds (which progression state unlocks Mist Form, Eclipse, or which mob a + /// given tier can tame) are left as-is, same boundary drawn for Skadi's progression table - + /// these are a differently-shaped piece of config (per-tier unlock tables, not flat values). + /// + public static class AswidConfig + { + // ─── Keybinds ────────────────────────────────────────────────────────── + // Defaults match today's fixed inputs exactly, so nobody's controls change until they + // open Configuration Manager (or the .cfg) and rebind one on purpose. + public static ConfigEntry BatFormKey; + public static ConfigEntry MistFormKey; + public static ConfigEntry EclipseKey; + public static ConfigEntry TameKey; + public static ConfigEntry ToggleDevourKey; + + // ─── Passive combat (scales with progression state, doubles at night) ──── + public static ConfigEntry DamageBonusPerState; + public static ConfigEntry ArmorBonusPerState; + public static ConfigEntry SpeedBonusPerState; + public static ConfigEntry NightMultiplier; + public static ConfigEntry BloodMagicSkillGainMultiplier; + public static ConfigEntry SurtlingFormDamageBonus; + + // ─── Vampiric Aura (passive, always active) ────────────────────────────── + public static ConfigEntry AuraTickInterval; + public static ConfigEntry AuraRadiusDay; + public static ConfigEntry AuraRadiusNight; + public static ConfigEntry AuraBaseDamage; + public static ConfigEntry AuraBloodMagicScaling; + public static ConfigEntry AuraExecuteThreshold; + + // ─── Superhuman Senses (tier 5+ passive) ───────────────────────────────── + public static ConfigEntry SensesRadius; + public static ConfigEntry SensesRefreshInterval; + public static ConfigEntry SensesLightRange; + public static ConfigEntry SensesLightIntensity; + + // ─── Eclipse (tier 6+ ability) ──────────────────────────────────────── + public static ConfigEntry EclipseCooldown; + public static ConfigEntry EclipseCastTime; + public static ConfigEntry EclipseDuration; + + // ─── Devour ──────────────────────────────────────────────────────────── + public static ConfigEntry DevourCooldown; + + // ─── Domination (tier 6+ ability, native Interact key) ─────────────────── + public static ConfigEntry EnslaveCooldown; + public static ConfigEntry ThrallLifetime; + + public static void Bind(ConfigFile config) + { + const string keybinds = "Aswid - Keybinds"; + BatFormKey = config.Bind(keybinds, "Bat Form", new KeyboardShortcut(KeyCode.G), + new ConfigDescription("Transform into (or revert from) a Bat, tier 2+ (night only) / tier 3+ (any time).")); + MistFormKey = config.Bind(keybinds, "Mist Form Toggle", new KeyboardShortcut(KeyCode.H), + new ConfigDescription("Become (or revert from) mist, tier 7+.")); + EclipseKey = config.Bind(keybinds, "Cast Eclipse", new KeyboardShortcut(KeyCode.J), + new ConfigDescription("Casts Eclipse, tier 6+. Fails silently at night.")); + TameKey = config.Bind(keybinds, "Tame", new KeyboardShortcut(KeyCode.U), + new ConfigDescription("Tames the creature under your cursor, if your tier allows it.")); + ToggleDevourKey = config.Bind(keybinds, "Toggle Devour Ability", new KeyboardShortcut(KeyCode.I), + new ConfigDescription("Turns the automatic Devour-on-kill behavior on or off.")); + + const string combat = "Aswid - Passive Combat"; + DamageBonusPerState = config.Bind(combat, "Damage Bonus Per State", 2f, + new ConfigDescription("Flat physical damage added to equipped weapons, per progression state.", new AcceptableValueRange(0f, 10f))); + ArmorBonusPerState = config.Bind(combat, "Armor Bonus Per State", 1f, + new ConfigDescription("Flat armor added, per progression state.", new AcceptableValueRange(0f, 10f))); + SpeedBonusPerState = config.Bind(combat, "Speed Bonus Per State", 0.01f, + new ConfigDescription("Move/jump speed multiplier added, per progression state (0.01 = 1%).", new AcceptableValueRange(0f, 0.1f))); + NightMultiplier = config.Bind(combat, "Night Multiplier", 2f, + new ConfigDescription("Multiplies the speed, armor, damage, and lifesteal bonuses above while it is night.", new AcceptableValueRange(1f, 5f))); + BloodMagicSkillGainMultiplier = config.Bind(combat, "Blood Magic Skill Gain Multiplier", 2f, + new ConfigDescription("Multiplies how fast the Blood Magic skill levels up.", new AcceptableValueRange(0.5f, 5f))); + SurtlingFormDamageBonus = config.Bind(combat, "Surtling Form Damage Bonus", 30f, + new ConfigDescription("Flat damage added to every attack once the tier 8 Surtling form is unlocked.", new AcceptableValueRange(0f, 100f))); + + const string aura = "Aswid - Vampiric Aura"; + AuraTickInterval = config.Bind(aura, "Tick Interval", 0.25f, + new ConfigDescription("Seconds between aura damage/lifesteal ticks.", new AcceptableValueRange(0.05f, 2f))); + AuraRadiusDay = config.Bind(aura, "Radius (Day)", 3f, + new ConfigDescription("Meters from the player that the aura drains during the day.", new AcceptableValueRange(1f, 20f))); + AuraRadiusNight = config.Bind(aura, "Radius (Night)", 6f, + new ConfigDescription("Meters from the player that the aura drains at night.", new AcceptableValueRange(1f, 20f))); + AuraBaseDamage = config.Bind(aura, "Base Damage", 1f, + new ConfigDescription("Damage per tick before the Blood Magic skill bonus, at human form's 0.5x multiplier.", new AcceptableValueRange(0f, 20f))); + AuraBloodMagicScaling = config.Bind(aura, "Blood Magic Damage Scaling", 5f, + new ConfigDescription("Extra damage per tick at 100 Blood Magic skill (scales linearly from 0).", new AcceptableValueRange(0f, 20f))); + AuraExecuteThreshold = config.Bind(aura, "Execute Threshold", 0.20f, + new ConfigDescription("Non-boss enemies at or below this fraction of max health are executed by the aura instead of merely damaged.", new AcceptableValueRange(0f, 1f))); + + const string senses = "Aswid - Superhuman Senses"; + SensesRadius = config.Bind(senses, "Detection Radius", 100f, + new ConfigDescription("Meters within which nearby creatures are marked, tier 5+.", new AcceptableValueRange(10f, 300f))); + SensesRefreshInterval = config.Bind(senses, "Refresh Interval", 1f, + new ConfigDescription("Seconds between detection sweeps.", new AcceptableValueRange(0.2f, 5f))); + SensesLightRange = config.Bind(senses, "Marker Light Range", 10f, + new ConfigDescription("Range of the light placed on a detected creature.", new AcceptableValueRange(1f, 30f))); + SensesLightIntensity = config.Bind(senses, "Marker Light Intensity", 2f, + new ConfigDescription("Intensity of the light placed on a detected creature.", new AcceptableValueRange(0.1f, 10f))); + + const string eclipse = "Aswid - Eclipse"; + EclipseCooldown = config.Bind(eclipse, "Cooldown", 900f, + new ConfigDescription("Seconds between casts.", new AcceptableValueRange(0f, 3600f))); + EclipseCastTime = config.Bind(eclipse, "Cast Time", 2f, + new ConfigDescription("Seconds the player is rooted while casting.", new AcceptableValueRange(0f, 10f))); + EclipseDuration = config.Bind(eclipse, "Duration", 60f, + new ConfigDescription("Seconds the forced night lasts.", new AcceptableValueRange(5f, 600f))); + + const string devour = "Aswid - Devour"; + DevourCooldown = config.Bind(devour, "Consume Cooldown", 5f, + new ConfigDescription("Minimum seconds between devouring a corpse, outside of an execute (which bypasses this).", new AcceptableValueRange(0f, 60f))); + + const string domination = "Aswid - Domination"; + EnslaveCooldown = config.Bind(domination, "Enslave Cooldown", 900f, + new ConfigDescription("Seconds between dominating a creature, tier 6+.", new AcceptableValueRange(0f, 3600f))); + ThrallLifetime = config.Bind(domination, "Thrall Lifetime", 60f, + new ConfigDescription("Seconds a dominated thrall survives before it dies on its own.", new AcceptableValueRange(10f, 600f))); + } + } +} diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index e3f2724..1381089 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -177,8 +177,8 @@ namespace RacesOfValheim if (__instance == Player.m_localPlayer && AswidRace.IsAswid()) { int state = BossProgressionManager.GetCurrentProgressionState(); - float multiplier = (EnvMan.instance != null && EnvMan.IsNight()) ? 2f : 1f; - __result += 1f * state * multiplier; + float multiplier = (EnvMan.instance != null && EnvMan.IsNight()) ? AswidConfig.NightMultiplier.Value : 1f; + __result += AswidConfig.ArmorBonusPerState.Value * state * multiplier; } } } @@ -203,8 +203,8 @@ namespace RacesOfValheim int state = BossProgressionManager.GetCurrentProgressionState(); if (state > 0) { - float multiplier = (EnvMan.instance != null && EnvMan.IsNight()) ? 2f : 1f; - float bonus = 2f * state * multiplier; + float multiplier = (EnvMan.instance != null && EnvMan.IsNight()) ? AswidConfig.NightMultiplier.Value : 1f; + float bonus = AswidConfig.DamageBonusPerState.Value * state * multiplier; // Add flat bonus to physical damage types that the weapon already has if (__result.m_slash > 0) __result.m_slash += bonus; @@ -463,7 +463,11 @@ namespace RacesOfValheim if (canTame) { - __result += "\n[K] Tame"; + // Used to hardcode "[K] Tame" while AswidRace.Update actually checked U (now + // AswidConfig.TameKey) - the hint never matched the working key, and would have + // gone stale again the moment that key was rebound. MainKey.ToString() reads back + // whatever is actually bound. + __result += $"\n[{AswidConfig.TameKey.Value.MainKey}] Tame"; } } } @@ -525,7 +529,7 @@ namespace RacesOfValheim ZNetView nview = __instance.GetComponent(); if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Aswid") { - if (__instance == Player.m_localPlayer && RaceInput.Allowed && Input.GetKeyDown(KeyCode.I)) + if (__instance == Player.m_localPlayer && RaceInput.Allowed && AswidConfig.ToggleDevourKey.Value.IsDown()) { AswidRace.DevourEnabled = !AswidRace.DevourEnabled; string msg = AswidRace.DevourEnabled ? "Devour Ability: ENABLED" : "Devour Ability: DISABLED"; @@ -647,7 +651,7 @@ namespace RacesOfValheim float lifesteal = rules.LifestealPercent; if (EnvMan.instance != null && EnvMan.IsNight()) { - lifesteal *= 2f; + lifesteal *= AswidConfig.NightMultiplier.Value; } if (lifesteal > 0f) { @@ -738,7 +742,7 @@ namespace RacesOfValheim { if (skillType == Skills.SkillType.BloodMagic) { - factor *= 2f; // Benedictus et Afflictus: Double speed for Blood Magic + factor *= AswidConfig.BloodMagicSkillGainMultiplier.Value; // Benedictus et Afflictus } } } diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index a117fa9..e3b1765 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -185,7 +185,7 @@ namespace RacesOfValheim { DateTime lastTime = new DateTime(ticks); float elapsed = (float)(DateTime.Now - lastTime).TotalSeconds; - float cooldown = (15f * 60f) - elapsed; + float cooldown = AswidConfig.EnslaveCooldown.Value - elapsed; return Mathf.Max(0f, cooldown); } } @@ -226,7 +226,7 @@ namespace RacesOfValheim sensesCheckTimer -= Time.deltaTime; if (sensesCheckTimer <= 0f) { - sensesCheckTimer = 1.0f; // Refresh every 1 second (TTL is 2s) + sensesCheckTimer = AswidConfig.SensesRefreshInterval.Value; // TTL is 2s List allChars = Character.GetAllCharacters(); Vector3 myPos = Player.m_localPlayer.transform.position; @@ -239,7 +239,7 @@ namespace RacesOfValheim if (c == null || c == Player.m_localPlayer || c.IsDead() || c.IsTamed()) continue; float dist = Vector3.Distance(c.transform.position, myPos); - if (dist <= 100f) // 100 meters detection radius + if (dist <= AswidConfig.SensesRadius.Value) { try { @@ -256,8 +256,8 @@ namespace RacesOfValheim Light pLight = lightObj.AddComponent(); pLight.type = LightType.Point; pLight.color = Color.green; - pLight.range = 10f; - pLight.intensity = 2f; + pLight.range = AswidConfig.SensesLightRange.Value; + pLight.intensity = AswidConfig.SensesLightIntensity.Value; pLight.shadows = LightShadows.None; activeSensesLight[c] = lightObj; @@ -379,14 +379,14 @@ namespace RacesOfValheim if (RaceInput.Allowed) { - if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(AswidProgression.GetGKeyRules(state)); return; } - if (Input.GetKeyDown(KeyCode.H)) { TryToggleMistForm(); return; } - if (Input.GetKeyDown(KeyCode.J)) - { - TryCastEclipse(state); - return; + if (AswidConfig.BatFormKey.Value.IsDown()) { TryTransformWithRules(AswidProgression.GetGKeyRules(state)); return; } + if (AswidConfig.MistFormKey.Value.IsDown()) { TryToggleMistForm(); return; } + if (AswidConfig.EclipseKey.Value.IsDown()) + { + TryCastEclipse(state); + return; } - if (Input.GetKeyDown(KeyCode.U)) + if (AswidConfig.TameKey.Value.IsDown()) { TryTameHoverObject(state); return; @@ -760,7 +760,7 @@ namespace RacesOfValheim if (IsEclipseActive) return; - float cooldown = 900f; // 15 minutes + float cooldown = AswidConfig.EclipseCooldown.Value; if (Time.time - lastEclipseTime < cooldown) { int remaining = (int)(cooldown - (Time.time - lastEclipseTime)); @@ -787,7 +787,7 @@ namespace RacesOfValheim Player.m_localPlayer.Message(MessageHud.MessageType.Center, "An Eclipse descends..."); float castTimer = 0f; - while(castTimer < 2.0f) + while(castTimer < AswidConfig.EclipseCastTime.Value) { // Force root player physically if possible without breaking their animator HarmonyLib.Traverse.Create(Player.m_localPlayer).Method("SetRun", false).GetValue(); @@ -802,7 +802,7 @@ namespace RacesOfValheim HarmonyLib.Traverse.Create(EnvMan.instance).Field("m_debugTimeOfDay").SetValue(0.5f); // Midnight } - yield return new WaitForSeconds(60f); + yield return new WaitForSeconds(AswidConfig.EclipseDuration.Value); // Revert to server time if (EnvMan.instance != null) @@ -823,7 +823,7 @@ namespace RacesOfValheim private void HandleVampiricAura() { damageTickTimer += Time.deltaTime; - if (damageTickTimer < 0.25f) return; + if (damageTickTimer < AswidConfig.AuraTickInterval.Value) return; damageTickTimer = 0f; PerformLifeDrain(); @@ -846,8 +846,8 @@ namespace RacesOfValheim try { Vector3 center = Player.m_localPlayer.transform.position; - float radius = 3f; - if (EnvMan.instance != null && EnvMan.IsNight()) radius = 6f; + float radius = AswidConfig.AuraRadiusDay.Value; + if (EnvMan.instance != null && EnvMan.IsNight()) radius = AswidConfig.AuraRadiusNight.Value; int layerMask = LayerMask.GetMask("character", "character_net", "character_ghost"); var colliders = Physics.OverlapSphere(center, radius, layerMask); @@ -865,12 +865,12 @@ namespace RacesOfValheim float maxHp = c.GetMaxHealth(); float currentHp = c.GetHealth(); - float baseDamage = 1.0f; + float baseDamage = AswidConfig.AuraBaseDamage.Value; float bloodMagicFactor = Player.m_localPlayer.GetSkillFactor(Skills.SkillType.BloodMagic); - // Lo scaling aggiunge un massimo di +5.0 danni (al livello 100), indipendentemente dal danno base - float totalDamage = (baseDamage + bloodMagicFactor * 5f) * GetAuraFormMultiplier(); + // Lo scaling aggiunge un massimo di +AuraBloodMagicScaling danni (al livello 100), indipendentemente dal danno base + float totalDamage = (baseDamage + bloodMagicFactor * AswidConfig.AuraBloodMagicScaling.Value) * GetAuraFormMultiplier(); - if (currentHp > 0 && currentHp <= maxHp * 0.20f && !c.IsBoss()) + if (currentHp > 0 && currentHp <= maxHp * AswidConfig.AuraExecuteThreshold.Value && !c.IsBoss()) { totalDamage = currentHp * 2f; // Lethal damage for execute TryConsumeMob(c, maxHp, true); // Automatically devour when executed, bypassing cooldown @@ -905,7 +905,7 @@ namespace RacesOfValheim { if (!DevourEnabled) return; - if (!bypassCooldown && Time.time - lastConsumeTime < 5f) + if (!bypassCooldown && Time.time - lastConsumeTime < AswidConfig.DevourCooldown.Value) { return; // Cooldown active } diff --git a/JotunnModStub/Aswid/AswidStatusEffects.cs b/JotunnModStub/Aswid/AswidStatusEffects.cs index 5d746f0..f87e9bb 100644 --- a/JotunnModStub/Aswid/AswidStatusEffects.cs +++ b/JotunnModStub/Aswid/AswidStatusEffects.cs @@ -19,12 +19,12 @@ namespace RacesOfValheim { m_fallDamageModifier = -1f; // No fall damage - float multiplier = (EnvMan.instance != null && EnvMan.IsNight()) ? 2f : 1f; + float multiplier = (EnvMan.instance != null && EnvMan.IsNight()) ? AswidConfig.NightMultiplier.Value : 1f; + + m_speedModifier = AswidConfig.SpeedBonusPerState.Value * state * multiplier; - m_speedModifier = 0.01f * state * multiplier; // +3% speed per stage (*2 at night) - // For jump, Valheim SE_Stats typically adds the y value to 1 - m_jumpModifier = new Vector3(0f, 0.01f * state * multiplier, 0f); + m_jumpModifier = new Vector3(0f, AswidConfig.SpeedBonusPerState.Value * state * multiplier, 0f); if (state >= 5) { @@ -47,7 +47,7 @@ namespace RacesOfValheim var rules = AswidProgression.GetRules(state); if (rules != null && rules.HasSurtlingForm) { - hitData.m_damage.m_damage += 30f; + hitData.m_damage.m_damage += AswidConfig.SurtlingFormDamageBonus.Value; } } } diff --git a/JotunnModStub/Aswid/AswidThrall.cs b/JotunnModStub/Aswid/AswidThrall.cs index 77bb599..8d8297f 100644 --- a/JotunnModStub/Aswid/AswidThrall.cs +++ b/JotunnModStub/Aswid/AswidThrall.cs @@ -53,7 +53,7 @@ namespace RacesOfValheim if (enslaveTime > 0) { DateTime time = new DateTime(enslaveTime); - if ((DateTime.Now - time).TotalSeconds >= 60.0) + if ((DateTime.Now - time).TotalSeconds >= AswidConfig.ThrallLifetime.Value) { // Time's up! Kill the thrall. HitData hit = new HitData(); diff --git a/JotunnModStub/ConfigurationManagerAttributes.cs b/JotunnModStub/ConfigurationManagerAttributes.cs new file mode 100644 index 0000000..9b18654 --- /dev/null +++ b/JotunnModStub/ConfigurationManagerAttributes.cs @@ -0,0 +1,37 @@ +using System; +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// Duck-typed by Configuration Manager (matched by field name via reflection, not by type), + /// so nothing here needs a reference to ConfigurationManager.dll and the mod works with or + /// without that plugin installed - see CONFIGURATION-MANAGER-HOWTO.md, "Overriding default + /// Configuration Manager behavior". Kept internal, not public, so this shape can never collide + /// with another mod's copy of the same trick. + /// + /// Only the fields RacesOfValheim actually sets (Order, CustomDrawer, HideDefaultButton, + /// ReadOnly) need to be correct; the rest of Configuration Manager's documented set is kept + /// alongside them so future config additions do not need a second copy of this file. + /// + internal sealed class ConfigurationManagerAttributes + { + // Most of these are read by Configuration Manager itself via reflection and are never + // assigned from our own code, which is exactly what CS0649 is warning about here. +#pragma warning disable 0649 + public Action CustomDrawer; + public bool? Browsable; + public string Category; + public object DefaultValue; + public bool? HideDefaultButton; + public bool? HideSettingName; + public string Description; + public string DispName; + public int? Order; + public bool? ReadOnly; + public bool? IsAdvanced; + public Func ObjToStr; + public Func StrToObj; +#pragma warning restore 0649 + } +} diff --git a/JotunnModStub/Draugh/DraughConfig.cs b/JotunnModStub/Draugh/DraughConfig.cs new file mode 100644 index 0000000..8f3c8fe --- /dev/null +++ b/JotunnModStub/Draugh/DraughConfig.cs @@ -0,0 +1,116 @@ +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// Every tunable number behind the Draugh's abilities, bound as BepInEx ConfigEntry so they + /// show up in Configuration Manager without touching code - see + /// CONFIGURATION-MANAGER-HOWTO.md. Bound once, from RacesOfValheim.Awake(). One section per + /// topic (matches SkadiConfig/AswidConfig's layout) rather than one shared section, so each + /// shows up as its own entry in Configuration Manager's category list. + /// + /// No keybinds here: every Draugh ability triggers automatically off a game event (a parry, a + /// hit taken, a hit landed, death) rather than a key press, unlike Skadi or Aswid. + /// + /// Tier-gate thresholds (which progression state unlocks each ability) are left as-is, same + /// boundary drawn for Skadi's progression table - these are a differently-shaped piece of + /// config (per-tier unlock tables, not flat values). + /// + public static class DraughConfig + { + // ─── Passive combat (always active) ─────────────────────────────────── + public static ConfigEntry PhysicalResistMultiplier; + public static ConfigEntry FireSpiritWeaknessMultiplier; + + // ─── Sunken Menace (tier 2+: Wet heals instead of hurts) ───────────────── + public static ConfigEntry WetHealthRegenMultiplier; + + // ─── Rotting Edge (tier 3+: poison on hit, poison splash on parry) ────── + public static ConfigEntry PoisonOnHitPercent; + public static ConfigEntry ParryWindow; + public static ConfigEntry PoisonSplashDamage; + + // ─── Undead Fortitude (tier 4+: crit on staggered, death aura) ────────── + public static ConfigEntry StaggerCritMultiplier; + public static ConfigEntry DeathAuraRadius; + + // ─── North Wind (tier 5+: AoE frost on parry, on the same cooldown) ────── + public static ConfigEntry NorthWindCooldown; + public static ConfigEntry NorthWindRadius; + public static ConfigEntry NorthWindFrostDamage; + public static ConfigEntry NorthWindPushForce; + + // ─── Undying Will (tier 6+: survive death by burning Eitr) ────────────── + public static ConfigEntry UndyingWillCooldown; + public static ConfigEntry UndyingWillEitrDrainPerTick; + public static ConfigEntry UndyingWillTickInterval; + + // ─── Swarm of Terror (tier 7+: spawn friendly seeker brood on melee hits) ─ + public static ConfigEntry SwarmDetectionRadius; + public static ConfigEntry SwarmSpawnCooldown; + public static ConfigEntry SwarmSpawnCount; + public static ConfigEntry SwarmBroodLifetime; + + // ─── Steal Their Breath (tier 8+: cancel Undying Will death by a kill) ──── + public static ConfigEntry StealBreathHealPercent; + + public static void Bind(ConfigFile config) + { + const string combat = "Draugh - Passive Combat"; + PhysicalResistMultiplier = config.Bind(combat, "Physical Resist Multiplier", 0.8f, + new ConfigDescription("Multiplies incoming blunt/slash/pierce damage (0.8 = 20% resistance).", new AcceptableValueRange(0f, 1f))); + FireSpiritWeaknessMultiplier = config.Bind(combat, "Fire/Spirit Weakness Multiplier", 1.5f, + new ConfigDescription("Multiplies incoming fire/spirit damage (1.5 = 50% weaker).", new AcceptableValueRange(1f, 3f))); + + const string sunkenMenace = "Draugh - Sunken Menace"; + WetHealthRegenMultiplier = config.Bind(sunkenMenace, "Wet Health Regen Multiplier", 1.25f, + new ConfigDescription("Health regen multiplier while Wet, tier 2+ (Wet heals instead of hurting).", new AcceptableValueRange(1f, 3f))); + + const string rottingEdge = "Draugh - Rotting Edge"; + PoisonOnHitPercent = config.Bind(rottingEdge, "Poison On Hit Percent", 0.20f, + new ConfigDescription("Fraction of physical damage dealt added as poison, tier 3+.", new AcceptableValueRange(0f, 1f))); + ParryWindow = config.Bind(rottingEdge, "Parry Window", 0.25f, + new ConfigDescription("Seconds after a block still counts as a parry for Poison Splash/North Wind.", new AcceptableValueRange(0.05f, 1f))); + PoisonSplashDamage = config.Bind(rottingEdge, "Poison Splash Damage", 40f, + new ConfigDescription("Flat poison damage dealt to whoever you parry, tier 3+.", new AcceptableValueRange(0f, 200f))); + + const string fortitude = "Draugh - Undead Fortitude"; + StaggerCritMultiplier = config.Bind(fortitude, "Stagger Crit Multiplier", 1.30f, + new ConfigDescription("Multiplies physical damage dealt to staggered enemies, tier 4+.", new AcceptableValueRange(1f, 3f))); + DeathAuraRadius = config.Bind(fortitude, "Death Aura Radius", 100f, + new ConfigDescription("Meters within which an ally's death drops Human Meat for you, tier 4+.", new AcceptableValueRange(10f, 300f))); + + const string northWind = "Draugh - North Wind"; + NorthWindCooldown = config.Bind(northWind, "Cooldown", 20f, + new ConfigDescription("Seconds between North Wind triggers, tier 5+.", new AcceptableValueRange(0f, 120f))); + NorthWindRadius = config.Bind(northWind, "Radius", 8f, + new ConfigDescription("Meters from you that North Wind damages.", new AcceptableValueRange(1f, 30f))); + NorthWindFrostDamage = config.Bind(northWind, "Frost Damage", 50f, + new ConfigDescription("Flat frost damage dealt to everything in range.", new AcceptableValueRange(0f, 200f))); + NorthWindPushForce = config.Bind(northWind, "Push Force", 20f, + new ConfigDescription("Knockback applied to everything hit.", new AcceptableValueRange(0f, 100f))); + + const string undyingWill = "Draugh - Undying Will"; + UndyingWillCooldown = config.Bind(undyingWill, "Cooldown", 600f, + new ConfigDescription("Seconds between Undying Will triggers, tier 6+.", new AcceptableValueRange(0f, 3600f))); + UndyingWillEitrDrainPerTick = config.Bind(undyingWill, "Eitr Drain Per Tick", 2f, + new ConfigDescription("Eitr spent per tick while surviving on borrowed time.", new AcceptableValueRange(0f, 20f))); + UndyingWillTickInterval = config.Bind(undyingWill, "Tick Interval", 0.2f, + new ConfigDescription("Seconds between Eitr drain ticks.", new AcceptableValueRange(0.05f, 2f))); + + const string swarm = "Draugh - Swarm Of Terror"; + SwarmDetectionRadius = config.Bind(swarm, "Melee Detection Radius", 5f, + new ConfigDescription("Meters within which a hit taken counts as melee and can trigger a spawn, tier 7+.", new AcceptableValueRange(1f, 20f))); + SwarmSpawnCooldown = config.Bind(swarm, "Spawn Cooldown", 10f, + new ConfigDescription("Seconds between spawns.", new AcceptableValueRange(0f, 60f))); + SwarmSpawnCount = config.Bind(swarm, "Spawn Count", 2, + new ConfigDescription("Friendly Seeker Broodlings spawned per trigger.", new AcceptableValueRange(1, 10))); + SwarmBroodLifetime = config.Bind(swarm, "Brood Lifetime", 9.5f, + new ConfigDescription("Seconds a spawned broodling survives before it dies on its own.", new AcceptableValueRange(1f, 60f))); + + const string stealBreath = "Draugh - Steal Their Breath"; + StealBreathHealPercent = config.Bind(stealBreath, "Heal Percent", 0.25f, + new ConfigDescription("Fraction of max health healed when a kill cancels an in-progress Undying Will death, tier 8+.", new AcceptableValueRange(0f, 1f))); + } + } +} diff --git a/JotunnModStub/Draugh/DraughPatches.cs b/JotunnModStub/Draugh/DraughPatches.cs index 92784c2..b640b03 100644 --- a/JotunnModStub/Draugh/DraughPatches.cs +++ b/JotunnModStub/Draugh/DraughPatches.cs @@ -120,14 +120,14 @@ namespace RacesOfValheim if (!DraughRace.IsDraugh()) return; // Apply specific damage modifiers for Draugh - // -20% damage received from slash, pierce, blunt - hit.m_damage.m_blunt *= 0.8f; - hit.m_damage.m_slash *= 0.8f; - hit.m_damage.m_pierce *= 0.8f; - - // +50% damage received from fire, spirit - hit.m_damage.m_fire *= 1.5f; - hit.m_damage.m_spirit *= 1.5f; + float physResist = DraughConfig.PhysicalResistMultiplier.Value; + hit.m_damage.m_blunt *= physResist; + hit.m_damage.m_slash *= physResist; + hit.m_damage.m_pierce *= physResist; + + float fireSpiritWeakness = DraughConfig.FireSpiritWeaknessMultiplier.Value; + hit.m_damage.m_fire *= fireSpiritWeakness; + hit.m_damage.m_spirit *= fireSpiritWeakness; // Stage 4: Undead Fortitude (Poison Immunity) if (BossProgressionManager.GetCurrentProgressionState() >= 4) diff --git a/JotunnModStub/Draugh/DraughProgressionPatches.cs b/JotunnModStub/Draugh/DraughProgressionPatches.cs index 8aac6ce..8162551 100644 --- a/JotunnModStub/Draugh/DraughProgressionPatches.cs +++ b/JotunnModStub/Draugh/DraughProgressionPatches.cs @@ -20,7 +20,7 @@ namespace RacesOfValheim if (BossProgressionManager.GetCurrentProgressionState() >= 2) { // Invert the Wet debuff to actually heal the Draugh - __instance.m_healthRegenMultiplier = 1.25f; // +25% health regen + __instance.m_healthRegenMultiplier = DraughConfig.WetHealthRegenMultiplier.Value; __instance.m_staminaRegenMultiplier = 1f; // No stamina penalty __instance.m_tooltip = "The water restores your rotten flesh. Health regeneration increased."; } @@ -47,20 +47,21 @@ namespace RacesOfValheim float physDamage = hit.m_damage.m_blunt + hit.m_damage.m_slash + hit.m_damage.m_pierce + hit.m_damage.m_chop; if (physDamage > 0f && hit.m_skill != Skills.SkillType.BloodMagic && hit.m_skill != Skills.SkillType.ElementalMagic) { - // Add poison damage based on the physical damage (e.g., 20% of physical damage as poison DoT) - hit.m_damage.m_poison += physDamage * 0.20f; + // Add poison damage based on the physical damage + hit.m_damage.m_poison += physDamage * DraughConfig.PoisonOnHitPercent.Value; } } if (BossProgressionManager.GetCurrentProgressionState() >= 4) { - // Stage 4: Undead Fortitude (+30% crit damage on staggered enemies) + // Stage 4: Undead Fortitude (crit damage on staggered enemies) if (__instance.IsStaggering()) { - hit.m_damage.m_blunt *= 1.30f; - hit.m_damage.m_slash *= 1.30f; - hit.m_damage.m_pierce *= 1.30f; - hit.m_damage.m_chop *= 1.30f; + float critMult = DraughConfig.StaggerCritMultiplier.Value; + hit.m_damage.m_blunt *= critMult; + hit.m_damage.m_slash *= critMult; + hit.m_damage.m_pierce *= critMult; + hit.m_damage.m_chop *= critMult; } } } @@ -82,31 +83,31 @@ namespace RacesOfValheim if (state >= 3) { - // Check if it was a parry. + // Check if it was a parry. float blockTimer = Traverse.Create(__instance).Field("m_blockTimer").GetValue(); - float parryTime = 0.25f; // Default Valheim parry window - + float parryTime = DraughConfig.ParryWindow.Value; + if (blockTimer != -1f && blockTimer <= parryTime) { // Stage 3: Poison Splash HitData poisonSplash = new HitData(); - poisonSplash.m_damage.m_poison = 40f; // Flat base poison splash + poisonSplash.m_damage.m_poison = DraughConfig.PoisonSplashDamage.Value; poisonSplash.m_point = attacker.GetCenterPoint(); poisonSplash.SetAttacker(__instance); poisonSplash.m_dir = (attacker.GetCenterPoint() - __instance.GetCenterPoint()).normalized; - + attacker.ApplyDamage(poisonSplash, true, false); - + // Visual effect for splash UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("vfx_OozeHit"), attacker.GetCenterPoint(), Quaternion.identity); // Stage 5: North Wind (AoE Frost) if (state >= 5) { - if (Time.time - lastNorthWindTime >= 20f) + if (Time.time - lastNorthWindTime >= DraughConfig.NorthWindCooldown.Value) { lastNorthWindTime = Time.time; - + // Visual effect for Nova (sledge frost effect) GameObject iceHit = ZNetScene.instance.GetPrefab("vfx_sledge_iron_hit"); // Actually, vfx_ice_hit is better, or vfx_sledge_iron_hit which is used by Frostner if (iceHit == null) iceHit = ZNetScene.instance.GetPrefab("vfx_ice_hit"); @@ -115,25 +116,26 @@ namespace RacesOfValheim UnityEngine.Object.Instantiate(iceHit, __instance.transform.position, Quaternion.identity); } - // Find all characters within 8 meters + // Find all characters within range + float northWindRadius = DraughConfig.NorthWindRadius.Value; List allCharacters = Character.GetAllCharacters(); foreach (Character ch in allCharacters) { if (ch == null || ch == __instance || ch.IsPlayer() || ch.IsDead()) continue; - if (Vector3.Distance(__instance.transform.position, ch.transform.position) <= 8f) + if (Vector3.Distance(__instance.transform.position, ch.transform.position) <= northWindRadius) { HitData northWind = new HitData(); - northWind.m_damage.m_frost = 50f; + northWind.m_damage.m_frost = DraughConfig.NorthWindFrostDamage.Value; northWind.m_point = ch.GetCenterPoint(); northWind.SetAttacker(__instance); northWind.m_dir = (ch.GetCenterPoint() - __instance.GetCenterPoint()).normalized; - northWind.m_pushForce = 20f; - + northWind.m_pushForce = DraughConfig.NorthWindPushForce.Value; + ch.ApplyDamage(northWind, true, false); } } - + Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "The northern wind blows"); } } @@ -177,7 +179,7 @@ namespace RacesOfValheim { if (p.m_customData != null && p.m_customData.TryGetValue("Race", out string race) && race == "Draugh") { - if (Vector3.Distance(__instance.transform.position, p.transform.position) <= 100f) + if (Vector3.Distance(__instance.transform.position, p.transform.position) <= DraughConfig.DeathAuraRadius.Value) { draughNearby = true; break; @@ -229,7 +231,7 @@ namespace RacesOfValheim } float currentEitr = __instance.GetEitr(); - if (currentEitr > 0f && Time.time - DraughRace.lastUndyingWillTime >= 600f) // 10 minutes + if (currentEitr > 0f && Time.time - DraughRace.lastUndyingWillTime >= DraughConfig.UndyingWillCooldown.Value) { // Trigger Undying Will! DraughRace.lastUndyingWillTime = Time.time; @@ -279,12 +281,12 @@ namespace RacesOfValheim if (hit == null || hit.GetAttacker() == null || hit.m_damage.GetTotalDamage() <= 0f) return; // Melee check via distance - if (Vector3.Distance(hit.GetAttacker().transform.position, __instance.transform.position) <= 5f) + if (Vector3.Distance(hit.GetAttacker().transform.position, __instance.transform.position) <= DraughConfig.SwarmDetectionRadius.Value) { - if (Time.time - DraughRace.lastSeekerSpawnTime >= 10f) + if (Time.time - DraughRace.lastSeekerSpawnTime >= DraughConfig.SwarmSpawnCooldown.Value) { DraughRace.lastSeekerSpawnTime = Time.time; - + GameObject prefab = ObjectDB.instance.GetItemPrefab("SeekerBrood"); if (prefab == null) { @@ -295,17 +297,17 @@ namespace RacesOfValheim { Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Swarm of Terror!"); - for (int i = 0; i < 2; i++) + for (int i = 0; i < DraughConfig.SwarmSpawnCount.Value; i++) { Vector3 spawnPos = __instance.transform.position + __instance.transform.forward * 1f + UnityEngine.Random.insideUnitSphere * 1.5f; spawnPos.y = __instance.transform.position.y; - + GameObject brood = UnityEngine.Object.Instantiate(prefab, spawnPos, Quaternion.identity); Character c = brood.GetComponent(); if (c != null) { c.m_faction = Character.Faction.Players; // Make it friendly - + // Remove drops CharacterDrop drop = brood.GetComponent(); if (drop != null) @@ -313,8 +315,7 @@ namespace RacesOfValheim UnityEngine.Object.Destroy(drop); } - // Kill after 9.5 seconds - DraughRace.Instance.StartCoroutine(DraughRace.Instance.KillBroodAfterTime(c, 9.5f)); + DraughRace.Instance.StartCoroutine(DraughRace.Instance.KillBroodAfterTime(c, DraughConfig.SwarmBroodLifetime.Value)); } } } @@ -335,7 +336,7 @@ namespace RacesOfValheim // Steal Their Breath triggered! DraughRace.isUndying = false; // Break the routine loop - float healAmount = Player.m_localPlayer.GetMaxHealth() * 0.25f; + float healAmount = Player.m_localPlayer.GetMaxHealth() * DraughConfig.StealBreathHealPercent.Value; Player.m_localPlayer.Heal(healAmount); Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Steal Their Breath! Death is denied."); diff --git a/JotunnModStub/Draugh/DraughRace.cs b/JotunnModStub/Draugh/DraughRace.cs index 0293ec8..d4f9275 100644 --- a/JotunnModStub/Draugh/DraughRace.cs +++ b/JotunnModStub/Draugh/DraughRace.cs @@ -148,10 +148,9 @@ namespace RacesOfValheim break; } - // Drain 2 Eitr per tick (5 ticks per second = 10 eitr/sec) - p.UseEitr(2f); - - yield return new WaitForSeconds(0.2f); + p.UseEitr(DraughConfig.UndyingWillEitrDrainPerTick.Value); + + yield return new WaitForSeconds(DraughConfig.UndyingWillTickInterval.Value); } // Restore visuals diff --git a/JotunnModStub/Dvergar/DvergarAbilities.cs b/JotunnModStub/Dvergar/DvergarAbilities.cs index 67bb3b8..b0f0dc4 100644 --- a/JotunnModStub/Dvergar/DvergarAbilities.cs +++ b/JotunnModStub/Dvergar/DvergarAbilities.cs @@ -26,12 +26,12 @@ namespace RacesOfValheim DvergarProgression.DvergarRules rules = DvergarProgression.GetRules(state); - if (rules.RunicPing && Input.GetKeyDown(DvergarConfig.RunicPingKey)) + if (rules.RunicPing && DvergarConfigManagement.RunicPingKey.Value.IsDown()) { TryRunicPing(player); } - if (rules.RunicOvercharge && Input.GetKeyDown(DvergarConfig.RunicOverchargeKey)) + if (rules.RunicOvercharge && DvergarConfigManagement.RunicOverchargeKey.Value.IsDown()) { TryRunicOvercharge(player); } diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 38c21f8..854efd0 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -191,7 +191,9 @@ namespace RacesOfValheim // ─── Health malus ──────────────────────────────────────────────────── // Indexed by progression state; index 0 is unused so the state number indexes directly. - // Base -10, growing to -20 once The Queen falls. + // Base -10, growing to -20 once The Queen falls. Left as a plain per-tier table, same + // boundary drawn everywhere else in this mod (Skadi's progression table included) - + // not exposed through Configuration Manager. public static readonly float[] HealthMalusByState = { 0f, // (unused) @@ -206,7 +208,10 @@ namespace RacesOfValheim }; // A Dvergar must never be reduced below this, however the malus and food line up. - public static readonly float MinMaxHealth = 5f; + // Forwards to DvergarConfigManagement (BepInEx ConfigEntry) so every existing call site + // keeps reading DvergarConfig.MinMaxHealth unchanged - see that class for why this one + // field, and not the rest of this file, is configurable. + public static float MinMaxHealth => DvergarConfigManagement.MinMaxHealth.Value; // ─── Elemental affinity ────────────────────────────────────────────── // Runes in the blood: every blow the Dvergar lands carries lightning. @@ -215,21 +220,28 @@ namespace RacesOfValheim // growing by a flat step per progression state, so +2 at Base through +16 after Fader - // with lightning in place of frost. SkadiDamagePatch is the reference; like it, this // applies to every blow the player lands, not only melee. - public static readonly float ElementalDamagePerState = 2f; + public static float ElementalDamagePerState => DvergarConfigManagement.ElementalDamagePerState.Value; public static readonly HitData.DamageType ElementalDamageType = HitData.DamageType.Lightning; // ─── Weapon affinity ───────────────────────────────────────────────── // Bonus damage plus a stamina discount on the attack. Neither scales with the tier - a // tier only ever adds a new weapon to the list - and skill XP is deliberately untouched. + // + // DamagePercent and StaminaPercent below are fallback shape values only: identical across + // every weapon today, and DvergarProgression.GetRules overrides both with + // DvergarConfigManagement's live (and configurable) values before handing rules out - see + // the comment there. FlatDamage and StaminaFlat stay literal zero-and-unconfigured: both + // are currently inert placeholders (FlatDamage's whole effect is gated behind + // `if (affinity.FlatDamage > 0f)` in DvergarPatches, which never fires at zero). public struct WeaponAffinity { public Skills.SkillType Skill; public int UnlockState; public HitData.DamageType FlatDamageType; // channel the flat bonus lands on public float FlatDamage; // TODO - public float DamagePercent; // TODO, share of physical damage added - public float StaminaPercent; // TODO, share of attack stamina refunded + public float DamagePercent; // fallback shape only, see above + public float StaminaPercent; // fallback shape only, see above public float StaminaFlat; // TODO, flat stamina refunded public string DisplayName; } @@ -275,13 +287,14 @@ namespace RacesOfValheim public const int MiningAffinityState = 2; // Faster mining is modelled as extra pickaxe damage per swing rather than a swing-rate - // change: rock HP is what actually gates how long a vein takes. - public static readonly float MiningDamageMultiplier = 1.20f; // TODO: 20% faster? - public static readonly float MiningStaminaPercent = 0.40f; // TODO: or 40% less stamina? + // change: rock HP is what actually gates how long a vein takes. Forward to + // DvergarConfigManagement (BepInEx ConfigEntry) - see that class. + public static float MiningDamageMultiplier => DvergarConfigManagement.MiningDamageMultiplier.Value; + public static float MiningStaminaPercent => DvergarConfigManagement.MiningStaminaPercent.Value; // Chance for a mined vein to yield an extra unit of ore. 0 disables the yield half of // the affinity and leaves it purely a speed/stamina perk. - public static readonly float MiningExtraDropChance = 0.25f; // TODO + public static float MiningExtraDropChance => DvergarConfigManagement.MiningExtraDropChance.Value; // Matched against the drop prefab name, lowercased, by Contains. public static readonly string[] OreDropNames = @@ -344,18 +357,21 @@ namespace RacesOfValheim }; // ─── Runic Ping (Yagluth) ──────────────────────────────────────────── - public const int RunicPingState = 6; - public const KeyCode RunicPingKey = KeyCode.G; + // The keybind used to live here as a KeyCode const; it is now DvergarConfigManagement's + // RunicPingKey (a rebindable KeyboardShortcut), read directly by DvergarAbilities. + public const int RunicPingState = 6; - public static readonly float RunicPingEitrCost = 25f; // TODO - public static readonly float RunicPingRadius = 40f; // TODO - public static readonly float RunicPingDuration = 10f; // TODO - public static readonly float RunicPingCooldown = 20f; // TODO + // Every numeric knob below forwards to DvergarConfigManagement (BepInEx ConfigEntry) - + // see that class for why these, and not the colours, are configurable. + public static float RunicPingEitrCost => DvergarConfigManagement.RunicPingEitrCost.Value; + public static float RunicPingRadius => DvergarConfigManagement.RunicPingRadius.Value; + public static float RunicPingDuration => DvergarConfigManagement.RunicPingDuration.Value; + public static float RunicPingCooldown => DvergarConfigManagement.RunicPingCooldown.Value; - public static readonly Color RunicPingOreColor = new Color(0.4f, 0.8f, 1f); - public static readonly Color RunicPingEnemyColor = new Color(1f, 0.35f, 0.35f); - public static readonly float RunicPingLightRange = 8f; - public static readonly float RunicPingLightIntensity = 2f; + public static readonly Color RunicPingOreColor = new Color(0.4f, 0.8f, 1f); + public static readonly Color RunicPingEnemyColor = new Color(1f, 0.35f, 0.35f); + public static float RunicPingLightRange => DvergarConfigManagement.RunicPingLightRange.Value; + public static float RunicPingLightIntensity => DvergarConfigManagement.RunicPingLightIntensity.Value; // Vein prefabs are matched on name, lowercased, by Contains - MineRock5_Copper, // silvervein, rock4_copper and friends all fall out of this list. @@ -365,13 +381,14 @@ namespace RacesOfValheim }; // ─── Runic Overcharge (Fader) ──────────────────────────────────────── - public const int RunicOverchargeState = 8; - public const KeyCode RunicOverchargeKey = KeyCode.H; + // The keybind used to live here as a KeyCode const; it is now DvergarConfigManagement's + // RunicOverchargeKey (a rebindable KeyboardShortcut), read directly by DvergarAbilities. + public const int RunicOverchargeState = 8; - public static readonly float RunicOverchargeEitrCost = 60f; // TODO - public static readonly float RunicOverchargeMultiplier = 4f; // TODO, applied to physical damage - public static readonly float RunicOverchargeWindow = 15f; // seconds the charge is held - public static readonly float RunicOverchargeCooldown = 60f; // TODO + public static float RunicOverchargeEitrCost => DvergarConfigManagement.RunicOverchargeEitrCost.Value; + public static float RunicOverchargeMultiplier => DvergarConfigManagement.RunicOverchargeMultiplier.Value; // applied to physical damage + public static float RunicOverchargeWindow => DvergarConfigManagement.RunicOverchargeWindow.Value; // seconds the charge is held + public static float RunicOverchargeCooldown => DvergarConfigManagement.RunicOverchargeCooldown.Value; // ─── Helpers ───────────────────────────────────────────────────────── /// Clamped table lookup, so a state outside 1..8 can never index out of range. diff --git a/JotunnModStub/Dvergar/DvergarConfigManagement.cs b/JotunnModStub/Dvergar/DvergarConfigManagement.cs new file mode 100644 index 0000000..b9be848 --- /dev/null +++ b/JotunnModStub/Dvergar/DvergarConfigManagement.cs @@ -0,0 +1,111 @@ +using UnityEngine; +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// The BepInEx-configurable slice of the Dvergar's numbers, bound as ConfigEntry so they show + /// up in Configuration Manager without touching code - see CONFIGURATION-MANAGER-HOWTO.md. + /// Bound once, from RacesOfValheim.Awake(). One section per topic (matches + /// SkadiConfig/AswidConfig/DraughConfig's layout). + /// + /// Named separately from the pre-existing DvergarConfig (rather than folding into it) because + /// that class is a different kind of thing: identity constants that must never change once a + /// player has the race (RaceId, status effect names - renaming them would orphan saved + /// characters), hand-tuned cosmetic placement numbers (eye/hood position - exposing those as + /// sliders would just let someone accidentally break the model), and per-tier tables (health + /// malus, smithing/trader discounts - the same "leave alone" boundary drawn for every other + /// race's progression table). Only the genuine ability knobs - Runic Ping/Overcharge and their + /// two keybinds, mining and weapon-affinity percentages - belong here. DvergarConfig's own + /// fields for those now forward to this class (see the comments there), so every existing call + /// site kept working unchanged. + /// + /// One caveat worth knowing: DvergarProgression.GetRules caches its result per progression + /// state the first time that state is reached. ElementalDamagePerState and the weapon-affinity + /// percentages below are read into that cache, so retuning them mid-session only affects tiers + /// the cache hasn't already built - a relog (or reaching a new tier) picks up the new value. + /// Runic Ping/Overcharge and mining read their config live on every use and are unaffected. + /// + public static class DvergarConfigManagement + { + // ─── Keybinds ────────────────────────────────────────────────────────── + public static ConfigEntry RunicPingKey; + public static ConfigEntry RunicOverchargeKey; + + // ─── Passive combat ────────────────────────────────────────────────── + public static ConfigEntry ElementalDamagePerState; + public static ConfigEntry MinMaxHealth; + public static ConfigEntry WeaponAffinityDamagePercent; + public static ConfigEntry WeaponAffinityStaminaPercent; + + // ─── Mining ──────────────────────────────────────────────────────────── + public static ConfigEntry MiningDamageMultiplier; + public static ConfigEntry MiningStaminaPercent; + public static ConfigEntry MiningExtraDropChance; + + // ─── Runic Ping (tier 6+) ───────────────────────────────────────────── + public static ConfigEntry RunicPingEitrCost; + public static ConfigEntry RunicPingRadius; + public static ConfigEntry RunicPingDuration; + public static ConfigEntry RunicPingCooldown; + public static ConfigEntry RunicPingLightRange; + public static ConfigEntry RunicPingLightIntensity; + + // ─── Runic Overcharge (tier 8) ──────────────────────────────────────── + public static ConfigEntry RunicOverchargeEitrCost; + public static ConfigEntry RunicOverchargeMultiplier; + public static ConfigEntry RunicOverchargeWindow; + public static ConfigEntry RunicOverchargeCooldown; + + public static void Bind(ConfigFile config) + { + const string keybinds = "Dvergar - Keybinds"; + RunicPingKey = config.Bind(keybinds, "Runic Ping", new KeyboardShortcut(KeyCode.G), + new ConfigDescription("Lights up ore veins and hidden enemies nearby, tier 6+.")); + RunicOverchargeKey = config.Bind(keybinds, "Runic Overcharge", new KeyboardShortcut(KeyCode.H), + new ConfigDescription("Loads the next favoured-weapon blow with bonus damage, tier 8.")); + + const string combat = "Dvergar - Passive Combat"; + ElementalDamagePerState = config.Bind(combat, "Elemental Damage Per State", 2f, + new ConfigDescription("Lightning added to every blow the player lands, multiplied by the current progression state.", new AcceptableValueRange(0f, 10f))); + MinMaxHealth = config.Bind(combat, "Minimum Max Health", 5f, + new ConfigDescription("A Dvergar's max health is never reduced below this, however the per-tier malus lines up.", new AcceptableValueRange(1f, 50f))); + WeaponAffinityDamagePercent = config.Bind(combat, "Weapon Affinity Damage Percent", 0.15f, + new ConfigDescription("Extra physical damage with a favoured weapon (Hammer/Bow/Axe/Crossbow), as a fraction.", new AcceptableValueRange(0f, 1f))); + WeaponAffinityStaminaPercent = config.Bind(combat, "Weapon Affinity Stamina Percent", 0.20f, + new ConfigDescription("Stamina refunded on attacks with a favoured weapon, as a fraction.", new AcceptableValueRange(0f, 1f))); + + const string mining = "Dvergar - Mining"; + MiningDamageMultiplier = config.Bind(mining, "Damage Multiplier", 1.20f, + new ConfigDescription("Multiplies pickaxe damage against rock, tier 2+.", new AcceptableValueRange(1f, 3f))); + MiningStaminaPercent = config.Bind(mining, "Stamina Discount Percent", 0.40f, + new ConfigDescription("Stamina saved per pickaxe swing, as a fraction.", new AcceptableValueRange(0f, 1f))); + MiningExtraDropChance = config.Bind(mining, "Extra Ore Drop Chance", 0.25f, + new ConfigDescription("Chance a mined vein yields one extra unit of ore. 0 disables the yield half of the affinity.", new AcceptableValueRange(0f, 1f))); + + const string ping = "Dvergar - Runic Ping"; + RunicPingEitrCost = config.Bind(ping, "Eitr Cost", 25f, + new ConfigDescription("Eitr spent per cast.", new AcceptableValueRange(0f, 100f))); + RunicPingRadius = config.Bind(ping, "Radius", 40f, + new ConfigDescription("Meters within which ore veins and hidden enemies are marked.", new AcceptableValueRange(5f, 100f))); + RunicPingDuration = config.Bind(ping, "Marker Duration", 10f, + new ConfigDescription("Seconds a marker light stays lit.", new AcceptableValueRange(1f, 60f))); + RunicPingCooldown = config.Bind(ping, "Cooldown", 20f, + new ConfigDescription("Seconds between casts.", new AcceptableValueRange(0f, 300f))); + RunicPingLightRange = config.Bind(ping, "Marker Light Range", 8f, + new ConfigDescription("Range of each marker light.", new AcceptableValueRange(1f, 30f))); + RunicPingLightIntensity = config.Bind(ping, "Marker Light Intensity", 2f, + new ConfigDescription("Intensity of each marker light.", new AcceptableValueRange(0.1f, 10f))); + + const string overcharge = "Dvergar - Runic Overcharge"; + RunicOverchargeEitrCost = config.Bind(overcharge, "Eitr Cost", 60f, + new ConfigDescription("Eitr spent to load a charge.", new AcceptableValueRange(0f, 200f))); + RunicOverchargeMultiplier = config.Bind(overcharge, "Damage Multiplier", 4f, + new ConfigDescription("Multiplies physical damage on the blow that discharges the loaded weapon.", new AcceptableValueRange(1f, 10f))); + RunicOverchargeWindow = config.Bind(overcharge, "Charge Window", 15f, + new ConfigDescription("Seconds a loaded charge is held before it lapses unused.", new AcceptableValueRange(1f, 60f))); + RunicOverchargeCooldown = config.Bind(overcharge, "Cooldown", 60f, + new ConfigDescription("Seconds between casts.", new AcceptableValueRange(0f, 300f))); + } + } +} diff --git a/JotunnModStub/Dvergar/DvergarProgression.cs b/JotunnModStub/Dvergar/DvergarProgression.cs index f3bcc57..5469a11 100644 --- a/JotunnModStub/Dvergar/DvergarProgression.cs +++ b/JotunnModStub/Dvergar/DvergarProgression.cs @@ -41,10 +41,21 @@ namespace RacesOfValheim state = Mathf.Clamp(state, BossProgressionManager.MinState, BossProgressionManager.MaxState); if (cached[state]) return cache[state]; + // DamagePercent/StaminaPercent are overridden from DvergarConfigManagement here + // rather than in the WeaponAffinities array itself: that array is a static readonly + // field evaluated at class-load time, which can run before RacesOfValheim.Awake() + // calls DvergarConfigManagement.Bind - reading .Value there would risk a + // null-reference on the ConfigEntry. Reading it here, when rules are actually built, + // is always after Bind has run. List affinities = new List(); foreach (DvergarConfig.WeaponAffinity affinity in DvergarConfig.WeaponAffinities) { - if (state >= affinity.UnlockState) affinities.Add(affinity); + if (state < affinity.UnlockState) continue; + + DvergarConfig.WeaponAffinity live = affinity; + live.DamagePercent = DvergarConfigManagement.WeaponAffinityDamagePercent.Value; + live.StaminaPercent = DvergarConfigManagement.WeaponAffinityStaminaPercent.Value; + affinities.Add(live); } DvergarRules rules = new DvergarRules diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index e2628aa..615a4a3 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -58,17 +58,17 @@ namespace RacesOfValheim } if (isGrounded && RaceInput.Allowed) { - if (Input.GetKeyDown(KeyCode.O)) + if (FenrirConfig.HowlKey.Value.IsDown()) { StartCoroutine(HowlRoutine()); } else if (Input.GetMouseButtonDown(1)) // Tasto destro (Heavy Claw) { - StartCoroutine(ClawRoutine("attack_claw1", 110f, 1.2f, 0.5f)); + StartCoroutine(ClawRoutine("attack_claw1", FenrirConfig.FenringHeavyClawDamage.Value, 1.2f, 0.5f)); } else if (Input.GetMouseButtonDown(0)) // Tasto sinistro { - StartCoroutine(ClawRoutine("attack_claw0", 60f, 1.0f, 0.4f)); + StartCoroutine(ClawRoutine("attack_claw0", FenrirConfig.FenringLightClawDamage.Value, 1.0f, 0.4f)); } else if (Input.GetMouseButtonDown(2)) // Tasto centrale { @@ -173,11 +173,11 @@ namespace RacesOfValheim Rigidbody rb = Player.m_localPlayer.GetComponent(); if (rb != null) { - Vector3 dashVelocity = Player.m_localPlayer.transform.forward * 31.5f; + Vector3 dashVelocity = Player.m_localPlayer.transform.forward * FenrirConfig.FenringJumpDashSpeed.Value; // Spinta verso l'alto solo nella prima metà dello scatto - if (elapsedDash < dashDuration / 2f) + if (elapsedDash < dashDuration / 2f) { - dashVelocity += Vector3.up * 13.1f; + dashVelocity += Vector3.up * FenrirConfig.FenringJumpDashUpwardSpeed.Value; } rb.MovePosition(rb.position + dashVelocity * Time.fixedDeltaTime); @@ -188,7 +188,7 @@ namespace RacesOfValheim } // Infliggiamo il danno al termine dello scatto - ExecuteClawDamage(95f); + ExecuteClawDamage(FenrirConfig.FenringJumpAttackDamage.Value); // Tempo per riprendersi dall'atterraggio prima di potersi muovere di nuovo yield return new WaitForSeconds(0.55f); @@ -203,7 +203,7 @@ namespace RacesOfValheim Vector3 playerPos = Player.m_localPlayer.transform.position; Vector3 attackPoint = playerPos + Player.m_localPlayer.transform.forward * 1.5f + Vector3.up * 1f; - float attackRadius = 2.5f; + float attackRadius = FenrirConfig.FenringAttackRadius.Value; float unarmedSkillLevel = Player.m_localPlayer.GetSkillLevel(Skills.SkillType.Unarmed); float totalDamage = baseDamage + unarmedSkillLevel; @@ -243,7 +243,7 @@ namespace RacesOfValheim { HitData hitData = new HitData(); hitData.m_damage.m_slash = totalDamage; - hitData.m_pushForce = 30f; + hitData.m_pushForce = FenrirConfig.FenringPushForce.Value; hitData.m_point = targetCenter; hitData.m_dir = Player.m_localPlayer.transform.forward; hitData.m_skill = Skills.SkillType.Unarmed; @@ -339,7 +339,7 @@ namespace RacesOfValheim StopFire(); } - if (canAct && Input.GetKeyDown(KeyCode.O)) + if (canAct && FenrirConfig.HowlKey.Value.IsDown()) { StartCoroutine(HowlRoutine()); } @@ -429,8 +429,7 @@ namespace RacesOfValheim private void UpdateFire() { - // Drain Eitr ridotto del 50% (da 25 a 12.5 per sec) - Player.m_localPlayer.UseEitr(12.5f * Time.deltaTime); + Player.m_localPlayer.UseEitr(FenrirConfig.CultistFireEitrDrainPerSecond.Value * Time.deltaTime); cultistAnim.SetFloat("forward_speed", 0f); cultistAnim.SetFloat("sideway_speed", 0f); @@ -460,11 +459,11 @@ namespace RacesOfValheim Vector3 playerPos = Player.m_localPlayer.transform.position; Vector3 attackPoint = playerPos + Player.m_localPlayer.transform.forward * 2.5f + Vector3.up * 1f; - float attackRadius = 3f; + float attackRadius = FenrirConfig.CultistFireAttackRadius.Value; float magicSkillLevel = Player.m_localPlayer.GetSkillLevel(Skills.SkillType.ElementalMagic); - float baseFireDamage = 20f; // per 0.2s - float totalDamage = baseFireDamage + (magicSkillLevel * 0.5f); + float baseFireDamage = FenrirConfig.CultistFireDamagePerTick.Value; + float totalDamage = baseFireDamage + (magicSkillLevel * FenrirConfig.CultistFireMagicSkillScaling.Value); int layerMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle"); Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask); @@ -531,7 +530,7 @@ namespace RacesOfValheim PlaySFX("sfx_cultist_attack", "sfx_fenring_attack", "sfx_wolf_attack"); - ExecuteClawDamage(85f); + ExecuteClawDamage(FenrirConfig.CultistClawDamage.Value); float remainingTimeToIdle = 0.5f - 0.4f; if (remainingTimeToIdle > 0) @@ -557,7 +556,7 @@ namespace RacesOfValheim PlaySFX("sfx_cultist_attack_double", "sfx_cultist_attack", "sfx_fenring_attack"); - ExecuteClawDamage(140f); + ExecuteClawDamage(FenrirConfig.CultistDoubleClawDamage.Value); // Attendiamo che l'animazione finisca (locking del giocatore) // L'animazione doppia del cultista dura circa 1.5 - 2 secondi @@ -573,7 +572,7 @@ namespace RacesOfValheim Vector3 playerPos = Player.m_localPlayer.transform.position; Vector3 attackPoint = playerPos + Player.m_localPlayer.transform.forward * 1.5f + Vector3.up * 1f; - float attackRadius = 2.5f; + float attackRadius = FenrirConfig.CultistAttackRadius.Value; float unarmedSkillLevel = Player.m_localPlayer.GetSkillLevel(Skills.SkillType.Unarmed); float totalDamage = baseDamage + unarmedSkillLevel; @@ -613,7 +612,7 @@ namespace RacesOfValheim { HitData hitData = new HitData(); hitData.m_damage.m_slash = totalDamage; - hitData.m_pushForce = 30f; + hitData.m_pushForce = FenrirConfig.CultistPushForce.Value; hitData.m_point = targetCenter; hitData.m_dir = Player.m_localPlayer.transform.forward; hitData.m_skill = Skills.SkillType.Unarmed; @@ -679,15 +678,15 @@ namespace RacesOfValheim { if (Input.GetMouseButtonDown(0)) // Left Click { - StartCoroutine(WolfAttackRoutine("attack1", 40f, 0.6f, 0.2f)); + StartCoroutine(WolfAttackRoutine("attack1", FenrirConfig.WolfAttack1Damage.Value, 0.6f, 0.2f)); } else if (Input.GetMouseButtonDown(1)) // Right Click { - StartCoroutine(WolfAttackRoutine("attack2", 60f, 0.8f, 0.3f)); + StartCoroutine(WolfAttackRoutine("attack2", FenrirConfig.WolfAttack2Damage.Value, 0.8f, 0.3f)); } else if (Input.GetMouseButtonDown(2)) // Middle Click { - StartCoroutine(WolfAttackRoutine("attack3", 80f, 1.0f, 0.4f)); + StartCoroutine(WolfAttackRoutine("attack3", FenrirConfig.WolfAttack3Damage.Value, 1.0f, 0.4f)); } } } @@ -745,7 +744,7 @@ namespace RacesOfValheim Vector3 playerPos = Player.m_localPlayer.transform.position; // Il lupo è basso, abbassiamo l'altezza dell'attacco Vector3 attackPoint = playerPos + Player.m_localPlayer.transform.forward * 1.5f + Vector3.up * 0.5f; - float attackRadius = 2.0f; + float attackRadius = FenrirConfig.WolfAttackRadius.Value; float unarmedSkillLevel = Player.m_localPlayer.GetSkillLevel(Skills.SkillType.Unarmed); float totalDamage = baseDamage + unarmedSkillLevel; @@ -785,7 +784,7 @@ namespace RacesOfValheim { HitData hitData = new HitData(); hitData.m_damage.m_slash = totalDamage; - hitData.m_pushForce = 20f; + hitData.m_pushForce = FenrirConfig.WolfPushForce.Value; hitData.m_point = targetCenter; hitData.m_dir = Player.m_localPlayer.transform.forward; hitData.m_skill = Skills.SkillType.Unarmed; @@ -852,12 +851,12 @@ namespace RacesOfValheim { if (Input.GetMouseButtonDown(0)) // Left Click { - StartCoroutine(UlvAttackRoutine("attack_bite", 40f, 0.6f, 0.2f)); + StartCoroutine(UlvAttackRoutine("attack_bite", FenrirConfig.UlvBiteDamage.Value, 0.6f, 0.2f)); } else if (Input.GetMouseButtonDown(1)) // Right Click { // Right click uses bite but as a heavier attack since slash is moved to jump - StartCoroutine(UlvAttackRoutine("attack_bite", 60f, 0.8f, 0.3f)); + StartCoroutine(UlvAttackRoutine("attack_bite", FenrirConfig.UlvHeavyBiteDamage.Value, 0.8f, 0.3f)); } else if (Input.GetMouseButtonDown(2)) // Middle Click { @@ -928,7 +927,7 @@ namespace RacesOfValheim Vector3 playerPos = Player.m_localPlayer.transform.position; Vector3 attackPoint = playerPos + Player.m_localPlayer.transform.forward * 1.5f + Vector3.up * 0.5f; - float attackRadius = 2.0f; + float attackRadius = FenrirConfig.UlvAttackRadius.Value; float unarmedSkillLevel = Player.m_localPlayer.GetSkillLevel(Skills.SkillType.Unarmed); float totalDamage = baseDamage + unarmedSkillLevel; @@ -968,7 +967,7 @@ namespace RacesOfValheim { HitData hitData = new HitData(); hitData.m_damage.m_slash = totalDamage; - hitData.m_pushForce = 25f; + hitData.m_pushForce = FenrirConfig.UlvPushForce.Value; hitData.m_point = targetCenter; hitData.m_dir = Player.m_localPlayer.transform.forward; hitData.m_skill = Skills.SkillType.Unarmed; @@ -999,7 +998,7 @@ namespace RacesOfValheim // Leap forward (+50% range) float leapDuration = 0.25f; - float leapSpeed = 18f; // Increased from 12f to 18f + float leapSpeed = FenrirConfig.UlvLeapSpeed.Value; float elapsed = 0f; while (elapsed < leapDuration) @@ -1022,7 +1021,7 @@ namespace RacesOfValheim } } - ExecuteBiteDamage(80f); + ExecuteBiteDamage(FenrirConfig.UlvJumpAttackDamage.Value); yield return new WaitForSeconds(0.4f); diff --git a/JotunnModStub/Fenrir/FenrirConfig.cs b/JotunnModStub/Fenrir/FenrirConfig.cs new file mode 100644 index 0000000..0208a9a --- /dev/null +++ b/JotunnModStub/Fenrir/FenrirConfig.cs @@ -0,0 +1,211 @@ +using UnityEngine; +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// Every tunable number and keybind behind the Fenrir's abilities and special attacks, bound + /// as BepInEx ConfigEntry so they show up in Configuration Manager without touching code - see + /// CONFIGURATION-MANAGER-HOWTO.md. Bound once, from RacesOfValheim.Awake(). One section per + /// topic (matches SkadiConfig/AswidConfig/DraughConfig's layout). + /// + /// Only the four transform/howl keys are exposed as rebindable - unlike Skadi's dragon forms, + /// which share one unified attack-button scheme across all three forms, each of Fenrir's four + /// forms (Fenring, Cultist, Wolf, Ulv) is an independent MonoBehaviour with its own hardcoded + /// mouse-button reads. Rebinding all of those individually would be a much larger, more + /// error-prone change for comparatively little value over just leaving attacks on the mouse, + /// which is where an action game's combat inputs are expected to live. + /// + /// One caveat: the Form Buffs section is read once, into the status effects built by + /// FenrirRace.CreateModAssets on mod startup - not every frame. Retuning those values + /// mid-session needs a relog to take effect. Everything else (Passive Combat, every attack's + /// numbers) is read live on every use. + /// + public static class FenrirConfig + { + // ─── Keybinds ────────────────────────────────────────────────────────── + // Defaults match today's fixed inputs exactly, so nobody's controls change until they + // open Configuration Manager (or the .cfg) and rebind one on purpose. + public static ConfigEntry WolfFormKey; + public static ConfigEntry FenrirFormKey; + public static ConfigEntry CultistFormKey; + public static ConfigEntry HowlKey; + + // ─── Passive combat (scales with progression state) ────────────────── + public static ConfigEntry ArmorBonusPerState; + public static ConfigEntry DamageBonusPerState; + public static ConfigEntry FallDamageReductionPerState; + public static ConfigEntry SpeedBonusPerState; + public static ConfigEntry JumpBonusPerState; + public static ConfigEntry SunSicknessDuration; + + // ─── Form buffs (applied while transformed) ─────────────────────────── + public static ConfigEntry FullFormSpeedBonus; + public static ConfigEntry FullFormJumpBonus; + public static ConfigEntry FullFormFallDamageReduction; + public static ConfigEntry WolfFormSpeedBonus; + public static ConfigEntry WolfFormFallDamageReduction; + public static ConfigEntry FormStaminaRegenMultiplier; + public static ConfigEntry FormStaminaDrainReduction; + + // ─── Fenring form attacks ───────────────────────────────────────────── + public static ConfigEntry FenringHeavyClawDamage; + public static ConfigEntry FenringLightClawDamage; + public static ConfigEntry FenringJumpAttackDamage; + public static ConfigEntry FenringJumpDashSpeed; + public static ConfigEntry FenringJumpDashUpwardSpeed; + public static ConfigEntry FenringAttackRadius; + public static ConfigEntry FenringPushForce; + + // ─── Cultist form attacks ────────────────────────────────────────────── + public static ConfigEntry CultistClawDamage; + public static ConfigEntry CultistDoubleClawDamage; + public static ConfigEntry CultistAttackRadius; + public static ConfigEntry CultistPushForce; + public static ConfigEntry CultistFireDamagePerTick; + public static ConfigEntry CultistFireEitrDrainPerSecond; + public static ConfigEntry CultistFireMagicSkillScaling; + public static ConfigEntry CultistFireAttackRadius; + + // ─── Wolf form attacks ───────────────────────────────────────────────── + public static ConfigEntry WolfAttack1Damage; + public static ConfigEntry WolfAttack2Damage; + public static ConfigEntry WolfAttack3Damage; + public static ConfigEntry WolfAttackRadius; + public static ConfigEntry WolfPushForce; + + // ─── Ulv form attacks ────────────────────────────────────────────────── + public static ConfigEntry UlvBiteDamage; + public static ConfigEntry UlvHeavyBiteDamage; + public static ConfigEntry UlvJumpAttackDamage; + public static ConfigEntry UlvLeapSpeed; + public static ConfigEntry UlvAttackRadius; + public static ConfigEntry UlvPushForce; + + public static void Bind(ConfigFile config) + { + const string keybinds = "Fenrir - Keybinds"; + WolfFormKey = config.Bind(keybinds, "Wolf Form", new KeyboardShortcut(KeyCode.G), + new ConfigDescription("Transform into (or revert from) a Wolf/Ulv, tier 3+.")); + FenrirFormKey = config.Bind(keybinds, "Fenrir Form", new KeyboardShortcut(KeyCode.H), + new ConfigDescription("Transform into (or revert from) a Fenring/Ulv, tier 4+.")); + CultistFormKey = config.Bind(keybinds, "Cultist Form", new KeyboardShortcut(KeyCode.J), + new ConfigDescription("Transform into (or revert from) a Cultist, tier 6+.")); + HowlKey = config.Bind(keybinds, "Howl", new KeyboardShortcut(KeyCode.O), + new ConfigDescription("Howls in Fenring or Cultist form. Cosmetic only.")); + + const string combat = "Fenrir - Passive Combat"; + ArmorBonusPerState = config.Bind(combat, "Armor Bonus Per State", 3f, + new ConfigDescription("Flat armor added, per progression state.", new AcceptableValueRange(0f, 20f))); + DamageBonusPerState = config.Bind(combat, "Damage Bonus Per State", 5f, + new ConfigDescription("Flat physical damage added to equipped weapons, per progression state.", new AcceptableValueRange(0f, 20f))); + FallDamageReductionPerState = config.Bind(combat, "Fall Damage Reduction Per State", 0.1f, + new ConfigDescription("Fall damage reduction added per progression state, capped at 100%.", new AcceptableValueRange(0f, 1f))); + SpeedBonusPerState = config.Bind(combat, "Speed Bonus Per State", 0.03f, + new ConfigDescription("Move speed multiplier added, per progression state.", new AcceptableValueRange(0f, 0.2f))); + JumpBonusPerState = config.Bind(combat, "Jump Bonus Per State", 0.03f, + new ConfigDescription("Jump height multiplier added, per progression state.", new AcceptableValueRange(0f, 0.2f))); + SunSicknessDuration = config.Bind(combat, "Sun Sickness Duration", 60f, + new ConfigDescription("Seconds of forced human form after being reverted by sunrise.", new AcceptableValueRange(0f, 300f))); + + const string buffs = "Fenrir - Form Buffs"; + BindNote(config, buffs, "Note: these values need a relog to take effect."); + FullFormSpeedBonus = config.Bind(buffs, "Full Form Speed Bonus", 1.0f, + new ConfigDescription("Speed multiplier bonus while in Fenring or Cultist form.", new AcceptableValueRange(0f, 3f))); + FullFormJumpBonus = config.Bind(buffs, "Full Form Jump Bonus", 1.0f, + new ConfigDescription("Jump multiplier bonus while in Fenring or Cultist form.", new AcceptableValueRange(0f, 3f))); + FullFormFallDamageReduction = config.Bind(buffs, "Full Form Fall Damage Reduction", 1.0f, + new ConfigDescription("Fall damage reduction while in Fenring or Cultist form (1 = immune).", new AcceptableValueRange(0f, 1f))); + WolfFormSpeedBonus = config.Bind(buffs, "Wolf Form Speed Bonus", 0.5f, + new ConfigDescription("Speed multiplier bonus while in Wolf or Ulv form.", new AcceptableValueRange(0f, 3f))); + WolfFormFallDamageReduction = config.Bind(buffs, "Wolf Form Fall Damage Reduction", 0.5f, + new ConfigDescription("Fall damage reduction while in Wolf or Ulv form.", new AcceptableValueRange(0f, 1f))); + FormStaminaRegenMultiplier = config.Bind(buffs, "Stamina Regen Multiplier", 1.3f, + new ConfigDescription("Stamina regen multiplier in any transformed state.", new AcceptableValueRange(1f, 5f))); + FormStaminaDrainReduction = config.Bind(buffs, "Stamina Drain Reduction", 0.2f, + new ConfigDescription("Reduction to running stamina drain in any transformed state.", new AcceptableValueRange(0f, 1f))); + + const string fenring = "Fenrir - Fenring Attacks"; + FenringHeavyClawDamage = config.Bind(fenring, "Heavy Claw Damage", 110f, + new ConfigDescription("Base damage of the heavy claw (Right Mouse), before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f))); + FenringLightClawDamage = config.Bind(fenring, "Light Claw Damage", 60f, + new ConfigDescription("Base damage of the light claw (Left Mouse), before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f))); + FenringJumpAttackDamage = config.Bind(fenring, "Jump Attack Damage", 95f, + new ConfigDescription("Base damage of the leaping attack (Middle Mouse), before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f))); + FenringJumpDashSpeed = config.Bind(fenring, "Jump Dash Speed", 31.5f, + new ConfigDescription("Forward speed during the leap.", new AcceptableValueRange(0f, 60f))); + FenringJumpDashUpwardSpeed = config.Bind(fenring, "Jump Dash Upward Speed", 13.1f, + new ConfigDescription("Upward speed during the first half of the leap.", new AcceptableValueRange(0f, 30f))); + FenringAttackRadius = config.Bind(fenring, "Attack Radius", 2.5f, + new ConfigDescription("Hit-sweep radius for all three attacks.", new AcceptableValueRange(1f, 10f))); + FenringPushForce = config.Bind(fenring, "Push Force", 30f, + new ConfigDescription("Knockback applied on a hit.", new AcceptableValueRange(0f, 100f))); + + const string cultist = "Fenrir - Cultist Attacks"; + CultistClawDamage = config.Bind(cultist, "Claw Damage", 85f, + new ConfigDescription("Base damage of the single claw (Left Mouse), before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f))); + CultistDoubleClawDamage = config.Bind(cultist, "Double Claw Damage", 140f, + new ConfigDescription("Base damage of the double claw (Middle Mouse), before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f))); + CultistAttackRadius = config.Bind(cultist, "Claw Attack Radius", 2.5f, + new ConfigDescription("Hit-sweep radius for both claw attacks.", new AcceptableValueRange(1f, 10f))); + CultistPushForce = config.Bind(cultist, "Claw Push Force", 30f, + new ConfigDescription("Knockback applied by a claw hit.", new AcceptableValueRange(0f, 100f))); + CultistFireDamagePerTick = config.Bind(cultist, "Fire Damage Per Tick", 20f, + new ConfigDescription("Fire damage per 0.2s tick while channeling (Right Mouse held), before the Elemental Magic skill bonus.", new AcceptableValueRange(0f, 100f))); + CultistFireEitrDrainPerSecond = config.Bind(cultist, "Fire Eitr Drain Per Second", 12.5f, + new ConfigDescription("Eitr spent per second while channeling fire.", new AcceptableValueRange(0f, 100f))); + CultistFireMagicSkillScaling = config.Bind(cultist, "Fire Magic Skill Scaling", 0.5f, + new ConfigDescription("Extra fire damage per tick, per point of Elemental Magic skill.", new AcceptableValueRange(0f, 5f))); + CultistFireAttackRadius = config.Bind(cultist, "Fire Attack Radius", 3f, + new ConfigDescription("Hit-sweep radius for the fire breath.", new AcceptableValueRange(1f, 15f))); + + const string wolf = "Fenrir - Wolf Attacks"; + WolfAttack1Damage = config.Bind(wolf, "Attack 1 Damage", 40f, + new ConfigDescription("Base damage of the Left Mouse attack, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 300f))); + WolfAttack2Damage = config.Bind(wolf, "Attack 2 Damage", 60f, + new ConfigDescription("Base damage of the Right Mouse attack, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 300f))); + WolfAttack3Damage = config.Bind(wolf, "Attack 3 Damage", 80f, + new ConfigDescription("Base damage of the Middle Mouse attack, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 300f))); + WolfAttackRadius = config.Bind(wolf, "Attack Radius", 2.0f, + new ConfigDescription("Hit-sweep radius for all three attacks.", new AcceptableValueRange(1f, 10f))); + WolfPushForce = config.Bind(wolf, "Push Force", 20f, + new ConfigDescription("Knockback applied on a hit.", new AcceptableValueRange(0f, 100f))); + + const string ulv = "Fenrir - Ulv Attacks"; + UlvBiteDamage = config.Bind(ulv, "Bite Damage", 40f, + new ConfigDescription("Base damage of the Left Mouse bite, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 300f))); + UlvHeavyBiteDamage = config.Bind(ulv, "Heavy Bite Damage", 60f, + new ConfigDescription("Base damage of the Right Mouse bite, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 300f))); + UlvJumpAttackDamage = config.Bind(ulv, "Jump Attack Damage", 80f, + new ConfigDescription("Base damage of the leaping Middle Mouse attack, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 300f))); + UlvLeapSpeed = config.Bind(ulv, "Leap Speed", 18f, + new ConfigDescription("Forward speed during the leap attack.", new AcceptableValueRange(0f, 40f))); + UlvAttackRadius = config.Bind(ulv, "Attack Radius", 2.0f, + new ConfigDescription("Hit-sweep radius for all three attacks.", new AcceptableValueRange(1f, 10f))); + UlvPushForce = config.Bind(ulv, "Push Force", 25f, + new ConfigDescription("Knockback applied on a hit.", new AcceptableValueRange(0f, 100f))); + } + + /// + /// A non-editable line of text, standing in for the caveat comment this class carries at + /// the top - Configuration Manager has no label widget of its own, so this binds a real + /// (unused) bool ConfigEntry and replaces its value widget with nothing via CustomDrawer, + /// same trick used for section dividers earlier in this mod's config work. A high Order + /// keeps it above the section's other entries, which are left at the default Order and so + /// sort alphabetically among themselves. + /// + private static void BindNote(ConfigFile config, string section, string text) + { + config.Bind(section, text, false, new ConfigDescription( + "", null, new ConfigurationManagerAttributes + { + Order = 100, + CustomDrawer = DrawNothing, + HideDefaultButton = true, + ReadOnly = true + })); + } + + private static void DrawNothing(ConfigEntryBase entry) { } + } +} diff --git a/JotunnModStub/Fenrir/FenrirProgression.cs b/JotunnModStub/Fenrir/FenrirProgression.cs index 6a14551..94af2c2 100644 --- a/JotunnModStub/Fenrir/FenrirProgression.cs +++ b/JotunnModStub/Fenrir/FenrirProgression.cs @@ -32,27 +32,27 @@ namespace RacesOfValheim public static float GetArmorBonus(int state) { - return 3f * state; + return FenrirConfig.ArmorBonusPerState.Value * state; } public static float GetDamageBonus(int state) { - return 5f * state; + return FenrirConfig.DamageBonusPerState.Value * state; } public static float GetFallDamageModifier(int state) { - return Mathf.Clamp(-0.1f * state, -1f, 0f); + return Mathf.Clamp(-FenrirConfig.FallDamageReductionPerState.Value * state, -1f, 0f); } public static float GetSpeedModifier(int state) { - return 0.03f * state; + return FenrirConfig.SpeedBonusPerState.Value * state; } public static float GetJumpModifier(int state) { - return 0.03f * state; + return FenrirConfig.JumpBonusPerState.Value * state; } // --- Transformation Rules for Keys --- diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs index fc2e349..1bf827d 100644 --- a/JotunnModStub/Fenrir/FenrirRace.cs +++ b/JotunnModStub/Fenrir/FenrirRace.cs @@ -67,32 +67,32 @@ namespace RacesOfValheim { formBuffSE = ScriptableObject.CreateInstance(); formBuffSE.name = "SE_FenrirForm"; formBuffSE.m_name = "Bestial Fury"; - formBuffSE.m_speedModifier = 1.0f; - formBuffSE.m_jumpModifier = new Vector3(0, 1.0f, 0); - formBuffSE.m_fallDamageModifier = -1f; - formBuffSE.m_staminaRegenMultiplier = 1.3f; - formBuffSE.m_runStaminaDrainModifier = -0.2f; + formBuffSE.m_speedModifier = FenrirConfig.FullFormSpeedBonus.Value; + formBuffSE.m_jumpModifier = new Vector3(0, FenrirConfig.FullFormJumpBonus.Value, 0); + formBuffSE.m_fallDamageModifier = -FenrirConfig.FullFormFallDamageReduction.Value; + formBuffSE.m_staminaRegenMultiplier = FenrirConfig.FormStaminaRegenMultiplier.Value; + formBuffSE.m_runStaminaDrainModifier = -FenrirConfig.FormStaminaDrainReduction.Value; formBuffSE.m_icon = fenringTrophyIcon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(formBuffSE, fixReference: false)); cultistFormBuffSE = ScriptableObject.CreateInstance(); cultistFormBuffSE.name = "SE_CultistForm"; cultistFormBuffSE.m_name = "Cultist Fury"; - cultistFormBuffSE.m_speedModifier = 1.0f; - cultistFormBuffSE.m_jumpModifier = new Vector3(0, 1.0f, 0); - cultistFormBuffSE.m_fallDamageModifier = -1f; - cultistFormBuffSE.m_staminaRegenMultiplier = 1.3f; - cultistFormBuffSE.m_runStaminaDrainModifier = -0.2f; + cultistFormBuffSE.m_speedModifier = FenrirConfig.FullFormSpeedBonus.Value; + cultistFormBuffSE.m_jumpModifier = new Vector3(0, FenrirConfig.FullFormJumpBonus.Value, 0); + cultistFormBuffSE.m_fallDamageModifier = -FenrirConfig.FullFormFallDamageReduction.Value; + cultistFormBuffSE.m_staminaRegenMultiplier = FenrirConfig.FormStaminaRegenMultiplier.Value; + cultistFormBuffSE.m_runStaminaDrainModifier = -FenrirConfig.FormStaminaDrainReduction.Value; cultistFormBuffSE.m_icon = fenringTrophyIcon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(cultistFormBuffSE, fixReference: false)); wolfFormBuffSE = ScriptableObject.CreateInstance(); wolfFormBuffSE.name = "SE_WolfForm"; wolfFormBuffSE.m_name = "Wolf Senses"; - wolfFormBuffSE.m_speedModifier = 0.5f; - wolfFormBuffSE.m_fallDamageModifier = -0.5f; - wolfFormBuffSE.m_staminaRegenMultiplier = 1.3f; - wolfFormBuffSE.m_runStaminaDrainModifier = -0.2f; + wolfFormBuffSE.m_speedModifier = FenrirConfig.WolfFormSpeedBonus.Value; + wolfFormBuffSE.m_fallDamageModifier = -FenrirConfig.WolfFormFallDamageReduction.Value; + wolfFormBuffSE.m_staminaRegenMultiplier = FenrirConfig.FormStaminaRegenMultiplier.Value; + wolfFormBuffSE.m_runStaminaDrainModifier = -FenrirConfig.FormStaminaDrainReduction.Value; wolfFormBuffSE.m_icon = fenringTrophyIcon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(wolfFormBuffSE, fixReference: false)); } @@ -125,8 +125,8 @@ namespace RacesOfValheim { } else if (!isNight && wasNight) { - // Sunrise: force revert and block for 60 seconds - sunSicknessTimer = 60f; + // Sunrise: force revert and block transforming again for a while + sunSicknessTimer = FenrirConfig.SunSicknessDuration.Value; ForceRevert(); } wasNight = isNight; @@ -147,9 +147,9 @@ namespace RacesOfValheim { int state = BossProgressionManager.GetCurrentProgressionState(); - if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(FenrirProgression.GetGKeyRules(state)); return; } - if (Input.GetKeyDown(KeyCode.H)) { TryTransformWithRules(FenrirProgression.GetHKeyRules(state)); return; } - if (Input.GetKeyDown(KeyCode.J)) { TryTransformWithRules(FenrirProgression.GetJKeyRules(state)); return; } + if (FenrirConfig.WolfFormKey.Value.IsDown()) { TryTransformWithRules(FenrirProgression.GetGKeyRules(state)); return; } + if (FenrirConfig.FenrirFormKey.Value.IsDown()) { TryTransformWithRules(FenrirProgression.GetHKeyRules(state)); return; } + if (FenrirConfig.CultistFormKey.Value.IsDown()) { TryTransformWithRules(FenrirProgression.GetJKeyRules(state)); return; } } private void TryTransformWithRules(FenrirProgression.FormRules rules) diff --git a/JotunnModStub/Furling/FurlingConfig.cs b/JotunnModStub/Furling/FurlingConfig.cs new file mode 100644 index 0000000..f6ebb4e --- /dev/null +++ b/JotunnModStub/Furling/FurlingConfig.cs @@ -0,0 +1,88 @@ +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// Every tunable number behind the Furling's abilities, bound as BepInEx ConfigEntry so they + /// show up in Configuration Manager without touching code - see + /// CONFIGURATION-MANAGER-HOWTO.md. Bound once, from RacesOfValheim.Awake(). One section per + /// topic (matches the other races' layout). + /// + /// No keybinds section: every Furling ability is passive, triggered automatically by tier, + /// biome, or combat events rather than a key press - unlike every other race so far. + /// + /// Tier-gate thresholds (which progression state unlocks each ability) are left as-is, same + /// boundary drawn for every other race's progression table - not exposed here. "Dance of the + /// Dead" (tier 4+, doubles alchemy/ammo craft yield) has no numeric knob either: it works by + /// crafting a second copy of the output rather than multiplying a configurable amount, so + /// there is nothing here to bind. + /// + public static class FurlingConfig + { + // ─── Passive combat (always active, no tier gate) ──────────────────── + public static ConfigEntry RunSpeedBonus; + public static ConfigEntry WeaponSkillXPMultiplier; + public static ConfigEntry IgniteOnHitMinFireDamage; + + // ─── Master of Shadows (tier 2+) ────────────────────────────────────── + public static ConfigEntry StealthNoiseRangeThreshold; + + // ─── The Wickerman (tier 3+) ─────────────────────────────────────────── + public static ConfigEntry WickermanFireResistMultiplier; + public static ConfigEntry PoisonResistMultiplier; + public static ConfigEntry FireArrowMinDamage; + + // ─── Grave Robber (tier 5+) ──────────────────────────────────────────── + public static ConfigEntry TrophyDropMultiplier; + public static ConfigEntry TrophyDoublingRadius; + public static ConfigEntry CoinsPerStarMin; + public static ConfigEntry CoinsPerStarMax; + + // ─── The King is Dead (tier 6+) ─────────────────────────────────────── + public static ConfigEntry PlainsSkillXPMultiplier; + + // ─── In the Mist (tier 7+) ───────────────────────────────────────────── + public static ConfigEntry EitrFoodDigestionSlowdown; + + public static void Bind(ConfigFile config) + { + const string combat = "Furling - Passive Combat"; + RunSpeedBonus = config.Bind(combat, "Run Speed Bonus", 0.1f, + new ConfigDescription("Move speed multiplier bonus, always active.", new AcceptableValueRange(0f, 1f))); + WeaponSkillXPMultiplier = config.Bind(combat, "Weapon Skill XP Multiplier", 2f, + new ConfigDescription("Multiplies XP gain for every weapon skill, always active.", new AcceptableValueRange(0.5f, 5f))); + IgniteOnHitMinFireDamage = config.Bind(combat, "Ignite On Hit Min Fire Damage", 10f, + new ConfigDescription("Minimum fire damage added to a physical hit, tier 8+ (Through Fire and Flames).", new AcceptableValueRange(0f, 100f))); + + const string shadows = "Furling - Master of Shadows"; + StealthNoiseRangeThreshold = config.Bind(shadows, "Noise Range Threshold", 15f, + new ConfigDescription("Noise events at or below this range are suppressed entirely, tier 2+.", new AcceptableValueRange(0f, 50f))); + + const string wickerman = "Furling - The Wickerman"; + WickermanFireResistMultiplier = config.Bind(wickerman, "Fire Resist Multiplier", 0.5f, + new ConfigDescription("Multiplies incoming fire damage, tier 3+ (full immunity replaces this at tier 8+).", new AcceptableValueRange(0f, 1f))); + PoisonResistMultiplier = config.Bind(wickerman, "Poison Resist Multiplier", 0.5f, + new ConfigDescription("Multiplies incoming poison damage, tier 3+ and tier 8+.", new AcceptableValueRange(0f, 1f))); + FireArrowMinDamage = config.Bind(wickerman, "Fire Arrow Min Damage", 22f, + new ConfigDescription("Minimum fire damage added to bow attacks, tier 3+.", new AcceptableValueRange(0f, 100f))); + + const string graveRobber = "Furling - Grave Robber"; + TrophyDropMultiplier = config.Bind(graveRobber, "Trophy Drop Multiplier", 2f, + new ConfigDescription("Multiplies trophy drop counts from non-boss kills within range, tier 5+.", new AcceptableValueRange(1f, 5f))); + TrophyDoublingRadius = config.Bind(graveRobber, "Trophy Doubling Radius", 25f, + new ConfigDescription("Meters from the player a kill must be within for its trophy drops to be doubled.", new AcceptableValueRange(1f, 100f))); + CoinsPerStarMin = config.Bind(graveRobber, "Coins Per Star Min", 1, + new ConfigDescription("Minimum bonus coins dropped, per star the kill had.", new AcceptableValueRange(0, 50))); + CoinsPerStarMax = config.Bind(graveRobber, "Coins Per Star Max", 25, + new ConfigDescription("Maximum bonus coins dropped, per star the kill had.", new AcceptableValueRange(0, 100))); + + const string kingIsDead = "Furling - The King Is Dead"; + PlainsSkillXPMultiplier = config.Bind(kingIsDead, "Plains Skill XP Multiplier", 2f, + new ConfigDescription("Multiplies XP gain for every skill while standing in the Plains biome, tier 6+.", new AcceptableValueRange(0.5f, 5f))); + + const string mist = "Furling - In the Mist"; + EitrFoodDigestionSlowdown = config.Bind(mist, "Eitr Food Digestion Slowdown", 0.5f, + new ConfigDescription("Fraction of normal speed at which eitr (blue) food is consumed, tier 7+ (0.5 = lasts twice as long).", new AcceptableValueRange(0.1f, 1f))); + } + } +} diff --git a/JotunnModStub/Furling/FurlingFireAbility.cs b/JotunnModStub/Furling/FurlingFireAbility.cs index baf1920..9d55afe 100644 --- a/JotunnModStub/Furling/FurlingFireAbility.cs +++ b/JotunnModStub/Furling/FurlingFireAbility.cs @@ -136,7 +136,7 @@ namespace RacesOfValheim hit.m_damage.m_pierce > 0 || hit.m_damage.m_chop > 0 || hit.m_damage.m_pickaxe > 0) { - hit.m_damage.m_fire = Mathf.Max(hit.m_damage.m_fire, 10f); + hit.m_damage.m_fire = Mathf.Max(hit.m_damage.m_fire, FurlingConfig.IgniteOnHitMinFireDamage.Value); } } diff --git a/JotunnModStub/Furling/FurlingPatches.cs b/JotunnModStub/Furling/FurlingPatches.cs index c4c0ed8..8e0167c 100644 --- a/JotunnModStub/Furling/FurlingPatches.cs +++ b/JotunnModStub/Furling/FurlingPatches.cs @@ -42,7 +42,7 @@ namespace RacesOfValheim { if (__instance == null || __instance != Player.m_localPlayer) return; if (!FurlingRace.IsFurling()) return; - __result *= 1.1f; + __result *= 1f + FurlingConfig.RunSpeedBonus.Value; } } @@ -323,14 +323,14 @@ namespace RacesOfValheim if (isWeaponSkill) { - factor *= 2f; + factor *= FurlingConfig.WeaponSkillXPMultiplier.Value; } else if (BossProgressionManager.GetCurrentProgressionState() >= 6) { - // The King is Dead: in Plains, ALL other skills (including magic) get 2x XP + // The King is Dead: in Plains, ALL other skills (including magic) get bonus XP if (EnvMan.instance != null && EnvMan.instance.GetCurrentBiome() == Heightmap.Biome.Plains) { - factor *= 2f; + factor *= FurlingConfig.PlainsSkillXPMultiplier.Value; } } } @@ -347,7 +347,7 @@ namespace RacesOfValheim // Check if it's nighttime or inside a dungeon if (BossProgressionManager.GetCurrentProgressionState() >= 2) // Master of Shadows (Eikthyr) { - if (range <= 15f) + if (range <= FurlingConfig.StealthNoiseRangeThreshold.Value) { return false; } @@ -368,12 +368,12 @@ namespace RacesOfValheim if (state >= 8) // Through Fire and Flames (Fader): full fire immunity { hit.m_damage.m_fire = 0f; - if (hit.m_damage.m_poison > 0) hit.m_damage.m_poison *= 0.5f; + if (hit.m_damage.m_poison > 0) hit.m_damage.m_poison *= FurlingConfig.PoisonResistMultiplier.Value; } - else if (state >= 3) // The Wickerman: -50% fire and poison + else if (state >= 3) // The Wickerman: reduced fire and poison { - if (hit.m_damage.m_fire > 0) hit.m_damage.m_fire *= 0.5f; - if (hit.m_damage.m_poison > 0) hit.m_damage.m_poison *= 0.5f; + if (hit.m_damage.m_fire > 0) hit.m_damage.m_fire *= FurlingConfig.WickermanFireResistMultiplier.Value; + if (hit.m_damage.m_poison > 0) hit.m_damage.m_poison *= FurlingConfig.PoisonResistMultiplier.Value; } } } @@ -393,10 +393,11 @@ namespace RacesOfValheim (ammo != null && ammo.m_shared.m_skillType == Skills.SkillType.Bows)) { // If the arrow doesn't already have significant fire damage, add it - if (hitData != null && hitData.m_damage.m_fire < 22f) + float minFireDamage = FurlingConfig.FireArrowMinDamage.Value; + if (hitData != null && hitData.m_damage.m_fire < minFireDamage) { // Adds fire damage equivalent to a standard fire arrow - hitData.m_damage.m_fire = Mathf.Max(hitData.m_damage.m_fire, 22f); + hitData.m_damage.m_fire = Mathf.Max(hitData.m_damage.m_fire, minFireDamage); } } } @@ -494,7 +495,7 @@ namespace RacesOfValheim if (character != null && (character.IsBoss() || character.gameObject.name.ToLower().Contains("boss"))) return; float distance = Vector3.Distance(Player.m_localPlayer.transform.position, __instance.transform.position); - if (distance > 25f) return; + if (distance > FurlingConfig.TrophyDoublingRadius.Value) return; var newList = new System.Collections.Generic.List>(); foreach (var drop in __result) @@ -506,7 +507,7 @@ namespace RacesOfValheim var itemDrop = go.GetComponent(); if (itemDrop != null && itemDrop.m_itemData.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Trophy) { - amount *= 2; + amount = Mathf.RoundToInt(amount * FurlingConfig.TrophyDropMultiplier.Value); } } newList.Add(new System.Collections.Generic.KeyValuePair(go, amount)); @@ -519,7 +520,7 @@ namespace RacesOfValheim GameObject coinsPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab("Coins"); if (coinsPrefab != null) { - int extraCoins = stars * UnityEngine.Random.Range(1, 26); + int extraCoins = stars * UnityEngine.Random.Range(FurlingConfig.CoinsPerStarMin.Value, FurlingConfig.CoinsPerStarMax.Value + 1); newList.Add(new System.Collections.Generic.KeyValuePair(coinsPrefab, extraCoins)); } } @@ -635,8 +636,8 @@ namespace RacesOfValheim // Blue food = eitr > 0 if (food.m_item.m_shared.m_foodEitr > 0f) { - // Give back half of dt that vanilla subtracted - food.m_time += dt * 0.5f; + // Give back the slowed-down fraction of dt that vanilla subtracted + food.m_time += dt * (1f - FurlingConfig.EitrFoodDigestionSlowdown.Value); // Clamp to max burn time so we don't exceed the original duration float maxTime = food.m_item.m_shared.m_foodBurnTime; if (food.m_time > maxTime) food.m_time = maxTime; diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index 58f907e..0ddbc5f 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -109,10 +109,10 @@ namespace RacesOfValheim sb.AppendLine($"[Bonemass Unlock] Kin of the Traders (Passive): Haldor and Hildir know their own. Their prices drop by {rules.TraderBuyDiscount * 100f:0}% for you, and what they pay for your trophies and hunting rewards rises by {rules.TraderSellBonus * 100f:0}%.\n"); if (rules.RunicPing) - sb.AppendLine($"[Yagluth Unlock] Runic Ping ('{DvergarConfig.RunicPingKey}' Key): Spend {DvergarConfig.RunicPingEitrCost:0} eitr to send a pulse through the stone. For {DvergarConfig.RunicPingDuration:0} seconds every ore vein and every hidden enemy within {DvergarConfig.RunicPingRadius:0} meters is lit for you alone.\n"); + sb.AppendLine($"[Yagluth Unlock] Runic Ping ('{DvergarConfigManagement.RunicPingKey.Value}' Key): Spend {DvergarConfig.RunicPingEitrCost:0} eitr to send a pulse through the stone. For {DvergarConfig.RunicPingDuration:0} seconds every ore vein and every hidden enemy within {DvergarConfig.RunicPingRadius:0} meters is lit for you alone.\n"); if (rules.RunicOvercharge) - sb.AppendLine($"[Fader Unlock] Runic Overcharge ('{DvergarConfig.RunicOverchargeKey}' Key): Spend {DvergarConfig.RunicOverchargeEitrCost:0} eitr to load the runes. Your next blow with a favoured weapon lands with {DvergarConfig.RunicOverchargeMultiplier:0}x its weight. Hold the charge no longer than {DvergarConfig.RunicOverchargeWindow:0} seconds or it bleeds away.\n"); + sb.AppendLine($"[Fader Unlock] Runic Overcharge ('{DvergarConfigManagement.RunicOverchargeKey.Value}' Key): Spend {DvergarConfig.RunicOverchargeEitrCost:0} eitr to load the runes. Your next blow with a favoured weapon lands with {DvergarConfig.RunicOverchargeMultiplier:0}x its weight. Hold the charge no longer than {DvergarConfig.RunicOverchargeWindow:0} seconds or it bleeds away.\n"); knownTexts["Dvergar Secrets"] = sb.ToString(); } diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index c1bf198..09d87f8 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -24,6 +24,18 @@ namespace RacesOfValheim private void Awake() { Instance = this; + // Bound in alphabetical order by race, since Configuration Manager's category list + // follows bind order rather than sorting itself - confirmed from the Skadi/Aswid + // ordering in-game. Keep new races' Bind() calls slotted in alphabetically here. + AswidConfig.Bind(Config); + DraughConfig.Bind(Config); + DvergarConfigManagement.Bind(Config); + FenrirConfig.Bind(Config); + FurlingConfig.Bind(Config); + SkadiConfig.Bind(Config); + SkeletonConfig.Bind(Config); + TrentaConfigManagement.Bind(Config); + TrolConfig.Bind(Config); harmony.PatchAll(); gameObject.AddComponent(); gameObject.AddComponent(); diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index 4b797ce..b325194 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -60,24 +60,26 @@ namespace RacesOfValheim return live != null && live.Form == formRules.Form && live.CanAttackInForm; } - private const float ATTACK_COOLDOWN = 3f; + // Read from SkadiConfig (BepInEx Config) rather than fixed constants, so dragon-form + // attacks can be retuned from Configuration Manager - see CONFIGURATION-MANAGER-HOWTO.md. + private static float ATTACK_COOLDOWN => SkadiConfig.FormAttackCooldown.Value; // Ranged volleys charge per projectile rather than a flat fee, so the 20- and 60-shard // breaths cost what they are worth instead of the same as a three-shard drake spit. // Stamina rather than eitr, for the same reason the Cold Spell uses it: eitr food only // exists from the Mistlands on, while the drake form arrives at the Elder, so an eitr // cost left the earliest dragon tiers with no attack they could actually pay for. - private const float STAMINA_PER_PROJECTILE = 1.5f; + private static float STAMINA_PER_PROJECTILE => SkadiConfig.StaminaPerProjectile.Value; // Ceiling so the widest breath stays castable: 60 shards would otherwise ask 90 stamina. - private const float MAX_VOLLEY_STAMINA = 85f; + private static float MAX_VOLLEY_STAMINA => SkadiConfig.MaxVolleyStamina.Value; // Melee costs nothing at all - it is the baseline attack that has to work at every tier, // including the long stretch where the player has no eitr whatsoever. - private const float MELEE_RADIUS = 3f; - private const float MODER_MELEE_DAMAGE = 90f; - private const float FADER_MELEE_DAMAGE = 120f; - private const float FADER_SPIN_DAMAGE = 100f; - private const float FADER_SPIN_RADIUS = 5f; + private static float MELEE_RADIUS => SkadiConfig.MeleeRadius.Value; + private static float MODER_MELEE_DAMAGE => SkadiConfig.ModerMeleeDamage.Value; + private static float FADER_MELEE_DAMAGE => SkadiConfig.FaderMeleeDamage.Value; + private static float FADER_SPIN_DAMAGE => SkadiConfig.FaderSpinDamage.Value; + private static float FADER_SPIN_RADIUS => SkadiConfig.FaderSpinRadius.Value; private void Start() { @@ -93,8 +95,8 @@ namespace RacesOfValheim { if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return; - // Handle Flight Toggle (RMB) - Disabled for Fader - if (RaceInput.Allowed && Input.GetMouseButtonDown(1) && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon) + // Handle Flight Toggle (Right Mouse by default, rebindable) - Disabled for Fader + if (RaceInput.Allowed && SkadiConfig.FlightToggleKey.Value.IsDown() && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon) { if (!isFlying && !isLanding) { @@ -148,24 +150,26 @@ namespace RacesOfValheim anim.SetFloat("forward_speed", speed); } - // Handle Attack + // Handle Attack - each trigger is a rebindable SkadiConfig keybind; the button id + // passed into PerformAttackCoroutine (0/1/2) still selects which attack runs, exactly + // as it did when these were raw mouse-button checks. if (CanAttackNow() && RaceInput.Allowed) { - if (Input.GetMouseButtonDown(0)) + if (SkadiConfig.PrimaryAttackKey.Value.IsDown()) { if (HasAttackForButton(0) && Time.time - lastAttackTime >= ATTACK_COOLDOWN) { StartCoroutine(PerformAttackCoroutine(0)); } } - else if (Input.GetMouseButtonDown(2)) // MMB + else if (SkadiConfig.BreathAttackKey.Value.IsDown()) { if (Time.time - lastAttackTime >= ATTACK_COOLDOWN) { StartCoroutine(PerformAttackCoroutine(2)); } } - else if (Input.GetMouseButtonDown(1) && formRules.Form == SkadiProgression.FormType.SkeletonDragon) // RMB for Fader Spin + else if (SkadiConfig.SpinAttackKey.Value.IsDown() && formRules.Form == SkadiProgression.FormType.SkeletonDragon) // Fader Spin { if (Time.time - lastAttackTime >= ATTACK_COOLDOWN) { diff --git a/JotunnModStub/Skadi/SkadiConfig.cs b/JotunnModStub/Skadi/SkadiConfig.cs new file mode 100644 index 0000000..81134c3 --- /dev/null +++ b/JotunnModStub/Skadi/SkadiConfig.cs @@ -0,0 +1,179 @@ +using UnityEngine; +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// Every tunable number and keybind behind Skadi's abilities and special attacks, bound as + /// BepInEx ConfigEntry so they show up in Configuration Manager without touching code - see + /// CONFIGURATION-MANAGER-HOWTO.md. Bound once, from RacesOfValheim.Awake(). + /// + /// One section per sub-group (rather than everything under one "Skadi" section) so each shows + /// up as its own entry in Configuration Manager's category list - collapsing them into a + /// single section made that list disappear. Keybinds is bound first, before its section + /// otherwise sorts alphabetically among the rest, since it is the group most worth reaching + /// quickly; within it every entry carries an explicit Order (Configuration Manager otherwise + /// sorts a section's own entries alphabetically) so it reads attack -> cast -> breath -> spin + /// -> flight -> the three transform keys, the order abilities actually chain in a fight, + /// rather than alphabetically. + /// + public static class SkadiConfig + { + // ─── Keybinds ────────────────────────────────────────────────────────── + // Defaults match today's fixed inputs exactly, so nobody's controls change until they + // open Configuration Manager (or the .cfg) and rebind one on purpose. + public static ConfigEntry PrimaryAttackKey; + public static ConfigEntry ColdSpellKey; + public static ConfigEntry BreathAttackKey; + public static ConfigEntry SpinAttackKey; + public static ConfigEntry FlightToggleKey; + public static ConfigEntry DrakeFormKey; + public static ConfigEntry ModerFormKey; + public static ConfigEntry FaderFormKey; + + // ─── Cold Spell (human form) ───────────────────────────────────────── + public static ConfigEntry SpellStaminaCost; + public static ConfigEntry SpellCooldown; + public static ConfigEntry ImprovedSpellCooldown; + public static ConfigEntry SpellBaseDamage; + public static ConfigEntry SpellDamagePerState; + public static ConfigEntry ImprovedSpellShards; + public static ConfigEntry ImprovedSpellDamageBudget; + + // ─── Frost Aura (tier 7+ passive) ─────────────────────────────────────── + public static ConfigEntry AuraRadius; + public static ConfigEntry AuraDamagePerTick; + public static ConfigEntry AuraTickInterval; + + // ─── Passive combat ────────────────────────────────────────────────── + public static ConfigEntry BonusFrostDamagePerState; + + // ─── Dragon forms: scale ───────────────────────────────────────────── + public static ConfigEntry DrakeScale; + public static ConfigEntry ModerScale; + public static ConfigEntry FaderScale; + + // ─── Dragon forms: attacks ──────────────────────────────────────────── + public static ConfigEntry FormAttackCooldown; + public static ConfigEntry StaminaPerProjectile; + public static ConfigEntry MaxVolleyStamina; + public static ConfigEntry MeleeRadius; + public static ConfigEntry ModerMeleeDamage; + public static ConfigEntry FaderMeleeDamage; + public static ConfigEntry FaderSpinDamage; + public static ConfigEntry FaderSpinRadius; + + // ─── Directed flight (Drake/Moder) ──────────────────────────────────── + public static ConfigEntry FlightTurnSpeed; + public static ConfigEntry FlightGlideSpeed; + public static ConfigEntry FlightBoostSpeed; + public static ConfigEntry FlightSprintSpeed; + public static ConfigEntry FlightReverseSpeed; + public static ConfigEntry FlightLiftoffSpeed; + public static ConfigEntry FlightHoverSeconds; + public static ConfigEntry FlightSprintStaminaPerSecond; + + public static void Bind(ConfigFile config) + { + // Bound first, and ahead of everything else in the file, in case Configuration + // Manager's category list preserves bind order rather than sorting sections + // alphabetically - either way, the keybinds themselves still land in the requested + // order via the explicit Order below, which is guaranteed. + const string keybinds = "Skadi - Keybinds"; + int keyOrder = 8; + PrimaryAttackKey = config.Bind(keybinds, "Dragon Primary Attack", new KeyboardShortcut(KeyCode.Mouse0), + KeyDesc("Bite/claw attack in any dragon form.", keyOrder--)); + ColdSpellKey = config.Bind(keybinds, "Cold Spell Cast", new KeyboardShortcut(KeyCode.Mouse2), + KeyDesc("Casts the Cold Spell in human form, tier 1+.", keyOrder--)); + BreathAttackKey = config.Bind(keybinds, "Dragon Breath Attack", new KeyboardShortcut(KeyCode.Mouse2), + KeyDesc("Ranged breath/barrage attack in Moder and Skeleton Dragon form.", keyOrder--)); + SpinAttackKey = config.Bind(keybinds, "Fader Spin Attack", new KeyboardShortcut(KeyCode.Mouse1), + KeyDesc("360-degree spin attack, Skeleton Dragon form only.", keyOrder--)); + FlightToggleKey = config.Bind(keybinds, "Flight Toggle", new KeyboardShortcut(KeyCode.Mouse1), + KeyDesc("Takes off or lands while in Drake or Moder form.", keyOrder--)); + DrakeFormKey = config.Bind(keybinds, "Drake Form", new KeyboardShortcut(KeyCode.G), + KeyDesc("Transform into (or revert from) the Drake, tier 3+.", keyOrder--)); + ModerFormKey = config.Bind(keybinds, "Moder Form", new KeyboardShortcut(KeyCode.H), + KeyDesc("Transform into (or revert from) Moder, tier 5+.", keyOrder--)); + FaderFormKey = config.Bind(keybinds, "Fader Form", new KeyboardShortcut(KeyCode.J), + KeyDesc("Transform into (or revert from) the Skeleton Dragon, tier 8.", keyOrder--)); + + const string combat = "Skadi - Passive Combat"; + BonusFrostDamagePerState = config.Bind(combat, "Bonus Frost Damage Per State", 2f, + new ConfigDescription("Flat frost damage added to every hit the player lands, multiplied by the current progression state.", new AcceptableValueRange(0f, 10f))); + + const string spell = "Skadi - Cold Spell"; + SpellStaminaCost = config.Bind(spell, "Stamina Cost", 20f, + new ConfigDescription("Stamina spent per cast.", new AcceptableValueRange(0f, 100f))); + SpellCooldown = config.Bind(spell, "Cooldown", 1.5f, + new ConfigDescription("Seconds between casts before the improved (tier 6+) cast unlocks.", new AcceptableValueRange(0.1f, 10f))); + ImprovedSpellCooldown = config.Bind(spell, "Improved Cooldown", 4f, + new ConfigDescription("Seconds between casts once the improved cast unlocks (tier 6+) - a burst rather than rapid-fire.", new AcceptableValueRange(0.1f, 15f))); + SpellBaseDamage = config.Bind(spell, "Base Damage", 15f, + new ConfigDescription("Frost damage at progression state 0, before the per-state bonus.", new AcceptableValueRange(0f, 200f))); + SpellDamagePerState = config.Bind(spell, "Damage Per Progression State", 8f, + new ConfigDescription("Extra frost damage added per boss progression state (0-8).", new AcceptableValueRange(0f, 50f))); + ImprovedSpellShards = config.Bind(spell, "Improved Shard Count", 10, + new ConfigDescription("Number of shards the improved (tier 6+) cast splits into.", new AcceptableValueRange(1, 30))); + ImprovedSpellDamageBudget = config.Bind(spell, "Improved Damage Budget", 1.6f, + new ConfigDescription("Total damage of an improved cast, as a multiple of one normal cast, before it is split across shards.", new AcceptableValueRange(0.5f, 5f))); + + const string aura = "Skadi - Frost Aura"; + AuraRadius = config.Bind(aura, "Radius", 3f, + new ConfigDescription("Meters from the player that the tier 7+ aura damages.", new AcceptableValueRange(1f, 15f))); + AuraDamagePerTick = config.Bind(aura, "Damage Per Tick", 10f, + new ConfigDescription("Frost damage dealt to every enemy in range, once per tick.", new AcceptableValueRange(0f, 50f))); + AuraTickInterval = config.Bind(aura, "Tick Interval", 1f, + new ConfigDescription("Seconds between aura damage ticks.", new AcceptableValueRange(0.1f, 5f))); + + const string scale = "Skadi - Dragon Form Scale"; + DrakeScale = config.Bind(scale, "Drake Scale", 0.9f, + new ConfigDescription("Model scale while transformed into the Drake (tier 3-4).", new AcceptableValueRange(0.1f, 2f))); + ModerScale = config.Bind(scale, "Moder Scale", 0.5f, + new ConfigDescription("Model scale while transformed into Moder (tier 5-7).", new AcceptableValueRange(0.1f, 2f))); + FaderScale = config.Bind(scale, "Fader Scale", 0.55f, + new ConfigDescription("Model scale while transformed into the Skeleton Dragon (tier 8).", new AcceptableValueRange(0.1f, 2f))); + + const string attacks = "Skadi - Dragon Form Attacks"; + FormAttackCooldown = config.Bind(attacks, "Attack Cooldown", 3f, + new ConfigDescription("Seconds between attacks in any dragon form.", new AcceptableValueRange(0.5f, 15f))); + StaminaPerProjectile = config.Bind(attacks, "Stamina Per Projectile", 1.5f, + new ConfigDescription("Stamina charged per shard/projectile in a ranged volley.", new AcceptableValueRange(0f, 10f))); + MaxVolleyStamina = config.Bind(attacks, "Max Volley Stamina", 85f, + new ConfigDescription("Stamina ceiling for a single volley, so the widest breath (60 shards) stays castable.", new AcceptableValueRange(0f, 300f))); + MeleeRadius = config.Bind(attacks, "Melee Radius", 3f, + new ConfigDescription("Hit-sweep radius for bite/claw attacks (Moder and Fader).", new AcceptableValueRange(1f, 15f))); + ModerMeleeDamage = config.Bind(attacks, "Moder Melee Damage", 90f, + new ConfigDescription("Base damage of Moder's bite/claw attacks, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f))); + FaderMeleeDamage = config.Bind(attacks, "Fader Melee Damage", 120f, + new ConfigDescription("Base damage of the Skeleton Dragon's bite/claw attacks, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f))); + FaderSpinDamage = config.Bind(attacks, "Fader Spin Damage", 100f, + new ConfigDescription("Base damage of the Skeleton Dragon's 360-degree spin attack.", new AcceptableValueRange(0f, 500f))); + FaderSpinRadius = config.Bind(attacks, "Fader Spin Radius", 5f, + new ConfigDescription("Hit-sweep radius for the Skeleton Dragon's spin attack.", new AcceptableValueRange(1f, 15f))); + + const string flight = "Skadi - Directed Flight"; + FlightTurnSpeed = config.Bind(flight, "Turn Speed", 120f, + new ConfigDescription("Degrees per second the dragon form turns to face its heading.", new AcceptableValueRange(10f, 360f))); + FlightGlideSpeed = config.Bind(flight, "Glide Speed", 5f, + new ConfigDescription("Speed while gliding unpowered (no W/S held).", new AcceptableValueRange(0f, 30f))); + FlightBoostSpeed = config.Bind(flight, "Boost Speed", 12f, + new ConfigDescription("Speed while holding W without sprinting.", new AcceptableValueRange(0f, 50f))); + FlightSprintSpeed = config.Bind(flight, "Sprint Speed", 22f, + new ConfigDescription("Speed while holding W and Shift, stamina permitting.", new AcceptableValueRange(0f, 60f))); + FlightReverseSpeed = config.Bind(flight, "Reverse Speed", 7f, + new ConfigDescription("Speed while beating backwards (S).", new AcceptableValueRange(0f, 30f))); + FlightLiftoffSpeed = config.Bind(flight, "Liftoff Speed", 9f, + new ConfigDescription("Climb speed while clawing out of water.", new AcceptableValueRange(0f, 30f))); + FlightHoverSeconds = config.Bind(flight, "Hover Seconds", 5f, + new ConfigDescription("How long level flight holds altitude after the last powered input before it starts to sink.", new AcceptableValueRange(0f, 30f))); + FlightSprintStaminaPerSecond = config.Bind(flight, "Sprint Stamina Per Second", 15f, + new ConfigDescription("Stamina drained per second while the sprint speed is actually granted.", new AcceptableValueRange(0f, 60f))); + } + + private static ConfigDescription KeyDesc(string description, int order) + { + return new ConfigDescription(description, null, new ConfigurationManagerAttributes { Order = order }); + } + } +} diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index 88cce4b..7e1c3cd 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -229,7 +229,7 @@ namespace RacesOfValheim var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState()); if (rules.BonusFrostDamage) { - hit.m_damage.m_frost += 2f * BossProgressionManager.GetCurrentProgressionState(); + hit.m_damage.m_frost += SkadiConfig.BonusFrostDamagePerState.Value * BossProgressionManager.GetCurrentProgressionState(); } } } @@ -250,17 +250,19 @@ namespace RacesOfValheim [HarmonyPatch(typeof(Character), "UpdateFlying")] public static class SkadiDirectedFlightPatch { - private const float TURN_SPEED = 120f; - private const float GLIDE_SPEED = 5f; - private const float BOOST_SPEED = 12f; - private const float SPRINT_SPEED = 22f; - private const float REVERSE_SPEED = 7f; + // Read from SkadiConfig (BepInEx Config) rather than fixed constants, so flight can be + // retuned from Configuration Manager - see CONFIGURATION-MANAGER-HOWTO.md. + private static float TURN_SPEED => SkadiConfig.FlightTurnSpeed.Value; + private static float GLIDE_SPEED => SkadiConfig.FlightGlideSpeed.Value; + private static float BOOST_SPEED => SkadiConfig.FlightBoostSpeed.Value; + private static float SPRINT_SPEED => SkadiConfig.FlightSprintSpeed.Value; + private static float REVERSE_SPEED => SkadiConfig.FlightReverseSpeed.Value; // Climbing out of water is deliberately slower than a powered climb in open air - the // wings are dragging themselves free, not racing. - private const float LIFTOFF_SPEED = 9f; - private const float HOVER_SECONDS = 5f; + private static float LIFTOFF_SPEED => SkadiConfig.FlightLiftoffSpeed.Value; + private static float HOVER_SECONDS => SkadiConfig.FlightHoverSeconds.Value; // Per second, drained only while the sprint is actually being granted. - private const float SPRINT_STAMINA_PER_SECOND = 15f; + private static float SPRINT_STAMINA_PER_SECOND => SkadiConfig.FlightSprintStaminaPerSecond.Value; // Tangent of the unpowered descent angle: 0.4 sinks at roughly 22 degrees below level. private const float DESCENT_SLOPE = 0.4f; // How much of the aim heading survives the climb out of water. Mostly up, with enough @@ -465,12 +467,13 @@ namespace RacesOfValheim } // Valheim binds its own SecondaryAttack action to Middle Mouse, the same button the - // Cold Spell casts on, so pressing it also swung the unarmed secondary - the kick that - // kept showing up alongside the cast no matter which animation trigger we used. For a - // Skadi who has the spell, Middle Mouse belongs to the spell. Keyed off the live button - // state rather than a flag set during our Update, so it does not depend on whether + // Cold Spell casts on by default, so pressing it also swung the unarmed secondary - + // the kick that kept showing up alongside the cast no matter which animation trigger + // we used. For a Skadi who has the spell, that button belongs to the spell. Keyed off + // the live button state (via the configured shortcut, so a rebind stays in sync) + // rather than a flag set during our Update, so it does not depend on whether // PlayerController's FixedUpdate happens to run first. - if (secondaryAttack && Input.GetMouseButton(2) && + if (secondaryAttack && SkadiConfig.ColdSpellKey.Value.IsPressed() && SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi()) { var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState()); diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index 558c1bf..f5cf719 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -27,17 +27,21 @@ namespace RacesOfValheim // Cold Spell tuning. Damage is 15 + 8 per progression state, so it runs from roughly 31 at // Eikthyr to 79 at Fader - deliberately a notch under the melee options of the other races // at each tier, which is the trade for hitting at range on a short cooldown. + // + // All values below read from SkadiConfig (BepInEx Config, see SkadiConfig.cs) rather than + // being fixed constants, so they can be retuned from Configuration Manager without a + // rebuild - see CONFIGURATION-MANAGER-HOWTO.md. public const string SPELL_COOLDOWN_SE = "SE_SkadiSpellCooldown"; public const string ATTACK_COOLDOWN_SE = "SE_SkadiAttackCooldown"; - private const float SPELL_STAMINA_COST = 20f; - private const float SPELL_COOLDOWN = 1.5f; - private const float IMPROVED_SPELL_COOLDOWN = 4f; - private const float SPELL_BASE_DAMAGE = 15f; - private const float SPELL_DAMAGE_PER_STATE = 8f; - private const int IMPROVED_SPELL_SHARDS = 10; + private static float SPELL_STAMINA_COST => SkadiConfig.SpellStaminaCost.Value; + private static float SPELL_COOLDOWN => SkadiConfig.SpellCooldown.Value; + private static float IMPROVED_SPELL_COOLDOWN => SkadiConfig.ImprovedSpellCooldown.Value; + private static float SPELL_BASE_DAMAGE => SkadiConfig.SpellBaseDamage.Value; + private static float SPELL_DAMAGE_PER_STATE => SkadiConfig.SpellDamagePerState.Value; + private static int IMPROVED_SPELL_SHARDS => SkadiConfig.ImprovedSpellShards.Value; // The improved cast spreads 1.6 casts worth of damage over its shards: wider, not stronger. - private const float IMPROVED_SPELL_DAMAGE_BUDGET = 1.6f; + private static float IMPROVED_SPELL_DAMAGE_BUDGET => SkadiConfig.ImprovedSpellDamageBudget.Value; private void Awake() { @@ -158,7 +162,7 @@ namespace RacesOfValheim if (rules.FrostAura) { EnsureFrostAuraVFX(true); - if (Time.time - lastAuraTime >= 1f) + if (Time.time - lastAuraTime >= SkadiConfig.AuraTickInterval.Value) { ApplyColdAura(); lastAuraTime = Time.time; @@ -217,9 +221,9 @@ namespace RacesOfValheim if (!RaceInput.Allowed) return; int state = BossProgressionManager.GetCurrentProgressionState(); - if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(SkadiProgression.GetGKeyRules(state)); return; } - if (Input.GetKeyDown(KeyCode.H)) { TryTransformWithRules(SkadiProgression.GetHKeyRules(state)); return; } - if (Input.GetKeyDown(KeyCode.J)) { TryTransformWithRules(SkadiProgression.GetJKeyRules(state)); return; } + if (SkadiConfig.DrakeFormKey.Value.IsDown()) { TryTransformWithRules(SkadiProgression.GetGKeyRules(state)); return; } + if (SkadiConfig.ModerFormKey.Value.IsDown()) { TryTransformWithRules(SkadiProgression.GetHKeyRules(state)); return; } + if (SkadiConfig.FaderFormKey.Value.IsDown()) { TryTransformWithRules(SkadiProgression.GetJKeyRules(state)); return; } // Debug Dump if (Input.GetKeyDown(KeyCode.F8)) @@ -307,8 +311,8 @@ namespace RacesOfValheim if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return; if (isTransformed) return; // Do not cast human spell while in dragon form - // Middle Mouse Button to cast - if (Input.GetMouseButtonDown(2)) + // Middle Mouse Button to cast, by default - rebindable via SkadiConfig.ColdSpellKey. + if (SkadiConfig.ColdSpellKey.Value.IsDown()) { // The improved cast is a burst rather than a rapid-fire, so it waits longer. float cooldown = rules.ImprovedColdSpell ? IMPROVED_SPELL_COOLDOWN : SPELL_COOLDOWN; @@ -482,10 +486,10 @@ namespace RacesOfValheim if (c == Player.m_localPlayer) continue; if (c.IsTamed() || c.IsPlayer()) continue; - if (Vector3.Distance(center, c.transform.position) <= 3f) + if (Vector3.Distance(center, c.transform.position) <= SkadiConfig.AuraRadius.Value) { HitData hit = new HitData(); - hit.m_damage.m_frost = 10f; + hit.m_damage.m_frost = SkadiConfig.AuraDamagePerTick.Value; hit.m_point = c.transform.position; hit.m_dir = (c.transform.position - center).normalized; hit.SetAttacker(Player.m_localPlayer); @@ -525,9 +529,9 @@ namespace RacesOfValheim private Vector3 GetFormScale(SkadiProgression.FormType form) { - if (form == SkadiProgression.FormType.Moder) return Vector3.one * 0.5f; // Increased to 50% - if (form == SkadiProgression.FormType.SkeletonDragon) return Vector3.one * 0.55f; // 10% larger than Moder - return Vector3.one * 0.9f; // Drake (reduced by 10%) + if (form == SkadiProgression.FormType.Moder) return Vector3.one * SkadiConfig.ModerScale.Value; + if (form == SkadiProgression.FormType.SkeletonDragon) return Vector3.one * SkadiConfig.FaderScale.Value; + return Vector3.one * SkadiConfig.DrakeScale.Value; // Drake } private IEnumerator TransformRoutine(SkadiProgression.FormRules rules) diff --git a/JotunnModStub/Skeleton/SkeletonConfig.cs b/JotunnModStub/Skeleton/SkeletonConfig.cs new file mode 100644 index 0000000..a31f1a9 --- /dev/null +++ b/JotunnModStub/Skeleton/SkeletonConfig.cs @@ -0,0 +1,76 @@ +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// Every tunable number behind the Skeleton's abilities, bound as BepInEx ConfigEntry so they + /// show up in Configuration Manager without touching code - see + /// CONFIGURATION-MANAGER-HOWTO.md. Bound once, from RacesOfValheim.Awake(). One section per + /// topic (matches the other races' layout). + /// + /// No keybinds section: every Skeleton ability is passive, triggered by tier and combat events + /// rather than a key press. + /// + /// The per-tier progression table itself (SkeletonProgression.GetRules: max health bonus, + /// lifesteal percent per tier, max summons) is left as-is, same boundary drawn for every other + /// race's progression table - not exposed here. Only the flat ability numbers a tier's boolean + /// flag switches on are configurable. + /// + /// One caveat: Enhanced Regen Health Multiplier is read into SE_SkeletonStats.RebuildForState, + /// which only re-reads it when the player's progression state changes (it short-circuits if + /// the state matches what it last built for). Retuning that one value mid-session at an + /// already-reached tier needs a relog (or reaching a new tier) to take effect. Everything else + /// here reads live on every use. + /// + public static class SkeletonConfig + { + // ─── Passive combat ────────────────────────────────────────────────── + public static ConfigEntry AutoStunCooldown; + public static ConfigEntry AutoStunStaggerMultiplier; + public static ConfigEntry PoisonAttackBonus; + public static ConfigEntry EnhancedRegenHealthMultiplier; + public static ConfigEntry EnhancedRegenTickSpeedBonus; + + // ─── Fire Aura (tier 5+) ─────────────────────────────────────────────── + public static ConfigEntry FireAuraRadius; + public static ConfigEntry FireAuraDamagePerTick; + public static ConfigEntry FireAuraTickInterval; + + // ─── Resurrection (tier 6+) ──────────────────────────────────────────── + public static ConfigEntry ResurrectionCooldown; + + // ─── Visuals ─────────────────────────────────────────────────────────── + public static ConfigEntry HeadFireVFXEnabled; + + public static void Bind(ConfigFile config) + { + const string combat = "Skeleton - Passive Combat"; + AutoStunCooldown = config.Bind(combat, "Auto Stun Cooldown", 5f, + new ConfigDescription("Seconds between forced staggers on the enemy hit, tier 3+.", new AcceptableValueRange(0f, 60f))); + AutoStunStaggerMultiplier = config.Bind(combat, "Auto Stun Stagger Multiplier", 100f, + new ConfigDescription("Stagger multiplier applied to force the stagger through.", new AcceptableValueRange(1f, 500f))); + PoisonAttackBonus = config.Bind(combat, "Poison Attack Bonus", 20f, + new ConfigDescription("Flat poison damage added to every hit the player lands, tier 4+.", new AcceptableValueRange(0f, 100f))); + EnhancedRegenHealthMultiplier = config.Bind(combat, "Enhanced Regen Health Multiplier", 1.5f, + new ConfigDescription("Health regeneration multiplier, tier 5+.", new AcceptableValueRange(1f, 5f))); + EnhancedRegenTickSpeedBonus = config.Bind(combat, "Enhanced Regen Tick Speed Bonus", 0.25f, + new ConfigDescription("Extra speed at which the regen timer accumulates, tier 5+ (0.25 = 25% faster ticks).", new AcceptableValueRange(0f, 2f))); + + const string aura = "Skeleton - Fire Aura"; + FireAuraRadius = config.Bind(aura, "Radius", 5f, + new ConfigDescription("Meters from the player that the tier 5+ aura damages.", new AcceptableValueRange(1f, 20f))); + FireAuraDamagePerTick = config.Bind(aura, "Damage Per Tick", 30f, + new ConfigDescription("Fire damage dealt to every enemy in range, once per tick.", new AcceptableValueRange(0f, 100f))); + FireAuraTickInterval = config.Bind(aura, "Tick Interval", 1f, + new ConfigDescription("Seconds between aura damage ticks.", new AcceptableValueRange(0.1f, 5f))); + + const string resurrection = "Skeleton - Resurrection"; + ResurrectionCooldown = config.Bind(resurrection, "Cooldown", 300f, + new ConfigDescription("Seconds between auto-resurrections, tier 6+.", new AcceptableValueRange(0f, 3600f))); + + const string visuals = "Skeleton - Visuals"; + HeadFireVFXEnabled = config.Bind(visuals, "Head Fire VFX Enabled", true, + new ConfigDescription("Whether the burning-skull effect (worn from tier 5+) renders at all. A client-side preference: disabling it stops you from seeing it on yourself and on every other skeleton you look at, but does not change what other players see.")); + } + } +} diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index df22e9d..d302562 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -594,16 +594,16 @@ namespace RacesOfValheim if (attacker != null && attacker == Player.m_localPlayer && SkeletonRace.IsSkeleton()) { // Auto Stun - if (rules.AutoStunFirstHit && Time.time - lastStunTime > 5f) + if (rules.AutoStunFirstHit && Time.time - lastStunTime > SkeletonConfig.AutoStunCooldown.Value) { - hit.m_staggerMultiplier = 100f; // Force stagger + hit.m_staggerMultiplier = SkeletonConfig.AutoStunStaggerMultiplier.Value; // Force stagger lastStunTime = Time.time; } // Poison Attacks if (rules.PoisonAttacks) { - hit.m_damage.m_poison += 20f; // Add flat 20 poison damage + hit.m_damage.m_poison += SkeletonConfig.PoisonAttackBonus.Value; } // Lifesteal diff --git a/JotunnModStub/Skeleton/SkeletonRace.cs b/JotunnModStub/Skeleton/SkeletonRace.cs index b6f7e1f..6fa6e92 100644 --- a/JotunnModStub/Skeleton/SkeletonRace.cs +++ b/JotunnModStub/Skeleton/SkeletonRace.cs @@ -431,18 +431,17 @@ namespace RacesOfValheim // rate, which is the player's own field. if (rules.EnhancedRegen) { - // Speed up regen ticks by 20% (1.25x faster timer accumulation) float currentTimer = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_foodRegenTimer").Value; - HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_foodRegenTimer").SetValue(currentTimer + Time.deltaTime * 0.25f); + HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_foodRegenTimer").SetValue(currentTimer + Time.deltaTime * SkeletonConfig.EnhancedRegenTickSpeedBonus.Value); } // Flames on the skull, worn with the fire-tier model and nothing else. - headFlame.Apply(Player.m_localPlayer, rules.ModelPrefab == SkeletonProgression.FireModel); + headFlame.Apply(Player.m_localPlayer, SkeletonConfig.HeadFireVFXEnabled.Value && rules.ModelPrefab == SkeletonProgression.FireModel); if (rules.FireAura) { EnsureFireAuraVFX(true); - if (Time.time - lastAuraTime >= 1f) + if (Time.time - lastAuraTime >= SkeletonConfig.FireAuraTickInterval.Value) { ApplyFireAura(); lastAuraTime = Time.time; @@ -551,10 +550,10 @@ namespace RacesOfValheim if (Player.m_localPlayer == null) return; Vector3 center = Player.m_localPlayer.transform.position; - float radius = 5f; - + float radius = SkeletonConfig.FireAuraRadius.Value; + HitData hitData = new HitData(); - hitData.m_damage.m_fire = 30f; // 30 fire damage per second + hitData.m_damage.m_fire = SkeletonConfig.FireAuraDamagePerTick.Value; hitData.SetAttacker(Player.m_localPlayer); hitData.m_dir = Vector3.zero; diff --git a/JotunnModStub/Skeleton/SkeletonStatusEffects.cs b/JotunnModStub/Skeleton/SkeletonStatusEffects.cs index 553a760..502dd04 100644 --- a/JotunnModStub/Skeleton/SkeletonStatusEffects.cs +++ b/JotunnModStub/Skeleton/SkeletonStatusEffects.cs @@ -39,7 +39,7 @@ namespace RacesOfValheim // template: SEMan.AddStatusEffect clones what it is given and adds the clone, so // anything written to the template afterwards reaches nobody. That is why the Moder // regeneration bonus never applied either. - m_healthRegenMultiplier = rules.EnhancedRegen ? 1.5f : 1.0f; + m_healthRegenMultiplier = rules.EnhancedRegen ? SkeletonConfig.EnhancedRegenHealthMultiplier.Value : 1.0f; m_mods = new List { @@ -62,9 +62,9 @@ namespace RacesOfValheim base.Setup(character); m_name = "Resurrection Cooldown"; m_tooltip = "Your skeletal body is too weak to resurrect again right now."; - m_icon = Jotunn.Managers.PrefabManager.Cache.GetPrefab("TrophySkeletonPoison")?.GetComponent()?.m_itemData.GetIcon() + m_icon = Jotunn.Managers.PrefabManager.Cache.GetPrefab("TrophySkeletonPoison")?.GetComponent()?.m_itemData.GetIcon() ?? Jotunn.Managers.PrefabManager.Cache.GetPrefab("TrophySkeleton")?.GetComponent()?.m_itemData.GetIcon(); - m_ttl = 300f; // 5 minutes + m_ttl = SkeletonConfig.ResurrectionCooldown.Value; } } } diff --git a/JotunnModStub/Trenta/TrentaAbilities.cs b/JotunnModStub/Trenta/TrentaAbilities.cs index 18a3a53..1dceaf9 100644 --- a/JotunnModStub/Trenta/TrentaAbilities.cs +++ b/JotunnModStub/Trenta/TrentaAbilities.cs @@ -23,17 +23,17 @@ namespace RacesOfValheim // Player.TakeInput, so nothing fires while a map, chest or chat window has focus. if (!RaceInput.Allowed) return; - if (state >= TrentaConfig.PurpleRainUnlockState && Input.GetKeyDown(TrentaConfig.PurpleRainKey)) + if (state >= TrentaConfig.PurpleRainUnlockState && TrentaConfigManagement.PurpleRainKey.Value.IsDown()) { TryPurpleRain(player); } - if (state >= TrentaConfig.PortalUnlockState && Input.GetKeyDown(TrentaConfig.PortalKey)) + if (state >= TrentaConfig.PortalUnlockState && TrentaConfigManagement.PortalKey.Value.IsDown()) { TryOpenPortal(player); } - if (state >= TrentaConfig.MuspellUnlockState && Input.GetKeyDown(TrentaConfig.MuspellKey)) + if (state >= TrentaConfig.MuspellUnlockState && TrentaConfigManagement.MuspellKey.Value.IsDown()) { TrentaMuspell.Toggle(player); } diff --git a/JotunnModStub/Trenta/TrentaConfig.cs b/JotunnModStub/Trenta/TrentaConfig.cs index 3db2fec..f182720 100644 --- a/JotunnModStub/Trenta/TrentaConfig.cs +++ b/JotunnModStub/Trenta/TrentaConfig.cs @@ -93,11 +93,12 @@ namespace RacesOfValheim // Base passive, live from state 1: stand motionless in daylight, out from under a roof, // and the Trenta puts down roots. TrentaAbilities.TickPhotosynthesis reads every number // below; nothing is hard-coded in the patch itself. - public const float PhotosynthesisStillnessSeconds = 10f; // channel time before it fires - public const int PhotosynthesisHealSeconds = 8; // number of 1-second heal ticks - public const float PhotosynthesisHealPercentPerSecond = 0.10f; // % of max health per tick - public const float PhotosynthesisRestBaseMinutes = 5f; // Rested duration at Base - public const float PhotosynthesisRestMinutesPerBoss = 1f; // + this, per boss defeated + // Forward to TrentaConfigManagement (BepInEx ConfigEntry) - see that class. + public static float PhotosynthesisStillnessSeconds => TrentaConfigManagement.PhotosynthesisStillnessSeconds.Value; + public static int PhotosynthesisHealSeconds => TrentaConfigManagement.PhotosynthesisHealSeconds.Value; + public static float PhotosynthesisHealPercentPerSecond => TrentaConfigManagement.PhotosynthesisHealPercentPerSecond.Value; + public static float PhotosynthesisRestBaseMinutes => TrentaConfigManagement.PhotosynthesisRestBaseMinutes.Value; + public static float PhotosynthesisRestMinutesPerBoss => TrentaConfigManagement.PhotosynthesisRestMinutesPerBoss.Value; // Character.GetVelocity() never reads exactly zero even standing still - a bit of // physics jitter is normal. Below this, the Trenta counts as motionless. @@ -110,16 +111,20 @@ namespace RacesOfValheim // lines up with RaceHostilityManager's Trenta block (Greyling/Greydwarf/Fuling/Troll/ // Leech/Deathsquito) and with every tamed companion and teammate, for free. public const int PurpleRainUnlockState = 3; // The Elder dead - public const KeyCode PurpleRainKey = KeyCode.G; + // The keybind used to live here as a KeyCode const; it is now + // TrentaConfigManagement's PurpleRainKey (a rebindable KeyboardShortcut), read directly + // by TrentaAbilities. - public const float PurpleRainCooldown = 20f; - public const float PurpleRainRadius = 8f; // TODO: tune - public const float PurpleRainHealAmount = 40f; // TODO: tune - flat heal per ally hit - public const float PurpleRainPoisonDamage = 40f; // TODO: tune - a Poison-type hit; vanilla's - // own poison-on-hit handling takes over - // from there, same as SkeletonRace's fire - // aura just deals Fire damage and lets - // the burn status follow from that. + // Forward to TrentaConfigManagement (BepInEx ConfigEntry) - see that class. + public static float PurpleRainCooldown => TrentaConfigManagement.PurpleRainCooldown.Value; + public static float PurpleRainRadius => TrentaConfigManagement.PurpleRainRadius.Value; + public static float PurpleRainHealAmount => TrentaConfigManagement.PurpleRainHealAmount.Value; + public static float PurpleRainPoisonDamage => TrentaConfigManagement.PurpleRainPoisonDamage.Value; + // A Poison-type hit; vanilla's own + // poison-on-hit handling takes over from + // there, same as SkeletonRace's fire aura + // just deals Fire damage and lets the + // burn status follow from that. public const string PurpleRainCdSE = "SE_TrentaPurpleRainCooldown"; @@ -141,12 +146,13 @@ namespace RacesOfValheim // Last Stand: always-on armor bonus that scales with health already lost, so it does // nothing at full health and its most at the edge of death. SE_TrentaStats.ModifyArmorMods // reads this every time armor is computed - there is no timer or trigger to it. - public const float LastStandMaxArmorBonus = 0.5f; // +50% armor at ~0 health remaining + // Forwards to TrentaConfigManagement (BepInEx ConfigEntry) - see that class. + public static float LastStandMaxArmorBonus => TrentaConfigManagement.LastStandMaxArmorBonus.Value; // Thorns: reflects this fraction of every hit taken back at whoever landed it. // Trenta_Character_Damage_Thorns_Patch reads it fresh on every hit - no timer, no charge, // no cooldown, it just always applies. Replaces Camouflage, which never worked reliably. - public const float ThornsReflectPercent = 0.2f; + public static float ThornsReflectPercent => TrentaConfigManagement.ThornsReflectPercent.Value; // ─── Homecoming Portal (Yagluth) ───────────────────────────────────── // Opens a linked pair of portals - one where the Trenta is standing, one at their @@ -156,11 +162,13 @@ namespace RacesOfValheim // custom (TrentaPortal.cs), not a re-skinned vanilla TeleportWorld, which is exactly why // it can skip the raw-ore restriction the real thing carries. public const int PortalUnlockState = 6; // Yagluth dead - public const KeyCode PortalKey = KeyCode.H; + // The keybind used to live here as a KeyCode const; it is now TrentaConfigManagement's + // PortalKey (a rebindable KeyboardShortcut), read directly by TrentaAbilities. - public const float PortalCooldown = 300f; // 5 minutes - public const float PortalLifetime = 30f; - public const float PortalSpawnDistance = 2f; // meters in front of the player, where it opens + // Forward to TrentaConfigManagement (BepInEx ConfigEntry) - see that class. + public static float PortalCooldown => TrentaConfigManagement.PortalCooldown.Value; + public static float PortalLifetime => TrentaConfigManagement.PortalLifetime.Value; + public static float PortalSpawnDistance => TrentaConfigManagement.PortalSpawnDistance.Value; // Source of the swirl visual the portal clones and retints. "portal_wood" is the // confirmed internal ID of the vanilla portal piece (verified against a live source @@ -184,13 +192,14 @@ namespace RacesOfValheim // (probably scene data on the wild instance, not code), so this one rests on the wiki's // account of live behaviour rather than the assembly's own IL the way most numbers in // this file do - flag it if it reads as too strong or too weak once tried. - public const float HornetsNestDamagePerTick = 10f; - public const float HornetsNestTickInterval = 4f; + // Forward to TrentaConfigManagement (BepInEx ConfigEntry) - see that class. + public static float HornetsNestDamagePerTick => TrentaConfigManagement.HornetsNestDamagePerTick.Value; + public static float HornetsNestTickInterval => TrentaConfigManagement.HornetsNestTickInterval.Value; - public const float HornetsNestEngageRadius = 6f; // TODO: tune - how close a foe has to get - public const float HornetsNestFollowSpeed = 8f; // TODO: tune - public const float HornetsNestOrbitRadius = 0.6f; // how tightly it hugs the Trenta at rest - public const float HornetsNestAttackHeight = 1.5f; // hovers this high over a target it is stinging - the "from above" for the pierce half of each tick + public static float HornetsNestEngageRadius => TrentaConfigManagement.HornetsNestEngageRadius.Value; // how close a foe has to get + public static float HornetsNestFollowSpeed => TrentaConfigManagement.HornetsNestFollowSpeed.Value; + public static float HornetsNestOrbitRadius => TrentaConfigManagement.HornetsNestOrbitRadius.Value; // how tightly it hugs the Trenta at rest + public static float HornetsNestAttackHeight => TrentaConfigManagement.HornetsNestAttackHeight.Value; // hovers this high over a target it is stinging - the "from above" for the pierce half of each tick // The flies only, not the smoke or the drip, off the same "Draugr" prefab // DraughRace.EnsureVFX already reads for its own aura - same source, same filtering rule, @@ -212,26 +221,28 @@ namespace RacesOfValheim // pattern) about as closely as two independent races' code can - both are read, not // guessed, so the shape of this is trustworthy even where individual numbers below are not. public const int MuspellUnlockState = 8; // Fader dead - public const KeyCode MuspellKey = KeyCode.J; + // The keybind used to live here as a KeyCode const; it is now TrentaConfigManagement's + // MuspellKey (a rebindable KeyboardShortcut), read directly by TrentaAbilities. // "gd_king" is The Elder's own internal prefab name, confirmed against a live source // (not guessed) the same way "portal_wood" and "Draugr" were. public const string MuspellFormPrefab = "gd_king"; - public const float MuspellScale = 0.5f; + // Forward to TrentaConfigManagement (BepInEx ConfigEntry) - see that class. + public static float MuspellScale => TrentaConfigManagement.MuspellScale.Value; // Stomp's damage/radius are still this mod's own numbers - TODO: replace with // gd_king_stomp's own SharedData.m_damages once dumpelder reports it, the same way the // trigger name below was replaced with a read value instead of a guess. - public const float MuspellStompDamage = 60f; - public const float MuspellStompRadius = 2.5f; // TODO: tune + public static float MuspellStompDamage => TrentaConfigManagement.MuspellStompDamage.Value; + public static float MuspellStompRadius => TrentaConfigManagement.MuspellStompRadius.Value; // The ranged attack is a real Projectile (type=Projectile, range 8-24), not an instant // cone hit - "gdking_root_projectile", The Elder's own vine/spike shot, spawned and set up // exactly the way Attack.FireProjectileBurst does it (Instantiate, new HitData, IProjectile // .Setup), for "identico" rather than an approximation. public const string MuspellSpikeProjectilePrefab = "gdking_root_projectile"; - public const float MuspellSpikeDamage = 35f; // TODO: replace with the projectile's own m_damage once dumpelder reports it - public const float MuspellSpikeVelocity = 20f; // TODO: tune - m_projectileVel isn't in this dump yet either + public static float MuspellSpikeDamage => TrentaConfigManagement.MuspellSpikeDamage.Value; // TODO: replace with the projectile's own m_damage once dumpelder reports it + public static float MuspellSpikeVelocity => TrentaConfigManagement.MuspellSpikeVelocity.Value; // TODO: m_projectileVel isn't in this dump yet either // Read straight off gd_king's own default weapons via the "dumpelder" console command // (RacesOfValheim.DumpElderCommand) rather than guessed - confirmed by IL that @@ -301,8 +312,9 @@ namespace RacesOfValheim "MarinatedGreens" // Marinated greens }; - // Digestion runs twice as long for a Trenta eating any of the foods above. - public const float FoodDurationMultiplier = 2f; + // Digestion runs longer for a Trenta eating any of the foods above. Forwards to + // TrentaConfigManagement (BepInEx ConfigEntry) - see that class. + public static float FoodDurationMultiplier => TrentaConfigManagement.FoodDurationMultiplier.Value; // ─── Awakened seeds ────────────────────────────────────────────────── // Once a Trenta has felled Eikthyr, every seed, cone, acorn and self-seeding mushroom in diff --git a/JotunnModStub/Trenta/TrentaConfigManagement.cs b/JotunnModStub/Trenta/TrentaConfigManagement.cs new file mode 100644 index 0000000..6b058b3 --- /dev/null +++ b/JotunnModStub/Trenta/TrentaConfigManagement.cs @@ -0,0 +1,155 @@ +using UnityEngine; +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// The BepInEx-configurable slice of the Trenta's numbers, bound as ConfigEntry so they show + /// up in Configuration Manager without touching code - see CONFIGURATION-MANAGER-HOWTO.md. + /// Bound once, from RacesOfValheim.Awake(). One section per topic (matches every other race's + /// layout). + /// + /// Named separately from the pre-existing TrentaConfig (rather than folding into it), same + /// reasoning as DvergarConfigManagement: that class is a different kind of thing - identity + /// constants that must never change once a player has the race (RaceId, status effect and + /// prefab names - renaming them would orphan saved characters or break asset lookups), + /// hand-tuned cosmetic placement numbers (skin colour, crown position), and design-time data + /// tables (HealthBonusByState, the per-biome AwakenedSeedFoods list) left alone under the same + /// boundary drawn for every other race's progression table. Only the genuine ability knobs - + /// Photosynthesis, Purple Rain, Last Stand/Thorns, Homecoming Portal, Hornet's Nest, Muspell, + /// and the vegan food duration bonus - plus the three transform/ability keybinds, belong here. + /// TrentaConfig's own fields for those now forward to this class (same const-to-property trick + /// used for Skadi and Dvergar), so every existing call site kept working unchanged except the + /// three keybind consumers in TrentaAbilities, which now read the live configured key. + /// + /// Everything here is read live on every use - TrentaProgression.GetRules only caches + /// HealthBonus (from the untouched table above), so none of this needs a relog to take effect. + /// + public static class TrentaConfigManagement + { + // ─── Keybinds ────────────────────────────────────────────────────────── + public static ConfigEntry PurpleRainKey; + public static ConfigEntry PortalKey; + public static ConfigEntry MuspellKey; + + // ─── Photosynthesis (tier 1+, passive) ─────────────────────────────── + public static ConfigEntry PhotosynthesisStillnessSeconds; + public static ConfigEntry PhotosynthesisHealSeconds; + public static ConfigEntry PhotosynthesisHealPercentPerSecond; + public static ConfigEntry PhotosynthesisRestBaseMinutes; + public static ConfigEntry PhotosynthesisRestMinutesPerBoss; + + // ─── Purple Rain (tier 3+) ──────────────────────────────────────────── + public static ConfigEntry PurpleRainCooldown; + public static ConfigEntry MuspellPurpleRainCooldown; + public static ConfigEntry PurpleRainRadius; + public static ConfigEntry PurpleRainHealAmount; + public static ConfigEntry PurpleRainPoisonDamage; + + // ─── Last Stand & Thorns (tier 5+) ──────────────────────────────────── + public static ConfigEntry LastStandMaxArmorBonus; + public static ConfigEntry ThornsReflectPercent; + + // ─── Homecoming Portal (tier 6+) ────────────────────────────────────── + public static ConfigEntry PortalCooldown; + public static ConfigEntry PortalLifetime; + public static ConfigEntry PortalSpawnDistance; + + // ─── Hornet's Nest (tier 7+, passive) ───────────────────────────────── + public static ConfigEntry HornetsNestDamagePerTick; + public static ConfigEntry HornetsNestTickInterval; + public static ConfigEntry HornetsNestEngageRadius; + public static ConfigEntry HornetsNestFollowSpeed; + public static ConfigEntry HornetsNestOrbitRadius; + public static ConfigEntry HornetsNestAttackHeight; + + // ─── Muspell (tier 8) ────────────────────────────────────────────────── + public static ConfigEntry MuspellScale; + public static ConfigEntry MuspellStompDamage; + public static ConfigEntry MuspellStompRadius; + public static ConfigEntry MuspellSpikeDamage; + public static ConfigEntry MuspellSpikeVelocity; + + // ─── Diet ────────────────────────────────────────────────────────────── + public static ConfigEntry FoodDurationMultiplier; + + public static void Bind(ConfigFile config) + { + const string keybinds = "Trenta - Keybinds"; + PurpleRainKey = config.Bind(keybinds, "Purple Rain", new KeyboardShortcut(KeyCode.G), + new ConfigDescription("Casts Purple Rain, tier 3+.")); + PortalKey = config.Bind(keybinds, "Homecoming Portal", new KeyboardShortcut(KeyCode.H), + new ConfigDescription("Opens the Homecoming Portal pair, tier 6+.")); + MuspellKey = config.Bind(keybinds, "Muspell Form", new KeyboardShortcut(KeyCode.J), + new ConfigDescription("Transform into (or revert from) Muspell, tier 8.")); + + const string photo = "Trenta - Photosynthesis"; + PhotosynthesisStillnessSeconds = config.Bind(photo, "Stillness Seconds", 10f, + new ConfigDescription("Seconds standing still in daylight, out from under a roof, before healing begins.", new AcceptableValueRange(1f, 60f))); + PhotosynthesisHealSeconds = config.Bind(photo, "Heal Ticks", 8, + new ConfigDescription("Number of 1-second heal ticks once it fires.", new AcceptableValueRange(1, 30))); + PhotosynthesisHealPercentPerSecond = config.Bind(photo, "Heal Percent Per Tick", 0.10f, + new ConfigDescription("Fraction of max health healed per tick.", new AcceptableValueRange(0f, 1f))); + PhotosynthesisRestBaseMinutes = config.Bind(photo, "Rest Base Minutes", 5f, + new ConfigDescription("Rested-buff duration granted at base tier.", new AcceptableValueRange(0f, 60f))); + PhotosynthesisRestMinutesPerBoss = config.Bind(photo, "Rest Minutes Per Boss", 1f, + new ConfigDescription("Extra Rested-buff minutes, per boss defeated.", new AcceptableValueRange(0f, 10f))); + + const string purpleRain = "Trenta - Purple Rain"; + PurpleRainCooldown = config.Bind(purpleRain, "Cooldown", 20f, + new ConfigDescription("Seconds between casts in human form.", new AcceptableValueRange(0f, 300f))); + MuspellPurpleRainCooldown = config.Bind(purpleRain, "Muspell Cooldown", 10f, + new ConfigDescription("Seconds between casts while transformed into Muspell.", new AcceptableValueRange(0f, 300f))); + PurpleRainRadius = config.Bind(purpleRain, "Radius", 8f, + new ConfigDescription("Meters from the player the spray reaches.", new AcceptableValueRange(1f, 30f))); + PurpleRainHealAmount = config.Bind(purpleRain, "Ally Heal Amount", 40f, + new ConfigDescription("Flat heal applied to every ally hit.", new AcceptableValueRange(0f, 200f))); + PurpleRainPoisonDamage = config.Bind(purpleRain, "Enemy Poison Damage", 40f, + new ConfigDescription("Flat poison damage applied to every enemy hit.", new AcceptableValueRange(0f, 200f))); + + const string lastStand = "Trenta - Last Stand & Thorns"; + LastStandMaxArmorBonus = config.Bind(lastStand, "Last Stand Max Armor Bonus", 0.5f, + new ConfigDescription("Armor multiplier bonus at near-zero health, tier 5+ (0.5 = +50%). Scales down to 0 at full health.", new AcceptableValueRange(0f, 3f))); + ThornsReflectPercent = config.Bind(lastStand, "Thorns Reflect Percent", 0.2f, + new ConfigDescription("Fraction of every hit taken reflected back at the attacker, tier 5+.", new AcceptableValueRange(0f, 1f))); + + const string portal = "Trenta - Homecoming Portal"; + PortalCooldown = config.Bind(portal, "Cooldown", 300f, + new ConfigDescription("Seconds between casts, tier 6+.", new AcceptableValueRange(0f, 3600f))); + PortalLifetime = config.Bind(portal, "Lifetime", 30f, + new ConfigDescription("Seconds the portal pair stays open.", new AcceptableValueRange(5f, 300f))); + PortalSpawnDistance = config.Bind(portal, "Spawn Distance", 2f, + new ConfigDescription("Meters in front of the player the cast-side portal opens.", new AcceptableValueRange(0.5f, 10f))); + + const string hornets = "Trenta - Hornet’s Nest"; + HornetsNestDamagePerTick = config.Bind(hornets, "Damage Per Tick", 10f, + new ConfigDescription("Poison and pierce damage dealt per sting, tier 7+.", new AcceptableValueRange(0f, 50f))); + HornetsNestTickInterval = config.Bind(hornets, "Tick Interval", 4f, + new ConfigDescription("Seconds between stings on an engaged target.", new AcceptableValueRange(0.5f, 20f))); + HornetsNestEngageRadius = config.Bind(hornets, "Engage Radius", 6f, + new ConfigDescription("Meters from the player within which a foe is engaged.", new AcceptableValueRange(1f, 30f))); + HornetsNestFollowSpeed = config.Bind(hornets, "Follow Speed", 8f, + new ConfigDescription("Meters per second the nest moves to reach its target or resting orbit.", new AcceptableValueRange(1f, 30f))); + HornetsNestOrbitRadius = config.Bind(hornets, "Orbit Radius", 0.6f, + new ConfigDescription("How tightly it hugs the player while at rest.", new AcceptableValueRange(0.1f, 5f))); + HornetsNestAttackHeight = config.Bind(hornets, "Attack Height", 1.5f, + new ConfigDescription("Meters above a target it hovers while stinging.", new AcceptableValueRange(0f, 5f))); + + const string muspell = "Trenta - Muspell"; + MuspellScale = config.Bind(muspell, "Model Scale", 0.5f, + new ConfigDescription("Model scale while transformed, tier 8.", new AcceptableValueRange(0.1f, 2f))); + MuspellStompDamage = config.Bind(muspell, "Stomp Damage", 60f, + new ConfigDescription("Base damage of the stomp attack, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 300f))); + MuspellStompRadius = config.Bind(muspell, "Stomp Radius", 2.5f, + new ConfigDescription("Hit-sweep radius for the stomp.", new AcceptableValueRange(1f, 10f))); + MuspellSpikeDamage = config.Bind(muspell, "Spike Damage", 35f, + new ConfigDescription("Base pierce damage of the root-spike projectile, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 200f))); + MuspellSpikeVelocity = config.Bind(muspell, "Spike Velocity", 20f, + new ConfigDescription("Travel speed of the root-spike projectile.", new AcceptableValueRange(1f, 60f))); + + const string diet = "Trenta - Diet"; + FoodDurationMultiplier = config.Bind(diet, "Vegan Food Duration Multiplier", 2f, + new ConfigDescription("Multiplies digestion time for every vegan-safe food eaten.", new AcceptableValueRange(1f, 5f))); + } + } +} diff --git a/JotunnModStub/Trol/TrolConfig.cs b/JotunnModStub/Trol/TrolConfig.cs new file mode 100644 index 0000000..de2c18e --- /dev/null +++ b/JotunnModStub/Trol/TrolConfig.cs @@ -0,0 +1,130 @@ +using UnityEngine; +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// Every tunable number and keybind behind the Trol's abilities, bound as BepInEx ConfigEntry + /// so they show up in Configuration Manager without touching code - see + /// CONFIGURATION-MANAGER-HOWTO.md. Bound once, from RacesOfValheim.Awake(). One section per + /// topic (matches every other race's layout). + /// + /// Tier-gate thresholds (which progression state unlocks each perk) are left as-is, same + /// boundary drawn for every other race's progression table - not exposed here. + /// + /// True Form's scale (Normal/Advanced) is read from both the local transform routine + /// (TrolRace) and the remote-sizing postfix (TrolPatches) - both now read the same + /// ConfigEntry rather than each carrying its own literal, so a retuned value can no longer + /// make a Trol one size to themselves and another to everyone else. + /// + public static class TrolConfig + { + // ─── Keybinds ────────────────────────────────────────────────────────── + public static ConfigEntry ThrowRockKey; + public static ConfigEntry TrueFormKey; + + // ─── Passive combat ────────────────────────────────────────────────── + public static ConfigEntry FireWeaknessMultiplier; + public static ConfigEntry BonemassMeleeBonus; + public static ConfigEntry YagluthMeleeBonus; + public static ConfigEntry TrueFormMeleeBonus; + public static ConfigEntry RegenMultiplierBonus; + public static ConfigEntry FavoredSkillXPMultiplier; + public static ConfigEntry CarryWeightBonusBase; + public static ConfigEntry CarryWeightBonusBonemass; + public static ConfigEntry CarryWeightBonusYagluth; + public static ConfigEntry ArmorBonusPerState; + + // ─── Throw Rock (tier 3+) ───────────────────────────────────────────── + public static ConfigEntry ThrowRockCooldown; + public static ConfigEntry ThrowRockCooldownTrueForm; + public static ConfigEntry ThrowRockBaseDamage; + public static ConfigEntry ThrowRockBonemassBonus; + public static ConfigEntry ThrowRockYagluthBonus; + public static ConfigEntry ThrowRockTrueFormBonus; + public static ConfigEntry ThrowRockProjectileVelocity; + public static ConfigEntry ThrowLogVelocity; + + // ─── True Form (tier 5+) ─────────────────────────────────────────────── + public static ConfigEntry TrueFormDuration; + public static ConfigEntry TrueFormCooldown; + public static ConfigEntry TrueFormScaleNormal; + public static ConfigEntry TrueFormScaleAdvanced; + + // ─── Log Weapon (tier 7+) ────────────────────────────────────────────── + public static ConfigEntry LogWeaponMaxDurability; + public static ConfigEntry LogWeaponDurabilityDrainPerHit; + + // ─── Farming ─────────────────────────────────────────────────────────── + public static ConfigEntry UnarmedFarmingDamageBonusPerState; + + public static void Bind(ConfigFile config) + { + const string keybinds = "Trol - Keybinds"; + ThrowRockKey = config.Bind(keybinds, "Throw Rock", new KeyboardShortcut(KeyCode.G), + new ConfigDescription("Throws a rock (or the log you're holding), tier 3+.")); + TrueFormKey = config.Bind(keybinds, "True Form", new KeyboardShortcut(KeyCode.H), + new ConfigDescription("Transform into (or revert from) True Form, tier 5+.")); + + const string combat = "Trol - Passive Combat"; + FireWeaknessMultiplier = config.Bind(combat, "Fire Weakness Multiplier", 1.5f, + new ConfigDescription("Multiplies incoming fire damage (1.5 = 50% weaker).", new AcceptableValueRange(1f, 3f))); + BonemassMeleeBonus = config.Bind(combat, "Bonemass Melee Bonus", 10f, + new ConfigDescription("Flat damage added to Clubs/Unarmed/Axes attacks, tier 4+.", new AcceptableValueRange(0f, 100f))); + YagluthMeleeBonus = config.Bind(combat, "Yagluth Melee Bonus", 5f, + new ConfigDescription("Additional flat damage added to Clubs/Unarmed/Axes attacks, tier 6+.", new AcceptableValueRange(0f, 100f))); + TrueFormMeleeBonus = config.Bind(combat, "True Form Melee Bonus", 40f, + new ConfigDescription("Flat damage added to Clubs/Unarmed/Axes attacks while in True Form.", new AcceptableValueRange(0f, 200f))); + RegenMultiplierBonus = config.Bind(combat, "Regen Multiplier Bonus", 0.10f, + new ConfigDescription("Health regen multiplier bonus, tier 3+ (0.10 = +10%).", new AcceptableValueRange(0f, 2f))); + FavoredSkillXPMultiplier = config.Bind(combat, "Favored Skill XP Multiplier", 2f, + new ConfigDescription("Multiplies XP gain for Clubs/Unarmed/Axes/Pickaxes/WoodCutting, tier 2+.", new AcceptableValueRange(0.5f, 5f))); + CarryWeightBonusBase = config.Bind(combat, "Carry Weight Bonus (Base)", 200f, + new ConfigDescription("Flat carry weight added, always active.", new AcceptableValueRange(0f, 1000f))); + CarryWeightBonusBonemass = config.Bind(combat, "Carry Weight Bonus (Bonemass)", 50f, + new ConfigDescription("Additional flat carry weight, tier 4+.", new AcceptableValueRange(0f, 500f))); + CarryWeightBonusYagluth = config.Bind(combat, "Carry Weight Bonus (Yagluth)", 50f, + new ConfigDescription("Additional flat carry weight, tier 6+.", new AcceptableValueRange(0f, 500f))); + ArmorBonusPerState = config.Bind(combat, "Armor Bonus Per State", 3f, + new ConfigDescription("Flat armor added, per progression state.", new AcceptableValueRange(0f, 20f))); + + const string throwRock = "Trol - Throw Rock"; + ThrowRockCooldown = config.Bind(throwRock, "Cooldown", 60f, + new ConfigDescription("Seconds between throws in human form.", new AcceptableValueRange(0f, 300f))); + ThrowRockCooldownTrueForm = config.Bind(throwRock, "Cooldown (True Form)", 15f, + new ConfigDescription("Seconds between throws while in True Form.", new AcceptableValueRange(0f, 300f))); + ThrowRockBaseDamage = config.Bind(throwRock, "Base Damage", 25f, + new ConfigDescription("Base blunt damage of a thrown rock (not used when throwing a log).", new AcceptableValueRange(0f, 200f))); + ThrowRockBonemassBonus = config.Bind(throwRock, "Bonemass Bonus", 10f, + new ConfigDescription("Additional damage, tier 4+.", new AcceptableValueRange(0f, 100f))); + ThrowRockYagluthBonus = config.Bind(throwRock, "Yagluth Bonus", 5f, + new ConfigDescription("Additional damage, tier 6+.", new AcceptableValueRange(0f, 100f))); + ThrowRockTrueFormBonus = config.Bind(throwRock, "True Form Bonus", 40f, + new ConfigDescription("Additional damage while in True Form.", new AcceptableValueRange(0f, 200f))); + ThrowRockProjectileVelocity = config.Bind(throwRock, "Rock Velocity", 20f, + new ConfigDescription("Travel speed of a thrown rock.", new AcceptableValueRange(1f, 60f))); + ThrowLogVelocity = config.Bind(throwRock, "Log Velocity", 60f, + new ConfigDescription("Travel speed of a thrown log (compensates for its weight/drag).", new AcceptableValueRange(1f, 150f))); + + const string trueForm = "Trol - True Form"; + TrueFormDuration = config.Bind(trueForm, "Duration", 60f, + new ConfigDescription("Seconds True Form lasts before automatically reverting.", new AcceptableValueRange(5f, 600f))); + TrueFormCooldown = config.Bind(trueForm, "Cooldown", 600f, + new ConfigDescription("Seconds between True Form activations.", new AcceptableValueRange(0f, 3600f))); + TrueFormScaleNormal = config.Bind(trueForm, "Scale", 2.0f, + new ConfigDescription("Model scale while in True Form, tier 5-6.", new AcceptableValueRange(1f, 4f))); + TrueFormScaleAdvanced = config.Bind(trueForm, "Scale (Tier 7+)", 2.5f, + new ConfigDescription("Model scale while in True Form, tier 7+.", new AcceptableValueRange(1f, 4f))); + + 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(1f, 50f))); + LogWeaponDurabilityDrainPerHit = config.Bind(logWeapon, "Durability Drain Per Hit", 1f, + new ConfigDescription("Durability spent per hit landed.", new AcceptableValueRange(0.1f, 10f))); + + const string farming = "Trol - Farming"; + UnarmedFarmingDamageBonusPerState = config.Bind(farming, "Unarmed Damage Bonus Per State", 3f, + new ConfigDescription("Extra chop/pickaxe damage when farming or mining unarmed, per progression state.", new AcceptableValueRange(0f, 20f))); + } + } +} diff --git a/JotunnModStub/Trol/TrolDamagePatches.cs b/JotunnModStub/Trol/TrolDamagePatches.cs index b858cba..c20d3f2 100644 --- a/JotunnModStub/Trol/TrolDamagePatches.cs +++ b/JotunnModStub/Trol/TrolDamagePatches.cs @@ -10,10 +10,10 @@ namespace RacesOfValheim { if (__instance == Player.m_localPlayer && TrolRace.IsTrol()) { - // Trols are weak to fire (take 50% more damage) + // Trols are weak to fire if (hit.m_damage.m_fire > 0f) { - hit.m_damage.m_fire *= 1.5f; + hit.m_damage.m_fire *= TrolConfig.FireWeaknessMultiplier.Value; } } @@ -21,37 +21,40 @@ namespace RacesOfValheim { if (BossProgressionManager.GetCurrentProgressionState() >= 4) // Bonemass { + float bonus = TrolConfig.BonemassMeleeBonus.Value; if (hit.m_skill == Skills.SkillType.Clubs || hit.m_skill == Skills.SkillType.Unarmed) { - hit.m_damage.m_blunt += 10f; + hit.m_damage.m_blunt += bonus; } else if (hit.m_skill == Skills.SkillType.Axes) { - hit.m_damage.m_slash += 10f; + hit.m_damage.m_slash += bonus; } } if (BossProgressionManager.GetCurrentProgressionState() >= 6) // Yagluth { + float bonus = TrolConfig.YagluthMeleeBonus.Value; if (hit.m_skill == Skills.SkillType.Clubs || hit.m_skill == Skills.SkillType.Unarmed) { - hit.m_damage.m_blunt += 5f; + hit.m_damage.m_blunt += bonus; } else if (hit.m_skill == Skills.SkillType.Axes) { - hit.m_damage.m_slash += 5f; + hit.m_damage.m_slash += bonus; } } if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode())) { + float bonus = TrolConfig.TrueFormMeleeBonus.Value; if (hit.m_skill == Skills.SkillType.Clubs || hit.m_skill == Skills.SkillType.Unarmed) { - hit.m_damage.m_blunt += 40f; + hit.m_damage.m_blunt += bonus; } else if (hit.m_skill == Skills.SkillType.Axes) { - hit.m_damage.m_slash += 40f; + hit.m_damage.m_slash += bonus; } } } diff --git a/JotunnModStub/Trol/TrolFarmingPatches.cs b/JotunnModStub/Trol/TrolFarmingPatches.cs index be7c476..1e43a40 100644 --- a/JotunnModStub/Trol/TrolFarmingPatches.cs +++ b/JotunnModStub/Trol/TrolFarmingPatches.cs @@ -33,7 +33,7 @@ namespace RacesOfValheim else if (state >= 3) hit.m_toolTier = 1; // Elder (Bronze) else if (state >= 2) hit.m_toolTier = 1; // Eikthyr (Flint/Antler) - float damageBonus = state * 3f; + float damageBonus = state * TrolConfig.UnarmedFarmingDamageBonusPerState.Value; // Convert blunt damage to chop or pickaxe damage, plus progression bonus if (isTree) diff --git a/JotunnModStub/Trol/TrolPatches.cs b/JotunnModStub/Trol/TrolPatches.cs index 5c1a2c3..4fd11b1 100644 --- a/JotunnModStub/Trol/TrolPatches.cs +++ b/JotunnModStub/Trol/TrolPatches.cs @@ -149,7 +149,7 @@ namespace RacesOfValheim float targetScale = ScaleForState(state); if (isTrueFormActive) { - targetScale = state >= 7 ? 2.5f : 2.0f; + targetScale = state >= 7 ? TrolConfig.TrueFormScaleAdvanced.Value : TrolConfig.TrueFormScaleNormal.Value; } if (!isLocal) @@ -204,18 +204,18 @@ namespace RacesOfValheim string race = "Human"; ZNetView nview = __instance.GetComponent(); if (nview != null && nview.IsValid()) race = nview.GetZDO().GetString("RacesOfValheim_Race", "Human"); else if (__instance.m_customData != null && __instance.m_customData.TryGetValue("Race", out string savedRace)) race = savedRace; if (race == "Trol") { - // Base carry weight is 300. We add 200 to make it 500. + // Base carry weight is 300. We add a bonus to make it 500 by default. // If they wear Megingjord, it will become 500 + 150 = 650. - __result += 200f; + __result += TrolConfig.CarryWeightBonusBase.Value; int state = BossProgressionManager.GetCurrentProgressionState(); if (state >= 4) { - __result += 50f; // After Bonemass + __result += TrolConfig.CarryWeightBonusBonemass.Value; } if (state >= 6) { - __result += 50f; // After Yagluth + __result += TrolConfig.CarryWeightBonusYagluth.Value; } } } @@ -228,9 +228,8 @@ namespace RacesOfValheim { if (__instance == Player.m_localPlayer && TrolRace.IsTrol()) { - // +3 Armor per progression state (boss defeated) int state = BossProgressionManager.GetCurrentProgressionState(); - __result += 3f * state; + __result += TrolConfig.ArmorBonusPerState.Value * state; } } } diff --git a/JotunnModStub/Trol/TrolRace.cs b/JotunnModStub/Trol/TrolRace.cs index 5b7eb15..a132bc8 100644 --- a/JotunnModStub/Trol/TrolRace.cs +++ b/JotunnModStub/Trol/TrolRace.cs @@ -98,9 +98,9 @@ namespace RacesOfValheim } ItemDrop itemDrop = customWep.ItemPrefab.GetComponent(); - itemDrop.m_itemData.m_shared.m_maxDurability = 6f; + itemDrop.m_itemData.m_shared.m_maxDurability = TrolConfig.LogWeaponMaxDurability.Value; itemDrop.m_itemData.m_shared.m_useDurability = true; - itemDrop.m_itemData.m_shared.m_useDurabilityDrain = 1f; + itemDrop.m_itemData.m_shared.m_useDurabilityDrain = TrolConfig.LogWeaponDurabilityDrainPerHit.Value; itemDrop.m_itemData.m_shared.m_destroyBroken = false; itemDrop.m_itemData.m_shared.m_weight = 0f; itemDrop.m_itemData.m_shared.m_equipDuration = 0.1f; @@ -121,12 +121,12 @@ namespace RacesOfValheim if (RaceInput.Allowed) { - if (Input.GetKeyDown(KeyCode.G)) + if (TrolConfig.ThrowRockKey.Value.IsDown()) { TryThrowRock(); } - if (Input.GetKeyDown(KeyCode.H)) + if (TrolConfig.TrueFormKey.Value.IsDown()) { TryTrueForm(); } @@ -217,7 +217,9 @@ namespace RacesOfValheim if (visual != null) { Vector3 startScale = visual.transform.localScale; - float trueFormScale = BossProgressionManager.GetCurrentProgressionState() >= 7 ? 2.5f : 2.0f; + float trueFormScale = BossProgressionManager.GetCurrentProgressionState() >= 7 + ? TrolConfig.TrueFormScaleAdvanced.Value + : TrolConfig.TrueFormScaleNormal.Value; Vector3 targetScale = new Vector3(trueFormScale, trueFormScale, trueFormScale); while (elapsed < duration) @@ -277,7 +279,7 @@ namespace RacesOfValheim private System.Collections.IEnumerator ThrowRockRoutine() { bool isTrueForm = Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode()); - float throwRockCooldown = isTrueForm ? 15f : 60f; + float throwRockCooldown = isTrueForm ? TrolConfig.ThrowRockCooldownTrueForm.Value : TrolConfig.ThrowRockCooldown.Value; var addedSE = Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_TrolThrowRockCooldown".GetStableHashCode(), true); if (addedSE != null) @@ -323,8 +325,8 @@ namespace RacesOfValheim if (rb != null) { - // 3x speed to compensate for log weight/drag - rb.velocity = Player.m_localPlayer.GetLookDir() * 60f; + // Compensates for log weight/drag + rb.velocity = Player.m_localPlayer.GetLookDir() * TrolConfig.ThrowLogVelocity.Value; // Add some slight rotation tumbling rb.angularVelocity = new Vector3(10f, 5f, 0f); } @@ -343,24 +345,24 @@ namespace RacesOfValheim if (proj != null) { HitData hitData = new HitData(); - hitData.m_damage.m_blunt = 25f; // Base troll rock - + hitData.m_damage.m_blunt = TrolConfig.ThrowRockBaseDamage.Value; + if (BossProgressionManager.GetCurrentProgressionState() >= 4) { - hitData.m_damage.m_blunt += 10f; // Bonemass bonus + hitData.m_damage.m_blunt += TrolConfig.ThrowRockBonemassBonus.Value; } if (BossProgressionManager.GetCurrentProgressionState() >= 6) { - hitData.m_damage.m_blunt += 5f; // Yagluth bonus + hitData.m_damage.m_blunt += TrolConfig.ThrowRockYagluthBonus.Value; } - + if (isTrueForm) { - hitData.m_damage.m_blunt += 40f; // True Form bonus + hitData.m_damage.m_blunt += TrolConfig.ThrowRockTrueFormBonus.Value; } hitData.SetAttacker(Player.m_localPlayer); - proj.Setup(Player.m_localPlayer, Player.m_localPlayer.GetLookDir() * 20f, -1f, hitData, null, null); + proj.Setup(Player.m_localPlayer, Player.m_localPlayer.GetLookDir() * TrolConfig.ThrowRockProjectileVelocity.Value, -1f, hitData, null, null); } } } diff --git a/JotunnModStub/Trol/TrolRegenPatches.cs b/JotunnModStub/Trol/TrolRegenPatches.cs index 36f1866..79f4009 100644 --- a/JotunnModStub/Trol/TrolRegenPatches.cs +++ b/JotunnModStub/Trol/TrolRegenPatches.cs @@ -12,7 +12,7 @@ namespace RacesOfValheim // After The Elder (Progression State >= 2) if (BossProgressionManager.GetCurrentProgressionState() >= 3) { - regenMultiplier *= 1.10f; // +10% passive health regeneration + regenMultiplier *= 1f + TrolConfig.RegenMultiplierBonus.Value; } } } diff --git a/JotunnModStub/Trol/TrolSkillPatches.cs b/JotunnModStub/Trol/TrolSkillPatches.cs index 8db9b8b..d07bc9b 100644 --- a/JotunnModStub/Trol/TrolSkillPatches.cs +++ b/JotunnModStub/Trol/TrolSkillPatches.cs @@ -23,7 +23,7 @@ namespace RacesOfValheim if (isTrolSkill) { - factor *= 2f; + factor *= TrolConfig.FavoredSkillXPMultiplier.Value; } } } diff --git a/JotunnModStub/Trol/TrolStatusEffects.cs b/JotunnModStub/Trol/TrolStatusEffects.cs index d61840f..e5277f6 100644 --- a/JotunnModStub/Trol/TrolStatusEffects.cs +++ b/JotunnModStub/Trol/TrolStatusEffects.cs @@ -35,7 +35,7 @@ namespace RacesOfValheim name = "SE_TrolTrueForm"; m_name = "True Form"; m_tooltip = "You have unleashed your inner troll!"; - m_ttl = 60f; // 1 minute duration + m_ttl = TrolConfig.TrueFormDuration.Value; GameObject itemPrefab = PrefabManager.Cache.GetPrefab("Stone"); if (itemPrefab != null) @@ -57,7 +57,7 @@ namespace RacesOfValheim name = "SE_TrolTrueFormCooldown"; m_name = "True Form Cooldown"; m_tooltip = "You are exhausted from your True Form."; - m_ttl = 600f; // 10 minutes cooldown + m_ttl = TrolConfig.TrueFormCooldown.Value; GameObject itemPrefab = PrefabManager.Cache.GetPrefab("Stone"); if (itemPrefab != null) diff --git a/JotunnModStub/ZdoVisualSync.cs b/JotunnModStub/ZdoVisualSync.cs index 1c698dc..4559f86 100644 --- a/JotunnModStub/ZdoVisualSync.cs +++ b/JotunnModStub/ZdoVisualSync.cs @@ -164,7 +164,7 @@ namespace RacesOfValheim // The burning skull, grown locally for whoever we are looking at. The tier is on the // ZDO, so this client can work out for itself whether they should be alight. - m_skeletonHeadFlame.Apply(m_player, rules.ModelPrefab == SkeletonProgression.FireModel); + m_skeletonHeadFlame.Apply(m_player, SkeletonConfig.HeadFireVFXEnabled.Value && rules.ModelPrefab == SkeletonProgression.FireModel); // Apply Scale Vector3 targetScale = rules.ScaleMultiplier;