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;
// Check if it died from this hit
if (__state > 0f && __instance.GetHealth() <= 0f)
Character attacker = hit.GetAttacker();
if (attacker != null && attacker.IsPlayer() && attacker == Player.m_localPlayer)
{
Jotunn.Logger.LogInfo($"[AswidDebug] {__instance.name} died. __state: {__state}, CurrentHP: {__instance.GetHealth()}");
Character attacker = hit.GetAttacker();
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>();
if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Aswid")
{
ZNetView nview = attacker.GetComponent<ZNetView>();
if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Aswid")
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;
// 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...");
// Check if physical attack
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)
if (physDamage > 0f)
{
Jotunn.Logger.LogInfo($"[AswidDebug] Calling TryConsumeMob for {__instance.name}");
AswidRace.TryConsumeMob(__instance, __instance.GetMaxHealth());

View file

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