diff --git a/JotunnModStub/Fenrir/FenrirConfig.cs b/JotunnModStub/Fenrir/FenrirConfig.cs index 67f695a..17a26cd 100644 --- a/JotunnModStub/Fenrir/FenrirConfig.cs +++ b/JotunnModStub/Fenrir/FenrirConfig.cs @@ -199,7 +199,7 @@ namespace RacesOfValheim ReadyMessage = config.Bind(appearance, "Ready Message", true, new ConfigDescription("Shows \"
is Ready!\" when a form's cooldown ends. The eyes say the same thing; turn this off if they are enough.")); EyeGlow = config.Bind(appearance, "Eye Glow", true, - new ConfigDescription("Fenrir eyes glow at night in the Fenring's own orange: faint while no form can be taken, bright when one can. Off hides them on every Fenrir you see.")); + new ConfigDescription("Fenrir eyes glow at night in the Fenring's own orange: faint while no form can be taken, bright when one can, yellow when the Cultist is back from its cooldown. Off hides them on every Fenrir you see.")); // Above 0.5 so the red channel (2.0 x strength) passes 1 and the bloom pass picks it // up: at 0.35 the faint state read as no glow at all. EyeNightStrength = config.Bind(appearance, "Eye Night Strength", 0.6f, diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs index 9feeb51..963737b 100644 --- a/JotunnModStub/Fenrir/FenrirRace.cs +++ b/JotunnModStub/Fenrir/FenrirRace.cs @@ -150,7 +150,7 @@ namespace RacesOfValheim { } wasNight = isNight; - FenrirVisuals.SetReady(Player.m_localPlayer, CanTakeAnyForm()); + FenrirVisuals.SetReady(Player.m_localPlayer, GetReadyState()); if (isTransformed) { @@ -174,17 +174,26 @@ namespace RacesOfValheim { } /// - /// Whether one of the three keys would transform right now. The same gates as - /// TryTransformWithRules below, without its messages: this feeds the eye glow. + /// What the eyes should say right now, using the same gates as TryTransformWithRules + /// below without its messages. The Cultist wins over the other forms only while its rules + /// give it a cooldown: that is the one form whose return is worth announcing. /// - private bool CanTakeAnyForm() + private FenrirVisuals.ReadyState GetReadyState() { - if (isTransformed) return false; + if (isTransformed) return FenrirVisuals.ReadyState.None; int state = BossProgressionManager.GetCurrentProgressionState(); - return CanTake(FenrirProgression.GetGKeyRules(state)) + FenrirProgression.FormRules cultist = FenrirProgression.GetJKeyRules(state); + + if (CanTake(cultist) && cultist.CooldownMinutes > 0) return FenrirVisuals.ReadyState.Cultist; + + if (CanTake(FenrirProgression.GetGKeyRules(state)) || CanTake(FenrirProgression.GetHKeyRules(state)) - || CanTake(FenrirProgression.GetJKeyRules(state)); + || CanTake(cultist)) + { + return FenrirVisuals.ReadyState.Form; + } + return FenrirVisuals.ReadyState.None; } private bool CanTake(FenrirProgression.FormRules rules) diff --git a/JotunnModStub/Fenrir/FenrirVisuals.cs b/JotunnModStub/Fenrir/FenrirVisuals.cs index 7b901c0..fd0836b 100644 --- a/JotunnModStub/Fenrir/FenrirVisuals.cs +++ b/JotunnModStub/Fenrir/FenrirVisuals.cs @@ -7,7 +7,8 @@ namespace RacesOfValheim { /// /// The Fenrir's eyes catch the light at night, the way a wolf's do: a faint glow while no form - /// can be taken, a bright one when a key would transform right now. Dark by day and while in a + /// can be taken, a bright one when a key would transform right now, and the Cultist's yellow + /// when that form is back from its cooldown. Dark by day and while in a /// beast form, whose own eyes take over. A community suggestion (lexsonn), meant to say what /// the "Ready!" text says without the text. /// @@ -26,6 +27,14 @@ namespace RacesOfValheim { public const string RaceId = "Fenrir"; public const string ReadyKey = "RacesOfValheim_FenrirReady"; + + /// Written to the ZDO as an int, so the values are part of the network contract. + public enum ReadyState + { + None = 0, + Form = 1, + Cultist = 2, + } private const string FormKey = "RacesOfValheim_FenrirForm"; private const string EyesName = "FenrirEyes"; private const string SourceModel = "Skeleton"; @@ -33,6 +42,11 @@ namespace RacesOfValheim private static readonly Color FenringGlow = new Color(2.0f, 0.372f, 0f, 1f); + // The Cultist's body is the Fenring's material and its breath is white flame tinted by + // texture, so neither tells it apart. Its own death effect (vfx_fenring_cultist_death) + // does: FlameRoundYellowParticle's _EmissionColor, same bundle. + private static readonly Color CultistGlow = new Color(2.691f, 1.797f, 0.455f, 1f); + // AswidVisuals' base placement plus its Configuration Manager defaults, which are what // playtesting settled on for this same pair of eyes on this same rig. private const float EyeForward = 0.081f + 0.013f; @@ -43,13 +57,13 @@ namespace RacesOfValheim private const float EyeRoll = -180f; /// Owner only, and only on a change: one ZDO write per transition, not per frame. - public static void SetReady(Player player, bool ready) + public static void SetReady(Player player, ReadyState ready) { ZNetView nview = player != null ? player.GetComponent() : null; if (nview == null || !nview.IsValid() || !nview.IsOwner()) return; ZDO zdo = nview.GetZDO(); - if (zdo.GetBool(ReadyKey, false) != ready) zdo.Set(ReadyKey, ready); + if (zdo.GetInt(ReadyKey, 0) != (int)ready) zdo.Set(ReadyKey, (int)ready); } /// @@ -81,7 +95,7 @@ namespace RacesOfValheim if (player.GetComponent() == null) player.gameObject.AddComponent(); - float strength = GetGlowStrength(player); + float strength = GetGlowStrength(player, out Color hue); if (strength <= 0f) { if (eyes != null && eyes.gameObject.activeSelf) eyes.gameObject.SetActive(false); @@ -98,12 +112,17 @@ namespace RacesOfValheim } if (!eyes.gameObject.activeSelf) eyes.gameObject.SetActive(true); - PaintEyes(eyes, FenringGlow * strength); + PaintEyes(eyes, hue * strength); } - /// 0 means dark: day, a beast form, or the viewer turned the glow off. - private static float GetGlowStrength(Player player) + /// + /// 0 means dark: day, a beast form, or the viewer turned the glow off. Otherwise faint + /// orange with nothing ready, bright orange with a form ready, bright yellow when the + /// Cultist is back from its cooldown. + /// + private static float GetGlowStrength(Player player, out Color hue) { + hue = FenringGlow; if (!FenrirConfig.EyeGlow.Value) return 0f; if (EnvMan.instance == null || !EnvMan.IsNight()) return 0f; @@ -113,9 +132,11 @@ namespace RacesOfValheim ZDO zdo = nview.GetZDO(); if (!string.IsNullOrEmpty(zdo.GetString(FormKey, ""))) return 0f; - return zdo.GetBool(ReadyKey, false) - ? FenrirConfig.EyeReadyStrength.Value - : FenrirConfig.EyeNightStrength.Value; + ReadyState ready = (ReadyState)zdo.GetInt(ReadyKey, 0); + if (ready == ReadyState.None) return FenrirConfig.EyeNightStrength.Value; + + if (ready == ReadyState.Cultist) hue = CultistGlow; + return FenrirConfig.EyeReadyStrength.Value; } public class EyeTicker : MonoBehaviour