feat(alfar): v1.6.0 - the Alfar, an eleventh race
Grey, tall and thin, with black eyes. Eitr is armour and fuel (shield, diet, soft fall, levitation), Heimkall sends a lethal blow home at one health every 20 minutes. Caster powers from Skrid to the archon Sameining, with on-screen cooldowns. Automated base around the Ljoskjarne: drones, three constructs, crystals, Ljosgard, Prismavard. Compendium page in EN/IT/RU. README: New in block, race section, progression, station line, changelog. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9e9790d1e9
commit
3f8cf1ee27
48 changed files with 7779 additions and 16 deletions
169
JotunnModStub/Alfar/AlfarStatusEffects.cs
Normal file
169
JotunnModStub/Alfar/AlfarStatusEffects.cs
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The Alfar's passive carrier. For now it holds only the FEATHER FALL: with eitr in the pool the
|
||||
/// body is lowered instead of dropped.
|
||||
///
|
||||
/// Valheim already has the mechanism (the Feather Cape): SE_Stats.m_maxMaxFallSpeed makes
|
||||
/// StatusEffect.ModifyWalkVelocity clamp the downward speed (verified in the IL, doc sec. 16B).
|
||||
/// So the effect is an SE_Stats with that field switched on while there is eitr and off when
|
||||
/// there is none - and a fall at eitr zero is a normal, fast, damaging fall.
|
||||
///
|
||||
/// The fall DAMAGE is a separate matter, handled by the shield prefix (AlfarEitr): a fall is free
|
||||
/// while there is eitr. This effect is what makes it look like falling softly.
|
||||
///
|
||||
/// Rebuilt every tick for the same reason the Sverm's is: Setup runs once, at spawn, so anything
|
||||
/// written there is frozen.
|
||||
/// </summary>
|
||||
public class SE_AlfarStats : SE_Stats
|
||||
{
|
||||
public const string EffectName = "SE_AlfarStats";
|
||||
|
||||
public override void Setup(Character character)
|
||||
{
|
||||
base.Setup(character);
|
||||
name = EffectName;
|
||||
m_name = "$rov_se_alfar_stats_name";
|
||||
m_tooltip = "$rov_se_alfar_stats_tooltip";
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
public override void UpdateStatusEffect(float dt)
|
||||
{
|
||||
base.UpdateStatusEffect(dt);
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
private void Rebuild()
|
||||
{
|
||||
Player player = m_character as Player;
|
||||
bool charged = player != null && player.GetEitr() > 0f;
|
||||
|
||||
// Written on the LIVE effect, not on the registered template: SEMan clones what it is
|
||||
// given, so a template edited afterwards reaches nobody.
|
||||
m_maxMaxFallSpeed = charged && AlfarConfig.SoftFall.Value ? AlfarConfig.FeatherFallSpeed.Value : 0f;
|
||||
|
||||
// The archon form is faster. SE_Stats.m_speedModifier is added to the body's speed factor.
|
||||
m_speedModifier = AlfarArchon.Active ? AlfarPowerConfig.ArchonSpeedBonus.Value : 0f;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A marker with a countdown: the HUD prints the remaining time of any effect that has a m_ttl, so
|
||||
/// the cooldowns of the powers, the Heimkall wait and the archon form all show on screen without a
|
||||
/// line of UI code (the Dvergar's cooldown icons do the same).
|
||||
/// </summary>
|
||||
public class SE_AlfarTimer : StatusEffect
|
||||
{
|
||||
}
|
||||
|
||||
public static class AlfarStatusEffects
|
||||
{
|
||||
public static readonly string[] TimerIds = { "skrid", "graf", "kall", "storm", "beam", "kyrr", "heimkall", "archon" };
|
||||
|
||||
public static string TimerName(string id) { return "SE_AlfarTimer_" + id; }
|
||||
|
||||
private static string TimerIcon(string id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case "graf": return "TrophyDeathsquito";
|
||||
case "kall": return "Thunderstone";
|
||||
case "storm": return "OrbThunderBlood";
|
||||
case "beam": return "Crystal";
|
||||
case "kyrr": return "FreezeGland";
|
||||
case "archon": return "TrophyFader";
|
||||
default: return "Eitr";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Starts (or restarts) the on-screen countdown of a power, the Heimkall wait or the form.</summary>
|
||||
public static void ShowTimer(string id, float seconds)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null || seconds <= 0f) return;
|
||||
|
||||
int hash = TimerName(id).GetStableHashCode();
|
||||
SEMan seman = player.GetSEMan();
|
||||
seman.RemoveStatusEffect(hash, true);
|
||||
seman.AddStatusEffect(hash, true);
|
||||
|
||||
StatusEffect effect = seman.GetStatusEffect(hash);
|
||||
if (effect != null) effect.m_ttl = seconds;
|
||||
}
|
||||
|
||||
public static void ClearTimer(string id)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player != null) player.GetSEMan().RemoveStatusEffect(TimerName(id).GetStableHashCode(), true);
|
||||
}
|
||||
|
||||
public static bool HasTimer(string id)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
return player != null && player.GetSEMan().HaveStatusEffect(TimerName(id).GetStableHashCode());
|
||||
}
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
foreach (string id in TimerIds)
|
||||
{
|
||||
Sprite timerIcon = null;
|
||||
GameObject source = PrefabManager.Cache.GetPrefab<GameObject>(TimerIcon(id));
|
||||
ItemDrop sourceDrop = source != null ? source.GetComponent<ItemDrop>() : null;
|
||||
if (sourceDrop != null && sourceDrop.m_itemData != null && sourceDrop.m_itemData.m_shared != null &&
|
||||
sourceDrop.m_itemData.m_shared.m_icons != null && sourceDrop.m_itemData.m_shared.m_icons.Length > 0)
|
||||
{
|
||||
timerIcon = sourceDrop.m_itemData.m_shared.m_icons[0];
|
||||
}
|
||||
|
||||
var timer = ScriptableObject.CreateInstance<SE_AlfarTimer>();
|
||||
timer.name = TimerName(id);
|
||||
timer.m_name = "$rov_se_alfar_timer_" + id + "_name";
|
||||
timer.m_icon = timerIcon;
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(timer, fixReference: false));
|
||||
}
|
||||
|
||||
Sprite icon = null;
|
||||
GameObject prefab = PrefabManager.Cache.GetPrefab<GameObject>("Eitr");
|
||||
ItemDrop drop = prefab != null ? prefab.GetComponent<ItemDrop>() : null;
|
||||
if (drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null &&
|
||||
drop.m_itemData.m_shared.m_icons != null && drop.m_itemData.m_shared.m_icons.Length > 0)
|
||||
{
|
||||
icon = drop.m_itemData.m_shared.m_icons[0];
|
||||
}
|
||||
|
||||
var stats = ScriptableObject.CreateInstance<SE_AlfarStats>();
|
||||
stats.name = SE_AlfarStats.EffectName;
|
||||
stats.m_name = "$rov_se_alfar_stats_name";
|
||||
stats.m_icon = icon;
|
||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(stats, fixReference: false));
|
||||
}
|
||||
|
||||
/// <summary>Adds the passive to a player that lacks it: status effects do not survive death or a reload.</summary>
|
||||
public static void Ensure(Player player)
|
||||
{
|
||||
if (player == null) return;
|
||||
int hash = SE_AlfarStats.EffectName.GetStableHashCode();
|
||||
if (!player.GetSEMan().HaveStatusEffect(hash))
|
||||
{
|
||||
player.GetSEMan().AddStatusEffect(hash, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Takes the passive off a player who stopped being an Alfr.</summary>
|
||||
public static void Remove(Player player)
|
||||
{
|
||||
if (player == null) return;
|
||||
int hash = SE_AlfarStats.EffectName.GetStableHashCode();
|
||||
if (player.GetSEMan().HaveStatusEffect(hash))
|
||||
{
|
||||
player.GetSEMan().RemoveStatusEffect(hash, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue