Add Aswid passive lifesteal scaling with progression state

This commit is contained in:
Ferdinando 2026-07-30 22:34:26 +02:00
commit 55d2cc97bb
2 changed files with 29 additions and 11 deletions

View file

@ -654,22 +654,38 @@ namespace RacesOfValheim
{ {
if (hit == null || __instance == null || __instance.IsPlayer()) return; if (hit == null || __instance == null || __instance.IsPlayer()) return;
// Check if it died from this hit Character attacker = hit.GetAttacker();
if (__state > 0f && __instance.GetHealth() <= 0f) if (attacker != null && attacker.IsPlayer() && attacker == Player.m_localPlayer)
{ {
Jotunn.Logger.LogInfo($"[AswidDebug] {__instance.name} died. __state: {__state}, CurrentHP: {__instance.GetHealth()}"); ZNetView nview = attacker.GetComponent<ZNetView>();
Character attacker = hit.GetAttacker(); if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Aswid")
if (attacker != null) Jotunn.Logger.LogInfo($"[AswidDebug] Attacker is: {attacker.name} / Player: {attacker.IsPlayer()} / Local: {attacker == Player.m_localPlayer}");
if (attacker != null && attacker.IsPlayer() && attacker == Player.m_localPlayer)
{ {
ZNetView nview = attacker.GetComponent<ZNetView>(); float physDamage = hit.m_damage.m_blunt + hit.m_damage.m_slash + hit.m_damage.m_pierce + hit.m_damage.m_chop + hit.m_damage.m_pickaxe + hit.m_damage.m_damage;
if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Aswid")
// On-hit Lifesteal
if (physDamage > 0f)
{ {
int currentState = BossProgressionManager.GetCurrentProgressionState();
var rules = AswidProgression.GetRules(currentState);
float lifesteal = rules.LifestealPercent;
if (EnvMan.instance != null && EnvMan.IsNight())
{
lifesteal *= 2f;
}
if (lifesteal > 0f)
{
float healAmount = physDamage * lifesteal;
Player.m_localPlayer.Heal(healAmount, true);
}
}
// On-death Devour
if (__state > 0f && __instance.GetHealth() <= 0f)
{
Jotunn.Logger.LogInfo($"[AswidDebug] {__instance.name} died. __state: {__state}, CurrentHP: {__instance.GetHealth()}");
Jotunn.Logger.LogInfo($"[AswidDebug] Attacker is local Aswid player. Checking damage type..."); Jotunn.Logger.LogInfo($"[AswidDebug] Attacker is local Aswid player. Checking damage type...");
// Check if physical attack if (physDamage > 0f)
if (hit.m_damage.m_blunt > 0 || hit.m_damage.m_slash > 0 || hit.m_damage.m_pierce > 0 || hit.m_damage.m_chop > 0 || hit.m_damage.m_pickaxe > 0 || hit.m_damage.m_damage > 0)
{ {
Jotunn.Logger.LogInfo($"[AswidDebug] Calling TryConsumeMob for {__instance.name}"); Jotunn.Logger.LogInfo($"[AswidDebug] Calling TryConsumeMob for {__instance.name}");
AswidRace.TryConsumeMob(__instance, __instance.GetMaxHealth()); AswidRace.TryConsumeMob(__instance, __instance.GetMaxHealth());

View file

@ -23,11 +23,13 @@ namespace RacesOfValheim
public float BonusHealth = 0f; public float BonusHealth = 0f;
public float BonusStamina = 0f; public float BonusStamina = 0f;
public bool HasSurtlingForm = false; public bool HasSurtlingForm = false;
public float LifestealPercent = 0f;
} }
public static AswidRules GetRules(int state) public static AswidRules GetRules(int state)
{ {
AswidRules rules = new AswidRules(); AswidRules rules = new AswidRules();
rules.LifestealPercent = (state * 2f) / 100f; // 2% per state
// State 0 is the base state, no modifiers yet. // State 0 is the base state, no modifiers yet.
if (state >= 1) if (state >= 1)