Merge pull request 'fix-aswid-dvergar' (#8) from fix-aswid-dvergar into main
Reviewed-on: #8
This commit is contained in:
commit
49413df038
14 changed files with 394 additions and 235 deletions
|
|
@ -661,19 +661,56 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True while the local Aswid is holding a blood magic item. The three eitr patches below
|
||||||
|
/// all turn on exactly this condition, so it lives in one place rather than three.
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsLocalAswidWieldingBloodMagic(Character character)
|
||||||
|
{
|
||||||
|
if (character == null || character != Player.m_localPlayer) return false;
|
||||||
|
if (!AswidRace.IsAswid()) return false;
|
||||||
|
|
||||||
|
ItemDrop.ItemData weapon = Player.m_localPlayer.GetCurrentWeapon();
|
||||||
|
return weapon != null && weapon.m_shared != null &&
|
||||||
|
weapon.m_shared.m_skillType == Skills.SkillType.BloodMagic;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The gate that actually decides whether a blood magic attack may start, and the reason
|
||||||
|
/// Blood Magic Mastery did nothing.
|
||||||
|
///
|
||||||
|
/// Attack.Start asks Character.TryUseEitr, whose very first test is:
|
||||||
|
///
|
||||||
|
/// if (GetMaxEitr() == 0) { Message("$hud_eitrrequired"); return false; }
|
||||||
|
///
|
||||||
|
/// An Aswid carrying no eitr food has a maximum of zero, so the attack was refused right
|
||||||
|
/// there - before HaveEitr was ever consulted, which is why forcing HaveEitr true (below)
|
||||||
|
/// changed nothing on its own. Freeing the cast has to happen here.
|
||||||
|
///
|
||||||
|
/// TryUseEitr only ever gates; the spend happens separately through UseEitr, so returning
|
||||||
|
/// true costs nothing. The health price of blood magic is charged elsewhere and is left
|
||||||
|
/// completely alone - it is meant to be the whole price.
|
||||||
|
/// </summary>
|
||||||
|
[HarmonyPatch(typeof(Character), "TryUseEitr")]
|
||||||
|
public static class Character_TryUseEitr_Patch
|
||||||
|
{
|
||||||
|
public static bool Prefix(Character __instance, ref bool __result)
|
||||||
|
{
|
||||||
|
if (!IsLocalAswidWieldingBloodMagic(__instance)) return true;
|
||||||
|
|
||||||
|
__result = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Player), "HaveEitr")]
|
[HarmonyPatch(typeof(Player), "HaveEitr")]
|
||||||
public static class Player_HaveEitr_Patch
|
public static class Player_HaveEitr_Patch
|
||||||
{
|
{
|
||||||
public static void Postfix(Player __instance, ref bool __result)
|
public static void Postfix(Player __instance, ref bool __result)
|
||||||
{
|
{
|
||||||
if (__instance != null && __instance == Player.m_localPlayer && AswidRace.IsAswid())
|
// Still needed for the paths that ask HaveEitr directly rather than through
|
||||||
{
|
// TryUseEitr - Attack.FireProjectileBurst and the bow/crossbow draw among them.
|
||||||
var weapon = __instance.GetCurrentWeapon();
|
if (IsLocalAswidWieldingBloodMagic(__instance)) __result = true;
|
||||||
if (weapon != null && weapon.m_shared != null && weapon.m_shared.m_skillType == Skills.SkillType.BloodMagic)
|
|
||||||
{
|
|
||||||
__result = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -682,14 +719,7 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
public static bool Prefix(Player __instance)
|
public static bool Prefix(Player __instance)
|
||||||
{
|
{
|
||||||
if (__instance != null && __instance == Player.m_localPlayer && AswidRace.IsAswid())
|
if (IsLocalAswidWieldingBloodMagic(__instance)) return false; // Skip spending Eitr
|
||||||
{
|
|
||||||
var weapon = __instance.GetCurrentWeapon();
|
|
||||||
if (weapon != null && weapon.m_shared != null && weapon.m_shared.m_skillType == Skills.SkillType.BloodMagic)
|
|
||||||
{
|
|
||||||
return false; // Skip spending Eitr
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,15 @@ using UnityEngine;
|
||||||
namespace RacesOfValheim
|
namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Dvergur's two eitr abilities.
|
/// The Dvergar's two eitr abilities.
|
||||||
///
|
///
|
||||||
/// Runic Ping (Yagluth) - spend eitr to light up ore veins and hidden enemies nearby.
|
/// Runic Ping (Yagluth) - spend eitr to light up ore veins and hidden enemies nearby.
|
||||||
/// Runic Overcharge (Fader) - spend eitr to load the next blow of a favoured weapon.
|
/// Runic Overcharge (Fader) - spend eitr to load the next blow of a favoured weapon.
|
||||||
///
|
///
|
||||||
/// Both are driven from DvergurRace.Update and both read their cost, radius, duration and
|
/// Both are driven from DvergarRace.Update and both read their cost, radius, duration and
|
||||||
/// cooldown out of DvergurConfig.
|
/// cooldown out of DvergarConfig.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class DvergurAbilities
|
public static class DvergarAbilities
|
||||||
{
|
{
|
||||||
private static float lastPingTime = -1000f;
|
private static float lastPingTime = -1000f;
|
||||||
private static float lastOverchargeTime = -1000f;
|
private static float lastOverchargeTime = -1000f;
|
||||||
|
|
@ -24,14 +24,14 @@ namespace RacesOfValheim
|
||||||
// Player.TakeInput, so nothing fires while a map, chest or chat window has focus.
|
// Player.TakeInput, so nothing fires while a map, chest or chat window has focus.
|
||||||
if (!RaceInput.Allowed) return;
|
if (!RaceInput.Allowed) return;
|
||||||
|
|
||||||
DvergurProgression.DvergurRules rules = DvergurProgression.GetRules(state);
|
DvergarProgression.DvergarRules rules = DvergarProgression.GetRules(state);
|
||||||
|
|
||||||
if (rules.RunicPing && Input.GetKeyDown(DvergurConfig.RunicPingKey))
|
if (rules.RunicPing && Input.GetKeyDown(DvergarConfig.RunicPingKey))
|
||||||
{
|
{
|
||||||
TryRunicPing(player);
|
TryRunicPing(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rules.RunicOvercharge && Input.GetKeyDown(DvergurConfig.RunicOverchargeKey))
|
if (rules.RunicOvercharge && Input.GetKeyDown(DvergarConfig.RunicOverchargeKey))
|
||||||
{
|
{
|
||||||
TryRunicOvercharge(player);
|
TryRunicOvercharge(player);
|
||||||
}
|
}
|
||||||
|
|
@ -41,17 +41,17 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
private static void TryRunicPing(Player player)
|
private static void TryRunicPing(Player player)
|
||||||
{
|
{
|
||||||
if (Time.time - lastPingTime < DvergurConfig.RunicPingCooldown) return;
|
if (Time.time - lastPingTime < DvergarConfig.RunicPingCooldown) return;
|
||||||
|
|
||||||
if (player.GetEitr() < DvergurConfig.RunicPingEitrCost)
|
if (player.GetEitr() < DvergarConfig.RunicPingEitrCost)
|
||||||
{
|
{
|
||||||
player.Message(MessageHud.MessageType.Center, "Not enough eitr");
|
player.Message(MessageHud.MessageType.Center, "Not enough eitr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.UseEitr(DvergurConfig.RunicPingEitrCost);
|
player.UseEitr(DvergarConfig.RunicPingEitrCost);
|
||||||
lastPingTime = Time.time;
|
lastPingTime = Time.time;
|
||||||
DvergurStatusEffects.ApplyCooldownIcon(DvergurConfig.RunicPingCdSE, DvergurConfig.RunicPingCooldown);
|
DvergarStatusEffects.ApplyCooldownIcon(DvergarConfig.RunicPingCdSE, DvergarConfig.RunicPingCooldown);
|
||||||
|
|
||||||
int marked = MarkSurroundings(player);
|
int marked = MarkSurroundings(player);
|
||||||
player.Message(MessageHud.MessageType.Center,
|
player.Message(MessageHud.MessageType.Center,
|
||||||
|
|
@ -69,25 +69,25 @@ namespace RacesOfValheim
|
||||||
HashSet<GameObject> alreadyMarked = new HashSet<GameObject>();
|
HashSet<GameObject> alreadyMarked = new HashSet<GameObject>();
|
||||||
int marked = 0;
|
int marked = 0;
|
||||||
|
|
||||||
foreach (Collider collider in Physics.OverlapSphere(center, DvergurConfig.RunicPingRadius))
|
foreach (Collider collider in Physics.OverlapSphere(center, DvergarConfig.RunicPingRadius))
|
||||||
{
|
{
|
||||||
if (collider == null) continue;
|
if (collider == null) continue;
|
||||||
|
|
||||||
GameObject vein = FindVeinRoot(collider);
|
GameObject vein = FindVeinRoot(collider);
|
||||||
if (vein == null || !alreadyMarked.Add(vein)) continue;
|
if (vein == null || !alreadyMarked.Add(vein)) continue;
|
||||||
|
|
||||||
SpawnMarker(vein.transform, DvergurConfig.RunicPingOreColor);
|
SpawnMarker(vein.transform, DvergarConfig.RunicPingOreColor);
|
||||||
marked++;
|
marked++;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Character character in Character.GetAllCharacters())
|
foreach (Character character in Character.GetAllCharacters())
|
||||||
{
|
{
|
||||||
if (character == null || character == player || character.IsDead() || character.IsTamed()) continue;
|
if (character == null || character == player || character.IsDead() || character.IsTamed()) continue;
|
||||||
if (Vector3.Distance(character.transform.position, center) > DvergurConfig.RunicPingRadius) continue;
|
if (Vector3.Distance(character.transform.position, center) > DvergarConfig.RunicPingRadius) continue;
|
||||||
if (!BaseAI.IsEnemy(player, character)) continue;
|
if (!BaseAI.IsEnemy(player, character)) continue;
|
||||||
if (!alreadyMarked.Add(character.gameObject)) continue;
|
if (!alreadyMarked.Add(character.gameObject)) continue;
|
||||||
|
|
||||||
SpawnMarker(character.transform, DvergurConfig.RunicPingEnemyColor);
|
SpawnMarker(character.transform, DvergarConfig.RunicPingEnemyColor);
|
||||||
marked++;
|
marked++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,7 +124,7 @@ namespace RacesOfValheim
|
||||||
if (root == null) return null;
|
if (root == null) return null;
|
||||||
|
|
||||||
string name = root.name.ToLower();
|
string name = root.name.ToLower();
|
||||||
foreach (string veinName in DvergurConfig.RunicPingVeinNames)
|
foreach (string veinName in DvergarConfig.RunicPingVeinNames)
|
||||||
{
|
{
|
||||||
if (name.Contains(veinName)) return root;
|
if (name.Contains(veinName)) return root;
|
||||||
}
|
}
|
||||||
|
|
@ -133,20 +133,20 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
private static void SpawnMarker(Transform target, Color color)
|
private static void SpawnMarker(Transform target, Color color)
|
||||||
{
|
{
|
||||||
GameObject markerObj = new GameObject("DvergurRunicMark");
|
GameObject markerObj = new GameObject("DvergarRunicMark");
|
||||||
markerObj.transform.SetParent(target, false);
|
markerObj.transform.SetParent(target, false);
|
||||||
markerObj.transform.localPosition = Vector3.up;
|
markerObj.transform.localPosition = Vector3.up;
|
||||||
|
|
||||||
Light light = markerObj.AddComponent<Light>();
|
Light light = markerObj.AddComponent<Light>();
|
||||||
light.type = LightType.Point;
|
light.type = LightType.Point;
|
||||||
light.color = color;
|
light.color = color;
|
||||||
light.range = DvergurConfig.RunicPingLightRange;
|
light.range = DvergarConfig.RunicPingLightRange;
|
||||||
light.intensity = DvergurConfig.RunicPingLightIntensity;
|
light.intensity = DvergarConfig.RunicPingLightIntensity;
|
||||||
light.shadows = LightShadows.None;
|
light.shadows = LightShadows.None;
|
||||||
|
|
||||||
if (DvergurRace.Instance != null)
|
if (DvergarRace.Instance != null)
|
||||||
{
|
{
|
||||||
DvergurRace.Instance.StartCoroutine(DestroyAfter(markerObj, DvergurConfig.RunicPingDuration));
|
DvergarRace.Instance.StartCoroutine(DestroyAfter(markerObj, DvergarConfig.RunicPingDuration));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -166,38 +166,38 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
private static void TryRunicOvercharge(Player player)
|
private static void TryRunicOvercharge(Player player)
|
||||||
{
|
{
|
||||||
if (Time.time - lastOverchargeTime < DvergurConfig.RunicOverchargeCooldown) return;
|
if (Time.time - lastOverchargeTime < DvergarConfig.RunicOverchargeCooldown) return;
|
||||||
|
|
||||||
int overchargeHash = DvergurConfig.OverchargeSE.GetStableHashCode();
|
int overchargeHash = DvergarConfig.OverchargeSE.GetStableHashCode();
|
||||||
if (player.GetSEMan().HaveStatusEffect(overchargeHash)) return; // already loaded
|
if (player.GetSEMan().HaveStatusEffect(overchargeHash)) return; // already loaded
|
||||||
|
|
||||||
if (player.GetEitr() < DvergurConfig.RunicOverchargeEitrCost)
|
if (player.GetEitr() < DvergarConfig.RunicOverchargeEitrCost)
|
||||||
{
|
{
|
||||||
player.Message(MessageHud.MessageType.Center, "Not enough eitr");
|
player.Message(MessageHud.MessageType.Center, "Not enough eitr");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.UseEitr(DvergurConfig.RunicOverchargeEitrCost);
|
player.UseEitr(DvergarConfig.RunicOverchargeEitrCost);
|
||||||
lastOverchargeTime = Time.time;
|
lastOverchargeTime = Time.time;
|
||||||
DvergurStatusEffects.ApplyCooldownIcon(DvergurConfig.OverchargeCdSE, DvergurConfig.RunicOverchargeCooldown);
|
DvergarStatusEffects.ApplyCooldownIcon(DvergarConfig.OverchargeCdSE, DvergarConfig.RunicOverchargeCooldown);
|
||||||
|
|
||||||
player.GetSEMan().AddStatusEffect(overchargeHash, true);
|
player.GetSEMan().AddStatusEffect(overchargeHash, true);
|
||||||
StatusEffect se = player.GetSEMan().GetStatusEffect(overchargeHash);
|
StatusEffect se = player.GetSEMan().GetStatusEffect(overchargeHash);
|
||||||
// The charge is held, not permanent: it lapses if no favoured blow lands in time.
|
// The charge is held, not permanent: it lapses if no favoured blow lands in time.
|
||||||
if (se != null) se.m_ttl = DvergurConfig.RunicOverchargeWindow;
|
if (se != null) se.m_ttl = DvergarConfig.RunicOverchargeWindow;
|
||||||
|
|
||||||
player.Message(MessageHud.MessageType.Center, "Runic Overcharge: your next blow is loaded");
|
player.Message(MessageHud.MessageType.Center, "Runic Overcharge: your next blow is loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Spends a held charge. Called from the damage patch once it has confirmed the blow was
|
/// Spends a held charge. Called from the damage patch once it has confirmed the blow was
|
||||||
/// struck with a weapon the Dvergur is at home with.
|
/// struck with a weapon the Dvergar is at home with.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool ConsumeOvercharge(Player player)
|
public static bool ConsumeOvercharge(Player player)
|
||||||
{
|
{
|
||||||
if (player == null) return false;
|
if (player == null) return false;
|
||||||
|
|
||||||
int hash = DvergurConfig.OverchargeSE.GetStableHashCode();
|
int hash = DvergarConfig.OverchargeSE.GetStableHashCode();
|
||||||
if (!player.GetSEMan().HaveStatusEffect(hash)) return false;
|
if (!player.GetSEMan().HaveStatusEffect(hash)) return false;
|
||||||
|
|
||||||
player.GetSEMan().RemoveStatusEffect(hash, true);
|
player.GetSEMan().RemoveStatusEffect(hash, true);
|
||||||
|
|
@ -3,29 +3,29 @@ using UnityEngine;
|
||||||
namespace RacesOfValheim
|
namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Every tunable number the Dvergur uses, in one place.
|
/// Every tunable number the Dvergar uses, in one place.
|
||||||
///
|
///
|
||||||
/// The race was specced with most percentages still open, so nothing here is baked into the
|
/// The race was specced with most percentages still open, so nothing here is baked into the
|
||||||
/// logic: DvergurProgression reads these to build its per-tier rules and the patches read the
|
/// logic: DvergarProgression reads these to build its per-tier rules and the patches read the
|
||||||
/// rules, never a literal. Retuning the race means editing this file only.
|
/// rules, never a literal. Retuning the race means editing this file only.
|
||||||
///
|
///
|
||||||
/// Values still marked TODO are placeholders chosen to be playable, not final.
|
/// Values still marked TODO are placeholders chosen to be playable, not final.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class DvergurConfig
|
public static class DvergarConfig
|
||||||
{
|
{
|
||||||
// ─── Identity ────────────────────────────────────────────────────────
|
// ─── Identity ────────────────────────────────────────────────────────
|
||||||
// "Dvergur" is provisional. It is the value stored in m_customData["Race"] and in the
|
// "Dvergar" is provisional. It is the value stored in m_customData["Race"] and in the
|
||||||
// ZDO, so renaming it after players have chosen the race would orphan their characters.
|
// ZDO, so renaming it after players have chosen the race would orphan their characters.
|
||||||
public const string RaceId = "Dvergur";
|
public const string RaceId = "Dvergar";
|
||||||
|
|
||||||
public const string StatsSE = "SE_DvergurStats";
|
public const string StatsSE = "SE_DvergarStats";
|
||||||
public const string OverchargeSE = "SE_DvergurOvercharge";
|
public const string OverchargeSE = "SE_DvergarOvercharge";
|
||||||
public const string RunicPingCdSE = "SE_DvergurRunicPingCooldown";
|
public const string RunicPingCdSE = "SE_DvergarRunicPingCooldown";
|
||||||
public const string OverchargeCdSE = "SE_DvergurOverchargeCooldown";
|
public const string OverchargeCdSE = "SE_DvergarOverchargeCooldown";
|
||||||
|
|
||||||
// Mirrors the ZDO key layout the other races use, so remote clients can read the tier
|
// Mirrors the ZDO key layout the other races use, so remote clients can read the tier
|
||||||
// without having the local player's progression state.
|
// without having the local player's progression state.
|
||||||
public const string StateZdoKey = "RacesOfValheim_DvergurState";
|
public const string StateZdoKey = "RacesOfValheim_DvergarState";
|
||||||
|
|
||||||
// ─── Model ───────────────────────────────────────────────────────────
|
// ─── Model ───────────────────────────────────────────────────────────
|
||||||
// Applied to the player's "Visual" child rather than the root transform, the way Furling
|
// Applied to the player's "Visual" child rather than the root transform, the way Furling
|
||||||
|
|
@ -44,7 +44,7 @@ namespace RacesOfValheim
|
||||||
// This is a multiplier over the human skin texture, not a replacement, so a value near
|
// This is a multiplier over the human skin texture, not a replacement, so a value near
|
||||||
// (1,1,1) changes nothing anyone can see. The first attempt at (0.72, 0.74, 0.82) was
|
// (1,1,1) changes nothing anyone can see. The first attempt at (0.72, 0.74, 0.82) was
|
||||||
// exactly that mistake: correct code, invisible result. Every race that reads clearly
|
// exactly that mistake: correct code, invisible result. Every race that reads clearly
|
||||||
// commits to a channel - Trol (0.1, 0.6, 0.7), Furling (0.3, 0.8, 0.3) - so the Dvergur
|
// commits to a channel - Trol (0.1, 0.6, 0.7), Furling (0.3, 0.8, 0.3) - so the Dvergar
|
||||||
// does too: a cold, dark slate blue-grey.
|
// does too: a cold, dark slate blue-grey.
|
||||||
public static readonly Color SkinColor = new Color(0.42f, 0.52f, 0.68f, 1f);
|
public static readonly Color SkinColor = new Color(0.42f, 0.52f, 0.68f, 1f);
|
||||||
|
|
||||||
|
|
@ -103,9 +103,20 @@ namespace RacesOfValheim
|
||||||
20f // 8 Fader
|
20f // 8 Fader
|
||||||
};
|
};
|
||||||
|
|
||||||
// A Dvergur must never be reduced below this, however the malus and food line up.
|
// A Dvergar must never be reduced below this, however the malus and food line up.
|
||||||
public static readonly float MinMaxHealth = 5f;
|
public static readonly float MinMaxHealth = 5f;
|
||||||
|
|
||||||
|
// ─── Elemental affinity ──────────────────────────────────────────────
|
||||||
|
// Runes in the blood: every blow the Dvergar lands carries lightning.
|
||||||
|
//
|
||||||
|
// Deliberately the same shape as Skadi's Ice Affinity - live from the base tier and
|
||||||
|
// growing by a flat step per progression state, so +2 at Base through +16 after Fader -
|
||||||
|
// with lightning in place of frost. SkadiDamagePatch is the reference; like it, this
|
||||||
|
// applies to every blow the player lands, not only melee.
|
||||||
|
public static readonly float ElementalDamagePerState = 2f;
|
||||||
|
|
||||||
|
public static readonly HitData.DamageType ElementalDamageType = HitData.DamageType.Lightning;
|
||||||
|
|
||||||
// ─── Weapon affinity ─────────────────────────────────────────────────
|
// ─── Weapon affinity ─────────────────────────────────────────────────
|
||||||
// Bonus damage plus a stamina discount on the attack. Neither scales with the tier - a
|
// Bonus damage plus a stamina discount on the attack. Neither scales with the tier - a
|
||||||
// tier only ever adds a new weapon to the list - and skill XP is deliberately untouched.
|
// tier only ever adds a new weapon to the list - and skill XP is deliberately untouched.
|
||||||
|
|
@ -6,15 +6,15 @@ using UnityEngine;
|
||||||
namespace RacesOfValheim
|
namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Every hook the Dvergur needs. The patches only ever decide *whether* a perk applies; *how
|
/// Every hook the Dvergar needs. The patches only ever decide *whether* a perk applies; *how
|
||||||
/// much* it applies always comes from DvergurProgression, which in turn reads DvergurConfig.
|
/// much* it applies always comes from DvergarProgression, which in turn reads DvergarConfig.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class DvergurPatches
|
public static class DvergarPatches
|
||||||
{
|
{
|
||||||
// ─── Health malus ────────────────────────────────────────────────────
|
// ─── Health malus ────────────────────────────────────────────────────
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Dvergur is a small frame, and carries less health for it.
|
/// The Dvergar is a small frame, and carries less health for it.
|
||||||
///
|
///
|
||||||
/// The malus is taken off the food total rather than off Character.GetMaxHealth, which is
|
/// The malus is taken off the food total rather than off Character.GetMaxHealth, which is
|
||||||
/// what the first attempt did and what produced the bug where the bar shrank but the
|
/// what the first attempt did and what produced the bug where the bar shrank but the
|
||||||
|
|
@ -30,17 +30,17 @@ namespace RacesOfValheim
|
||||||
/// number and bar, value and animation all agree.
|
/// number and bar, value and animation all agree.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
|
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
|
||||||
public static class Dvergur_GetTotalFoodValue_Patch
|
public static class Dvergar_GetTotalFoodValue_Patch
|
||||||
{
|
{
|
||||||
public static void Postfix(Player __instance, ref float hp)
|
public static void Postfix(Player __instance, ref float hp)
|
||||||
{
|
{
|
||||||
if (__instance == null || __instance != Player.m_localPlayer) return;
|
if (__instance == null || __instance != Player.m_localPlayer) return;
|
||||||
if (!DvergurRace.IsDvergur()) return;
|
if (!DvergarRace.IsDvergar()) return;
|
||||||
|
|
||||||
float malus = DvergurProgression.Current.HealthMalus;
|
float malus = DvergarProgression.Current.HealthMalus;
|
||||||
if (malus <= 0f) return;
|
if (malus <= 0f) return;
|
||||||
|
|
||||||
hp = Mathf.Max(DvergurConfig.MinMaxHealth, hp - malus);
|
hp = Mathf.Max(DvergarConfig.MinMaxHealth, hp - malus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,16 +50,16 @@ namespace RacesOfValheim
|
||||||
/// Sizing runs off Player.Update, which is where the Trol does it and the only place it
|
/// Sizing runs off Player.Update, which is where the Trol does it and the only place it
|
||||||
/// holds: Trol's own postfix forces every non-Trol player's visual back to scale 1 on the
|
/// holds: Trol's own postfix forces every non-Trol player's visual back to scale 1 on the
|
||||||
/// same frame, so a scale applied from anywhere else was simply overwritten. Being a
|
/// same frame, so a scale applied from anywhere else was simply overwritten. Being a
|
||||||
/// postfix on the same method puts the Dvergur on equal footing, and RaceScale keeps the
|
/// postfix on the same method puts the Dvergar on equal footing, and RaceScale keeps the
|
||||||
/// two from undoing each other.
|
/// two from undoing each other.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HarmonyPatch(typeof(Player), "Update")]
|
[HarmonyPatch(typeof(Player), "Update")]
|
||||||
public static class Dvergur_PlayerUpdate_Scale_Patch
|
public static class Dvergar_PlayerUpdate_Scale_Patch
|
||||||
{
|
{
|
||||||
public static void Postfix(Player __instance)
|
public static void Postfix(Player __instance)
|
||||||
{
|
{
|
||||||
if (__instance == null) return;
|
if (__instance == null) return;
|
||||||
DvergurVisuals.ApplyScale(__instance, DvergurVisuals.IsDvergurPlayer(__instance));
|
DvergarVisuals.ApplyScale(__instance, DvergarVisuals.IsDvergarPlayer(__instance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,23 +67,32 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bonus damage with hammer, bow, axe and crossbow as each is unlocked, and the payoff for
|
/// Bonus damage with hammer, bow, axe and crossbow as each is unlocked, and the payoff for
|
||||||
/// a held Runic Overcharge. Neither touches skill XP: the Dvergur is at home with these
|
/// a held Runic Overcharge. Neither touches skill XP: the Dvergar is at home with these
|
||||||
/// weapons, not faster at learning them.
|
/// weapons, not faster at learning them.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HarmonyPatch(typeof(Character), "Damage")]
|
[HarmonyPatch(typeof(Character), "Damage")]
|
||||||
public static class Dvergur_WeaponAffinity_Damage_Patch
|
public static class Dvergar_WeaponAffinity_Damage_Patch
|
||||||
{
|
{
|
||||||
public static void Prefix(Character __instance, HitData hit)
|
public static void Prefix(Character __instance, HitData hit)
|
||||||
{
|
{
|
||||||
if (hit == null || Player.m_localPlayer == null) return;
|
if (hit == null || Player.m_localPlayer == null) return;
|
||||||
if (hit.GetAttacker() != Player.m_localPlayer) return;
|
if (hit.GetAttacker() != Player.m_localPlayer) return;
|
||||||
if (!DvergurRace.IsDvergur()) return;
|
if (!DvergarRace.IsDvergar()) return;
|
||||||
|
|
||||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||||
DvergurConfig.WeaponAffinity? found = DvergurProgression.GetAffinity(hit.m_skill, state);
|
|
||||||
|
// Runic Spark, before the weapon check: the lightning rides every blow the Dvergar
|
||||||
|
// lands, favoured weapon or not, exactly as Skadi's frost does in SkadiDamagePatch.
|
||||||
|
float elemental = DvergarProgression.GetRules(state).ElementalDamage;
|
||||||
|
if (elemental > 0f)
|
||||||
|
{
|
||||||
|
AddFlat(hit, DvergarConfig.ElementalDamageType, elemental);
|
||||||
|
}
|
||||||
|
|
||||||
|
DvergarConfig.WeaponAffinity? found = DvergarProgression.GetAffinity(hit.m_skill, state);
|
||||||
if (!found.HasValue) return;
|
if (!found.HasValue) return;
|
||||||
|
|
||||||
DvergurConfig.WeaponAffinity affinity = found.Value;
|
DvergarConfig.WeaponAffinity affinity = found.Value;
|
||||||
|
|
||||||
if (affinity.DamagePercent > 0f)
|
if (affinity.DamagePercent > 0f)
|
||||||
{
|
{
|
||||||
|
|
@ -97,10 +106,10 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
// Overcharge only ever discharges into a favoured weapon, which is why it is
|
// Overcharge only ever discharges into a favoured weapon, which is why it is
|
||||||
// spent here rather than on the first hit of any kind.
|
// spent here rather than on the first hit of any kind.
|
||||||
if (DvergurProgression.GetRules(state).RunicOvercharge &&
|
if (DvergarProgression.GetRules(state).RunicOvercharge &&
|
||||||
DvergurAbilities.ConsumeOvercharge(Player.m_localPlayer))
|
DvergarAbilities.ConsumeOvercharge(Player.m_localPlayer))
|
||||||
{
|
{
|
||||||
ScalePhysical(hit, DvergurConfig.RunicOverchargeMultiplier);
|
ScalePhysical(hit, DvergarConfig.RunicOverchargeMultiplier);
|
||||||
Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Runic Overcharge discharges");
|
Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Runic Overcharge discharges");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -116,10 +125,15 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case HitData.DamageType.Blunt: hit.m_damage.m_blunt += amount; break;
|
case HitData.DamageType.Blunt: hit.m_damage.m_blunt += amount; break;
|
||||||
case HitData.DamageType.Slash: hit.m_damage.m_slash += amount; break;
|
case HitData.DamageType.Slash: hit.m_damage.m_slash += amount; break;
|
||||||
case HitData.DamageType.Pierce: hit.m_damage.m_pierce += amount; break;
|
case HitData.DamageType.Pierce: hit.m_damage.m_pierce += amount; break;
|
||||||
default: hit.m_damage.m_damage += amount; break;
|
case HitData.DamageType.Fire: hit.m_damage.m_fire += amount; break;
|
||||||
|
case HitData.DamageType.Frost: hit.m_damage.m_frost += amount; break;
|
||||||
|
case HitData.DamageType.Lightning: hit.m_damage.m_lightning += amount; break;
|
||||||
|
case HitData.DamageType.Poison: hit.m_damage.m_poison += amount; break;
|
||||||
|
case HitData.DamageType.Spirit: hit.m_damage.m_spirit += amount; break;
|
||||||
|
default: hit.m_damage.m_damage += amount; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -131,63 +145,63 @@ namespace RacesOfValheim
|
||||||
/// by this player apart from every other DropTable call in the world. Same flag-around-the
|
/// by this player apart from every other DropTable call in the world. Same flag-around-the
|
||||||
/// -call approach the Furling uses for its doubled ore.
|
/// -call approach the Furling uses for its doubled ore.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static bool isDvergurMining = false;
|
private static bool isDvergarMining = false;
|
||||||
|
|
||||||
private static bool BeginMiningHit(HitData hit)
|
private static bool BeginMiningHit(HitData hit)
|
||||||
{
|
{
|
||||||
if (hit == null || Player.m_localPlayer == null) return false;
|
if (hit == null || Player.m_localPlayer == null) return false;
|
||||||
if (hit.GetAttacker() != Player.m_localPlayer) return false;
|
if (hit.GetAttacker() != Player.m_localPlayer) return false;
|
||||||
if (!DvergurRace.IsDvergur()) return false;
|
if (!DvergarRace.IsDvergar()) return false;
|
||||||
if (!DvergurProgression.Current.MiningAffinity) return false;
|
if (!DvergarProgression.Current.MiningAffinity) return false;
|
||||||
|
|
||||||
// A pickaxe swing is what the affinity is about - chopping and combat hits on the same
|
// A pickaxe swing is what the affinity is about - chopping and combat hits on the same
|
||||||
// objects go through here too and must be left alone.
|
// objects go through here too and must be left alone.
|
||||||
if (hit.m_damage.m_pickaxe <= 0f) return false;
|
if (hit.m_damage.m_pickaxe <= 0f) return false;
|
||||||
|
|
||||||
hit.m_damage.m_pickaxe *= DvergurConfig.MiningDamageMultiplier;
|
hit.m_damage.m_pickaxe *= DvergarConfig.MiningDamageMultiplier;
|
||||||
isDvergurMining = true;
|
isDvergarMining = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EndMiningHit(bool began)
|
private static void EndMiningHit(bool began)
|
||||||
{
|
{
|
||||||
if (began) isDvergurMining = false;
|
if (began) isDvergarMining = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(MineRock5), "DamageArea")]
|
[HarmonyPatch(typeof(MineRock5), "DamageArea")]
|
||||||
public static class Dvergur_MineRock5_DamageArea_Patch
|
public static class Dvergar_MineRock5_DamageArea_Patch
|
||||||
{
|
{
|
||||||
public static void Prefix(HitData hit, out bool __state) => __state = BeginMiningHit(hit);
|
public static void Prefix(HitData hit, out bool __state) => __state = BeginMiningHit(hit);
|
||||||
public static void Postfix(bool __state) => EndMiningHit(__state);
|
public static void Postfix(bool __state) => EndMiningHit(__state);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(MineRock), "RPC_Hit")]
|
[HarmonyPatch(typeof(MineRock), "RPC_Hit")]
|
||||||
public static class Dvergur_MineRock_RPC_Hit_Patch
|
public static class Dvergar_MineRock_RPC_Hit_Patch
|
||||||
{
|
{
|
||||||
public static void Prefix(HitData hit, out bool __state) => __state = BeginMiningHit(hit);
|
public static void Prefix(HitData hit, out bool __state) => __state = BeginMiningHit(hit);
|
||||||
public static void Postfix(bool __state) => EndMiningHit(__state);
|
public static void Postfix(bool __state) => EndMiningHit(__state);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Destructible), "RPC_Damage")]
|
[HarmonyPatch(typeof(Destructible), "RPC_Damage")]
|
||||||
public static class Dvergur_Destructible_RPC_Damage_Patch
|
public static class Dvergar_Destructible_RPC_Damage_Patch
|
||||||
{
|
{
|
||||||
public static void Prefix(HitData hit, out bool __state) => __state = BeginMiningHit(hit);
|
public static void Prefix(HitData hit, out bool __state) => __state = BeginMiningHit(hit);
|
||||||
public static void Postfix(bool __state) => EndMiningHit(__state);
|
public static void Postfix(bool __state) => EndMiningHit(__state);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(DropTable), "GetDropList", new System.Type[] { typeof(int) })]
|
[HarmonyPatch(typeof(DropTable), "GetDropList", new System.Type[] { typeof(int) })]
|
||||||
public static class Dvergur_DropTable_GetDropList_Patch
|
public static class Dvergar_DropTable_GetDropList_Patch
|
||||||
{
|
{
|
||||||
public static void Postfix(ref List<GameObject> __result)
|
public static void Postfix(ref List<GameObject> __result)
|
||||||
{
|
{
|
||||||
if (!isDvergurMining || __result == null) return;
|
if (!isDvergarMining || __result == null) return;
|
||||||
if (DvergurConfig.MiningExtraDropChance <= 0f) return;
|
if (DvergarConfig.MiningExtraDropChance <= 0f) return;
|
||||||
|
|
||||||
List<GameObject> extra = new List<GameObject>();
|
List<GameObject> extra = new List<GameObject>();
|
||||||
foreach (GameObject drop in __result)
|
foreach (GameObject drop in __result)
|
||||||
{
|
{
|
||||||
if (drop == null || !IsOre(drop.name)) continue;
|
if (drop == null || !IsOre(drop.name)) continue;
|
||||||
if (Random.value <= DvergurConfig.MiningExtraDropChance) extra.Add(drop);
|
if (Random.value <= DvergarConfig.MiningExtraDropChance) extra.Add(drop);
|
||||||
}
|
}
|
||||||
__result.AddRange(extra);
|
__result.AddRange(extra);
|
||||||
}
|
}
|
||||||
|
|
@ -195,7 +209,7 @@ namespace RacesOfValheim
|
||||||
private static bool IsOre(string prefabName)
|
private static bool IsOre(string prefabName)
|
||||||
{
|
{
|
||||||
string lower = prefabName.ToLower();
|
string lower = prefabName.ToLower();
|
||||||
foreach (string ore in DvergurConfig.OreDropNames)
|
foreach (string ore in DvergarConfig.OreDropNames)
|
||||||
{
|
{
|
||||||
if (lower.Contains(ore)) return true;
|
if (lower.Contains(ore)) return true;
|
||||||
}
|
}
|
||||||
|
|
@ -210,18 +224,18 @@ namespace RacesOfValheim
|
||||||
/// the crafting panel and Player.ConsumeResources go through, so the figure the player is
|
/// the crafting panel and Player.ConsumeResources go through, so the figure the player is
|
||||||
/// quoted and the figure they are charged can never drift apart.
|
/// quoted and the figure they are charged can never drift apart.
|
||||||
///
|
///
|
||||||
/// Scoped to the metals and gems in DvergurConfig.DiscountedResourceNames, which is what
|
/// Scoped to the metals and gems in DvergarConfig.DiscountedResourceNames, which is what
|
||||||
/// keeps this a smithing perk rather than a blanket discount on every wooden wall.
|
/// keeps this a smithing perk rather than a blanket discount on every wooden wall.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HarmonyPatch(typeof(Piece.Requirement), "GetAmount")]
|
[HarmonyPatch(typeof(Piece.Requirement), "GetAmount")]
|
||||||
public static class Dvergur_Requirement_GetAmount_Patch
|
public static class Dvergar_Requirement_GetAmount_Patch
|
||||||
{
|
{
|
||||||
public static void Postfix(Piece.Requirement __instance, ref int __result)
|
public static void Postfix(Piece.Requirement __instance, ref int __result)
|
||||||
{
|
{
|
||||||
if (__result <= 1 || Player.m_localPlayer == null) return;
|
if (__result <= 1 || Player.m_localPlayer == null) return;
|
||||||
if (!DvergurRace.IsDvergur()) return;
|
if (!DvergarRace.IsDvergar()) return;
|
||||||
|
|
||||||
float discount = DvergurProgression.Current.SmithingDiscount;
|
float discount = DvergarProgression.Current.SmithingDiscount;
|
||||||
if (discount <= 0f) return;
|
if (discount <= 0f) return;
|
||||||
|
|
||||||
if (__instance == null || __instance.m_resItem == null) return;
|
if (__instance == null || __instance.m_resItem == null) return;
|
||||||
|
|
@ -233,7 +247,7 @@ namespace RacesOfValheim
|
||||||
private static bool IsDiscounted(string prefabName)
|
private static bool IsDiscounted(string prefabName)
|
||||||
{
|
{
|
||||||
string lower = prefabName.ToLower();
|
string lower = prefabName.ToLower();
|
||||||
foreach (string resource in DvergurConfig.DiscountedResourceNames)
|
foreach (string resource in DvergarConfig.DiscountedResourceNames)
|
||||||
{
|
{
|
||||||
if (lower == resource || lower.Contains(resource)) return true;
|
if (lower == resource || lower.Contains(resource)) return true;
|
||||||
}
|
}
|
||||||
|
|
@ -249,17 +263,17 @@ namespace RacesOfValheim
|
||||||
///
|
///
|
||||||
/// The discounted entries are fresh TradeItem instances rather than edited originals: the
|
/// The discounted entries are fresh TradeItem instances rather than edited originals: the
|
||||||
/// list Valheim hands back holds the trader's own objects, and rewriting their prices in
|
/// list Valheim hands back holds the trader's own objects, and rewriting their prices in
|
||||||
/// place would permanently mark down the shop for everyone, Dvergur or not.
|
/// place would permanently mark down the shop for everyone, Dvergar or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HarmonyPatch(typeof(Trader), "GetAvailableItems")]
|
[HarmonyPatch(typeof(Trader), "GetAvailableItems")]
|
||||||
public static class Dvergur_Trader_GetAvailableItems_Patch
|
public static class Dvergar_Trader_GetAvailableItems_Patch
|
||||||
{
|
{
|
||||||
public static void Postfix(ref List<Trader.TradeItem> __result)
|
public static void Postfix(ref List<Trader.TradeItem> __result)
|
||||||
{
|
{
|
||||||
if (__result == null || Player.m_localPlayer == null) return;
|
if (__result == null || Player.m_localPlayer == null) return;
|
||||||
if (!DvergurRace.IsDvergur()) return;
|
if (!DvergarRace.IsDvergar()) return;
|
||||||
|
|
||||||
float discount = DvergurProgression.Current.TraderBuyDiscount;
|
float discount = DvergarProgression.Current.TraderBuyDiscount;
|
||||||
if (discount <= 0f) return;
|
if (discount <= 0f) return;
|
||||||
|
|
||||||
List<Trader.TradeItem> discounted = new List<Trader.TradeItem>(__result.Count);
|
List<Trader.TradeItem> discounted = new List<Trader.TradeItem>(__result.Count);
|
||||||
|
|
@ -286,14 +300,14 @@ namespace RacesOfValheim
|
||||||
/// lands on exactly the side of the counter it is meant to.
|
/// lands on exactly the side of the counter it is meant to.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HarmonyPatch(typeof(ItemDrop.ItemData), "GetValue")]
|
[HarmonyPatch(typeof(ItemDrop.ItemData), "GetValue")]
|
||||||
public static class Dvergur_ItemData_GetValue_Patch
|
public static class Dvergar_ItemData_GetValue_Patch
|
||||||
{
|
{
|
||||||
public static void Postfix(ref int __result)
|
public static void Postfix(ref int __result)
|
||||||
{
|
{
|
||||||
if (__result <= 0 || Player.m_localPlayer == null) return;
|
if (__result <= 0 || Player.m_localPlayer == null) return;
|
||||||
if (!DvergurRace.IsDvergur()) return;
|
if (!DvergarRace.IsDvergar()) return;
|
||||||
|
|
||||||
float bonus = DvergurProgression.Current.TraderSellBonus;
|
float bonus = DvergarProgression.Current.TraderSellBonus;
|
||||||
if (bonus <= 0f) return;
|
if (bonus <= 0f) return;
|
||||||
|
|
||||||
__result = Mathf.RoundToInt(__result * (1f + bonus));
|
__result = Mathf.RoundToInt(__result * (1f + bonus));
|
||||||
|
|
@ -303,7 +317,7 @@ namespace RacesOfValheim
|
||||||
// ─── Skin ────────────────────────────────────────────────────────────
|
// ─── Skin ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tints the Dvergur ashen grey.
|
/// Tints the Dvergar ashen grey.
|
||||||
///
|
///
|
||||||
/// The first attempt did this the way the race-selection menu appears to - VisEquipment's
|
/// The first attempt did this the way the race-selection menu appears to - VisEquipment's
|
||||||
/// SetSkinColor followed by UpdateColors - and nothing happened, because that pair is not
|
/// SetSkinColor followed by UpdateColors - and nothing happened, because that pair is not
|
||||||
|
|
@ -315,21 +329,21 @@ namespace RacesOfValheim
|
||||||
///
|
///
|
||||||
/// No local-player check and no saved original: the race is read from the ZDO with a
|
/// No local-player check and no saved original: the race is read from the ZDO with a
|
||||||
/// m_customData fallback so the main-menu preview and the first spawn frame are covered
|
/// m_customData fallback so the main-menu preview and the first spawn frame are covered
|
||||||
/// too, and the tint simply stops being applied once the player is no longer a Dvergur.
|
/// too, and the tint simply stops being applied once the player is no longer a Dvergar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HarmonyPatch(typeof(VisEquipment), "UpdateColors")]
|
[HarmonyPatch(typeof(VisEquipment), "UpdateColors")]
|
||||||
public static class Dvergur_VisEquipment_UpdateColors_Patch
|
public static class Dvergar_VisEquipment_UpdateColors_Patch
|
||||||
{
|
{
|
||||||
public static void Postfix(VisEquipment __instance)
|
public static void Postfix(VisEquipment __instance)
|
||||||
{
|
{
|
||||||
if (__instance == null || !__instance.m_isPlayer) return;
|
if (__instance == null || !__instance.m_isPlayer) return;
|
||||||
|
|
||||||
Player player = __instance.GetComponent<Player>();
|
Player player = __instance.GetComponent<Player>();
|
||||||
if (player == null || !DvergurVisuals.IsDvergurPlayer(player)) return;
|
if (player == null || !DvergarVisuals.IsDvergarPlayer(player)) return;
|
||||||
|
|
||||||
if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null)
|
if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null)
|
||||||
{
|
{
|
||||||
__instance.m_bodyModel.material.SetColor("_SkinColor", DvergurConfig.SkinColor);
|
__instance.m_bodyModel.material.SetColor("_SkinColor", DvergarConfig.SkinColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
TintRenderers(Traverse.Create(__instance).Field("m_hairItemInstance").GetValue<GameObject>());
|
TintRenderers(Traverse.Create(__instance).Field("m_hairItemInstance").GetValue<GameObject>());
|
||||||
|
|
@ -341,7 +355,7 @@ namespace RacesOfValheim
|
||||||
if (instance == null) return;
|
if (instance == null) return;
|
||||||
foreach (Renderer renderer in instance.GetComponentsInChildren<Renderer>())
|
foreach (Renderer renderer in instance.GetComponentsInChildren<Renderer>())
|
||||||
{
|
{
|
||||||
if (renderer.material != null) renderer.material.SetColor("_SkinColor", DvergurConfig.HairColor);
|
if (renderer.material != null) renderer.material.SetColor("_SkinColor", DvergarConfig.HairColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -354,7 +368,7 @@ namespace RacesOfValheim
|
||||||
/// again behind the hood.
|
/// again behind the hood.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")]
|
[HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")]
|
||||||
public static class Dvergur_VisEquipment_UpdateVisuals_Patch
|
public static class Dvergar_VisEquipment_UpdateVisuals_Patch
|
||||||
{
|
{
|
||||||
public static void Postfix(VisEquipment __instance)
|
public static void Postfix(VisEquipment __instance)
|
||||||
{
|
{
|
||||||
|
|
@ -363,7 +377,7 @@ namespace RacesOfValheim
|
||||||
Player player = __instance.GetComponent<Player>();
|
Player player = __instance.GetComponent<Player>();
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
DvergurVisuals.ApplyHood(player);
|
DvergarVisuals.ApplyHood(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,21 +4,24 @@ using UnityEngine;
|
||||||
namespace RacesOfValheim
|
namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Turns a boss progression state into the set of Dvergur perks active at that tier, the same
|
/// Turns a boss progression state into the set of Dvergar perks active at that tier, the same
|
||||||
/// way SkeletonProgression and SkadiProgression do for their races.
|
/// way SkeletonProgression and SkadiProgression do for their races.
|
||||||
///
|
///
|
||||||
/// Nothing is decided here - every figure comes out of DvergurConfig - so the tuning pass can
|
/// Nothing is decided here - every figure comes out of DvergarConfig - so the tuning pass can
|
||||||
/// happen without touching a single patch.
|
/// happen without touching a single patch.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class DvergurProgression
|
public static class DvergarProgression
|
||||||
{
|
{
|
||||||
public struct DvergurRules
|
public struct DvergarRules
|
||||||
{
|
{
|
||||||
/// <summary>Points subtracted from max health at this tier.</summary>
|
/// <summary>Points subtracted from max health at this tier.</summary>
|
||||||
public float HealthMalus;
|
public float HealthMalus;
|
||||||
|
|
||||||
/// <summary>Weapon skills the Dvergur is at home with, already filtered by tier.</summary>
|
/// <summary>Lightning added to every blow at this tier. Live from the base tier.</summary>
|
||||||
public List<DvergurConfig.WeaponAffinity> Affinities;
|
public float ElementalDamage;
|
||||||
|
|
||||||
|
/// <summary>Weapon skills the Dvergar is at home with, already filtered by tier.</summary>
|
||||||
|
public List<DvergarConfig.WeaponAffinity> Affinities;
|
||||||
|
|
||||||
public bool MiningAffinity;
|
public bool MiningAffinity;
|
||||||
public float SmithingDiscount;
|
public float SmithingDiscount;
|
||||||
|
|
@ -30,30 +33,31 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
// GetRules runs from Update loops and from damage patches, so the per-state result is
|
// GetRules runs from Update loops and from damage patches, so the per-state result is
|
||||||
// built once and handed back on every later call.
|
// built once and handed back on every later call.
|
||||||
private static readonly DvergurRules[] cache = new DvergurRules[BossProgressionManager.MaxState + 1];
|
private static readonly DvergarRules[] cache = new DvergarRules[BossProgressionManager.MaxState + 1];
|
||||||
private static readonly bool[] cached = new bool[BossProgressionManager.MaxState + 1];
|
private static readonly bool[] cached = new bool[BossProgressionManager.MaxState + 1];
|
||||||
|
|
||||||
public static DvergurRules GetRules(int state)
|
public static DvergarRules GetRules(int state)
|
||||||
{
|
{
|
||||||
state = Mathf.Clamp(state, BossProgressionManager.MinState, BossProgressionManager.MaxState);
|
state = Mathf.Clamp(state, BossProgressionManager.MinState, BossProgressionManager.MaxState);
|
||||||
if (cached[state]) return cache[state];
|
if (cached[state]) return cache[state];
|
||||||
|
|
||||||
List<DvergurConfig.WeaponAffinity> affinities = new List<DvergurConfig.WeaponAffinity>();
|
List<DvergarConfig.WeaponAffinity> affinities = new List<DvergarConfig.WeaponAffinity>();
|
||||||
foreach (DvergurConfig.WeaponAffinity affinity in DvergurConfig.WeaponAffinities)
|
foreach (DvergarConfig.WeaponAffinity affinity in DvergarConfig.WeaponAffinities)
|
||||||
{
|
{
|
||||||
if (state >= affinity.UnlockState) affinities.Add(affinity);
|
if (state >= affinity.UnlockState) affinities.Add(affinity);
|
||||||
}
|
}
|
||||||
|
|
||||||
DvergurRules rules = new DvergurRules
|
DvergarRules rules = new DvergarRules
|
||||||
{
|
{
|
||||||
HealthMalus = DvergurConfig.Lookup(DvergurConfig.HealthMalusByState, state),
|
HealthMalus = DvergarConfig.Lookup(DvergarConfig.HealthMalusByState, state),
|
||||||
|
ElementalDamage = DvergarConfig.ElementalDamagePerState * state,
|
||||||
Affinities = affinities,
|
Affinities = affinities,
|
||||||
MiningAffinity = state >= DvergurConfig.MiningAffinityState,
|
MiningAffinity = state >= DvergarConfig.MiningAffinityState,
|
||||||
SmithingDiscount = DvergurConfig.Lookup(DvergurConfig.SmithingDiscountByState, state),
|
SmithingDiscount = DvergarConfig.Lookup(DvergarConfig.SmithingDiscountByState, state),
|
||||||
TraderBuyDiscount = DvergurConfig.Lookup(DvergurConfig.TraderBuyDiscountByState, state),
|
TraderBuyDiscount = DvergarConfig.Lookup(DvergarConfig.TraderBuyDiscountByState, state),
|
||||||
TraderSellBonus = DvergurConfig.Lookup(DvergurConfig.TraderSellBonusByState, state),
|
TraderSellBonus = DvergarConfig.Lookup(DvergarConfig.TraderSellBonusByState, state),
|
||||||
RunicPing = state >= DvergurConfig.RunicPingState,
|
RunicPing = state >= DvergarConfig.RunicPingState,
|
||||||
RunicOvercharge = state >= DvergurConfig.RunicOverchargeState
|
RunicOvercharge = state >= DvergarConfig.RunicOverchargeState
|
||||||
};
|
};
|
||||||
|
|
||||||
cache[state] = rules;
|
cache[state] = rules;
|
||||||
|
|
@ -62,17 +66,17 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Rules for whatever tier the local player is currently on.</summary>
|
/// <summary>Rules for whatever tier the local player is currently on.</summary>
|
||||||
public static DvergurRules Current => GetRules(BossProgressionManager.GetCurrentProgressionState());
|
public static DvergarRules Current => GetRules(BossProgressionManager.GetCurrentProgressionState());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The affinity covering a weapon skill at the current tier, or null when the Dvergur has
|
/// The affinity covering a weapon skill at the current tier, or null when the Dvergar has
|
||||||
/// no particular feel for it. Mining counts as an affinity for stamina purposes only, so
|
/// no particular feel for it. Mining counts as an affinity for stamina purposes only, so
|
||||||
/// it is deliberately not part of this list.
|
/// it is deliberately not part of this list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static DvergurConfig.WeaponAffinity? GetAffinity(Skills.SkillType skill, int state)
|
public static DvergarConfig.WeaponAffinity? GetAffinity(Skills.SkillType skill, int state)
|
||||||
{
|
{
|
||||||
DvergurRules rules = GetRules(state);
|
DvergarRules rules = GetRules(state);
|
||||||
foreach (DvergurConfig.WeaponAffinity affinity in rules.Affinities)
|
foreach (DvergarConfig.WeaponAffinity affinity in rules.Affinities)
|
||||||
{
|
{
|
||||||
if (affinity.Skill == skill) return affinity;
|
if (affinity.Skill == skill) return affinity;
|
||||||
}
|
}
|
||||||
|
|
@ -4,17 +4,17 @@ using UnityEngine;
|
||||||
namespace RacesOfValheim
|
namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Driver for the Dvergur: a short, stocky smith who trades a slice of health for an affinity
|
/// Driver for the Dvergar: a short, stocky smith who trades a slice of health for an affinity
|
||||||
/// with hammer, bow, axe and crossbow, a knack for mining and the ear of Haldor and Hildir.
|
/// with hammer, bow, axe and crossbow, a knack for mining and the ear of Haldor and Hildir.
|
||||||
///
|
///
|
||||||
/// Only the per-frame upkeep lives here. Body scale is a Player.Update postfix in
|
/// Only the per-frame upkeep lives here. Body scale is a Player.Update postfix in
|
||||||
/// DvergurPatches, since that is the one place it survives; the perks are the other patches in
|
/// DvergarPatches, since that is the one place it survives; the perks are the other patches in
|
||||||
/// that file; the two eitr abilities are in DvergurAbilities; and every number they use comes
|
/// that file; the two eitr abilities are in DvergarAbilities; and every number they use comes
|
||||||
/// from DvergurConfig by way of DvergurProgression.
|
/// from DvergarConfig by way of DvergarProgression.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DvergurRace : MonoBehaviour
|
public class DvergarRace : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static DvergurRace Instance;
|
public static DvergarRace Instance;
|
||||||
|
|
||||||
// NaN so that the very first frame always counts as a change and pushes the malus through.
|
// NaN so that the very first frame always counts as a change and pushes the malus through.
|
||||||
private float lastAppliedMalus = float.NaN;
|
private float lastAppliedMalus = float.NaN;
|
||||||
|
|
@ -26,14 +26,37 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
public void CreateModAssets()
|
public void CreateModAssets()
|
||||||
{
|
{
|
||||||
DvergurStatusEffects.RegisterStatusEffects();
|
DvergarStatusEffects.RegisterStatusEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsDvergur()
|
/// <summary>
|
||||||
|
/// The race was called "Dvergur" before it was renamed, and that string is what got written
|
||||||
|
/// into m_customData and the ZDO. Without this, every character created under the old name
|
||||||
|
/// would come back with no race at all and be handed the selection menu again.
|
||||||
|
/// </summary>
|
||||||
|
public const string LegacyRaceId = "Dvergur";
|
||||||
|
|
||||||
|
public static void MigrateLegacyRaceId(Player player)
|
||||||
|
{
|
||||||
|
if (player == null || player.m_customData == null) return;
|
||||||
|
if (!player.m_customData.TryGetValue("Race", out string race) || race != LegacyRaceId) return;
|
||||||
|
|
||||||
|
player.m_customData["Race"] = DvergarConfig.RaceId;
|
||||||
|
|
||||||
|
ZNetView nview = player.GetComponent<ZNetView>();
|
||||||
|
if (nview != null && nview.IsValid())
|
||||||
|
{
|
||||||
|
nview.GetZDO().Set("RacesOfValheim_Race", DvergarConfig.RaceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
Jotunn.Logger.LogInfo($"[Dvergar] Migrated '{LegacyRaceId}' to '{DvergarConfig.RaceId}' for {player.GetPlayerName()}.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsDvergar()
|
||||||
{
|
{
|
||||||
return Player.m_localPlayer != null &&
|
return Player.m_localPlayer != null &&
|
||||||
Player.m_localPlayer.m_customData.ContainsKey("Race") &&
|
Player.m_localPlayer.m_customData.ContainsKey("Race") &&
|
||||||
Player.m_localPlayer.m_customData["Race"] == DvergurConfig.RaceId;
|
Player.m_localPlayer.m_customData["Race"] == DvergarConfig.RaceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
|
|
@ -41,30 +64,30 @@ namespace RacesOfValheim
|
||||||
Player player = Player.m_localPlayer;
|
Player player = Player.m_localPlayer;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
bool isDvergur = IsDvergur();
|
bool isDvergar = IsDvergar();
|
||||||
|
|
||||||
DvergurVisuals.ApplyHood(player);
|
DvergarVisuals.ApplyHood(player);
|
||||||
|
|
||||||
// Max health is recomputed by Player.UpdateFood, which runs on its own schedule. Left
|
// Max health is recomputed by Player.UpdateFood, which runs on its own schedule. Left
|
||||||
// to itself the malus would only take effect at the next food tick, so a change of
|
// to itself the malus would only take effect at the next food tick, so a change of
|
||||||
// race or of tier is pushed through immediately - this is also what makes the health
|
// race or of tier is pushed through immediately - this is also what makes the health
|
||||||
// bar and the number agree the instant a player becomes (or stops being) a Dvergur.
|
// bar and the number agree the instant a player becomes (or stops being) a Dvergar.
|
||||||
float desiredMalus = isDvergur ? DvergurProgression.Current.HealthMalus : 0f;
|
float desiredMalus = isDvergar ? DvergarProgression.Current.HealthMalus : 0f;
|
||||||
if (!Mathf.Approximately(desiredMalus, lastAppliedMalus))
|
if (!Mathf.Approximately(desiredMalus, lastAppliedMalus))
|
||||||
{
|
{
|
||||||
lastAppliedMalus = desiredMalus;
|
lastAppliedMalus = desiredMalus;
|
||||||
Traverse.Create(player).Method("UpdateFood", 0f, true).GetValue();
|
Traverse.Create(player).Method("UpdateFood", 0f, true).GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDvergur || player.IsDead()) return;
|
if (!isDvergar || player.IsDead()) return;
|
||||||
|
|
||||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||||
|
|
||||||
// Keep the passive carrier attached. It is re-added rather than assumed because a
|
// Keep the passive carrier attached. It is re-added rather than assumed because a
|
||||||
// respawn, a death or a world load all clear the player's status effects.
|
// respawn, a death or a world load all clear the player's status effects.
|
||||||
if (DvergurStatusEffects.StatsSE != null)
|
if (DvergarStatusEffects.StatsSE != null)
|
||||||
{
|
{
|
||||||
int hash = DvergurConfig.StatsSE.GetStableHashCode();
|
int hash = DvergarConfig.StatsSE.GetStableHashCode();
|
||||||
if (!player.GetSEMan().HaveStatusEffect(hash))
|
if (!player.GetSEMan().HaveStatusEffect(hash))
|
||||||
{
|
{
|
||||||
player.GetSEMan().AddStatusEffect(hash, true);
|
player.GetSEMan().AddStatusEffect(hash, true);
|
||||||
|
|
@ -75,10 +98,10 @@ namespace RacesOfValheim
|
||||||
ZNetView nview = player.GetComponent<ZNetView>();
|
ZNetView nview = player.GetComponent<ZNetView>();
|
||||||
if (nview != null && nview.IsValid())
|
if (nview != null && nview.IsValid())
|
||||||
{
|
{
|
||||||
nview.GetZDO().Set(DvergurConfig.StateZdoKey, state);
|
nview.GetZDO().Set(DvergarConfig.StateZdoKey, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
DvergurAbilities.Tick(player, state);
|
DvergarAbilities.Tick(player, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -6,16 +6,16 @@ using UnityEngine;
|
||||||
namespace RacesOfValheim
|
namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Passive carrier for the Dvergur. The stamina half of weapon affinity lives here rather than
|
/// Passive carrier for the Dvergar. The stamina half of weapon affinity lives here rather than
|
||||||
/// in a Harmony patch because Valheim already routes attack cost through the status effects
|
/// in a Harmony patch because Valheim already routes attack cost through the status effects
|
||||||
/// (SEMan.ModifyAttackStaminaUsage), so there is nothing to intercept.
|
/// (SEMan.ModifyAttackStaminaUsage), so there is nothing to intercept.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SE_DvergurStats : SE_Stats
|
public class SE_DvergarStats : SE_Stats
|
||||||
{
|
{
|
||||||
public override void Setup(Character character)
|
public override void Setup(Character character)
|
||||||
{
|
{
|
||||||
base.Setup(character);
|
base.Setup(character);
|
||||||
name = DvergurConfig.StatsSE;
|
name = DvergarConfig.StatsSE;
|
||||||
m_name = "Stone and Forge";
|
m_name = "Stone and Forge";
|
||||||
m_tooltip = "Small, sturdy, and born to the anvil.";
|
m_tooltip = "Small, sturdy, and born to the anvil.";
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ namespace RacesOfValheim
|
||||||
base.ModifyAttackStaminaUsage(baseStaminaUse, ref staminaUse);
|
base.ModifyAttackStaminaUsage(baseStaminaUse, ref staminaUse);
|
||||||
|
|
||||||
if (!(m_character is Player player) || player != Player.m_localPlayer) return;
|
if (!(m_character is Player player) || player != Player.m_localPlayer) return;
|
||||||
if (!DvergurRace.IsDvergur()) return;
|
if (!DvergarRace.IsDvergar()) return;
|
||||||
|
|
||||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||||
|
|
||||||
|
|
@ -39,14 +39,14 @@ namespace RacesOfValheim
|
||||||
// Mining is a discount on the pickaxe, not a weapon affinity, so it is checked apart.
|
// Mining is a discount on the pickaxe, not a weapon affinity, so it is checked apart.
|
||||||
if (skill == Skills.SkillType.Pickaxes)
|
if (skill == Skills.SkillType.Pickaxes)
|
||||||
{
|
{
|
||||||
if (DvergurProgression.GetRules(state).MiningAffinity)
|
if (DvergarProgression.GetRules(state).MiningAffinity)
|
||||||
{
|
{
|
||||||
staminaUse = Mathf.Max(0f, staminaUse * (1f - DvergurConfig.MiningStaminaPercent));
|
staminaUse = Mathf.Max(0f, staminaUse * (1f - DvergarConfig.MiningStaminaPercent));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DvergurConfig.WeaponAffinity? affinity = DvergurProgression.GetAffinity(skill, state);
|
DvergarConfig.WeaponAffinity? affinity = DvergarProgression.GetAffinity(skill, state);
|
||||||
if (!affinity.HasValue) return;
|
if (!affinity.HasValue) return;
|
||||||
|
|
||||||
// Static by design: the discount is the same the day it unlocks as it is after Fader.
|
// Static by design: the discount is the same the day it unlocks as it is after Fader.
|
||||||
|
|
@ -56,9 +56,9 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runic Overcharge, held between the cast and the blow that spends it. Purely a marker with a
|
/// Runic Overcharge, held between the cast and the blow that spends it. Purely a marker with a
|
||||||
/// countdown - DvergurPatches reads it when the next affine hit lands.
|
/// countdown - DvergarPatches reads it when the next affine hit lands.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SE_DvergurOvercharge : StatusEffect
|
public class SE_DvergarOvercharge : StatusEffect
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,42 +66,42 @@ namespace RacesOfValheim
|
||||||
/// Ability cooldowns. They exist only so the HUD has something to count down, the way
|
/// Ability cooldowns. They exist only so the HUD has something to count down, the way
|
||||||
/// SE_SkadiAbilityCooldown does: Valheim prints the remaining time of any effect with a m_ttl.
|
/// SE_SkadiAbilityCooldown does: Valheim prints the remaining time of any effect with a m_ttl.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SE_DvergurAbilityCooldown : StatusEffect
|
public class SE_DvergarAbilityCooldown : StatusEffect
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DvergurStatusEffects
|
public static class DvergarStatusEffects
|
||||||
{
|
{
|
||||||
public static SE_DvergurStats StatsSE { get; private set; }
|
public static SE_DvergarStats StatsSE { get; private set; }
|
||||||
|
|
||||||
public static void RegisterStatusEffects()
|
public static void RegisterStatusEffects()
|
||||||
{
|
{
|
||||||
Sprite icon = GetItemIcon("HelmetDverger") ?? GetItemIcon("DvergrKeyFragment") ?? GetItemIcon("Copper");
|
Sprite icon = GetItemIcon("HelmetDverger") ?? GetItemIcon("DvergrKeyFragment") ?? GetItemIcon("Copper");
|
||||||
|
|
||||||
var stats = ScriptableObject.CreateInstance<SE_DvergurStats>();
|
var stats = ScriptableObject.CreateInstance<SE_DvergarStats>();
|
||||||
stats.name = DvergurConfig.StatsSE;
|
stats.name = DvergarConfig.StatsSE;
|
||||||
stats.m_name = "Stone and Forge";
|
stats.m_name = "Stone and Forge";
|
||||||
stats.m_icon = icon;
|
stats.m_icon = icon;
|
||||||
CustomStatusEffect customStats = new CustomStatusEffect(stats, fixReference: false);
|
CustomStatusEffect customStats = new CustomStatusEffect(stats, fixReference: false);
|
||||||
ItemManager.Instance.AddStatusEffect(customStats);
|
ItemManager.Instance.AddStatusEffect(customStats);
|
||||||
StatsSE = customStats.StatusEffect as SE_DvergurStats;
|
StatsSE = customStats.StatusEffect as SE_DvergarStats;
|
||||||
|
|
||||||
var overcharge = ScriptableObject.CreateInstance<SE_DvergurOvercharge>();
|
var overcharge = ScriptableObject.CreateInstance<SE_DvergarOvercharge>();
|
||||||
overcharge.name = DvergurConfig.OverchargeSE;
|
overcharge.name = DvergarConfig.OverchargeSE;
|
||||||
overcharge.m_name = "Runic Overcharge";
|
overcharge.m_name = "Runic Overcharge";
|
||||||
overcharge.m_tooltip = "Your next blow with a favoured weapon carries the whole of the charge.";
|
overcharge.m_tooltip = "Your next blow with a favoured weapon carries the whole of the charge.";
|
||||||
overcharge.m_icon = GetItemIcon("Eitr") ?? icon;
|
overcharge.m_icon = GetItemIcon("Eitr") ?? icon;
|
||||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(overcharge, fixReference: false));
|
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(overcharge, fixReference: false));
|
||||||
|
|
||||||
var pingCd = ScriptableObject.CreateInstance<SE_DvergurAbilityCooldown>();
|
var pingCd = ScriptableObject.CreateInstance<SE_DvergarAbilityCooldown>();
|
||||||
pingCd.name = DvergurConfig.RunicPingCdSE;
|
pingCd.name = DvergarConfig.RunicPingCdSE;
|
||||||
pingCd.m_name = "Runic Ping";
|
pingCd.m_name = "Runic Ping";
|
||||||
pingCd.m_tooltip = "The runes must settle before you may call on them again.";
|
pingCd.m_tooltip = "The runes must settle before you may call on them again.";
|
||||||
pingCd.m_icon = GetItemIcon("DvergrKeyFragment") ?? icon;
|
pingCd.m_icon = GetItemIcon("DvergrKeyFragment") ?? icon;
|
||||||
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(pingCd, fixReference: false));
|
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(pingCd, fixReference: false));
|
||||||
|
|
||||||
var overchargeCd = ScriptableObject.CreateInstance<SE_DvergurAbilityCooldown>();
|
var overchargeCd = ScriptableObject.CreateInstance<SE_DvergarAbilityCooldown>();
|
||||||
overchargeCd.name = DvergurConfig.OverchargeCdSE;
|
overchargeCd.name = DvergarConfig.OverchargeCdSE;
|
||||||
overchargeCd.m_name = "Overcharge Cooldown";
|
overchargeCd.m_name = "Overcharge Cooldown";
|
||||||
overchargeCd.m_tooltip = "The runes are spent.";
|
overchargeCd.m_tooltip = "The runes are spent.";
|
||||||
overchargeCd.m_icon = GetItemIcon("Eitr") ?? icon;
|
overchargeCd.m_icon = GetItemIcon("Eitr") ?? icon;
|
||||||
|
|
@ -5,7 +5,7 @@ using UnityEngine;
|
||||||
namespace RacesOfValheim
|
namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The Dvergur's looks: a short body, dvergr skin, and a hood that is always worn.
|
/// The Dvergar's looks: a short body, dvergr skin, and a hood that is always worn.
|
||||||
///
|
///
|
||||||
/// The hood is a pure cosmetic override, not an equipment lock. The helmet slot stays free and
|
/// The hood is a pure cosmetic override, not an equipment lock. The helmet slot stays free and
|
||||||
/// whatever the player equips keeps every one of its stats - only its mesh is swapped out, so
|
/// whatever the player equips keeps every one of its stats - only its mesh is swapped out, so
|
||||||
|
|
@ -14,9 +14,9 @@ namespace RacesOfValheim
|
||||||
/// Everything here runs for local and remote players alike, which is why it takes a Player
|
/// Everything here runs for local and remote players alike, which is why it takes a Player
|
||||||
/// rather than reading Player.m_localPlayer.
|
/// rather than reading Player.m_localPlayer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class DvergurVisuals
|
public static class DvergarVisuals
|
||||||
{
|
{
|
||||||
private const string HoodName = "DvergurHood";
|
private const string HoodName = "DvergarHood";
|
||||||
|
|
||||||
// The source is looked up once per session; the search walks a whole creature prefab and
|
// The source is looked up once per session; the search walks a whole creature prefab and
|
||||||
// would otherwise run again for every player that comes into view. The failure is cached
|
// would otherwise run again for every player that comes into view. The failure is cached
|
||||||
|
|
@ -45,7 +45,7 @@ namespace RacesOfValheim
|
||||||
return "Human";
|
return "Human";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsDvergurPlayer(Player player) => GetPlayerRace(player) == DvergurConfig.RaceId;
|
public static bool IsDvergarPlayer(Player player) => GetPlayerRace(player) == DvergarConfig.RaceId;
|
||||||
|
|
||||||
// ─── Scale ───────────────────────────────────────────────────────────
|
// ─── Scale ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ namespace RacesOfValheim
|
||||||
/// left the scale in a fight it could not win: Trol's Player.Update postfix resets every
|
/// left the scale in a fight it could not win: Trol's Player.Update postfix resets every
|
||||||
/// non-Trol player's visual to 1 on the same frame, and whichever ran last won.
|
/// non-Trol player's visual to 1 on the same frame, and whichever ran last won.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void ApplyScale(Player player, bool isDvergur)
|
public static void ApplyScale(Player player, bool isDvergar)
|
||||||
{
|
{
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
|
|
@ -64,15 +64,15 @@ namespace RacesOfValheim
|
||||||
GameObject visual = Traverse.Create(player).Field("m_visual").GetValue<GameObject>();
|
GameObject visual = Traverse.Create(player).Field("m_visual").GetValue<GameObject>();
|
||||||
if (visual == null) return;
|
if (visual == null) return;
|
||||||
|
|
||||||
if (isDvergur)
|
if (isDvergar)
|
||||||
{
|
{
|
||||||
float target = DvergurConfig.VisualScale;
|
float target = DvergarConfig.VisualScale;
|
||||||
if (Mathf.Abs(visual.transform.localScale.x - target) > 0.001f)
|
if (Mathf.Abs(visual.transform.localScale.x - target) > 0.001f)
|
||||||
{
|
{
|
||||||
visual.transform.localScale = new Vector3(target, target, target);
|
visual.transform.localScale = new Vector3(target, target, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Mathf.Abs(visual.transform.localScale.x - DvergurConfig.VisualScale) < 0.001f)
|
else if (Mathf.Abs(visual.transform.localScale.x - DvergarConfig.VisualScale) < 0.001f)
|
||||||
{
|
{
|
||||||
// Only ever undo our own scale - another race may legitimately be sizing this player.
|
// Only ever undo our own scale - another race may legitimately be sizing this player.
|
||||||
visual.transform.localScale = Vector3.one;
|
visual.transform.localScale = Vector3.one;
|
||||||
|
|
@ -90,7 +90,7 @@ namespace RacesOfValheim
|
||||||
VisEquipment visEq = player != null ? player.GetComponent<VisEquipment>() : null;
|
VisEquipment visEq = player != null ? player.GetComponent<VisEquipment>() : null;
|
||||||
if (visEq == null) return;
|
if (visEq == null) return;
|
||||||
|
|
||||||
if (IsDvergurPlayer(player) && !player.IsDead())
|
if (IsDvergarPlayer(player) && !player.IsDead())
|
||||||
{
|
{
|
||||||
EnsureHood(visEq);
|
EnsureHood(visEq);
|
||||||
HideEquippedHelmet(visEq);
|
HideEquippedHelmet(visEq);
|
||||||
|
|
@ -132,7 +132,7 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
if (visEq.m_bodyModel == null || visEq.m_bodyModel.bones == null) return;
|
if (visEq.m_bodyModel == null || visEq.m_bodyModel.bones == null) return;
|
||||||
|
|
||||||
Transform playerHead = FindBoneByName(visEq.m_bodyModel.bones, DvergurConfig.PlayerHeadBoneName);
|
Transform playerHead = FindBoneByName(visEq.m_bodyModel.bones, DvergarConfig.PlayerHeadBoneName);
|
||||||
if (playerHead == null) return;
|
if (playerHead == null) return;
|
||||||
|
|
||||||
if (playerHead.Find(HoodName) != null) return; // already wearing it
|
if (playerHead.Find(HoodName) != null) return; // already wearing it
|
||||||
|
|
@ -149,13 +149,13 @@ namespace RacesOfValheim
|
||||||
StripComponents(hood);
|
StripComponents(hood);
|
||||||
hood.SetActive(true);
|
hood.SetActive(true);
|
||||||
|
|
||||||
Transform hatBone = FindChildByName(hood.transform, DvergurConfig.HoodBoneName);
|
Transform hatBone = FindChildByName(hood.transform, DvergarConfig.HoodBoneName);
|
||||||
Transform bodyRoot = FindChildByName(hood.transform, DvergurConfig.BodyRootBoneName);
|
Transform bodyRoot = FindChildByName(hood.transform, DvergarConfig.BodyRootBoneName);
|
||||||
|
|
||||||
if (hatBone == null)
|
if (hatBone == null)
|
||||||
{
|
{
|
||||||
Jotunn.Logger.LogWarning(
|
Jotunn.Logger.LogWarning(
|
||||||
$"[Dvergur] No '{DvergurConfig.HoodBoneName}' bone in the instantiated dvergr; hood dropped.");
|
$"[Dvergar] No '{DvergarConfig.HoodBoneName}' bone in the instantiated dvergr; hood dropped.");
|
||||||
Object.Destroy(hood);
|
Object.Destroy(hood);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -166,14 +166,14 @@ namespace RacesOfValheim
|
||||||
if (bodyRoot != null) bodyRoot.localScale = Vector3.zero;
|
if (bodyRoot != null) bodyRoot.localScale = Vector3.zero;
|
||||||
|
|
||||||
// Scale and rotation before alignment, since both move the hat bone.
|
// Scale and rotation before alignment, since both move the hat bone.
|
||||||
hood.transform.localRotation = Quaternion.Euler(DvergurConfig.HoodOffsetRotation);
|
hood.transform.localRotation = Quaternion.Euler(DvergarConfig.HoodOffsetRotation);
|
||||||
hood.transform.localScale = Vector3.one * DvergurConfig.HoodExtraScale;
|
hood.transform.localScale = Vector3.one * DvergarConfig.HoodExtraScale;
|
||||||
|
|
||||||
// The hat now sits wherever the dvergr's own skull was. Shifting the whole object by
|
// The hat now sits wherever the dvergr's own skull was. Shifting the whole object by
|
||||||
// the gap between that and the player's head bone lands it correctly without a single
|
// the gap between that and the player's head bone lands it correctly without a single
|
||||||
// hand-measured offset.
|
// hand-measured offset.
|
||||||
hood.transform.position += playerHead.position - hatBone.position;
|
hood.transform.position += playerHead.position - hatBone.position;
|
||||||
hood.transform.localPosition += DvergurConfig.HoodOffsetPosition;
|
hood.transform.localPosition += DvergarConfig.HoodOffsetPosition;
|
||||||
|
|
||||||
foreach (SkinnedMeshRenderer renderer in hood.GetComponentsInChildren<SkinnedMeshRenderer>(true))
|
foreach (SkinnedMeshRenderer renderer in hood.GetComponentsInChildren<SkinnedMeshRenderer>(true))
|
||||||
{
|
{
|
||||||
|
|
@ -234,14 +234,14 @@ namespace RacesOfValheim
|
||||||
if (visualResolved) return cachedVisual;
|
if (visualResolved) return cachedVisual;
|
||||||
visualResolved = true;
|
visualResolved = true;
|
||||||
|
|
||||||
GameObject prefab = PrefabManager.Cache.GetPrefab<GameObject>(DvergurConfig.DvergerPrefabName);
|
GameObject prefab = PrefabManager.Cache.GetPrefab<GameObject>(DvergarConfig.DvergerPrefabName);
|
||||||
if (prefab == null)
|
if (prefab == null)
|
||||||
{
|
{
|
||||||
Jotunn.Logger.LogWarning($"[Dvergur] Prefab '{DvergurConfig.DvergerPrefabName}' not found; no hood.");
|
Jotunn.Logger.LogWarning($"[Dvergar] Prefab '{DvergarConfig.DvergerPrefabName}' not found; no hood.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform visual = prefab.transform.Find(DvergurConfig.DvergerVisualName);
|
Transform visual = prefab.transform.Find(DvergarConfig.DvergerVisualName);
|
||||||
if (visual == null)
|
if (visual == null)
|
||||||
{
|
{
|
||||||
// Fall back to whatever holds the renderer, in case the child is ever renamed.
|
// Fall back to whatever holds the renderer, in case the child is ever renamed.
|
||||||
|
|
@ -252,11 +252,11 @@ namespace RacesOfValheim
|
||||||
if (visual == null)
|
if (visual == null)
|
||||||
{
|
{
|
||||||
Jotunn.Logger.LogWarning(
|
Jotunn.Logger.LogWarning(
|
||||||
$"[Dvergur] '{DvergurConfig.DvergerPrefabName}' has no '{DvergurConfig.DvergerVisualName}' child and no renderer; no hood.");
|
$"[Dvergar] '{DvergarConfig.DvergerPrefabName}' has no '{DvergarConfig.DvergerVisualName}' child and no renderer; no hood.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Jotunn.Logger.LogInfo($"[Dvergur] Hood source resolved to '{DvergurConfig.DvergerPrefabName}/{visual.name}'.");
|
Jotunn.Logger.LogInfo($"[Dvergar] Hood source resolved to '{DvergarConfig.DvergerPrefabName}/{visual.name}'.");
|
||||||
cachedVisual = visual.gameObject;
|
cachedVisual = visual.gameObject;
|
||||||
return cachedVisual;
|
return cachedVisual;
|
||||||
}
|
}
|
||||||
|
|
@ -265,9 +265,9 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
if (visEq.m_bodyModel == null || visEq.m_bodyModel.bones == null) return;
|
if (visEq.m_bodyModel == null || visEq.m_bodyModel.bones == null) return;
|
||||||
|
|
||||||
Transform playerHead = FindBoneByName(visEq.m_bodyModel.bones, DvergurConfig.PlayerHeadBoneName);
|
Transform playerHead = FindBoneByName(visEq.m_bodyModel.bones, DvergarConfig.PlayerHeadBoneName);
|
||||||
Transform hood = playerHead != null ? playerHead.Find(HoodName) : null;
|
Transform hood = playerHead != null ? playerHead.Find(HoodName) : null;
|
||||||
if (hood == null) return; // never was a Dvergur - leave the helmet alone
|
if (hood == null) return; // never was a Dvergar - leave the helmet alone
|
||||||
|
|
||||||
// Destroy is deferred to the end of the frame, so the object is renamed first: without
|
// Destroy is deferred to the end of the frame, so the object is renamed first: without
|
||||||
// that, every call until it actually goes away finds it again and re-runs the restore.
|
// that, every call until it actually goes away finds it again and re-runs the restore.
|
||||||
|
|
@ -16,7 +16,7 @@ namespace RacesOfValheim
|
||||||
"Furling Secrets",
|
"Furling Secrets",
|
||||||
"Trol Secrets",
|
"Trol Secrets",
|
||||||
"Draugh Secrets",
|
"Draugh Secrets",
|
||||||
"Dvergur Secrets"
|
"Dvergar Secrets"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void UpdateCompendiumText(Player player)
|
public static void UpdateCompendiumText(Player player)
|
||||||
|
|
@ -68,9 +68,9 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
GenerateDraughText(knownTexts, state, player);
|
GenerateDraughText(knownTexts, state, player);
|
||||||
}
|
}
|
||||||
else if (currentRace == DvergurConfig.RaceId)
|
else if (currentRace == DvergarConfig.RaceId)
|
||||||
{
|
{
|
||||||
GenerateDvergurText(knownTexts, state);
|
GenerateDvergarText(knownTexts, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,17 +78,19 @@ namespace RacesOfValheim
|
||||||
/// Reads its figures straight out of the live rules rather than restating them, so the
|
/// Reads its figures straight out of the live rules rather than restating them, so the
|
||||||
/// entry cannot drift from the code the way a hand-written percentage would.
|
/// entry cannot drift from the code the way a hand-written percentage would.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void GenerateDvergurText(Dictionary<string, string> knownTexts, int state)
|
private static void GenerateDvergarText(Dictionary<string, string> knownTexts, int state)
|
||||||
{
|
{
|
||||||
DvergurProgression.DvergurRules rules = DvergurProgression.GetRules(state);
|
DvergarProgression.DvergarRules rules = DvergarProgression.GetRules(state);
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.AppendLine("The Dvergur's Craft\n");
|
sb.AppendLine("The Dvergar's Craft\n");
|
||||||
|
|
||||||
sb.AppendLine($"[Base Passive] Small and Stubborn: You stand a third shorter than a human and carry {rules.HealthMalus:0.#} less health for it. The dvergr hood never leaves your head - wear whatever helm you please and keep every point of its protection, but the runes will always show you as one of the deep folk.\n");
|
sb.AppendLine($"[Base Passive] Small and Stubborn: You stand a third shorter than a human and carry {rules.HealthMalus:0.#} less health for it. The dvergr hood never leaves your head - wear whatever helm you please and keep every point of its protection, but the runes will always show you as one of the deep folk.\n");
|
||||||
|
|
||||||
|
sb.AppendLine($"[Base Passive] Runic Spark: The runes in your blood earth themselves through whatever you strike. Every blow you land carries +{rules.ElementalDamage:0.#} Lightning damage - a bonus that grows as each boss falls.\n");
|
||||||
|
|
||||||
List<string> weapons = new List<string>();
|
List<string> weapons = new List<string>();
|
||||||
foreach (DvergurConfig.WeaponAffinity affinity in rules.Affinities)
|
foreach (DvergarConfig.WeaponAffinity affinity in rules.Affinities)
|
||||||
{
|
{
|
||||||
weapons.Add(affinity.DisplayName);
|
weapons.Add(affinity.DisplayName);
|
||||||
}
|
}
|
||||||
|
|
@ -107,12 +109,12 @@ namespace RacesOfValheim
|
||||||
sb.AppendLine($"[Bonemass Unlock] Kin of the Traders (Passive): Haldor and Hildir know their own. Their prices drop by {rules.TraderBuyDiscount * 100f:0}% for you, and what they pay for your trophies and hunting rewards rises by {rules.TraderSellBonus * 100f:0}%.\n");
|
sb.AppendLine($"[Bonemass Unlock] Kin of the Traders (Passive): Haldor and Hildir know their own. Their prices drop by {rules.TraderBuyDiscount * 100f:0}% for you, and what they pay for your trophies and hunting rewards rises by {rules.TraderSellBonus * 100f:0}%.\n");
|
||||||
|
|
||||||
if (rules.RunicPing)
|
if (rules.RunicPing)
|
||||||
sb.AppendLine($"[Yagluth Unlock] Runic Ping ('{DvergurConfig.RunicPingKey}' Key): Spend {DvergurConfig.RunicPingEitrCost:0} eitr to send a pulse through the stone. For {DvergurConfig.RunicPingDuration:0} seconds every ore vein and every hidden enemy within {DvergurConfig.RunicPingRadius:0} meters is lit for you alone.\n");
|
sb.AppendLine($"[Yagluth Unlock] Runic Ping ('{DvergarConfig.RunicPingKey}' Key): Spend {DvergarConfig.RunicPingEitrCost:0} eitr to send a pulse through the stone. For {DvergarConfig.RunicPingDuration:0} seconds every ore vein and every hidden enemy within {DvergarConfig.RunicPingRadius:0} meters is lit for you alone.\n");
|
||||||
|
|
||||||
if (rules.RunicOvercharge)
|
if (rules.RunicOvercharge)
|
||||||
sb.AppendLine($"[Fader Unlock] Runic Overcharge ('{DvergurConfig.RunicOverchargeKey}' Key): Spend {DvergurConfig.RunicOverchargeEitrCost:0} eitr to load the runes. Your next blow with a favoured weapon lands with {DvergurConfig.RunicOverchargeMultiplier:0}x its weight. Hold the charge no longer than {DvergurConfig.RunicOverchargeWindow:0} seconds or it bleeds away.\n");
|
sb.AppendLine($"[Fader Unlock] Runic Overcharge ('{DvergarConfig.RunicOverchargeKey}' Key): Spend {DvergarConfig.RunicOverchargeEitrCost:0} eitr to load the runes. Your next blow with a favoured weapon lands with {DvergarConfig.RunicOverchargeMultiplier:0}x its weight. Hold the charge no longer than {DvergarConfig.RunicOverchargeWindow:0} seconds or it bleeds away.\n");
|
||||||
|
|
||||||
knownTexts["Dvergur Secrets"] = sb.ToString();
|
knownTexts["Dvergar Secrets"] = sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void GenerateDraughText(Dictionary<string, string> knownTexts, int state, Player player)
|
private static void GenerateDraughText(Dictionary<string, string> knownTexts, int state, Player player)
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace RacesOfValheim
|
||||||
/// makes every such race stamp on every other one, with the winner decided by whichever
|
/// makes every such race stamp on every other one, with the winner decided by whichever
|
||||||
/// postfix Harmony happened to run last.
|
/// postfix Harmony happened to run last.
|
||||||
///
|
///
|
||||||
/// That is what left the Dvergur at full height: Trol's reset ran on the same frame and put it
|
/// That is what left the Dvergar at full height: Trol's reset ran on the same frame and put it
|
||||||
/// straight back to 1. Asking here first means a race only ever resets a player that nobody
|
/// straight back to 1. Asking here first means a race only ever resets a player that nobody
|
||||||
/// else is sizing.
|
/// else is sizing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -19,7 +19,7 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
"Trol",
|
"Trol",
|
||||||
"Furling",
|
"Furling",
|
||||||
DvergurConfig.RaceId
|
DvergarConfig.RaceId
|
||||||
};
|
};
|
||||||
|
|
||||||
public static bool ManagesOwnScale(string race)
|
public static bool ManagesOwnScale(string race)
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ namespace RacesOfValheim
|
||||||
gameObject.AddComponent<FurlingRace>();
|
gameObject.AddComponent<FurlingRace>();
|
||||||
gameObject.AddComponent<TrolRace>();
|
gameObject.AddComponent<TrolRace>();
|
||||||
gameObject.AddComponent<DraughRace>();
|
gameObject.AddComponent<DraughRace>();
|
||||||
gameObject.AddComponent<DvergurRace>();
|
gameObject.AddComponent<DvergarRace>();
|
||||||
PrefabManager.OnVanillaPrefabsAvailable += CreateAllModAssets;
|
PrefabManager.OnVanillaPrefabsAvailable += CreateAllModAssets;
|
||||||
CommandManager.Instance.AddConsoleCommand(new ResetRaceCommand());
|
CommandManager.Instance.AddConsoleCommand(new ResetRaceCommand());
|
||||||
CommandManager.Instance.AddConsoleCommand(new CheckProgressionCommand());
|
CommandManager.Instance.AddConsoleCommand(new CheckProgressionCommand());
|
||||||
|
|
@ -74,8 +74,8 @@ namespace RacesOfValheim
|
||||||
player.GetSEMan().RemoveStatusEffect("SE_SkeletonStats".GetStableHashCode());
|
player.GetSEMan().RemoveStatusEffect("SE_SkeletonStats".GetStableHashCode());
|
||||||
player.GetSEMan().RemoveStatusEffect("SE_SkadiStats".GetStableHashCode());
|
player.GetSEMan().RemoveStatusEffect("SE_SkadiStats".GetStableHashCode());
|
||||||
player.GetSEMan().RemoveStatusEffect("SE_SkadiCooldown".GetStableHashCode());
|
player.GetSEMan().RemoveStatusEffect("SE_SkadiCooldown".GetStableHashCode());
|
||||||
player.GetSEMan().RemoveStatusEffect(DvergurConfig.StatsSE.GetStableHashCode());
|
player.GetSEMan().RemoveStatusEffect(DvergarConfig.StatsSE.GetStableHashCode());
|
||||||
player.GetSEMan().RemoveStatusEffect(DvergurConfig.OverchargeSE.GetStableHashCode());
|
player.GetSEMan().RemoveStatusEffect(DvergarConfig.OverchargeSE.GetStableHashCode());
|
||||||
|
|
||||||
ZNetView nview = player.GetComponent<ZNetView>();
|
ZNetView nview = player.GetComponent<ZNetView>();
|
||||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Human");
|
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Human");
|
||||||
|
|
@ -97,7 +97,7 @@ namespace RacesOfValheim
|
||||||
FurlingRace.Instance.CreateModAssets();
|
FurlingRace.Instance.CreateModAssets();
|
||||||
TrolRace.Instance.CreateModAssets();
|
TrolRace.Instance.CreateModAssets();
|
||||||
DraughRace.Instance.CreateModAssets();
|
DraughRace.Instance.CreateModAssets();
|
||||||
DvergurRace.Instance.CreateModAssets();
|
DvergarRace.Instance.CreateModAssets();
|
||||||
}
|
}
|
||||||
// --- RACE SELECTION UI ---
|
// --- RACE SELECTION UI ---
|
||||||
public void ShowRaceSelectionMenu()
|
public void ShowRaceSelectionMenu()
|
||||||
|
|
@ -239,7 +239,7 @@ namespace RacesOfValheim
|
||||||
CreateRaceButtonWithConfirm("Draugh", new Vector2(450, -20), GetDraughIcon(), "A decaying undead warrior fueled by dark magic and extreme metal.", SelectDraugh);
|
CreateRaceButtonWithConfirm("Draugh", new Vector2(450, -20), GetDraughIcon(), "A decaying undead warrior fueled by dark magic and extreme metal.", SelectDraugh);
|
||||||
|
|
||||||
// Row 3 (y = -140)
|
// Row 3 (y = -140)
|
||||||
CreateRaceButtonWithConfirm("Dvergur", new Vector2(-450, -140), GetDvergurIcon(), "Small, stubborn smiths of the deep. Frail of frame, but masters of metal, mine and market.", SelectDvergur);
|
CreateRaceButtonWithConfirm("Dvergar", new Vector2(-450, -140), GetDvergarIcon(), "Small, stubborn smiths of the deep. Frail of frame, but masters of metal, mine and market.", SelectDvergar);
|
||||||
|
|
||||||
GUIManager.BlockInput(true);
|
GUIManager.BlockInput(true);
|
||||||
}
|
}
|
||||||
|
|
@ -583,30 +583,30 @@ namespace RacesOfValheim
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SelectDvergur()
|
private void SelectDvergar()
|
||||||
{
|
{
|
||||||
if (Player.m_localPlayer != null)
|
if (Player.m_localPlayer != null)
|
||||||
{
|
{
|
||||||
Player.m_localPlayer.m_customData["Race"] = DvergurConfig.RaceId;
|
Player.m_localPlayer.m_customData["Race"] = DvergarConfig.RaceId;
|
||||||
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
|
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
|
||||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", DvergurConfig.RaceId);
|
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", DvergarConfig.RaceId);
|
||||||
|
|
||||||
Player.m_localPlayer.GetSEMan().AddStatusEffect(DvergurConfig.StatsSE.GetStableHashCode(), true);
|
Player.m_localPlayer.GetSEMan().AddStatusEffect(DvergarConfig.StatsSE.GetStableHashCode(), true);
|
||||||
|
|
||||||
// No SetSkinColor here: the tint is written onto the material by the UpdateColors
|
// No SetSkinColor here: the tint is written onto the material by the UpdateColors
|
||||||
// postfix in DvergurPatches, which keys off the race and so needs nothing saved.
|
// postfix in DvergarPatches, which keys off the race and so needs nothing saved.
|
||||||
VisEquipment visEq = Player.m_localPlayer.GetComponent<VisEquipment>();
|
VisEquipment visEq = Player.m_localPlayer.GetComponent<VisEquipment>();
|
||||||
if (visEq != null)
|
if (visEq != null)
|
||||||
{
|
{
|
||||||
visEq.GetType().GetMethod("UpdateVisuals", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null);
|
visEq.GetType().GetMethod("UpdateVisuals", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Dvergur.");
|
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Dvergar.");
|
||||||
CloseRaceSelectionMenu();
|
CloseRaceSelectionMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Sprite GetDvergurIcon()
|
private Sprite GetDvergarIcon()
|
||||||
{
|
{
|
||||||
GameObject prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("HelmetDverger")?.gameObject;
|
GameObject prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("HelmetDverger")?.gameObject;
|
||||||
if (prefab == null) prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("DvergrKeyFragment")?.gameObject;
|
if (prefab == null) prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("DvergrKeyFragment")?.gameObject;
|
||||||
|
|
@ -679,6 +679,11 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
if (__instance == Player.m_localPlayer)
|
if (__instance == Player.m_localPlayer)
|
||||||
{
|
{
|
||||||
|
// Runs before anything reads the race, so the rest of this method - and the race
|
||||||
|
// check further down that would otherwise reopen the selection menu - sees the
|
||||||
|
// renamed id rather than the old one.
|
||||||
|
DvergarRace.MigrateLegacyRaceId(__instance);
|
||||||
|
|
||||||
if (__instance.m_customData.ContainsKey("FenrirCurse_Active") && __instance.m_customData["FenrirCurse_Active"] == "true")
|
if (__instance.m_customData.ContainsKey("FenrirCurse_Active") && __instance.m_customData["FenrirCurse_Active"] == "true")
|
||||||
{
|
{
|
||||||
__instance.GetSEMan().AddStatusEffect("SE_FenrirCurse".GetStableHashCode(), true);
|
__instance.GetSEMan().AddStatusEffect("SE_FenrirCurse".GetStableHashCode(), true);
|
||||||
|
|
@ -691,7 +696,7 @@ namespace RacesOfValheim
|
||||||
if (visEq != null) visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null);
|
if (visEq != null) visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The Dvergur needs no entry here: its tint is applied by the UpdateColors postfix
|
// The Dvergar needs no entry here: its tint is applied by the UpdateColors postfix
|
||||||
// every time Valheim refreshes the body, rather than being stored on the player.
|
// every time Valheim refreshes the body, rather than being stored on the player.
|
||||||
|
|
||||||
// Check for Race Selection
|
// Check for Race Selection
|
||||||
|
|
@ -784,7 +789,7 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
public override void Run(string[] args)
|
public override void Run(string[] args)
|
||||||
{
|
{
|
||||||
string prefabName = args.Length > 0 ? args[0] : DvergurConfig.DvergerPrefabName;
|
string prefabName = args.Length > 0 ? args[0] : DvergarConfig.DvergerPrefabName;
|
||||||
GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(prefabName);
|
GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(prefabName);
|
||||||
if (prefab == null)
|
if (prefab == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
61
JotunnModStub/SkillLossFix.cs
Normal file
61
JotunnModStub/SkillLossFix.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace RacesOfValheim
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Honours the world's "no skill loss" setting for every skill, without exception.
|
||||||
|
///
|
||||||
|
/// Death runs Skills.OnDeath, which is only ever:
|
||||||
|
///
|
||||||
|
/// LowerAllSkills(m_DeathLowerFactor * Game.m_skillReductionRate)
|
||||||
|
///
|
||||||
|
/// and the world modifier works by driving m_skillReductionRate to zero. LowerAllSkills then
|
||||||
|
/// walks every skill and applies `m_level -= m_level * factor`, which at a factor of zero
|
||||||
|
/// takes nothing - but it also does two things unconditionally, whatever the factor:
|
||||||
|
///
|
||||||
|
/// * it wipes m_accumulator on every skill, throwing away all progress toward the next
|
||||||
|
/// level, and
|
||||||
|
/// * it prints "$msg_skills_lowered".
|
||||||
|
///
|
||||||
|
/// So on a no-skill-loss world a death still silently costs the progress banked toward the
|
||||||
|
/// next level in every skill and still announces a loss. On a skill sitting just short of the
|
||||||
|
/// next level that reads exactly like losing a level - which is how this surfaced, on Blood
|
||||||
|
/// Magic, the skill the Aswid gains fastest and so the one most likely to be near a boundary.
|
||||||
|
///
|
||||||
|
/// Blocking the call outright when the factor is zero is what "no skill loss" should mean.
|
||||||
|
/// The guard is on the factor rather than on the race, so it holds for every skill and every
|
||||||
|
/// race, and a world with a partial death penalty is left completely alone.
|
||||||
|
/// </summary>
|
||||||
|
[HarmonyPatch(typeof(Skills), "LowerAllSkills")]
|
||||||
|
public static class Skills_LowerAllSkills_NoLossPatch
|
||||||
|
{
|
||||||
|
// Not public on Game, hence the reflection; resolved once rather than per death.
|
||||||
|
private static readonly FieldInfo SkillReductionRateField =
|
||||||
|
AccessTools.Field(typeof(Game), "m_skillReductionRate");
|
||||||
|
|
||||||
|
public static bool Prefix(Skills __instance, float factor)
|
||||||
|
{
|
||||||
|
Player player = Traverse.Create(__instance).Field<Player>("m_player").Value;
|
||||||
|
if (player == null || player != Player.m_localPlayer) return true;
|
||||||
|
|
||||||
|
// Logged either way: a death that lowers nothing and a death that lowers something
|
||||||
|
// look identical from in-game, and this is the only place the difference is visible.
|
||||||
|
float worldRate = ReadWorldRate();
|
||||||
|
Jotunn.Logger.LogInfo(
|
||||||
|
$"[SkillLoss] LowerAllSkills factor={factor} worldSkillReductionRate={worldRate} " +
|
||||||
|
$"bloodMagic={player.GetSkillLevel(Skills.SkillType.BloodMagic):0.##} " +
|
||||||
|
$"-> {(factor <= 0f ? "blocked" : "allowed")}");
|
||||||
|
|
||||||
|
return factor > 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static float ReadWorldRate()
|
||||||
|
{
|
||||||
|
// Fail loud rather than silently: a rename in a game update should show up in the log
|
||||||
|
// as an obviously wrong number, not as a patch that quietly stops matching.
|
||||||
|
if (SkillReductionRateField == null) return float.NaN;
|
||||||
|
return (float)SkillReductionRateField.GetValue(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -95,7 +95,12 @@ namespace RacesOfValheim
|
||||||
public const string StateKey = "RacesOfValheim_State";
|
public const string StateKey = "RacesOfValheim_State";
|
||||||
public const string TrueFormKey = "RacesOfValheim_TrolTrueForm";
|
public const string TrueFormKey = "RacesOfValheim_TrolTrueForm";
|
||||||
|
|
||||||
private static float lastRemoteLog = 0f;
|
// Remote sync tracing. It used to fire on a 2-second timer for as long as a remote player
|
||||||
|
// existed, which in the main menu means forever: Player.m_localPlayer is null there, so the
|
||||||
|
// character-preview player counts as remote and the log never stopped. Keyed on the state
|
||||||
|
// it reports instead, so it still catches a remote player being sized wrongly - the reason
|
||||||
|
// it exists - without narrating a menu that is doing nothing.
|
||||||
|
private static string lastRemoteLogKey = "";
|
||||||
|
|
||||||
private static float ScaleForState(int state)
|
private static float ScaleForState(int state)
|
||||||
{
|
{
|
||||||
|
|
@ -147,13 +152,17 @@ namespace RacesOfValheim
|
||||||
targetScale = state >= 7 ? 2.5f : 2.0f;
|
targetScale = state >= 7 ? 2.5f : 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLocal && Time.time - lastRemoteLog > 2f)
|
if (!isLocal)
|
||||||
{
|
{
|
||||||
lastRemoteLog = Time.time;
|
string logKey = $"{__instance.GetPlayerName()}|{race}|{zdoReady}|{state}|{isTrueFormActive}|{targetScale:F2}";
|
||||||
Jotunn.Logger.LogInfo(
|
if (logKey != lastRemoteLogKey)
|
||||||
$"[TrolSync] remote '{__instance.GetPlayerName()}' race='{race}' zdoReady={zdoReady} " +
|
{
|
||||||
$"state={state} trueForm={isTrueFormActive} target={targetScale:F2} " +
|
lastRemoteLogKey = logKey;
|
||||||
$"currentScale={visual.transform.localScale.x:F2} rootScale={__instance.transform.localScale.x:F2}");
|
Jotunn.Logger.LogInfo(
|
||||||
|
$"[TrolSync] remote '{__instance.GetPlayerName()}' race='{race}' zdoReady={zdoReady} " +
|
||||||
|
$"state={state} trueForm={isTrueFormActive} target={targetScale:F2} " +
|
||||||
|
$"currentScale={visual.transform.localScale.x:F2} rootScale={__instance.transform.localScale.x:F2}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (race == "Trol")
|
if (race == "Trol")
|
||||||
|
|
@ -179,7 +188,7 @@ namespace RacesOfValheim
|
||||||
else if (!RaceScale.ManagesOwnScale(race) && Mathf.Abs(visual.transform.localScale.x - 1f) > 0.001f)
|
else if (!RaceScale.ManagesOwnScale(race) && Mathf.Abs(visual.transform.localScale.x - 1f) > 0.001f)
|
||||||
{
|
{
|
||||||
// Races that size themselves are left alone. Without this guard the reset fires on
|
// Races that size themselves are left alone. Without this guard the reset fires on
|
||||||
// every frame for a Furling or a Dvergur too, undoing their scale as fast as they
|
// every frame for a Furling or a Dvergar too, undoing their scale as fast as they
|
||||||
// set it, because both are applied from a postfix on this same method.
|
// set it, because both are applied from a postfix on this same method.
|
||||||
visual.transform.localScale = Vector3.one;
|
visual.transform.localScale = Vector3.one;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,11 +81,11 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
// Managed externally in TrolPatches.cs
|
// Managed externally in TrolPatches.cs
|
||||||
}
|
}
|
||||||
else if (race == DvergurConfig.RaceId)
|
else if (race == DvergarConfig.RaceId)
|
||||||
{
|
{
|
||||||
// Scale is handled for every player by the Player.Update postfix; this only keeps
|
// Scale is handled for every player by the Player.Update postfix; this only keeps
|
||||||
// the hood and the hidden helmet asserted between equipment refreshes.
|
// the hood and the hidden helmet asserted between equipment refreshes.
|
||||||
DvergurVisuals.ApplyHood(m_player);
|
DvergarVisuals.ApplyHood(m_player);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue