fix-skadi-race #2
3 changed files with 82 additions and 8 deletions
Fix Skadi resetrace, cold spell VFX, and Freezing-to-Cold conversion
- resetrace never cleaned up SE_SkadiStats/SE_SkadiCooldown, so Skadi's Aura and its frost buffs stuck around after switching race. - Cold Spell projectile spawned near the feet (0.4m) and used the unarmed kick animation; now spawns at chest height and uses the galdr_cast (raised-arms) trigger instead. - Freezing-to-Cold silently did nothing from tier 1 onward: Skadi's passive Frost damage resistance made Valheim's own environmental check skip Cold/Freezing entirely before our conversion patch ever ran. Added a scoped patch that neutralizes just that environmental check for the local Skadi player, plus a guard against Valheim's own Cold-removal call flickering the converted status off every other frame, plus an explicit cleanup of any real Freezing left over from before the conversion kicked in. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
commit
00b1b4e9ed
|
|
@ -600,6 +600,8 @@ namespace RacesOfValheim
|
||||||
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_FenrirCurse".GetStableHashCode());
|
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_FenrirCurse".GetStableHashCode());
|
||||||
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_AswidStats".GetStableHashCode());
|
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_AswidStats".GetStableHashCode());
|
||||||
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_SkeletonStats".GetStableHashCode());
|
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_SkeletonStats".GetStableHashCode());
|
||||||
|
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_SkadiStats".GetStableHashCode());
|
||||||
|
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_SkadiCooldown".GetStableHashCode());
|
||||||
|
|
||||||
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
|
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
|
||||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Human");
|
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Human");
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,10 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
if (rules.FreezingToCold)
|
if (rules.FreezingToCold)
|
||||||
{
|
{
|
||||||
|
// Strip any real Freezing that may already be active (e.g. applied
|
||||||
|
// before this tier's conversion kicked in) so it can't linger
|
||||||
|
// alongside the converted Cold status.
|
||||||
|
__instance.RemoveStatusEffect("Freezing".GetStableHashCode(), true);
|
||||||
nameHash = "Cold".GetStableHashCode();
|
nameHash = "Cold".GetStableHashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -106,6 +110,73 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SE_SkadiStats grants a "Resistant" (or higher) Frost damage modifier from tier 1 onward,
|
||||||
|
// exactly like drinking a Frost Resistance potion. Valheim's own Player.UpdateEnvStatusEffects
|
||||||
|
// checks that same Frost damage modifier before deciding whether to apply Cold/Freezing at
|
||||||
|
// all, and skips both entirely once the character is Frost-resistant. That means real Mountain
|
||||||
|
// exposure (which applies Freezing, not Cold, per vanilla rules) never even reaches
|
||||||
|
// SkadiSEManPatch above from tier 1 onward, so the tier 2 "Freezing to Cold" conversion never
|
||||||
|
// gets a chance to run. These two patches scope out just that one environmental check: while
|
||||||
|
// Player.UpdateEnvStatusEffects is running for the local Skadi player, GetDamageModifiers is
|
||||||
|
// reported as Normal for Frost, so vanilla always attempts to apply the real status and
|
||||||
|
// SkadiSEManPatch's per-tier logic (block/convert/allow) is what actually decides the outcome.
|
||||||
|
// Frost damage resistance from hits (SkadiDamagePatch) is untouched by this.
|
||||||
|
[HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")]
|
||||||
|
public static class SkadiEnvCheckScope
|
||||||
|
{
|
||||||
|
public static bool Active = false;
|
||||||
|
|
||||||
|
public static void Prefix(Player __instance)
|
||||||
|
{
|
||||||
|
Active = __instance == Player.m_localPlayer && SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Postfix()
|
||||||
|
{
|
||||||
|
Active = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(Character), "GetDamageModifiers")]
|
||||||
|
public static class SkadiEnvFrostModifierPatch
|
||||||
|
{
|
||||||
|
public static void Postfix(Character __instance, ref HitData.DamageModifiers __result)
|
||||||
|
{
|
||||||
|
if (SkadiEnvCheckScope.Active && __instance == Player.m_localPlayer)
|
||||||
|
{
|
||||||
|
__result.m_frost = HitData.DamageModifier.Normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valheim's Player.UpdateEnvStatusEffects always tries RemoveStatusEffect(Cold, quiet:true)
|
||||||
|
// as the first step of applying Freezing. Since SkadiSEManPatch redirects Freezing into Cold,
|
||||||
|
// that removal would strip our converted Cold status every other frame (a permanent
|
||||||
|
// add/remove flicker that cancels the buff out). Blocking just this "quiet" removal for the
|
||||||
|
// FreezingToCold player forces Valheim to always fall through to AddStatusEffect(Freezing,...),
|
||||||
|
// which SkadiSEManPatch converts to a stable, non-resetting Cold re-application instead.
|
||||||
|
[HarmonyPatch(typeof(SEMan), "RemoveStatusEffect", new System.Type[] { typeof(int), typeof(bool) })]
|
||||||
|
public static class SkadiColdRemovalGuardPatch
|
||||||
|
{
|
||||||
|
public static bool Prefix(SEMan __instance, int nameHash, bool quiet, ref bool __result)
|
||||||
|
{
|
||||||
|
if (quiet && nameHash == "Cold".GetStableHashCode())
|
||||||
|
{
|
||||||
|
Character character = Traverse.Create(__instance).Field<Character>("m_character").Value;
|
||||||
|
if (character == Player.m_localPlayer && SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi())
|
||||||
|
{
|
||||||
|
var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState());
|
||||||
|
if (rules.FreezingToCold && !rules.ImmuneToFreezing)
|
||||||
|
{
|
||||||
|
__result = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Character), "ApplyDamage")]
|
[HarmonyPatch(typeof(Character), "ApplyDamage")]
|
||||||
public static class SkadiDamagePatch
|
public static class SkadiDamagePatch
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ namespace RacesOfValheim
|
||||||
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return;
|
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return;
|
||||||
if (isTransformed) return; // Do not cast human spell while in dragon form
|
if (isTransformed) return; // Do not cast human spell while in dragon form
|
||||||
|
|
||||||
// Middle Mouse Button to cast (Kick)
|
// Middle Mouse Button to cast
|
||||||
if (Input.GetMouseButtonDown(2))
|
if (Input.GetMouseButtonDown(2))
|
||||||
{
|
{
|
||||||
float cooldown = rules.ImprovedColdSpell ? 2.0f : 1.5f;
|
float cooldown = rules.ImprovedColdSpell ? 2.0f : 1.5f;
|
||||||
|
|
@ -246,10 +246,11 @@ namespace RacesOfValheim
|
||||||
lastSpellTime = Time.time;
|
lastSpellTime = Time.time;
|
||||||
|
|
||||||
var zanim = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field<ZSyncAnimation>("m_zanim").Value;
|
var zanim = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field<ZSyncAnimation>("m_zanim").Value;
|
||||||
if (zanim != null)
|
if (zanim != null)
|
||||||
{
|
{
|
||||||
// Forcing secondary attack trigger, which is kick when unarmed
|
// Raised-arms Galdr cast gesture instead of the unarmed kick, so the cast
|
||||||
zanim.SetTrigger("secondary");
|
// reads as a spell instead of a leg swing near the ground.
|
||||||
|
zanim.SetTrigger("galdr_cast");
|
||||||
}
|
}
|
||||||
|
|
||||||
StartCoroutine(ColdSpellKickCoroutine(rules));
|
StartCoroutine(ColdSpellKickCoroutine(rules));
|
||||||
|
|
@ -258,7 +259,7 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
private IEnumerator ColdSpellKickCoroutine(SkadiProgression.FormRules rules)
|
private IEnumerator ColdSpellKickCoroutine(SkadiProgression.FormRules rules)
|
||||||
{
|
{
|
||||||
// Wait for the kick animation to reach the extension point
|
// Wait for the cast animation to reach the release point
|
||||||
yield return new WaitForSeconds(0.4f);
|
yield return new WaitForSeconds(0.4f);
|
||||||
|
|
||||||
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) yield break;
|
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) yield break;
|
||||||
|
|
@ -287,16 +288,16 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) break;
|
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) break;
|
||||||
|
|
||||||
// Spawn from the foot (low position, forward)
|
// Spawn from chest height, forward
|
||||||
Vector3 lookDir = Player.m_localPlayer.GetLookDir();
|
Vector3 lookDir = Player.m_localPlayer.GetLookDir();
|
||||||
|
|
||||||
// Add a small spread for the improved blast
|
// Add a small spread for the improved blast
|
||||||
if (rules.ImprovedColdSpell && i > 0)
|
if (rules.ImprovedColdSpell && i > 0)
|
||||||
{
|
{
|
||||||
lookDir = Quaternion.Euler(UnityEngine.Random.Range(-5f, 5f), UnityEngine.Random.Range(-5f, 5f), 0f) * lookDir;
|
lookDir = Quaternion.Euler(UnityEngine.Random.Range(-5f, 5f), UnityEngine.Random.Range(-5f, 5f), 0f) * lookDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 spawnPos = Player.m_localPlayer.transform.position + Vector3.up * 0.4f + lookDir * 0.6f;
|
Vector3 spawnPos = Player.m_localPlayer.transform.position + Vector3.up * 1.4f + lookDir * 0.6f;
|
||||||
|
|
||||||
GameObject projInstance = Instantiate(projPrefab, spawnPos, Quaternion.LookRotation(lookDir));
|
GameObject projInstance = Instantiate(projPrefab, spawnPos, Quaternion.LookRotation(lookDir));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue