The poison immunity fix before this one was necessary but not sufficient: it kept the damage modifiers current, on an effect that was not there. SE_SkeletonStats carries every damage modifier the race has - pierce and slash resistance, the weakness to blunt, and the poison immunity - and it was applied in exactly one place, the moment the player clicked Skeleton in the race menu. Status effects are not saved with a character and do not survive death, so from the next respawn or the next login onward a Skeleton simply had none of them. That is why a blob still poisoned a tier 5 Skeleton. It is now re-applied whenever it is missing. The Moder regeneration bonus was broken the same way round: SkeletonRace wrote m_healthRegenMultiplier onto the registered template, but SEMan.AddStatusEffect clones what it is given and adds the clone, so the write reached nobody. The effect now sets it on itself, alongside the modifiers it already rebuilds per tier. Also lights the skull. Cosmetic only, worn with the fire-tier model and nothing else. It is parented to the player and moved onto the head bone each frame rather than parented to the bone: the rig is authored at roughly 100x and a particle system inheriting that would put a bonfire where a candle belongs.
70 lines
3.1 KiB
C#
70 lines
3.1 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
public class SE_SkeletonStats : SE_Stats
|
|
{
|
|
// The tier the current m_mods were built for. -1 means "never built".
|
|
private int m_appliedState = -1;
|
|
|
|
public override void Setup(Character character)
|
|
{
|
|
base.Setup(character);
|
|
RebuildForState();
|
|
}
|
|
|
|
public override void UpdateStatusEffect(float dt)
|
|
{
|
|
base.UpdateStatusEffect(dt);
|
|
|
|
// Setup runs once, when the effect is first applied - so the damage modifiers were
|
|
// frozen at whatever tier the player happened to be on then, usually tier 1 because the
|
|
// effect goes on at spawn before a boss is ever killed. Poison immunity therefore never
|
|
// arrived: killing the boss changed the rules, and nothing ever asked them again.
|
|
// Everything else the race does re-reads GetRules per hit, which is why only the
|
|
// modifiers looked broken. Re-check here instead; the state comparison makes it free.
|
|
RebuildForState();
|
|
}
|
|
|
|
private void RebuildForState()
|
|
{
|
|
int state = BossProgressionManager.GetCurrentProgressionState();
|
|
if (state == m_appliedState) return;
|
|
m_appliedState = state;
|
|
|
|
SkeletonProgression.SkeletonRules rules = SkeletonProgression.GetRules(state);
|
|
|
|
// Set here, on the live effect, rather than by SkeletonRace on the registered
|
|
// template: SEMan.AddStatusEffect clones what it is given and adds the clone, so
|
|
// anything written to the template afterwards reaches nobody. That is why the Moder
|
|
// regeneration bonus never applied either.
|
|
m_healthRegenMultiplier = rules.EnhancedRegen ? 1.5f : 1.0f;
|
|
|
|
m_mods = new List<HitData.DamageModPair>
|
|
{
|
|
new HitData.DamageModPair { m_type = HitData.DamageType.Pierce, m_modifier = HitData.DamageModifier.Resistant },
|
|
new HitData.DamageModPair { m_type = HitData.DamageType.Slash, m_modifier = HitData.DamageModifier.Resistant },
|
|
new HitData.DamageModPair { m_type = HitData.DamageType.Blunt, m_modifier = HitData.DamageModifier.Weak }
|
|
};
|
|
|
|
if (rules.PoisonImmunity)
|
|
{
|
|
m_mods.Add(new HitData.DamageModPair { m_type = HitData.DamageType.Poison, m_modifier = HitData.DamageModifier.Immune });
|
|
}
|
|
}
|
|
}
|
|
|
|
public class SE_SkeletonResurrectCooldown : StatusEffect
|
|
{
|
|
public override void Setup(Character character)
|
|
{
|
|
base.Setup(character);
|
|
m_name = "Resurrection Cooldown";
|
|
m_tooltip = "Your skeletal body is too weak to resurrect again right now.";
|
|
m_icon = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>("TrophySkeletonPoison")?.GetComponent<ItemDrop>()?.m_itemData.GetIcon()
|
|
?? Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>("TrophySkeleton")?.GetComponent<ItemDrop>()?.m_itemData.GetIcon();
|
|
m_ttl = 300f; // 5 minutes
|
|
}
|
|
}
|
|
}
|