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
This commit is contained in:
kanym 2026-11-06 21:21:11 +01:00
commit d9bca1934f
11 changed files with 105 additions and 9 deletions

View file

@ -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<Character> hit = new HashSet<Character>();
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);
}
/// <summary>

View file

@ -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

View file

@ -45,6 +45,8 @@ namespace RacesOfValheim
public static ConfigEntry<float> PurpleRainRadius;
public static ConfigEntry<float> PurpleRainHealAmount;
public static ConfigEntry<float> PurpleRainPoisonDamage;
public static ConfigEntry<float> PurpleRainBloodMagicHeal;
public static ConfigEntry<float> PurpleRainBloodMagicPoison;
// ─── Bonemass (tier 4+, passive) ──────────────────────────────────────
public static ConfigEntry<float> SwimStaminaRegen;
@ -116,6 +118,10 @@ namespace RacesOfValheim
new ConfigDescription("Flat heal applied to you and to every ally hit.", new AcceptableValueRange<float>(0f, 200f)));
PurpleRainPoisonDamage = config.Bind(purpleRain, "Enemy Poison Damage", 40f,
new ConfigDescription("Flat poison damage applied to every enemy hit.", new AcceptableValueRange<float>(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<float>(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<float>(0f, 200f)));
const string bonemass = "Trenta - Bonemass";
SwimStaminaRegen = config.Bind(bonemass, "Swim Stamina Regen", 0.1f,

View file

@ -435,6 +435,7 @@ namespace RacesOfValheim
float totalDamage = baseDamage + unarmedSkillLevel;
HashSet<GameObject> hit = new HashSet<GameObject>();
bool hitCreature = false;
foreach (Collider collider in Physics.OverlapSphere(center, radius))
{
Character target = collider.GetComponentInParent<Character>();
@ -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);
}
/// <summary>