diff --git a/JotunnModStub/Skeleton/SkeletonRace.cs b/JotunnModStub/Skeleton/SkeletonRace.cs index 8f7438c..1d82864 100644 --- a/JotunnModStub/Skeleton/SkeletonRace.cs +++ b/JotunnModStub/Skeleton/SkeletonRace.cs @@ -228,9 +228,16 @@ namespace RacesOfValheim if (Player.m_localPlayer == null) return; - if (!IsSkeleton() || Player.m_localPlayer.IsDead()) + if (!IsSkeleton() || Player.m_localPlayer.IsDead()) { + // Everything the race puts on the player has to come off here, because this is the + // only path taken once they stop being one. A Fader-tier Skeleton who reset to + // Human kept a burning skull and a collapsed jaw, since neither the flame nor the + // jaw was ever switched back from outside the Skeleton branch below. EnsureFireAuraVFX(false); + EnsureHeadFlameVFX(false); + RestoreJawBone(); + if (Player.m_localPlayer.transform.localScale != Vector3.one) { Player.m_localPlayer.transform.localScale = Vector3.one; @@ -305,25 +312,12 @@ namespace RacesOfValheim } } - // Hide Charred Twitcher Jaw - if (currentVis != null && currentVis.m_bodyModel != null && currentVis.m_bodyModel.bones != null) - { - foreach (Transform bone in currentVis.m_bodyModel.bones) - { - if (bone != null && bone.name.ToLower().Contains("jaw")) - { - if (state >= 8) - { - if (bone.localScale != Vector3.zero) bone.localScale = Vector3.zero; - } - else - { - if (bone.localScale == Vector3.zero) bone.localScale = Vector3.one; - } - break; - } - } - } + // Fader used to collapse this bone, because the charred twitcher it wore there carried + // a jaw of its own and the two doubled up. That model is gone from every tier now, and + // the skeleton worn in its place has a jaw that belongs on the face - so the tier lost + // its mandible for no reason at all. Kept as a restore so anyone left with a collapsed + // jaw by the old build gets it back. + RestoreJawBone(); // Apply Scale Vector3 targetScale = rules.ScaleMultiplier; @@ -423,6 +417,25 @@ namespace RacesOfValheim } } + /// + /// Puts the player's jaw back if anything collapsed it. Safe to call every frame and for + /// any race - it does nothing unless the bone is actually at zero scale. + /// + private static void RestoreJawBone() + { + VisEquipment vis = Player.m_localPlayer != null + ? Player.m_localPlayer.GetComponent() + : null; + if (vis == null || vis.m_bodyModel == null || vis.m_bodyModel.bones == null) return; + + foreach (Transform bone in vis.m_bodyModel.bones) + { + if (bone == null || !bone.name.ToLower().Contains("jaw")) continue; + if (bone.localScale == Vector3.zero) bone.localScale = Vector3.one; + break; + } + } + /// /// Flames burning on the skull. Cosmetic only - it deals nothing and blocks nothing. ///