Rework Skadi dragon flight, enforce form duration, surface timers in HUD

Flight ran on the debug-fly noclip, so it ignored aim entirely and needed
Space/Ctrl for height. It now uses Character's native flying-creature
movement with the camera's full look direction fed in each frame:

- Aim steers, including climb and dive; W powers forward, releasing it
  holds level briefly and then settles into a glide instead of coasting
  along the aim vector (which let you climb forever without input).
- The body actually turns now. m_flyTurnSpeed sat at Character's 12 deg/s
  default because the Player prefab was never set up to fly, so a quarter
  turn took over seven seconds and read as no rotation at all.
- Touching down no longer slides you forward forever. Zeroing the fly
  speeds stops the character without fighting the AddForce UpdateFlying
  queues, which had caused frame-to-frame jitter and TAA ghosting.

DurationMinutes was never wired to anything, so timed forms never expired
and their cooldown, which only starts on reversion, was unreachable in
practice. Timed forms now drop on their own, and both the remaining time
and the cooldown show up beside the minimap as a Moder trophy icon.

Attack capability was snapshotted when the form was entered, so reaching
the Bonemass tier while already transformed left the drake unarmed until
the player reverted and transformed again; it is re-read live now.
This commit is contained in:
kanym 2026-07-31 16:25:06 +02:00
commit cccabe16ef
5 changed files with 193 additions and 21 deletions

View file

@ -11,6 +11,7 @@ namespace RacesOfValheim
public static SkadiRace Instance;
public static SE_SkadiStats skadiCurseSE;
public static SE_FormCooldown skadiCdSE;
public static SE_SkadiForm skadiFormSE;
private float auraTimer = 0f;
private float lastSpellTime = 0f;
@ -18,6 +19,8 @@ namespace RacesOfValheim
private bool isTransformed = false;
private bool isTransformingSequence = false;
private SkadiProgression.FormRules activeRules = null;
// Time.time at which a timed form drops; 0 means the current form has no time limit.
private float formExpireTime = 0f;
private float lastAuraTime = 0f;
private GameObject frostAuraVFX = null;
@ -47,18 +50,33 @@ namespace RacesOfValheim
ItemManager.Instance.AddStatusEffect(skadiStats);
skadiCurseSE = skadiStats.StatusEffect as SE_SkadiStats;
// Timed forms and their cooldown are Moder's, so they carry her trophy rather than the
// drake one used for the passive blessing.
Sprite dragonIcon = GetTrophyIcon("TrophyDragonQueen") ?? GetTrophyIcon("TrophyHatchling");
skadiCdSE = ScriptableObject.CreateInstance<SE_FormCooldown>();
skadiCdSE.name = "SE_SkadiCooldown";
skadiCdSE.m_name = "Dragon Form Cooldown";
if (drakeTrophy != null)
{
ItemDrop trophyDrop = drakeTrophy.GetComponent<ItemDrop>();
if (trophyDrop != null && trophyDrop.m_itemData.m_shared.m_icons.Length > 0)
{
skadiCdSE.m_icon = trophyDrop.m_itemData.m_shared.m_icons[0];
}
}
skadiCdSE.m_icon = dragonIcon;
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(skadiCdSE, fixReference: false));
skadiFormSE = ScriptableObject.CreateInstance<SE_SkadiForm>();
skadiFormSE.name = "SE_SkadiForm";
skadiFormSE.m_name = "Dragon Form";
skadiFormSE.m_tooltip = "Your dragon shape holds for a while longer.";
skadiFormSE.m_icon = dragonIcon;
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(skadiFormSE, fixReference: false));
}
private static Sprite GetTrophyIcon(string prefabName)
{
GameObject trophy = PrefabManager.Cache.GetPrefab<ItemDrop>(prefabName)?.gameObject;
ItemDrop drop = trophy != null ? trophy.GetComponent<ItemDrop>() : null;
if (drop != null && drop.m_itemData.m_shared.m_icons.Length > 0)
{
return drop.m_itemData.m_shared.m_icons[0];
}
return null;
}
@ -139,6 +157,16 @@ namespace RacesOfValheim
if (isTransformingSequence) return;
// Forms with a DurationMinutes budget drop on their own once it runs out, which is
// also what starts their cooldown - without this the timed tiers never expired.
if (isTransformed && formExpireTime > 0f && Time.time >= formExpireTime)
{
formExpireTime = 0f;
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Your dragon form fades.");
StartCoroutine(RevertToHumanRoutine());
return;
}
int state = BossProgressionManager.GetCurrentProgressionState();
if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(SkadiProgression.GetGKeyRules(state)); return; }
if (Input.GetKeyDown(KeyCode.H)) { TryTransformWithRules(SkadiProgression.GetHKeyRules(state)); return; }
@ -589,10 +617,33 @@ namespace RacesOfValheim
else if (prefabName == "Fader") Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are Fader!");
isTransformed = true;
StartFormTimer(rules);
}
}
}
// Drives both the expiry check in Update and the HUD icon: the status effect exists purely
// so Valheim draws Moder's trophy with its own countdown next to the minimap.
private void StartFormTimer(SkadiProgression.FormRules rules)
{
int hash = "SE_SkadiForm".GetStableHashCode();
SEMan seman = Player.m_localPlayer.GetSEMan();
seman.RemoveStatusEffect(hash, true);
if (rules.DurationMinutes <= 0f)
{
formExpireTime = 0f;
return;
}
float seconds = rules.DurationMinutes * 60f;
formExpireTime = Time.time + seconds;
seman.AddStatusEffect(hash, true);
StatusEffect se = seman.GetStatusEffect(hash);
if (se != null) se.m_ttl = seconds;
}
private void ExecuteReversion()
{
Transform playerVisual = Player.m_localPlayer.transform.Find("Visual");
@ -615,6 +666,8 @@ namespace RacesOfValheim
}
isTransformed = false;
formExpireTime = 0f;
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_SkadiForm".GetStableHashCode(), true);
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You returned to human form.");
if (activeRules != null && activeRules.CooldownMinutes > 0)