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:
parent
b16d1775d8
commit
0f5b5e4868
13 changed files with 200 additions and 57 deletions
|
|
@ -45,21 +45,37 @@ namespace RacesOfValheim
|
|||
// level for a short window past this before letting it start sinking.
|
||||
public float LastPoweredTime { get; set; }
|
||||
|
||||
// The drake's numbers for DirectedFlightPatch. Base flight stays free on purpose - the
|
||||
// drake arrives at the Elder, long before the player has the stamina pool to pay for
|
||||
// simply staying airborne - so only the sprint costs anything.
|
||||
public float TurnSpeed => SkadiConfig.FlightTurnSpeed.Value;
|
||||
public float GlideSpeed => SkadiConfig.FlightGlideSpeed.Value;
|
||||
public float BoostSpeed => SkadiConfig.FlightBoostSpeed.Value;
|
||||
public float SprintSpeed => SkadiConfig.FlightSprintSpeed.Value;
|
||||
public float ReverseSpeed => SkadiConfig.FlightReverseSpeed.Value;
|
||||
// This form's numbers for DirectedFlightPatch. The Drake's base flight defaults to free on
|
||||
// purpose - it arrives at the Elder, long before the player has the stamina pool to pay
|
||||
// for simply staying airborne - so only its sprint costs anything. The Moder pays for
|
||||
// every beat. The Fader never flies, so it falls back on the Drake's set unread.
|
||||
private SkadiConfig.FormFlight Flight =>
|
||||
formRules != null && formRules.Form == SkadiProgression.FormType.Moder ? SkadiConfig.ModerFlight : SkadiConfig.DrakeFlight;
|
||||
|
||||
public float TurnSpeed => Flight.TurnSpeed.Value;
|
||||
public float GlideSpeed => Flight.GlideSpeed.Value;
|
||||
public float BoostSpeed => Flight.BoostSpeed.Value;
|
||||
public float SprintSpeed => Flight.SprintSpeed.Value;
|
||||
public float ReverseSpeed => Flight.ReverseSpeed.Value;
|
||||
// Climbing out of water is deliberately slower than a powered climb in open air - the
|
||||
// wings are dragging themselves free, not racing.
|
||||
public float LiftoffSpeed => SkadiConfig.FlightLiftoffSpeed.Value;
|
||||
public float HoverSeconds => SkadiConfig.FlightHoverSeconds.Value;
|
||||
public float PoweredStaminaPerSecond => 0f;
|
||||
public float SprintStaminaPerSecond => SkadiConfig.FlightSprintStaminaPerSecond.Value;
|
||||
public bool CanPower => true;
|
||||
public float LiftoffSpeed => Flight.LiftoffSpeed.Value;
|
||||
public float HoverSeconds => Flight.HoverSeconds.Value;
|
||||
public float PoweredStaminaPerSecond => Flight.PoweredStaminaPerSecond.Value * EncumberedCostFactor();
|
||||
public float SprintStaminaPerSecond => Flight.SprintStaminaPerSecond.Value * EncumberedCostFactor();
|
||||
public bool CanPower => !(IsEncumbered() && TooHeavyToFly);
|
||||
|
||||
private bool TooHeavyToFly => Flight.Encumbered.Value == AswidConfig.EncumberedMode.Blocked;
|
||||
|
||||
private static bool IsEncumbered()
|
||||
{
|
||||
return Player.m_localPlayer != null && Player.m_localPlayer.IsEncumbered();
|
||||
}
|
||||
|
||||
private float EncumberedCostFactor()
|
||||
{
|
||||
return IsEncumbered() ? 1f + Flight.EncumberedExtraCost.Value : 1f;
|
||||
}
|
||||
|
||||
private SkadiProgression.FormRules formRules;
|
||||
|
||||
|
|
@ -171,7 +187,11 @@ namespace RacesOfValheim
|
|||
(SkadiConfig.FlightToggleKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(1)) &&
|
||||
formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon)
|
||||
{
|
||||
if (!isFlying && !isLanding)
|
||||
if (!isFlying && !isLanding && IsEncumbered() && TooHeavyToFly)
|
||||
{
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_too_heavy_to_fly"));
|
||||
}
|
||||
else if (!isFlying && !isLanding)
|
||||
{
|
||||
isFlying = true;
|
||||
LastPoweredTime = Time.time;
|
||||
|
|
|
|||
|
|
@ -69,15 +69,38 @@ namespace RacesOfValheim
|
|||
public static ConfigEntry<float> FaderSpinDamage;
|
||||
public static ConfigEntry<float> FaderSpinRadius;
|
||||
|
||||
// ─── Directed flight (Drake/Moder) ────────────────────────────────────
|
||||
public static ConfigEntry<float> FlightTurnSpeed;
|
||||
public static ConfigEntry<float> FlightGlideSpeed;
|
||||
public static ConfigEntry<float> FlightBoostSpeed;
|
||||
public static ConfigEntry<float> FlightSprintSpeed;
|
||||
public static ConfigEntry<float> FlightReverseSpeed;
|
||||
public static ConfigEntry<float> FlightLiftoffSpeed;
|
||||
public static ConfigEntry<float> FlightHoverSeconds;
|
||||
public static ConfigEntry<float> FlightSprintStaminaPerSecond;
|
||||
// ─── Dragon forms: flight and timing, one set per form ───────────────────
|
||||
// One section for all three, as Dissolution asked for the bat's knobs on each form: the
|
||||
// keys carry the form's name and an Order, so Configuration Manager lists Drake, then
|
||||
// Moder, then Fader instead of mixing them alphabetically.
|
||||
public class FormFlight
|
||||
{
|
||||
public ConfigEntry<float> TurnSpeed;
|
||||
public ConfigEntry<float> GlideSpeed;
|
||||
public ConfigEntry<float> BoostSpeed;
|
||||
public ConfigEntry<float> SprintSpeed;
|
||||
public ConfigEntry<float> ReverseSpeed;
|
||||
public ConfigEntry<float> LiftoffSpeed;
|
||||
public ConfigEntry<float> HoverSeconds;
|
||||
public ConfigEntry<float> PoweredStaminaPerSecond;
|
||||
public ConfigEntry<float> SprintStaminaPerSecond;
|
||||
public ConfigEntry<AswidConfig.EncumberedMode> Encumbered;
|
||||
public ConfigEntry<float> EncumberedExtraCost;
|
||||
}
|
||||
|
||||
public class FormTiming
|
||||
{
|
||||
// -1 keeps the boss-tier table in SkadiProgression, so an untouched .cfg plays as before.
|
||||
public ConfigEntry<float> MaxDuration;
|
||||
public ConfigEntry<float> DurationPerState;
|
||||
public ConfigEntry<float> Cooldown;
|
||||
}
|
||||
|
||||
public static FormFlight DrakeFlight;
|
||||
public static FormFlight ModerFlight;
|
||||
public static FormTiming DrakeTiming;
|
||||
public static FormTiming ModerTiming;
|
||||
public static FormTiming FaderTiming;
|
||||
|
||||
public static void Bind(ConfigFile config)
|
||||
{
|
||||
|
|
@ -164,23 +187,69 @@ namespace RacesOfValheim
|
|||
FaderSpinRadius = config.Bind(attacks, "Fader Spin Radius", 5f,
|
||||
new ConfigDescription("Hit-sweep radius for the Skeleton Dragon's spin attack.", new AcceptableValueRange<float>(1f, 15f)));
|
||||
|
||||
const string flight = "Skadi - Directed Flight";
|
||||
FlightTurnSpeed = config.Bind(flight, "Turn Speed", 120f,
|
||||
new ConfigDescription("Degrees per second the dragon form turns to face its heading.", new AcceptableValueRange<float>(10f, 360f)));
|
||||
FlightGlideSpeed = config.Bind(flight, "Glide Speed", 5f,
|
||||
new ConfigDescription("Speed while gliding unpowered (no W/S held).", new AcceptableValueRange<float>(0f, 30f)));
|
||||
FlightBoostSpeed = config.Bind(flight, "Boost Speed", 12f,
|
||||
new ConfigDescription("Speed while holding W without sprinting.", new AcceptableValueRange<float>(0f, 50f)));
|
||||
FlightSprintSpeed = config.Bind(flight, "Sprint Speed", 22f,
|
||||
new ConfigDescription("Speed while holding W and Shift, stamina permitting.", new AcceptableValueRange<float>(0f, 60f)));
|
||||
FlightReverseSpeed = config.Bind(flight, "Reverse Speed", 7f,
|
||||
new ConfigDescription("Speed while beating backwards (S).", new AcceptableValueRange<float>(0f, 30f)));
|
||||
FlightLiftoffSpeed = config.Bind(flight, "Liftoff Speed", 9f,
|
||||
new ConfigDescription("Climb speed while clawing out of water.", new AcceptableValueRange<float>(0f, 30f)));
|
||||
FlightHoverSeconds = config.Bind(flight, "Hover Seconds", 5f,
|
||||
new ConfigDescription("How long level flight holds altitude after the last powered input before it starts to sink.", new AcceptableValueRange<float>(0f, 30f)));
|
||||
FlightSprintStaminaPerSecond = config.Bind(flight, "Sprint Stamina Per Second", 15f,
|
||||
new ConfigDescription("Stamina drained per second while the sprint speed is actually granted.", new AcceptableValueRange<float>(0f, 60f)));
|
||||
// Was "Skadi - Directed Flight", one set of numbers for both flying forms. The Drake is
|
||||
// the scout: quick, nimble, free to fly, grounded by a heavy pack. The Moder is the
|
||||
// freighter: slow to turn and paying for every beat, but it lifts what the Drake cannot.
|
||||
const string forms = "Skadi - Dragon Forms";
|
||||
int order = 1000;
|
||||
DrakeFlight = BindFlight(config, forms, "Drake", ref order,
|
||||
turn: 180f, glide: 6f, boost: 14f, sprint: 26f, reverse: 8f, liftoff: 9f, hover: 3f,
|
||||
powered: 0f, sprintCost: 10f, encumbered: AswidConfig.EncumberedMode.Blocked, extraCost: 0.25f);
|
||||
DrakeTiming = BindTiming(config, forms, "Drake", ref order);
|
||||
ModerFlight = BindFlight(config, forms, "Moder", ref order,
|
||||
turn: 80f, glide: 5f, boost: 10f, sprint: 18f, reverse: 6f, liftoff: 9f, hover: 8f,
|
||||
powered: 3f, sprintCost: 15f, encumbered: AswidConfig.EncumberedMode.Allowed, extraCost: 0.25f);
|
||||
ModerTiming = BindTiming(config, forms, "Moder", ref order);
|
||||
FaderTiming = BindTiming(config, forms, "Fader", ref order);
|
||||
}
|
||||
|
||||
private static FormFlight BindFlight(ConfigFile config, string section, string form, ref int order,
|
||||
float turn, float glide, float boost, float sprint, float reverse, float liftoff, float hover,
|
||||
float powered, float sprintCost, AswidConfig.EncumberedMode encumbered, float extraCost)
|
||||
{
|
||||
return new FormFlight
|
||||
{
|
||||
TurnSpeed = config.Bind(section, $"{form} Turn Speed", turn,
|
||||
OrderedDesc($"Degrees per second the {form} turns towards where you aim.", new AcceptableValueRange<float>(10f, 360f), order--)),
|
||||
GlideSpeed = config.Bind(section, $"{form} Glide Speed", glide,
|
||||
OrderedDesc($"{form} speed while gliding with no key held, in m/s.", new AcceptableValueRange<float>(0f, 30f), order--)),
|
||||
BoostSpeed = config.Bind(section, $"{form} Boost Speed", boost,
|
||||
OrderedDesc($"{form} speed while holding W, in m/s. Costs the flight stamina below.", new AcceptableValueRange<float>(0f, 50f), order--)),
|
||||
SprintSpeed = config.Bind(section, $"{form} Sprint Speed", sprint,
|
||||
OrderedDesc($"{form} speed while holding W and Shift, in m/s. Costs the sprint stamina on top.", new AcceptableValueRange<float>(0f, 60f), order--)),
|
||||
ReverseSpeed = config.Bind(section, $"{form} Reverse Speed", reverse,
|
||||
OrderedDesc($"{form} speed while holding S, in m/s. Costs the flight stamina.", new AcceptableValueRange<float>(0f, 30f), order--)),
|
||||
LiftoffSpeed = config.Bind(section, $"{form} Liftoff Speed", liftoff,
|
||||
OrderedDesc($"{form} climb speed out of water, in m/s. Always free, so a form that touches the sea can still leave it.", new AcceptableValueRange<float>(0f, 30f), order--)),
|
||||
HoverSeconds = config.Bind(section, $"{form} Hover Seconds", hover,
|
||||
OrderedDesc($"How long the {form} holds its height after the last powered beat before it starts to sink.", new AcceptableValueRange<float>(0f, 30f), order--)),
|
||||
PoweredStaminaPerSecond = config.Bind(section, $"{form} Flight Stamina Per Second", powered,
|
||||
OrderedDesc($"Stamina per second while the {form} holds W or S. Out of stamina, it can only glide. 0 makes flight free.", new AcceptableValueRange<float>(0f, 60f), order--)),
|
||||
SprintStaminaPerSecond = config.Bind(section, $"{form} Sprint Stamina Per Second", sprintCost,
|
||||
OrderedDesc($"Extra stamina per second while the {form} sprints, on top of the flight cost.", new AcceptableValueRange<float>(0f, 60f), order--)),
|
||||
Encumbered = config.Bind(section, $"{form} While Encumbered", encumbered,
|
||||
OrderedDesc($"Allowed: the {form} flies while you carry too much, at the extra stamina cost below. Blocked: it cannot take off while you are encumbered, and one that becomes encumbered in the air can only glide down. It still walks.", null, order--)),
|
||||
EncumberedExtraCost = config.Bind(section, $"{form} Encumbered Extra Stamina Cost", extraCost,
|
||||
OrderedDesc($"With 'Allowed' above: how much more the {form}'s flight and sprint cost while encumbered. 0.25 = 25% more.", new AcceptableValueRange<float>(0f, 1f), order--)),
|
||||
};
|
||||
}
|
||||
|
||||
private static FormTiming BindTiming(ConfigFile config, string section, string form, ref int order)
|
||||
{
|
||||
return new FormTiming
|
||||
{
|
||||
MaxDuration = config.Bind(section, $"{form} Max Duration", -1f,
|
||||
OrderedDesc($"Seconds the {form} form lasts before you turn back on your own. -1 follows the boss tiers (see the Compendium), 0 means no limit.", new AcceptableValueRange<float>(-1f, 3600f), order--)),
|
||||
DurationPerState = config.Bind(section, $"{form} Duration Per State", 0f,
|
||||
OrderedDesc($"Seconds added to the {form}'s max duration per progression state. Only counts when Max Duration is above 0.", new AcceptableValueRange<float>(0f, 600f), order--)),
|
||||
Cooldown = config.Bind(section, $"{form} Cooldown", -1f,
|
||||
OrderedDesc($"Seconds after leaving the {form} form before you can take it again. -1 follows the boss tiers, 0 means none.", new AcceptableValueRange<float>(-1f, 3600f), order--)),
|
||||
};
|
||||
}
|
||||
|
||||
private static ConfigDescription OrderedDesc(string description, AcceptableValueBase range, int order)
|
||||
{
|
||||
return new ConfigDescription(description, range, new ConfigurationManagerAttributes { Order = order });
|
||||
}
|
||||
|
||||
private static ConfigDescription KeyDesc(string description, int order)
|
||||
|
|
|
|||
|
|
@ -85,7 +85,9 @@ namespace RacesOfValheim
|
|||
rules.Form = FormType.Drake;
|
||||
rules.CanAttackInForm = false;
|
||||
}
|
||||
return rules.Form != FormType.None ? rules : null;
|
||||
if (rules.Form == FormType.None) return null;
|
||||
ApplyTiming(rules, SkadiConfig.DrakeTiming, state);
|
||||
return rules;
|
||||
}
|
||||
|
||||
public static FormRules GetHKeyRules(int state)
|
||||
|
|
@ -112,7 +114,9 @@ namespace RacesOfValheim
|
|||
rules.CooldownMinutes = 10f;
|
||||
rules.CanAttackInForm = true;
|
||||
}
|
||||
return rules.Form != FormType.None ? rules : null;
|
||||
if (rules.Form == FormType.None) return null;
|
||||
ApplyTiming(rules, SkadiConfig.ModerTiming, state);
|
||||
return rules;
|
||||
}
|
||||
|
||||
public static FormRules GetJKeyRules(int state)
|
||||
|
|
@ -125,7 +129,27 @@ namespace RacesOfValheim
|
|||
rules.CooldownMinutes = 0f;
|
||||
rules.CanAttackInForm = true;
|
||||
}
|
||||
return rules.Form != FormType.None ? rules : null;
|
||||
if (rules.Form == FormType.None) return null;
|
||||
ApplyTiming(rules, SkadiConfig.FaderTiming, state);
|
||||
return rules;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The config's timing on top of the tier table above: -1 leaves the table's value, 0 or
|
||||
/// more replaces it. Per-state seconds only stretch a limit that exists, as on the bat.
|
||||
/// </summary>
|
||||
private static void ApplyTiming(FormRules rules, SkadiConfig.FormTiming timing, int state)
|
||||
{
|
||||
if (timing == null) return;
|
||||
|
||||
float max = timing.MaxDuration.Value;
|
||||
if (max >= 0f)
|
||||
rules.DurationMinutes = max > 0f ? (max + timing.DurationPerState.Value * state) / 60f : 0f;
|
||||
else if (rules.DurationMinutes > 0f)
|
||||
rules.DurationMinutes += timing.DurationPerState.Value * state / 60f;
|
||||
|
||||
float cooldown = timing.Cooldown.Value;
|
||||
if (cooldown >= 0f) rules.CooldownMinutes = cooldown / 60f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue