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
176
JotunnModStub/Alfar/AlfarArchon.cs
Normal file
176
JotunnModStub/Alfar/AlfarArchon.cs
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// SAMEINING, the archon (Alfar_Progettazione.txt sec. 13.8): Fader's power, an all-or-nothing form.
|
||||
///
|
||||
/// - needs 75% of the maximum eitr and a READY Heimkall, and spends ALL the eitr;
|
||||
/// - lasts up to three minutes: bigger (x1.5), glowing, +20% speed;
|
||||
/// - instead of armour there is a POOL of points, three per eitr spent: every blow lands on it,
|
||||
/// and when it is gone the form ends early;
|
||||
/// - no weapons: a psionic pulse strikes everything hostile around the body, once a second;
|
||||
/// - Ljosstorm and Geisli cost nothing in the form, but wait a few seconds between uses;
|
||||
/// - it ENDS (time up, pool gone) with a teleport home at one hit point, eitr at zero, and the
|
||||
/// Heimkall wait starting. The form IS a Heimkall spent on purpose.
|
||||
///
|
||||
/// The form is published in the ZDO so other players see the size and the glow.
|
||||
/// </summary>
|
||||
public static class AlfarArchon
|
||||
{
|
||||
public const string ZdoKey = "Alfar_Archon";
|
||||
|
||||
public static bool Active { get; private set; }
|
||||
public static float Pool { get; private set; }
|
||||
public static float EndsAt { get; private set; }
|
||||
public static float StartedAt { get; private set; }
|
||||
|
||||
private static float nextPulse;
|
||||
|
||||
/// <summary>True for any player in range: the form is read off the ZDO, not local state.</summary>
|
||||
public static bool IsArchon(Player player)
|
||||
{
|
||||
if (player == null) return false;
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
return nview != null && nview.IsValid() && nview.GetZDO().GetInt(ZdoKey, 0) == 1;
|
||||
}
|
||||
|
||||
public static bool IsLocalActive => Active && Player.m_localPlayer != null;
|
||||
|
||||
private static void Publish(Player player, bool on)
|
||||
{
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set(ZdoKey, on ? 1 : 0);
|
||||
}
|
||||
|
||||
// ─── Entering ────────────────────────────────────────────────────────
|
||||
|
||||
public static bool TryActivate(Player player)
|
||||
{
|
||||
if (Active || player == null) return false;
|
||||
|
||||
float max = player.GetMaxEitr();
|
||||
float eitr = player.GetEitr();
|
||||
if (max <= 0f || eitr < max * AlfarPowerConfig.ArchonThreshold.Value)
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_archon_not_charged"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!AlfarHeimkall.IsReady(player))
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_archon_not_ready"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Everything goes in: the strength of the form is what the Alfr had eaten.
|
||||
Pool = eitr * AlfarPowerConfig.ArchonPoolPerEitr.Value;
|
||||
AlfarEitr.Spend(player, eitr);
|
||||
|
||||
Active = true;
|
||||
StartedAt = Time.time;
|
||||
EndsAt = Time.time + AlfarPowerConfig.ArchonSeconds.Value;
|
||||
AlfarStatusEffects.ShowTimer("archon", AlfarPowerConfig.ArchonSeconds.Value);
|
||||
nextPulse = Time.time + AlfarPowerConfig.ArchonPulseInterval.Value;
|
||||
Publish(player, true);
|
||||
|
||||
Jotunn.Logger.LogInfo($"[Alfar] Sameining on: pool {Pool:0} for {AlfarPowerConfig.ArchonSeconds.Value:0}s.");
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_archon_on"));
|
||||
return true;
|
||||
}
|
||||
|
||||
// ─── In the form ─────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Takes a blow into the pool. Called from the shield prefix before anything else, because in
|
||||
/// the form the pool IS the defence: every type of damage, drowning and the edge of the world
|
||||
/// included, since nothing else can end the form but the pool and the clock.
|
||||
/// </summary>
|
||||
public static void Absorb(Player player, HitData hit)
|
||||
{
|
||||
if (!Active || hit == null) return;
|
||||
|
||||
float total = hit.m_damage.GetTotalDamage();
|
||||
hit.m_damage = default(HitData.DamageTypes);
|
||||
if (total <= 0f) return;
|
||||
|
||||
Pool -= total;
|
||||
// The exit itself is done in Tick, outside the damage call.
|
||||
}
|
||||
|
||||
public static void Tick(Player player)
|
||||
{
|
||||
if (!Active) return;
|
||||
|
||||
if (player == null || player.IsDead())
|
||||
{
|
||||
// The body is gone (or the world is): nothing to teleport, only the state to drop.
|
||||
Active = false;
|
||||
if (player != null) Publish(player, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Pool <= 0f || Time.time >= EndsAt)
|
||||
{
|
||||
Exit(player, Pool <= 0f ? "pool gone" : "time up");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Time.time >= nextPulse)
|
||||
{
|
||||
nextPulse = Time.time + AlfarPowerConfig.ArchonPulseInterval.Value;
|
||||
AlfarPowers.Pulse(player, AlfarPowerConfig.ArchonPulseRadius.Value, AlfarPowerConfig.ArchonPulseDamage.Value);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Leaving ─────────────────────────────────────────────────────────
|
||||
|
||||
public static void Exit(Player player, string reason)
|
||||
{
|
||||
if (!Active) return;
|
||||
|
||||
Active = false;
|
||||
Pool = 0f;
|
||||
Publish(player, false);
|
||||
AlfarStatusEffects.ClearTimer("archon");
|
||||
|
||||
// Eitr to zero, then the Heimkall: the form spends the one that was ready.
|
||||
AlfarEitr.Spend(player, player.GetEitr());
|
||||
AlfarHeimkall.TryTrigger(player, "Sameining " + reason, force: true);
|
||||
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_archon_off"));
|
||||
Jotunn.Logger.LogInfo($"[Alfar] Sameining off ({reason}).");
|
||||
}
|
||||
|
||||
/// <summary>The cooldown Ljosstorm and Geisli wait in the form, instead of costing eitr.</summary>
|
||||
public static float FreePowerCooldown => AlfarPowerConfig.ArchonFreePowerCooldown.Value;
|
||||
|
||||
/// <summary>
|
||||
/// NO WEAPONS in the form: the psionic pulse is the attack. Humanoid.StartAttack is the one
|
||||
/// door every swing, shot and draw goes through (verified, doc sec. 16B); returning false
|
||||
/// with a false result is "nothing started".
|
||||
/// </summary>
|
||||
[HarmonyLib.HarmonyPatch(typeof(Humanoid), "StartAttack")]
|
||||
public static class Alfar_Archon_NoWeapons_Patch
|
||||
{
|
||||
public static bool Prefix(Humanoid __instance, ref bool __result)
|
||||
{
|
||||
if (Active && __instance == Player.m_localPlayer)
|
||||
{
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Clears the state without teleporting (used by the reset command).</summary>
|
||||
public static void ForceClear(Player player)
|
||||
{
|
||||
Active = false;
|
||||
Pool = 0f;
|
||||
if (player != null) Publish(player, false);
|
||||
AlfarStatusEffects.ClearTimer("archon");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue