Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
2e31f98380 feat(dvergar): add Fire Construct base-defense piece (Mountain faction feature)
Stationary Hammer piece cloned from DvergerMageFire: scans a configurable
radius for hostile, non-Mountain-faction, non-player Characters and fires its
own fireball (real attack data pulled off Humanoid.m_defaultItems, grounded in
an in-game dumpelder dump, not guessed).

Fire-only for this first pass; Ice/Support are a later append to the same
pattern. Several in-game fixes along the way: a missing piece icon (Jotunn
silently drops any piece without one), a missing known-piece teach on spawn
(same fix RaceMenuWard already needed), a kinematic Rigidbody fighting
Character's own velocity writes, and MonsterAI needing to be disabled rather
than destroyed - several vanilla systems (EnemyHud, most likely damage
registration too) assume any combat-relevant Character has one.

FactionHostilityPatch gains a public IsMountainFactionMob accessor so the
construct's target filter shares the same Mountain roster as the rest of
Factions instead of a second hand-maintained list.
2026-08-07 08:23:04 +02:00
c320fa5b2b 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.
2026-08-06 18:35:09 +02:00
b34deef2de chore: ignore local Factions/session reference notes
Personal knowledge-dump notes, kept out of version control.
2026-08-06 16:06:36 +02:00
9 changed files with 478 additions and 1 deletions

5
.gitignore vendored
View file

@ -28,3 +28,8 @@ Thumbs.db
# How to setup Configuration Manager # How to setup Configuration Manager
CONFIGURATION-MANAGER-HOWTO.md CONFIGURATION-MANAGER-HOWTO.md
# Personal reference notes - not part of the mod itself
FACTIONS-KNOWLEDGE.md
SESSION-NOTES.md
MOUNTAIN-FACTION-BRAINSTORM.md

View file

@ -57,6 +57,13 @@ namespace RacesOfValheim
public static ConfigEntry<float> RunicOverchargeWindow; public static ConfigEntry<float> RunicOverchargeWindow;
public static ConfigEntry<float> RunicOverchargeCooldown; public static ConfigEntry<float> RunicOverchargeCooldown;
// ─── Fire Construct (placeable turret) ─────────────────────────────────
// See DvergarFireConstruct.cs. Fire-only for this first pass; Ice/Support are a later
// append to the same piece/recipe pattern, not a redesign.
public static ConfigEntry<float> ConstructScanRadius;
public static ConfigEntry<float> ConstructScanInterval;
public static ConfigEntry<float> ConstructFireCooldown;
public static void Bind(ConfigFile config) public static void Bind(ConfigFile config)
{ {
const string keybinds = "Dvergar - Keybinds"; const string keybinds = "Dvergar - Keybinds";
@ -106,6 +113,14 @@ namespace RacesOfValheim
new ConfigDescription("Seconds a loaded charge is held before it lapses unused.", new AcceptableValueRange<float>(1f, 60f))); new ConfigDescription("Seconds a loaded charge is held before it lapses unused.", new AcceptableValueRange<float>(1f, 60f)));
RunicOverchargeCooldown = config.Bind(overcharge, "Cooldown", 60f, RunicOverchargeCooldown = config.Bind(overcharge, "Cooldown", 60f,
new ConfigDescription("Seconds between casts.", new AcceptableValueRange<float>(0f, 300f))); new ConfigDescription("Seconds between casts.", new AcceptableValueRange<float>(0f, 300f)));
const string construct = "Dvergar - Fire Construct";
ConstructScanRadius = config.Bind(construct, "Scan Radius", 10f,
new ConfigDescription("Meters within which the construct looks for a target. Kept close to the fireball's own 7m attack range so it doesn't open fire on something it can't actually hit yet.", new AcceptableValueRange<float>(3f, 30f)));
ConstructScanInterval = config.Bind(construct, "Scan Interval", 0.5f,
new ConfigDescription("Seconds between target scans.", new AcceptableValueRange<float>(0.1f, 5f)));
ConstructFireCooldown = config.Bind(construct, "Fire Cooldown", 3f,
new ConfigDescription("Seconds between shots once a target is found.", new AcceptableValueRange<float>(0.5f, 15f)));
} }
} }
} }

View file

@ -0,0 +1,266 @@
using System.Collections;
using UnityEngine;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
namespace RacesOfValheim
{
/// <summary>
/// A stationary base-defense piece: a bound DvergerMageFire, stripped of its AI and loot, that
/// scans for hostile Characters in range and fires its own fireball at them.
///
/// Grounded in an in-game dump (`dumpelder DvergerMageFire`, see MOUNTAIN-FACTION-BRAINSTORM.md)
/// rather than guessed: the source prefab is Humanoid-based with no embedded offensive
/// component (unlike Aswid's eitrrefinery/Radiator case), so all we need is its real attack
/// data off Humanoid.m_defaultItems - DvergerStaffFire_fireball (fire damage, projectile
/// velocity) and its projectile prefab, DvergerStaffFire_fireball_projectile - and to trigger
/// the same animation trigger it already uses, "attack_cast".
///
/// Fire-only for this first pass; DvergerMageIce/DvergerMageSupport are a later append to this
/// same clone/strip/behavior shape, not a redesign.
/// </summary>
public static class DvergarFireConstruct
{
public const string PrefabName = "DvergarFireConstruct";
private const string SourcePrefab = "DvergerMageFire";
public const string WeaponPrefabName = "DvergerStaffFire_fireball";
public const string ProjectilePrefabName = "DvergerStaffFire_fireball_projectile";
public static void Register()
{
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PrefabName, SourcePrefab);
if (prefab == null)
{
Jotunn.Logger.LogWarning("[Dvergar] Could not clone DvergerMageFire; Fire Construct not registered.");
return;
}
// MonsterAI is DISABLED, not destroyed - confirmed via IL that several vanilla systems
// assume any combat-relevant Character has one and reach for it unconditionally:
// EnemyHud.UpdateHuds calls Character.GetBaseAI() and immediately .HaveTarget() with no
// null check (MonsterAI extends BaseAI), which NRE'd every frame once it was gone -
// that same method also reads BaseAI.IsEnemy(Character,Character), the same check combat
// hit-registration very plausibly gates on too, which lines up with attacks not landing
// on a first in-game test. Disabling still stops it from ever wandering, targeting, or
// auto-attacking on its own (Update/FixedUpdate never run on a disabled component) -
// the same practical effect as destroying it - while GetComponent<MonsterAI>() keeps
// finding a real (just inactive) one for everything else that expects to.
MonsterAI monsterAI = prefab.GetComponent<MonsterAI>();
if (monsterAI != null) monsterAI.enabled = false;
DestroyComponent<CharacterDrop>(prefab);
DestroyComponent<NpcTalk>(prefab);
// Constraints only, NOT kinematic - Character's own base FixedUpdate keeps calling
// rigidbody.velocity = ... every frame on its own (gravity/grounding logic that has no
// idea MonsterAI is gone), and Unity refuses that specific assignment on a kinematic
// body, which spammed "Setting linear velocity of a kinematic body is not supported"
// forever once this was in-game. Freezing position/rotation via constraints instead
// keeps it stationary while leaving the body non-kinematic, so those internal velocity
// writes stay legal - they just can't move anything, since translation is locked.
Rigidbody body = prefab.GetComponent<Rigidbody>();
if (body != null)
{
body.constraints = RigidbodyConstraints.FreezeAll;
}
// Humanoid is deliberately kept, not stripped: it's what equips DvergerStaffFire and
// DvergerSuitFire into VisEquipment in the first place, so removing it risked a bare
// model. Its own health/death system also gives this piece its durability, in place
// of the WearNTear every other piece in this mod uses - see the doc comment on
// DvergarFireConstructBehavior for that tradeoff.
prefab.AddComponent<DvergarFireConstructBehavior>();
Piece piece = prefab.GetComponent<Piece>();
if (piece == null) piece = prefab.AddComponent<Piece>();
// DvergerMageFire is a monster, not a piece, so unlike RaceMenuWard's clone (guard_stone,
// already a valid vanilla piece with its own icon) this Piece starts completely bare.
// Jotunn's CustomPiece rejects (logs "is not valid" and never registers it) any piece
// with no icon. DvergerStaffFire_fireball's own icon turned out empty - it's a
// monster-only weapon, never shown in a player inventory slot, so nobody ever gave it
// one. TrophyDvergr is real player-facing loot (sold in DvergShop) and always has one.
GameObject trophyPrefab = PrefabManager.Cache.GetPrefab<GameObject>("TrophyDvergr");
ItemDrop trophyDrop = trophyPrefab != null ? trophyPrefab.GetComponent<ItemDrop>() : null;
if (trophyDrop != null && trophyDrop.m_itemData.m_shared.m_icons.Length > 0)
{
piece.m_icon = trophyDrop.m_itemData.m_shared.m_icons[0];
}
else
{
Jotunn.Logger.LogWarning("[Dvergar] Could not find an icon for the Fire Construct piece - it will fail Jotunn's validity check.");
}
PieceConfig config = new PieceConfig
{
Name = "Fire Construct",
Description = "A bound Dverger fire-mage, still loyal to whoever built it. Attacks anything hostile in range.",
PieceTable = PieceTables.Hammer,
Category = PieceCategories.Crafting,
// No CraftingStation - the RaceMenuWard lesson: a station-gated piece vanishes
// from the hammer wheel the moment you step out of range. Plain materials for now,
// same reasoning as the Skadi trinket: prove the mechanic in-game before wiring in
// the Factions merchant-gate item (see MOUNTAIN-FACTION-BRAINSTORM.md).
Requirements = new[]
{
new RequirementConfig("Stone", 10, 0, true),
new RequirementConfig("Bronze", 5, 0, true)
}
};
PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, config));
}
/// <summary>
/// A build piece only appears in the hammer once its name is in the player's known
/// recipes (PieceTable.UpdateAvailable filters on exactly that) - the same Jotunn quirk
/// RaceMenuWard.EnsureKnown already works around for its own piece. Without this, the
/// construct is fully registered and buildable in principle but never actually shows up
/// in the hammer wheel for anyone.
/// </summary>
public static void EnsureKnown(Player player)
{
if (player == null) return;
GameObject prefab = PrefabManager.Instance.GetPrefab(PrefabName);
if (prefab == null)
{
Jotunn.Logger.LogWarning($"{PrefabName} prefab missing; cannot teach the piece.");
return;
}
Piece piece = prefab.GetComponent<Piece>();
if (piece == null)
{
Jotunn.Logger.LogWarning($"{PrefabName} has no Piece component.");
return;
}
var traverse = HarmonyLib.Traverse.Create(player);
traverse.Method("AddKnownPiece", piece).GetValue();
traverse.Method("UpdateAvailablePiecesList").GetValue();
}
private static void DestroyComponent<T>(GameObject go) where T : Component
{
T component = go.GetComponent<T>();
if (component != null) Object.DestroyImmediate(component);
}
}
/// <summary>
/// Durability tradeoff, not yet verified in-game: this piece has no WearNTear. The source
/// prefab is a full Humanoid/Character, and stacking WearNTear's structural HP on top of
/// Character's own health/death system would mean two damage pipelines fighting over the same
/// piece, so Character's own health is used instead. That means it dies (and presumably
/// ragdolls) the way any monster does, rather than being "demolished" through the normal
/// hammer repair/remove flow, which relies on WearNTear. Whether that reads as a problem in
/// practice is one of the first things to check once this is in-game.
/// </summary>
public class DvergarFireConstructBehavior : MonoBehaviour
{
private Animator anim;
private Character self;
private Transform eyePos;
private GameObject projectilePrefab;
private HitData.DamageTypes damage;
private float projectileVel;
private bool dataResolved;
private float nextScanTime;
private float nextFireTime;
private void Awake()
{
anim = GetComponentInChildren<Animator>();
self = GetComponent<Character>();
eyePos = transform.Find("EyePos");
}
private void Update()
{
if (Time.time < nextScanTime) return;
nextScanTime = Time.time + DvergarConfigManagement.ConstructScanInterval.Value;
if (!dataResolved) ResolveWeaponData();
if (projectilePrefab == null) return;
Character target = FindTarget();
if (target != null && Time.time >= nextFireTime)
{
nextFireTime = Time.time + DvergarConfigManagement.ConstructFireCooldown.Value;
StartCoroutine(FireCoroutine(target));
}
}
// Read once, lazily rather than in Awake - PrefabManager.Cache may not be fully populated
// the instant a placed piece wakes up.
private void ResolveWeaponData()
{
GameObject weaponPrefab = PrefabManager.Cache.GetPrefab<GameObject>(DvergarFireConstruct.WeaponPrefabName);
ItemDrop weaponDrop = weaponPrefab != null ? weaponPrefab.GetComponent<ItemDrop>() : null;
if (weaponDrop == null) return;
damage = weaponDrop.m_itemData.m_shared.m_damages;
projectileVel = weaponDrop.m_itemData.m_shared.m_attack.m_projectileVel;
projectilePrefab = PrefabManager.Cache.GetPrefab<GameObject>(DvergarFireConstruct.ProjectilePrefabName);
dataResolved = true;
}
private Character FindTarget()
{
float radius = DvergarConfigManagement.ConstructScanRadius.Value;
int mask = LayerMask.GetMask("character", "character_net", "hitbox");
Collider[] hits = Physics.OverlapSphere(transform.position, radius, mask);
Character best = null;
float bestDist = float.MaxValue;
foreach (Collider hit in hits)
{
Character c = hit.GetComponentInParent<Character>();
if (c == null || c == self || c.IsDead() || c.IsPlayer()) continue;
// Never target Mountain-faction fauna (Wolf, Ulv, Dverger, ...) - same roster
// FactionHostilityPatch already uses to keep those creatures at peace with the
// three Mountain races, so this construct doesn't shoot its own neighbours.
string prefabName = c.gameObject.name.Replace("(Clone)", "").Trim();
if (FactionHostilityPatch.IsMountainFactionMob(prefabName)) continue;
float dist = Vector3.Distance(transform.position, c.transform.position);
if (dist < bestDist)
{
bestDist = dist;
best = c;
}
}
return best;
}
private IEnumerator FireCoroutine(Character target)
{
if (anim != null) anim.SetTrigger("attack_cast");
yield return new WaitForSeconds(0.5f);
if (target == null || target.IsDead() || projectilePrefab == null) yield break;
Vector3 spawnPos = eyePos != null ? eyePos.position : transform.position + Vector3.up * 1.5f;
Vector3 targetPos = target.transform.position + Vector3.up * 1f;
Vector3 dir = (targetPos - spawnPos).normalized;
GameObject projInstance = Object.Instantiate(projectilePrefab, spawnPos, Quaternion.LookRotation(dir));
Projectile proj = projInstance.GetComponent<Projectile>();
if (proj != null)
{
HitData hitData = new HitData();
hitData.m_damage = damage;
hitData.SetAttacker(self);
proj.Setup(self, dir * projectileVel, -1f, hitData, null, null);
}
}
}
}

View file

@ -70,6 +70,14 @@ namespace RacesOfValheim
return mobs.Contains(prefabName); return mobs.Contains(prefabName);
} }
// Shared with DvergarFireConstruct's target scan, so its friendly-fire filter reads off
// the same Mountain roster as everything else in Factions rather than a second
// hand-maintained copy of it.
public static bool IsMountainFactionMob(string prefabName)
{
return MontagnaMobs.Contains(prefabName);
}
public static void Postfix(Character a, Character b, ref bool __result) public static void Postfix(Character a, Character b, ref bool __result)
{ {
if (!__result) return; // already not enemies, nothing to add if (!__result) return; // already not enemies, nothing to add

View file

@ -158,6 +158,7 @@ namespace RacesOfValheim
if (__instance != Player.m_localPlayer) return; if (__instance != Player.m_localPlayer) return;
RaceMenuWard.TryPlaceAtSpawn(); RaceMenuWard.TryPlaceAtSpawn();
RaceMenuWard.EnsureKnown(__instance); RaceMenuWard.EnsureKnown(__instance);
DvergarFireConstruct.EnsureKnown(__instance);
} }
} }

View file

@ -107,12 +107,14 @@ namespace RacesOfValheim
RaceMenuWard.Register(); RaceMenuWard.Register();
FenrirRace.Instance.CreateModAssets(); FenrirRace.Instance.CreateModAssets();
SkadiRace.Instance.CreateModAssets(); SkadiRace.Instance.CreateModAssets();
SkadiHoverTrinket.Register();
SkeletonRace.Instance.CreateModAssets(); SkeletonRace.Instance.CreateModAssets();
AswidRace.Instance.CreateModAssets(); AswidRace.Instance.CreateModAssets();
FurlingRace.Instance.CreateModAssets(); FurlingRace.Instance.CreateModAssets();
TrolRace.Instance.CreateModAssets(); TrolRace.Instance.CreateModAssets();
DraughRace.Instance.CreateModAssets(); DraughRace.Instance.CreateModAssets();
DvergarRace.Instance.CreateModAssets(); DvergarRace.Instance.CreateModAssets();
DvergarFireConstruct.Register();
TrentaRace.Instance.CreateModAssets(); TrentaRace.Instance.CreateModAssets();
} }
// --- RACE SELECTION UI --- // --- RACE SELECTION UI ---

