feat(skadi): add Rime Feather hover trinket (Mountain faction feature)
Utility-slot item cloned from Megingjord: holding Space while airborne climbs at a steady rate (stamina-gated), letting go caps the fall speed into a free Drake-glide-inspired float instead of a hard drop, and feather fall is always on while equipped via the item's own m_fallDamageModifier equip effect. Independent of DrakeFormBehavior/Character.m_flying on purpose. Crafts at a plain Forge for now (FreezeGland x5 + Silver x5) - the Factions merchant-gate item and a race lock on the fall-damage effect are still open, see MOUNTAIN-FACTION-BRAINSTORM.md.
This commit is contained in:
parent
b34deef2de
commit
c320fa5b2b
5 changed files with 183 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -31,4 +31,5 @@ CONFIGURATION-MANAGER-HOWTO.md
|
|||
|
||||
# Personal reference notes - not part of the mod itself
|
||||
FACTIONS-KNOWLEDGE.md
|
||||
SESSION-NOTES.md
|
||||
SESSION-NOTES.md
|
||||
MOUNTAIN-FACTION-BRAINSTORM.md
|
||||
|
|
@ -107,6 +107,7 @@ namespace RacesOfValheim
|
|||
RaceMenuWard.Register();
|
||||
FenrirRace.Instance.CreateModAssets();
|
||||
SkadiRace.Instance.CreateModAssets();
|
||||
SkadiHoverTrinket.Register();
|
||||
SkeletonRace.Instance.CreateModAssets();
|
||||
AswidRace.Instance.CreateModAssets();
|
||||
FurlingRace.Instance.CreateModAssets();
|
||||
|
|
|
|||
|
|
@ -63,6 +63,15 @@ namespace RacesOfValheim
|
|||
public static ConfigEntry<float> FaderSpinDamage;
|
||||
public static ConfigEntry<float> FaderSpinRadius;
|
||||
|
||||
// ─── Hover Trinket (Rime Feather) ───────────────────────────────────
|
||||
// Deliberately separate from the Directed Flight block below: this is the always-available
|
||||
// base-form trinket (hold Space while airborne to climb), not the Elder-onward Drake/Moder
|
||||
// form transformation. See SkadiHoverTrinket.cs.
|
||||
public static ConfigEntry<float> TrinketAscendSpeed;
|
||||
public static ConfigEntry<float> TrinketStaminaPerSecond;
|
||||
public static ConfigEntry<float> TrinketGlideFallSpeed;
|
||||
public static ConfigEntry<float> TrinketFallDamageReduction;
|
||||
|
||||
// ─── Directed flight (Drake/Moder) ────────────────────────────────────
|
||||
public static ConfigEntry<float> FlightTurnSpeed;
|
||||
public static ConfigEntry<float> FlightGlideSpeed;
|
||||
|
|
@ -152,6 +161,16 @@ 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 trinket = "Skadi - Hover Trinket";
|
||||
TrinketAscendSpeed = config.Bind(trinket, "Ascend Speed", 4f,
|
||||
new ConfigDescription("Climb speed (m/s) while airborne and holding Space with the Rime Feather equipped.", new AcceptableValueRange<float>(0.5f, 15f)));
|
||||
TrinketStaminaPerSecond = config.Bind(trinket, "Stamina Per Second", 8f,
|
||||
new ConfigDescription("Stamina drained per second while climbing. Running out hands the frame back to normal gravity.", new AcceptableValueRange<float>(0f, 60f)));
|
||||
TrinketGlideFallSpeed = config.Bind(trinket, "Glide Fall Speed", 5.4f,
|
||||
new ConfigDescription("Maximum fall speed (m/s) while airborne without holding Space - a free parachute-style glide, Drake-flight-inspired, rather than a normal hard drop. Only caps actual falling, so it never robs a jump of its rise.", new AcceptableValueRange<float>(1f, 20f)));
|
||||
TrinketFallDamageReduction = config.Bind(trinket, "Fall Damage Reduction", 1f,
|
||||
new ConfigDescription("Fall damage reduction while the Rime Feather is equipped (1 = fully immune), applied via the item's own equip status effect regardless of the Space climb.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
|
||||
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)));
|
||||
|
|
|
|||
156
JotunnModStub/Skadi/SkadiHoverTrinket.cs
Normal file
156
JotunnModStub/Skadi/SkadiHoverTrinket.cs
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
using UnityEngine;
|
||||
using Jotunn.Configs;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// "Rime Feather" - a Utility-slot trinket. Deliberately independent of DrakeFormBehavior /
|
||||
/// Character.m_flying / the UpdateFlying patches in SkadiPatches.cs: that machinery is the
|
||||
/// Elder-onward Drake/Moder form transformation and is not touched here. This is a much
|
||||
/// weaker, always-available tool for the base humanoid form - hold Space while airborne to
|
||||
/// climb, and never take fall damage while it's worn.
|
||||
///
|
||||
/// Feather fall is wired up the vanilla way: m_fallDamageModifier on the item's own
|
||||
/// m_equipStatusEffect, the same field Fenrir's form buffs use (see FenrirRace.cs). Vanilla's
|
||||
/// own equip machinery applies and removes it automatically, so it needs no patch and no
|
||||
/// per-frame code of its own.
|
||||
///
|
||||
/// The climb itself has no vanilla status-effect equivalent, so it runs from
|
||||
/// SkadiRace.Update() every frame - see SkadiRace.Tick() call site - already gated there on
|
||||
/// IsSkadi() and RaceInput.Allowed.
|
||||
///
|
||||
/// Known gap, not yet closed: the feather-fall status effect is a plain equip effect with no
|
||||
/// race check, so a non-Skadi player who crafts and wears this also gets fall immunity for
|
||||
/// free. Aswid's equivalent (Blood Essence) hard-gates its player-facing benefit to the
|
||||
/// matching race; this doesn't yet. Left as-is for this first pass - flag before shipping if
|
||||
/// exclusivity matters here as much as it did there.
|
||||
///
|
||||
/// Also not yet wired: the Factions merchant-gate item every other new feature in this
|
||||
/// initiative routes through (see MOUNTAIN-FACTION-BRAINSTORM.md). For now this crafts at a
|
||||
/// normal Forge from plain materials so the ability itself can be tested in-game first.
|
||||
/// </summary>
|
||||
public static class SkadiHoverTrinket
|
||||
{
|
||||
public const string CloneName = "SkadiHoverTrinket";
|
||||
// Megingjord's internal id - a plain Utility-slot stat item, easiest to strip down.
|
||||
private const string SourcePrefab = "BeltStrength";
|
||||
public const string StatusEffectName = "SE_SkadiHoverTrinket";
|
||||
|
||||
private static bool registered = false;
|
||||
private static SE_Stats fallDamageSE;
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
if (registered) return;
|
||||
|
||||
fallDamageSE = ScriptableObject.CreateInstance<SE_Stats>();
|
||||
fallDamageSE.name = StatusEffectName;
|
||||
fallDamageSE.m_name = "Rime Feather";
|
||||
fallDamageSE.m_tooltip = "Falls don't hurt while this is worn.";
|
||||
fallDamageSE.m_fallDamageModifier = -SkadiConfig.TrinketFallDamageReduction.Value;
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(fallDamageSE, fixReference: false));
|
||||
|
||||
ItemConfig config = new ItemConfig();
|
||||
config.Name = "Rime Feather";
|
||||
config.Description = "A drake's primary feather, still cold to the touch. Hold Space to climb; you will never fear a fall while it's on you.";
|
||||
config.CraftingStation = "piece_workbench";
|
||||
config.Requirements = new[]
|
||||
{
|
||||
new RequirementConfig("FreezeGland", 5),
|
||||
new RequirementConfig("Silver", 5)
|
||||
};
|
||||
|
||||
CustomItem customItem = new CustomItem(CloneName, SourcePrefab, config);
|
||||
if (customItem == null || customItem.ItemDrop == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Skadi] Could not create the Rime Feather trinket.");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemDrop.ItemData.SharedData shared = customItem.ItemDrop.m_itemData.m_shared;
|
||||
|
||||
// Strip everything BeltStrength brought with it - the point is a fresh Utility item,
|
||||
// not a free Megingjord tacked on top. Overwriting m_equipStatusEffect below already
|
||||
// drops Megingjord's own carry-weight bonus, since that lived entirely on the SE we're
|
||||
// replacing.
|
||||
shared.m_maxStackSize = 1;
|
||||
shared.m_equipStatusEffect = fallDamageSE;
|
||||
shared.m_setStatusEffect = null;
|
||||
shared.m_setSize = 0;
|
||||
|
||||
// Borrow the same drake trophy icon SkadiRace already uses for the curse SE, rather
|
||||
// than needing a new art asset.
|
||||
GameObject drakeTrophy = PrefabManager.Cache.GetPrefab<ItemDrop>("TrophyHatchling")?.gameObject;
|
||||
if (drakeTrophy != null)
|
||||
{
|
||||
ItemDrop trophyDrop = drakeTrophy.GetComponent<ItemDrop>();
|
||||
if (trophyDrop != null && trophyDrop.m_itemData.m_shared.m_icons.Length > 0)
|
||||
{
|
||||
shared.m_icons = trophyDrop.m_itemData.m_shared.m_icons;
|
||||
}
|
||||
}
|
||||
|
||||
ItemManager.Instance.AddItem(customItem);
|
||||
registered = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called every frame from SkadiRace.Update(), already gated there on IsSkadi() and
|
||||
/// RaceInput.Allowed. Only acts while airborne and not swimming, and steps aside entirely
|
||||
/// while the Drake/Moder flight patch is active, so the two systems never fight for the
|
||||
/// same frame.
|
||||
///
|
||||
/// Two states, both free of any timer: holding Space climbs (costs stamina); letting go
|
||||
/// caps the fall speed instead of letting normal gravity take over, for a permanent,
|
||||
/// Drake-glide-inspired float rather than a hard drop. The cap only ever slows an actual
|
||||
/// fall (vel.y already below it) - it never touches a rising jump, so tapping Space for a
|
||||
/// normal jump still arcs normally with the trinket equipped.
|
||||
/// </summary>
|
||||
public static void Tick(Player player)
|
||||
{
|
||||
if (player == null || player.IsDead()) return;
|
||||
if (player.IsOnGround() || player.IsSwimming()) return;
|
||||
if (DrakeFormBehavior.Active != null && DrakeFormBehavior.Active.IsFlying) return;
|
||||
if (!IsEquipped(player)) return;
|
||||
|
||||
// Character drives its own movement through a Rigidbody on the same GameObject (see
|
||||
// TrolRace.cs's log-throw for the same GetComponent<Rigidbody>() approach) - there is
|
||||
// no public Character.SetVelocity to hand this to instead.
|
||||
Rigidbody body = player.GetComponent<Rigidbody>();
|
||||
if (body == null) return;
|
||||
|
||||
if (Input.GetKey(KeyCode.Space))
|
||||
{
|
||||
float cost = SkadiConfig.TrinketStaminaPerSecond.Value * Time.deltaTime;
|
||||
if (!player.HaveStamina(cost)) return;
|
||||
player.UseStamina(cost);
|
||||
|
||||
// A fixed climb speed, not an accumulated force - holding Space climbs at a
|
||||
// steady rate rather than accelerating without limit.
|
||||
Vector3 vel = body.velocity;
|
||||
vel.y = SkadiConfig.TrinketAscendSpeed.Value;
|
||||
body.velocity = vel;
|
||||
}
|
||||
else
|
||||
{
|
||||
float glideSpeed = SkadiConfig.TrinketGlideFallSpeed.Value;
|
||||
if (body.velocity.y < -glideSpeed)
|
||||
{
|
||||
Vector3 vel = body.velocity;
|
||||
vel.y = -glideSpeed;
|
||||
body.velocity = vel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsEquipped(Player player)
|
||||
{
|
||||
Inventory inv = player.GetInventory();
|
||||
if (inv == null) return false;
|
||||
ItemDrop.ItemData item = inv.GetItem(CloneName, 1, true);
|
||||
return item != null && player.IsItemEquiped(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -205,6 +205,11 @@ namespace RacesOfValheim
|
|||
HandleColdSpell(rules);
|
||||
}
|
||||
|
||||
if (RaceInput.Allowed)
|
||||
{
|
||||
SkadiHoverTrinket.Tick(Player.m_localPlayer);
|
||||
}
|
||||
|
||||
if (isTransformingSequence) return;
|
||||
|
||||
// Forms with a DurationMinutes budget drop on their own once it runs out, which is
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue