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/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 91f64b4..551865d 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -24,6 +24,10 @@ 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); SkadiConfig.Bind(Config); harmony.PatchAll(); gameObject.AddComponent();