View file

@ -63,6 +63,15 @@ namespace RacesOfValheim
public static ConfigEntry<float> FaderSpinDamage; public static ConfigEntry<float> FaderSpinDamage;
public static ConfigEntry<float> FaderSpinRadius; 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) ──────────────────────────────────── // ─── Directed flight (Drake/Moder) ────────────────────────────────────
public static ConfigEntry<float> FlightTurnSpeed; public static ConfigEntry<float> FlightTurnSpeed;
public static ConfigEntry<float> FlightGlideSpeed; public static ConfigEntry<float> FlightGlideSpeed;
@ -152,6 +161,16 @@ namespace RacesOfValheim
FaderSpinRadius = config.Bind(attacks, "Fader Spin Radius", 5f, 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))); 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"; const string flight = "Skadi - Directed Flight";
FlightTurnSpeed = config.Bind(flight, "Turn Speed", 120f, 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))); new ConfigDescription("Degrees per second the dragon form turns to face its heading.", new AcceptableValueRange<float>(10f, 360f)));

View 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);
}
}
}

View file

@ -205,6 +205,11 @@ namespace RacesOfValheim
HandleColdSpell(rules); HandleColdSpell(rules);
} }
if (RaceInput.Allowed)
{
SkadiHoverTrinket.Tick(Player.m_localPlayer);
}
if (isTransformingSequence) return; if (isTransformingSequence) return;
// Forms with a DurationMinutes budget drop on their own once it runs out, which is // Forms with a DurationMinutes budget drop on their own once it runs out, which is