feat(skadi): each dragon form flies and cools down on its own terms

The Drake and the Moder shared one set of flight numbers, so once the
Moder lost its time limit at the Queen the Drake had no reason left.
Now the Drake is the scout: quick to turn, fast, free to fly, but it
will not take off while encumbered. The Moder is the freighter: slow to
turn, 3 stamina a second to beat its wings, and it lifts a heavy pack at
25% extra cost.

"Skadi - Directed Flight" becomes "Skadi - Dragon Forms", with every
flight number per form plus the bat's Flight Stamina, While Encumbered,
Encumbered Extra Stamina Cost, Max Duration, Duration Per State and
Cooldown. Duration and cooldown default to -1, which keeps the
boss-tier table.

Each form also gets its own cooldown effect and icon, so a cooldown on
one form no longer blocks another. Suggested by Dissolution.
This commit is contained in:
kanym 2026-11-02 15:58:17 +01:00
commit 0f5b5e4868
13 changed files with 200 additions and 57 deletions

View file

@ -79,11 +79,11 @@ namespace RacesOfValheim
// drake one used for the passive blessing.
Sprite dragonIcon = GetItemIcon("TrophyDragonQueen") ?? GetItemIcon("TrophyHatchling");
skadiCdSE = ScriptableObject.CreateInstance<SE_FormCooldown>();
skadiCdSE.name = "SE_SkadiCooldown";
skadiCdSE.m_name = "$rov_se_skadi_formcd_name";
skadiCdSE.m_icon = dragonIcon;
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(skadiCdSE, fixReference: false));
// One cooldown per form, so a Drake cooldown set in the config never holds the Moder
// back, nor the other way round. The Moder keeps the original name.
skadiCdSE = RegisterFormCooldown(SkadiProgression.FormType.Moder, "$rov_se_skadi_formcd_name", dragonIcon);
RegisterFormCooldown(SkadiProgression.FormType.Drake, "$rov_se_skadi_drakecd_name", GetItemIcon("TrophyHatchling") ?? dragonIcon);
RegisterFormCooldown(SkadiProgression.FormType.SkeletonDragon, "$rov_se_skadi_fadercd_name", GetItemIcon("TrophyFader") ?? dragonIcon);
skadiFormSE = ScriptableObject.CreateInstance<SE_SkadiForm>();
skadiFormSE.name = "SE_SkadiForm";
@ -124,6 +124,26 @@ namespace RacesOfValheim
if (se != null) se.m_ttl = seconds;
}
private static SE_FormCooldown RegisterFormCooldown(SkadiProgression.FormType form, string displayName, Sprite icon)
{
SE_FormCooldown cd = ScriptableObject.CreateInstance<SE_FormCooldown>();
cd.name = CooldownSEName(form);
cd.m_name = displayName;
cd.m_icon = icon;
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(cd, fixReference: false));
return cd;
}
private static string CooldownSEName(SkadiProgression.FormType form)
{
switch (form)
{
case SkadiProgression.FormType.Drake: return "SE_SkadiCooldown_Drake";
case SkadiProgression.FormType.SkeletonDragon: return "SE_SkadiCooldown_Fader";
default: return "SE_SkadiCooldown";
}
}
private static Sprite GetItemIcon(string prefabName)
{
GameObject trophy = PrefabManager.Cache.GetPrefab<ItemDrop>(prefabName)?.gameObject;
@ -687,7 +707,7 @@ namespace RacesOfValheim
if (rules.CooldownMinutes > 0)
{
var cdSE = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_SkadiCooldown".GetStableHashCode());
var cdSE = Player.m_localPlayer.GetSEMan().GetStatusEffect(CooldownSEName(rules.Form).GetStableHashCode());
if (cdSE != null)
{
float m_time = HarmonyLib.Traverse.Create(cdSE).Field<float>("m_time").Value;
@ -983,8 +1003,9 @@ namespace RacesOfValheim
if (activeRules != null && activeRules.CooldownMinutes > 0)
{
Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_SkadiCooldown".GetStableHashCode(), true);
var cdSE = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_SkadiCooldown".GetStableHashCode());
int cdHash = CooldownSEName(activeRules.Form).GetStableHashCode();
Player.m_localPlayer.GetSEMan().AddStatusEffect(cdHash, true);
var cdSE = Player.m_localPlayer.GetSEMan().GetStatusEffect(cdHash);
if (cdSE != null) cdSE.m_ttl = activeRules.CooldownMinutes * 60f;
}
activeRules = null;