From d9bca1934fb9b5df8b78ba258e4d58d0a07c40a5 Mon Sep 17 00:00:00 2001 From: kanym Date: Fri, 6 Nov 2026 21:21:11 +0100 Subject: [PATCH] fix(skills): hand-built attacks level the skill they scale with Form attacks and powers called Damage directly, and vanilla only raises a skill inside Attack and Projectile.OnHit, so the skill never moved. FormMelee.RaiseSkill pays once per swing or tick that hit a creature. - Fenrir forms' claws and bites: Unarmed; Cultist fire: Elemental Magic - Skadi drake melee and Trenta stomp: Unarmed - Aswid aura: Blood Magic, 0.1 per second like the Frost Aura - Alfar Geisli and Ljosstorm: Elemental Magic; Sameining pulse 0.1/s - Trenta Purple Rain scales with Blood Magic (two new bonus keys) and levels it once per cast that reaches someone besides the caster --- JotunnModStub/Alfar/AlfarArchon.cs | 5 ++++- JotunnModStub/Alfar/AlfarPowers.cs | 20 ++++++++++++++++--- JotunnModStub/Aswid/AswidRace.cs | 7 +++++++ JotunnModStub/Fenrir/FenrirBehaviors.cs | 20 +++++++++++++++++++ JotunnModStub/Fenrir/FenrirFormShared.cs | 15 ++++++++++++++ JotunnModStub/RaceCompendium.cs | 4 ++-- JotunnModStub/Skadi/DrakeFormBehavior.cs | 4 ++++ JotunnModStub/Trenta/TrentaAbilities.cs | 17 +++++++++++++--- JotunnModStub/Trenta/TrentaConfig.cs | 10 ++++++++++ .../Trenta/TrentaConfigManagement.cs | 6 ++++++ JotunnModStub/Trenta/TrentaMuspell.cs | 6 ++++++ 11 files changed, 105 insertions(+), 9 deletions(-) diff --git a/JotunnModStub/Alfar/AlfarArchon.cs b/JotunnModStub/Alfar/AlfarArchon.cs index 0be4415..079d7a6 100644 --- a/JotunnModStub/Alfar/AlfarArchon.cs +++ b/JotunnModStub/Alfar/AlfarArchon.cs @@ -119,7 +119,10 @@ namespace RacesOfValheim if (Time.time >= nextPulse) { nextPulse = Time.time + AlfarPowerConfig.ArchonPulseInterval.Value; - AlfarPowers.Pulse(player, AlfarPowerConfig.ArchonPulseRadius.Value, AlfarPowerConfig.ArchonPulseDamage.Value); + // The pulse fires on its own while the form lasts, so it earns what an aura does: + // a tenth of a hit per second, once per pulse that struck something. + if (AlfarPowers.Pulse(player, AlfarPowerConfig.ArchonPulseRadius.Value, AlfarPowerConfig.ArchonPulseDamage.Value)) + FormMelee.RaiseSkill(Skills.SkillType.ElementalMagic, 0.1f * AlfarPowerConfig.ArchonPulseInterval.Value); } } diff --git a/JotunnModStub/Alfar/AlfarPowers.cs b/JotunnModStub/Alfar/AlfarPowers.cs index 82aca06..6b0ea70 100644 --- a/JotunnModStub/Alfar/AlfarPowers.cs +++ b/JotunnModStub/Alfar/AlfarPowers.cs @@ -148,12 +148,17 @@ namespace RacesOfValheim } /// A pulse of lightning on every hostile creature within a radius of the Alfr. - public static void Pulse(Player player, float radius, float damage) + /// True if it struck at least one creature. + public static bool Pulse(Player player, float radius, float damage) { + bool struck = false; foreach (Character character in CharactersIn(player.transform.position, radius)) { - if (IsHostile(player, character)) Strike(player, character, damage, character.GetCenterPoint()); + if (!IsHostile(player, character)) continue; + Strike(player, character, damage, character.GetCenterPoint()); + struck = true; } + return struck; } private static IEnumerable CharactersIn(Vector3 center, float radius) @@ -396,7 +401,11 @@ namespace RacesOfValheim AlfarEitr.Spend(player, cost); } - if (IsHostile(player, target)) Strike(player, target, AlfarPowerConfig.BeamDps.Value * tick, end); + if (IsHostile(player, target)) + { + Strike(player, target, AlfarPowerConfig.BeamDps.Value * tick, end); + FormMelee.RaiseSkill(Skills.SkillType.ElementalMagic, tick); // a full hit per second on target + } } private static void RaiseHand(Player player) @@ -548,14 +557,19 @@ namespace RacesOfValheim const float tick = 0.5f; nextTick = Time.time + tick; + bool struck = false; foreach (Collider collider in Physics.OverlapSphere(transform.position, Radius, ~0, QueryTriggerInteraction.Ignore)) { Character character = collider.GetComponentInParent(); if (character == null || character == Owner || character.IsDead() || character.IsTamed()) continue; if (!BaseAI.IsEnemy(Owner, character)) continue; AlfarPowers.Strike(Owner, character, DamagePerSecond * tick, character.GetCenterPoint()); + struck = true; } + // Once per tick, not per creature: a full hit per second the storm strikes something. + if (struck && Owner == Player.m_localPlayer) FormMelee.RaiseSkill(Skills.SkillType.ElementalMagic, tick); + Vector2 offset = Random.insideUnitCircle * Radius; AlfarFx.Spawn("fx_JotunWitch_LightningBolt_Explosion", transform.position + new Vector3(offset.x, 0f, offset.y)); } diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index d05d8bb..8367a64 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -1191,6 +1191,7 @@ namespace RacesOfValheim int layerMask = LayerMask.GetMask("character", "character_net", "character_ghost"); var colliders = Physics.OverlapSphere(center, radius, layerMask); + bool hitCreature = false; foreach (var col in colliders) { @@ -1241,10 +1242,16 @@ namespace RacesOfValheim // kill). ApplyDamage() skipped all of that: it edited the local copy of a // character we usually do not own, and the owner overwrote it on the next sync. c.Damage(hd); + hitCreature = true; SpawnBloodVFX(c); } } + + // The aura scales with Blood Magic but called Damage directly, so it never paid + // the skill back. Passive and always on, so it earns what the Skadi's Frost Aura + // does: a tenth of a hit per second of draining, once per tick, not per victim. + if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.BloodMagic, 0.1f * AswidConfig.AuraTickInterval.Value); } catch (Exception ex) { diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index b702a20..d0dd0cd 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -774,6 +774,7 @@ namespace RacesOfValheim Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask); FormMelee.LogSwing(FormLabel, hits.Length); System.Collections.Generic.HashSet hitObjects = new System.Collections.Generic.HashSet(); + bool hitCreature = false; foreach (Collider hit in hits) { @@ -823,10 +824,13 @@ namespace RacesOfValheim FormMelee.LogHit(FormLabel, target, totalDamage); target.Damage(hitData); FormMelee.GrantAdrenaline(target); + if (target is Character) hitCreature = true; } } } } + + if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed); } } @@ -1067,6 +1071,7 @@ namespace RacesOfValheim Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask); FormMelee.LogSwing(FormLabel, hits.Length); System.Collections.Generic.HashSet hitObjects = new System.Collections.Generic.HashSet(); + bool hitCreature = false; foreach (Collider hit in hits) { @@ -1106,6 +1111,7 @@ namespace RacesOfValheim FormMelee.LogHit(FormLabel, target, totalDamage); target.Damage(hitData); FormMelee.GrantAdrenaline(target, 0.2f); // one 0.2s tick: a full hit per second of breath + if (target is Character) hitCreature = true; if (ZNetScene.instance != null) { @@ -1115,6 +1121,8 @@ namespace RacesOfValheim } } } + + if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.ElementalMagic, 0.2f); // one 0.2s tick: a full swing's worth per second of breath } private IEnumerator ClawRoutine() @@ -1231,6 +1239,7 @@ namespace RacesOfValheim Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask); FormMelee.LogSwing(FormLabel, hits.Length); System.Collections.Generic.HashSet hitObjects = new System.Collections.Generic.HashSet(); + bool hitCreature = false; foreach (Collider hit in hits) { @@ -1280,10 +1289,13 @@ namespace RacesOfValheim FormMelee.LogHit(FormLabel, target, totalDamage); target.Damage(hitData); FormMelee.GrantAdrenaline(target); + if (target is Character) hitCreature = true; } } } } + + if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed); } } @@ -1446,6 +1458,7 @@ namespace RacesOfValheim Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask); FormMelee.LogSwing(FormLabel, hits.Length); System.Collections.Generic.HashSet hitObjects = new System.Collections.Generic.HashSet(); + bool hitCreature = false; foreach (Collider hit in hits) { @@ -1495,10 +1508,13 @@ namespace RacesOfValheim FormMelee.LogHit(FormLabel, target, totalDamage); target.Damage(hitData); FormMelee.GrantAdrenaline(target); + if (target is Character) hitCreature = true; } } } } + + if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed); } } @@ -1654,6 +1670,7 @@ namespace RacesOfValheim Collider[] hits = Physics.OverlapSphere(attackPoint, attackRadius, layerMask); FormMelee.LogSwing(FormLabel, hits.Length); System.Collections.Generic.HashSet hitObjects = new System.Collections.Generic.HashSet(); + bool hitCreature = false; foreach (Collider hit in hits) { @@ -1703,10 +1720,13 @@ namespace RacesOfValheim FormMelee.LogHit(FormLabel, target, totalDamage); target.Damage(hitData); FormMelee.GrantAdrenaline(target); + if (target is Character) hitCreature = true; } } } } + + if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed); } private IEnumerator UlvJumpAttackRoutine() diff --git a/JotunnModStub/Fenrir/FenrirFormShared.cs b/JotunnModStub/Fenrir/FenrirFormShared.cs index a26c6ed..259fc08 100644 --- a/JotunnModStub/Fenrir/FenrirFormShared.cs +++ b/JotunnModStub/Fenrir/FenrirFormShared.cs @@ -368,6 +368,21 @@ namespace RacesOfValheim player.AddAdrenaline(perHit * character.m_enemyAdrenalineMultiplier * scale); } + /// + /// The skill experience vanilla gives for a weapon hit, which a hand-built hit never got. + /// Vanilla raises the skill inside Attack (once per swing that landed on a creature) and + /// inside Projectile.OnHit; Character.Damage never does, so a form that calls Damage + /// directly left its skill at whatever level the player brought in. Call it once per + /// swing or tick, after the loop, never once per target. amount lets a damage-over-time + /// tick pay a fraction of a swing. + /// + public static void RaiseSkill(Skills.SkillType skill, float amount = 1f) + { + Player player = Player.m_localPlayer; + if (player == null || amount <= 0f) return; + player.RaiseSkill(skill, amount); + } + /// /// Charges a form attack's stamina the way vanilla charges a weapon's (Attack.GetAttackStamina): /// the equipment modifier, status effects (meads, race passives), then up to a third off with diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index c609ab2..1505ac1 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -874,8 +874,8 @@ namespace RacesOfValheim int foodDuration = Mathf.RoundToInt(TrentaConfig.FoodDurationMultiplier); int purpleRainRadius = Mathf.RoundToInt(TrentaConfig.PurpleRainRadius); - int purpleRainHeal = Mathf.RoundToInt(TrentaConfig.PurpleRainHealAmount); - int purpleRainPoison = Mathf.RoundToInt(TrentaConfig.PurpleRainPoisonDamage); + int purpleRainHeal = Mathf.RoundToInt(TrentaConfig.PurpleRainHealFor(Player.m_localPlayer)); + int purpleRainPoison = Mathf.RoundToInt(TrentaConfig.PurpleRainPoisonFor(Player.m_localPlayer)); int purpleRainCooldown = Mathf.RoundToInt(TrentaConfigManagement.PurpleRainCooldown.Value); int purpleRainMuspellCooldown = Mathf.RoundToInt(TrentaConfigManagement.MuspellPurpleRainCooldown.Value); diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index eeed348..f1335bf 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -599,6 +599,7 @@ namespace RacesOfValheim 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, radius, layerMask); System.Collections.Generic.HashSet hitObjects = new System.Collections.Generic.HashSet(); + bool hitCreature = false; foreach (Collider hit in hits) { @@ -641,7 +642,10 @@ namespace RacesOfValheim target.Damage(hitData); FormMelee.GrantAdrenaline(target); + if (characterTarget != null) hitCreature = true; } + + if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed); } private void OnDestroy() diff --git a/JotunnModStub/Trenta/TrentaAbilities.cs b/JotunnModStub/Trenta/TrentaAbilities.cs index 3809865..088ec3a 100644 --- a/JotunnModStub/Trenta/TrentaAbilities.cs +++ b/JotunnModStub/Trenta/TrentaAbilities.cs @@ -196,7 +196,14 @@ namespace RacesOfValheim // The Trenta stands in its own rain and is healed by it too. It used to be left out, so // a lone Trenta cast a heal that never touched anyone. - player.Heal(TrentaConfig.PurpleRainHealAmount, true); + float heal = TrentaConfig.PurpleRainHealFor(player); + float poison = TrentaConfig.PurpleRainPoisonFor(player); + player.Heal(heal, true); + + // Blood Magic experience once per cast that reached someone besides the caster, the + // way a vanilla staff pays per cast: healing only yourself earns nothing, or the + // skill would level by casting into an empty field on cooldown. + bool reachedSomeone = false; HashSet hit = new HashSet(); foreach (Collider collider in Physics.OverlapSphere(player.transform.position, TrentaConfig.PurpleRainRadius)) @@ -209,16 +216,20 @@ namespace RacesOfValheim if (BaseAI.IsEnemy(player, character)) { HitData hitData = new HitData(); - hitData.m_damage.m_poison = TrentaConfig.PurpleRainPoisonDamage; + hitData.m_damage.m_poison = poison; + hitData.m_skill = Skills.SkillType.BloodMagic; hitData.SetAttacker(player); hitData.m_dir = Vector3.zero; character.Damage(hitData); } else { - character.Heal(TrentaConfig.PurpleRainHealAmount, true); + character.Heal(heal, true); } + reachedSomeone = true; } + + if (reachedSomeone) FormMelee.RaiseSkill(Skills.SkillType.BloodMagic); } /// diff --git a/JotunnModStub/Trenta/TrentaConfig.cs b/JotunnModStub/Trenta/TrentaConfig.cs index 35fc25d..f3a1972 100644 --- a/JotunnModStub/Trenta/TrentaConfig.cs +++ b/JotunnModStub/Trenta/TrentaConfig.cs @@ -120,6 +120,16 @@ namespace RacesOfValheim public static float PurpleRainRadius => TrentaConfigManagement.PurpleRainRadius.Value; public static float PurpleRainHealAmount => TrentaConfigManagement.PurpleRainHealAmount.Value; public static float PurpleRainPoisonDamage => TrentaConfigManagement.PurpleRainPoisonDamage.Value; + + // The base figures plus the Blood Magic bonus, scaled linearly up to the full bonus at + // level 100 - the same shape as the Aswid's Vampiric Aura. The compendium reads these + // too, so its numbers follow the player's skill. + public static float PurpleRainHealFor(Player player) => + PurpleRainHealAmount + BloodMagicFactor(player) * TrentaConfigManagement.PurpleRainBloodMagicHeal.Value; + public static float PurpleRainPoisonFor(Player player) => + PurpleRainPoisonDamage + BloodMagicFactor(player) * TrentaConfigManagement.PurpleRainBloodMagicPoison.Value; + private static float BloodMagicFactor(Player player) => + player != null ? player.GetSkillFactor(Skills.SkillType.BloodMagic) : 0f; // A Poison-type hit; vanilla's own // poison-on-hit handling takes over from // there, same as SkeletonRace's fire aura diff --git a/JotunnModStub/Trenta/TrentaConfigManagement.cs b/JotunnModStub/Trenta/TrentaConfigManagement.cs index 556edf9..09b5752 100644 --- a/JotunnModStub/Trenta/TrentaConfigManagement.cs +++ b/JotunnModStub/Trenta/TrentaConfigManagement.cs @@ -45,6 +45,8 @@ namespace RacesOfValheim public static ConfigEntry PurpleRainRadius; public static ConfigEntry PurpleRainHealAmount; public static ConfigEntry PurpleRainPoisonDamage; + public static ConfigEntry PurpleRainBloodMagicHeal; + public static ConfigEntry PurpleRainBloodMagicPoison; // ─── Bonemass (tier 4+, passive) ────────────────────────────────────── public static ConfigEntry SwimStaminaRegen; @@ -116,6 +118,10 @@ namespace RacesOfValheim new ConfigDescription("Flat heal applied to you and 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))); + PurpleRainBloodMagicHeal = config.Bind(purpleRain, "Blood Magic Heal Bonus", 40f, + new ConfigDescription("Extra heal at 100 Blood Magic skill, added to Ally Heal Amount (scales linearly from 0).", new AcceptableValueRange(0f, 200f))); + PurpleRainBloodMagicPoison = config.Bind(purpleRain, "Blood Magic Poison Bonus", 40f, + new ConfigDescription("Extra poison damage at 100 Blood Magic skill, added to Enemy Poison Damage (scales linearly from 0).", new AcceptableValueRange(0f, 200f))); const string bonemass = "Trenta - Bonemass"; SwimStaminaRegen = config.Bind(bonemass, "Swim Stamina Regen", 0.1f, diff --git a/JotunnModStub/Trenta/TrentaMuspell.cs b/JotunnModStub/Trenta/TrentaMuspell.cs index 3dadb33..a75f761 100644 --- a/JotunnModStub/Trenta/TrentaMuspell.cs +++ b/JotunnModStub/Trenta/TrentaMuspell.cs @@ -435,6 +435,7 @@ namespace RacesOfValheim float totalDamage = baseDamage + unarmedSkillLevel; HashSet hit = new HashSet(); + bool hitCreature = false; foreach (Collider collider in Physics.OverlapSphere(center, radius)) { Character target = collider.GetComponentInParent(); @@ -442,7 +443,12 @@ namespace RacesOfValheim if (!BaseAI.IsEnemy(player, target)) continue; DealDamage(player, target, totalDamage, HitData.DamageType.Blunt, Vector3.zero); + hitCreature = true; } + + // The spike projectile levels Unarmed through vanilla's Projectile.OnHit; the stomp + // calls Damage directly and has to raise the skill itself. + if (hitCreature) FormMelee.RaiseSkill(Skills.SkillType.Unarmed); } ///