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");
|
||||
}
|
||||
}
|
||||
}
|
||||
134
JotunnModStub/Alfar/AlfarChests.cs
Normal file
134
JotunnModStub/Alfar/AlfarChests.cs
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
using System.Collections.Generic;
|
||||
using Jotunn.Configs;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The EIRINNSIGLI, the verdigris seal (Alfar_Progettazione.txt sec. 9.2c): a bronze nail turned at
|
||||
/// the forge. Put inside a chest it tells the drones NOT to look there - the inverse of the
|
||||
/// Butler's, where the seal says "this one is yours". Only the colour differs from the nail: a model
|
||||
/// recolour does not touch the inventory icon (guide 5.2), so in the pack it looks like a bronze
|
||||
/// nail and only the name tells it apart.
|
||||
/// </summary>
|
||||
public static class AlfarSigil
|
||||
{
|
||||
public const string PrefabName = "AlfarSigil";
|
||||
public const string DisplayName = "$rov_item_alfar_sigil_name";
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PrefabName, "BronzeNails");
|
||||
if (prefab == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] Could not clone BronzeNails: no verdigris seal.");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemDrop drop = prefab.GetComponent<ItemDrop>();
|
||||
if (drop == null || drop.m_itemData == null || drop.m_itemData.m_shared == null) return;
|
||||
|
||||
ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
|
||||
shared.m_name = DisplayName;
|
||||
shared.m_description = "$rov_item_alfar_sigil_desc";
|
||||
|
||||
AlfarConstructs.Tint(prefab, new Color(0.36f, 0.68f, 0.58f, 1f));
|
||||
ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false));
|
||||
|
||||
ItemManager.Instance.AddRecipe(new CustomRecipe(new RecipeConfig
|
||||
{
|
||||
Item = PrefabName,
|
||||
Amount = 1,
|
||||
CraftingStation = CraftingStations.Forge,
|
||||
MinStationLevel = 1,
|
||||
Requirements = new[] { new RequirementConfig("BronzeNails", 1, 0, true) },
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The two special chests (sec. 9.2c): built like an ordinary chest with Greydwarf eyes added to
|
||||
/// the price. The ENTRY chest is where everything is thrown and where the drones sort from; the
|
||||
/// WOOD chest holds the wood the drones may burn - the only wood they ever consume.
|
||||
/// </summary>
|
||||
public static class AlfarChests
|
||||
{
|
||||
public const string EntryName = "AlfarInngangskista";
|
||||
public const string WoodName = "AlfarEldividarkista";
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
RegisterOne(EntryName, "$rov_piece_alfar_inngangskista_name", "$rov_piece_alfar_inngangskista_desc",
|
||||
new Color(0.62f, 0.80f, 1f, 1f));
|
||||
RegisterOne(WoodName, "$rov_piece_alfar_eldividarkista_name", "$rov_piece_alfar_eldividarkista_desc",
|
||||
new Color(0.85f, 0.62f, 0.36f, 1f));
|
||||
}
|
||||
|
||||
private static void RegisterOne(string pieceName, string display, string description, Color tint)
|
||||
{
|
||||
GameObject source = PrefabManager.Cache.GetPrefab<GameObject>("piece_chest_wood");
|
||||
if (source == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] No 'piece_chest_wood': the chest " + pieceName + " is not registered.");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(pieceName, source);
|
||||
if (prefab == null) return;
|
||||
|
||||
// The price of a plain chest, read from the game (guide 3.2), plus the eyes.
|
||||
var requirements = new List<RequirementConfig>();
|
||||
Piece vanilla = source.GetComponent<Piece>();
|
||||
if (vanilla != null && vanilla.m_resources != null)
|
||||
{
|
||||
foreach (Piece.Requirement r in vanilla.m_resources)
|
||||
{
|
||||
if (r.m_resItem == null) continue;
|
||||
requirements.Add(new RequirementConfig(r.m_resItem.gameObject.name, r.m_amount, 0, true));
|
||||
}
|
||||
}
|
||||
requirements.Add(new RequirementConfig("GreydwarfEye", AlfarNexusConfig.ChestEyes.Value, 0, true));
|
||||
|
||||
Container container = prefab.GetComponent<Container>();
|
||||
if (container != null) container.m_name = display;
|
||||
|
||||
Piece piece = prefab.GetComponent<Piece>();
|
||||
if (piece == null) { Jotunn.Logger.LogWarning("[Alfar] The chest has no Piece: " + pieceName); return; }
|
||||
piece.m_name = display;
|
||||
piece.m_description = description;
|
||||
|
||||
AlfarConstructs.Tint(prefab, tint);
|
||||
|
||||
PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig
|
||||
{
|
||||
Name = display,
|
||||
Description = description,
|
||||
PieceTable = PieceTables.Hammer,
|
||||
Category = PieceCategories.Crafting,
|
||||
Icon = piece.m_icon,
|
||||
Requirements = requirements.ToArray(),
|
||||
}));
|
||||
|
||||
// One of each inside the reach of a Ljoskjarne, and only for the Alfar, and only where a core stands.
|
||||
PieceDensityLimit.Register(pieceName, AlfarNexusConfig.NexusRadius.Value, 1, "rov_msg_build_limit_alfar_chest");
|
||||
PieceDensityLimit.RegisterGate(pieceName, (player, position) =>
|
||||
{
|
||||
if (!AlfarRace.IsLocalAlfar())
|
||||
{
|
||||
if (player != null) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_only_alfar"));
|
||||
return false;
|
||||
}
|
||||
if (AlfarNexusBehaviour.Covering(position) == null)
|
||||
{
|
||||
if (player != null) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_chest_needs_nexus"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
AlfarPieces.Extra.Add(pieceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
110
JotunnModStub/Alfar/AlfarCommands.cs
Normal file
110
JotunnModStub/Alfar/AlfarCommands.cs
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
using Jotunn.Entities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// Test helpers for the Alfar, in the F5 console. They exist so the phases of Alfar_Test.txt can
|
||||
/// be walked through without waiting twenty minutes between steps.
|
||||
///
|
||||
/// alfarstatus what the race is doing right now (eitr, Heimkall timer, SE, form...)
|
||||
/// alfarreset clears every Alfar timer and cooldown
|
||||
/// alfareitr <n|full|0> sets the eitr pool: a number, "full", or 0
|
||||
/// alfarhp <n> sets the current health, to try the lethal-blow case without dying
|
||||
/// </summary>
|
||||
public class AlfarStatusCommand : ConsoleCommand
|
||||
{
|
||||
public override string Name => "alfarstatus";
|
||||
public override string Help => "[DEBUG] Prints the Alfar's eitr, health, Heimkall timer and passive.";
|
||||
|
||||
public override void Run(string[] args)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null) { Console.instance.Print("No local player."); return; }
|
||||
|
||||
string race = AlfarVisuals.GetPlayerRace(player);
|
||||
Print($"race={race} progression state={BossProgressionManager.GetCurrentProgressionState()}");
|
||||
Print($"health={player.GetHealth():0}/{player.GetMaxHealth():0} eitr={player.GetEitr():0.0}/{player.GetMaxEitr():0}");
|
||||
|
||||
float left = AlfarHeimkall.Remaining(player);
|
||||
Print($"Heimkall: {(left <= 0f ? "READY" : (left / 60f).ToString("0.0") + " min left")} " +
|
||||
$"(cooldown now {AlfarHeimkall.CooldownSeconds() / 60f:0} min)");
|
||||
|
||||
bool se = player.GetSEMan().HaveStatusEffect(SE_AlfarStats.EffectName.GetStableHashCode());
|
||||
Print($"passive status effect: {(se ? "on" : "OFF")}");
|
||||
}
|
||||
|
||||
private static void Print(string text)
|
||||
{
|
||||
Console.instance.Print("[Alfar] " + text);
|
||||
Jotunn.Logger.LogInfo("[Alfar] " + text);
|
||||
}
|
||||
}
|
||||
|
||||
public class AlfarResetCommand : ConsoleCommand
|
||||
{
|
||||
public override string Name => "alfarreset";
|
||||
public override string Help => "[DEBUG] Clears the Alfar's Heimkall timer and every power cooldown.";
|
||||
|
||||
public override void Run(string[] args)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null) return;
|
||||
|
||||
AlfarHeimkall.ResetTimer(player);
|
||||
AlfarHeimkall.InvulnerableUntil = 0f;
|
||||
AlfarPowers.ResetCooldowns(player);
|
||||
Console.instance.Print("[Alfar] Heimkall timer and power cooldowns cleared.");
|
||||
}
|
||||
}
|
||||
|
||||
public class AlfarEitrCommand : ConsoleCommand
|
||||
{
|
||||
public override string Name => "alfareitr";
|
||||
public override string Help => "[DEBUG] alfareitr <number|full|0> - sets the Alfr's current eitr.";
|
||||
|
||||
public override void Run(string[] args)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null || args.Length == 0) { Console.instance.Print("alfareitr <number|full|0>"); return; }
|
||||
|
||||
float target;
|
||||
if (args[0].ToLower() == "full") target = player.GetMaxEitr();
|
||||
else if (!float.TryParse(args[0], System.Globalization.NumberStyles.Float,
|
||||
System.Globalization.CultureInfo.InvariantCulture, out target))
|
||||
{
|
||||
Console.instance.Print("alfareitr <number|full|0>");
|
||||
return;
|
||||
}
|
||||
|
||||
target = Mathf.Clamp(target, 0f, player.GetMaxEitr());
|
||||
float delta = target - player.GetEitr();
|
||||
if (delta > 0f) player.AddEitr(delta);
|
||||
else if (delta < 0f) AlfarEitr.Spend(player, -delta);
|
||||
|
||||
Console.instance.Print($"[Alfar] eitr = {player.GetEitr():0.0}/{player.GetMaxEitr():0}");
|
||||
}
|
||||
}
|
||||
|
||||
public class AlfarHpCommand : ConsoleCommand
|
||||
{
|
||||
public override string Name => "alfarhp";
|
||||
public override string Help => "[DEBUG] alfarhp <number> - sets the current health, to test the lethal-blow case.";
|
||||
|
||||
public override void Run(string[] args)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null || args.Length == 0) { Console.instance.Print("alfarhp <number>"); return; }
|
||||
|
||||
if (!float.TryParse(args[0], System.Globalization.NumberStyles.Float,
|
||||
System.Globalization.CultureInfo.InvariantCulture, out float hp))
|
||||
{
|
||||
Console.instance.Print("alfarhp <number>");
|
||||
return;
|
||||
}
|
||||
|
||||
player.SetHealth(Mathf.Clamp(hp, 1f, player.GetMaxHealth()));
|
||||
Console.instance.Print($"[Alfar] health = {player.GetHealth():0}/{player.GetMaxHealth():0}");
|
||||
}
|
||||
}
|
||||
}
|
||||
159
JotunnModStub/Alfar/AlfarConfig.cs
Normal file
159
JotunnModStub/Alfar/AlfarConfig.cs
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
using BepInEx.Configuration;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// Every number the Alfar use. Nothing numeric lives in the logic files (guide 3.4), and every
|
||||
/// value here is a STARTING value: Alfar_Progettazione.txt sec. 19 says they will all be
|
||||
/// corrected in play.
|
||||
///
|
||||
/// Only the look is bound so far. The shield, the powers and the base add their own sections as
|
||||
/// they are written.
|
||||
/// </summary>
|
||||
public static class AlfarConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Written into m_customData["Race"] and the ZDO. Chosen once and never changed: renaming it
|
||||
/// later leaves every saved Alfar character unrecognised and back to human (the Brandr
|
||||
/// lesson, design doc sec. 2).
|
||||
/// </summary>
|
||||
public const string RaceId = "Alfar";
|
||||
|
||||
// ─── Look ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>The tint written into _SkinColor. Ash grey: low saturation, a hair cool.</summary>
|
||||
public static ConfigEntry<Color> SkinColor;
|
||||
|
||||
/// <summary>
|
||||
/// Height against a normal Viking: +5%, design doc sec. 7.1. Applied to the Visual child's Y,
|
||||
/// never the root (RaceEyeHeight explains why).
|
||||
/// </summary>
|
||||
public static ConfigEntry<float> HeightScale;
|
||||
|
||||
/// <summary>
|
||||
/// Width and depth: "barely visibly thinner", about -8%. Together with HeightScale this is a
|
||||
/// NON-UNIFORM scale, which is where held weapons and the first-person camera tend to look
|
||||
/// squashed - doc sec. 7.2. If it does, raise this toward 1 before touching anything else.
|
||||
/// </summary>
|
||||
public static ConfigEntry<float> WidthScale;
|
||||
|
||||
/// <summary>
|
||||
/// 1 is the Sverm's size, which is what the design asked to try first ("se non va li
|
||||
/// allarghiamo"). Raise it to enlarge the eyes: 1.6 is roughly a grey from the films.
|
||||
/// </summary>
|
||||
public static ConfigEntry<float> EyeSizeMultiplier;
|
||||
|
||||
// The eye geometry is the Sverm's, unchanged (SvermVisuals): offsets are metres in the head
|
||||
// bone's OWN frame, so they land on the same part of the face at any body scale.
|
||||
public const float EyeSeparation = 0.032f;
|
||||
public const float EyeForward = 0.081f;
|
||||
public const float EyeHeight = 0.181f;
|
||||
public const float EyeSize = 0.062f;
|
||||
|
||||
// ─── Eitr: diet, shield, soft fall ───────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// What each food adds to the maximum eitr besides its own: min(hp, stamina) times this.
|
||||
/// 1 is the design (sec. 3): native eitr plus the lower of hp and stamina.
|
||||
/// </summary>
|
||||
public static ConfigEntry<float> DietMultiplier;
|
||||
|
||||
/// <summary>
|
||||
/// Eitr spent per point of damage. 1:1, FIXED, for ever (sec. 4.1): progression comes from
|
||||
/// the food raising the pool, not from a better rate.
|
||||
/// </summary>
|
||||
public static ConfigEntry<float> ShieldRate;
|
||||
|
||||
/// <summary>Lightning and spirit cost this many times the rate (sec. 5.1: the double cost).</summary>
|
||||
public static ConfigEntry<float> ConductiveMultiplier;
|
||||
|
||||
/// <summary>
|
||||
/// Falls cost nothing while there is any eitr (sec. 4.5: soft fall). Off, a fall is shielded
|
||||
/// like any other blow.
|
||||
/// </summary>
|
||||
public static ConfigEntry<bool> SoftFall;
|
||||
|
||||
/// <summary>
|
||||
/// The fastest an Alfr falls while there is eitr, in metres per second. The vanilla Feather
|
||||
/// Cape caps at 5; a little under that reads as floating.
|
||||
/// </summary>
|
||||
public static ConfigEntry<float> FeatherFallSpeed;
|
||||
|
||||
// ─── Heimkall: the death that costs a wait ───────────────────────────
|
||||
|
||||
/// <summary>Minutes before a second Heimkall is possible, before Yagluth (sec. 6).</summary>
|
||||
public static ConfigEntry<float> HeimkallMinutes;
|
||||
|
||||
/// <summary>The same, once Yagluth is down.</summary>
|
||||
public static ConfigEntry<float> HeimkallMinutesAfterYagluth;
|
||||
|
||||
/// <summary>The same, once Fader is down.</summary>
|
||||
public static ConfigEntry<float> HeimkallMinutesAfterFader;
|
||||
|
||||
/// <summary>
|
||||
/// Seconds of invulnerability on arrival, so a lethal blow does not simply repeat at the
|
||||
/// bed. Without it a burning or drowning death would loop.
|
||||
/// </summary>
|
||||
public static ConfigEntry<float> HeimkallInvulnerableSeconds;
|
||||
|
||||
public static void Bind(ConfigFile config)
|
||||
{
|
||||
const string heimkall = "Alfar - Heimkall";
|
||||
|
||||
HeimkallMinutes = config.Bind(heimkall, "Cooldown Minutes", 20f,
|
||||
new ConfigDescription("Minutes between two Heimkalls (the lethal-blow teleport to the bed). Inside this wait, a lethal blow kills normally.",
|
||||
new AcceptableValueRange<float>(0f, 120f)));
|
||||
|
||||
HeimkallMinutesAfterYagluth = config.Bind(heimkall, "Cooldown Minutes After Yagluth", 15f,
|
||||
new ConfigDescription("The cooldown once Yagluth is defeated.",
|
||||
new AcceptableValueRange<float>(0f, 120f)));
|
||||
|
||||
HeimkallMinutesAfterFader = config.Bind(heimkall, "Cooldown Minutes After Fader", 10f,
|
||||
new ConfigDescription("The cooldown once Fader is defeated.",
|
||||
new AcceptableValueRange<float>(0f, 120f)));
|
||||
|
||||
HeimkallInvulnerableSeconds = config.Bind(heimkall, "Invulnerable Seconds", 5f,
|
||||
new ConfigDescription("Seconds nothing can hurt the Alfr after arriving.",
|
||||
new AcceptableValueRange<float>(0f, 30f)));
|
||||
|
||||
const string eitr = "Alfar - Eitr";
|
||||
|
||||
DietMultiplier = config.Bind(eitr, "Diet Multiplier", 1f,
|
||||
new ConfigDescription("Each food adds its native eitr plus min(hp, stamina) times this to the maximum eitr.",
|
||||
new AcceptableValueRange<float>(0f, 3f)));
|
||||
|
||||
ShieldRate = config.Bind(eitr, "Shield Rate", 1f,
|
||||
new ConfigDescription("Eitr spent per point of damage absorbed (1 = 1:1).",
|
||||
new AcceptableValueRange<float>(0.1f, 5f)));
|
||||
|
||||
ConductiveMultiplier = config.Bind(eitr, "Lightning And Spirit Multiplier", 2f,
|
||||
new ConfigDescription("Lightning and spirit damage cost this many times the shield rate.",
|
||||
new AcceptableValueRange<float>(1f, 5f)));
|
||||
|
||||
SoftFall = config.Bind(eitr, "Soft Fall", true,
|
||||
new ConfigDescription("Falling does no damage, and is slowed, while the Alfr has any eitr."));
|
||||
|
||||
FeatherFallSpeed = config.Bind(eitr, "Feather Fall Speed", 4f,
|
||||
new ConfigDescription("Maximum falling speed (m/s) while the Alfr has eitr. Lower floats more.",
|
||||
new AcceptableValueRange<float>(1f, 20f)));
|
||||
|
||||
const string look = "Alfar - Look";
|
||||
|
||||
SkinColor = config.Bind(look, "Skin Color", new Color(0.86f, 0.88f, 0.88f, 1f),
|
||||
new ConfigDescription("How light the ash-grey skin is. The skin texture itself is made grey; this only sets its brightness."));
|
||||
|
||||
HeightScale = config.Bind(look, "Height Scale", 1.05f,
|
||||
new ConfigDescription("Body height against a normal Viking (1.05 = +5%).",
|
||||
new AcceptableValueRange<float>(0.8f, 1.3f)));
|
||||
|
||||
WidthScale = config.Bind(look, "Width Scale", 0.92f,
|
||||
new ConfigDescription("Body width and depth against a normal Viking (0.92 = 8% thinner).",
|
||||
new AcceptableValueRange<float>(0.7f, 1.2f)));
|
||||
|
||||
EyeSizeMultiplier = config.Bind(look, "Eye Size Multiplier", 0.8f,
|
||||
new ConfigDescription("1 = the Sverm's eye size; 0.8 is slightly smaller. Raise to enlarge the black eyes.",
|
||||
new AcceptableValueRange<float>(0.5f, 3f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
397
JotunnModStub/Alfar/AlfarConstructs.cs
Normal file
397
JotunnModStub/Alfar/AlfarConstructs.cs
Normal file
|
|
@ -0,0 +1,397 @@
|
|||
using System.Collections.Generic;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The three constructs, the Alfar's only troops (Alfar_Progettazione.txt sec. 8.5):
|
||||
///
|
||||
/// Neistvordr a Surtling: hp 60 and a shield of 60 (the vanilla Surtling has 20), fire thrower
|
||||
/// Steinvordr the StoneGolem: hp 800, the tank, ONE per Nexus
|
||||
/// Eldingvordr a smaller Abomination at half its hp, which fires a lightning sphere every 8 s
|
||||
///
|
||||
/// Everything that makes them the Alfar's is done by what is added, not by rewriting attacks:
|
||||
/// AlfarMark turns whatever they deal into lightning and keeps it off friends and buildings,
|
||||
/// AlfarCreatureShield gives them a shield that returns by itself, and RaisedThrall gives them
|
||||
/// the follow and stay orders every other race's troops already have.
|
||||
///
|
||||
/// They are NOT repaired and do not heal: the damage to the body is permanent. RaisedThrall's
|
||||
/// sentinel regeneration (SkeletonSentryBehaviour) is therefore left off, and the creature's own
|
||||
/// slow vanilla regeneration is switched off too.
|
||||
/// </summary>
|
||||
public static class AlfarConstructs
|
||||
{
|
||||
public const string Neistvordr = "AlfarNeistvordr";
|
||||
public const string Steinvordr = "AlfarSteinvordr";
|
||||
public const string Eldingvordr = "AlfarEldingvordr";
|
||||
|
||||
public const string SphereProjectile = "AlfarLightningSphere";
|
||||
public const string SphereWeapon = "AlfarSphereAttack";
|
||||
|
||||
public class Kind
|
||||
{
|
||||
public string PrefabName;
|
||||
public string Display;
|
||||
public string Source;
|
||||
public float Health; // 0 = keep the vanilla creature's
|
||||
public float HealthFactor; // applied after Health when Health is 0
|
||||
public float Scale; // 1 = the vanilla size
|
||||
}
|
||||
|
||||
public static readonly Kind[] Roster =
|
||||
{
|
||||
new Kind { PrefabName = Neistvordr, Display = "$rov_creature_alfar_neistvordr_name", Source = "Surtling", Health = 60f, Scale = 1f },
|
||||
new Kind { PrefabName = Steinvordr, Display = "$rov_creature_alfar_steinvordr_name", Source = "StoneGolem", Health = 0f, HealthFactor = 1f, Scale = 0.6f },
|
||||
new Kind { PrefabName = Eldingvordr, Display = "$rov_creature_alfar_eldingvordr_name", Source = "Abomination", Health = 0f, HealthFactor = 0.5f, Scale = 0.4f },
|
||||
};
|
||||
|
||||
public static Kind Find(string prefabName)
|
||||
{
|
||||
foreach (Kind kind in Roster) if (kind.PrefabName == prefabName) return kind;
|
||||
return null;
|
||||
}
|
||||
|
||||
// ─── Registration ────────────────────────────────────────────────────
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
// The sphere first: the Eldingvordr's weapon needs it.
|
||||
bool sphere = RegisterSphere();
|
||||
|
||||
foreach (Kind kind in Roster)
|
||||
{
|
||||
if (kind.PrefabName == Eldingvordr && !sphere)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] No lightning sphere: the Eldingvordr keeps the Abomination's melee.");
|
||||
}
|
||||
RegisterOne(kind, sphere);
|
||||
}
|
||||
}
|
||||
|
||||
private static void RegisterOne(Kind kind, bool sphere)
|
||||
{
|
||||
GameObject source = PrefabManager.Cache.GetPrefab<GameObject>(kind.Source);
|
||||
if (source == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning($"[Alfar] No '{kind.Source}' to build {kind.Display} from.");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(kind.PrefabName, source);
|
||||
if (prefab == null) return;
|
||||
|
||||
Character character = prefab.GetComponent<Character>();
|
||||
if (character != null)
|
||||
{
|
||||
character.m_name = kind.Display;
|
||||
character.m_faction = Character.Faction.Players;
|
||||
if (kind.Health > 0f) character.m_health = kind.Health;
|
||||
else character.m_health *= kind.HealthFactor;
|
||||
|
||||
// The damage to the body is permanent: no slow regeneration either.
|
||||
character.m_regenAllHPTime = 0f;
|
||||
}
|
||||
|
||||
if (!Mathf.Approximately(kind.Scale, 1f))
|
||||
{
|
||||
prefab.transform.localScale = Vector3.one * kind.Scale;
|
||||
ZNetView nview = prefab.GetComponent<ZNetView>();
|
||||
if (nview != null) nview.m_syncInitialScale = true;
|
||||
}
|
||||
|
||||
BaseAI ai = prefab.GetComponent<BaseAI>();
|
||||
if (ai != null) ai.m_randomMoveRange = AlfarNexusConfig.ConstructLeash.Value;
|
||||
|
||||
MonsterAI monster = prefab.GetComponent<MonsterAI>();
|
||||
if (monster != null)
|
||||
{
|
||||
// The vanilla creatures attack player-built objects. Ours never touch a building.
|
||||
monster.m_attackPlayerObjects = false;
|
||||
monster.m_alertRange = AlfarNexusConfig.ConstructAlertRange.Value;
|
||||
monster.m_maxChaseDistance = AlfarNexusConfig.ConstructAlertRange.Value;
|
||||
}
|
||||
|
||||
// A construct that dropped Coal, a Surtling core or a trophy would be a loot farm.
|
||||
foreach (CharacterDrop drops in prefab.GetComponentsInChildren<CharacterDrop>(true))
|
||||
{
|
||||
if (drops != null) Object.DestroyImmediate(drops);
|
||||
}
|
||||
|
||||
if (kind.PrefabName == Eldingvordr && sphere) GiveSphereWeapon(prefab);
|
||||
if (kind.PrefabName == Neistvordr) BlueFlames(prefab);
|
||||
else Tint(prefab, new Color(0.85f, 0.52f, 0.2f, 1f));
|
||||
|
||||
AlfarMark mark = prefab.AddComponent<AlfarMark>();
|
||||
mark.Role = "construct";
|
||||
|
||||
// What a destroyed construct gives back: the METAL it was built from, and nothing else - the
|
||||
// crystals and the refined eitr are spent for good (design sec. 8.5).
|
||||
AlfarRefund refund = prefab.AddComponent<AlfarRefund>();
|
||||
refund.Item = kind.PrefabName == Neistvordr ? "Bronze" : kind.PrefabName == Eldingvordr ? "Iron" : "BlackMetal";
|
||||
refund.Amount = kind.PrefabName == Neistvordr ? AlfarNexusConfig.NeistMetal.Value
|
||||
: kind.PrefabName == Eldingvordr ? AlfarNexusConfig.EldingMetal.Value
|
||||
: AlfarNexusConfig.SteinMetal.Value;
|
||||
|
||||
AlfarCreatureShield shield = prefab.AddComponent<AlfarCreatureShield>();
|
||||
shield.MaxShield = character != null ? character.m_health : 0f;
|
||||
shield.Shield = shield.MaxShield;
|
||||
|
||||
RaisedThrall thrall = prefab.AddComponent<RaisedThrall>();
|
||||
thrall.m_kind = kind.PrefabName;
|
||||
thrall.m_commandingRace = AlfarConfig.RaceId;
|
||||
thrall.m_maxFollowers = -1; // the cap is the Nexus's, per type, counted at the Nexus
|
||||
thrall.m_witherSeconds = AlfarNexusConfig.WitherSeconds.Value;
|
||||
thrall.m_homeCheckRange = AlfarNexusConfig.NexusRadius.Value;
|
||||
thrall.m_refusalMessage = "$rov_msg_thrall_refusal_alfar";
|
||||
|
||||
PrefabManager.Instance.AddPrefab(prefab);
|
||||
Jotunn.Logger.LogInfo($"[Alfar] Registered '{kind.PrefabName}' from '{kind.Source}'.");
|
||||
}
|
||||
|
||||
// ─── The lightning sphere ────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// The Eldingvordr's shot: a sphere that bursts in a small area, hurts only enemies, and never
|
||||
/// touches a building (doc sec. 8.5 and 16B V12). Cloned from the Dverger ice projectile, the
|
||||
/// clean base the probe found: an area burst and NO lingering effect spawned on impact (the
|
||||
/// fire one drops a fire field and also spawns on buildings).
|
||||
/// </summary>
|
||||
private static bool RegisterSphere()
|
||||
{
|
||||
GameObject source = PrefabManager.Cache.GetPrefab<GameObject>("DvergerStaffIce_projectile");
|
||||
if (source == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] DvergerStaffIce_projectile not found: no lightning sphere.");
|
||||
return false;
|
||||
}
|
||||
|
||||
GameObject projectile = PrefabManager.Instance.CreateClonedPrefab(SphereProjectile, source);
|
||||
if (projectile == null) return false;
|
||||
|
||||
Projectile settings = projectile.GetComponent<Projectile>();
|
||||
if (settings == null) return false;
|
||||
|
||||
settings.m_gravity = 0f;
|
||||
settings.m_ttl = 4f;
|
||||
settings.m_aoe = 3f;
|
||||
settings.m_aoeSkipWearNTear = true;
|
||||
settings.m_hitFriendly = false;
|
||||
settings.m_noDamageFriendly = true;
|
||||
settings.m_hitOwner = false;
|
||||
settings.m_statusEffect = "";
|
||||
|
||||
Tint(projectile, new Color(0.55f, 0.85f, 1f, 1f));
|
||||
PrefabManager.Instance.AddPrefab(projectile);
|
||||
|
||||
// The weapon that fires it: the Surtling's own fireball weapon, because a creature that
|
||||
// shoots needs an item with a projectile attack, and that is the one that exists.
|
||||
GameObject surtling = PrefabManager.Cache.GetPrefab<GameObject>("Surtling");
|
||||
Humanoid surtlingHumanoid = surtling != null ? surtling.GetComponent<Humanoid>() : null;
|
||||
GameObject fireball = surtlingHumanoid != null && surtlingHumanoid.m_defaultItems != null &&
|
||||
surtlingHumanoid.m_defaultItems.Length > 0
|
||||
? surtlingHumanoid.m_defaultItems[0]
|
||||
: null;
|
||||
if (fireball == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] The Surtling's fireball weapon was not found: no sphere weapon.");
|
||||
return false;
|
||||
}
|
||||
|
||||
GameObject weapon = PrefabManager.Instance.CreateClonedPrefab(SphereWeapon, fireball);
|
||||
if (weapon == null) return false;
|
||||
|
||||
ItemDrop drop = weapon.GetComponent<ItemDrop>();
|
||||
if (drop == null || drop.m_itemData == null || drop.m_itemData.m_shared == null) return false;
|
||||
|
||||
ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
|
||||
shared.m_name = "$rov_item_alfar_sphere_name";
|
||||
|
||||
// One shot every eight seconds (design): the AI waits this long between uses.
|
||||
shared.m_aiAttackInterval = AlfarNexusConfig.SphereIntervalSeconds.Value;
|
||||
shared.m_aiAttackRange = AlfarNexusConfig.SphereRange.Value;
|
||||
shared.m_aiAttackRangeMin = 4f;
|
||||
|
||||
HitData.DamageTypes damage = default(HitData.DamageTypes);
|
||||
damage.m_lightning = AlfarNexusConfig.SphereDamage.Value;
|
||||
shared.m_damages = damage;
|
||||
|
||||
if (shared.m_attack != null)
|
||||
{
|
||||
shared.m_attack.m_attackProjectile = projectile;
|
||||
// The Abomination's right hand: where the sphere leaves from.
|
||||
shared.m_attack.m_attackOriginJoint = "r.hand";
|
||||
}
|
||||
|
||||
ItemManager.Instance.AddItem(new CustomItem(weapon, fixReference: false));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void GiveSphereWeapon(GameObject prefab)
|
||||
{
|
||||
Humanoid humanoid = prefab.GetComponent<Humanoid>();
|
||||
GameObject weapon = PrefabManager.Instance.GetPrefab(SphereWeapon);
|
||||
if (humanoid == null || weapon == null) return;
|
||||
|
||||
humanoid.m_defaultItems = new[] { weapon };
|
||||
humanoid.m_randomWeapon = new GameObject[0];
|
||||
humanoid.m_randomArmor = new GameObject[0];
|
||||
humanoid.m_randomShield = new GameObject[0];
|
||||
humanoid.m_randomSets = new Humanoid.ItemSet[0];
|
||||
}
|
||||
|
||||
// ─── Colour ──────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// A tint on every mesh, through renderer.materials (an instanced copy) and NEVER .material or
|
||||
/// sharedMaterial: the vanilla creature uses the same asset and must stay as it is (guide 3.5).
|
||||
/// This is a recolour and not a retexture: a true repaint of the golem and the Abomination is
|
||||
/// still to do (test file, phase 6).
|
||||
/// </summary>
|
||||
public static void Tint(GameObject prefab, Color color)
|
||||
{
|
||||
foreach (Renderer renderer in prefab.GetComponentsInChildren<Renderer>(true))
|
||||
{
|
||||
if (renderer is ParticleSystemRenderer || renderer is TrailRenderer || renderer is LineRenderer) continue;
|
||||
|
||||
Material[] materials = renderer.materials;
|
||||
foreach (Material material in materials)
|
||||
{
|
||||
if (material == null) continue;
|
||||
if (material.HasProperty("_Color")) material.color = color;
|
||||
if (material.HasProperty("_EmissionColor"))
|
||||
{
|
||||
material.SetColor("_EmissionColor", color * 0.08f);
|
||||
material.EnableKeyword("_EMISSION");
|
||||
}
|
||||
}
|
||||
renderer.materials = materials;
|
||||
}
|
||||
|
||||
foreach (Light light in prefab.GetComponentsInChildren<Light>(true)) light.color = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Surtling is made of particles and lights, not textures, and the vanilla prefab ALREADY
|
||||
/// carries blue variants of its flames, switched off (probe, doc 16C P2): turn those on, turn
|
||||
/// the red ones off, and recolour the glow of the body and the point light.
|
||||
/// </summary>
|
||||
private static void BlueFlames(GameObject prefab)
|
||||
{
|
||||
foreach (Transform child in prefab.GetComponentsInChildren<Transform>(true))
|
||||
{
|
||||
if (child.name == "flames_world_BLUE") child.gameObject.SetActive(true);
|
||||
else if (child.name == "flames" || child.name == "flames_world" || child.name == "flames_world_Purple")
|
||||
{
|
||||
child.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
Color blue = new Color(0.25f, 0.55f, 1f, 1f);
|
||||
foreach (Light light in prefab.GetComponentsInChildren<Light>(true)) light.color = blue;
|
||||
|
||||
foreach (Renderer renderer in prefab.GetComponentsInChildren<SkinnedMeshRenderer>(true))
|
||||
{
|
||||
Material[] materials = renderer.materials;
|
||||
foreach (Material material in materials)
|
||||
{
|
||||
if (material != null && material.HasProperty("_EmissionColor"))
|
||||
{
|
||||
// The vanilla emission is white-hot (73): keep the strength, change the hue.
|
||||
material.SetColor("_EmissionColor", new Color(0.25f, 0.55f, 1f, 1f) * 30f);
|
||||
}
|
||||
}
|
||||
renderer.materials = materials;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Counting and spawning (called by the Nexus) ─────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// A destroyed construct drops the metal it cost, on the ground where it fell. Only a DEATH:
|
||||
/// a zone unloading destroys the object too and must not pay anyone (the same rule as the
|
||||
/// Butler's payload).
|
||||
/// </summary>
|
||||
public class AlfarRefund : MonoBehaviour
|
||||
{
|
||||
public string Item = "";
|
||||
public int Amount;
|
||||
}
|
||||
|
||||
[HarmonyLib.HarmonyPatch(typeof(Character), "OnDeath")]
|
||||
public static class Alfar_Refund_Patch
|
||||
{
|
||||
public static void Postfix(Character __instance)
|
||||
{
|
||||
AlfarRefund refund = __instance != null ? __instance.GetComponent<AlfarRefund>() : null;
|
||||
if (refund == null || refund.Amount <= 0 || ObjectDB.instance == null) return;
|
||||
|
||||
GameObject prefab = ObjectDB.instance.GetItemPrefab(refund.Item);
|
||||
ItemDrop template = prefab != null ? prefab.GetComponent<ItemDrop>() : null;
|
||||
if (template == null || template.m_itemData == null) return;
|
||||
|
||||
int left = refund.Amount;
|
||||
int max = Mathf.Max(1, template.m_itemData.m_shared.m_maxStackSize);
|
||||
Vector3 at = __instance.transform.position + Vector3.up * 0.5f;
|
||||
|
||||
while (left > 0)
|
||||
{
|
||||
int stack = Mathf.Min(left, max);
|
||||
ItemDrop.ItemData clone = template.m_itemData.Clone();
|
||||
clone.m_dropPrefab = prefab;
|
||||
ItemDrop.DropItem(clone, stack, at + Random.insideUnitSphere * 0.3f, Quaternion.identity);
|
||||
left -= stack;
|
||||
}
|
||||
refund.Amount = 0; // once only
|
||||
}
|
||||
}
|
||||
|
||||
public static int CountAlive(Vector3 anchor, string prefabName)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (RaisedThrall thrall in RaisedThrall.BoundTo(anchor))
|
||||
{
|
||||
if (thrall != null && thrall.Kind == prefabName) count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static bool Spawn(Vector3 anchor, string prefabName)
|
||||
{
|
||||
GameObject prefab = ZNetScene.instance != null ? ZNetScene.instance.GetPrefab(prefabName) : null;
|
||||
if (prefab == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning($"[Alfar] No '{prefabName}' in ZNetScene: it cannot be built.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 where = SpawnSpot(anchor);
|
||||
GameObject spawned = Object.Instantiate(prefab, where, Quaternion.Euler(0f, Random.Range(0, 360), 0f));
|
||||
RaisedThrall thrall = spawned != null ? spawned.GetComponent<RaisedThrall>() : null;
|
||||
if (thrall != null) thrall.Bind(anchor);
|
||||
return spawned != null;
|
||||
}
|
||||
|
||||
/// <summary>A free spot on a ring around the Nexus, on the ground, or due south as a last resort.</summary>
|
||||
public static Vector3 SpawnSpot(Vector3 centre)
|
||||
{
|
||||
const float radius = 3.5f;
|
||||
int obstacleMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "vehicle");
|
||||
float start = Random.Range(0f, 360f);
|
||||
|
||||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
float angle = (start + i * 30f) * Mathf.Deg2Rad;
|
||||
Vector3 candidate = centre + new Vector3(Mathf.Cos(angle), 0f, Mathf.Sin(angle)) * radius;
|
||||
if (ZoneSystem.instance != null) candidate.y = ZoneSystem.instance.GetGroundHeight(candidate);
|
||||
if (Physics.CheckSphere(candidate + Vector3.up * 1.5f, 1f, obstacleMask)) continue;
|
||||
return candidate + Vector3.up * 0.3f;
|
||||
}
|
||||
|
||||
Vector3 fallback = centre + new Vector3(0f, 0f, -radius);
|
||||
if (ZoneSystem.instance != null) fallback.y = ZoneSystem.instance.GetGroundHeight(fallback);
|
||||
return fallback + Vector3.up * 0.3f;
|
||||
}
|
||||
}
|
||||
}
|
||||
1950
JotunnModStub/Alfar/AlfarDroneAI.cs
Normal file
1950
JotunnModStub/Alfar/AlfarDroneAI.cs
Normal file
File diff suppressed because it is too large
Load diff
365
JotunnModStub/Alfar/AlfarDrones.cs
Normal file
365
JotunnModStub/Alfar/AlfarDrones.cs
Normal file
|
|
@ -0,0 +1,365 @@
|
|||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The LJOSVAETTIR, the Alfar's drones (Alfar_Progettazione.txt sec. 9): a Deathsquito without legs,
|
||||
/// stinger or buzz, bronze, with blue light. One kind of drone does every job (the work itself is
|
||||
/// AlfarDroneWork); the only thing apart is the GRAFVAETTIR, the same creature thrown like a
|
||||
/// grenade to dig the precious ores around a point for two minutes and then vanish.
|
||||
///
|
||||
/// What a drone is by itself: 25 hp and a shield of 25, tamed, tied to its Ljoskjarne, and able to
|
||||
/// defend itself with a lightning zap of 1 damage every two seconds. It never attacks anything
|
||||
/// outside the Nexus's radius and never goes after anything: it is a worker, not a soldier.
|
||||
///
|
||||
/// The Deathsquito is ONE skinned mesh with one material (probe, doc 16C P1): the legs are bones, so
|
||||
/// they are hidden by scaling the bones to zero, and the blue is an emission on a bronze body, not
|
||||
/// separate eyes and wings - a true repaint is still to do.
|
||||
/// </summary>
|
||||
public static class AlfarDrones
|
||||
{
|
||||
public const string DroneName = "AlfarDrone";
|
||||
public const string MinerName = "AlfarGrafvaettir";
|
||||
public const string ZapWeapon = "AlfarDroneZap";
|
||||
|
||||
private static readonly Color Bronze = new Color(1f, 0.62f, 0.25f, 1f);
|
||||
private static readonly Color ElectricBlue = new Color(0.25f, 0.65f, 1f, 1f);
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
GameObject source = PrefabManager.Cache.GetPrefab<GameObject>("Deathsquito");
|
||||
if (source == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] No 'Deathsquito' to build the drones from.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool zap = RegisterZap(source);
|
||||
RegisterOne(source, DroneName, "$rov_creature_alfar_drone_name", zap, miner: false);
|
||||
RegisterOne(source, MinerName, "$rov_creature_alfar_grafvaettir_name", zap, miner: true);
|
||||
}
|
||||
|
||||
/// <summary>The Deathsquito's sting turned into a zap: 1 lightning, every two seconds.</summary>
|
||||
private static bool RegisterZap(GameObject deathsquito)
|
||||
{
|
||||
Humanoid humanoid = deathsquito.GetComponent<Humanoid>();
|
||||
GameObject sting = humanoid != null && humanoid.m_defaultItems != null && humanoid.m_defaultItems.Length > 0
|
||||
? humanoid.m_defaultItems[0]
|
||||
: null;
|
||||
if (sting == null) return false;
|
||||
|
||||
GameObject weapon = PrefabManager.Instance.CreateClonedPrefab(ZapWeapon, sting);
|
||||
if (weapon == null) return false;
|
||||
|
||||
ItemDrop drop = weapon.GetComponent<ItemDrop>();
|
||||
if (drop == null || drop.m_itemData == null || drop.m_itemData.m_shared == null) return false;
|
||||
|
||||
ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
|
||||
shared.m_name = "$rov_item_alfar_zap_name";
|
||||
|
||||
HitData.DamageTypes damage = default(HitData.DamageTypes);
|
||||
damage.m_lightning = AlfarNexusConfig.DroneZapDamage.Value;
|
||||
shared.m_damages = damage;
|
||||
shared.m_aiAttackInterval = AlfarNexusConfig.DroneZapInterval.Value;
|
||||
|
||||
ItemManager.Instance.AddItem(new CustomItem(weapon, fixReference: false));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void RegisterOne(GameObject source, string prefabName, string display, bool zap, bool miner)
|
||||
{
|
||||
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(prefabName, source);
|
||||
if (prefab == null) return;
|
||||
|
||||
Character character = prefab.GetComponent<Character>();
|
||||
if (character != null)
|
||||
{
|
||||
character.m_name = display;
|
||||
character.m_faction = Character.Faction.Players;
|
||||
character.m_health = AlfarNexusConfig.DroneHealth.Value;
|
||||
}
|
||||
|
||||
Humanoid humanoid = prefab.GetComponent<Humanoid>();
|
||||
if (humanoid != null)
|
||||
{
|
||||
GameObject weapon = zap ? PrefabManager.Instance.GetPrefab(ZapWeapon) : null;
|
||||
// A miner does not fight at all; the worker only defends itself.
|
||||
humanoid.m_defaultItems = !miner && weapon != null ? new[] { weapon } : new GameObject[0];
|
||||
humanoid.m_randomWeapon = new GameObject[0];
|
||||
humanoid.m_randomArmor = new GameObject[0];
|
||||
humanoid.m_randomShield = new GameObject[0];
|
||||
humanoid.m_randomSets = new Humanoid.ItemSet[0];
|
||||
}
|
||||
|
||||
MonsterAI monster = prefab.GetComponent<MonsterAI>();
|
||||
if (monster != null)
|
||||
{
|
||||
monster.m_attackPlayerObjects = false;
|
||||
monster.m_alertRange = AlfarNexusConfig.NexusRadius.Value;
|
||||
monster.m_maxChaseDistance = AlfarNexusConfig.NexusRadius.Value;
|
||||
}
|
||||
|
||||
BaseAI ai = prefab.GetComponent<BaseAI>();
|
||||
if (ai != null) ai.m_randomMoveRange = 5f;
|
||||
|
||||
foreach (CharacterDrop drops in prefab.GetComponentsInChildren<CharacterDrop>(true))
|
||||
{
|
||||
if (drops != null) Object.DestroyImmediate(drops);
|
||||
}
|
||||
|
||||
// The buzz: the continuous sound child, and the flying loop effect.
|
||||
foreach (Transform child in prefab.GetComponentsInChildren<Transform>(true))
|
||||
{
|
||||
if (child != null && child.name == "SFX") Object.DestroyImmediate(child.gameObject);
|
||||
}
|
||||
if (character != null) character.m_flyingContinuousEffect = new EffectList { m_effectPrefabs = new EffectList.EffectData[0] };
|
||||
|
||||
HideLegs(prefab);
|
||||
Look(prefab);
|
||||
prefab.AddComponent<AlfarDroneLook>();
|
||||
|
||||
AlfarMark mark = prefab.AddComponent<AlfarMark>();
|
||||
mark.Role = miner ? "miner" : "drone";
|
||||
|
||||
AlfarCreatureShield shield = prefab.AddComponent<AlfarCreatureShield>();
|
||||
shield.MaxShield = AlfarNexusConfig.DroneHealth.Value;
|
||||
shield.Shield = shield.MaxShield;
|
||||
|
||||
if (miner)
|
||||
{
|
||||
// The mining drone has no anchor and no leash: it lives two minutes and vanishes.
|
||||
prefab.AddComponent<AlfarMiner>();
|
||||
}
|
||||
else
|
||||
{
|
||||
// The worker is NOT a RaisedThrall: that brings the follow command on E, and a drone
|
||||
// that can be walked out of the base stops working (the Butler's reasoning, Butler 9).
|
||||
// AlfarDroneAI keeps its own anchor to the Nexus and its own wither.
|
||||
AlfarDroneAI work = prefab.AddComponent<AlfarDroneAI>();
|
||||
work.m_fightsBack = true; // it defends itself with the zap
|
||||
work.m_homeDistance = 4f;
|
||||
}
|
||||
|
||||
PrefabManager.Instance.AddPrefab(prefab);
|
||||
Jotunn.Logger.LogInfo($"[Alfar] Registered '{prefabName}'.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No legs: the mesh is one skinned body, so the leg bones are scaled to zero and take their
|
||||
/// part of the mesh with them. The stinger has no bone of its own and is left (doc 16C P1).
|
||||
/// </summary>
|
||||
private static void HideLegs(GameObject prefab)
|
||||
{
|
||||
foreach (Transform bone in prefab.GetComponentsInChildren<Transform>(true))
|
||||
{
|
||||
string n = bone.name;
|
||||
if (n == "L.leg1" || n == "R.leg1") bone.localScale = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Look(GameObject prefab)
|
||||
{
|
||||
foreach (Renderer renderer in prefab.GetComponentsInChildren<SkinnedMeshRenderer>(true))
|
||||
{
|
||||
Material[] materials = renderer.materials;
|
||||
foreach (Material material in materials)
|
||||
{
|
||||
if (material == null) continue;
|
||||
if (material.HasProperty("_Color")) material.color = Bronze;
|
||||
if (material.HasProperty("_EmissionColor"))
|
||||
{
|
||||
material.SetColor("_EmissionColor", ElectricBlue * 0.15f);
|
||||
material.EnableKeyword("_EMISSION");
|
||||
}
|
||||
}
|
||||
renderer.materials = materials;
|
||||
}
|
||||
foreach (Light light in prefab.GetComponentsInChildren<Light>(true)) light.color = ElectricBlue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The same look, applied to the LIVE body at spawn and re-applied after the animator every
|
||||
/// frame for the bones: edits made on the registered clone may not reach the instance, and the
|
||||
/// animator can write the leg scale back.
|
||||
/// </summary>
|
||||
public class AlfarDroneLook : MonoBehaviour
|
||||
{
|
||||
private Transform[] legs;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
var list = new System.Collections.Generic.List<Transform>();
|
||||
foreach (Transform bone in GetComponentsInChildren<Transform>(true))
|
||||
{
|
||||
if (bone.name == "L.leg1" || bone.name == "R.leg1") list.Add(bone);
|
||||
}
|
||||
legs = list.ToArray();
|
||||
Look(gameObject);
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
foreach (Transform leg in legs) if (leg != null) leg.localScale = Vector3.zero;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Counting and spawning ───────────────────────────────────────────
|
||||
|
||||
public static int CountAlive(Vector3 anchor)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (AlfarDroneAI drone in AlfarDroneAI.All)
|
||||
{
|
||||
if (drone != null && drone.IsBoundTo(anchor)) count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static bool Spawn(Vector3 anchor)
|
||||
{
|
||||
GameObject prefab = ZNetScene.instance != null ? ZNetScene.instance.GetPrefab(DroneName) : null;
|
||||
if (prefab == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning($"[Alfar] No '{DroneName}' in ZNetScene: no drone can be made.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 where = AlfarConstructs.SpawnSpot(anchor) + Vector3.up * 1.5f;
|
||||
GameObject spawned = Object.Instantiate(prefab, where, Quaternion.identity);
|
||||
AlfarDroneAI work = spawned != null ? spawned.GetComponent<AlfarDroneAI>() : null;
|
||||
if (work != null) work.Bind(anchor);
|
||||
return spawned != null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A MINING DRONE: thrown to a point, it digs the precious ores around that point for a fixed time
|
||||
/// and then vanishes (design sec. 9.3). It takes over its own AI tick like the Butler's servants do
|
||||
/// (a prefix on MonsterAI.UpdateAI), flies to the nearest deposit on the list and strikes it with
|
||||
/// pickaxe damage at a tool tier high enough for any of them. The ore falls where it stands.
|
||||
///
|
||||
/// Whatever it breaks is on the list in AlfarMiner.Deposits; a name list in the config so a
|
||||
/// wrong or missing name is a config edit, not a rebuild.
|
||||
/// </summary>
|
||||
public class AlfarMiner : MonoBehaviour
|
||||
{
|
||||
public Vector3 Centre;
|
||||
public float Radius = 12f;
|
||||
public float LiveSeconds = 120f;
|
||||
|
||||
private float born;
|
||||
private float nextStrike;
|
||||
private Component target;
|
||||
|
||||
private static readonly System.Reflection.MethodInfo MoveToMethod =
|
||||
AccessTools.Method(typeof(BaseAI), "MoveTo", new[] { typeof(float), typeof(Vector3), typeof(float), typeof(bool) });
|
||||
|
||||
private void Start()
|
||||
{
|
||||
born = Time.time;
|
||||
}
|
||||
|
||||
public bool Tick(MonsterAI ai, float dt)
|
||||
{
|
||||
if (Time.time - born >= LiveSeconds)
|
||||
{
|
||||
ZNetView nview = GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid() && nview.IsOwner()) ZNetScene.instance.Destroy(gameObject);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target == null || !target.gameObject.activeInHierarchy) target = FindDeposit();
|
||||
if (target == null) { ai.StopMoving(); return true; }
|
||||
|
||||
Vector3 point = target.transform.position;
|
||||
float distance = Vector3.Distance(transform.position, point);
|
||||
|
||||
if (distance > 3.5f)
|
||||
{
|
||||
if (MoveToMethod != null) MoveToMethod.Invoke(ai, new object[] { dt, point + Vector3.up * 1.5f, 2f, true });
|
||||
return true;
|
||||
}
|
||||
|
||||
ai.StopMoving();
|
||||
if (Time.time < nextStrike) return true;
|
||||
nextStrike = Time.time + 1f;
|
||||
Strike(target);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string[] names;
|
||||
private static string[] Deposits => names ?? (names = AlfarNexusConfig.MinerDeposits.Value.Split(
|
||||
new[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries));
|
||||
|
||||
private bool IsPrecious(string prefabName)
|
||||
{
|
||||
foreach (string wanted in Deposits)
|
||||
{
|
||||
if (prefabName.IndexOf(wanted.Trim(), System.StringComparison.OrdinalIgnoreCase) >= 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Component FindDeposit()
|
||||
{
|
||||
Component best = null;
|
||||
float bestDistance = float.MaxValue;
|
||||
foreach (Collider collider in Physics.OverlapSphere(Centre, Radius, ~0, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
Component deposit = collider.GetComponentInParent<MineRock5>();
|
||||
if (deposit == null) deposit = collider.GetComponentInParent<MineRock>();
|
||||
if (deposit == null) deposit = collider.GetComponentInParent<Destructible>();
|
||||
if (deposit == null) continue;
|
||||
|
||||
string prefabName = Utils.GetPrefabName(deposit.gameObject);
|
||||
if (!IsPrecious(prefabName)) continue;
|
||||
|
||||
float distance = Vector3.Distance(transform.position, deposit.transform.position);
|
||||
if (distance < bestDistance) { best = deposit; bestDistance = distance; }
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
private void Strike(Component deposit)
|
||||
{
|
||||
IDestructible destructible = deposit as IDestructible;
|
||||
if (destructible == null) return;
|
||||
|
||||
HitData hit = new HitData();
|
||||
hit.m_damage.m_pickaxe = AlfarNexusConfig.MinerDamage.Value;
|
||||
hit.m_toolTier = 100;
|
||||
hit.m_dodgeable = false;
|
||||
hit.m_blockable = false;
|
||||
hit.m_point = deposit.transform.position;
|
||||
hit.m_dir = (deposit.transform.position - transform.position).normalized;
|
||||
|
||||
// MineRock5 picks the piece of the rock to hurt from the collider that was hit.
|
||||
Collider collider = deposit.GetComponentInChildren<Collider>();
|
||||
if (collider != null)
|
||||
{
|
||||
hit.m_hitCollider = collider;
|
||||
hit.m_point = collider.bounds.center;
|
||||
}
|
||||
|
||||
destructible.Damage(hit);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(MonsterAI), "UpdateAI")]
|
||||
public static class Alfar_Miner_UpdateAI_Patch
|
||||
{
|
||||
public static bool Prefix(MonsterAI __instance, float __0, ref bool __result)
|
||||
{
|
||||
if (__instance == null) return true;
|
||||
AlfarMiner miner = __instance.GetComponent<AlfarMiner>();
|
||||
if (miner == null) return true;
|
||||
|
||||
__result = miner.Tick(__instance, __0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
166
JotunnModStub/Alfar/AlfarEitr.cs
Normal file
166
JotunnModStub/Alfar/AlfarEitr.cs
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The Alfar's one resource (Alfar_Progettazione.txt sec. 3, 4 and 5.1): food becomes eitr, and
|
||||
/// eitr is the shield.
|
||||
///
|
||||
/// Every signature and call order here was read from assembly_valheim.dll (doc sec. 16B V1-V4),
|
||||
/// not remembered:
|
||||
/// - Character.ApplyDamage is the single final stage for direct hits, burning and poison
|
||||
/// ticks AND falls, so one prefix on it covers all three;
|
||||
/// - Player.RPC_UseEitr spends eitr and arms the vanilla regeneration delay, which is the
|
||||
/// only brake the shield has - writing m_eitr by hand would skip the delay;
|
||||
/// - Player.GetTotalFoodValue is what UpdateFood hands to SetMaxEitr.
|
||||
/// </summary>
|
||||
public static class AlfarEitr
|
||||
{
|
||||
private static readonly MethodInfo UseEitrRpc =
|
||||
AccessTools.Method(typeof(Player), "RPC_UseEitr", new[] { typeof(long), typeof(float) });
|
||||
|
||||
/// <summary>
|
||||
/// Spends eitr WITHOUT Game.m_eitrRate scaling, so the rate is exactly the configured one.
|
||||
/// UseEitr would multiply by the world modifier first; the RPC does not, and it is what
|
||||
/// arms the regeneration delay (V3).
|
||||
/// </summary>
|
||||
public static void Spend(Player player, float amount)
|
||||
{
|
||||
if (player == null || amount <= 0f) return;
|
||||
|
||||
if (UseEitrRpc == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] Player.RPC_UseEitr not found: the shield cannot spend eitr.");
|
||||
return;
|
||||
}
|
||||
UseEitrRpc.Invoke(player, new object[] { 0L, amount });
|
||||
}
|
||||
|
||||
// ─── Diet ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Each food adds min(hp, stamina) to the maximum eitr, on top of the eitr it already has.
|
||||
/// Clarified by the user: the minimum is between hp and stamina ONLY, so a plain cooked
|
||||
/// meat (40 / 30 / 0) is worth +30 eitr and a balanced food is better than a lopsided one.
|
||||
///
|
||||
/// Locally only: GetTotalFoodValue is the owner's own bookkeeping. Positional parameters
|
||||
/// (guide 5.16): __0 hp, __1 stamina, __2 eitr.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
|
||||
public static class Alfar_FoodValue_Patch
|
||||
{
|
||||
public static void Postfix(Player __instance, ref float __2)
|
||||
{
|
||||
if (__instance == null || !AlfarVisuals.IsAlfarPlayer(__instance)) return;
|
||||
|
||||
float bonus = 0f;
|
||||
foreach (Player.Food food in __instance.GetFoods())
|
||||
{
|
||||
bonus += Mathf.Min(food.m_health, food.m_stamina);
|
||||
}
|
||||
|
||||
__2 += bonus * AlfarConfig.DietMultiplier.Value;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Shield and soft fall ────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Blows land on the eitr first, 1 for 1.
|
||||
///
|
||||
/// - No cooldown: the shield absorbs for as long as one point of eitr remains.
|
||||
/// - Lightning and spirit cost double (the cost, not the damage: DamageModifier.Weak is a
|
||||
/// flat +50% and cannot be made to double anything).
|
||||
/// - A blow bigger than the pool is shared out: the eitr takes the share it can, the body
|
||||
/// takes the rest.
|
||||
/// - Drowning and the edge of the world skip the shield altogether; falls are free while
|
||||
/// there is eitr and shielded like anything else once there is none left.
|
||||
///
|
||||
/// The prefix edits the HitData and lets ApplyDamage run: with nothing left in it,
|
||||
/// ApplyDamage returns at once ("took no damage"). Positional parameters, and the argument
|
||||
/// types are in the attribute so the patch binds to the real overload (guide 5.16).
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Character), "ApplyDamage",
|
||||
new[] { typeof(HitData), typeof(bool), typeof(bool), typeof(HitData.DamageModifier) })]
|
||||
public static class Alfar_ApplyDamage_Patch
|
||||
{
|
||||
public static void Prefix(Character __instance, HitData __0)
|
||||
{
|
||||
Player player = __instance as Player;
|
||||
if (player == null || __0 == null) return;
|
||||
if (!AlfarVisuals.IsAlfarPlayer(player)) return;
|
||||
|
||||
// The shield belongs to whoever owns the body: ApplyDamage runs on the owner, and a
|
||||
// remote copy must not spend eitr it does not hold.
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview == null || !nview.IsValid() || !nview.IsOwner()) return;
|
||||
|
||||
// The same early exits ApplyDamage has: nothing to absorb, nothing to spend.
|
||||
if (player.IsDead() || player.IsTeleporting() || player.InCutscene() || player.InGodMode()) return;
|
||||
|
||||
// Just arrived by Heimkall: nothing hurts for a few seconds, or a burning death would
|
||||
// simply repeat at the bed.
|
||||
if (Time.time < AlfarHeimkall.InvulnerableUntil)
|
||||
{
|
||||
__0.m_damage = default(HitData.DamageTypes);
|
||||
return;
|
||||
}
|
||||
|
||||
// In the archon form the pool IS the defence: it takes every blow, drowning and the
|
||||
// edge of the world included, and the eitr is already spent (AlfarArchon).
|
||||
if (AlfarArchon.Active)
|
||||
{
|
||||
AlfarArchon.Absorb(player, __0);
|
||||
return;
|
||||
}
|
||||
|
||||
HitData.HitType type = __0.m_hitType;
|
||||
if (type == HitData.HitType.Drowning || type == HitData.HitType.EdgeOfWorld) return;
|
||||
|
||||
float available = player.GetEitr();
|
||||
|
||||
if (type == HitData.HitType.Fall && AlfarConfig.SoftFall.Value)
|
||||
{
|
||||
// Soft fall: free while there is eitr, a normal fall once there is none.
|
||||
if (available > 0f) __0.m_damage = default(HitData.DamageTypes);
|
||||
return;
|
||||
}
|
||||
|
||||
float cost = Cost(__0.m_damage);
|
||||
if (cost <= 0f || available <= 0f) return;
|
||||
|
||||
if (available >= cost)
|
||||
{
|
||||
Spend(player, cost);
|
||||
__0.m_damage = default(HitData.DamageTypes);
|
||||
return;
|
||||
}
|
||||
|
||||
// Shared out: the eitr absorbs the fraction it can pay for, the body takes the rest.
|
||||
float covered = available / cost;
|
||||
HitData.DamageTypes remaining = __0.m_damage;
|
||||
remaining.Modify(1f - covered);
|
||||
__0.m_damage = remaining;
|
||||
Spend(player, available);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The eitr a blow costs. Every damage type that wounds a person counts; chop and
|
||||
/// pickaxe are tool damage (trees, rocks) and do not. Lightning and spirit are doubled.
|
||||
/// </summary>
|
||||
private static float Cost(HitData.DamageTypes damage)
|
||||
{
|
||||
float rate = AlfarConfig.ShieldRate.Value;
|
||||
float conductive = AlfarConfig.ConductiveMultiplier.Value;
|
||||
|
||||
float ordinary = damage.m_damage + damage.m_blunt + damage.m_slash + damage.m_pierce +
|
||||
damage.m_fire + damage.m_frost + damage.m_poison;
|
||||
float double_ = damage.m_lightning + damage.m_spirit;
|
||||
|
||||
return (ordinary + double_ * conductive) * rate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
171
JotunnModStub/Alfar/AlfarHeimkall.cs
Normal file
171
JotunnModStub/Alfar/AlfarHeimkall.cs
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
using System.Globalization;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// HEIMKALL: a lethal blow does not kill an Alfr, it sends them to their bed with one hit point
|
||||
/// (Alfar_Progettazione.txt sec. 6). Then a wait: 20 minutes, 15 after Yagluth, 10 after Fader.
|
||||
/// Inside the wait a lethal blow kills like it does anyone.
|
||||
///
|
||||
/// HOW IT AVOIDS DEATH (read from the IL, doc sec. 16B V5):
|
||||
/// Character.ApplyDamage ends with the health at zero, and the death itself is not decided
|
||||
/// there but in Character.CheckDeath, which Character.CustomFixedUpdate calls on its next step.
|
||||
/// So a POSTFIX on ApplyDamage that puts one hit point back, the same frame, means the check
|
||||
/// finds a living body and there is no death routine, no tomb, no skill loss, no message.
|
||||
///
|
||||
/// The timer lives in m_customData as a world-time stamp, so it survives a logout.
|
||||
/// </summary>
|
||||
public static class AlfarHeimkall
|
||||
{
|
||||
private const string TimerKey = "Alfar_HeimkallAt";
|
||||
|
||||
/// <summary>Time.time until which nothing may hurt the local Alfr (the arrival grace).</summary>
|
||||
public static float InvulnerableUntil;
|
||||
|
||||
// ─── The timer ───────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>The cooldown for the current boss progress, in seconds.</summary>
|
||||
public static float CooldownSeconds()
|
||||
{
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
float minutes = state >= 8 ? AlfarConfig.HeimkallMinutesAfterFader.Value
|
||||
: state >= 6 ? AlfarConfig.HeimkallMinutesAfterYagluth.Value
|
||||
: AlfarConfig.HeimkallMinutes.Value;
|
||||
return minutes * 60f;
|
||||
}
|
||||
|
||||
/// <summary>Seconds left before the next Heimkall; 0 when it is ready.</summary>
|
||||
public static float Remaining(Player player)
|
||||
{
|
||||
if (player == null || player.m_customData == null || ZNet.instance == null) return 0f;
|
||||
if (!player.m_customData.TryGetValue(TimerKey, out string stamp)) return 0f;
|
||||
if (!double.TryParse(stamp, NumberStyles.Float, CultureInfo.InvariantCulture, out double at)) return 0f;
|
||||
|
||||
double elapsed = ZNet.instance.GetTimeSeconds() - at;
|
||||
|
||||
// A stamp from a different world (its clock is another clock) reads as the future, or as
|
||||
// a wait longer than any cooldown. Either way the timer is not this world's: ready.
|
||||
float cooldown = CooldownSeconds();
|
||||
if (elapsed < 0d || elapsed > 1e9) return 0f;
|
||||
|
||||
return Mathf.Max(0f, cooldown - (float)elapsed);
|
||||
}
|
||||
|
||||
public static bool IsReady(Player player) => Remaining(player) <= 0f;
|
||||
|
||||
public static void StartTimer(Player player)
|
||||
{
|
||||
if (player == null || ZNet.instance == null) return;
|
||||
player.m_customData[TimerKey] =
|
||||
ZNet.instance.GetTimeSeconds().ToString("R", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static void ResetTimer(Player player)
|
||||
{
|
||||
if (player != null && player.m_customData != null) player.m_customData.Remove(TimerKey);
|
||||
AlfarStatusEffects.ClearTimer("heimkall");
|
||||
}
|
||||
|
||||
private static float nextIconSync;
|
||||
|
||||
/// <summary>
|
||||
/// Keeps the on-screen Heimkall countdown honest: status effects are not saved, so after a
|
||||
/// reload the wait is put back on screen with what is really left of it, and removed when over.
|
||||
/// </summary>
|
||||
public static void SyncIcon(Player player)
|
||||
{
|
||||
if (Time.time < nextIconSync) return;
|
||||
nextIconSync = Time.time + 2f;
|
||||
|
||||
float left = Remaining(player);
|
||||
bool shown = AlfarStatusEffects.HasTimer("heimkall");
|
||||
if (left > 0f && !shown) AlfarStatusEffects.ShowTimer("heimkall", left);
|
||||
else if (left <= 0f && shown) AlfarStatusEffects.ClearTimer("heimkall");
|
||||
}
|
||||
|
||||
// ─── The call home ───────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Teleports to the bed (or the world spawn when there is none) at one hit point, clears what
|
||||
/// was killing the body, and starts the wait. Returns false when it is not ready.
|
||||
/// </summary>
|
||||
public static bool TryTrigger(Player player, string reason, bool force = false)
|
||||
{
|
||||
// force: the archon form ends with a Heimkall that it already paid for at the start.
|
||||
if (player == null || (!force && !IsReady(player))) return false;
|
||||
|
||||
bool bed;
|
||||
Vector3 destination = FindDestination(out bed);
|
||||
|
||||
// distantTeleport tells Valheim to stream the destination zone in first. Anything past a
|
||||
// couple of zone-widths needs it.
|
||||
bool distant = Vector3.Distance(player.transform.position, destination) > 100f;
|
||||
bool teleported = player.TeleportTo(destination, player.transform.rotation, distant);
|
||||
|
||||
// Whether or not the teleport was accepted (it refuses for two seconds after another
|
||||
// one), the body must not die this frame.
|
||||
player.SetHealth(1f);
|
||||
|
||||
// What was killing the body goes with it: burning, poison, the cold, being wet. Cleared
|
||||
// before the passive is put back, since RemoveAll takes that too.
|
||||
player.GetSEMan().RemoveAllStatusEffects(true);
|
||||
AlfarStatusEffects.Ensure(player);
|
||||
|
||||
InvulnerableUntil = Time.time + AlfarConfig.HeimkallInvulnerableSeconds.Value;
|
||||
StartTimer(player);
|
||||
AlfarStatusEffects.ShowTimer("heimkall", CooldownSeconds());
|
||||
|
||||
Jotunn.Logger.LogInfo($"[Alfar] Heimkall ({reason}): teleported={teleported} to {destination}; " +
|
||||
$"next in {CooldownSeconds() / 60f:0} min.");
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get(bed ? "rov_msg_alfar_heimkall" : "rov_msg_alfar_heimkall_nobed"));
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The bed the player set, else the world's original spawn. A bed point already has its height;
|
||||
/// the world spawn is stored with a placeholder height (50), so its ground is worked out from the
|
||||
/// world generator, which answers even when the zone there is not loaded yet - the first version
|
||||
/// stood the Alfr at 50.5 m in the air or inside a hill. A bed counts only after the player has
|
||||
/// SET it (sleeping in it, or interacting with it); an unused bed is not a spawn point.
|
||||
/// </summary>
|
||||
private static Vector3 FindDestination(out bool bed)
|
||||
{
|
||||
PlayerProfile profile = Game.instance != null ? Game.instance.GetPlayerProfile() : null;
|
||||
|
||||
bed = profile != null && profile.HaveCustomSpawnPoint();
|
||||
if (bed) return profile.GetCustomSpawnPoint() + Vector3.up * 0.5f;
|
||||
|
||||
Vector3 point = PlayerProfile.m_originalSpawnPoint;
|
||||
if (WorldGenerator.instance != null)
|
||||
{
|
||||
float ground = WorldGenerator.instance.GetHeight(point.x, point.z);
|
||||
point.y = Mathf.Max(ground, 30f) + 1f; // 30 is the sea level: never under the water
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
||||
// ─── The patch ───────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// After the blow has landed: if it left the body at zero, call it home instead. The shield
|
||||
/// prefix has already taken what it could, so this only fires for the blow the eitr could
|
||||
/// not cover (or a fall at eitr zero, a drowning, the edge of the world).
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Character), "ApplyDamage",
|
||||
new[] { typeof(HitData), typeof(bool), typeof(bool), typeof(HitData.DamageModifier) })]
|
||||
public static class Alfar_Heimkall_Patch
|
||||
{
|
||||
public static void Postfix(Character __instance)
|
||||
{
|
||||
Player player = __instance as Player;
|
||||
if (player == null || player != Player.m_localPlayer) return;
|
||||
if (!AlfarVisuals.IsAlfarPlayer(player)) return;
|
||||
if (player.IsDead() || player.GetHealth() > 0f) return;
|
||||
|
||||
TryTrigger(player, "lethal blow");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
JotunnModStub/Alfar/AlfarLevitation.cs
Normal file
120
JotunnModStub/Alfar/AlfarLevitation.cs
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// LEVITATION (Alfar_Progettazione.txt sec. 4.6): in the air, hold the jump key and the Alfr rises
|
||||
/// slowly, burning eitr slowly. Let go and the soft fall takes over.
|
||||
///
|
||||
/// There is no hover in vanilla. This pushes the rigidbody's vertical speed up toward a small
|
||||
/// target while the key is held, and nothing else: no horizontal speed is added, so it is a way
|
||||
/// over a ledge or out of a pit and not flight (the pool of an early Alfr lasts about half a
|
||||
/// minute of it).
|
||||
///
|
||||
/// It runs on the owner's FixedUpdate, where the rigidbody is read, and the position syncs like
|
||||
/// any other movement. The eitr is spent in small batches, not every physics step: each spend arms
|
||||
/// the regeneration delay and goes through an RPC call.
|
||||
/// </summary>
|
||||
public static class AlfarLevitation
|
||||
{
|
||||
// A short moment in the air before it starts, so a normal jump (a tap) is just a jump.
|
||||
private const float AirDelay = 0.2f;
|
||||
private const float SpendInterval = 0.25f;
|
||||
|
||||
private static float airTime;
|
||||
private static float owed;
|
||||
private static float nextSpend;
|
||||
|
||||
public static bool Rising { get; private set; }
|
||||
|
||||
[HarmonyPatch(typeof(Player), "FixedUpdate")]
|
||||
public static class Alfar_Levitation_Patch
|
||||
{
|
||||
public static void Postfix(Player __instance)
|
||||
{
|
||||
if (__instance == null || __instance != Player.m_localPlayer) return;
|
||||
if (!AlfarVisuals.IsAlfarPlayer(__instance) || __instance.IsDead()) { Reset(); return; }
|
||||
|
||||
// THE ARCHON FLIES for as long as the form lasts: it hovers where it is, climbs while
|
||||
// jump is held and sinks while crouch is held. The eitr is already gone, so nothing is
|
||||
// spent. Horizontal movement stays the normal controls.
|
||||
if (AlfarArchon.Active)
|
||||
{
|
||||
Rigidbody flyer = Traverse.Create(__instance).Field("m_body").GetValue<Rigidbody>();
|
||||
if (flyer != null)
|
||||
{
|
||||
float speed = AlfarPowerConfig.LevitationRise.Value * 2f;
|
||||
float target = 0f;
|
||||
if (Time.time - AlfarArchon.StartedAt < 0.6f) target = 4f; // lift off
|
||||
else if (RaceInput.Allowed && JumpHeld()) target = speed;
|
||||
else if (RaceInput.Allowed && ZInput.GetButton("Crouch")) target = -speed;
|
||||
|
||||
Vector3 velocity = flyer.linearVelocity;
|
||||
velocity.y = Mathf.Lerp(velocity.y, target, 0.25f);
|
||||
flyer.linearVelocity = velocity;
|
||||
}
|
||||
Traverse.Create(__instance).Field("m_maxAirAltitude").SetValue(__instance.transform.position.y);
|
||||
Rising = true;
|
||||
return;
|
||||
}
|
||||
|
||||
bool wants = RaceInput.Allowed && JumpHeld();
|
||||
bool airborne = !__instance.IsOnGround() && !__instance.IsSwimming() && !__instance.IsAttached() &&
|
||||
!__instance.IsFlying();
|
||||
|
||||
airTime = airborne ? airTime + Time.fixedDeltaTime : 0f;
|
||||
|
||||
float cost = AlfarPowerConfig.LevitationCostPerSecond.Value;
|
||||
bool canPay = AlfarArchon.Active || __instance.GetEitr() > 0f;
|
||||
|
||||
if (!wants || !airborne || airTime < AirDelay || !canPay)
|
||||
{
|
||||
Rising = false;
|
||||
FlushSpend(__instance);
|
||||
return;
|
||||
}
|
||||
|
||||
Rising = true;
|
||||
|
||||
Rigidbody body = Traverse.Create(__instance).Field("m_body").GetValue<Rigidbody>();
|
||||
if (body != null)
|
||||
{
|
||||
Vector3 velocity = body.linearVelocity;
|
||||
velocity.y = Mathf.Lerp(velocity.y, AlfarPowerConfig.LevitationRise.Value, 0.25f);
|
||||
body.linearVelocity = velocity;
|
||||
}
|
||||
|
||||
// Rising resets the fall: the point of the soft fall is that the way down starts at
|
||||
// the top, and a long climb must not count as a long drop at eitr zero.
|
||||
Traverse.Create(__instance).Field("m_maxAirAltitude").SetValue(__instance.transform.position.y);
|
||||
|
||||
// In the archon form the eitr is already gone and the pool pays for nothing here.
|
||||
if (!AlfarArchon.Active) owed += cost * Time.fixedDeltaTime;
|
||||
if (Time.time >= nextSpend) FlushSpend(__instance);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool JumpHeld()
|
||||
{
|
||||
// ZInput's "Jump" covers the space bar and the pad's jump button alike, and respects the
|
||||
// controls the player picked in the settings.
|
||||
return ZInput.GetButton("Jump");
|
||||
}
|
||||
|
||||
private static void FlushSpend(Player player)
|
||||
{
|
||||
nextSpend = Time.time + SpendInterval;
|
||||
if (owed <= 0f) return;
|
||||
AlfarEitr.Spend(player, owed);
|
||||
owed = 0f;
|
||||
}
|
||||
|
||||
private static void Reset()
|
||||
{
|
||||
airTime = 0f;
|
||||
owed = 0f;
|
||||
Rising = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
108
JotunnModStub/Alfar/AlfarLjosgard.cs
Normal file
108
JotunnModStub/Alfar/AlfarLjosgard.cs
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
using System.Collections.Generic;
|
||||
using Jotunn.Configs;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The LJOSGARD, the garden of light (Alfar_Progettazione.txt sec. 8.6 and 12): the module of the
|
||||
/// Nexus that mixes the two mushrooms of the Mistlands into SAP, very slowly.
|
||||
///
|
||||
/// It is a clone of the stone furnace with its recipe turned: MAGECAP is the "ore" and JOTUN PUFFS
|
||||
/// the "fuel", one of each per sap, so mixing the two is exactly what a smelter already does with
|
||||
/// its two inputs. Being a Smelter it needs no new code to be served: the drones feed it (a
|
||||
/// Smelter-family station) and carry the sap away, and the refinery (vanilla, sap as fuel and soft
|
||||
/// tissue as ore) is served by them too. Output falls where a furnace's does.
|
||||
/// </summary>
|
||||
public static class AlfarLjosgard
|
||||
{
|
||||
public const string PieceName = "AlfarLjosgard";
|
||||
public const string PieceDisplay = "$rov_piece_alfar_ljosgard_name";
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
GameObject source = PrefabManager.Cache.GetPrefab<GameObject>("smelter");
|
||||
ItemDrop magecap = PrefabManager.Cache.GetPrefab<ItemDrop>("MushroomMagecap");
|
||||
ItemDrop puffs = PrefabManager.Cache.GetPrefab<ItemDrop>("MushroomJotunPuffs");
|
||||
ItemDrop sap = PrefabManager.Cache.GetPrefab<ItemDrop>("Sap");
|
||||
|
||||
if (source == null || magecap == null || puffs == null || sap == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] The Ljosgard needs the 'smelter' piece and the Magecap, Jotun Puffs and Sap items: not registered.");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PieceName, source);
|
||||
if (prefab == null) return;
|
||||
|
||||
// The furnace's heat and its fire: the Ljosgard is cool to the touch (guide 5.1).
|
||||
AswidBloodRefinery.StripOffensive(prefab, "Ljosgard");
|
||||
|
||||
Smelter smelter = prefab.GetComponent<Smelter>();
|
||||
if (smelter == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] The cloned smelter has no Smelter component: no Ljosgard.");
|
||||
return;
|
||||
}
|
||||
|
||||
smelter.m_name = PieceDisplay;
|
||||
smelter.m_conversion = new List<Smelter.ItemConversion>
|
||||
{
|
||||
new Smelter.ItemConversion { m_from = magecap, m_to = sap },
|
||||
};
|
||||
smelter.m_fuelItem = puffs;
|
||||
smelter.m_fuelPerProduct = 1;
|
||||
smelter.m_maxOre = AlfarNexusConfig.GardCapacity.Value;
|
||||
smelter.m_maxFuel = AlfarNexusConfig.GardCapacity.Value;
|
||||
smelter.m_secPerProduct = AlfarNexusConfig.GardSecondsPerSap.Value;
|
||||
smelter.m_requiresRoof = false;
|
||||
smelter.m_spawnStack = false;
|
||||
smelter.m_windmill = null;
|
||||
|
||||
AlfarConstructs.Tint(prefab, new Color(0.55f, 0.85f, 0.7f, 1f));
|
||||
|
||||
Piece piece = prefab.GetComponent<Piece>();
|
||||
if (piece == null) { Jotunn.Logger.LogWarning("[Alfar] The cloned smelter has no Piece."); return; }
|
||||
|
||||
piece.m_craftingStation = null;
|
||||
piece.m_name = PieceDisplay;
|
||||
piece.m_description = "$rov_piece_alfar_ljosgard_desc";
|
||||
|
||||
PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig
|
||||
{
|
||||
Name = PieceDisplay,
|
||||
Description = "$rov_piece_alfar_ljosgard_desc",
|
||||
PieceTable = PieceTables.Hammer,
|
||||
Category = PieceCategories.Crafting,
|
||||
Icon = piece.m_icon,
|
||||
Requirements = new[]
|
||||
{
|
||||
new RequirementConfig("Bronze", AlfarNexusConfig.GardBronze.Value, 0, true),
|
||||
new RequirementConfig("MushroomJotunPuffs", AlfarNexusConfig.GardMushrooms.Value, 0, true),
|
||||
new RequirementConfig("MushroomMagecap", AlfarNexusConfig.GardMushrooms.Value, 0, true),
|
||||
},
|
||||
}));
|
||||
|
||||
// One per Ljoskjarne, inside its reach, and only for the Alfar.
|
||||
PieceDensityLimit.Register(PieceName, AlfarNexusConfig.NexusRadius.Value, 1, "rov_msg_build_limit_alfar_ljosgard");
|
||||
PieceDensityLimit.RegisterGate(PieceName, (player, position) =>
|
||||
{
|
||||
if (!AlfarRace.IsLocalAlfar())
|
||||
{
|
||||
if (player != null) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_only_alfar"));
|
||||
return false;
|
||||
}
|
||||
if (AlfarNexusBehaviour.Covering(position) == null)
|
||||
{
|
||||
if (player != null) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_gard_needs_nexus"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
AlfarPieces.Extra.Add(PieceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
149
JotunnModStub/Alfar/AlfarMark.cs
Normal file
149
JotunnModStub/Alfar/AlfarMark.cs
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// Marks a creature or a piece as one of the Alfar's own: a construct, a drone or a tower.
|
||||
///
|
||||
/// What the mark does is decided in ONE place, the patches below, instead of editing every attack
|
||||
/// of every cloned creature (Alfar_Progettazione.txt sec. 8.5 and 16C P4):
|
||||
/// - everything the marked thing deals becomes LIGHTNING, with the same total; chop and pickaxe
|
||||
/// are tool damage and are dropped;
|
||||
/// - it never hurts an ally;
|
||||
/// - it never hurts a building, a tree or a rock.
|
||||
/// Intercepting the hit covers melee, projectiles and area attacks alike, whatever the vanilla
|
||||
/// creature does with its weapons.
|
||||
/// </summary>
|
||||
public class AlfarMark : MonoBehaviour
|
||||
{
|
||||
/// <summary>"drone", "construct" or "tower": only for logs and the status command.</summary>
|
||||
public string Role = "";
|
||||
|
||||
/// <summary>The attacker's mark, or null when the hit is not from one of ours.</summary>
|
||||
public static AlfarMark Of(HitData hit)
|
||||
{
|
||||
if (hit == null) return null;
|
||||
Character attacker = hit.GetAttacker();
|
||||
return attacker != null ? attacker.GetComponent<AlfarMark>() : null;
|
||||
}
|
||||
|
||||
/// <summary>All the damage that can wound a person, moved into lightning. Chop and pickaxe go.</summary>
|
||||
public static void ConvertToLightning(HitData hit)
|
||||
{
|
||||
HitData.DamageTypes d = hit.m_damage;
|
||||
float total = d.m_damage + d.m_blunt + d.m_slash + d.m_pierce + d.m_fire + d.m_frost +
|
||||
d.m_poison + d.m_spirit + d.m_lightning;
|
||||
|
||||
HitData.DamageTypes converted = default(HitData.DamageTypes);
|
||||
converted.m_lightning = total;
|
||||
hit.m_damage = converted;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The blows of an Alfar creature: lightning only, and never on a friend.</summary>
|
||||
[HarmonyPatch(typeof(Character), "Damage")]
|
||||
public static class AlfarMark_CharacterDamage_Patch
|
||||
{
|
||||
public static bool Prefix(Character __instance, HitData __0)
|
||||
{
|
||||
AlfarMark mark = AlfarMark.Of(__0);
|
||||
if (mark == null) return true;
|
||||
|
||||
Character attacker = __0.GetAttacker();
|
||||
if (__instance == attacker) return false;
|
||||
|
||||
// Nobody on our side is ever hurt by us: players, their tames, the other constructs.
|
||||
if (!BaseAI.IsEnemy(attacker, __instance)) return false;
|
||||
|
||||
AlfarMark.ConvertToLightning(__0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Buildings, trees and rocks take nothing from the Alfar's creatures: the golem that razed its
|
||||
/// owner's base would be a bug. One prefix on every kind of thing that can be struck.
|
||||
/// </summary>
|
||||
[HarmonyPatch]
|
||||
public static class AlfarMark_StructureDamage_Patch
|
||||
{
|
||||
public static IEnumerable<MethodBase> TargetMethods()
|
||||
{
|
||||
System.Type[] types =
|
||||
{
|
||||
typeof(WearNTear), typeof(Destructible), typeof(MineRock5), typeof(MineRock),
|
||||
typeof(TreeBase), typeof(TreeLog),
|
||||
};
|
||||
|
||||
foreach (System.Type type in types)
|
||||
{
|
||||
MethodBase method = AccessTools.Method(type, "Damage", new[] { typeof(HitData) });
|
||||
if (method != null) yield return method;
|
||||
else Jotunn.Logger.LogWarning($"[Alfar] {type.Name}.Damage(HitData) not found: that structure is not protected from the Alfar's creatures.");
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Prefix(HitData __0)
|
||||
{
|
||||
return AlfarMark.Of(__0) == null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A shield equal to the creature's health that comes back by itself: 1% of it per second once it
|
||||
/// has gone five seconds without being hit (design sec. 8.5 and 9.6). Health does NOT come back:
|
||||
/// the damage to the body is permanent, which is why a construct is rebuilt and not repaired.
|
||||
///
|
||||
/// Its own absorption and not SE_Shield: the blow arrives at ApplyDamage, and what is left after
|
||||
/// the shield is what reaches the health (the same stage the Alfr's own eitr shield uses).
|
||||
/// </summary>
|
||||
public class AlfarCreatureShield : MonoBehaviour
|
||||
{
|
||||
public float MaxShield;
|
||||
public float Shield;
|
||||
public float RegenPerSecondFraction = 0.01f;
|
||||
public float QuietSeconds = 5f;
|
||||
|
||||
private float lastHit = -999f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Shield <= 0f) Shield = MaxShield;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Shield >= MaxShield || Time.time - lastHit < QuietSeconds) return;
|
||||
Shield = Mathf.Min(MaxShield, Shield + MaxShield * RegenPerSecondFraction * Time.deltaTime);
|
||||
}
|
||||
|
||||
public void Absorb(HitData hit)
|
||||
{
|
||||
float total = hit.m_damage.GetTotalDamage();
|
||||
if (total <= 0f) return;
|
||||
|
||||
lastHit = Time.time;
|
||||
float absorbed = Mathf.Min(Shield, total);
|
||||
Shield -= absorbed;
|
||||
|
||||
HitData.DamageTypes rest = hit.m_damage;
|
||||
rest.Modify((total - absorbed) / total);
|
||||
hit.m_damage = rest;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Character), "ApplyDamage",
|
||||
new[] { typeof(HitData), typeof(bool), typeof(bool), typeof(HitData.DamageModifier) })]
|
||||
public static class Alfar_CreatureShield_Patch
|
||||
{
|
||||
public static void Prefix(Character __instance, HitData __0)
|
||||
{
|
||||
if (__0 == null || __instance is Player) return;
|
||||
AlfarCreatureShield shield = __instance.GetComponent<AlfarCreatureShield>();
|
||||
if (shield != null) shield.Absorb(__0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
104
JotunnModStub/Alfar/AlfarMiners.cs
Normal file
104
JotunnModStub/Alfar/AlfarMiners.cs
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// GRAFVAETTIR, the mining grenade (Alfar_Progettazione.txt sec. 9.3): unlocked at Eikthyr, thrown
|
||||
/// like a grenade at a point; five drones dig the precious ores around it for two minutes and
|
||||
/// vanish. The ore falls where it stands, and nothing else limits it but its cost (eitr, a little
|
||||
/// stone and flint) and a five minute wait.
|
||||
///
|
||||
/// The thrown part is only the spawn; the digging is AlfarMiner on the drones themselves.
|
||||
/// </summary>
|
||||
public static class AlfarMiners
|
||||
{
|
||||
private static float readyAt;
|
||||
|
||||
public static void Tick(Player player)
|
||||
{
|
||||
// Nothing to tick per frame: the miners run themselves. Kept so the power loop treats
|
||||
// every power the same way.
|
||||
}
|
||||
|
||||
public static void Throw(Player player)
|
||||
{
|
||||
if (Time.time < readyAt) return;
|
||||
|
||||
Transform aim = GameCamera.instance != null ? GameCamera.instance.transform : player.transform;
|
||||
Vector3 origin = aim.position;
|
||||
Vector3 direction = aim.forward;
|
||||
float range = AlfarPowerConfig.GrafRange.Value;
|
||||
|
||||
Vector3 point = origin + direction * range;
|
||||
foreach (RaycastHit hit in Physics.RaycastAll(origin, direction, range, ~0, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
if (hit.collider.GetComponentInParent<Player>() == player) continue;
|
||||
if (Vector3.Distance(origin, hit.point) < Vector3.Distance(origin, point)) point = hit.point;
|
||||
}
|
||||
|
||||
// The price: a little eitr, a little stone, a little flint.
|
||||
string stone = SharedName("Stone");
|
||||
string flint = SharedName("Flint");
|
||||
int needStone = AlfarPowerConfig.GrafStone.Value;
|
||||
int needFlint = AlfarPowerConfig.GrafFlint.Value;
|
||||
float eitr = AlfarPowerConfig.GrafEitr.Value;
|
||||
|
||||
Inventory inventory = player.GetInventory();
|
||||
if (inventory.CountItems(stone, -1, false) < needStone || inventory.CountItems(flint, -1, false) < needFlint)
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_graf_materials", needStone, needFlint));
|
||||
return;
|
||||
}
|
||||
if (player.GetEitr() < eitr)
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_no_eitr"));
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject prefab = ZNetScene.instance != null ? ZNetScene.instance.GetPrefab(AlfarDrones.MinerName) : null;
|
||||
if (prefab == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning($"[Alfar] No '{AlfarDrones.MinerName}' in ZNetScene: the mining drones cannot be thrown.");
|
||||
return;
|
||||
}
|
||||
|
||||
inventory.RemoveItem(stone, needStone, -1, false);
|
||||
inventory.RemoveItem(flint, needFlint, -1, false);
|
||||
AlfarEitr.Spend(player, eitr);
|
||||
readyAt = Time.time + AlfarPowerConfig.GrafCooldown.Value;
|
||||
AlfarStatusEffects.ShowTimer("graf", AlfarPowerConfig.GrafCooldown.Value);
|
||||
|
||||
int count = AlfarPowerConfig.GrafCount.Value;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Vector2 offset = Random.insideUnitCircle * 1.5f;
|
||||
Vector3 where = point + new Vector3(offset.x, 1.5f + i * 0.2f, offset.y);
|
||||
GameObject spawned = Object.Instantiate(prefab, where, Quaternion.identity);
|
||||
|
||||
AlfarMiner miner = spawned.GetComponent<AlfarMiner>();
|
||||
if (miner != null)
|
||||
{
|
||||
miner.Centre = point;
|
||||
miner.Radius = AlfarPowerConfig.GrafRadius.Value;
|
||||
miner.LiveSeconds = AlfarPowerConfig.GrafSeconds.Value;
|
||||
}
|
||||
|
||||
// Tame at once so nothing flees them and they flee nothing; no anchor, no leash.
|
||||
MonsterAI ai = spawned.GetComponent<MonsterAI>();
|
||||
Character character = spawned.GetComponent<Character>();
|
||||
if (ai != null) ai.MakeTame();
|
||||
if (character != null) character.SetTamed(true);
|
||||
}
|
||||
|
||||
AlfarFx.Spawn("fx_JotunWitch_LightningBolt_Explosion", point);
|
||||
Jotunn.Logger.LogInfo($"[Alfar] Grafvaettir thrown: {count} at {point}.");
|
||||
}
|
||||
|
||||
private static string SharedName(string prefabName)
|
||||
{
|
||||
GameObject prefab = ObjectDB.instance != null ? ObjectDB.instance.GetItemPrefab(prefabName) : null;
|
||||
ItemDrop drop = prefab != null ? prefab.GetComponent<ItemDrop>() : null;
|
||||
return drop != null ? drop.m_itemData.m_shared.m_name : prefabName;
|
||||
}
|
||||
}
|
||||
}
|
||||
576
JotunnModStub/Alfar/AlfarNexus.cs
Normal file
576
JotunnModStub/Alfar/AlfarNexus.cs
Normal file
|
|
@ -0,0 +1,576 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using HarmonyLib;
|
||||
using Jotunn.Configs;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The LJOSKJARNE, the Alfar's Nexus (Alfar_Progettazione.txt sec. 8): the one piece the whole
|
||||
/// base hangs from. It makes the drones and the constructs, it keeps the crystals, and the towers
|
||||
/// and the drones only work inside its radius. One per 1.6 km2 like the other races' stations.
|
||||
///
|
||||
/// ONE INTERACTION POINT (guide 4.7): E opens the vanilla merchant window with a row per product
|
||||
/// (AlfarNexusStore), the way the Trol's war totem and the Dvergar's contract bank do. The first
|
||||
/// version stepped through the products with Shift+E, which gave trouble in other races' tests, and
|
||||
/// the player asked for the store. The prices are not coins: they come out of the pack, and the
|
||||
/// row's tooltip lists them with how many exist and how many are allowed.
|
||||
///
|
||||
/// Everything is paid from the player's inventory. The crystals the Nexus makes (after the
|
||||
/// Kristallvigsla) pile up inside it, a beehive's way - slowly, to a cap, and it stops when full
|
||||
/// until somebody collects - and "collect" moves them to the pack.
|
||||
/// </summary>
|
||||
public static class AlfarNexus
|
||||
{
|
||||
public const string PieceName = "AlfarNexus";
|
||||
public const string PieceDisplay = "$rov_piece_alfar_nexus_name";
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PieceName, "piece_cartographytable");
|
||||
if (prefab == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] Could not clone piece_cartographytable; the Ljoskjarne is not registered.");
|
||||
return;
|
||||
}
|
||||
|
||||
// The MapTable trap (Butler 4.1): MapTable is Interactable AND Hoverable and takes the E
|
||||
// key before our Switch sees it. Everything goes except what makes it a building.
|
||||
foreach (MonoBehaviour behaviour in prefab.GetComponentsInChildren<MonoBehaviour>(true))
|
||||
{
|
||||
if (behaviour == null) continue;
|
||||
if (behaviour is Piece || behaviour is ZNetView || behaviour is WearNTear) continue;
|
||||
Object.DestroyImmediate(behaviour);
|
||||
}
|
||||
|
||||
AlfarConstructs.Tint(prefab, new Color(0.62f, 0.8f, 1f, 1f));
|
||||
|
||||
AlfarNexusBehaviour nexus = prefab.AddComponent<AlfarNexusBehaviour>();
|
||||
nexus.m_switch = prefab.AddComponent<Switch>();
|
||||
nexus.m_switch.m_name = PieceDisplay;
|
||||
|
||||
// A Trader with an empty catalogue: StoreGui needs one to open at all, and the rows are drawn
|
||||
// by AlfarNexusStore. Disabled and with every list filled, for the reasons the Trol's totem
|
||||
// spells out (Trader.Update and Start assume an animator and a look-at rig that a nucleus
|
||||
// does not have, and an unfilled list sends Trader.Interact into a null Say).
|
||||
Trader trader = prefab.GetComponent<Trader>() ?? prefab.AddComponent<Trader>();
|
||||
trader.m_name = PieceDisplay;
|
||||
trader.enabled = false;
|
||||
trader.m_items = new List<Trader.TradeItem>();
|
||||
trader.m_useItems = new List<Trader.TraderUseItem>();
|
||||
trader.m_randomTalk = new List<string>();
|
||||
trader.m_randomGreets = new List<string>();
|
||||
trader.m_randomGoodbye = new List<string>();
|
||||
trader.m_randomStartTrade = new List<string>();
|
||||
trader.m_randomBuy = new List<string>();
|
||||
trader.m_randomSell = new List<string>();
|
||||
trader.m_randomGiveItemNo = new List<string>();
|
||||
trader.m_randomUseItemAlreadyRecieved = new List<string>();
|
||||
trader.m_randomTalkConditionals = new List<Trader.ConditionalDialog>();
|
||||
|
||||
Sprite icon = BorrowIcon("Eitr") ?? BorrowIcon("SurtlingCore");
|
||||
|
||||
Piece piece = prefab.GetComponent<Piece>() ?? prefab.AddComponent<Piece>();
|
||||
piece.m_craftingStation = null;
|
||||
piece.m_resources = new Piece.Requirement[0];
|
||||
piece.m_name = PieceDisplay;
|
||||
piece.m_canBeRemoved = true;
|
||||
piece.m_groundPiece = false;
|
||||
piece.m_groundOnly = false;
|
||||
piece.m_icon = icon;
|
||||
|
||||
Piece template = PrefabManager.Cache.GetPrefab<Piece>("piece_workbench");
|
||||
if (template != null && template.m_placeEffect != null) piece.m_placeEffect = template.m_placeEffect;
|
||||
|
||||
PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig
|
||||
{
|
||||
Name = PieceDisplay,
|
||||
Description = "$rov_piece_alfar_nexus_desc",
|
||||
PieceTable = PieceTables.Hammer,
|
||||
Category = PieceCategories.Crafting,
|
||||
Icon = icon,
|
||||
Requirements = new[]
|
||||
{
|
||||
new RequirementConfig("Bronze", AlfarNexusConfig.NexusBronze.Value, 0, true),
|
||||
new RequirementConfig("Stone", AlfarNexusConfig.NexusStone.Value, 0, true),
|
||||
},
|
||||
}));
|
||||
|
||||
PieceDensityLimit.Register(PieceName, PieceDensityLimit.RadiusForArea(AlfarNexusConfig.NexusDensityKm2.Value),
|
||||
1, "rov_msg_build_limit_alfar_nexus");
|
||||
PieceDensityLimit.RegisterGate(PieceName, (player, position) =>
|
||||
{
|
||||
if (AlfarRace.IsLocalAlfar()) return true;
|
||||
if (player != null) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_only_alfar"));
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public static Sprite BorrowIcon(string prefabName)
|
||||
{
|
||||
ItemDrop drop = PrefabManager.Cache.GetPrefab<ItemDrop>(prefabName);
|
||||
Sprite[] icons = drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null
|
||||
? drop.m_itemData.m_shared.m_icons
|
||||
: null;
|
||||
return icons != null && icons.Length > 0 ? icons[0] : null;
|
||||
}
|
||||
|
||||
/// <summary>Teaches the player the Alfar's pieces: a piece registered after the learning pass does not reach its table alone (guide 4.4).</summary>
|
||||
public static void EnsureKnown(Player player)
|
||||
{
|
||||
if (player == null || !AlfarVisuals.IsAlfarPlayer(player)) return;
|
||||
|
||||
Traverse traverse = Traverse.Create(player);
|
||||
foreach (string name in AlfarPieces.AllNames())
|
||||
{
|
||||
GameObject prefab = PrefabManager.Instance.GetPrefab(name);
|
||||
Piece piece = prefab != null ? prefab.GetComponent<Piece>() : null;
|
||||
if (piece != null) traverse.Method("AddKnownPiece", piece).GetValue();
|
||||
}
|
||||
traverse.Method("UpdateAvailablePiecesList").GetValue();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The names of every piece the Alfar can build, in one place for the lock and for learning.</summary>
|
||||
public static class AlfarPieces
|
||||
{
|
||||
public static readonly List<string> Extra = new List<string>();
|
||||
|
||||
public static IEnumerable<string> AllNames()
|
||||
{
|
||||
yield return AlfarNexus.PieceName;
|
||||
foreach (string name in Extra) yield return name;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), "OnSpawned")]
|
||||
public static class AlfarKnownPatch
|
||||
{
|
||||
public static void Postfix(Player __instance)
|
||||
{
|
||||
if (__instance != Player.m_localPlayer) return;
|
||||
AlfarNexus.EnsureKnown(__instance);
|
||||
}
|
||||
}
|
||||
|
||||
public class AlfarNexusBehaviour : MonoBehaviour
|
||||
{
|
||||
public Switch m_switch;
|
||||
|
||||
public static readonly List<AlfarNexusBehaviour> All = new List<AlfarNexusBehaviour>();
|
||||
|
||||
private const string KeySelected = "RoV_alfarSel";
|
||||
private const string KeyUpgrade = "RoV_alfarUp";
|
||||
private const string KeyCrystals = "RoV_alfarCr";
|
||||
private const string KeyCrystalAt = "RoV_alfarCrAt";
|
||||
|
||||
public enum Product { Drone = 0, Neistvordr = 1, Eldingvordr = 2, Steinvordr = 3, Upgrade = 4, Collect = 5 }
|
||||
private static readonly int ProductCount = System.Enum.GetValues(typeof(Product)).Length;
|
||||
|
||||
private ZNetView m_nview;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_nview = GetComponent<ZNetView>();
|
||||
All.Add(this);
|
||||
RaisedThrall.RegisterStation(transform);
|
||||
|
||||
if (m_switch != null)
|
||||
{
|
||||
m_switch.m_onUse = OnUse;
|
||||
m_switch.m_onHover = Hover;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
All.Remove(this);
|
||||
RaisedThrall.UnregisterStation(transform);
|
||||
}
|
||||
|
||||
/// <summary>The nearest Ljoskjarne whose radius covers the point, or null.</summary>
|
||||
public static AlfarNexusBehaviour Covering(Vector3 point)
|
||||
{
|
||||
AlfarNexusBehaviour best = null;
|
||||
float bestDistance = float.MaxValue;
|
||||
foreach (AlfarNexusBehaviour nexus in All)
|
||||
{
|
||||
if (nexus == null) continue;
|
||||
float distance = Vector3.Distance(nexus.transform.position, point);
|
||||
if (distance <= AlfarNexusConfig.NexusRadius.Value && distance < bestDistance)
|
||||
{
|
||||
best = nexus;
|
||||
bestDistance = distance;
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
// ─── State ───────────────────────────────────────────────────────────
|
||||
|
||||
private bool Upgraded => m_nview != null && m_nview.IsValid() && m_nview.GetZDO().GetInt(KeyUpgrade, 0) == 1;
|
||||
public int Crystals => m_nview != null && m_nview.IsValid() ? m_nview.GetZDO().GetInt(KeyCrystals, 0) : 0;
|
||||
|
||||
private Product Selected
|
||||
{
|
||||
get
|
||||
{
|
||||
int value = m_nview != null && m_nview.IsValid() ? m_nview.GetZDO().GetInt(KeySelected, 0) : 0;
|
||||
return (Product)Mathf.Clamp(value, 0, ProductCount - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private bool Available(Product product)
|
||||
{
|
||||
bool constructsOpen = Upgraded && BossProgressionManager.GetCurrentProgressionState() >= AlfarNexusConfig.ConstructState;
|
||||
switch (product)
|
||||
{
|
||||
case Product.Drone: return true;
|
||||
case Product.Neistvordr:
|
||||
case Product.Eldingvordr:
|
||||
case Product.Steinvordr: return constructsOpen;
|
||||
case Product.Upgrade: return !Upgraded;
|
||||
case Product.Collect: return Upgraded;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ─── Crystals: a beehive's way ───────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// One crystal per Time Factor beehive-intervals of WORLD time, up to the cap, and nothing while
|
||||
/// full: the clock restarts when somebody collects, like the honey. Only the owner counts.
|
||||
/// The beehive's own interval is read, not copied (guide 3.2) - and only the INTERVAL, not its
|
||||
/// daylight rule: the Alfar have no light mechanic (doc sec. 8.6).
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner() || !Upgraded || ZNet.instance == null) return;
|
||||
|
||||
ZDO zdo = m_nview.GetZDO();
|
||||
int cap = AlfarNexusConfig.CrystalCap.Value;
|
||||
int stored = zdo.GetInt(KeyCrystals, 0);
|
||||
double now = ZNet.instance.GetTimeSeconds();
|
||||
|
||||
if (stored >= cap) { zdo.Set(KeyCrystalAt, now.ToString("R", System.Globalization.CultureInfo.InvariantCulture)); return; }
|
||||
|
||||
string stamp = zdo.GetString(KeyCrystalAt, "");
|
||||
if (!double.TryParse(stamp, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out double at))
|
||||
{
|
||||
zdo.Set(KeyCrystalAt, now.ToString("R", System.Globalization.CultureInfo.InvariantCulture));
|
||||
return;
|
||||
}
|
||||
|
||||
float interval = CrystalInterval();
|
||||
int made = Mathf.FloorToInt((float)((now - at) / interval));
|
||||
if (made <= 0) return;
|
||||
|
||||
stored = Mathf.Min(cap, stored + made);
|
||||
zdo.Set(KeyCrystals, stored);
|
||||
zdo.Set(KeyCrystalAt, (at + made * interval).ToString("R", System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
/// <summary>Seconds per crystal: Time Factor times a vanilla beehive's seconds per honey.</summary>
|
||||
public static float CrystalInterval()
|
||||
{
|
||||
Beehive hive = TrentaConfig.FindVanillaBeehive();
|
||||
float honey = hive != null && hive.m_secPerUnit > 0f ? hive.m_secPerUnit : 1200f;
|
||||
return honey * AlfarNexusConfig.CrystalTimeFactor.Value;
|
||||
}
|
||||
|
||||
// ─── Costs ───────────────────────────────────────────────────────────
|
||||
|
||||
private struct Cost
|
||||
{
|
||||
public string Item;
|
||||
public int Amount;
|
||||
public Cost(string item, int amount) { Item = item; Amount = amount; }
|
||||
}
|
||||
|
||||
private static List<Cost> CostOf(Product product)
|
||||
{
|
||||
switch (product)
|
||||
{
|
||||
case Product.Drone:
|
||||
return new List<Cost> { new Cost("Bronze", AlfarNexusConfig.DroneBronze.Value) };
|
||||
case Product.Neistvordr:
|
||||
return new List<Cost>
|
||||
{
|
||||
new Cost("Bronze", AlfarNexusConfig.NeistMetal.Value),
|
||||
new Cost("Crystal", AlfarNexusConfig.NeistCrystal.Value),
|
||||
new Cost("Eitr", AlfarNexusConfig.NeistEitr.Value),
|
||||
};
|
||||
case Product.Eldingvordr:
|
||||
return new List<Cost>
|
||||
{
|
||||
new Cost("Iron", AlfarNexusConfig.EldingMetal.Value),
|
||||
new Cost("Crystal", AlfarNexusConfig.EldingCrystal.Value),
|
||||
new Cost("Eitr", AlfarNexusConfig.EldingEitr.Value),
|
||||
};
|
||||
case Product.Steinvordr:
|
||||
return new List<Cost>
|
||||
{
|
||||
new Cost("BlackMetal", AlfarNexusConfig.SteinMetal.Value),
|
||||
new Cost("Crystal", AlfarNexusConfig.SteinCrystal.Value),
|
||||
new Cost("Eitr", AlfarNexusConfig.SteinEitr.Value),
|
||||
};
|
||||
case Product.Upgrade:
|
||||
return new List<Cost> { new Cost("Crystal", AlfarNexusConfig.UpgradeCrystals.Value) };
|
||||
}
|
||||
return new List<Cost>();
|
||||
}
|
||||
|
||||
private static string SharedName(string prefabName)
|
||||
{
|
||||
GameObject prefab = ObjectDB.instance != null ? ObjectDB.instance.GetItemPrefab(prefabName) : null;
|
||||
ItemDrop drop = prefab != null ? prefab.GetComponent<ItemDrop>() : null;
|
||||
return drop != null ? drop.m_itemData.m_shared.m_name : prefabName;
|
||||
}
|
||||
|
||||
private static bool CanPay(Player player, List<Cost> costs)
|
||||
{
|
||||
foreach (Cost cost in costs)
|
||||
{
|
||||
if (cost.Amount <= 0) continue;
|
||||
if (player.GetInventory().CountItems(SharedName(cost.Item), -1, false) < cost.Amount) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void Pay(Player player, List<Cost> costs)
|
||||
{
|
||||
foreach (Cost cost in costs)
|
||||
{
|
||||
if (cost.Amount > 0) player.GetInventory().RemoveItem(SharedName(cost.Item), cost.Amount, -1, false);
|
||||
}
|
||||
}
|
||||
|
||||
private static string CostText(List<Cost> costs)
|
||||
{
|
||||
var parts = new List<string>();
|
||||
foreach (Cost cost in costs)
|
||||
{
|
||||
if (cost.Amount > 0) parts.Add($"{cost.Amount} {Localization.instance.Localize(SharedName(cost.Item))}");
|
||||
}
|
||||
return parts.Count == 0 ? "-" : string.Join(", ", parts);
|
||||
}
|
||||
|
||||
// ─── Counts and caps ─────────────────────────────────────────────────
|
||||
|
||||
private int AliveOf(Product product)
|
||||
{
|
||||
Vector3 anchor = transform.position;
|
||||
switch (product)
|
||||
{
|
||||
case Product.Drone: return AlfarDrones.CountAlive(anchor);
|
||||
case Product.Neistvordr: return AlfarConstructs.CountAlive(anchor, AlfarConstructs.Neistvordr);
|
||||
case Product.Eldingvordr: return AlfarConstructs.CountAlive(anchor, AlfarConstructs.Eldingvordr);
|
||||
case Product.Steinvordr: return AlfarConstructs.CountAlive(anchor, AlfarConstructs.Steinvordr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static int CapOf(Product product)
|
||||
{
|
||||
switch (product)
|
||||
{
|
||||
case Product.Drone: return AlfarNexusConfig.DroneCap.Value;
|
||||
case Product.Neistvordr: return AlfarNexusConfig.NeistCap.Value;
|
||||
case Product.Eldingvordr: return AlfarNexusConfig.EldingCap.Value;
|
||||
case Product.Steinvordr: return AlfarNexusConfig.SteinCap.Value;
|
||||
}
|
||||
return int.MaxValue;
|
||||
}
|
||||
|
||||
private static string NameOf(Product product) => ModText.Get("rov_alfar_product_" + product.ToString().ToLowerInvariant());
|
||||
|
||||
// ─── Interaction ─────────────────────────────────────────────────────
|
||||
|
||||
private string Hover()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine(Localization.instance.Localize(AlfarNexus.PieceDisplay));
|
||||
sb.AppendLine($"[<color=yellow><b>$KEY_Use</b></color>] {ModText.Get("rov_alfar_nexus_open")}");
|
||||
|
||||
if (Upgraded) sb.AppendLine(ModText.Get("rov_alfar_nexus_crystals", Crystals, AlfarNexusConfig.CrystalCap.Value));
|
||||
else sb.AppendLine(ModText.Get("rov_alfar_nexus_no_upgrade"));
|
||||
|
||||
return Localization.instance.Localize(sb.ToString());
|
||||
}
|
||||
|
||||
private bool OnUse(Switch sw, Humanoid user, ItemDrop.ItemData item)
|
||||
{
|
||||
Player player = user as Player;
|
||||
if (player == null || m_nview == null || !m_nview.IsValid()) return false;
|
||||
|
||||
if (!AlfarVisuals.IsAlfarPlayer(player))
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_only_alfar"));
|
||||
return item != null;
|
||||
}
|
||||
|
||||
// Holding something is not a way to use the nucleus: it only opens the store.
|
||||
if (item != null)
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, "$msg_wontwork");
|
||||
return true;
|
||||
}
|
||||
|
||||
Trader trader = GetComponent<Trader>();
|
||||
if (trader == null || StoreGui.instance == null)
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_nexus_no_store"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// The store reads the nucleus back out of StoreGui's own m_trader when it repaints.
|
||||
StoreGui.instance.Show(trader);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ─── What the store window uses ──────────────────────────────────────
|
||||
|
||||
/// <summary>The products on offer right now, in the order the rows are drawn.</summary>
|
||||
public List<Product> OnOffer()
|
||||
{
|
||||
var list = new List<Product>();
|
||||
foreach (Product product in System.Enum.GetValues(typeof(Product)))
|
||||
{
|
||||
if (Available(product)) list.Add(product);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>Builds a product from the row the player clicked. Every check Build makes still applies.</summary>
|
||||
public void BuildFromStore(Product product)
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
if (player == null || m_nview == null || !m_nview.IsValid() || !Available(product)) return;
|
||||
|
||||
m_nview.ClaimOwnership();
|
||||
Build(player, product);
|
||||
}
|
||||
|
||||
/// <summary>The short number on a row: the metal (or the crystals of the upgrade) it costs.</summary>
|
||||
public static string PriceShort(Product product)
|
||||
{
|
||||
foreach (Cost cost in CostOf(product))
|
||||
{
|
||||
if (cost.Amount > 0) return cost.Amount.ToString();
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
|
||||
/// <summary>The full terms for the row's tooltip: the price, how many exist, how many are allowed.</summary>
|
||||
public string Terms(Product product)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine(CostText(CostOf(product)));
|
||||
|
||||
int cap = CapOf(product);
|
||||
if (cap != int.MaxValue) sb.AppendLine(ModText.Get("rov_alfar_store_count", AliveOf(product), cap));
|
||||
if (product == Product.Collect) sb.AppendLine(ModText.Get("rov_alfar_nexus_crystals", Crystals, AlfarNexusConfig.CrystalCap.Value));
|
||||
|
||||
sb.Append(ModText.Get("rov_alfar_store_terms"));
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string ProductName(Product product) => NameOf(product);
|
||||
|
||||
private void Build(Player player, Product product)
|
||||
{
|
||||
List<Cost> costs = CostOf(product);
|
||||
|
||||
if (product == Product.Collect)
|
||||
{
|
||||
Collect(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (AliveOf(product) >= CapOf(product))
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_nexus_cap"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CanPay(player, costs))
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_nexus_cannot_pay", CostText(costs)));
|
||||
return;
|
||||
}
|
||||
|
||||
bool done;
|
||||
switch (product)
|
||||
{
|
||||
case Product.Drone: done = AlfarDrones.Spawn(transform.position); break;
|
||||
case Product.Neistvordr: done = AlfarConstructs.Spawn(transform.position, AlfarConstructs.Neistvordr); break;
|
||||
case Product.Eldingvordr: done = AlfarConstructs.Spawn(transform.position, AlfarConstructs.Eldingvordr); break;
|
||||
case Product.Steinvordr: done = AlfarConstructs.Spawn(transform.position, AlfarConstructs.Steinvordr); break;
|
||||
case Product.Upgrade: done = true; break;
|
||||
default: done = false; break;
|
||||
}
|
||||
if (!done) return;
|
||||
|
||||
Pay(player, costs);
|
||||
|
||||
if (product == Product.Upgrade)
|
||||
{
|
||||
ZDO zdo = m_nview.GetZDO();
|
||||
zdo.Set(KeyUpgrade, 1);
|
||||
zdo.Set(KeyCrystalAt, ZNet.instance.GetTimeSeconds().ToString("R", System.Globalization.CultureInfo.InvariantCulture));
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_nexus_upgraded"));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_nexus_built", NameOf(product)));
|
||||
}
|
||||
}
|
||||
|
||||
private void Collect(Player player)
|
||||
{
|
||||
int stored = Crystals;
|
||||
if (stored <= 0)
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_nexus_no_crystals"));
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject prefab = ObjectDB.instance != null ? ObjectDB.instance.GetItemPrefab("Crystal") : null;
|
||||
if (prefab == null) return;
|
||||
|
||||
// Whatever fits goes in the pack; the rest stays in the Nexus.
|
||||
int taken = 0;
|
||||
for (int i = 0; i < stored; i++)
|
||||
{
|
||||
if (!player.GetInventory().CanAddItem(prefab, 1)) break;
|
||||
if (!player.GetInventory().AddItem(prefab, 1)) break;
|
||||
taken++;
|
||||
}
|
||||
|
||||
if (taken > 0)
|
||||
{
|
||||
ZDO zdo = m_nview.GetZDO();
|
||||
zdo.Set(KeyCrystals, stored - taken);
|
||||
// Collecting restarts the clock, like emptying a hive.
|
||||
zdo.Set(KeyCrystalAt, ZNet.instance.GetTimeSeconds().ToString("R", System.Globalization.CultureInfo.InvariantCulture));
|
||||
}
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_nexus_collected", taken));
|
||||
}
|
||||
|
||||
/// <summary>Crystals a drone may carry away from the Nexus, and the call that does it (used by the drone's work).</summary>
|
||||
public int TakeCrystals(int wanted)
|
||||
{
|
||||
if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner()) return 0;
|
||||
int stored = Crystals;
|
||||
int taken = Mathf.Min(stored, wanted);
|
||||
if (taken <= 0) return 0;
|
||||
ZDO zdo = m_nview.GetZDO();
|
||||
zdo.Set(KeyCrystals, stored - taken);
|
||||
zdo.Set(KeyCrystalAt, ZNet.instance.GetTimeSeconds().ToString("R", System.Globalization.CultureInfo.InvariantCulture));
|
||||
return taken;
|
||||
}
|
||||
}
|
||||
}
|
||||
144
JotunnModStub/Alfar/AlfarNexusConfig.cs
Normal file
144
JotunnModStub/Alfar/AlfarNexusConfig.cs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
using BepInEx.Configuration;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The numbers of the Alfar's base: the Nexus, its drones, the constructs, the towers and the
|
||||
/// crystals (Alfar_Progettazione.txt sec. 8, 9 and 19). All starting values, all to be corrected
|
||||
/// in play, none in the logic files.
|
||||
/// </summary>
|
||||
public static class AlfarNexusConfig
|
||||
{
|
||||
// The progression state the constructs open at (BossProgressionManager: 6 = Yagluth down).
|
||||
public const int ConstructState = 6;
|
||||
|
||||
// ─── The Nexus ───────────────────────────────────────────────────────
|
||||
public static ConfigEntry<float> NexusRadius;
|
||||
public static ConfigEntry<float> NexusDensityKm2;
|
||||
public static ConfigEntry<int> NexusBronze;
|
||||
public static ConfigEntry<int> NexusStone;
|
||||
|
||||
// ─── Drones ──────────────────────────────────────────────────────────
|
||||
public static ConfigEntry<int> DroneBronze;
|
||||
public static ConfigEntry<int> DroneCap;
|
||||
public static ConfigEntry<float> DroneHealth;
|
||||
public static ConfigEntry<float> DroneZapDamage;
|
||||
public static ConfigEntry<float> DroneZapInterval;
|
||||
|
||||
// ─── Mining drones ───────────────────────────────────────────────────
|
||||
public static ConfigEntry<string> MinerDeposits;
|
||||
public static ConfigEntry<float> MinerDamage;
|
||||
public static ConfigEntry<string> WildPickables;
|
||||
|
||||
// ─── Constructs ──────────────────────────────────────────────────────
|
||||
public static ConfigEntry<int> NeistMetal;
|
||||
public static ConfigEntry<int> NeistCrystal;
|
||||
public static ConfigEntry<int> NeistEitr;
|
||||
public static ConfigEntry<int> NeistCap;
|
||||
|
||||
public static ConfigEntry<int> EldingMetal;
|
||||
public static ConfigEntry<int> EldingCrystal;
|
||||
public static ConfigEntry<int> EldingEitr;
|
||||
public static ConfigEntry<int> EldingCap;
|
||||
|
||||
public static ConfigEntry<int> SteinMetal;
|
||||
public static ConfigEntry<int> SteinCrystal;
|
||||
public static ConfigEntry<int> SteinEitr;
|
||||
public static ConfigEntry<int> SteinCap;
|
||||
|
||||
public static ConfigEntry<float> ConstructLeash;
|
||||
public static ConfigEntry<float> ConstructAlertRange;
|
||||
public static ConfigEntry<float> WitherSeconds;
|
||||
|
||||
public static ConfigEntry<float> SphereDamage;
|
||||
public static ConfigEntry<float> SphereIntervalSeconds;
|
||||
public static ConfigEntry<float> SphereRange;
|
||||
|
||||
// ─── Crystals ────────────────────────────────────────────────────────
|
||||
public static ConfigEntry<int> UpgradeCrystals;
|
||||
public static ConfigEntry<int> CrystalCap;
|
||||
public static ConfigEntry<float> CrystalTimeFactor;
|
||||
|
||||
// ─── Towers ──────────────────────────────────────────────────────────
|
||||
public static ConfigEntry<int> TowerBronze;
|
||||
public static ConfigEntry<int> TowerCrystal;
|
||||
public static ConfigEntry<float> TowerHealthFactor;
|
||||
public static ConfigEntry<float> TowerDamage;
|
||||
public static ConfigEntry<float> TowerScale;
|
||||
|
||||
// ─── Ljosgard (sap) and chests ───────────────────────────────────────
|
||||
public static ConfigEntry<int> GardBronze;
|
||||
public static ConfigEntry<int> GardMushrooms;
|
||||
public static ConfigEntry<float> GardSecondsPerSap;
|
||||
public static ConfigEntry<int> GardCapacity;
|
||||
public static ConfigEntry<int> ChestEyes;
|
||||
|
||||
public static void Bind(ConfigFile config)
|
||||
{
|
||||
const string nexus = "Alfar - Nexus";
|
||||
NexusRadius = config.Bind(nexus, "Radius", 40f, new ConfigDescription("Metres around a Ljoskjarne where its drones work and its towers run.", new AcceptableValueRange<float>(10f, 150f)));
|
||||
NexusDensityKm2 = config.Bind(nexus, "Density Km2", 1.6f, new ConfigDescription("At most one Ljoskjarne per this many square kilometres.", new AcceptableValueRange<float>(0.1f, 20f)));
|
||||
NexusBronze = config.Bind(nexus, "Bronze Cost", 40, new ConfigDescription("Bronze to build a Ljoskjarne.", new AcceptableValueRange<int>(0, 500)));
|
||||
NexusStone = config.Bind(nexus, "Stone Cost", 30, new ConfigDescription("Stone to build a Ljoskjarne.", new AcceptableValueRange<int>(0, 500)));
|
||||
|
||||
const string drone = "Alfar - Drones";
|
||||
DroneBronze = config.Bind(drone, "Bronze Cost", 8, new ConfigDescription("Bronze for each Ljosvaettir.", new AcceptableValueRange<int>(0, 200)));
|
||||
DroneCap = config.Bind(drone, "Cap Per Nexus", 6, new ConfigDescription("Most drones one Ljoskjarne keeps.", new AcceptableValueRange<int>(0, 50)));
|
||||
DroneHealth = config.Bind(drone, "Health", 25f, new ConfigDescription("A drone's health and shield (a Deathsquito has 10).", new AcceptableValueRange<float>(1f, 1000f)));
|
||||
DroneZapDamage = config.Bind(drone, "Zap Damage", 1f, new ConfigDescription("Lightning damage of a drone's defensive zap.", new AcceptableValueRange<float>(0f, 100f)));
|
||||
DroneZapInterval = config.Bind(drone, "Zap Interval", 2f, new ConfigDescription("Seconds between a drone's zaps.", new AcceptableValueRange<float>(0.2f, 30f)));
|
||||
|
||||
MinerDeposits = config.Bind(drone, "Mining Targets", "MineRock_Copper,MineRock_Tin,MineRock_Iron,silvervein,rock3_silver,giant_brain",
|
||||
new ConfigDescription("Comma separated parts of prefab names the mining drones dig (case does not matter). Soft tissue comes from giant_brain."));
|
||||
MinerDamage = config.Bind(drone, "Mining Damage", 40f, new ConfigDescription("Pickaxe damage each mining drone does per second to a deposit.", new AcceptableValueRange<float>(1f, 1000f)));
|
||||
|
||||
WildPickables = config.Bind(drone, "Wild Plants Harvested", "Pickable_Mushroom,Pickable_Dandelion,Pickable_Thistle,RaspberryBush,BlueberryBush,CloudberryBush",
|
||||
new ConfigDescription("Comma separated parts of prefab names of WILD plants the drones pick without replanting (mushrooms, berry bushes, flowers). Trees are never touched. Cultivated crops are always replanted."));
|
||||
|
||||
const string construct = "Alfar - Constructs";
|
||||
NeistMetal = config.Bind(construct, "Neistvordr Bronze", 20, new ConfigDescription("Bronze for a Neistvordr.", new AcceptableValueRange<int>(0, 500)));
|
||||
NeistCrystal = config.Bind(construct, "Neistvordr Crystal", 3, new ConfigDescription("Crystals for a Neistvordr.", new AcceptableValueRange<int>(0, 50)));
|
||||
NeistEitr = config.Bind(construct, "Neistvordr Refined Eitr", 3, new ConfigDescription("Refined eitr for a Neistvordr.", new AcceptableValueRange<int>(0, 50)));
|
||||
NeistCap = config.Bind(construct, "Neistvordr Cap", 4, new ConfigDescription("Most Neistvordr one Ljoskjarne keeps.", new AcceptableValueRange<int>(0, 50)));
|
||||
|
||||
EldingMetal = config.Bind(construct, "Eldingvordr Iron", 20, new ConfigDescription("Iron for an Eldingvordr.", new AcceptableValueRange<int>(0, 500)));
|
||||
EldingCrystal = config.Bind(construct, "Eldingvordr Crystal", 5, new ConfigDescription("Crystals for an Eldingvordr.", new AcceptableValueRange<int>(0, 50)));
|
||||
EldingEitr = config.Bind(construct, "Eldingvordr Refined Eitr", 4, new ConfigDescription("Refined eitr for an Eldingvordr.", new AcceptableValueRange<int>(0, 50)));
|
||||
EldingCap = config.Bind(construct, "Eldingvordr Cap", 4, new ConfigDescription("Most Eldingvordr one Ljoskjarne keeps.", new AcceptableValueRange<int>(0, 50)));
|
||||
|
||||
SteinMetal = config.Bind(construct, "Steinvordr Black Metal", 20, new ConfigDescription("Black metal for a Steinvordr.", new AcceptableValueRange<int>(0, 500)));
|
||||
SteinCrystal = config.Bind(construct, "Steinvordr Crystal", 8, new ConfigDescription("Crystals for a Steinvordr.", new AcceptableValueRange<int>(0, 50)));
|
||||
SteinEitr = config.Bind(construct, "Steinvordr Refined Eitr", 6, new ConfigDescription("Refined eitr for a Steinvordr.", new AcceptableValueRange<int>(0, 50)));
|
||||
SteinCap = config.Bind(construct, "Steinvordr Cap", 1, new ConfigDescription("Most Steinvordr one Ljoskjarne keeps.", new AcceptableValueRange<int>(0, 50)));
|
||||
|
||||
ConstructLeash = config.Bind(construct, "Leash Range", 12f, new ConfigDescription("How far a construct wanders from its Ljoskjarne when not following.", new AcceptableValueRange<float>(2f, 80f)));
|
||||
ConstructAlertRange = config.Bind(construct, "Alert Range", 25f, new ConfigDescription("How far a construct notices and chases enemies.", new AcceptableValueRange<float>(5f, 100f)));
|
||||
WitherSeconds = config.Bind(construct, "Wither Seconds", 60f, new ConfigDescription("How long creatures last after their Ljoskjarne falls.", new AcceptableValueRange<float>(0f, 600f)));
|
||||
|
||||
SphereDamage = config.Bind(construct, "Sphere Damage", 80f, new ConfigDescription("Lightning damage of the Eldingvordr's sphere.", new AcceptableValueRange<float>(1f, 1000f)));
|
||||
SphereIntervalSeconds = config.Bind(construct, "Sphere Interval", 8f, new ConfigDescription("Seconds between the Eldingvordr's shots.", new AcceptableValueRange<float>(0.5f, 60f)));
|
||||
SphereRange = config.Bind(construct, "Sphere Range", 30f, new ConfigDescription("How far the Eldingvordr shoots.", new AcceptableValueRange<float>(5f, 80f)));
|
||||
|
||||
const string crystal = "Alfar - Crystals";
|
||||
UpgradeCrystals = config.Bind(crystal, "Upgrade Cost", 20, new ConfigDescription("Crystals the player must find for the Kristallvigsla.", new AcceptableValueRange<int>(0, 200)));
|
||||
CrystalCap = config.Bind(crystal, "Stored Cap", 20, new ConfigDescription("Most crystals the Ljoskjarne holds before it stops making them.", new AcceptableValueRange<int>(1, 200)));
|
||||
CrystalTimeFactor = config.Bind(crystal, "Time Factor", 2f, new ConfigDescription("A crystal takes this many times a vanilla beehive's time for one honey.", new AcceptableValueRange<float>(0.1f, 20f)));
|
||||
|
||||
const string tower = "Alfar - Towers";
|
||||
TowerBronze = config.Bind(tower, "Bronze Cost", 25, new ConfigDescription("Bronze for a Prismavard.", new AcceptableValueRange<int>(0, 500)));
|
||||
TowerCrystal = config.Bind(tower, "Crystal Cost", 2, new ConfigDescription("Crystals for a Prismavard.", new AcceptableValueRange<int>(0, 50)));
|
||||
TowerHealthFactor = config.Bind(tower, "Health Factor", 0.5f, new ConfigDescription("A Prismavard's health against the charred ballista's 400.", new AcceptableValueRange<float>(0.05f, 3f)));
|
||||
TowerDamage = config.Bind(tower, "Bolt Damage", 40f, new ConfigDescription("Lightning damage of a Prismavard's bolt.", new AcceptableValueRange<float>(1f, 1000f)));
|
||||
TowerScale = config.Bind(tower, "Scale", 0.6f, new ConfigDescription("Size of a Prismavard against the charred ballista.", new AcceptableValueRange<float>(0.2f, 2f)));
|
||||
|
||||
const string gard = "Alfar - Ljosgard";
|
||||
GardBronze = config.Bind(gard, "Bronze Cost", 40, new ConfigDescription("Bronze for a Ljosgard.", new AcceptableValueRange<int>(0, 500)));
|
||||
GardMushrooms = config.Bind(gard, "Mushrooms Cost", 10, new ConfigDescription("Jotun Puffs AND Magecap, this many of each, to build a Ljosgard.", new AcceptableValueRange<int>(0, 100)));
|
||||
GardSecondsPerSap = config.Bind(gard, "Seconds Per Sap", 600f, new ConfigDescription("Seconds to turn one Jotun Puffs and one Magecap into a Sap.", new AcceptableValueRange<float>(10f, 7200f)));
|
||||
GardCapacity = config.Bind(gard, "Sap Capacity", 10, new ConfigDescription("Sap the Ljosgard holds before it stops.", new AcceptableValueRange<int>(1, 200)));
|
||||
|
||||
ChestEyes = config.Bind(gard, "Chest Greydwarf Eyes", 3, new ConfigDescription("Greydwarf eyes in the price of the entry chest and the wood chest.", new AcceptableValueRange<int>(0, 50)));
|
||||
}
|
||||
}
|
||||
}
|
||||
171
JotunnModStub/Alfar/AlfarNexusStore.cs
Normal file
171
JotunnModStub/Alfar/AlfarNexusStore.cs
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The Ljoskjarne's window: the merchant's own store with a column of products in it - the drone,
|
||||
/// the three constructs, the crystal upgrade, and the crystals to collect.
|
||||
///
|
||||
/// It is the Trol war totem's window (TrolTotemStore) cloned for another trader, and for the same
|
||||
/// reasons: same three patch points (Awake to build, FillList to repaint, Hide to clear), same trick
|
||||
/// of instantiating StoreGui.m_listElement for the rows. The empty-catalogue guard that keeps vanilla
|
||||
/// FillList from throwing is already on every trader with no wares (StoreGuiEmptyCatalogueGuardPatch),
|
||||
/// so this one needs none of its own.
|
||||
///
|
||||
/// What is different from the totem: a row's price is a number out of the pack and not coins, so the
|
||||
/// short figure on the row is the metal or the crystals, and the tooltip carries the whole price.
|
||||
/// </summary>
|
||||
public static class AlfarNexusStore
|
||||
{
|
||||
private static RectTransform _list;
|
||||
private static readonly List<GameObject> _rows = new List<GameObject>();
|
||||
|
||||
public static AlfarNexusBehaviour ActiveNexus(StoreGui gui)
|
||||
{
|
||||
Trader trader = FactionMerchantRuntime.GetActiveTrader(gui);
|
||||
return trader != null ? trader.GetComponent<AlfarNexusBehaviour>() : null;
|
||||
}
|
||||
|
||||
// ─── build ───────────────────────────────────────────────────────────
|
||||
|
||||
public static void Create(StoreGui gui)
|
||||
{
|
||||
if (gui == null || gui.m_listRoot == null || _list != null) return;
|
||||
|
||||
GameObject clone = Object.Instantiate(gui.m_listRoot.gameObject, gui.m_listRoot.parent);
|
||||
clone.name = "AlfarProductList";
|
||||
_list = clone.GetComponent<RectTransform>();
|
||||
_list.anchoredPosition = gui.m_listRoot.anchoredPosition;
|
||||
|
||||
// The clone carries whatever rows the vanilla list held at Awake: it starts empty.
|
||||
foreach (Transform child in _list) Object.Destroy(child.gameObject);
|
||||
_list.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public static void Clear()
|
||||
{
|
||||
foreach (GameObject row in _rows) if (row != null) Object.Destroy(row);
|
||||
_rows.Clear();
|
||||
if (_list != null) _list.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// ─── fill ────────────────────────────────────────────────────────────
|
||||
|
||||
public static void Refresh(StoreGui gui)
|
||||
{
|
||||
Clear();
|
||||
|
||||
AlfarNexusBehaviour nexus = ActiveNexus(gui);
|
||||
if (nexus == null) return; // an ordinary merchant: not ours
|
||||
|
||||
if (_list == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] The Ljoskjarne's column was never built (did the patch on StoreGui.Awake fail?).");
|
||||
return;
|
||||
}
|
||||
|
||||
_list.gameObject.SetActive(true);
|
||||
|
||||
int row = 0;
|
||||
foreach (AlfarNexusBehaviour.Product product in nexus.OnOffer())
|
||||
{
|
||||
BuildRow(gui, nexus, product, row++);
|
||||
}
|
||||
|
||||
float baseSize = Traverse.Create(gui).Field("m_itemlistBaseSize").GetValue<float>();
|
||||
_list.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Mathf.Max(baseSize, row * gui.m_itemSpacing));
|
||||
}
|
||||
|
||||
private static string IconOf(AlfarNexusBehaviour.Product product)
|
||||
{
|
||||
switch (product)
|
||||
{
|
||||
case AlfarNexusBehaviour.Product.Drone: return "TrophyDeathsquito";
|
||||
case AlfarNexusBehaviour.Product.Neistvordr: return "TrophySurtling";
|
||||
case AlfarNexusBehaviour.Product.Eldingvordr: return "TrophyAbomination";
|
||||
case AlfarNexusBehaviour.Product.Steinvordr: return "TrophySGolem";
|
||||
default: return "Crystal";
|
||||
}
|
||||
}
|
||||
|
||||
private static void BuildRow(StoreGui gui, AlfarNexusBehaviour nexus, AlfarNexusBehaviour.Product product, int rowIndex)
|
||||
{
|
||||
GameObject element = Object.Instantiate(gui.m_listElement, _list);
|
||||
element.SetActive(true);
|
||||
|
||||
RectTransform rt = (RectTransform)element.transform;
|
||||
float offset = (_list.rect.width - rt.rect.width) / 2f;
|
||||
rt.anchoredPosition = new Vector2(offset, rowIndex * -gui.m_itemSpacing - offset);
|
||||
|
||||
Sprite icon = Icon(IconOf(product));
|
||||
Image iconImage = element.transform.Find("icon").GetComponent<Image>();
|
||||
if (icon != null) iconImage.sprite = icon;
|
||||
|
||||
string name = AlfarNexusBehaviour.ProductName(product);
|
||||
element.transform.Find("name").GetComponent<TMP_Text>().text = Localization.instance.Localize(name);
|
||||
|
||||
TMP_Text price = FindDescendant<TMP_Text>(element.transform, "price");
|
||||
if (price != null) price.text = AlfarNexusBehaviour.PriceShort(product);
|
||||
|
||||
// The coin that sits beside the number on a vanilla row is the wrong picture here.
|
||||
foreach (Image image in element.GetComponentsInChildren<Image>(true))
|
||||
{
|
||||
if (image != null && image.gameObject.name.ToLowerInvariant().Contains("coin")) image.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
UITooltip tooltip = element.GetComponent<UITooltip>();
|
||||
if (tooltip != null) tooltip.Set(Localization.instance.Localize(name), nexus.Terms(product), gui.m_tooltipAnchor, default(Vector2));
|
||||
|
||||
AlfarNexusBehaviour.Product chosen = product;
|
||||
element.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
nexus.BuildFromStore(chosen);
|
||||
Traverse.Create(gui).Method("FillList").GetValue(); // repaints the column
|
||||
});
|
||||
|
||||
_rows.Add(element);
|
||||
}
|
||||
|
||||
// ─── helpers ─────────────────────────────────────────────────────────
|
||||
|
||||
private static Sprite Icon(string prefabName)
|
||||
{
|
||||
ItemDrop drop = Jotunn.Managers.PrefabManager.Cache.GetPrefab<ItemDrop>(prefabName);
|
||||
Sprite[] icons = drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null
|
||||
? drop.m_itemData.m_shared.m_icons
|
||||
: null;
|
||||
return icons != null && icons.Length > 0 ? icons[0] : null;
|
||||
}
|
||||
|
||||
private static T FindDescendant<T>(Transform root, string childName) where T : Component
|
||||
{
|
||||
foreach (T candidate in root.GetComponentsInChildren<T>(true))
|
||||
{
|
||||
if (candidate.gameObject.name == childName) return candidate;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(StoreGui), "Awake")]
|
||||
public static class AlfarNexusStoreSetupPatch
|
||||
{
|
||||
public static void Postfix(StoreGui __instance) => AlfarNexusStore.Create(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(StoreGui), "FillList")]
|
||||
public static class AlfarNexusStoreFillPatch
|
||||
{
|
||||
public static void Postfix(StoreGui __instance) => AlfarNexusStore.Refresh(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(StoreGui), "Hide")]
|
||||
public static class AlfarNexusStoreHidePatch
|
||||
{
|
||||
public static void Postfix() => AlfarNexusStore.Clear();
|
||||
}
|
||||
}
|
||||
149
JotunnModStub/Alfar/AlfarPatches.cs
Normal file
149
JotunnModStub/Alfar/AlfarPatches.cs
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The hooks that keep an Alfr looking like one. Only the look so far; the shield, the death
|
||||
/// timer and the powers add their own patches as they are written.
|
||||
/// </summary>
|
||||
public static class AlfarPatches
|
||||
{
|
||||
/// <summary>
|
||||
/// The only thing that actually colours a player.
|
||||
///
|
||||
/// SetSkinColor followed by UpdateColors does nothing, because UpdateColors is what REBUILDS
|
||||
/// the body material from Valheim's own values and throws any earlier write away
|
||||
/// (DvergarPatches documents the dead end). Writing _SkinColor here, after it has run, is the
|
||||
/// only order that survives.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(VisEquipment), "UpdateColors")]
|
||||
public static class Alfar_UpdateColors_Patch
|
||||
{
|
||||
public static void Postfix(VisEquipment __instance)
|
||||
{
|
||||
if (__instance == null || __instance.m_bodyModel == null) return;
|
||||
|
||||
Player player = __instance.GetComponent<Player>();
|
||||
if (player == null || !AlfarVisuals.IsAlfarPlayer(player)) return;
|
||||
|
||||
AlfarVisuals.ApplyGreyTexture(__instance, true);
|
||||
|
||||
Material material = __instance.m_bodyModel.material;
|
||||
if (material != null && material.HasProperty("_SkinColor"))
|
||||
{
|
||||
material.SetColor("_SkinColor", AlfarVisuals.SkinFor(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The character preview on the main menu is a Player too, with the saved race in its custom data
|
||||
/// and no ZNetView. Its Update may never run, so a small driver on it keeps the look: skin, hair,
|
||||
/// scale and eyes, twice a second, for as long as the preview exists. The existing menu hook only
|
||||
/// pushes ONE colour refresh and knows nothing of eyes or texture.
|
||||
/// </summary>
|
||||
public class AlfarPreviewDriver : MonoBehaviour
|
||||
{
|
||||
private Player player;
|
||||
private float next;
|
||||
|
||||
private void Awake() { player = GetComponent<Player>(); }
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (player == null || Time.time < next) return;
|
||||
next = Time.time + 0.5f;
|
||||
|
||||
bool isAlfar = AlfarVisuals.IsAlfarPlayer(player);
|
||||
AlfarVisuals.ApplyScale(player, isAlfar);
|
||||
AlfarVisuals.ApplyEyes(player);
|
||||
if (isAlfar) AlfarVisuals.ApplyHairless(player);
|
||||
AlfarVisuals.SyncSkin(player, isAlfar);
|
||||
}
|
||||
}
|
||||
|
||||
public static void AttachPreviewDriver(FejdStartup instance)
|
||||
{
|
||||
Player preview = instance.GetType()
|
||||
.GetMethod("GetPreviewPlayer",
|
||||
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic |
|
||||
System.Reflection.BindingFlags.Public)
|
||||
?.Invoke(instance, null) as Player;
|
||||
if (preview != null && preview.GetComponent<AlfarPreviewDriver>() == null)
|
||||
{
|
||||
preview.gameObject.AddComponent<AlfarPreviewDriver>();
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(FejdStartup), "SetupCharacterPreview")]
|
||||
public static class Alfar_Preview_Setup_Patch
|
||||
{
|
||||
[HarmonyPriority(Priority.Last)]
|
||||
public static void Postfix(FejdStartup __instance) => AttachPreviewDriver(__instance);
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(FejdStartup), "SetSelectedProfile")]
|
||||
public static class Alfar_Preview_Profile_Patch
|
||||
{
|
||||
[HarmonyPriority(Priority.Last)]
|
||||
public static void Postfix(FejdStartup __instance) => AttachPreviewDriver(__instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scale every frame, the cosmetics on a throttle.
|
||||
///
|
||||
/// On Player.Update because that is the one place body scale survives: the Trol's postfix
|
||||
/// forces every other player's visual back to 1 on the same frame, so a scale written
|
||||
/// anywhere else is simply overwritten. RaceScale keeps the two from undoing each other.
|
||||
/// This runs for every player in range, not just the local one, so other clients see an
|
||||
/// Alfr as one.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "Update")]
|
||||
public static class Alfar_PlayerUpdate_Patch
|
||||
{
|
||||
private static readonly Dictionary<Player, float> nextCosmeticPass = new Dictionary<Player, float>();
|
||||
private const float CosmeticInterval = 0.5f;
|
||||
|
||||
public static void Postfix(Player __instance)
|
||||
{
|
||||
if (__instance == null) return;
|
||||
|
||||
bool isAlfar = AlfarVisuals.IsAlfarPlayer(__instance);
|
||||
|
||||
AlfarVisuals.ApplyScale(__instance, isAlfar);
|
||||
|
||||
// The passive carrier belongs to the local body only; status effects are re-added
|
||||
// because they do not survive a reload or a death.
|
||||
if (__instance == Player.m_localPlayer)
|
||||
{
|
||||
if (isAlfar && !__instance.IsDead())
|
||||
{
|
||||
AlfarStatusEffects.Ensure(__instance);
|
||||
AlfarPowers.Tick(__instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
AlfarStatusEffects.Remove(__instance);
|
||||
if (AlfarArchon.Active) AlfarArchon.ForceClear(__instance);
|
||||
}
|
||||
}
|
||||
|
||||
if (!nextCosmeticPass.TryGetValue(__instance, out float due) || Time.time >= due)
|
||||
{
|
||||
nextCosmeticPass[__instance] = Time.time + CosmeticInterval;
|
||||
|
||||
// Unconditional, like the other races': the eyes have to be able to remove
|
||||
// themselves from whoever stops being an Alfr, and they cannot do that from
|
||||
// behind an `if (isAlfar)`.
|
||||
AlfarVisuals.ApplyEyes(__instance);
|
||||
AlfarVisuals.ApplyArchonGlow(__instance);
|
||||
|
||||
if (isAlfar) AlfarVisuals.ApplyHairless(__instance);
|
||||
AlfarVisuals.SyncSkin(__instance, isAlfar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
170
JotunnModStub/Alfar/AlfarPowerConfig.cs
Normal file
170
JotunnModStub/Alfar/AlfarPowerConfig.cs
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
using BepInEx.Configuration;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The numbers and the keys of the Alfar's powers (Alfar_Progettazione.txt sec. 13 and 19.6).
|
||||
/// Every value is a STARTING value to be corrected in play. Nothing numeric lives in the logic.
|
||||
///
|
||||
/// Keys follow the mod's habit: letters the other races also use (G, H, I, J, K, O, U), because a
|
||||
/// character has exactly one race, so the same letter never means two things at once.
|
||||
/// </summary>
|
||||
public static class AlfarPowerConfig
|
||||
{
|
||||
// Progression states a power unlocks at (BossProgressionManager: 2 Eikthyr ... 8 Fader).
|
||||
public const int SkridState = 2;
|
||||
public const int GrafvaettirState = 2;
|
||||
public const int UtsogState = 3;
|
||||
public const int KallState = 4;
|
||||
public const int LjosstormState = 5;
|
||||
public const int GeisliState = 6;
|
||||
public const int KyrrState = 7;
|
||||
public const int SameiningState = 8;
|
||||
|
||||
// ─── Keys ────────────────────────────────────────────────────────────
|
||||
public static ConfigEntry<KeyboardShortcut> SkridKey;
|
||||
public static ConfigEntry<KeyboardShortcut> GrafvaettirKey;
|
||||
public static ConfigEntry<KeyboardShortcut> KallKey;
|
||||
public static ConfigEntry<KeyboardShortcut> LjosstormKey;
|
||||
public static ConfigEntry<KeyboardShortcut> GeisliKey;
|
||||
public static ConfigEntry<KeyboardShortcut> KyrrKey;
|
||||
public static ConfigEntry<KeyboardShortcut> SameiningKey;
|
||||
|
||||
// ─── Skrid: the blink ────────────────────────────────────────────────
|
||||
public static ConfigEntry<float> SkridDistance;
|
||||
public static ConfigEntry<float> SkridCost;
|
||||
public static ConfigEntry<float> SkridCooldown;
|
||||
|
||||
// ─── Utsog: damage dealt comes back as eitr ──────────────────────────
|
||||
public static ConfigEntry<float> UtsogPercent;
|
||||
|
||||
// ─── Kall: telekinesis ───────────────────────────────────────────────
|
||||
public static ConfigEntry<float> KallRadius;
|
||||
public static ConfigEntry<float> KallSpeed;
|
||||
public static ConfigEntry<float> KallCost;
|
||||
public static ConfigEntry<float> KallCooldown;
|
||||
|
||||
// ─── Ljosstorm: the psionic storm ────────────────────────────────────
|
||||
public static ConfigEntry<float> StormRange;
|
||||
public static ConfigEntry<float> StormRadius;
|
||||
public static ConfigEntry<float> StormSeconds;
|
||||
public static ConfigEntry<float> StormDps;
|
||||
public static ConfigEntry<float> StormCost;
|
||||
public static ConfigEntry<float> StormCooldown;
|
||||
|
||||
// ─── Geisli: the beam ────────────────────────────────────────────────
|
||||
public static ConfigEntry<float> BeamRange;
|
||||
public static ConfigEntry<float> BeamDps;
|
||||
public static ConfigEntry<float> BeamCostPerSecond;
|
||||
public static ConfigEntry<float> BeamMaxSeconds;
|
||||
public static ConfigEntry<float> BeamCooldown;
|
||||
|
||||
// ─── Kyrr: stasis ────────────────────────────────────────────────────
|
||||
public static ConfigEntry<float> StasisRange;
|
||||
public static ConfigEntry<float> StasisSeconds;
|
||||
public static ConfigEntry<float> StasisBossSeconds;
|
||||
public static ConfigEntry<float> StasisCost;
|
||||
public static ConfigEntry<float> StasisCooldown;
|
||||
|
||||
// ─── Sameining: the archon ───────────────────────────────────────────
|
||||
public static ConfigEntry<float> ArchonThreshold;
|
||||
public static ConfigEntry<float> ArchonSeconds;
|
||||
public static ConfigEntry<float> ArchonScale;
|
||||
public static ConfigEntry<float> ArchonSpeedBonus;
|
||||
public static ConfigEntry<float> ArchonPoolPerEitr;
|
||||
public static ConfigEntry<float> ArchonPulseRadius;
|
||||
public static ConfigEntry<float> ArchonPulseDamage;
|
||||
public static ConfigEntry<float> ArchonPulseInterval;
|
||||
public static ConfigEntry<float> ArchonFreePowerCooldown;
|
||||
public static ConfigEntry<Color> ArchonColor;
|
||||
|
||||
// ─── Grafvaettir: the mining grenade ─────────────────────────────────
|
||||
public static ConfigEntry<float> GrafRange;
|
||||
public static ConfigEntry<float> GrafRadius;
|
||||
public static ConfigEntry<float> GrafSeconds;
|
||||
public static ConfigEntry<int> GrafCount;
|
||||
public static ConfigEntry<float> GrafEitr;
|
||||
public static ConfigEntry<int> GrafStone;
|
||||
public static ConfigEntry<int> GrafFlint;
|
||||
public static ConfigEntry<float> GrafCooldown;
|
||||
|
||||
// ─── Levitation ──────────────────────────────────────────────────────
|
||||
public static ConfigEntry<float> LevitationRise;
|
||||
public static ConfigEntry<float> LevitationCostPerSecond;
|
||||
|
||||
public static void Bind(ConfigFile config)
|
||||
{
|
||||
const string keys = "Alfar - Keybinds";
|
||||
SkridKey = config.Bind(keys, "Skrid (Blink)", new KeyboardShortcut(KeyCode.G));
|
||||
GrafvaettirKey = config.Bind(keys, "Grafvaettir (Mining Drones)", new KeyboardShortcut(KeyCode.H));
|
||||
KallKey = config.Bind(keys, "Kall (Telekinesis)", new KeyboardShortcut(KeyCode.J));
|
||||
LjosstormKey = config.Bind(keys, "Ljosstorm (Psionic Storm)", new KeyboardShortcut(KeyCode.K));
|
||||
GeisliKey = config.Bind(keys, "Geisli (Beam, hold)", new KeyboardShortcut(KeyCode.O));
|
||||
KyrrKey = config.Bind(keys, "Kyrr (Stasis)", new KeyboardShortcut(KeyCode.U));
|
||||
SameiningKey = config.Bind(keys, "Sameining (Archon)", new KeyboardShortcut(KeyCode.I));
|
||||
|
||||
const string skrid = "Alfar - Skrid";
|
||||
SkridDistance = config.Bind(skrid, "Distance", 8f, new ConfigDescription("Blink length in metres.", new AcceptableValueRange<float>(1f, 30f)));
|
||||
SkridCost = config.Bind(skrid, "Eitr Cost", 10f, new ConfigDescription("Eitr spent per blink.", new AcceptableValueRange<float>(0f, 200f)));
|
||||
SkridCooldown = config.Bind(skrid, "Cooldown", 3f, new ConfigDescription("Seconds between blinks.", new AcceptableValueRange<float>(0f, 120f)));
|
||||
|
||||
const string utsog = "Alfar - Utsog";
|
||||
UtsogPercent = config.Bind(utsog, "Return Percent", 15f, new ConfigDescription("Percent of the damage you deal that comes back as eitr.", new AcceptableValueRange<float>(0f, 100f)));
|
||||
|
||||
const string kall = "Alfar - Kall";
|
||||
KallRadius = config.Bind(kall, "Radius", 15f, new ConfigDescription("Metres around you whose dropped items are pulled in.", new AcceptableValueRange<float>(1f, 60f)));
|
||||
KallSpeed = config.Bind(kall, "Pull Speed", 12f, new ConfigDescription("Speed items fly toward you, in metres per second.", new AcceptableValueRange<float>(1f, 40f)));
|
||||
KallCost = config.Bind(kall, "Eitr Cost", 5f, new ConfigDescription("Eitr spent per pull.", new AcceptableValueRange<float>(0f, 200f)));
|
||||
KallCooldown = config.Bind(kall, "Cooldown", 2f, new ConfigDescription("Seconds between pulls.", new AcceptableValueRange<float>(0f, 120f)));
|
||||
|
||||
const string storm = "Alfar - Ljosstorm";
|
||||
StormRange = config.Bind(storm, "Range", 30f, new ConfigDescription("How far you can place the storm.", new AcceptableValueRange<float>(5f, 80f)));
|
||||
StormRadius = config.Bind(storm, "Radius", 6f, new ConfigDescription("Radius of the storm in metres.", new AcceptableValueRange<float>(1f, 30f)));
|
||||
StormSeconds = config.Bind(storm, "Duration", 6f, new ConfigDescription("Seconds the storm lasts.", new AcceptableValueRange<float>(1f, 60f)));
|
||||
StormDps = config.Bind(storm, "Damage Per Second", 20f, new ConfigDescription("Lightning damage per second to each enemy inside.", new AcceptableValueRange<float>(1f, 500f)));
|
||||
StormCost = config.Bind(storm, "Eitr Cost", 40f, new ConfigDescription("Eitr spent per cast.", new AcceptableValueRange<float>(0f, 400f)));
|
||||
StormCooldown = config.Bind(storm, "Cooldown", 20f, new ConfigDescription("Seconds between casts.", new AcceptableValueRange<float>(0f, 300f)));
|
||||
|
||||
const string beam = "Alfar - Geisli";
|
||||
BeamRange = config.Bind(beam, "Range", 30f, new ConfigDescription("Beam length in metres.", new AcceptableValueRange<float>(5f, 80f)));
|
||||
BeamDps = config.Bind(beam, "Damage Per Second", 35f, new ConfigDescription("Lightning damage per second to the target.", new AcceptableValueRange<float>(1f, 500f)));
|
||||
BeamCostPerSecond = config.Bind(beam, "Eitr Per Second", 8f, new ConfigDescription("Eitr burned each second the beam is held.", new AcceptableValueRange<float>(0f, 100f)));
|
||||
BeamMaxSeconds = config.Bind(beam, "Max Continuous Seconds", 8f, new ConfigDescription("The beam cuts off after this long.", new AcceptableValueRange<float>(1f, 60f)));
|
||||
BeamCooldown = config.Bind(beam, "Cooldown After Release", 2f, new ConfigDescription("Seconds before the beam can start again.", new AcceptableValueRange<float>(0f, 60f)));
|
||||
|
||||
const string stasis = "Alfar - Kyrr";
|
||||
StasisRange = config.Bind(stasis, "Range", 25f, new ConfigDescription("How far the stasis reaches.", new AcceptableValueRange<float>(5f, 80f)));
|
||||
StasisSeconds = config.Bind(stasis, "Seconds", 4f, new ConfigDescription("How long an ordinary enemy is held.", new AcceptableValueRange<float>(0.5f, 30f)));
|
||||
StasisBossSeconds = config.Bind(stasis, "Boss Seconds", 1.5f, new ConfigDescription("How long a boss is held.", new AcceptableValueRange<float>(0.5f, 30f)));
|
||||
StasisCost = config.Bind(stasis, "Eitr Cost", 50f, new ConfigDescription("Eitr spent per cast.", new AcceptableValueRange<float>(0f, 400f)));
|
||||
StasisCooldown = config.Bind(stasis, "Cooldown", 45f, new ConfigDescription("Seconds between casts.", new AcceptableValueRange<float>(0f, 600f)));
|
||||
|
||||
const string archon = "Alfar - Sameining";
|
||||
ArchonThreshold = config.Bind(archon, "Activation Threshold", 0.75f, new ConfigDescription("Fraction of the maximum eitr needed to begin. All of it is spent.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
ArchonSeconds = config.Bind(archon, "Duration", 180f, new ConfigDescription("Seconds the form lasts at most.", new AcceptableValueRange<float>(5f, 900f)));
|
||||
ArchonScale = config.Bind(archon, "Scale", 1.5f, new ConfigDescription("Body size multiplier in the form.", new AcceptableValueRange<float>(1f, 3f)));
|
||||
ArchonSpeedBonus = config.Bind(archon, "Speed Bonus", 0.2f, new ConfigDescription("Movement speed bonus in the form (0.2 = +20%).", new AcceptableValueRange<float>(0f, 1f)));
|
||||
ArchonPoolPerEitr = config.Bind(archon, "Pool Per Eitr", 3f, new ConfigDescription("Points of protection per point of eitr spent to enter.", new AcceptableValueRange<float>(0.1f, 20f)));
|
||||
ArchonPulseRadius = config.Bind(archon, "Pulse Radius", 4f, new ConfigDescription("Radius of the psionic pulse around you.", new AcceptableValueRange<float>(1f, 20f)));
|
||||
ArchonPulseDamage = config.Bind(archon, "Pulse Damage", 60f, new ConfigDescription("Lightning damage of each pulse.", new AcceptableValueRange<float>(1f, 1000f)));
|
||||
ArchonPulseInterval = config.Bind(archon, "Pulse Interval", 1f, new ConfigDescription("Seconds between pulses.", new AcceptableValueRange<float>(0.2f, 10f)));
|
||||
ArchonFreePowerCooldown = config.Bind(archon, "Free Power Cooldown", 5f, new ConfigDescription("In the form, Ljosstorm and Geisli cost no eitr but wait this long.", new AcceptableValueRange<float>(0f, 60f)));
|
||||
ArchonColor = config.Bind(archon, "Glow Color", new Color(0.55f, 0.85f, 1f, 1f), new ConfigDescription("Skin and light colour while in the form."));
|
||||
|
||||
const string graf = "Alfar - Grafvaettir";
|
||||
GrafRange = config.Bind(graf, "Throw Range", 25f, new ConfigDescription("How far the drones can be thrown.", new AcceptableValueRange<float>(5f, 80f)));
|
||||
GrafRadius = config.Bind(graf, "Dig Radius", 12f, new ConfigDescription("Radius around the landing point where they dig.", new AcceptableValueRange<float>(2f, 60f)));
|
||||
GrafSeconds = config.Bind(graf, "Duration", 120f, new ConfigDescription("Seconds the drones dig before vanishing.", new AcceptableValueRange<float>(5f, 900f)));
|
||||
GrafCount = config.Bind(graf, "Drones Per Throw", 5, new ConfigDescription("How many mining drones one throw makes.", new AcceptableValueRange<int>(1, 30)));
|
||||
GrafEitr = config.Bind(graf, "Eitr Cost", 25f, new ConfigDescription("Eitr spent per throw.", new AcceptableValueRange<float>(0f, 400f)));
|
||||
GrafStone = config.Bind(graf, "Stone Cost", 10, new ConfigDescription("Stone spent per throw.", new AcceptableValueRange<int>(0, 200)));
|
||||
GrafFlint = config.Bind(graf, "Flint Cost", 5, new ConfigDescription("Flint spent per throw.", new AcceptableValueRange<int>(0, 200)));
|
||||
GrafCooldown = config.Bind(graf, "Cooldown", 300f, new ConfigDescription("Seconds between throws; keep it well above the duration or they are permanent.", new AcceptableValueRange<float>(0f, 3600f)));
|
||||
|
||||
const string lev = "Alfar - Levitation";
|
||||
LevitationRise = config.Bind(lev, "Rise Speed", 2f, new ConfigDescription("Climb speed (m/s) while the jump key is held in the air.", new AcceptableValueRange<float>(0.2f, 10f)));
|
||||
LevitationCostPerSecond = config.Bind(lev, "Eitr Per Second", 2f, new ConfigDescription("Eitr burned each second of levitation.", new AcceptableValueRange<float>(0f, 50f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
616
JotunnModStub/Alfar/AlfarPowers.cs
Normal file
616
JotunnModStub/Alfar/AlfarPowers.cs
Normal file
|
|
@ -0,0 +1,616 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The Alfar's powers (Alfar_Progettazione.txt sec. 13): caster tools, one per boss from Eikthyr.
|
||||
///
|
||||
/// Skrid Eikthyr blink
|
||||
/// Grafvaettir Eikthyr mining drones thrown like a grenade (AlfarMiners)
|
||||
/// Utsog Elder damage dealt returns as eitr (passive, below)
|
||||
/// Kall Bonemass telekinesis
|
||||
/// Ljosstorm Moder psionic storm on the ground
|
||||
/// Geisli Yagluth continuous beam (hold the key)
|
||||
/// Kyrr Queen stasis
|
||||
/// Sameining Fader the archon (AlfarArchon)
|
||||
///
|
||||
/// Every power costs eitr from the SAME pool as the shield, which is the whole tension of the race
|
||||
/// (doc sec. 4.4). Eitr is spent through AlfarEitr.Spend so the vanilla regeneration delay arms.
|
||||
/// </summary>
|
||||
public static class AlfarPowers
|
||||
{
|
||||
private static readonly Dictionary<string, float> cooldownUntil = new Dictionary<string, float>();
|
||||
|
||||
public static void ResetCooldowns(Player player)
|
||||
{
|
||||
cooldownUntil.Clear();
|
||||
StopBeam();
|
||||
AlfarArchon.ForceClear(player);
|
||||
foreach (string id in AlfarStatusEffects.TimerIds) AlfarStatusEffects.ClearTimer(id);
|
||||
}
|
||||
|
||||
private static bool Ready(string id) => !cooldownUntil.TryGetValue(id, out float until) || Time.time >= until;
|
||||
|
||||
private static void StartCooldown(string id, float seconds)
|
||||
{
|
||||
cooldownUntil[id] = Time.time + seconds;
|
||||
AlfarStatusEffects.ShowTimer(id, seconds);
|
||||
}
|
||||
|
||||
private static bool Unlocked(int need) => BossProgressionManager.GetCurrentProgressionState() >= need;
|
||||
|
||||
/// <summary>
|
||||
/// The eitr a power costs: nothing for Ljosstorm and Geisli inside the archon form.
|
||||
/// </summary>
|
||||
private static float CostOf(float cost, bool freeInArchon) =>
|
||||
freeInArchon && AlfarArchon.Active ? 0f : cost;
|
||||
|
||||
private static float CooldownOf(float cooldown, bool freeInArchon) =>
|
||||
freeInArchon && AlfarArchon.Active ? AlfarArchon.FreePowerCooldown : cooldown;
|
||||
|
||||
/// <summary>Pays for a power, or says so and returns false.</summary>
|
||||
private static bool Pay(Player player, float cost)
|
||||
{
|
||||
if (cost <= 0f) return true;
|
||||
if (player.GetEitr() < cost)
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_no_eitr"));
|
||||
return false;
|
||||
}
|
||||
AlfarEitr.Spend(player, cost);
|
||||
return true;
|
||||
}
|
||||
|
||||
// ─── The loop ────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Called every frame for the LOCAL Alfr, from the Player.Update postfix.</summary>
|
||||
public static void Tick(Player player)
|
||||
{
|
||||
AlfarArchon.Tick(player);
|
||||
AlfarHeimkall.SyncIcon(player);
|
||||
AlfarMiners.Tick(player);
|
||||
TickBeam(player);
|
||||
|
||||
if (!RaceInput.Allowed || player.IsDead()) return;
|
||||
|
||||
if (Unlocked(AlfarPowerConfig.SkridState) && AlfarPowerConfig.SkridKey.Value.IsDownIgnoringHeldKeys()) Skrid(player);
|
||||
if (Unlocked(AlfarPowerConfig.GrafvaettirState) && AlfarPowerConfig.GrafvaettirKey.Value.IsDownIgnoringHeldKeys()) AlfarMiners.Throw(player);
|
||||
if (Unlocked(AlfarPowerConfig.KallState) && AlfarPowerConfig.KallKey.Value.IsDownIgnoringHeldKeys()) Kall(player);
|
||||
if (Unlocked(AlfarPowerConfig.LjosstormState) && AlfarPowerConfig.LjosstormKey.Value.IsDownIgnoringHeldKeys()) Ljosstorm(player);
|
||||
if (Unlocked(AlfarPowerConfig.KyrrState) && AlfarPowerConfig.KyrrKey.Value.IsDownIgnoringHeldKeys()) Kyrr(player);
|
||||
if (Unlocked(AlfarPowerConfig.SameiningState) && AlfarPowerConfig.SameiningKey.Value.IsDownIgnoringHeldKeys()) AlfarArchon.TryActivate(player);
|
||||
}
|
||||
|
||||
// ─── Aim ─────────────────────────────────────────────────────────────
|
||||
|
||||
private static Transform AimTransform(Player player)
|
||||
{
|
||||
return GameCamera.instance != null ? GameCamera.instance.transform : player.transform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What the crosshair is on: the first thing the ray hits that is not the Alfr, with the
|
||||
/// character under it if there is one. Triggers are ignored. With nothing hit, the point is at
|
||||
/// the end of the range.
|
||||
/// </summary>
|
||||
private static bool Aim(Player player, float range, out Vector3 point, out Character target)
|
||||
{
|
||||
Transform aim = AimTransform(player);
|
||||
Vector3 origin = aim.position;
|
||||
Vector3 direction = aim.forward;
|
||||
|
||||
target = null;
|
||||
point = origin + direction * range;
|
||||
|
||||
RaycastHit[] hits = Physics.RaycastAll(origin, direction, range, ~0, QueryTriggerInteraction.Ignore);
|
||||
System.Array.Sort(hits, (a, b) => a.distance.CompareTo(b.distance));
|
||||
|
||||
foreach (RaycastHit hit in hits)
|
||||
{
|
||||
if (hit.collider == null) continue;
|
||||
if (hit.collider.GetComponentInParent<Player>() == player) continue;
|
||||
|
||||
point = hit.point;
|
||||
target = hit.collider.GetComponentInParent<Character>();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsHostile(Player player, Character other)
|
||||
{
|
||||
return other != null && other != player && !other.IsDead() && !other.IsTamed() &&
|
||||
BaseAI.IsEnemy(player, other);
|
||||
}
|
||||
|
||||
// ─── Damage ──────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// One lightning strike on a character. Not blockable and not dodgeable: a power that can be
|
||||
/// blocked is a weapon, and these are not.
|
||||
/// </summary>
|
||||
public static void Strike(Player attacker, Character target, float lightning, Vector3 point)
|
||||
{
|
||||
if (target == null || lightning <= 0f) return;
|
||||
|
||||
HitData hit = new HitData();
|
||||
hit.m_damage.m_lightning = lightning;
|
||||
hit.m_point = point;
|
||||
hit.m_dir = (target.transform.position - attacker.transform.position).normalized;
|
||||
hit.m_dodgeable = false;
|
||||
hit.m_blockable = false;
|
||||
hit.m_hitType = HitData.HitType.PlayerHit;
|
||||
hit.SetAttacker(attacker);
|
||||
target.Damage(hit);
|
||||
}
|
||||
|
||||
/// <summary>A pulse of lightning on every hostile creature within a radius of the Alfr.</summary>
|
||||
public static void Pulse(Player player, float radius, float damage)
|
||||
{
|
||||
foreach (Character character in CharactersIn(player.transform.position, radius))
|
||||
{
|
||||
if (IsHostile(player, character)) Strike(player, character, damage, character.GetCenterPoint());
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<Character> CharactersIn(Vector3 center, float radius)
|
||||
{
|
||||
var seen = new HashSet<Character>();
|
||||
foreach (Collider collider in Physics.OverlapSphere(center, radius, ~0, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
Character character = collider.GetComponentInParent<Character>();
|
||||
if (character != null && seen.Add(character)) yield return character;
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Skrid: blink ────────────────────────────────────────────────────
|
||||
|
||||
private static void Skrid(Player player)
|
||||
{
|
||||
if (!Ready("skrid")) return;
|
||||
|
||||
Transform aim = AimTransform(player);
|
||||
Vector3 origin = player.transform.position + Vector3.up * 1.0f;
|
||||
Vector3 direction = aim.forward;
|
||||
float distance = AlfarPowerConfig.SkridDistance.Value;
|
||||
|
||||
if (!Pay(player, AlfarPowerConfig.SkridCost.Value)) return;
|
||||
|
||||
// Stop short of whatever is in the way, so the blink never ends inside a wall.
|
||||
Vector3 destination = origin + direction * distance;
|
||||
RaycastHit[] hits = Physics.RaycastAll(origin, direction, distance, ~0, QueryTriggerInteraction.Ignore);
|
||||
float nearest = float.MaxValue;
|
||||
foreach (RaycastHit hit in hits)
|
||||
{
|
||||
if (hit.collider.GetComponentInParent<Player>() == player) continue;
|
||||
if (hit.distance < nearest)
|
||||
{
|
||||
nearest = hit.distance;
|
||||
destination = hit.point - direction * 0.6f;
|
||||
}
|
||||
}
|
||||
|
||||
// Back down to the player's own height: the origin was at the chest.
|
||||
destination.y -= 1.0f;
|
||||
if (ZoneSystem.instance != null)
|
||||
{
|
||||
float ground = ZoneSystem.instance.GetSolidHeight(destination);
|
||||
if (destination.y < ground) destination.y = ground + 0.1f;
|
||||
}
|
||||
|
||||
Teleport(player, destination);
|
||||
StartCooldown("skrid", AlfarPowerConfig.SkridCooldown.Value);
|
||||
AlfarFx.Spawn("fx_JotunWitch_LightningBolt_Explosion", origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves the body without the teleport fade: the rigidbody is repositioned and its velocity
|
||||
/// zeroed, and the fall tracker is reset so a blink up a cliff does not count as a fall.
|
||||
/// </summary>
|
||||
private static void Teleport(Player player, Vector3 destination)
|
||||
{
|
||||
Rigidbody body = Traverse.Create(player).Field("m_body").GetValue<Rigidbody>();
|
||||
player.transform.position = destination;
|
||||
if (body != null)
|
||||
{
|
||||
body.position = destination;
|
||||
body.linearVelocity = Vector3.zero;
|
||||
}
|
||||
Traverse.Create(player).Field("m_maxAirAltitude").SetValue(destination.y);
|
||||
}
|
||||
|
||||
// ─── Utsog: damage dealt returns as eitr ─────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// After a blow lands on something that is not a player: if the local Alfr struck it, a share
|
||||
/// of the damage comes back as eitr. Runs only where the victim is owned, which is here for
|
||||
/// anything this client owns (singleplayer and the host in practice): a monster owned by
|
||||
/// another client feeds no eitr. Known limit, doc sec. 17.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Character), "ApplyDamage",
|
||||
new[] { typeof(HitData), typeof(bool), typeof(bool), typeof(HitData.DamageModifier) })]
|
||||
public static class Alfar_Utsog_Patch
|
||||
{
|
||||
public static void Postfix(Character __instance, HitData __0)
|
||||
{
|
||||
if (__instance == null || __0 == null || __instance is Player) return;
|
||||
|
||||
Player local = Player.m_localPlayer;
|
||||
if (local == null || __0.GetAttacker() != local) return;
|
||||
if (!AlfarVisuals.IsAlfarPlayer(local) || !Unlocked(AlfarPowerConfig.UtsogState)) return;
|
||||
if (__instance.IsTamed()) return;
|
||||
|
||||
float returned = __0.GetTotalDamage() * AlfarPowerConfig.UtsogPercent.Value / 100f;
|
||||
if (returned > 0f) local.AddEitr(returned);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Kall: telekinesis ───────────────────────────────────────────────
|
||||
|
||||
private static void Kall(Player player)
|
||||
{
|
||||
if (!Ready("kall")) return;
|
||||
if (!Pay(player, AlfarPowerConfig.KallCost.Value)) return;
|
||||
|
||||
Vector3 target = player.GetCenterPoint();
|
||||
int pulled = 0;
|
||||
var seen = new HashSet<ItemDrop>();
|
||||
|
||||
foreach (Collider collider in Physics.OverlapSphere(player.transform.position, AlfarPowerConfig.KallRadius.Value,
|
||||
~0, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
ItemDrop item = collider.GetComponentInParent<ItemDrop>();
|
||||
if (item == null || !seen.Add(item)) continue;
|
||||
|
||||
Rigidbody body = item.GetComponent<Rigidbody>();
|
||||
ZNetView nview = item.GetComponent<ZNetView>();
|
||||
if (body == null || nview == null || !nview.IsValid()) continue;
|
||||
|
||||
// The item's physics belong to whoever owns it; take it so the pull is not undone.
|
||||
nview.ClaimOwnership();
|
||||
Vector3 direction = (target - item.transform.position).normalized;
|
||||
body.WakeUp();
|
||||
body.linearVelocity = direction * AlfarPowerConfig.KallSpeed.Value;
|
||||
pulled++;
|
||||
}
|
||||
|
||||
StartCooldown("kall", AlfarPowerConfig.KallCooldown.Value);
|
||||
Jotunn.Logger.LogInfo($"[Alfar] Kall pulled {pulled} item(s).");
|
||||
}
|
||||
|
||||
// ─── Ljosstorm: the psionic storm ────────────────────────────────────
|
||||
|
||||
private static void Ljosstorm(Player player)
|
||||
{
|
||||
if (!Ready("storm")) return;
|
||||
|
||||
float cost = CostOf(AlfarPowerConfig.StormCost.Value, true);
|
||||
if (!Pay(player, cost)) return;
|
||||
|
||||
Aim(player, AlfarPowerConfig.StormRange.Value, out Vector3 point, out Character _);
|
||||
|
||||
GameObject storm = new GameObject("AlfarStorm");
|
||||
storm.transform.position = point;
|
||||
AlfarStormZone zone = storm.AddComponent<AlfarStormZone>();
|
||||
zone.Owner = player;
|
||||
zone.Radius = AlfarPowerConfig.StormRadius.Value;
|
||||
zone.Seconds = AlfarPowerConfig.StormSeconds.Value;
|
||||
zone.DamagePerSecond = AlfarPowerConfig.StormDps.Value;
|
||||
|
||||
StartCooldown("storm", CooldownOf(AlfarPowerConfig.StormCooldown.Value, true));
|
||||
}
|
||||
|
||||
// ─── Geisli: the beam ────────────────────────────────────────────────
|
||||
|
||||
private static LineRenderer beamLine;
|
||||
private static readonly List<LineRenderer> beamArcs = new List<LineRenderer>();
|
||||
private static GameObject beamFx;
|
||||
private static bool beamOn;
|
||||
private static float beamStarted;
|
||||
private static float beamNextTick;
|
||||
private static float beamNextAnim;
|
||||
private static float beamNextArcs;
|
||||
|
||||
/// <summary>
|
||||
/// The beam leaves the RIGHT HAND, raised with the palm open: the borrowed "gpower" gesture (the
|
||||
/// arms-raised cast the other races use too, with the real Guardian Power swallowed for a moment),
|
||||
/// repeated while the key is held so the arm stays up. A quiet electric hum comes from the
|
||||
/// vanilla lightning staff's charge effect hung on the hand, turned down, and a few jagged arcs
|
||||
/// flicker round the line.
|
||||
/// </summary>
|
||||
private static void TickBeam(Player player)
|
||||
{
|
||||
bool wanted = RaceInput.Allowed && !player.IsDead() && Unlocked(AlfarPowerConfig.GeisliState) &&
|
||||
AlfarPowerConfig.GeisliKey.Value.IsPressedIgnoringHeldKeys();
|
||||
|
||||
if (!wanted)
|
||||
{
|
||||
if (beamOn) StopBeam(startCooldown: true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!beamOn)
|
||||
{
|
||||
if (!Ready("beam")) return;
|
||||
if (player.GetEitr() <= 0f && !AlfarArchon.Active) { Pay(player, 1f); return; }
|
||||
beamOn = true;
|
||||
beamStarted = Time.time;
|
||||
beamNextTick = Time.time;
|
||||
beamNextAnim = 0f;
|
||||
StartBeamFx(player);
|
||||
}
|
||||
|
||||
if (Time.time - beamStarted > AlfarPowerConfig.BeamMaxSeconds.Value) { StopBeam(startCooldown: true); return; }
|
||||
|
||||
if (Time.time >= beamNextAnim)
|
||||
{
|
||||
beamNextAnim = Time.time + 1.6f;
|
||||
RaiseHand(player);
|
||||
}
|
||||
|
||||
Transform aim = AimTransform(player);
|
||||
Transform hand = AlfarVisuals.RightHand(player);
|
||||
Vector3 start = hand != null ? hand.position : player.GetEyePoint() + Vector3.down * 0.35f + aim.forward * 0.5f;
|
||||
Aim(player, AlfarPowerConfig.BeamRange.Value, out Vector3 end, out Character target);
|
||||
DrawBeam(start, end);
|
||||
|
||||
if (Time.time < beamNextTick) return;
|
||||
const float tick = 0.2f;
|
||||
beamNextTick = Time.time + tick;
|
||||
|
||||
float cost = CostOf(AlfarPowerConfig.BeamCostPerSecond.Value * tick, true);
|
||||
if (cost > 0f)
|
||||
{
|
||||
if (player.GetEitr() < cost) { StopBeam(startCooldown: true); return; }
|
||||
AlfarEitr.Spend(player, cost);
|
||||
}
|
||||
|
||||
if (IsHostile(player, target)) Strike(player, target, AlfarPowerConfig.BeamDps.Value * tick, end);
|
||||
}
|
||||
|
||||
private static void RaiseHand(Player player)
|
||||
{
|
||||
ZSyncAnimation animation = player.GetComponent<ZSyncAnimation>();
|
||||
if (animation == null) return;
|
||||
|
||||
RaceInput.SuppressGuardianPowerBriefly(3f);
|
||||
animation.SetTrigger("gpower");
|
||||
}
|
||||
|
||||
private static void StartBeamFx(Player player)
|
||||
{
|
||||
Transform hand = AlfarVisuals.RightHand(player);
|
||||
if (hand == null || ZNetScene.instance == null) return;
|
||||
|
||||
GameObject prefab = ZNetScene.instance.GetPrefab("fx_lightningstaff_charge");
|
||||
if (prefab == null) return;
|
||||
|
||||
beamFx = Object.Instantiate(prefab, hand.position, hand.rotation, hand);
|
||||
|
||||
// Not too loud: a hum, not a thunderclap.
|
||||
foreach (AudioSource source in beamFx.GetComponentsInChildren<AudioSource>(true))
|
||||
{
|
||||
source.volume *= 0.35f;
|
||||
}
|
||||
}
|
||||
|
||||
private static LineRenderer NewLine(string name, float width)
|
||||
{
|
||||
GameObject go = new GameObject(name);
|
||||
LineRenderer line = go.AddComponent<LineRenderer>();
|
||||
line.material = new Material(Shader.Find("Sprites/Default"));
|
||||
line.startWidth = width;
|
||||
line.endWidth = width * 0.5f;
|
||||
line.useWorldSpace = true;
|
||||
return line;
|
||||
}
|
||||
|
||||
private static void DrawBeam(Vector3 start, Vector3 end)
|
||||
{
|
||||
Color color = AlfarPowerConfig.ArchonColor.Value;
|
||||
|
||||
if (beamLine == null)
|
||||
{
|
||||
beamLine = NewLine("AlfarBeam", 0.12f);
|
||||
beamLine.positionCount = 2;
|
||||
}
|
||||
beamLine.startColor = color;
|
||||
beamLine.endColor = new Color(color.r, color.g, color.b, 0.4f);
|
||||
beamLine.SetPosition(0, start);
|
||||
beamLine.SetPosition(1, end);
|
||||
|
||||
// A few jagged arcs round the line, redrawn about twenty times a second.
|
||||
if (beamArcs.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
LineRenderer arc = NewLine("AlfarBeamArc" + i, 0.04f);
|
||||
arc.positionCount = 9;
|
||||
beamArcs.Add(arc);
|
||||
}
|
||||
}
|
||||
|
||||
if (Time.time >= beamNextArcs)
|
||||
{
|
||||
beamNextArcs = Time.time + 0.05f;
|
||||
Vector3 direction = end - start;
|
||||
foreach (LineRenderer arc in beamArcs)
|
||||
{
|
||||
arc.startColor = new Color(1f, 1f, 1f, 0.9f);
|
||||
arc.endColor = new Color(color.r, color.g, color.b, 0.2f);
|
||||
for (int i = 0; i < arc.positionCount; i++)
|
||||
{
|
||||
float t = i / (float)(arc.positionCount - 1);
|
||||
Vector3 point = start + direction * t;
|
||||
if (i > 0 && i < arc.positionCount - 1) point += Random.insideUnitSphere * 0.35f;
|
||||
arc.SetPosition(i, point);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void StopBeam(bool startCooldown = false)
|
||||
{
|
||||
if (beamLine != null) { Object.Destroy(beamLine.gameObject); beamLine = null; }
|
||||
foreach (LineRenderer arc in beamArcs) if (arc != null) Object.Destroy(arc.gameObject);
|
||||
beamArcs.Clear();
|
||||
if (beamFx != null) { Object.Destroy(beamFx); beamFx = null; }
|
||||
|
||||
if (beamOn && startCooldown) StartCooldown("beam", CooldownOf(AlfarPowerConfig.BeamCooldown.Value, true));
|
||||
beamOn = false;
|
||||
}
|
||||
|
||||
// ─── Kyrr: stasis ────────────────────────────────────────────────────
|
||||
|
||||
private static void Kyrr(Player player)
|
||||
{
|
||||
if (!Ready("kyrr")) return;
|
||||
|
||||
Transform aim = AimTransform(player);
|
||||
Character best = null;
|
||||
float bestDistance = float.MaxValue;
|
||||
foreach (RaycastHit hit in Physics.SphereCastAll(aim.position, 0.8f, aim.forward,
|
||||
AlfarPowerConfig.StasisRange.Value, ~0, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
Character character = hit.collider.GetComponentInParent<Character>();
|
||||
if (!IsHostile(player, character) || hit.distance >= bestDistance) continue;
|
||||
best = character;
|
||||
bestDistance = hit.distance;
|
||||
}
|
||||
|
||||
if (best == null) return;
|
||||
if (!Pay(player, AlfarPowerConfig.StasisCost.Value)) return;
|
||||
|
||||
float seconds = best.IsBoss() ? AlfarPowerConfig.StasisBossSeconds.Value : AlfarPowerConfig.StasisSeconds.Value;
|
||||
AlfarStasis.Apply(best, seconds);
|
||||
StartCooldown("kyrr", AlfarPowerConfig.StasisCooldown.Value);
|
||||
AlfarFx.Spawn("fx_JotunWitch_LightningBolt_Explosion", best.GetCenterPoint());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A storm on the ground that strikes every hostile creature inside it, twice a second.</summary>
|
||||
public class AlfarStormZone : MonoBehaviour
|
||||
{
|
||||
public Player Owner;
|
||||
public float Radius;
|
||||
public float Seconds;
|
||||
public float DamagePerSecond;
|
||||
|
||||
private float born;
|
||||
private float nextTick;
|
||||
private Light glow;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
born = Time.time;
|
||||
glow = gameObject.AddComponent<Light>();
|
||||
glow.color = AlfarPowerConfig.ArchonColor.Value;
|
||||
glow.range = Radius * 1.5f;
|
||||
glow.intensity = 2f;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Owner == null || Time.time - born >= Seconds) { Destroy(gameObject); return; }
|
||||
if (Time.time < nextTick) return;
|
||||
|
||||
const float tick = 0.5f;
|
||||
nextTick = Time.time + tick;
|
||||
|
||||
foreach (Collider collider in Physics.OverlapSphere(transform.position, Radius, ~0, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
Character character = collider.GetComponentInParent<Character>();
|
||||
if (character == null || character == Owner || character.IsDead() || character.IsTamed()) continue;
|
||||
if (!BaseAI.IsEnemy(Owner, character)) continue;
|
||||
AlfarPowers.Strike(Owner, character, DamagePerSecond * tick, character.GetCenterPoint());
|
||||
}
|
||||
|
||||
Vector2 offset = Random.insideUnitCircle * Radius;
|
||||
AlfarFx.Spawn("fx_JotunWitch_LightningBolt_Explosion", transform.position + new Vector3(offset.x, 0f, offset.y));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Holds a creature still and untouchable for a few seconds (Kyrr). Frozen means the AI is off, the
|
||||
/// animator stopped and the body locked; untouchable is the prefix at the bottom, which cancels
|
||||
/// every blow on a creature that carries this. Everything is put back when it runs out.
|
||||
/// </summary>
|
||||
public class AlfarStasis : MonoBehaviour
|
||||
{
|
||||
private float until;
|
||||
private Animator animator;
|
||||
private float animatorSpeed;
|
||||
private MonoBehaviour ai;
|
||||
private Rigidbody body;
|
||||
private RigidbodyConstraints constraints;
|
||||
|
||||
public static void Apply(Character target, float seconds)
|
||||
{
|
||||
AlfarStasis existing = target.GetComponent<AlfarStasis>();
|
||||
if (existing != null) { existing.until = Time.time + seconds; return; }
|
||||
|
||||
ZNetView nview = target.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid()) nview.ClaimOwnership();
|
||||
|
||||
AlfarStasis stasis = target.gameObject.AddComponent<AlfarStasis>();
|
||||
stasis.until = Time.time + seconds;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
animator = GetComponentInChildren<Animator>();
|
||||
if (animator != null) { animatorSpeed = animator.speed; animator.speed = 0f; }
|
||||
|
||||
ai = GetComponent<BaseAI>();
|
||||
if (ai != null) ai.enabled = false;
|
||||
|
||||
body = GetComponent<Rigidbody>();
|
||||
if (body != null)
|
||||
{
|
||||
constraints = body.constraints;
|
||||
body.linearVelocity = Vector3.zero;
|
||||
body.constraints = RigidbodyConstraints.FreezeAll;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Time.time >= until) Destroy(this);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (animator != null) animator.speed = animatorSpeed;
|
||||
if (ai != null) ai.enabled = true;
|
||||
if (body != null) body.constraints = constraints;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Character), "ApplyDamage",
|
||||
new[] { typeof(HitData), typeof(bool), typeof(bool), typeof(HitData.DamageModifier) })]
|
||||
public static class Alfar_Stasis_Patch
|
||||
{
|
||||
public static void Prefix(Character __instance, HitData __0)
|
||||
{
|
||||
if (__0 != null && __instance != null && __instance.GetComponent<AlfarStasis>() != null)
|
||||
{
|
||||
__0.m_damage = default(HitData.DamageTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Spawns a vanilla effect prefab by name, and says nothing if the name is not there.</summary>
|
||||
public static class AlfarFx
|
||||
{
|
||||
public static void Spawn(string prefabName, Vector3 position)
|
||||
{
|
||||
if (ZNetScene.instance == null) return;
|
||||
GameObject prefab = ZNetScene.instance.GetPrefab(prefabName);
|
||||
if (prefab == null) return;
|
||||
Object.Instantiate(prefab, position, Quaternion.identity);
|
||||
}
|
||||
}
|
||||
}
|
||||
434
JotunnModStub/Alfar/AlfarProbe.cs
Normal file
434
JotunnModStub/Alfar/AlfarProbe.cs
Normal file
|
|
@ -0,0 +1,434 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The Alfar probe: reads the live prefabs the design leans on, because Mono.Cecil only shows
|
||||
/// field NAMES and never the values baked into a prefab (Alfar_Progettazione.txt, sec. 16B V11).
|
||||
///
|
||||
/// Nothing here instantiates a prefab, so no AI or Awake logic runs. Everything goes to the
|
||||
/// BepInEx log under an [AlfarProbe] prefix; the console only says it finished.
|
||||
///
|
||||
/// alfarprobe EVERYTHING: every default target, the lightning table, and who
|
||||
/// references Softtissue and Crystal
|
||||
/// alfarprobe <prefab> just that prefab (names are the manifest's, case sensitive)
|
||||
/// alfarprobe lightning just the table of how every creature takes lightning damage
|
||||
///
|
||||
/// WHAT EACH TARGET ANSWERS, so the log can be read against the design rather than around it:
|
||||
/// Deathsquito are the legs and stinger separate objects (they are meant to be removed),
|
||||
/// where the buzz lives, which materials the eyes and wings use
|
||||
/// Surtling whether it is particles and lights or textures (decides how to recolour it)
|
||||
/// StoneGolem attacks, area attacks, hp: the numbers the construct copies
|
||||
/// Abomination whether it is a Humanoid with item attacks, and its hp and damage
|
||||
/// piece_Charred_Balista whether it is a Piece with WearNTear and a Turret, and what it
|
||||
/// needs to be built (sec. 8.6: it may only be the ballista a camp spawns)
|
||||
/// ancient_skull what it is (MineRock5, Destructible...) and what it drops (soft tissue?)
|
||||
/// eitrrefinery its conversion list: what really turns sap into refined eitr
|
||||
/// Beehive m_secPerUnit and m_maxHoney, which the crystal timer is defined from
|
||||
/// Dverger staffs the projectile the Abomination's sphere will be cloned from
|
||||
/// </summary>
|
||||
public class AlfarProbeCommand : ConsoleCommand
|
||||
{
|
||||
public override string Name => "alfarprobe";
|
||||
|
||||
public override string Help =>
|
||||
"[DEBUG] alfarprobe [prefab|lightning] - logs the live prefab data the Alfar design needs " +
|
||||
"(hierarchy, components, drops, attacks, lightning resistances) to the BepInEx log.";
|
||||
|
||||
private static readonly string[] DefaultTargets =
|
||||
{
|
||||
"Deathsquito", "Deathsquito_sting",
|
||||
"Surtling", "StoneGolem", "Abomination",
|
||||
"piece_Charred_Balista", "ancient_skull", "giant_skull",
|
||||
"eitrrefinery", "Beehive", "piece_beehive", "piece_sapcollector",
|
||||
"giant_skull_frac", "rock4_forest_frac", "giant_brain", "giant_brain_frac",
|
||||
"DvergerStaffFire_fireball_projectile", "DvergerStaffIce_projectile",
|
||||
"Pickable_Mushroom_Magecap", "Pickable_Mushroom_JotunPuffs", "sapling_magecap",
|
||||
};
|
||||
|
||||
// Components whose public fields are worth printing in full. Anything else is only listed by name.
|
||||
private static readonly HashSet<string> Interesting = new HashSet<string>
|
||||
{
|
||||
"Character", "Humanoid", "MonsterAI", "BaseAI", "CharacterDrop", "Tameable",
|
||||
"Piece", "WearNTear", "Turret", "ZNetView",
|
||||
"Destructible", "MineRock5", "MineRock", "DropOnDestroyed", "Pickable", "Plant",
|
||||
"Beehive", "Smelter", "CookingStation", "Fermenter", "Container",
|
||||
"Projectile", "Aoe", "ItemDrop", "ZSyncAnimation", "CharacterAnimEvent",
|
||||
};
|
||||
|
||||
// For these the private fields are printed as well, because the interesting data (default
|
||||
// items, attack timings) is private. Only fields declared on the type itself, to skip noise.
|
||||
private static readonly HashSet<string> WithPrivate = new HashSet<string>
|
||||
{
|
||||
"Humanoid", "MonsterAI", "BaseAI", "Character",
|
||||
};
|
||||
|
||||
public override void Run(string[] args)
|
||||
{
|
||||
if (args.Length > 0 && args[0].ToLower() == "lightning")
|
||||
{
|
||||
DumpLightningTable();
|
||||
Console.instance.Print("[AlfarProbe] lightning table written to the BepInEx log.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length > 1 && args[0].ToLower() == "whodrops")
|
||||
{
|
||||
WhoDrops(args[1]);
|
||||
Console.instance.Print($"[AlfarProbe] whodrops {args[1]} written to the BepInEx log.");
|
||||
return;
|
||||
}
|
||||
|
||||
string[] targets = args.Length > 0 ? args : DefaultTargets;
|
||||
foreach (string name in targets)
|
||||
{
|
||||
DumpPrefab(name);
|
||||
}
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
// The no-argument form is the WHOLE probe in one go: every default prefab, the
|
||||
// lightning table, and who references soft tissue and crystals (the two drops the
|
||||
// design could not place from the prefabs alone).
|
||||
DumpLightningTable();
|
||||
WhoDrops("Softtissue");
|
||||
WhoDrops("Crystal");
|
||||
}
|
||||
Console.instance.Print($"[AlfarProbe] done, {targets.Length} prefab(s). Read BepInEx/LogOutput.log.");
|
||||
}
|
||||
|
||||
private static void Log(string line) => Jotunn.Logger.LogInfo("[AlfarProbe] " + line);
|
||||
|
||||
private static GameObject Find(string name)
|
||||
{
|
||||
GameObject found = ZNetScene.instance != null ? ZNetScene.instance.GetPrefab(name) : null;
|
||||
if (found != null) return found;
|
||||
return PrefabManager.Cache.GetPrefab<GameObject>(name);
|
||||
}
|
||||
|
||||
// ─── One prefab ──────────────────────────────────────────────────────
|
||||
|
||||
private static void DumpPrefab(string name)
|
||||
{
|
||||
GameObject prefab = Find(name);
|
||||
Log($"==================== {name} ====================");
|
||||
if (prefab == null)
|
||||
{
|
||||
Log("NOT FOUND by ZNetScene or the prefab cache. Check the spelling against the manifest, " +
|
||||
"and note an _res/ prefab may not be registered at all (Alfar doc sec. 8.6).");
|
||||
return;
|
||||
}
|
||||
|
||||
Log($"root '{prefab.name}' scale={prefab.transform.localScale}");
|
||||
DumpHierarchy(prefab.transform, "", 0);
|
||||
|
||||
foreach (Component component in prefab.GetComponentsInChildren<Component>(true))
|
||||
{
|
||||
if (component == null) continue;
|
||||
string typeName = component.GetType().Name;
|
||||
if (!Interesting.Contains(typeName)) continue;
|
||||
|
||||
Log($"--- {typeName} on '{PathOf(component.transform, prefab.transform)}'");
|
||||
DumpFields(component, WithPrivate.Contains(typeName));
|
||||
}
|
||||
|
||||
DumpDefaultItems(prefab);
|
||||
}
|
||||
|
||||
private static void DumpHierarchy(Transform node, string indent, int depth)
|
||||
{
|
||||
if (depth > 9) { Log($"{indent}... (deeper than 9 levels)"); return; }
|
||||
|
||||
var parts = new List<string>();
|
||||
foreach (Component c in node.GetComponents<Component>())
|
||||
{
|
||||
if (c == null || c is Transform) continue;
|
||||
parts.Add(c.GetType().Name);
|
||||
}
|
||||
string pos = node.localPosition == Vector3.zero ? "" : $" pos={node.localPosition}";
|
||||
string scale = node.localScale == Vector3.one ? "" : $" scale={node.localScale}";
|
||||
Log($"{indent}{node.name}{(node.gameObject.activeSelf ? "" : " [INACTIVE]")}{pos}{scale}" +
|
||||
(parts.Count > 0 ? " <" + string.Join(", ", parts) + ">" : ""));
|
||||
|
||||
Renderer renderer = node.GetComponent<Renderer>();
|
||||
if (renderer != null)
|
||||
{
|
||||
foreach (Material m in renderer.sharedMaterials)
|
||||
{
|
||||
if (m == null) continue;
|
||||
Log($"{indent} material '{m.name}' shader='{(m.shader != null ? m.shader.name : "null")}'" +
|
||||
$" color={(m.HasProperty("_Color") ? m.GetColor("_Color").ToString() : "-")}" +
|
||||
$" emission={(m.HasProperty("_EmissionColor") ? m.GetColor("_EmissionColor").ToString() : "-")}");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Transform child in node)
|
||||
{
|
||||
DumpHierarchy(child, indent + " ", depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Generic field reader ────────────────────────────────────────────
|
||||
|
||||
private static void DumpFields(object target, bool includePrivate)
|
||||
{
|
||||
Type type = target.GetType();
|
||||
|
||||
// The first probe printed only the fields DECLARED on Humanoid and MonsterAI and so never
|
||||
// showed Character's (hp, faction, flying, damage modifiers) or BaseAI's. Walk up the
|
||||
// chain and print the public fields of every base too, private ones only on the leaf.
|
||||
for (Type level = type; level != null && level != typeof(MonoBehaviour) && level != typeof(Behaviour); level = level.BaseType)
|
||||
{
|
||||
bool leaf = level == type;
|
||||
BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly;
|
||||
if (includePrivate && leaf) flags |= BindingFlags.NonPublic;
|
||||
if (!leaf) Log($" -- inherited from {level.Name}");
|
||||
DumpLevel(target, level, flags);
|
||||
}
|
||||
}
|
||||
|
||||
private static void DumpLevel(object target, Type type, BindingFlags flags)
|
||||
{
|
||||
foreach (FieldInfo field in type.GetFields(flags))
|
||||
{
|
||||
// Runtime state, not prefab data: nothing there to learn and lots of it.
|
||||
if (field.FieldType == typeof(ZNetView) && field.IsPrivate) continue;
|
||||
object value;
|
||||
try { value = field.GetValue(target); }
|
||||
catch (Exception) { continue; }
|
||||
|
||||
string text = Describe(value, 0);
|
||||
if (text == null) continue;
|
||||
Log($" {field.Name} = {text}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A short readable form of a field value, or null when it is not worth a line (null, empty,
|
||||
/// zero). Objects are shown by name only: this is a probe, not a serialiser.
|
||||
/// </summary>
|
||||
private static string Describe(object value, int depth)
|
||||
{
|
||||
if (value == null) return null;
|
||||
|
||||
if (value is UnityEngine.Object unityObject)
|
||||
{
|
||||
return unityObject == null ? null : $"'{unityObject.name}' ({unityObject.GetType().Name})";
|
||||
}
|
||||
if (value is string s) return s.Length == 0 ? null : "'" + s + "'";
|
||||
|
||||
Type t = value.GetType();
|
||||
if (t.IsEnum) return value.ToString();
|
||||
if (t.IsPrimitive)
|
||||
{
|
||||
if (value is bool b) return b ? "true" : "false";
|
||||
string number = value.ToString();
|
||||
return number == "0" ? null : number;
|
||||
}
|
||||
if (value is Vector2 || value is Vector3 || value is Color || value is Quaternion || value is Vector4)
|
||||
{
|
||||
return value.ToString();
|
||||
}
|
||||
|
||||
if (depth >= 2) return $"({t.Name})";
|
||||
|
||||
if (value is IList list)
|
||||
{
|
||||
if (list.Count == 0) return null;
|
||||
var items = new List<string>();
|
||||
foreach (object item in list.Cast<object>().Take(24))
|
||||
{
|
||||
string d = Describe(item, depth + 1);
|
||||
if (d != null) items.Add(d);
|
||||
}
|
||||
return $"[{list.Count}] " + string.Join("; ", items);
|
||||
}
|
||||
|
||||
// A plain struct or class: print the fields that carry something.
|
||||
var inner = new List<string>();
|
||||
foreach (FieldInfo f in t.GetFields(BindingFlags.Instance | BindingFlags.Public))
|
||||
{
|
||||
object fv;
|
||||
try { fv = f.GetValue(value); }
|
||||
catch (Exception) { continue; }
|
||||
string d = Describe(fv, depth + 1);
|
||||
if (d != null) inner.Add($"{f.Name}={d}");
|
||||
}
|
||||
return inner.Count == 0 ? null : "{" + string.Join(", ", inner) + "}";
|
||||
}
|
||||
|
||||
// ─── What a creature actually attacks with ───────────────────────────
|
||||
|
||||
private static void DumpDefaultItems(GameObject prefab)
|
||||
{
|
||||
Humanoid humanoid = prefab.GetComponent<Humanoid>();
|
||||
if (humanoid == null) return;
|
||||
|
||||
Log("--- DEFAULT ITEMS (Humanoid.m_defaultItems / m_randomWeapon / m_unarmedWeapon)");
|
||||
var items = new List<GameObject>();
|
||||
AddAll(items, Read<GameObject[]>(humanoid, "m_defaultItems"));
|
||||
AddAll(items, Read<GameObject[]>(humanoid, "m_randomWeapon"));
|
||||
ItemDrop unarmed = Read<ItemDrop>(humanoid, "m_unarmedWeapon");
|
||||
if (unarmed != null) items.Add(unarmed.gameObject);
|
||||
|
||||
// The StoneGolem carries its weapons in random SETS (Spike, Sledge), which the first probe
|
||||
// never looked at: m_defaultItems was empty and it said "none".
|
||||
IList sets = Read<IList>(humanoid, "m_randomSets");
|
||||
if (sets != null)
|
||||
{
|
||||
foreach (object set in sets)
|
||||
{
|
||||
GameObject[] setItems = Read<GameObject[]>(set, "m_items");
|
||||
AddAll(items, setItems);
|
||||
}
|
||||
}
|
||||
|
||||
if (items.Count == 0) { Log(" (none)"); return; }
|
||||
|
||||
foreach (GameObject item in items.Distinct())
|
||||
{
|
||||
ItemDrop drop = item.GetComponent<ItemDrop>();
|
||||
if (drop == null || drop.m_itemData == null || drop.m_itemData.m_shared == null) continue;
|
||||
|
||||
ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
|
||||
Log($" weapon '{item.name}' ({shared.m_name}) damages={shared.m_damages}");
|
||||
LogAttack("primary", shared.m_attack);
|
||||
LogAttack("secondary", shared.m_secondaryAttack);
|
||||
}
|
||||
}
|
||||
|
||||
private static void LogAttack(string label, Attack attack)
|
||||
{
|
||||
if (attack == null) return;
|
||||
Log($" {label}: {Describe(attack, 0)}");
|
||||
}
|
||||
|
||||
private static T Read<T>(object target, string field) where T : class
|
||||
{
|
||||
FieldInfo info = target.GetType().GetField(field,
|
||||
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
return info != null ? info.GetValue(target) as T : null;
|
||||
}
|
||||
|
||||
private static void AddAll(List<GameObject> into, GameObject[] source)
|
||||
{
|
||||
if (source == null) return;
|
||||
foreach (GameObject go in source) if (go != null) into.Add(go);
|
||||
}
|
||||
|
||||
private static string PathOf(Transform node, Transform root)
|
||||
{
|
||||
if (node == root) return node.name;
|
||||
var names = new List<string>();
|
||||
for (Transform t = node; t != null && t != root; t = t.parent) names.Add(t.name);
|
||||
names.Reverse();
|
||||
return root.name + "/" + string.Join("/", names);
|
||||
}
|
||||
|
||||
// ─── Who drops an item ───────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Finds every prefab with a component that REFERENCES the named item: a drop table, a pickable,
|
||||
/// a destructible, a creature's loot. Written for soft tissue, which the design says comes from
|
||||
/// the Mistlands ancient skulls while the skull prefab itself drops nothing (probe 1): the drop
|
||||
/// has to be somewhere else, probably in the fragments the skull spawns when destroyed.
|
||||
/// </summary>
|
||||
private static void WhoDrops(string itemName)
|
||||
{
|
||||
Log($"==================== WHO REFERENCES '{itemName}' ====================");
|
||||
if (ZNetScene.instance == null)
|
||||
{
|
||||
Log("ZNetScene is not up: load a world and run it again.");
|
||||
return;
|
||||
}
|
||||
|
||||
int hits = 0;
|
||||
foreach (GameObject prefab in ZNetScene.instance.m_prefabs)
|
||||
{
|
||||
if (prefab == null || prefab.name == itemName) continue;
|
||||
foreach (Component component in prefab.GetComponentsInChildren<Component>(true))
|
||||
{
|
||||
if (component == null || component is Transform || component is ItemDrop) continue;
|
||||
if (References(component, itemName, 0)) { Log($"{prefab.name} :: {component.GetType().Name} on '{component.name}'"); hits++; }
|
||||
}
|
||||
}
|
||||
Log($"{hits} reference(s) to '{itemName}'.");
|
||||
}
|
||||
|
||||
private static bool References(object value, string itemName, int depth)
|
||||
{
|
||||
if (value == null || depth > 3) return false;
|
||||
|
||||
foreach (FieldInfo field in value.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public))
|
||||
{
|
||||
object fieldValue;
|
||||
try { fieldValue = field.GetValue(value); }
|
||||
catch (Exception) { continue; }
|
||||
if (fieldValue == null) continue;
|
||||
|
||||
if (fieldValue is UnityEngine.Object unityObject)
|
||||
{
|
||||
if (unityObject != null && unityObject.name == itemName) return true;
|
||||
continue;
|
||||
}
|
||||
|
||||
Type t = fieldValue.GetType();
|
||||
if (t.IsPrimitive || t.IsEnum || fieldValue is string) continue;
|
||||
|
||||
if (fieldValue is IList list)
|
||||
{
|
||||
foreach (object item in list)
|
||||
{
|
||||
if (item is UnityEngine.Object o) { if (o != null && o.name == itemName) return true; }
|
||||
else if (item != null && !item.GetType().IsPrimitive && References(item, itemName, depth + 1)) return true;
|
||||
}
|
||||
}
|
||||
else if (!t.IsAbstract && t.Namespace == null && References(fieldValue, itemName, depth + 1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ─── How every creature takes lightning ──────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// The constructs deal lightning, so a creature that resists or is immune to it resists the
|
||||
/// constructs (Alfar doc sec. 17.13). This is the table to read before pricing them.
|
||||
/// </summary>
|
||||
private static void DumpLightningTable()
|
||||
{
|
||||
Log("==================== LIGHTNING TABLE ====================");
|
||||
if (ZNetScene.instance == null)
|
||||
{
|
||||
Log("ZNetScene is not up (you are in the menu): load a world and run `alfarprobe lightning`.");
|
||||
return;
|
||||
}
|
||||
|
||||
var rows = new List<string>();
|
||||
foreach (GameObject prefab in ZNetScene.instance.m_prefabs)
|
||||
{
|
||||
if (prefab == null) continue;
|
||||
Character character = prefab.GetComponent<Character>();
|
||||
if (character == null) continue;
|
||||
|
||||
rows.Add($"{prefab.name,-28} faction={character.m_faction,-12} hp={character.m_health,7:0} " +
|
||||
$"boss={(character.m_boss ? "Y" : "n")} lightning={character.m_damageModifiers.m_lightning} " +
|
||||
$"fire={character.m_damageModifiers.m_fire} spirit={character.m_damageModifiers.m_spirit}");
|
||||
}
|
||||
|
||||
rows.Sort(StringComparer.Ordinal);
|
||||
foreach (string row in rows) Log(row);
|
||||
Log($"{rows.Count} creatures. Anything not 'Normal' under lightning is resistant, weak or immune.");
|
||||
}
|
||||
}
|
||||
}
|
||||
40
JotunnModStub/Alfar/AlfarRace.cs
Normal file
40
JotunnModStub/Alfar/AlfarRace.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The Alfar: light-bodied casters whose one resource is eitr (Alfar_Progettazione.txt).
|
||||
///
|
||||
/// Only the race check lives here for now. The shield, the death timer, the powers and the
|
||||
/// Nexus each get their own file as they are written; the look is AlfarVisuals and its patches.
|
||||
/// </summary>
|
||||
public static class AlfarRace
|
||||
{
|
||||
/// <summary>
|
||||
/// Everything the race registers with Jotunn. Called from RacesOfValheim.CreateAllModAssets,
|
||||
/// which runs on PrefabManager.OnVanillaPrefabsAvailable: the one moment Jotunn takes new
|
||||
/// status effects, items and prefabs into ObjectDB. Registered later, nothing can spawn.
|
||||
/// </summary>
|
||||
public static void CreateModAssets()
|
||||
{
|
||||
AlfarStatusEffects.Register();
|
||||
AlfarDrones.Register();
|
||||
AlfarConstructs.Register();
|
||||
AlfarSigil.Register();
|
||||
AlfarNexus.Register();
|
||||
AlfarChests.Register();
|
||||
AlfarLjosgard.Register();
|
||||
AlfarTowers.Register();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The local player's race, read from m_customData like every other race's IsXxx() (guide
|
||||
/// 5.4: never from the body model index, which is not a race).
|
||||
/// </summary>
|
||||
public static bool IsLocalAlfar()
|
||||
{
|
||||
Player player = Player.m_localPlayer;
|
||||
return player != null &&
|
||||
player.m_customData.TryGetValue("Race", out string race) &&
|
||||
race == AlfarConfig.RaceId;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
239
JotunnModStub/Alfar/AlfarTowers.cs
Normal file
239
JotunnModStub/Alfar/AlfarTowers.cs
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
using HarmonyLib;
|
||||
using Jotunn.Configs;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The PRISMAVARD, the Alfar's towers (Alfar_Progettazione.txt sec. 8.6): the charred ballista of the
|
||||
/// Ashlands, smaller and bronze, turned around to defend. Read from the live prefab (doc 16C P5):
|
||||
///
|
||||
/// - it is NOT a Piece: it has Turret, WearNTear and DropOnDestroyed and nothing that lets the
|
||||
/// hammer place it, so a Piece is added here;
|
||||
/// - it is an ENEMY tower: it targets players and tamed creatures and not enemies, so the three
|
||||
/// flags are turned round;
|
||||
/// - m_maxAmmo is 0 and HasAmmo() is true when it is 0 (read in the IL): the vanilla tower has
|
||||
/// infinite ammunition, so "consumes nothing" is free; what is changed is the AMMO, a bolt that
|
||||
/// does lightning, so the shot is ours.
|
||||
///
|
||||
/// It only works inside a Ljoskjarne's radius (AlfarTower switches the Turret off outside it), has a
|
||||
/// shield equal to its health that returns by itself, and is repaired with the hammer and by the
|
||||
/// drones like any building.
|
||||
/// </summary>
|
||||
public static class AlfarTowers
|
||||
{
|
||||
public const string PieceName = "AlfarPrismavard";
|
||||
public const string PieceDisplay = "$rov_piece_alfar_prismavard_name";
|
||||
public const string AmmoName = "AlfarPrismBolt";
|
||||
public const string ProjectileName = "AlfarPrismProjectile";
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
GameObject source = PrefabManager.Cache.GetPrefab<GameObject>("piece_Charred_Balista");
|
||||
if (source == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] No 'piece_Charred_Balista': the Prismavard is not registered.");
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PieceName, source);
|
||||
if (prefab == null) return;
|
||||
|
||||
Turret turret = prefab.GetComponent<Turret>();
|
||||
if (turret == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] The charred ballista has no Turret component: no Prismavard.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Turned around: it defends the base against enemies and never at players or their tames.
|
||||
turret.m_targetPlayers = false;
|
||||
turret.m_targetTamed = false;
|
||||
turret.m_targetEnemies = true;
|
||||
turret.m_returnAmmoOnDestroy = false;
|
||||
|
||||
// The ammunition: a bolt that does lightning, shot from a projectile that spares friends
|
||||
// and buildings. m_maxAmmo stays 0, which means infinite.
|
||||
GameObject ammo = RegisterAmmo(turret);
|
||||
if (ammo != null)
|
||||
{
|
||||
ItemDrop ammoDrop = ammo.GetComponent<ItemDrop>();
|
||||
turret.m_defaultAmmo = ammoDrop;
|
||||
if (turret.m_allowedAmmo != null && turret.m_allowedAmmo.Count > 0)
|
||||
{
|
||||
var allowed = turret.m_allowedAmmo[0];
|
||||
allowed.m_ammo = ammoDrop;
|
||||
turret.m_allowedAmmo[0] = allowed;
|
||||
}
|
||||
}
|
||||
|
||||
WearNTear wear = prefab.GetComponent<WearNTear>();
|
||||
if (wear != null) wear.m_health *= AlfarNexusConfig.TowerHealthFactor.Value;
|
||||
|
||||
// The loot of an enemy ballista: a tower of ours must not be a way to farm it.
|
||||
foreach (DropOnDestroyed drop in prefab.GetComponentsInChildren<DropOnDestroyed>(true))
|
||||
{
|
||||
if (drop != null) Object.DestroyImmediate(drop);
|
||||
}
|
||||
|
||||
prefab.transform.localScale = Vector3.one * AlfarNexusConfig.TowerScale.Value;
|
||||
ZNetView nview = prefab.GetComponent<ZNetView>();
|
||||
if (nview != null) nview.m_syncInitialScale = true;
|
||||
|
||||
AlfarConstructs.Tint(prefab, new Color(0.85f, 0.58f, 0.28f, 1f));
|
||||
|
||||
AlfarMark mark = prefab.AddComponent<AlfarMark>();
|
||||
mark.Role = "tower";
|
||||
|
||||
AlfarPieceShield shield = prefab.AddComponent<AlfarPieceShield>();
|
||||
shield.Max = wear != null ? wear.m_health : 100f;
|
||||
shield.Shield = shield.Max;
|
||||
|
||||
prefab.AddComponent<AlfarTower>();
|
||||
|
||||
Sprite icon = AlfarNexus.BorrowIcon("Crystal") ?? AlfarNexus.BorrowIcon("Bronze");
|
||||
|
||||
Piece piece = prefab.GetComponent<Piece>() ?? prefab.AddComponent<Piece>();
|
||||
piece.m_craftingStation = null;
|
||||
piece.m_resources = new Piece.Requirement[0];
|
||||
piece.m_name = PieceDisplay;
|
||||
piece.m_canBeRemoved = true;
|
||||
piece.m_icon = icon;
|
||||
piece.m_groundOnly = false;
|
||||
piece.m_groundPiece = false;
|
||||
|
||||
Piece template = PrefabManager.Cache.GetPrefab<Piece>("piece_workbench");
|
||||
if (template != null && template.m_placeEffect != null) piece.m_placeEffect = template.m_placeEffect;
|
||||
|
||||
PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig
|
||||
{
|
||||
Name = PieceDisplay,
|
||||
Description = "$rov_piece_alfar_prismavard_desc",
|
||||
PieceTable = PieceTables.Hammer,
|
||||
Category = PieceCategories.Misc,
|
||||
Icon = icon,
|
||||
Requirements = new[]
|
||||
{
|
||||
new RequirementConfig("Bronze", AlfarNexusConfig.TowerBronze.Value, 0, true),
|
||||
new RequirementConfig("Crystal", AlfarNexusConfig.TowerCrystal.Value, 0, true),
|
||||
},
|
||||
}));
|
||||
|
||||
// No cap on how many (the user said so), but one rule: inside a Ljoskjarne's radius.
|
||||
PieceDensityLimit.RegisterGate(PieceName, (player, position) =>
|
||||
{
|
||||
if (!AlfarRace.IsLocalAlfar())
|
||||
{
|
||||
if (player != null) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_only_alfar"));
|
||||
return false;
|
||||
}
|
||||
if (AlfarNexusBehaviour.Covering(position) == null)
|
||||
{
|
||||
if (player != null) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_tower_needs_nexus"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
AlfarPieces.Extra.Add(PieceName);
|
||||
}
|
||||
|
||||
private static GameObject RegisterAmmo(Turret turret)
|
||||
{
|
||||
ItemDrop original = turret.m_defaultAmmo;
|
||||
if (original == null)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] The ballista has no default ammo to copy.");
|
||||
return null;
|
||||
}
|
||||
|
||||
GameObject ammo = PrefabManager.Instance.CreateClonedPrefab(AmmoName, original.gameObject);
|
||||
if (ammo == null) return null;
|
||||
|
||||
ItemDrop drop = ammo.GetComponent<ItemDrop>();
|
||||
ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
|
||||
shared.m_name = "$rov_item_alfar_prismbolt_name";
|
||||
|
||||
HitData.DamageTypes damage = default(HitData.DamageTypes);
|
||||
damage.m_lightning = AlfarNexusConfig.TowerDamage.Value;
|
||||
shared.m_damages = damage;
|
||||
|
||||
// The projectile it flies as: a copy that spares friends and buildings.
|
||||
GameObject originalProjectile = shared.m_attack != null ? shared.m_attack.m_attackProjectile : null;
|
||||
if (originalProjectile != null)
|
||||
{
|
||||
GameObject projectile = PrefabManager.Instance.CreateClonedPrefab(ProjectileName, originalProjectile);
|
||||
Projectile settings = projectile != null ? projectile.GetComponent<Projectile>() : null;
|
||||
if (settings != null)
|
||||
{
|
||||
settings.m_hitFriendly = false;
|
||||
settings.m_noDamageFriendly = true;
|
||||
settings.m_aoeSkipWearNTear = true;
|
||||
PrefabManager.Instance.AddPrefab(projectile);
|
||||
shared.m_attack.m_attackProjectile = projectile;
|
||||
}
|
||||
}
|
||||
|
||||
ItemManager.Instance.AddItem(new CustomItem(ammo, fixReference: false));
|
||||
return ammo;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The tower runs only while a Ljoskjarne's radius covers it: outside, the Turret is off.</summary>
|
||||
public class AlfarTower : MonoBehaviour
|
||||
{
|
||||
private Turret turret;
|
||||
private float nextCheck;
|
||||
|
||||
private void Awake() { turret = GetComponent<Turret>(); }
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (turret == null || Time.time < nextCheck) return;
|
||||
nextCheck = Time.time + 2f;
|
||||
|
||||
bool powered = AlfarNexusBehaviour.Covering(transform.position) != null;
|
||||
if (turret.enabled != powered) turret.enabled = powered;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A building's shield: equal to its health, back at 1% a second after five quiet seconds. Its own
|
||||
/// absorption on WearNTear.ApplyDamage, the stage every blow on a building ends in; the hammer and
|
||||
/// the drones repair the HEALTH, the shield returns by itself.
|
||||
/// </summary>
|
||||
public class AlfarPieceShield : MonoBehaviour
|
||||
{
|
||||
public float Max;
|
||||
public float Shield;
|
||||
|
||||
private float lastHit = -999f;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Shield >= Max || Time.time - lastHit < 5f) return;
|
||||
Shield = Mathf.Min(Max, Shield + Max * 0.01f * Time.deltaTime);
|
||||
}
|
||||
|
||||
public float Absorb(float damage)
|
||||
{
|
||||
if (damage <= 0f) return damage;
|
||||
lastHit = Time.time;
|
||||
float absorbed = Mathf.Min(Shield, damage);
|
||||
Shield -= absorbed;
|
||||
return damage - absorbed;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(WearNTear), "ApplyDamage")]
|
||||
public static class Alfar_PieceShield_Patch
|
||||
{
|
||||
public static void Prefix(WearNTear __instance, ref float __0)
|
||||
{
|
||||
AlfarPieceShield shield = __instance != null ? __instance.GetComponent<AlfarPieceShield>() : null;
|
||||
if (shield != null) __0 = shield.Absorb(__0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
495
JotunnModStub/Alfar/AlfarVisuals.cs
Normal file
495
JotunnModStub/Alfar/AlfarVisuals.cs
Normal file
|
|
@ -0,0 +1,495 @@
|
|||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// What an Alfr looks like (Alfar_Progettazione.txt sec. 7): ash-grey skin, five percent taller
|
||||
/// and a little thinner than a Viking, no hair, no beard, and two completely black eyes.
|
||||
///
|
||||
/// Everything here is written the way the Sverm and the Dvergar already write theirs, because
|
||||
/// each of those shapes cost somebody a test session:
|
||||
/// - the race is read off the ZDO, so remote players render right, falling back to
|
||||
/// m_customData for the menu preview (same shape as SvermVisuals.GetPlayerRace);
|
||||
/// - the skin is written AFTER Valheim rebuilds the body material (see AlfarPatches);
|
||||
/// - the scale goes on the "Visual" child and never the root, and only ever undoes its own;
|
||||
/// - the eyes are spheres on the head bone with every offset divided by lossyScale, because
|
||||
/// the player armature is authored at scale 100.
|
||||
///
|
||||
/// The eyes are the Sverm's spheres with the glow taken out: same geometry, a matte black
|
||||
/// material, no emission at all.
|
||||
/// </summary>
|
||||
public static class AlfarVisuals
|
||||
{
|
||||
private const string EyesName = "AlfarEyes";
|
||||
private const string HeadBoneName = "Head";
|
||||
|
||||
// ─── Race check ──────────────────────────────────────────────────────
|
||||
|
||||
public static string GetPlayerRace(Player player)
|
||||
{
|
||||
if (player == null) return "Human";
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid())
|
||||
{
|
||||
string race = nview.GetZDO().GetString("RacesOfValheim_Race", "");
|
||||
if (!string.IsNullOrEmpty(race)) return race;
|
||||
}
|
||||
|
||||
if (player.m_customData != null && player.m_customData.TryGetValue("Race", out string custom))
|
||||
{
|
||||
return custom;
|
||||
}
|
||||
|
||||
return "Human";
|
||||
}
|
||||
|
||||
public static bool IsAlfarPlayer(Player player) => GetPlayerRace(player) == AlfarConfig.RaceId;
|
||||
|
||||
// ─── Scale ───────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// +5% in height and a little less wide. NON-uniform, so the scale is a Vector3 and not the
|
||||
/// single float the other races write.
|
||||
///
|
||||
/// The reset only ever undoes a scale that looks like ours: another race (the Trol, the
|
||||
/// Dvergar) may be sizing this player and RaceScale exists so the two do not fight.
|
||||
/// </summary>
|
||||
public static void ApplyScale(Player player, bool isAlfar)
|
||||
{
|
||||
if (player == null) return;
|
||||
|
||||
GameObject visual = Traverse.Create(player).Field("m_visual").GetValue<GameObject>();
|
||||
if (visual == null) return;
|
||||
|
||||
Vector3 ours = new Vector3(AlfarConfig.WidthScale.Value, AlfarConfig.HeightScale.Value, AlfarConfig.WidthScale.Value);
|
||||
|
||||
// The archon form is bigger: published in the ZDO, so every client sizes it the same.
|
||||
Vector3 archon = ours * AlfarPowerConfig.ArchonScale.Value;
|
||||
bool inArchon = isAlfar && AlfarArchon.IsArchon(player);
|
||||
|
||||
Vector3 current = visual.transform.localScale;
|
||||
Vector3 target = inArchon ? archon : ours;
|
||||
|
||||
if (!isAlfar)
|
||||
{
|
||||
// Undo only a scale that is one of ours, the normal one or the archon's.
|
||||
if (!LooksLike(current, ours) && !LooksLike(current, archon)) return;
|
||||
target = Vector3.one;
|
||||
}
|
||||
|
||||
if (!LooksLike(current, target))
|
||||
{
|
||||
visual.transform.localScale = target;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool LooksLike(Vector3 a, Vector3 b)
|
||||
{
|
||||
return Mathf.Abs(a.x - b.x) < 0.001f && Mathf.Abs(a.y - b.y) < 0.001f && Mathf.Abs(a.z - b.z) < 0.001f;
|
||||
}
|
||||
|
||||
// ─── Hair and beard ──────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Takes the hair and the beard off the VISUAL only. The Skeleton also rewrites the saved
|
||||
/// profile, which makes the loss permanent; the Alfar do not, so a reset to Human gets the
|
||||
/// hair back the next time the game rebuilds the equipment visuals.
|
||||
///
|
||||
/// Since Valheim 1.0 these take an item hash and not a name: 0 is the empty slot.
|
||||
/// </summary>
|
||||
public static void ApplyHairless(Player player)
|
||||
{
|
||||
if (player == null) return;
|
||||
|
||||
VisEquipment vis = player.GetComponent<VisEquipment>();
|
||||
if (vis == null) return;
|
||||
|
||||
vis.SetHairItem(0);
|
||||
vis.SetBeardItem(0);
|
||||
}
|
||||
|
||||
// ─── Eyes ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Which way the skull faces, measured once when the eyes are built and kept for as long as
|
||||
/// they exist (RigBindPose explains why it is read from the bind pose and not live).
|
||||
/// </summary>
|
||||
private class EyeFrame : MonoBehaviour
|
||||
{
|
||||
public Vector3 LocalForward = Vector3.forward;
|
||||
public Vector3 LocalUp = Vector3.up;
|
||||
public Vector3 LocalRight = Vector3.right;
|
||||
}
|
||||
|
||||
private static Shader cachedShader;
|
||||
private static bool shaderResolved;
|
||||
|
||||
public static void ApplyEyes(Player player)
|
||||
{
|
||||
if (player == null) return;
|
||||
|
||||
Transform headBone = FindBone(player, HeadBoneName);
|
||||
if (headBone == null) return; // rig not up yet; try again next pass
|
||||
|
||||
Transform eyes = headBone.Find(EyesName);
|
||||
|
||||
if (!IsAlfarPlayer(player) || player.IsDead())
|
||||
{
|
||||
if (eyes != null)
|
||||
{
|
||||
// Renamed first: Destroy is deferred to the end of the frame, and every call
|
||||
// until then would otherwise find it again.
|
||||
eyes.name = EyesName + "_Removed";
|
||||
Object.Destroy(eyes.gameObject);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (eyes == null)
|
||||
{
|
||||
// Sitting, attached, mid-attack or asleep the head can be turned away from the
|
||||
// body's forward at the instant the frame is measured, which puts the eyes behind
|
||||
// the skull. Wait for a neutral moment (the same guard as the Sverm's).
|
||||
if (player.IsAttached() || player.IsAttachedToShip() || player.InAttack() || player.IsSleeping())
|
||||
{
|
||||
return;
|
||||
}
|
||||
eyes = BuildEyes(player, headBone);
|
||||
}
|
||||
if (eyes == null) return;
|
||||
|
||||
PlaceEyes(headBone, eyes);
|
||||
}
|
||||
|
||||
private static void PlaceEyes(Transform headBone, Transform holder)
|
||||
{
|
||||
Vector3 lossy = headBone.lossyScale;
|
||||
if (Mathf.Abs(lossy.x) < 0.0001f || Mathf.Abs(lossy.y) < 0.0001f || Mathf.Abs(lossy.z) < 0.0001f) return;
|
||||
|
||||
EyeFrame frame = holder.GetComponent<EyeFrame>();
|
||||
if (frame == null) return;
|
||||
|
||||
// The Visual is scaled non-uniformly (thinner than tall), so lossyScale has three
|
||||
// different components and a single divisor would squash the spheres. Each axis is
|
||||
// divided by its own.
|
||||
Vector3 toLocal = new Vector3(1f / lossy.x, 1f / lossy.y, 1f / lossy.z);
|
||||
float eyeSize = AlfarConfig.EyeSize * AlfarConfig.EyeSizeMultiplier.Value;
|
||||
|
||||
Vector3 baseOffset = frame.LocalForward * AlfarConfig.EyeForward + frame.LocalUp * AlfarConfig.EyeHeight;
|
||||
|
||||
for (int i = 0; i < holder.childCount; i++)
|
||||
{
|
||||
Transform eye = holder.GetChild(i);
|
||||
|
||||
// Index 0 is offset against the right axis, so it is the model's left eye.
|
||||
float side = i == 0 ? -1f : 1f;
|
||||
Vector3 offset = baseOffset + frame.LocalRight * (side * AlfarConfig.EyeSeparation);
|
||||
|
||||
eye.localPosition = Vector3.Scale(offset, toLocal);
|
||||
eye.localScale = Vector3.Scale(Vector3.one * eyeSize, toLocal);
|
||||
}
|
||||
}
|
||||
|
||||
private static Transform BuildEyes(Player player, Transform headBone)
|
||||
{
|
||||
Shader shader = ResolveShader(player);
|
||||
if (shader == null) return null;
|
||||
|
||||
GameObject holder = new GameObject(EyesName);
|
||||
holder.transform.SetParent(headBone, false);
|
||||
holder.transform.localPosition = Vector3.zero;
|
||||
holder.transform.localRotation = Quaternion.identity;
|
||||
holder.transform.localScale = Vector3.one;
|
||||
|
||||
EyeFrame frame = holder.AddComponent<EyeFrame>();
|
||||
RigBindPose.MeasureHeadFrame(player, headBone, "Alfar",
|
||||
out frame.LocalForward, out frame.LocalUp, out frame.LocalRight);
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
// Spheres, not quads: a quad seen edge-on is a line and vanishes.
|
||||
GameObject eye = GameObject.CreatePrimitive(PrimitiveType.Sphere);
|
||||
eye.name = "Eye" + i;
|
||||
|
||||
foreach (Collider collider in eye.GetComponents<Collider>())
|
||||
{
|
||||
Object.Destroy(collider);
|
||||
}
|
||||
|
||||
eye.transform.SetParent(holder.transform, false);
|
||||
eye.transform.localPosition = Vector3.zero;
|
||||
eye.transform.localRotation = Quaternion.identity;
|
||||
eye.transform.localScale = Vector3.zero; // PlaceEyes runs immediately after this
|
||||
|
||||
Renderer renderer = eye.GetComponent<Renderer>();
|
||||
renderer.material = BlackMaterial(shader);
|
||||
renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
|
||||
renderer.receiveShadows = false;
|
||||
}
|
||||
|
||||
return holder.transform;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Matte black, and nothing else: the colour is black, the emission is black, and the two
|
||||
/// properties that make a lit shader shine are zeroed where the shader has them. The
|
||||
/// Sverm's eyes burn; these must read as holes.
|
||||
/// </summary>
|
||||
private static Material BlackMaterial(Shader shader)
|
||||
{
|
||||
Material material = new Material(shader);
|
||||
material.color = Color.black;
|
||||
|
||||
if (material.HasProperty("_EmissionColor")) material.SetColor("_EmissionColor", Color.black);
|
||||
if (material.HasProperty("_Glossiness")) material.SetFloat("_Glossiness", 0f);
|
||||
if (material.HasProperty("_Smoothness")) material.SetFloat("_Smoothness", 0f);
|
||||
if (material.HasProperty("_Metallic")) material.SetFloat("_Metallic", 0f);
|
||||
if (material.HasProperty("_SpecColor")) material.SetColor("_SpecColor", Color.black);
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom/Creature first, for the reason the Sverm's own resolver gives: Valheim dithers the
|
||||
/// player away when the camera gets inside them, and only the game's own shaders know about
|
||||
/// it, so eyes on an unlit shader would hang in the air while the face dissolved.
|
||||
/// </summary>
|
||||
private static Shader ResolveShader(Player player)
|
||||
{
|
||||
if (shaderResolved) return cachedShader;
|
||||
|
||||
// CUSTOM/CREATURE, found the one way that works in play. Two earlier attempts failed in
|
||||
// opposite directions and both are on record in the log:
|
||||
// 1. Shader.Find("Custom/Creature") returns null in the main-menu preview (Valheim's
|
||||
// shaders are not all loaded by name until something has used them), so the code
|
||||
// fell to Sprites/Default and CACHED it for the whole session;
|
||||
// 2. taking the player's own body shader gave 'Custom/Player', the SKIN shader: it
|
||||
// paints the skin texture, so the eyes came out white.
|
||||
// So: ask Shader.Find, and failing that read the shader off a real creature's material
|
||||
// (the Deathsquito's, the very prefab the drones are cloned from) once the world is up.
|
||||
// A failure is never cached, and in the menu preview there are simply no eyes yet.
|
||||
Shader shader = Shader.Find("Custom/Creature");
|
||||
|
||||
if (shader == null && ZNetScene.instance != null)
|
||||
{
|
||||
GameObject creature = ZNetScene.instance.GetPrefab("Deathsquito");
|
||||
Renderer renderer = creature != null ? creature.GetComponentInChildren<Renderer>(true) : null;
|
||||
if (renderer != null && renderer.sharedMaterial != null) shader = renderer.sharedMaterial.shader;
|
||||
}
|
||||
|
||||
if (shader == null)
|
||||
{
|
||||
// The main-menu preview has no world and so no creature to read a shader from. Its eyes
|
||||
// are only for show and are thrown away with the preview, so a plain unlit black will do
|
||||
// there - and it is NOT cached, so the world gets the real one.
|
||||
ZNetView preview = player != null ? player.GetComponent<ZNetView>() : null;
|
||||
if (preview == null || !preview.IsValid()) return Shader.Find("Sprites/Default");
|
||||
return null;
|
||||
}
|
||||
|
||||
Jotunn.Logger.LogInfo($"[Alfar] Eye shader resolved to '{shader.name}'.");
|
||||
shaderResolved = true;
|
||||
cachedShader = shader;
|
||||
return cachedShader;
|
||||
}
|
||||
|
||||
// ─── Skin ────────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Ash grey, or the glow colour while the archon form is up.</summary>
|
||||
public static Color SkinFor(Player player)
|
||||
{
|
||||
return AlfarArchon.IsArchon(player) ? AlfarPowerConfig.ArchonColor.Value : AlfarConfig.SkinColor.Value;
|
||||
}
|
||||
|
||||
private const string GlowName = "AlfarArchonGlow";
|
||||
|
||||
/// <summary>
|
||||
/// A blue light on the body while the archon form is up, taken off when it is not. Every
|
||||
/// client runs this for every Alfr in range, so the glow is seen by everyone.
|
||||
/// </summary>
|
||||
public static void ApplyArchonGlow(Player player)
|
||||
{
|
||||
if (player == null) return;
|
||||
|
||||
Transform existing = player.transform.Find(GlowName);
|
||||
bool want = IsAlfarPlayer(player) && AlfarArchon.IsArchon(player) && !player.IsDead();
|
||||
|
||||
if (!want)
|
||||
{
|
||||
if (existing != null) Object.Destroy(existing.gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
if (existing == null)
|
||||
{
|
||||
GameObject holder = new GameObject(GlowName);
|
||||
holder.transform.SetParent(player.transform, false);
|
||||
holder.transform.localPosition = Vector3.up * 1.2f;
|
||||
existing = holder.transform;
|
||||
|
||||
Light light = holder.AddComponent<Light>();
|
||||
light.type = LightType.Point;
|
||||
light.range = 9f;
|
||||
light.intensity = 3f;
|
||||
light.shadows = LightShadows.None;
|
||||
}
|
||||
|
||||
Light glow = existing.GetComponent<Light>();
|
||||
if (glow != null) glow.color = AlfarPowerConfig.ArchonColor.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The grey, for real. A tint on _SkinColor only MULTIPLIES the skin texture, and that texture is
|
||||
/// pink: multiplied by a grey it comes out as a darker human skin, not as grey skin (the second
|
||||
/// test: "the skin is the normal colour"). So the body's texture is replaced by a DESATURATED
|
||||
/// copy, made once on the GPU and read back, and _SkinColor then only sets how light the grey is.
|
||||
/// The original texture is remembered per material so a reset to human puts it back.
|
||||
/// </summary>
|
||||
private static readonly Dictionary<Texture, Texture2D> greyOf = new Dictionary<Texture, Texture2D>();
|
||||
private static readonly Dictionary<Material, Texture> originalTexture = new Dictionary<Material, Texture>();
|
||||
|
||||
private static Texture2D Desaturated(Texture source)
|
||||
{
|
||||
Texture2D grey;
|
||||
if (greyOf.TryGetValue(source, out grey) && grey != null) return grey;
|
||||
|
||||
RenderTexture target = RenderTexture.GetTemporary(source.width, source.height, 0,
|
||||
RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
|
||||
RenderTexture previous = RenderTexture.active;
|
||||
try
|
||||
{
|
||||
Graphics.Blit(source, target);
|
||||
RenderTexture.active = target;
|
||||
|
||||
grey = new Texture2D(source.width, source.height, TextureFormat.RGBA32, true);
|
||||
grey.ReadPixels(new Rect(0, 0, source.width, source.height), 0, 0);
|
||||
|
||||
Color32[] pixels = grey.GetPixels32();
|
||||
for (int i = 0; i < pixels.Length; i++)
|
||||
{
|
||||
Color32 c = pixels[i];
|
||||
byte luma = (byte)(c.r * 0.299f + c.g * 0.587f + c.b * 0.114f);
|
||||
pixels[i] = new Color32(luma, luma, luma, c.a);
|
||||
}
|
||||
grey.SetPixels32(pixels);
|
||||
grey.Apply(true);
|
||||
grey.name = source.name + "_AlfarGrey";
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Jotunn.Logger.LogWarning("[Alfar] Could not make the grey skin texture: " + e.Message);
|
||||
grey = null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
RenderTexture.active = previous;
|
||||
RenderTexture.ReleaseTemporary(target);
|
||||
}
|
||||
|
||||
if (grey != null) greyOf[source] = grey;
|
||||
return grey;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts the grey texture on every skin material of the body (or takes it off again). Runs from the
|
||||
/// UpdateColors postfix, so it covers the main-menu preview and every client, and from the
|
||||
/// cosmetic pass, so it survives anything that rebuilds the body.
|
||||
/// </summary>
|
||||
public static void ApplyGreyTexture(VisEquipment vis, bool on)
|
||||
{
|
||||
if (vis == null || vis.m_bodyModel == null) return;
|
||||
|
||||
foreach (Material material in vis.m_bodyModel.materials)
|
||||
{
|
||||
if (material == null || !material.HasProperty("_SkinColor") || !material.HasProperty("_MainTex")) continue;
|
||||
|
||||
Texture current = material.GetTexture("_MainTex");
|
||||
if (on)
|
||||
{
|
||||
if (current == null) continue;
|
||||
|
||||
bool ours = false;
|
||||
foreach (Texture2D grey in greyOf.Values) if (grey == current) { ours = true; break; }
|
||||
if (ours) continue;
|
||||
|
||||
Texture2D desaturated = Desaturated(current);
|
||||
if (desaturated == null) continue;
|
||||
|
||||
originalTexture[material] = current;
|
||||
material.SetTexture("_MainTex", desaturated);
|
||||
}
|
||||
else
|
||||
{
|
||||
Texture original;
|
||||
if (originalTexture.TryGetValue(material, out original) && original != null)
|
||||
{
|
||||
material.SetTexture("_MainTex", original);
|
||||
}
|
||||
originalTexture.Remove(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Keeps the skin right for whoever it is: the grey and its tint for an Alfr, the original for
|
||||
/// anyone who stopped being one. The tint is only written when it differs, and UpdateColors is
|
||||
/// pushed only then, so it costs a colour compare.
|
||||
/// </summary>
|
||||
public static void SyncSkin(Player player, bool isAlfar)
|
||||
{
|
||||
if (player == null) return;
|
||||
|
||||
VisEquipment vis = player.GetComponent<VisEquipment>();
|
||||
if (vis == null || vis.m_bodyModel == null) return;
|
||||
|
||||
if (!isAlfar)
|
||||
{
|
||||
if (originalTexture.Count > 0) ApplyGreyTexture(vis, false);
|
||||
return;
|
||||
}
|
||||
|
||||
ApplyGreyTexture(vis, true);
|
||||
|
||||
Material material = vis.m_bodyModel.material;
|
||||
if (material == null || !material.HasProperty("_SkinColor")) return;
|
||||
|
||||
Color wanted = SkinFor(player);
|
||||
Color current = material.GetColor("_SkinColor");
|
||||
if (Mathf.Abs(current.r - wanted.r) < 0.01f && Mathf.Abs(current.g - wanted.g) < 0.01f &&
|
||||
Mathf.Abs(current.b - wanted.b) < 0.01f) return;
|
||||
|
||||
Traverse.Create(vis).Method("UpdateColors").GetValue();
|
||||
}
|
||||
|
||||
// ─── Hands ───────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>The right hand bone: where the beam leaves from.</summary>
|
||||
public static Transform RightHand(Player player)
|
||||
{
|
||||
return player != null ? FindBone(player, "RightHand") : null;
|
||||
}
|
||||
|
||||
private static Transform FindBone(Player player, string boneName)
|
||||
{
|
||||
VisEquipment visEq = player.GetComponent<VisEquipment>();
|
||||
if (visEq == null || visEq.m_bodyModel == null || visEq.m_bodyModel.bones == null) return null;
|
||||
|
||||
foreach (Transform bone in visEq.m_bodyModel.bones)
|
||||
{
|
||||
if (bone != null && bone.name == boneName) return bone;
|
||||
}
|
||||
|
||||
// Loose match, because rigs are not consistent about capitalisation or prefixes.
|
||||
string wanted = boneName.ToLowerInvariant();
|
||||
foreach (Transform bone in visEq.m_bodyModel.bones)
|
||||
{
|
||||
if (bone != null && bone.name.ToLowerInvariant().Contains(wanted)) return bone;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ namespace RacesOfValheim
|
|||
// Whole sections that are cosmetic or per-player.
|
||||
private static readonly string[] LocalSections =
|
||||
{
|
||||
"Alfar - Look",
|
||||
"Aswid - Claws",
|
||||
"Aswid - Eyes",
|
||||
"Fenrir - Appearance",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "RacesOfValheim",
|
||||
"description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
|
||||
"version_number": "1.5.15",
|
||||
"version_number": "1.6.0",
|
||||
"website_url": "",
|
||||
"dependencies": [
|
||||
"denikson-BepInExPack_Valheim-5.4.2333",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
private static readonly string[] Races =
|
||||
{
|
||||
"Aswid", "Fenrir", "Skadi", "Skeleton", "Furling", "Trol", "Draugh", "Dvergar", "Trenta", "Sverm"
|
||||
"Aswid", "Fenrir", "Skadi", "Skeleton", "Furling", "Trol", "Draugh", "Dvergar", "Trenta", "Sverm", "Alfar"
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -81,6 +81,10 @@ namespace RacesOfValheim
|
|||
{
|
||||
GenerateSvermText(knownTexts, state);
|
||||
}
|
||||
else if (currentRace == AlfarConfig.RaceId)
|
||||
{
|
||||
GenerateAlfarText(knownTexts, state);
|
||||
}
|
||||
|
||||
// The War Vulture is not a racial power and does not belong inside any one race's
|
||||
// generator: it is an item whose access list is a config entry. Appended here, once,
|
||||
|
|
@ -119,6 +123,57 @@ namespace RacesOfValheim
|
|||
knownTexts[key] = sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Alfar's entry: what the body does, the powers as the bosses open them, and the Nexus.
|
||||
/// Every number is read from the config, so the page cannot promise what the game does not do.
|
||||
/// </summary>
|
||||
private static void GenerateAlfarText(Dictionary<string, string> knownTexts, int state)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
string F0(float v) => v.ToString("0");
|
||||
string F1(float v) => v.ToString("0.#");
|
||||
string Key(BepInEx.Configuration.ConfigEntry<BepInEx.Configuration.KeyboardShortcut> entry) => entry.Value.MainKey.ToString();
|
||||
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_the_alfar_light"));
|
||||
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_eitr_shield", F0(AlfarConfig.ShieldRate.Value * 100f), F1(AlfarConfig.ConductiveMultiplier.Value)));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_diet"));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_soft_fall"));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_levitation", F1(AlfarPowerConfig.LevitationCostPerSecond.Value)));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_heimkall", F0(AlfarConfig.HeimkallMinutes.Value), F0(AlfarConfig.HeimkallMinutesAfterYagluth.Value), F0(AlfarConfig.HeimkallMinutesAfterFader.Value), F0(AlfarConfig.HeimkallInvulnerableSeconds.Value)));
|
||||
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_powers"));
|
||||
if (state >= AlfarPowerConfig.SkridState)
|
||||
{
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_skrid", Key(AlfarPowerConfig.SkridKey), F0(AlfarPowerConfig.SkridDistance.Value), F0(AlfarPowerConfig.SkridCooldown.Value)));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_grafvaettir", Key(AlfarPowerConfig.GrafvaettirKey), F0(AlfarPowerConfig.GrafSeconds.Value), AlfarPowerConfig.GrafStone.Value, AlfarPowerConfig.GrafFlint.Value, F0(AlfarPowerConfig.GrafCooldown.Value)));
|
||||
}
|
||||
if (state >= AlfarPowerConfig.UtsogState)
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_utsog", F0(AlfarPowerConfig.UtsogPercent.Value * 100f)));
|
||||
if (state >= AlfarPowerConfig.KallState)
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_kall", Key(AlfarPowerConfig.KallKey), F0(AlfarPowerConfig.KallRadius.Value), F0(AlfarPowerConfig.KallCooldown.Value)));
|
||||
if (state >= AlfarPowerConfig.LjosstormState)
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_ljosstorm", Key(AlfarPowerConfig.LjosstormKey), F0(AlfarPowerConfig.StormRadius.Value), F0(AlfarPowerConfig.StormSeconds.Value), F0(AlfarPowerConfig.StormCooldown.Value)));
|
||||
if (state >= AlfarPowerConfig.GeisliState)
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_geisli", Key(AlfarPowerConfig.GeisliKey), F0(AlfarPowerConfig.BeamRange.Value), F0(AlfarPowerConfig.BeamMaxSeconds.Value)));
|
||||
if (state >= AlfarPowerConfig.KyrrState)
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_kyrr", Key(AlfarPowerConfig.KyrrKey), F0(AlfarPowerConfig.StasisSeconds.Value), F0(AlfarPowerConfig.StasisBossSeconds.Value)));
|
||||
if (state >= AlfarPowerConfig.SameiningState)
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_sameining", Key(AlfarPowerConfig.SameiningKey), F0(AlfarPowerConfig.ArchonThreshold.Value * 100f), F0(AlfarPowerConfig.ArchonSeconds.Value)));
|
||||
if (state < AlfarPowerConfig.SameiningState)
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_more_to_come"));
|
||||
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_nexus_title"));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_nexus", F0(AlfarNexusConfig.NexusRadius.Value), F1(AlfarNexusConfig.NexusDensityKm2.Value), AlfarNexusConfig.NexusBronze.Value));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_drones", AlfarNexusConfig.DroneCap.Value, AlfarNexusConfig.DroneBronze.Value));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_constructs", AlfarNexusConfig.NeistCap.Value, AlfarNexusConfig.EldingCap.Value, AlfarNexusConfig.SteinCap.Value));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_crystals", AlfarNexusConfig.CrystalCap.Value, AlfarNexusConfig.UpgradeCrystals.Value));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_ljosgard"));
|
||||
sb.AppendLine(ModText.Get("rov_compendium_alfar_towers"));
|
||||
|
||||
knownTexts[PageKey("Alfar")] = sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Sverm's entry, in two halves because the race is two halves: a body that grows on its
|
||||
/// own, and a colony that has to be built. Figures are read from the live rules and from the
|
||||
|
|
|
|||
|
|
@ -70,6 +70,19 @@ namespace RacesOfValheim
|
|||
new Entry { Race = "Dvergar", Label = "Runic Ping", Key = () => DvergarConfigManagement.RunicPingKey, Icon = "TrophyDvergr" },
|
||||
new Entry { Race = "Dvergar", Label = "Runic Overcharge", Key = () => DvergarConfigManagement.RunicOverchargeKey, Icon = "Eitr" },
|
||||
|
||||
new Entry { Race = AlfarConfig.RaceId, Label = "Skrid (Blink)", Key = () => AlfarPowerConfig.SkridKey, Icon = "Eitr",
|
||||
Available = p => BossProgressionManager.GetCurrentProgressionState() >= AlfarPowerConfig.SkridState },
|
||||
new Entry { Race = AlfarConfig.RaceId, Label = "Mining Drones", Key = () => AlfarPowerConfig.GrafvaettirKey, Icon = "TrophyDeathsquito",
|
||||
Available = p => BossProgressionManager.GetCurrentProgressionState() >= AlfarPowerConfig.GrafvaettirState },
|
||||
new Entry { Race = AlfarConfig.RaceId, Label = "Kall (Telekinesis)", Key = () => AlfarPowerConfig.KallKey, Icon = "Thunderstone",
|
||||
Available = p => BossProgressionManager.GetCurrentProgressionState() >= AlfarPowerConfig.KallState },
|
||||
new Entry { Race = AlfarConfig.RaceId, Label = "Ljosstorm", Key = () => AlfarPowerConfig.LjosstormKey, Icon = "OrbThunderBlood",
|
||||
Available = p => BossProgressionManager.GetCurrentProgressionState() >= AlfarPowerConfig.LjosstormState },
|
||||
new Entry { Race = AlfarConfig.RaceId, Label = "Kyrr (Stasis)", Key = () => AlfarPowerConfig.KyrrKey, Icon = "FreezeGland",
|
||||
Available = p => BossProgressionManager.GetCurrentProgressionState() >= AlfarPowerConfig.KyrrState },
|
||||
new Entry { Race = AlfarConfig.RaceId, Label = "Sameining (Archon)", Key = () => AlfarPowerConfig.SameiningKey, Icon = "TrophyFader",
|
||||
Available = p => BossProgressionManager.GetCurrentProgressionState() >= AlfarPowerConfig.SameiningState },
|
||||
|
||||
new Entry { Race = "Sverm", Label = "Ravager Strain", Key = () => SvermConfigManagement.RavagerKey, Icon = "TrophySeekerBrute" },
|
||||
|
||||
new Entry { Race = "Skeleton", Label = "Summon on Kill", Key = () => SkeletonConfig.SummonToggleKey, Icon = "StaffSkeleton",
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ namespace RacesOfValheim
|
|||
"Furling",
|
||||
DvergarConfig.RaceId,
|
||||
TrentaConfig.RaceId,
|
||||
// The Alfar are 5% taller and a little thinner: a non-uniform scale on the Visual.
|
||||
AlfarConfig.RaceId,
|
||||
// Sverm sizes itself only from the Queen on (Surrenal Glands, +10%). It is listed here
|
||||
// for every tier all the same: below that tier its own ApplyScale asks for 1, which is
|
||||
// the same answer another race's reset would give, and being on the list is what stops
|
||||
|
|
|
|||
|
|
@ -46,6 +46,11 @@ namespace RacesOfValheim
|
|||
{ TrentaConfig.ComposterPieceName, new[] { TrentaConfig.RaceId } },
|
||||
{ TrentaConfig.GrovePieceName, new[] { TrentaConfig.RaceId } },
|
||||
{ AswidBloodRefinery.PieceName, new[] { "Aswid" } },
|
||||
{ AlfarNexus.PieceName, new[] { AlfarConfig.RaceId } },
|
||||
{ AlfarTowers.PieceName, new[] { AlfarConfig.RaceId } },
|
||||
{ AlfarLjosgard.PieceName, new[] { AlfarConfig.RaceId } },
|
||||
{ AlfarChests.EntryName, new[] { AlfarConfig.RaceId } },
|
||||
{ AlfarChests.WoodName, new[] { AlfarConfig.RaceId } },
|
||||
};
|
||||
|
||||
/// <summary>The races allowed to build this piece, or null for a piece anyone builds.</summary>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
public const string PluginGUID = "com.nandor.racesofvalheim";
|
||||
public const string PluginName = "Races Of Valheim";
|
||||
public const string PluginVersion = "1.5.15";
|
||||
public const string PluginVersion = "1.6.0";
|
||||
|
||||
private readonly Harmony harmony = new Harmony(PluginGUID);
|
||||
|
||||
|
|
@ -28,6 +28,9 @@ namespace RacesOfValheim
|
|||
// Bound in alphabetical order by race, since Configuration Manager's category list
|
||||
// follows bind order rather than sorting itself - confirmed from the Skadi/Aswid
|
||||
// ordering in-game. Keep new races' Bind() calls slotted in alphabetically here.
|
||||
AlfarConfig.Bind(Config);
|
||||
AlfarPowerConfig.Bind(Config);
|
||||
AlfarNexusConfig.Bind(Config);
|
||||
AswidConfig.Bind(Config);
|
||||
DraughConfig.Bind(Config);
|
||||
DvergarConfigManagement.Bind(Config);
|
||||
|
|
@ -80,6 +83,11 @@ namespace RacesOfValheim
|
|||
CommandManager.Instance.AddConsoleCommand(new FenrirPackSpawnCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new DumpPotionsCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new ListPrefabsCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new AlfarProbeCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new AlfarStatusCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new AlfarResetCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new AlfarEitrCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new AlfarHpCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new DumpAnimCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new EvilLaughCommand());
|
||||
}
|
||||
|
|
@ -294,6 +302,7 @@ namespace RacesOfValheim
|
|||
DvergarRace.Instance.CreateModAssets();
|
||||
TrentaRace.Instance.CreateModAssets();
|
||||
SvermRace.Instance.CreateModAssets();
|
||||
AlfarRace.CreateModAssets();
|
||||
WarVultureItem.Register();
|
||||
TrolsHammerItem.Register();
|
||||
BoneServant.Register();
|
||||
|
|
@ -447,6 +456,7 @@ namespace RacesOfValheim
|
|||
CreateRaceButtonWithConfirm(DvergarConfig.RaceId, new Vector2(-450, -140), GetDvergarIcon(), SelectDvergar);
|
||||
CreateRaceButtonWithConfirm(TrentaConfig.RaceId, new Vector2(-150, -140), GetTrentaIcon(), SelectTrenta);
|
||||
CreateRaceButtonWithConfirm(SvermConfig.RaceId, new Vector2(150, -140), GetSvermIcon(), SelectSverm);
|
||||
CreateRaceButtonWithConfirm(AlfarConfig.RaceId, new Vector2(450, -140), GetAlfarIcon(), SelectAlfar);
|
||||
|
||||
GUIManager.BlockInput(true);
|
||||
}
|
||||
|
|
@ -469,6 +479,7 @@ namespace RacesOfValheim
|
|||
case DvergarConfig.RaceId: return Instance.GetDvergarIcon();
|
||||
case TrentaConfig.RaceId: return Instance.GetTrentaIcon();
|
||||
case SvermConfig.RaceId: return Instance.GetSvermIcon();
|
||||
case AlfarConfig.RaceId: return Instance.GetAlfarIcon();
|
||||
}
|
||||
return race == DraughVisuals.RaceId ? Instance.GetDraughIcon() : Instance.GetHumanIcon();
|
||||
}
|
||||
|
|
@ -874,6 +885,44 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
private void SelectAlfar()
|
||||
{
|
||||
if (Player.m_localPlayer != null)
|
||||
{
|
||||
Player.m_localPlayer.m_customData["Race"] = AlfarConfig.RaceId;
|
||||
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", AlfarConfig.RaceId);
|
||||
|
||||
// The grey skin is written by Alfar_UpdateColors_Patch, which runs after UpdateColors:
|
||||
// push one through so the change shows now and not at the next visual refresh.
|
||||
VisEquipment visEq = Player.m_localPlayer.GetComponent<VisEquipment>();
|
||||
if (visEq != null) Traverse.Create(visEq).Method("UpdateColors").GetValue();
|
||||
|
||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_alfar"));
|
||||
CloseRaceSelectionMenu();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refined eitr's own icon: the race lives on eitr. Falls back to a Surtling core and then
|
||||
/// to copper so the button is never an empty square.
|
||||
/// </summary>
|
||||
private Sprite GetAlfarIcon()
|
||||
{
|
||||
GameObject prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("Eitr")?.gameObject;
|
||||
if (prefab == null) prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("SurtlingCore")?.gameObject;
|
||||
if (prefab == null) prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("Copper")?.gameObject;
|
||||
if (prefab != null)
|
||||
{
|
||||
ItemDrop drop = prefab.GetComponent<ItemDrop>();
|
||||
if (drop != null && drop.m_itemData.m_shared.m_icons.Length > 0)
|
||||
{
|
||||
return drop.m_itemData.m_shared.m_icons[0];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Sprite GetSvermIcon()
|
||||
{
|
||||
GameObject prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("TrophySeekerBrute")?.gameObject;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,28 @@
|
|||
{
|
||||
"rov_compendium_alfar_title": "Alfar Secrets",
|
||||
"rov_compendium_alfar_the_alfar_light": "\n-- THE ALFAR --\n",
|
||||
"rov_compendium_alfar_eitr_shield": "[Base Passive] Eitr Shield: Eitr is your armour. Every blow lands on the pool first, at $1% of its weight, and lightning and spirit cost double (x$2 for the conductive). Only drowning and the edge of the world ignore it. With the pool empty, you are as soft as anyone.\n",
|
||||
"rov_compendium_alfar_diet": "[Base Passive] Diet of Light: Every food you eat also feeds the eitr pool, as much as the smaller of its health and stamina.\n",
|
||||
"rov_compendium_alfar_soft_fall": "[Base Passive] Soft Fall: With eitr in the pool, falls cost nothing and you drift down slowly, as with a feather cape. At eitr zero the ground is the ground.\n",
|
||||
"rov_compendium_alfar_levitation": "[Base Passive] Levitation: Hold Jump in the air and you rise slowly, burning $1 eitr a second. Let go and the soft fall takes over.\n",
|
||||
"rov_compendium_alfar_heimkall": "[Base Passive] Heimkall: A lethal blow does not kill you: you wake at one health at your bed, or at the world's origin if you have set no bed, and nothing can hurt you for $4 seconds. It can work once every $1 minutes ($2 after Yagluth, $3 after Fader); the timer shows on screen.\n",
|
||||
"rov_compendium_alfar_powers": "\n-- POWERS --\n",
|
||||
"rov_compendium_alfar_skrid": "[Eikthyr Unlock] Skrid ('$1' Key): Blink $2 meters where you look. Waits $3 seconds.\n",
|
||||
"rov_compendium_alfar_grafvaettir": "[Eikthyr Unlock] Grafvaettir ('$1' Key): Throw a grenade of drones that dig out every precious ore around for $2 seconds, then vanish. Costs $3 stone and $4 flint, and waits $5 seconds.\n",
|
||||
"rov_compendium_alfar_utsog": "[Elder Unlock] Utsog: What dies to your powers returns $1% of its health to you as eitr.\n",
|
||||
"rov_compendium_alfar_kall": "[Bonemass Unlock] Kall ('$1' Key): A wave of lightning around you, $2 meters wide. Waits $3 seconds.\n",
|
||||
"rov_compendium_alfar_ljosstorm": "[Moder Unlock] Ljosstorm ('$1' Key): A psionic storm over a $2 meter area for $3 seconds. Waits $4 seconds.\n",
|
||||
"rov_compendium_alfar_geisli": "[Yagluth Unlock] Geisli ('$1' Key, hold): A laser from your right hand, up to $2 meters, for at most $3 seconds, costing eitr by the second.\n",
|
||||
"rov_compendium_alfar_kyrr": "[Queen Unlock] Kyrr ('$1' Key): Holds what you look at in stasis for $2 seconds ($3 for a boss).\n",
|
||||
"rov_compendium_alfar_sameining": "[Fader Unlock] Sameining ('$1' Key): The archon. Needs $2% of your eitr and a ready Heimkall; spends all the eitr and turns it into a pool of protection. For up to $3 seconds you are larger, faster and you fly, and a psionic pulse strikes everything hostile around you, but you cannot use weapons. When it ends - time up or pool gone - you are called home at one health and the Heimkall begins its wait.\n",
|
||||
"rov_compendium_alfar_more_to_come": "More powers wake as the great ones fall.\n",
|
||||
"rov_compendium_alfar_nexus_title": "\n-- THE NEXUS --\n",
|
||||
"rov_compendium_alfar_nexus": "Ljoskjarne (Hammer): the heart of the base. Its radius is $1 meters, and only one may stand per square kilometer ($2 per km2 at most). It costs $3 bronze. Press it for the market: everything the Alfar build comes from here.\n",
|
||||
"rov_compendium_alfar_drones": "Drones: up to $1 of them, $2 bronze each. They work both trades of the Butlers - logistics through the entry chest and the chests by type, the forge, the kitchen, the farm with replanting - and repair whatever is damaged in the base for free. A Greydwarf-eye seal inside a chest tells them not to look.\n",
|
||||
"rov_compendium_alfar_constructs": "Constructs: Neistvordr (up to $1), Eldingvordr (up to $2) and Steinvordr (up to $3) per Nexus, paid in metal, crystals and eitr. They cannot be repaired, and when destroyed they give back the metal, never the crystals nor the eitr.\n",
|
||||
"rov_compendium_alfar_crystals": "Crystals: the Nexus grows them slowly and stops at $1 until someone - you or a drone - collects them. An upgrade for $2 crystals makes it faster.\n",
|
||||
"rov_compendium_alfar_ljosgard": "Ljosgard: a module of the Nexus that turns Magecap and Jotun Puffs into Sap, the slow way to farm magic.\n",
|
||||
"rov_compendium_alfar_towers": "Prismavard: bronze and crystal turrets with their own shield, powered by the Nexus radius, repaired with the hammer.\n",
|
||||
"rov_compendium_aswid_always_active_every_form_with": "Always active, in every form, with no key to hold - only the on/off toggle. Drains a $1m radius by day, $2m by night, for magic damage that scales with your Blood Magic skill, healing you for the damage dealt. Enemies at or below $3% health are executed outright. The aura hits for half in human form, full as a Bat, and double as Mist. It cannot tell traders from monsters, so switch it off with [I] before talking to Haldor or Hildir.\n",
|
||||
"rov_compendium_aswid_asmund_passive": "[Fader Unlock] Asmund (Passive):",
|
||||
"rov_compendium_aswid_aswid_s_curse": "The Aswid's Curse\n",
|
||||
|
|
|
|||
|
|
@ -135,4 +135,39 @@
|
|||
"rov_piece_boneship_karve_name": "Bone Karve",
|
||||
"rov_piece_boneship_longship_desc": "A longship gone to rot, ribbed with bone. It sails against any wind.",
|
||||
"rov_piece_boneship_longship_name": "Bone Longship"
|
||||
,
|
||||
"rov_creature_alfar_neistvordr_name": "Neistvordr",
|
||||
"rov_creature_alfar_steinvordr_name": "Steinvordr",
|
||||
"rov_creature_alfar_eldingvordr_name": "Eldingvordr",
|
||||
"rov_creature_alfar_drone_name": "Ljosvaettir",
|
||||
"rov_creature_alfar_grafvaettir_name": "Grafvaettir",
|
||||
"rov_piece_alfar_nexus_name": "Ljoskjarne",
|
||||
"rov_piece_alfar_nexus_desc": "The core of light. It makes the drones and the constructs, keeps the crystals, and everything of the base works inside its reach.",
|
||||
"rov_item_alfar_sphere_name": "Lightning sphere",
|
||||
"rov_item_alfar_zap_name": "Drone zap",
|
||||
"rov_alfar_product_drone": "Ljosvaettir (drone)",
|
||||
"rov_alfar_product_neistvordr": "Neistvordr (fire construct)",
|
||||
"rov_alfar_product_eldingvordr": "Eldingvordr (lightning construct)",
|
||||
"rov_alfar_product_steinvordr": "Steinvordr (stone construct)",
|
||||
"rov_alfar_product_upgrade": "Kristallvigsla (crystal upgrade)",
|
||||
"rov_alfar_product_collect": "Collect crystals",
|
||||
"rov_alfar_nexus_next": "Next product",
|
||||
"rov_alfar_nexus_crystals": "Crystals stored: $1 / $2",
|
||||
"rov_alfar_nexus_no_upgrade": "The Kristallvigsla is not built: no crystals, no constructs."
|
||||
,
|
||||
"rov_piece_alfar_prismavard_name": "Prismavard",
|
||||
"rov_piece_alfar_prismavard_desc": "A small bronze tower of light. It shoots lightning at enemies, works only inside a Ljoskjarne's reach, and can be repaired with the hammer.",
|
||||
"rov_item_alfar_prismbolt_name": "Prism bolt",
|
||||
"rov_item_alfar_sigil_name": "Eirinnsigli",
|
||||
"rov_item_alfar_sigil_desc": "A verdigris seal. Put it in a chest and the drones will not look there.",
|
||||
"rov_piece_alfar_inngangskista_name": "Inngangskista",
|
||||
"rov_piece_alfar_inngangskista_desc": "The entry chest. Throw everything in: the drones work from it and sort what is left into the chests that already hold the same thing.",
|
||||
"rov_piece_alfar_eldividarkista_name": "Eldividarkista",
|
||||
"rov_piece_alfar_eldividarkista_desc": "The wood chest. Only the wood in here is burnt by the drones.",
|
||||
"rov_piece_alfar_ljosgard_name": "Ljosgard",
|
||||
"rov_piece_alfar_ljosgard_desc": "The garden of light. It mixes Magecap and Jotun Puffs into sap, very slowly. The drones feed it."
|
||||
,
|
||||
"rov_alfar_nexus_open": "Open the store",
|
||||
"rov_alfar_store_count": "Alive: $1 of $2 allowed",
|
||||
"rov_alfar_store_terms": "Paid from your pack, not in coins."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
"rov_msg_core_chose_path_furling": "You chose the path of the Furling.",
|
||||
"rov_msg_core_chose_path_skadi": "You chose the path of Skadi.",
|
||||
"rov_msg_core_chose_path_skeleton": "You chose the path of the Skeleton.",
|
||||
"rov_msg_core_chose_path_alfar": "You chose the path of the Alfar.",
|
||||
"rov_msg_core_chose_path_sverm": "You chose the path of the Sverm.",
|
||||
"rov_msg_core_chose_path_trenta": "You chose the path of the Trenta.",
|
||||
"rov_msg_core_chose_path_trol": "You chose the path of the Trol.",
|
||||
|
|
@ -205,5 +206,32 @@
|
|||
"rov_msg_boneship_sunk": "The ship goes down, and $1 go with it.",
|
||||
"rov_msg_skeleton_summon_on": "Thy shall raise again.",
|
||||
"rov_msg_skeleton_summon_off": "Raising... nevermore.",
|
||||
"rov_msg_skeleton_summon_locked": "Summon on Kill awakens once The Queen falls."
|
||||
"rov_msg_skeleton_summon_locked": "Summon on Kill awakens once The Queen falls.",
|
||||
"rov_msg_alfar_heimkall": "Heimkall: the light calls you home.",
|
||||
"rov_msg_alfar_heimkall_nobed": "Heimkall: no bed is set, the light calls you to the world's origin.",
|
||||
"rov_msg_alfar_no_eitr": "Not enough eitr.",
|
||||
"rov_msg_alfar_archon_on": "Sameining: you are light.",
|
||||
"rov_msg_alfar_archon_off": "The light fades. You are called home.",
|
||||
"rov_msg_alfar_archon_not_charged": "Sameining needs most of your eitr.",
|
||||
"rov_msg_alfar_archon_not_ready": "Sameining needs Heimkall ready: it is the price of the form."
|
||||
,
|
||||
"rov_msg_alfar_only_alfar": "Only the Alfar can wake this.",
|
||||
"rov_msg_build_limit_alfar_nexus": "A Ljoskjarne already holds this land. One core to each stretch of ground.",
|
||||
"rov_msg_alfar_nexus_cap": "The core keeps no more of these.",
|
||||
"rov_msg_alfar_nexus_cannot_pay": "You lack the price: $1",
|
||||
"rov_msg_alfar_nexus_upgraded": "The Kristallvigsla is done. Crystals will grow in the core.",
|
||||
"rov_msg_alfar_nexus_built": "Made: $1",
|
||||
"rov_msg_alfar_nexus_no_crystals": "The core holds no crystals yet.",
|
||||
"rov_msg_alfar_nexus_collected": "Crystals taken: $1",
|
||||
"rov_msg_alfar_graf_materials": "The drones need $1 stone and $2 flint.",
|
||||
"rov_msg_thrall_refusal_alfar": "The construct does not know your light.",
|
||||
"rov_msg_thrall_refusal_alfar_drone": "The drone takes no orders. It works."
|
||||
,
|
||||
"rov_msg_alfar_tower_needs_nexus": "A Prismavard needs a Ljoskjarne within reach.",
|
||||
"rov_msg_alfar_chest_needs_nexus": "This chest needs a Ljoskjarne within reach.",
|
||||
"rov_msg_alfar_gard_needs_nexus": "The Ljosgard needs a Ljoskjarne within reach.",
|
||||
"rov_msg_build_limit_alfar_chest": "This core already has one of these within reach.",
|
||||
"rov_msg_build_limit_alfar_ljosgard": "This core already has its Ljosgard."
|
||||
,
|
||||
"rov_msg_alfar_nexus_no_store": "The nucleus has nothing to offer right now."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,5 +34,7 @@
|
|||
"rov_race_trenta_desc": "Tree-born folk, kin to root and leaf. Patient and hard to fell.",
|
||||
|
||||
"rov_race_sverm_name": "Sverm",
|
||||
"rov_race_sverm_desc": "Chitin-born swarm kin. Armoured from birth and never slowed, venomous, at peace with every crawling thing - but blunt trauma and fire find the seams."
|
||||
"rov_race_sverm_desc": "Chitin-born swarm kin. Armoured from birth and never slowed, venomous, at peace with every crawling thing - but blunt trauma and fire find the seams.",
|
||||
"rov_race_alfar_name": "Alfar",
|
||||
"rov_race_alfar_desc": "Light-bodied casters of Alfheim, tall, grey and thin. Food becomes eitr and eitr is your shield: every blow lands on it first, and the cost of dying is a long wait, not a lost life."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,5 +60,15 @@
|
|||
"rov_se_trol_trueformcd_name": "True Form Cooldown",
|
||||
"rov_se_trol_trueformcd_tooltip": "You are exhausted from your True Form.",
|
||||
"rov_se_skeleton_raisedead_name": "Raise the Dead",
|
||||
"rov_se_skeleton_raisedead_tooltip": "Each kill raises a skeleton to fight for you. Press the Summon on Kill key to turn it off."
|
||||
"rov_se_skeleton_raisedead_tooltip": "Each kill raises a skeleton to fight for you. Press the Summon on Kill key to turn it off.",
|
||||
"rov_se_alfar_timer_skrid_name": "Skrid ready in",
|
||||
"rov_se_alfar_timer_graf_name": "Grafvaettir ready in",
|
||||
"rov_se_alfar_timer_kall_name": "Kall ready in",
|
||||
"rov_se_alfar_timer_storm_name": "Ljosstorm ready in",
|
||||
"rov_se_alfar_timer_beam_name": "Geisli ready in",
|
||||
"rov_se_alfar_timer_kyrr_name": "Kyrr ready in",
|
||||
"rov_se_alfar_timer_heimkall_name": "Heimkall ready in",
|
||||
"rov_se_alfar_timer_archon_name": "Sameining (archon)",
|
||||
"rov_se_alfar_stats_name": "Eitr Shield",
|
||||
"rov_se_alfar_stats_tooltip": "While you hold eitr, blows land on it first and you fall slowly and unhurt."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,28 @@
|
|||
{
|
||||
"rov_compendium_alfar_title": "Segreti degli Alfar",
|
||||
"rov_compendium_alfar_the_alfar_light": "\n-- GLI ALFAR --\n",
|
||||
"rov_compendium_alfar_eitr_shield": "[Passiva di base] Scudo di Eitr: l'eitr è la tua armatura. Ogni colpo cade prima sulla riserva, al $1% del suo peso, e fulmine e spirito costano il doppio (x$2 per i conduttivi). Solo annegamento e fine del mondo lo ignorano. A riserva vuota sei fragile come chiunque.\n",
|
||||
"rov_compendium_alfar_diet": "[Passiva di base] Dieta di Luce: ogni cibo che mangi alimenta anche la riserva di eitr, quanto il minore fra la sua salute e la sua stamina.\n",
|
||||
"rov_compendium_alfar_soft_fall": "[Passiva di base] Caduta morbida: con eitr nella riserva le cadute non costano nulla e scendi piano, come con il mantello di piume. A eitr zero il suolo è il suolo.\n",
|
||||
"rov_compendium_alfar_levitation": "[Passiva di base] Levitazione: tieni premuto Salto in aria e sali lentamente, bruciando $1 eitr al secondo. Rilascia e subentra la caduta morbida.\n",
|
||||
"rov_compendium_alfar_heimkall": "[Passiva di base] Heimkall: un colpo letale non ti uccide: ti risvegli con un punto ferita al letto, o all'origine del mondo se non hai impostato un letto, e per $4 secondi nulla può farti male. Funziona una volta ogni $1 minuti ($2 dopo Yagluth, $3 dopo Fader); il timer è a schermo.\n",
|
||||
"rov_compendium_alfar_powers": "\n-- POTERI --\n",
|
||||
"rov_compendium_alfar_skrid": "[Sblocco Eikthyr] Skrid (tasto '$1'): scatto di $2 metri dove guardi. Attesa $3 secondi.\n",
|
||||
"rov_compendium_alfar_grafvaettir": "[Sblocco Eikthyr] Grafvaettir (tasto '$1'): lanci una granata di droni che scavano ogni minerale prezioso intorno per $2 secondi e poi svaniscono. Costa $3 pietra e $4 selce, attesa $5 secondi.\n",
|
||||
"rov_compendium_alfar_utsog": "[Sblocco Anziano] Utsog: ciò che muore per i tuoi poteri ti restituisce il $1% della sua salute come eitr.\n",
|
||||
"rov_compendium_alfar_kall": "[Sblocco Bonemass] Kall (tasto '$1'): un'onda di fulmini attorno a te, larga $2 metri. Attesa $3 secondi.\n",
|
||||
"rov_compendium_alfar_ljosstorm": "[Sblocco Moder] Ljosstorm (tasto '$1'): una tempesta psionica su un'area di $2 metri per $3 secondi. Attesa $4 secondi.\n",
|
||||
"rov_compendium_alfar_geisli": "[Sblocco Yagluth] Geisli (tasto '$1', tenuto): un laser dalla mano destra, fino a $2 metri, per al massimo $3 secondi, consumando eitr al secondo.\n",
|
||||
"rov_compendium_alfar_kyrr": "[Sblocco Regina] Kyrr (tasto '$1'): tiene in stasi ciò che guardi per $2 secondi ($3 per un boss).\n",
|
||||
"rov_compendium_alfar_sameining": "[Sblocco Fader] Sameining (tasto '$1'): l'arconte. Servono il $2% dell'eitr e un Heimkall pronto; spende tutto l'eitr e lo trasforma in una riserva di protezione. Per al massimo $3 secondi sei più grande, più veloce e voli, e un impulso psionico colpisce tutto ciò che è ostile attorno a te, ma non puoi usare armi. Alla fine - tempo scaduto o riserva esaurita - vieni richiamato a casa con un punto ferita e l'attesa dell'Heimkall ricomincia.\n",
|
||||
"rov_compendium_alfar_more_to_come": "Altri poteri si risveglieranno man mano che cadono i grandi.\n",
|
||||
"rov_compendium_alfar_nexus_title": "\n-- IL NEXUS --\n",
|
||||
"rov_compendium_alfar_nexus": "Ljoskjarne (Martello): il cuore della base. Il suo raggio è di $1 metri e ne può stare uno solo per chilometro quadrato (al massimo $2 per km2). Costa $3 bronzo. Premilo per il mercato: tutto ciò che gli Alfar costruiscono viene da qui.\n",
|
||||
"rov_compendium_alfar_drones": "Droni: fino a $1, $2 bronzo l'uno. Fanno entrambi i mestieri dei Maggiordomi - logistica con la cassa d'ingresso e le casse per tipo, la forgia, la cucina, la fattoria con reimpianto - e riparano gratis tutto ciò che è danneggiato nella base. Un sigillo in una cassa dice loro di non guardarci.\n",
|
||||
"rov_compendium_alfar_constructs": "Costrutti: Neistvordr (fino a $1), Eldingvordr (fino a $2) e Steinvordr (fino a $3) per Nexus, pagati in metallo, cristalli ed eitr. Non si riparano, e distrutti restituiscono il metallo, mai i cristalli né l'eitr.\n",
|
||||
"rov_compendium_alfar_crystals": "Cristalli: il Nexus li coltiva lentamente e si ferma a $1 finché qualcuno - tu o un drone - non li raccoglie. Un potenziamento da $2 cristalli lo rende più veloce.\n",
|
||||
"rov_compendium_alfar_ljosgard": "Ljosgard: un modulo del Nexus che trasforma Magecap e Jotun Puffs in Linfa, il modo lento di coltivare la magia.\n",
|
||||
"rov_compendium_alfar_towers": "Prismavard: torrette di bronzo e cristallo con uno scudo proprio, alimentate dal raggio del Nexus, riparabili con il martello.\n",
|
||||
"rov_compendium_aswid_always_active_every_form_with": "Sempre attiva, in ogni forma, senza tasti da tenere premuti: solo l'interruttore acceso/spento. Prosciuga un raggio di $1m di giorno e $2m di notte, con danni magici che crescono con la tua abilità di Magia del sangue, e ti cura per i danni inflitti. I nemici al $3% di salute o meno vengono giustiziati all'istante. L'aura colpisce a metà in forma umana, piena da pipistrello e doppia da nebbia. Non distingue i mercanti dai mostri, quindi spegnila con [I] prima di parlare con Haldor o Hildir.\n",
|
||||
"rov_compendium_aswid_asmund_passive": "[Sblocco Fader] Asmund (passiva):",
|
||||
"rov_compendium_aswid_aswid_s_curse": "La maledizione degli Aswid\n",
|
||||
|
|
|
|||
|
|
@ -135,4 +135,39 @@
|
|||
"rov_piece_boneship_karve_name": "Karve d'ossa",
|
||||
"rov_piece_boneship_longship_desc": "Un drakkar marcito, costolato d'ossa. Naviga contro qualunque vento.",
|
||||
"rov_piece_boneship_longship_name": "Drakkar d'ossa"
|
||||
,
|
||||
"rov_creature_alfar_neistvordr_name": "Neistvordr",
|
||||
"rov_creature_alfar_steinvordr_name": "Steinvordr",
|
||||
"rov_creature_alfar_eldingvordr_name": "Eldingvordr",
|
||||
"rov_creature_alfar_drone_name": "Ljosvaettir",
|
||||
"rov_creature_alfar_grafvaettir_name": "Grafvaettir",
|
||||
"rov_piece_alfar_nexus_name": "Ljoskjarne",
|
||||
"rov_piece_alfar_nexus_desc": "Il nucleo di luce. Fa i droni e i costrutti, tiene i cristalli, e tutto della base funziona dentro il suo raggio.",
|
||||
"rov_item_alfar_sphere_name": "Sfera di fulmine",
|
||||
"rov_item_alfar_zap_name": "Scossa del drone",
|
||||
"rov_alfar_product_drone": "Ljosvaettir (drone)",
|
||||
"rov_alfar_product_neistvordr": "Neistvordr (costrutto di fuoco)",
|
||||
"rov_alfar_product_eldingvordr": "Eldingvordr (costrutto di fulmine)",
|
||||
"rov_alfar_product_steinvordr": "Steinvordr (costrutto di pietra)",
|
||||
"rov_alfar_product_upgrade": "Kristallvigsla (potenziamento a cristalli)",
|
||||
"rov_alfar_product_collect": "Raccogli i cristalli",
|
||||
"rov_alfar_nexus_next": "Prodotto successivo",
|
||||
"rov_alfar_nexus_crystals": "Cristalli nel nucleo: $1 / $2",
|
||||
"rov_alfar_nexus_no_upgrade": "La Kristallvigsla non e' costruita: niente cristalli, niente costrutti."
|
||||
,
|
||||
"rov_piece_alfar_prismavard_name": "Prismavard",
|
||||
"rov_piece_alfar_prismavard_desc": "Una piccola torre di bronzo e luce. Spara fulmini ai nemici, funziona solo dentro il raggio di un Ljoskjarne e si ripara col martello.",
|
||||
"rov_item_alfar_prismbolt_name": "Dardo di prisma",
|
||||
"rov_item_alfar_sigil_name": "Eirinnsigli",
|
||||
"rov_item_alfar_sigil_desc": "Un sigillo di verderame. Mettilo in una cassa e i droni non la guarderanno.",
|
||||
"rov_piece_alfar_inngangskista_name": "Inngangskista",
|
||||
"rov_piece_alfar_inngangskista_desc": "La cassa d'ingresso. Butta dentro tutto: i droni lavorano da qui e smistano il resto nelle casse che contengono gia' la stessa cosa.",
|
||||
"rov_piece_alfar_eldividarkista_name": "Eldividarkista",
|
||||
"rov_piece_alfar_eldividarkista_desc": "La cassa della legna. Solo la legna qui dentro viene bruciata dai droni.",
|
||||
"rov_piece_alfar_ljosgard_name": "Ljosgard",
|
||||
"rov_piece_alfar_ljosgard_desc": "Il giardino di luce. Mescola Magecap e Jotun Puffs in linfa, molto lentamente. I droni lo alimentano."
|
||||
,
|
||||
"rov_alfar_nexus_open": "Apri il negozio",
|
||||
"rov_alfar_store_count": "Vivi: $1 su $2 consentiti",
|
||||
"rov_alfar_store_terms": "Si paga dallo zaino, non in monete."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
"rov_msg_core_chose_path_furling": "Hai scelto la via dei Furling.",
|
||||
"rov_msg_core_chose_path_skadi": "Hai scelto la via di Skadi.",
|
||||
"rov_msg_core_chose_path_skeleton": "Hai scelto la via degli Scheletri.",
|
||||
"rov_msg_core_chose_path_alfar": "Hai scelto la via degli Alfar.",
|
||||
"rov_msg_core_chose_path_sverm": "Hai scelto la via degli Sverm.",
|
||||
"rov_msg_core_chose_path_trenta": "Hai scelto la via dei Trenta.",
|
||||
"rov_msg_core_chose_path_trol": "Hai scelto la via dei Trol.",
|
||||
|
|
@ -205,5 +206,32 @@
|
|||
"rov_msg_boneship_sunk": "La nave affonda, e con lei $1.",
|
||||
"rov_msg_skeleton_summon_on": "Tu rialzerai ancora.",
|
||||
"rov_msg_skeleton_summon_off": "Risorgere... mai più.",
|
||||
"rov_msg_skeleton_summon_locked": "Evoca all'uccisione si risveglia quando cade la Regina."
|
||||
"rov_msg_skeleton_summon_locked": "Evoca all'uccisione si risveglia quando cade la Regina.",
|
||||
"rov_msg_alfar_heimkall": "Heimkall: la luce ti richiama a casa.",
|
||||
"rov_msg_alfar_heimkall_nobed": "Heimkall: nessun letto impostato, la luce ti richiama all'origine del mondo.",
|
||||
"rov_msg_alfar_no_eitr": "Eitr insufficiente.",
|
||||
"rov_msg_alfar_archon_on": "Sameining: sei luce.",
|
||||
"rov_msg_alfar_archon_off": "La luce si spegne. Vieni richiamato a casa.",
|
||||
"rov_msg_alfar_archon_not_charged": "Sameining richiede quasi tutto il tuo eitr.",
|
||||
"rov_msg_alfar_archon_not_ready": "Sameining richiede l'Heimkall pronto: e' il prezzo della forma."
|
||||
,
|
||||
"rov_msg_alfar_only_alfar": "Solo gli Alfar possono risvegliarlo.",
|
||||
"rov_msg_build_limit_alfar_nexus": "Un Ljoskjarne tiene gia' questa terra. Un nucleo per ogni tratto di terreno.",
|
||||
"rov_msg_alfar_nexus_cap": "Il nucleo non ne tiene di piu'.",
|
||||
"rov_msg_alfar_nexus_cannot_pay": "Ti manca il prezzo: $1",
|
||||
"rov_msg_alfar_nexus_upgraded": "La Kristallvigsla e' fatta. I cristalli cresceranno nel nucleo.",
|
||||
"rov_msg_alfar_nexus_built": "Fatto: $1",
|
||||
"rov_msg_alfar_nexus_no_crystals": "Il nucleo non ha ancora cristalli.",
|
||||
"rov_msg_alfar_nexus_collected": "Cristalli presi: $1",
|
||||
"rov_msg_alfar_graf_materials": "I droni vogliono $1 pietra e $2 selce.",
|
||||
"rov_msg_thrall_refusal_alfar": "Il costrutto non conosce la tua luce.",
|
||||
"rov_msg_thrall_refusal_alfar_drone": "Il drone non prende ordini. Lavora."
|
||||
,
|
||||
"rov_msg_alfar_tower_needs_nexus": "Una Prismavard richiede un Ljoskjarne nel raggio.",
|
||||
"rov_msg_alfar_chest_needs_nexus": "Questa cassa richiede un Ljoskjarne nel raggio.",
|
||||
"rov_msg_alfar_gard_needs_nexus": "Il Ljosgard richiede un Ljoskjarne nel raggio.",
|
||||
"rov_msg_build_limit_alfar_chest": "Questo nucleo ne ha gia' una nel suo raggio.",
|
||||
"rov_msg_build_limit_alfar_ljosgard": "Questo nucleo ha gia' il suo Ljosgard."
|
||||
,
|
||||
"rov_msg_alfar_nexus_no_store": "Il nucleo non ha niente da offrire adesso."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,5 +34,7 @@
|
|||
"rov_race_trenta_desc": "Popolo nato dagli alberi, parente di radici e foglie. Paziente e difficile da abbattere.",
|
||||
|
||||
"rov_race_sverm_name": "Sverm",
|
||||
"rov_race_sverm_desc": "Stirpe dello sciame nata dalla chitina. Corazzata dalla nascita e mai rallentata, velenosa, in pace con ogni cosa che striscia, ma i colpi contundenti e il fuoco trovano le giunture."
|
||||
"rov_race_sverm_desc": "Stirpe dello sciame nata dalla chitina. Corazzata dalla nascita e mai rallentata, velenosa, in pace con ogni cosa che striscia, ma i colpi contundenti e il fuoco trovano le giunture.",
|
||||
"rov_race_alfar_name": "Alfar",
|
||||
"rov_race_alfar_desc": "Incantatori di luce di Alfheim, alti, grigi e sottili. Il cibo diventa eitr e l'eitr è il tuo scudo: ogni colpo cade prima su di lui, e morire costa una lunga attesa, non una vita persa."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,5 +60,15 @@
|
|||
"rov_se_trol_trueformcd_name": "Ricarica vera forma",
|
||||
"rov_se_trol_trueformcd_tooltip": "Sei esausto dopo la tua vera forma.",
|
||||
"rov_se_skeleton_raisedead_name": "Risveglio dei morti",
|
||||
"rov_se_skeleton_raisedead_tooltip": "Ogni uccisione fa risorgere uno scheletro che combatte per te. Premi il tasto di Evoca all'uccisione per disattivarlo."
|
||||
"rov_se_skeleton_raisedead_tooltip": "Ogni uccisione fa risorgere uno scheletro che combatte per te. Premi il tasto di Evoca all'uccisione per disattivarlo.",
|
||||
"rov_se_alfar_timer_skrid_name": "Skrid pronto tra",
|
||||
"rov_se_alfar_timer_graf_name": "Grafvaettir pronto tra",
|
||||
"rov_se_alfar_timer_kall_name": "Kall pronto tra",
|
||||
"rov_se_alfar_timer_storm_name": "Ljosstorm pronto tra",
|
||||
"rov_se_alfar_timer_beam_name": "Geisli pronto tra",
|
||||
"rov_se_alfar_timer_kyrr_name": "Kyrr pronto tra",
|
||||
"rov_se_alfar_timer_heimkall_name": "Heimkall pronto tra",
|
||||
"rov_se_alfar_timer_archon_name": "Sameining (arconte)",
|
||||
"rov_se_alfar_stats_name": "Scudo di eitr",
|
||||
"rov_se_alfar_stats_tooltip": "Finché hai eitr, i colpi cadono prima su di lui e cadi piano e senza danni."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,28 @@
|
|||
{
|
||||
"rov_compendium_alfar_title": "Тайны Альфаров",
|
||||
"rov_compendium_alfar_the_alfar_light": "\n-- АЛЬФАРЫ --\n",
|
||||
"rov_compendium_alfar_eitr_shield": "[Базовая пассивка] Щит эйтра: эйтр - ваша броня. Каждый удар сначала приходится на запас, с весом $1%, а молния и дух обходятся вдвое дороже (x$2 для проводников). Лишь утопление и край мира его игнорируют. С пустым запасом вы уязвимы, как все.\n",
|
||||
"rov_compendium_alfar_diet": "[Базовая пассивка] Диета света: любая съеденная еда питает и запас эйтра - на меньшее из её здоровья и выносливости.\n",
|
||||
"rov_compendium_alfar_soft_fall": "[Базовая пассивка] Мягкое падение: при наличии эйтра падение ничего не стоит, и вы плавно снижаетесь, как в плаще из перьев. При нуле эйтра земля есть земля.\n",
|
||||
"rov_compendium_alfar_levitation": "[Базовая пассивка] Левитация: удерживайте Прыжок в воздухе - и вы медленно поднимаетесь, тратя $1 эйтра в секунду. Отпустите - и вступает мягкое падение.\n",
|
||||
"rov_compendium_alfar_heimkall": "[Базовая пассивка] Хеймкалль: смертельный удар вас не убивает: вы очнётесь с одной единицей здоровья у кровати или в начале мира, если кровать не задана, и $4 секунд вам ничто не вредит. Срабатывает раз в $1 минут ($2 после Ягнута, $3 после Фадера); таймер виден на экране.\n",
|
||||
"rov_compendium_alfar_powers": "\n-- СИЛЫ --\n",
|
||||
"rov_compendium_alfar_skrid": "[Открывается с Эйктюром] Скрид (клавиша '$1'): рывок на $2 метров туда, куда смотрите. Перезарядка $3 секунд.\n",
|
||||
"rov_compendium_alfar_grafvaettir": "[Открывается с Эйктюром] Графветтир (клавиша '$1'): бросок гранаты из дронов, которые $2 секунд выкапывают все ценные руды вокруг и исчезают. Стоит $3 камня и $4 кремня, перезарядка $5 секунд.\n",
|
||||
"rov_compendium_alfar_utsog": "[Открывается со Старейшиной] Утсог: тот, кто гибнет от ваших сил, возвращает вам $1% своего здоровья в виде эйтра.\n",
|
||||
"rov_compendium_alfar_kall": "[Открывается с Боунмассом] Калль (клавиша '$1'): волна молний вокруг вас шириной $2 метров. Перезарядка $3 секунд.\n",
|
||||
"rov_compendium_alfar_ljosstorm": "[Открывается с Модером] Льёсстормр (клавиша '$1'): псионическая буря на площади $2 метров на $3 секунд. Перезарядка $4 секунд.\n",
|
||||
"rov_compendium_alfar_geisli": "[Открывается с Ягнутом] Гейсли (клавиша '$1', удерживать): лазер из правой руки до $2 метров, не дольше $3 секунд, эйтр тратится каждую секунду.\n",
|
||||
"rov_compendium_alfar_kyrr": "[Открывается с Королевой] Кюрр (клавиша '$1'): удерживает того, на кого смотрите, в стазисе $2 секунд ($3 для босса).\n",
|
||||
"rov_compendium_alfar_sameining": "[Открывается с Фадером] Саминг (клавиша '$1'): архонт. Нужно $2% эйтра и готовый Хеймкалль; тратит весь эйтр и превращает его в запас защиты. До $3 секунд вы больше, быстрее и летаете, а псионический импульс бьёт всех врагов вокруг, но оружием пользоваться нельзя. В конце - по времени или с исчерпанным запасом - вас возвращают домой с одной единицей здоровья, и Хеймкалль начинает ожидание.\n",
|
||||
"rov_compendium_alfar_more_to_come": "Новые силы пробуждаются по мере падения великих.\n",
|
||||
"rov_compendium_alfar_nexus_title": "\n-- НЕКСУС --\n",
|
||||
"rov_compendium_alfar_nexus": "Льоскьярне (Молот): сердце базы. Радиус $1 метров, и на квадратный километр может стоять только один (не более $2 на км2). Стоит $3 бронзы. Нажмите на него - откроется рынок: всё, что строят Альфары, берётся отсюда.\n",
|
||||
"rov_compendium_alfar_drones": "Дроны: до $1, по $2 бронзы. Они выполняют обе работы Слуг - логистику через входной сундук и сундуки по типам, кузницу, кухню, ферму с пересадкой - и бесплатно чинят всё повреждённое на базе. Печать в сундуке велит им туда не смотреть.\n",
|
||||
"rov_compendium_alfar_constructs": "Конструкты: Нейстфёрдр (до $1), Эльдингфёрдр (до $2) и Штейнфёрдр (до $3) на Нексус, оплачиваются металлом, кристаллами и эйтром. Их нельзя чинить, а уничтоженные возвращают металл, но не кристаллы и не эйтр.\n",
|
||||
"rov_compendium_alfar_crystals": "Кристаллы: Нексус медленно выращивает их и останавливается на $1, пока кто-нибудь - вы или дрон - их не соберёт. Улучшение за $2 кристаллов ускоряет его.\n",
|
||||
"rov_compendium_alfar_ljosgard": "Льоскгард: модуль Нексуса, превращающий Магекап и Ётунские пуфы в Сок - медленный способ растить магию.\n",
|
||||
"rov_compendium_alfar_towers": "Призмавард: башни из бронзы и кристалла со своим щитом, питаются от радиуса Нексуса, чинятся молотом.\n",
|
||||
"rov_compendium_aswid_always_active_every_form_with": "Активна всегда и в любом облике, не требует зажатия клавиши — только переключение вкл/выкл. Высасывает жизнь в радиусе $1 м днем и $2 м ночью, нанося магический урон, зависящий от навыка «Магия крови», и исцеляя вас на величину нанесенного урона. Враги с запасом здоровья $3% и ниже погибают мгновенно. В человеческом облике аура наносит половинный урон, в облике летучей мыши — полный, а в облике тумана — удвоенный. Аура не отличает торговцев от монстров, поэтому отключайте ее клавишей [I] перед разговором с Хальдором или Хильдир.\n",
|
||||
"rov_compendium_aswid_asmund_passive": "[Награда: Прародитель] Асмунд (Пассивное):",
|
||||
"rov_compendium_aswid_aswid_s_curse": "Проклятие Асвида\n",
|
||||
|
|
|
|||
|
|
@ -135,4 +135,39 @@
|
|||
"rov_piece_boneship_karve_name": "Костяной карви",
|
||||
"rov_piece_boneship_longship_desc": "Сгнивший длинный корабль с ребрами из костей. Он идет против любого ветра.",
|
||||
"rov_piece_boneship_longship_name": "Костяной длинный корабль"
|
||||
,
|
||||
"rov_creature_alfar_neistvordr_name": "Нействордр",
|
||||
"rov_creature_alfar_steinvordr_name": "Стейнвордр",
|
||||
"rov_creature_alfar_eldingvordr_name": "Элдингвордр",
|
||||
"rov_creature_alfar_drone_name": "Льосветтир",
|
||||
"rov_creature_alfar_grafvaettir_name": "Графветтир",
|
||||
"rov_piece_alfar_nexus_name": "Льоскьярне",
|
||||
"rov_piece_alfar_nexus_desc": "Ядро света. Создаёт дронов и конструкты, хранит кристаллы, и вся база работает в его радиусе.",
|
||||
"rov_item_alfar_sphere_name": "Сфера молнии",
|
||||
"rov_item_alfar_zap_name": "Разряд дрона",
|
||||
"rov_alfar_product_drone": "Льосветтир (дрон)",
|
||||
"rov_alfar_product_neistvordr": "Нействордр (огненный конструкт)",
|
||||
"rov_alfar_product_eldingvordr": "Элдингвордр (конструкт молнии)",
|
||||
"rov_alfar_product_steinvordr": "Стейнвордр (каменный конструкт)",
|
||||
"rov_alfar_product_upgrade": "Кристальвигсла (улучшение кристаллами)",
|
||||
"rov_alfar_product_collect": "Забрать кристаллы",
|
||||
"rov_alfar_nexus_next": "Следующий продукт",
|
||||
"rov_alfar_nexus_crystals": "Кристаллов внутри: $1 / $2",
|
||||
"rov_alfar_nexus_no_upgrade": "Кристальвигсла не построена: нет кристаллов, нет конструктов."
|
||||
,
|
||||
"rov_piece_alfar_prismavard_name": "Призмаварт",
|
||||
"rov_piece_alfar_prismavard_desc": "Небольшая бронзовая башня света. Стреляет молниями во врагов, работает только в радиусе Льоскьярне и чинится молотом.",
|
||||
"rov_item_alfar_prismbolt_name": "Болт призмы",
|
||||
"rov_item_alfar_sigil_name": "Эйринсигли",
|
||||
"rov_item_alfar_sigil_desc": "Печать из медянки. Положите её в сундук, и дроны не будут туда смотреть.",
|
||||
"rov_piece_alfar_inngangskista_name": "Инганг-киста",
|
||||
"rov_piece_alfar_inngangskista_desc": "Входной сундук. Бросайте всё сюда: дроны работают отсюда и раскладывают остальное по сундукам с тем же содержимым.",
|
||||
"rov_piece_alfar_eldividarkista_name": "Эльдивидар-киста",
|
||||
"rov_piece_alfar_eldividarkista_desc": "Сундук с дровами. Дроны сжигают только дрова отсюда.",
|
||||
"rov_piece_alfar_ljosgard_name": "Льосгард",
|
||||
"rov_piece_alfar_ljosgard_desc": "Сад света. Очень медленно смешивает магекап и юотунские грибы в сок. Дроны его кормят."
|
||||
,
|
||||
"rov_alfar_nexus_open": "Открыть магазин",
|
||||
"rov_alfar_store_count": "Живых: $1 из $2 разрешённых",
|
||||
"rov_alfar_store_terms": "Оплата из рюкзака, не монетами."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
"rov_msg_core_chose_path_furling": "Вы избрали путь Фурлинга.",
|
||||
"rov_msg_core_chose_path_skadi": "Вы избрали путь Скади.",
|
||||
"rov_msg_core_chose_path_skeleton": "Вы избрали путь Скелета.",
|
||||
"rov_msg_core_chose_path_alfar": "Вы избрали путь Альфаров.",
|
||||
"rov_msg_core_chose_path_sverm": "Вы избрали путь Сверма.",
|
||||
"rov_msg_core_chose_path_trenta": "Вы избрали путь Тренты.",
|
||||
"rov_msg_core_chose_path_trol": "Вы избрали путь Тролля.",
|
||||
|
|
@ -205,5 +206,32 @@
|
|||
"rov_msg_boneship_sunk": "Корабль идет ко дну, и $1 вместе с ним.",
|
||||
"rov_msg_skeleton_summon_on": "Ты вновь поднимешь.",
|
||||
"rov_msg_skeleton_summon_off": "Восстание... никогда более.",
|
||||
"rov_msg_skeleton_summon_locked": "Призыв при убийстве пробудится, когда падёт Королева."
|
||||
"rov_msg_skeleton_summon_locked": "Призыв при убийстве пробудится, когда падёт Королева.",
|
||||
"rov_msg_alfar_heimkall": "Хеймкалль: свет зовёт вас домой.",
|
||||
"rov_msg_alfar_heimkall_nobed": "Хеймкалль: кровать не задана, свет зовёт вас к началу мира.",
|
||||
"rov_msg_alfar_no_eitr": "Недостаточно эйтра.",
|
||||
"rov_msg_alfar_archon_on": "Самейнинг: вы - свет.",
|
||||
"rov_msg_alfar_archon_off": "Свет гаснет. Вас зовут домой.",
|
||||
"rov_msg_alfar_archon_not_charged": "Для Самейнинга нужно почти весь эйтр.",
|
||||
"rov_msg_alfar_archon_not_ready": "Самейнингу нужен готовый Хеймкалль: это цена формы."
|
||||
,
|
||||
"rov_msg_alfar_only_alfar": "Пробудить это могут только Альфары.",
|
||||
"rov_msg_build_limit_alfar_nexus": "Льоскьярне уже держит эту землю. Одно ядро на участок.",
|
||||
"rov_msg_alfar_nexus_cap": "Ядро больше таких не держит.",
|
||||
"rov_msg_alfar_nexus_cannot_pay": "Вам не хватает цены: $1",
|
||||
"rov_msg_alfar_nexus_upgraded": "Кристальвигсла готова. В ядре будут расти кристаллы.",
|
||||
"rov_msg_alfar_nexus_built": "Создано: $1",
|
||||
"rov_msg_alfar_nexus_no_crystals": "В ядре пока нет кристаллов.",
|
||||
"rov_msg_alfar_nexus_collected": "Взято кристаллов: $1",
|
||||
"rov_msg_alfar_graf_materials": "Дронам нужно $1 камня и $2 кремня.",
|
||||
"rov_msg_thrall_refusal_alfar": "Конструкт не знает вашего света.",
|
||||
"rov_msg_thrall_refusal_alfar_drone": "Дрон не слушает приказов. Он работает."
|
||||
,
|
||||
"rov_msg_alfar_tower_needs_nexus": "Призмаварту нужен Льоскьярне поблизости.",
|
||||
"rov_msg_alfar_chest_needs_nexus": "Этому сундуку нужен Льоскьярне поблизости.",
|
||||
"rov_msg_alfar_gard_needs_nexus": "Льосгарду нужен Льоскьярне поблизости.",
|
||||
"rov_msg_build_limit_alfar_chest": "У этого ядра уже есть такой сундук в радиусе.",
|
||||
"rov_msg_build_limit_alfar_ljosgard": "У этого ядра уже есть свой Льосгард."
|
||||
,
|
||||
"rov_msg_alfar_nexus_no_store": "У ядра сейчас нечего предложить."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,5 +23,7 @@
|
|||
"rov_race_trenta_name": "Трента",
|
||||
"rov_race_trenta_desc": "Древоподобный народ, единый с корнями и листвой. Невозмутимы, и их невероятно трудно свалить с ног.",
|
||||
"rov_race_sverm_name": "Сверм",
|
||||
"rov_race_sverm_desc": "Порождение хитинового роя. Закованы в природный панцирь с рождения, ядовиты, дружественны ко всем ползучим тварям, однако дробящие удары и огонь легко находят щели в их защите."
|
||||
"rov_race_sverm_desc": "Порождение хитинового роя. Закованы в природный панцирь с рождения, ядовиты, дружественны ко всем ползучим тварям, однако дробящие удары и огонь легко находят щели в их защите.",
|
||||
"rov_race_alfar_name": "Альфары",
|
||||
"rov_race_alfar_desc": "Заклинатели света из Альфхейма, высокие, серые и тонкие. Еда становится эйтром, а эйтр - вашим щитом: любой удар сначала падает на него, а смерть стоит долгого ожидания, а не потерянной жизни."
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,5 +60,15 @@
|
|||
"rov_se_trol_trueformcd_name": "Перезарядка истинного облика",
|
||||
"rov_se_trol_trueformcd_tooltip": "Вы истощены после пребывания в Истинном облике.",
|
||||
"rov_se_skeleton_raisedead_name": "Восстание мёртвых",
|
||||
"rov_se_skeleton_raisedead_tooltip": "Каждое убийство поднимает скелета, который сражается за тебя. Нажми клавишу призыва при убийстве, чтобы выключить."
|
||||
"rov_se_skeleton_raisedead_tooltip": "Каждое убийство поднимает скелета, который сражается за тебя. Нажми клавишу призыва при убийстве, чтобы выключить.",
|
||||
"rov_se_alfar_timer_skrid_name": "Скрид готов через",
|
||||
"rov_se_alfar_timer_graf_name": "Графветтир готов через",
|
||||
"rov_se_alfar_timer_kall_name": "Калль готов через",
|
||||
"rov_se_alfar_timer_storm_name": "Льёсстормр готов через",
|
||||
"rov_se_alfar_timer_beam_name": "Гейсли готов через",
|
||||
"rov_se_alfar_timer_kyrr_name": "Кюрр готов через",
|
||||
"rov_se_alfar_timer_heimkall_name": "Хеймкалль готов через",
|
||||
"rov_se_alfar_timer_archon_name": "Саминг (архонт)",
|
||||
"rov_se_alfar_stats_name": "Щит эйтра",
|
||||
"rov_se_alfar_stats_tooltip": "Пока у вас есть эйтр, удары сначала падают на него, а падаете вы медленно и без вреда."
|
||||
}
|
||||
|
|
|
|||
35
README.md
35
README.md
|
|
@ -15,15 +15,15 @@ Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorT
|
|||
|
||||
---
|
||||
|
||||
## New in v1.5.15
|
||||
## New in v1.6.0
|
||||
|
||||
Skeleton round: max health is lower in the early and middle game (a fresh Skeleton starts at 50, Fader is unchanged), Auto-Resurrect fires only on a hit that would really kill you, and Summon on Kill can be switched on and off with G. Full details in the [changelog](#v1515).
|
||||
**The Alfar**, an eleventh race: grey, tall and thin, with eyes of solid black, who wear eitr as armour, blink, fly, call down lightning and, with Fader, become an archon. They build an automated base around a **Ljoskjarne** (the Nexus) instead of fighting with troops. Full details in the [changelog](#v160) and under [The Alfar](#11-alfar).
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
|
||||
**Races of Valheim introduces 10 custom playable races:**
|
||||
**Races of Valheim introduces 11 custom playable races:**
|
||||
|
||||
### 1. Skeleton
|
||||

|
||||
|
|
@ -106,6 +106,13 @@ Skeleton round: max health is lower in the early and middle game (a fresh Skelet
|
|||
- **The Colony:** After the Elder, a Brood Mound, a Hive Market and a roster of insect troops bought with digested biomass.
|
||||
- **Ravager Strain:** After Yagluth, become a Seeker Brute, with its own bite, lunging ram and two-claw ground slam that digs the earth. The carapace is worth double.
|
||||
|
||||
### 11. Alfar
|
||||
- **Eitr Shield:** Eitr is your armour: blows land on the eitr pool first, and lightning and spirit cost double. Only drowning and the edge of the world ignore it. Every food you eat also feeds the pool.
|
||||
- **Soft Fall & Levitation:** With eitr in the pool, falls cost nothing and you drift down slowly; hold Jump in the air to rise, burning eitr.
|
||||
- **Heimkall:** A lethal blow wakes you at one health at your bed (or the world's origin if you set none), invulnerable for 5 seconds. Once every 20 minutes, 15 after Yagluth and 10 after Fader.
|
||||
- **Caster powers:** Skrid (blink), Grafvaettir (a grenade of mining drones), Kall (lightning wave), Ljosstorm (psionic storm), Geisli (a laser from the hand), Kyrr (stasis) and, from Fader, Sameining, the archon. Their cooldowns and the Heimkall wait show on screen.
|
||||
- **The Nexus:** a Ljoskjarne with a market, workers that keep the base running, three constructs, crystals, a Ljosgard that turns mushrooms into Sap and bronze turrets. See [Race Stations & Companions](#race-stations--companions).
|
||||
|
||||
---
|
||||
|
||||
## Claws
|
||||
|
|
@ -263,6 +270,21 @@ Build a **Brood Mound** with the hammer — no more than two within its density
|
|||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Alfar Progression</strong></summary>
|
||||
|
||||
- **Base:** Eitr Shield — blows land on the eitr pool first, lightning and spirit cost double; only drowning and the edge of the world skip it. Diet of Light — every food also feeds the pool. Soft Fall and Levitation — falls are free and slow while there is eitr; hold Jump in the air to rise. Heimkall — a lethal blow sends you home at one health, 5 seconds of invulnerability, once every 20 minutes.
|
||||
- **Eikthyr:** Skrid (G) — blink where you look. Grafvaettir (H) — a grenade of mining drones that dig out every precious ore around for 2 minutes, then vanish.
|
||||
- **Elder:** Utsog — what dies to your powers gives back part of its health as eitr.
|
||||
- **Bonemass:** Kall (J) — a wave of lightning around you.
|
||||
- **Moder:** Ljosstorm (K) — a psionic storm over an area.
|
||||
- **Yagluth:** Geisli (O, hold) — a laser from your right hand. Heimkall wait drops to 15 minutes.
|
||||
- **Queen:** Kyrr (U) — stasis on what you look at.
|
||||
- **Fader:** Sameining (I) — the archon: all your eitr becomes a pool of protection; larger, faster, flying, a psionic pulse instead of weapons, up to 3 minutes. It ends with a trip home at one health. Heimkall wait drops to 10 minutes.
|
||||
|
||||
**The Nexus:** build a **Ljoskjarne** with the hammer, one per square kilometer, and press it for its market: drones, constructs, upgrades and crystals. Drones do both trades of the Bone Servants — logistics through an entry chest and chests by type, the forge, the kitchen, the farm with replanting — and repair what is damaged for free. A seal in a chest tells them not to look. The three constructs (Neistvordr, Eldingvordr, Steinvordr) are paid in metal, crystals and eitr; they cannot be repaired, and when destroyed give back the metal. The Nexus grows crystals slowly and stops when full until someone collects them. The **Ljosgard** turns Magecap and Jotun Puffs into Sap, and the **Prismavard** is a bronze turret powered by the Nexus.
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><strong>Trenta Progression</strong></summary>
|
||||
|
||||
|
|
@ -303,6 +325,7 @@ Every race has a buildable station of its own, gated by a reagent bought from it
|
|||
- **Skadi — Crystal Golem & Bone Cook:** a stonecutter-bound guardian on a leash. Skadi (and Trol) may also build inside any troll cave in the world. The Cook is Skadi's own half of the [Bone Servants](#skeleton--skadi--bone-servants).
|
||||
- **Skeleton — Bound Bone Pile, Bound Sentry & Bone Smith:** pay once per slot and that slot refills itself forever, because an army you re-buy after every fight is one nobody takes out of the house. Both the pile and the Sentry can be built on the ground, on floors and on foundations. The Sentry is a bound archer that cannot walk, regenerates when left alone, and hands its parts back when it falls. The Smith is Skeleton and Skadi's shared half of the [Bone Servants](#skeleton--skadi--bone-servants).
|
||||
- **Sverm — Brood Mound & Hive Market:** see [The Colony](#race-progressions-level-by-level).
|
||||
- **Alfar — Ljoskjarne (the Nexus), Ljosgard & Prismavard:** the Nexus is a market and the heart of an automated base: drones, three constructs and crystals. The Ljosgard turns two Mistland mushrooms into Sap. The Prismavard is a bronze turret. One Nexus per square kilometer; all of it Alfar only. See [Alfar Progression](#race-progressions-level-by-level).
|
||||
- **Trenta — Composter, Heartwood Grove & Root of the Elder:** the Composter rots raw flesh into Fertilizer, which grows any plant on the spot. The Grove is a tree that fertilises what surrounds it, stings what approaches it, and fills a chest with honey. The Root is one of the Elder's own summoned roots, planted for good: it knits its own wounds shut, and once a minute it repairs every player-built thing within five meters of it — anyone's, not just the Trenta's. Race locked, and only after the Elder falls.
|
||||
- **Trol — War Totem:** hires warbands of trolls and greydwarves for coin. Race locked — the hammer refuses it to anyone who is not a Trol. A dead warband is money spent.
|
||||
|
||||
|
|
@ -451,6 +474,12 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact
|
|||
|
||||
## Changelog
|
||||
|
||||
### v1.6.0
|
||||
- **New - the Alfar:** an eleventh race. Grey skin, a little taller and thinner than a viking, bald, with black eyes. Eitr is their armour and their fuel: blows land on the eitr pool first, food feeds it, falls are soft and free while it lasts, and holding Jump in the air makes you rise. A lethal blow sends you to your bed (or the world's origin) at one health once every 20 minutes (Heimkall).
|
||||
- **New - Alfar powers:** Skrid (blink) and Grafvaettir (mining drones) from Eikthyr, Utsog from the Elder, Kall from Bonemass, Ljosstorm from Moder, Geisli (laser from the hand) from Yagluth, Kyrr (stasis) from the Queen, and from Fader the archon Sameining. Cooldowns, the Heimkall wait and the archon's duration show on screen.
|
||||
- **New - the Alfar base:** the Ljoskjarne (Nexus) market, worker drones, three constructs, crystals, the Ljosgard and the Prismavard turret. See [Alfar Progression](#race-progressions-level-by-level).
|
||||
- **New - compendium and languages:** the Alfar have their compendium page, in English, Italian and Russian.
|
||||
|
||||
### v1.5.15
|
||||
- **Balance - Skeleton max health:** lower in the early and middle game. The bonus over the base 25 is now +25 / +45 / +65 / +90 / +125 / +165 / +215 / +275, from no bosses to Fader (it was +50 / +80 / +110 / +140 / +170 / +200 / +230 / +275). A fresh Skeleton starts at 50 instead of 75; from Yagluth on the gap closes, and Fader is unchanged at 300. A Skeleton never needs food and never spends stamina, so it was well ahead of a fed viking at every tier. Thanks to Jondar Korric and everyone else who asked for this.
|
||||
- **Fix - Auto-Resurrect on any hit:** a Skeleton's Auto-Resurrect now triggers only on a hit that would actually kill you. It used to compare the raw hit, before armour and blocking, with its poison and fire counted all at once, so with good armour it fired on almost any hit. On dedicated servers it could also miss a real deathblow when the server or another player controlled the attacker. Thanks to akira for the report.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "RacesOfValheim",
|
||||
"description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
|
||||
"version_number": "1.5.15",
|
||||
"version_number": "1.6.0",
|
||||
"website_url": "",
|
||||
"dependencies": [
|
||||
"denikson-BepInExPack_Valheim-5.4.2333",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue