Initial commit

This commit is contained in:
Ferdinando 2026-07-30 19:00:13 +02:00
commit c4a24c9fdf
142 changed files with 15491 additions and 0 deletions

View file

@ -0,0 +1,157 @@
using HarmonyLib;
using UnityEngine;
using System.Collections.Generic;
namespace RacesOfValheim
{
/// <summary>
/// "Through Fire and Flames" — unlocks after Fader (state >= 8).
///
/// Effects:
/// 1. Player has SE_Burning applied ONCE (999-min duration), like walking on a bonfire.
/// Reapplied automatically after respawn, load, or state unlock.
/// 2. No fire damage taken (handled in FurlingPatches.Furling_Character_Damage_Patch).
/// 3. The Burning icon is hidden from the HUD.
/// 4. All physical attacks apply SE_Burning to the target.
/// </summary>
public static class FurlingFireAbility
{
private static int _lastState = -1;
private static bool _burningApplied = false;
private static readonly int BurningHash = "Burning".GetStableHashCode();
private const float BURN_DURATION = 999f * 60f; // 999 minutes in seconds
// ─── Called from FurlingRace.Update() — cheap check, no timer ────────
public static void Tick()
{
if (Player.m_localPlayer == null || !FurlingRace.IsFurling())
{
_burningApplied = false;
_lastState = -1;
return;
}
int state = BossProgressionManager.GetCurrentProgressionState();
if (state < 8)
{
_burningApplied = false;
_lastState = state;
return;
}
bool stateJustUnlocked = (_lastState < 8);
bool seMissing = !Player.m_localPlayer.GetSEMan()
.HaveStatusEffect(BurningHash);
// Apply only when: first time, state just reached 8, or SE was lost (respawn/load)
if (!_burningApplied || stateJustUnlocked || seMissing)
{
ApplyPermanentBurning();
_burningApplied = true;
}
_lastState = state;
}
private static void ApplyPermanentBurning()
{
var seman = Player.m_localPlayer.GetSEMan();
// Allow our application through the suppression patch
FurlingFire_SuppressExternalBurning_Patch.AllowNextBurning = true;
seman.AddStatusEffect(BurningHash, true);
// Override the duration to 999 minutes so it never expires naturally
StatusEffect se = seman.GetStatusEffect(BurningHash);
if (se != null)
{
se.m_ttl = BURN_DURATION;
// Reset elapsed time so we start fresh
HarmonyLib.Traverse.Create(se).Field<float>("m_time").Value = 0f;
}
}
// ─── Hide Burning icon from HUD ───────────────────────────────────────
[HarmonyPatch(typeof(SEMan), "GetStatusEffects")]
public static class FurlingFire_HideHUDBurning_Patch
{
public static void Postfix(SEMan __instance, List<StatusEffect> __result)
{
if (__result == null || __result.Count == 0) return;
Character character = HarmonyLib.Traverse.Create(__instance)
.Field<Character>("m_character").Value;
if (character == null || character != Player.m_localPlayer) return;
if (!FurlingRace.IsFurling()) return;
if (BossProgressionManager.GetCurrentProgressionState() < 8) return;
__result.RemoveAll(se => se != null && se.name != null &&
se.name.IndexOf("Burning", System.StringComparison.OrdinalIgnoreCase) >= 0);
}
}
// ─── Block external Burning (fire pits, arrows) from being applied ────
[HarmonyPatch(typeof(SEMan), "AddStatusEffect",
new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })]
public static class FurlingFire_SuppressExternalBurning_Patch
{
public static bool AllowNextBurning = false;
public static bool Prefix(SEMan __instance, ref int nameHash)
{
if (nameHash != BurningHash) return true;
Character character = HarmonyLib.Traverse.Create(__instance)
.Field<Character>("m_character").Value;
if (character == null || character != Player.m_localPlayer) return true;
if (!FurlingRace.IsFurling()) return true;
if (BossProgressionManager.GetCurrentProgressionState() < 8) return true;
if (AllowNextBurning)
{
AllowNextBurning = false;
return true; // our own application — allow
}
return false; // external source — block (player is immune)
}
}
// ─── Physical attacks set enemies on fire ─────────────────────────────
[HarmonyPatch(typeof(Character), "Damage")]
public static class FurlingFire_IgniteOnHit_Patch
{
public static void Prefix(Character __instance, HitData hit)
{
if (__instance == null || __instance is Player) return;
if (Player.m_localPlayer == null || !FurlingRace.IsFurling()) return;
if (BossProgressionManager.GetCurrentProgressionState() < 8) return;
Character attacker = hit.GetAttacker();
if (attacker == null || attacker != Player.m_localPlayer) return;
if (hit.m_damage.m_blunt > 0 || hit.m_damage.m_slash > 0 ||
hit.m_damage.m_pierce > 0 || hit.m_damage.m_chop > 0 ||
hit.m_damage.m_pickaxe > 0)
{
hit.m_damage.m_fire = Mathf.Max(hit.m_damage.m_fire, 10f);
}
}
public static void Postfix(Character __instance, HitData hit)
{
if (__instance == null || __instance is Player) return;
if (Player.m_localPlayer == null || !FurlingRace.IsFurling()) return;
if (BossProgressionManager.GetCurrentProgressionState() < 8) return;
Character attacker = hit.GetAttacker();
if (attacker == null || attacker != Player.m_localPlayer) return;
if (!__instance.IsDead())
__instance.GetSEMan().AddStatusEffect(BurningHash, true);
}
}
}
}

View file

@ -0,0 +1,149 @@
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
using Jotunn.Managers;
namespace RacesOfValheim
{
/// <summary>
/// Displays a small "King / Queen" status indicator in the top-right corner of the HUD
/// when the local Furling player is inside the Plains biome and has unlocked the Yagluth ability (state >= 8).
/// Shows the unmodified Midsummer Crown icon above the gendered title.
/// </summary>
public static class FurlingKingUI
{
private static GameObject _hudRoot; // root panel anchored top-right
private static Image _crownImage; // the crown sprite
private static Text _titleText; // "King" / "Queen"
private const float UPDATE_INTERVAL = 1.0f;
private static float _timer = 0f;
// ─── Harmony patch: hook onto Hud.Update ─────────────────────────────
[HarmonyPatch(typeof(Hud), "Update")]
public static class FurlingKingUI_Hud_Update_Patch
{
public static void Postfix(Hud __instance)
{
_timer += Time.deltaTime;
if (_timer < UPDATE_INTERVAL) return;
_timer = 0f;
Tick(__instance);
}
}
// ─── Core update logic ────────────────────────────────────────────────
private static void Tick(Hud hud)
{
bool shouldShow = ShouldShowKingStatus();
if (!shouldShow)
{
if (_hudRoot != null) _hudRoot.SetActive(false);
return;
}
// Build the UI the first time it's needed
if (_hudRoot == null)
{
BuildUI(hud);
if (_hudRoot == null) return; // build failed (prefab not ready yet)
}
_hudRoot.SetActive(true);
// Update label based on player model (0 = male → King, 1 = female → Queen)
if (_titleText != null && Player.m_localPlayer != null)
{
int modelIndex = HarmonyLib.Traverse.Create(
Player.m_localPlayer.GetComponent<VisEquipment>()
).Field<int>("m_modelIndex").Value;
_titleText.text = (modelIndex == 1) ? "Queen" : "King";
}
}
// ─── Condition check ──────────────────────────────────────────────────
private static bool ShouldShowKingStatus()
{
if (Player.m_localPlayer == null) return false;
if (!FurlingRace.IsFurling()) return false;
if (BossProgressionManager.GetCurrentProgressionState() < 8) return false;
// Check Plains biome
Heightmap.Biome biome = Player.m_localPlayer.GetCurrentBiome();
return biome == Heightmap.Biome.Plains;
}
// ─── Build the HUD panel ──────────────────────────────────────────────
private static void BuildUI(Hud hud)
{
// Fetch the crown item icon
Sprite crownSprite = null;
var crownPrefab = PrefabManager.Cache.GetPrefab<ItemDrop>("HelmetMidsummerCrown");
if (crownPrefab != null)
crownSprite = crownPrefab.m_itemData.m_shared.m_icons.Length > 0
? crownPrefab.m_itemData.m_shared.m_icons[0]
: null;
// Parent to the Hud root canvas
Canvas canvas = hud.GetComponentInChildren<Canvas>();
if (canvas == null) return;
// Root panel
_hudRoot = new GameObject("FurlingKingStatus", typeof(RectTransform));
_hudRoot.transform.SetParent(canvas.transform, false);
RectTransform rt = _hudRoot.GetComponent<RectTransform>();
rt.anchorMin = new Vector2(1f, 1f);
rt.anchorMax = new Vector2(1f, 1f);
rt.pivot = new Vector2(1f, 1f);
rt.sizeDelta = new Vector2(90f, 110f);
rt.anchoredPosition = new Vector2(-10f, -10f); // 10px from top-right edge
// ── Crown icon ──────────────────────────────────────────────────
GameObject iconGO = new GameObject("CrownIcon", typeof(RectTransform), typeof(Image));
iconGO.transform.SetParent(_hudRoot.transform, false);
RectTransform iconRt = iconGO.GetComponent<RectTransform>();
iconRt.anchorMin = new Vector2(0.5f, 1f);
iconRt.anchorMax = new Vector2(0.5f, 1f);
iconRt.pivot = new Vector2(0.5f, 1f);
iconRt.sizeDelta = new Vector2(72f, 72f);
iconRt.anchoredPosition = Vector2.zero;
_crownImage = iconGO.GetComponent<Image>();
_crownImage.preserveAspect = true;
if (crownSprite != null)
_crownImage.sprite = crownSprite;
else
_crownImage.color = new Color(1f, 0.9f, 0.2f, 1f); // gold fallback
// ── Title text ──────────────────────────────────────────────────
GameObject textGO = new GameObject("TitleText", typeof(RectTransform), typeof(Text));
textGO.transform.SetParent(_hudRoot.transform, false);
RectTransform textRt = textGO.GetComponent<RectTransform>();
textRt.anchorMin = new Vector2(0f, 0f);
textRt.anchorMax = new Vector2(1f, 0f);
textRt.pivot = new Vector2(0.5f, 0f);
textRt.sizeDelta = new Vector2(0f, 28f);
textRt.anchoredPosition = Vector2.zero;
_titleText = textGO.GetComponent<Text>();
_titleText.text = "King";
_titleText.alignment = TextAnchor.MiddleCenter;
_titleText.fontSize = 18;
_titleText.fontStyle = FontStyle.Bold;
_titleText.color = new Color(1f, 0.92f, 0.4f, 1f); // gold text
// Try to match Valheim's font
_titleText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
// ── Subtle dark backing for readability ─────────────────────────
CanvasGroup cg = _hudRoot.AddComponent<CanvasGroup>();
cg.alpha = 0.92f;
}
}
}

View file

@ -0,0 +1,643 @@
using HarmonyLib;
using UnityEngine;
using Jotunn.Managers;
namespace RacesOfValheim
{
public static class FurlingPatches
{
[HarmonyPatch(typeof(Player), "Update")]
public static class Furling_PlayerUpdate_Patch
{
public static void Postfix(Player __instance)
{
if (__instance == null || __instance != Player.m_localPlayer) return;
if (FurlingRace.IsFurling())
{
// Scale player visuals down by 19% (0.9 * 0.9 = 0.81)
GameObject visual = Traverse.Create(__instance).Field("m_visual").GetValue<GameObject>();
if (visual != null && visual.transform.localScale != new Vector3(0.81f, 0.81f, 0.81f))
{
visual.transform.localScale = new Vector3(0.81f, 0.81f, 0.81f);
}
}
else
{
// Reset scale if not Furling
GameObject visual = Traverse.Create(__instance).Field("m_visual").GetValue<GameObject>();
if (visual != null && visual.transform.localScale == new Vector3(0.81f, 0.81f, 0.81f))
{
visual.transform.localScale = Vector3.one;
}
}
}
}
// +10% movement speed — fixed, does not scale with progression
[HarmonyPatch(typeof(Character), "GetRunSpeedFactor")]
public static class Furling_GetRunSpeedFactor_Patch
{
public static void Postfix(Character __instance, ref float __result)
{
if (__instance == null || __instance != Player.m_localPlayer) return;
if (!FurlingRace.IsFurling()) return;
__result *= 1.1f;
}
}
[HarmonyPatch(typeof(BaseAI), "IsEnemy", typeof(Character), typeof(Character))]
public static class Furling_BaseAI_IsEnemy_Patch
{
public static void Postfix(Character a, Character b, ref bool __result)
{
if (!__result || !FurlingRace.IsFurling() || Player.m_localPlayer == null) return;
Character playerChar = Player.m_localPlayer;
Character otherChar = null;
if (a == playerChar) otherChar = b;
else if (b == playerChar) otherChar = a;
if (otherChar != null)
{
string name = otherChar.gameObject.name.Replace("(Clone)", "").ToLower();
if (name == "goblin" ||
name == "goblinbrute" ||
name == "goblinshaman" ||
name == "lox" ||
name == "deathsquito" ||
name == "troll")
{
// Exclude minibosses/bosses explicitly if needed, but normally bosses are handled separately (Yagluth is GoblinKing).
if (name != "goblinking")
{
__result = false;
}
}
}
}
}
[HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")]
public static class Furling_VisEquipment_UpdateVisuals_Patch
{
public static string GetPlayerRace(VisEquipment visEq)
{
Player player = visEq.GetComponent<Player>();
if (player != null)
{
ZNetView nview = player.GetComponent<ZNetView>();
if (nview != null && nview.IsValid())
{
return nview.GetZDO().GetString("RacesOfValheim_Race", "Human");
}
// Main Menu handling and local fallback
if (player.m_customData != null && player.m_customData.TryGetValue("Race", out string r))
{
return r;
}
}
return "Human";
}
public static void Postfix(VisEquipment __instance)
{
if (!__instance.m_isPlayer) return;
string race = GetPlayerRace(__instance);
if (race == "Furling")
{
// Ensure the base model IS shown
if (__instance.m_bodyModel != null)
{
__instance.m_bodyModel.enabled = true;
Transform headBone = FindBoneByName(__instance.m_bodyModel.bones, "Head");
if (headBone != null)
{
Transform furlingHead = headBone.Find("FurlingHead_Trophy");
if (furlingHead == null)
{
GameObject trophyPrefab = PrefabManager.Cache.GetPrefab<ItemDrop>("TrophyGoblin")?.gameObject;
if (trophyPrefab != null)
{
// instantiateInWorldSpace = false per ereditare esattamente la trasformazione base
GameObject trophyVisual = UnityEngine.Object.Instantiate(trophyPrefab, headBone, false);
trophyVisual.name = "FurlingHead_Trophy";
// Rimuoviamo tutti gli script (HoverText, ZNetView, ItemDrop, ecc.) per evitare prompt a schermo
foreach (var comp in trophyVisual.GetComponentsInChildren<MonoBehaviour>())
{
UnityEngine.Object.Destroy(comp);
}
if (trophyVisual.GetComponent<Rigidbody>() != null)
UnityEngine.Object.Destroy(trophyVisual.GetComponent<Rigidbody>());
foreach (var col in trophyVisual.GetComponentsInChildren<Collider>())
{
UnityEngine.Object.Destroy(col);
}
// Valheim rig scales are huge (100).
// Spostiamo la testa leggermente in alto (asse Y = 0.0015) e 5cm indietro rispetto al centro (asse X positivo = 0.0005)
trophyVisual.transform.localPosition = new Vector3(0.0005f, 0.0015f, 0f);
// Torniamo allo stato precedente (Z=90) ma ruotiamo sull'asse delle orecchie (X) di -90
trophyVisual.transform.localRotation = Quaternion.Euler(-90, 0, 90);
// Rimpiccioliamo la testa affinché entri in quella umana (ulteriore 20% in meno -> 0.005832)
trophyVisual.transform.localScale = new Vector3(0.005832f, 0.005832f, 0.005832f);
// Risolve il problema della trasparenza (dither):
// Non possiamo applicare m_bodyModel.material perché i modelli (UV map) non coincidono e l'oggetto diventa invisibile.
// Ripristiniamo il materiale originale del trofeo, ma cambiamo il suo shader in Custom/Creature per fargli
// supportare la dissolvenza (dither) della telecamera, mantenendo le sue texture originali (che sono già verdi).
foreach (var mr in trophyVisual.GetComponentsInChildren<Renderer>())
{
if (mr.material != null)
{
Shader ditherShader = Shader.Find("Custom/Creature");
if (ditherShader != null)
{
mr.material.shader = ditherShader;
}
}
}
}
}
else
{
furlingHead.gameObject.SetActive(true);
}
}
int modelIndex = Traverse.Create(__instance).Field<int>("m_modelIndex").Value;
if (modelIndex == 0)
{
HideItem(__instance, "m_hairItemInstance");
HideItem(__instance, "m_hairItemInstances"); // In case it's a list in some versions
}
HideItem(__instance, "m_beardItemInstance");
HideItem(__instance, "m_beardItemInstances");
// Restore helmet visibility — let the game manage it normally
ShowItem(__instance, "m_helmetItemInstance");
}
}
else
{
// Not a furling, cleanup
if (__instance.m_bodyModel != null)
{
__instance.m_bodyModel.enabled = true;
Transform headBone = FindBoneByName(__instance.m_bodyModel.bones, "Head");
if (headBone != null)
{
Transform furlingHead = headBone.Find("FurlingHead_Trophy");
if (furlingHead != null)
{
furlingHead.gameObject.SetActive(false);
}
// Distruggiamo il tappo del collo (se c'era in precedenza) per sicurezza
Transform neckCap = headBone.Find("FulingNeckCap");
if (neckCap != null)
{
UnityEngine.Object.Destroy(neckCap.gameObject);
}
}
ShowItem(__instance, "m_hairItemInstance");
ShowItem(__instance, "m_beardItemInstance");
ShowItem(__instance, "m_hairItemInstances");
ShowItem(__instance, "m_beardItemInstances");
}
}
}
private static void HideItem(VisEquipment visEq, string fieldName)
{
try
{
var field = typeof(VisEquipment).GetField(fieldName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (field != null)
{
object val = field.GetValue(visEq);
if (val is GameObject go && go != null)
{
go.SetActive(false);
}
else if (val is System.Collections.Generic.List<GameObject> list)
{
foreach (var item in list) if (item != null) item.SetActive(false);
}
}
}
catch (System.Exception) { }
}
private static void ShowItem(VisEquipment visEq, string fieldName)
{
try
{
var field = typeof(VisEquipment).GetField(fieldName, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
if (field != null)
{
object val = field.GetValue(visEq);
if (val is GameObject go && go != null)
{
go.SetActive(true);
}
else if (val is System.Collections.Generic.List<GameObject> list)
{
foreach (var item in list) if (item != null) item.SetActive(true);
}
}
}
catch (System.Exception) { }
}
private static Transform FindBoneByName(Transform[] bones, string targetBoneName)
{
// Exact match first
foreach (Transform b in bones)
{
if (b != null && b.name == targetBoneName) return b;
}
// Fuzzy match
string sName = targetBoneName.ToLower().Replace("goblin_", "").Replace("furling_", "").Replace(" goblin", "");
// Common valheim mappings
if (sName == "pelvis") sName = "hips";
if (sName == "clavicle.l") sName = "leftshoulder";
if (sName == "clavicle.r") sName = "rightshoulder";
if (sName == "upperarm.l") sName = "leftarm";
if (sName == "upperarm.r") sName = "rightarm";
if (sName == "lowerarm.l") sName = "leftforearm";
if (sName == "lowerarm.r") sName = "rightforearm";
if (sName == "thigh.l") sName = "leftupleg";
if (sName == "thigh.r") sName = "rightupleg";
if (sName == "calf.l") sName = "leftleg";
if (sName == "calf.r") sName = "rightleg";
foreach (Transform b in bones)
{
if (b != null)
{
string pName = b.name.ToLower();
if (pName == sName || pName.Contains(sName) || sName.Contains(pName))
{
return b;
}
}
}
return null;
}
}
[HarmonyPatch(typeof(Skills), "RaiseSkill")]
public static class Furling_Skills_RaiseSkill_Patch
{
public static void Prefix(Skills __instance, Skills.SkillType skillType, ref float factor)
{
// Check if this Skills instance belongs to the local player
Player player = HarmonyLib.Traverse.Create(__instance).Field("m_player").GetValue<Player>();
if (player != null && player == Player.m_localPlayer && FurlingRace.IsFurling())
{
// The Art of War: Double XP for weapon skills (always active)
bool isWeaponSkill = (skillType == Skills.SkillType.Swords ||
skillType == Skills.SkillType.Knives ||
skillType == Skills.SkillType.Clubs ||
skillType == Skills.SkillType.Polearms ||
skillType == Skills.SkillType.Spears ||
skillType == Skills.SkillType.Axes ||
skillType == Skills.SkillType.Bows ||
skillType == Skills.SkillType.Crossbows ||
skillType == Skills.SkillType.Unarmed ||
skillType == Skills.SkillType.Blocking);
if (isWeaponSkill)
{
factor *= 2f;
}
else if (BossProgressionManager.GetCurrentProgressionState() >= 6)
{
// The King is Dead: in Plains, ALL other skills (including magic) get 2x XP
if (EnvMan.instance != null && EnvMan.instance.GetCurrentBiome() == Heightmap.Biome.Plains)
{
factor *= 2f;
}
}
}
}
}
[HarmonyPatch(typeof(Character), "AddNoise")]
public static class Furling_Character_AddNoise_Patch
{
public static bool Prefix(Character __instance, float range)
{
if (__instance != null && __instance == Player.m_localPlayer && FurlingRace.IsFurling())
{
// Check if it's nighttime or inside a dungeon
if (BossProgressionManager.GetCurrentProgressionState() >= 2) // Master of Shadows (Eikthyr)
{
if (range <= 15f)
{
return false;
}
}
}
return true;
}
}
[HarmonyPatch(typeof(Character), "Damage")]
public static class Furling_Character_Damage_Patch
{
public static void Prefix(Character __instance, HitData hit)
{
if (__instance != null && __instance == Player.m_localPlayer && FurlingRace.IsFurling())
{
int state = BossProgressionManager.GetCurrentProgressionState();
if (state >= 8) // Through Fire and Flames (Fader): full fire immunity
{
hit.m_damage.m_fire = 0f;
if (hit.m_damage.m_poison > 0) hit.m_damage.m_poison *= 0.5f;
}
else if (state >= 3) // The Wickerman: -50% fire and poison
{
if (hit.m_damage.m_fire > 0) hit.m_damage.m_fire *= 0.5f;
if (hit.m_damage.m_poison > 0) hit.m_damage.m_poison *= 0.5f;
}
}
}
}
[HarmonyPatch(typeof(Projectile), "Setup")]
public static class Furling_Projectile_Setup_Patch
{
public static void Prefix(Character owner, Vector3 velocity, float hitNoise, HitData hitData, ItemDrop.ItemData item, ItemDrop.ItemData ammo)
{
if (owner != null && owner == Player.m_localPlayer && FurlingRace.IsFurling())
{
if (BossProgressionManager.GetCurrentProgressionState() >= 3) // The Wickerman (Elder)
{
// Check if it's an arrow (either by skill or by checking if a bow/ammo was used)
if ((hitData != null && hitData.m_skill == Skills.SkillType.Bows) ||
(ammo != null && ammo.m_shared.m_skillType == Skills.SkillType.Bows))
{
// If the arrow doesn't already have significant fire damage, add it
if (hitData != null && hitData.m_damage.m_fire < 22f)
{
// Adds fire damage equivalent to a standard fire arrow
hitData.m_damage.m_fire = Mathf.Max(hitData.m_damage.m_fire, 22f);
}
}
}
}
}
}
[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
public static class Furling_InventoryGui_DoCrafting_Patch
{
public static void Postfix(InventoryGui __instance, Player player)
{
if (Player.m_localPlayer != null && FurlingRace.IsFurling())
{
if (BossProgressionManager.GetCurrentProgressionState() >= 4) // Dance of the Dead (Bonemass)
{
Recipe craftRecipe = HarmonyLib.Traverse.Create(__instance).Field("m_craftRecipe").GetValue<Recipe>();
if (craftRecipe == null || craftRecipe.m_item == null) return;
ItemDrop itemDrop = craftRecipe.m_item;
string prefabName = itemDrop.gameObject.name.ToLower();
ItemDrop.ItemData.ItemType type = itemDrop.m_itemData.m_shared.m_itemType;
bool isMead = prefabName.Contains("mead") || prefabName.Contains("potion") || prefabName.Contains("wine");
bool isBomb = prefabName.Contains("bomb") || prefabName.Contains("oozeboomb") || prefabName.Contains("bile");
bool isAmmo = type == ItemDrop.ItemData.ItemType.Ammo;
if (isMead || isBomb || isAmmo)
{
int amount = craftRecipe.m_amount;
ItemDrop.ItemData craftUpgradeItem = HarmonyLib.Traverse.Create(__instance).Field("m_craftUpgradeItem").GetValue<ItemDrop.ItemData>();
int quality = craftUpgradeItem != null ? craftUpgradeItem.m_quality + 1 : 1;
int craftVariant = HarmonyLib.Traverse.Create(__instance).Field("m_craftVariant").GetValue<int>();
ItemDrop.ItemData addedItem = player.GetInventory().AddItem(itemDrop.gameObject.name, amount, quality, craftVariant, player.GetPlayerID(), player.GetPlayerName());
if (addedItem == null)
{
// Inventory full, drop on ground
GameObject go = UnityEngine.Object.Instantiate(itemDrop.gameObject, player.transform.position + player.transform.forward + Vector3.up, Quaternion.identity);
ItemDrop drop = go.GetComponent<ItemDrop>();
drop.m_itemData.m_stack = amount;
drop.m_itemData.m_quality = quality;
drop.m_itemData.m_variant = craftVariant;
}
}
}
}
}
}
[HarmonyPatch(typeof(VisEquipment), "UpdateColors")]
public static class FurlingSkinColorPatch
{
public static void Postfix(VisEquipment __instance)
{
if (!__instance.m_isPlayer) return;
string race = Furling_VisEquipment_UpdateVisuals_Patch.GetPlayerRace(__instance);
if (race == "Furling")
{
if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null)
{
// Verde più acceso/brillante (Goblin)
Color furlingColor = new Color(0.4f, 0.75f, 0.25f, 1f);
__instance.m_bodyModel.material.SetColor("_SkinColor", furlingColor);
}
int modelIndex = Traverse.Create(__instance).Field<int>("m_modelIndex").Value;
if (modelIndex == 1) // Female
{
var hairInst = Traverse.Create(__instance).Field("m_hairItemInstance").GetValue<GameObject>();
if (hairInst != null)
{
foreach (var r in hairInst.GetComponentsInChildren<Renderer>())
{
if (r.material != null) r.material.SetColor("_SkinColor", Color.red);
}
}
}
}
}
}
public static bool IsMining = false;
[HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")]
public static class Furling_CharacterDrop_GenerateDropList_Patch
{
public static void Postfix(CharacterDrop __instance, ref System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<GameObject, int>> __result)
{
if (Player.m_localPlayer == null || !FurlingRace.IsFurling()) return;
if (BossProgressionManager.GetCurrentProgressionState() < 5) return;
Character character = __instance.GetComponent<Character>();
if (character != null && (character.IsBoss() || character.gameObject.name.ToLower().Contains("boss"))) return;
float distance = Vector3.Distance(Player.m_localPlayer.transform.position, __instance.transform.position);
if (distance > 25f) return;
var newList = new System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<GameObject, int>>();
foreach (var drop in __result)
{
var go = drop.Key;
int amount = drop.Value;
if (go != null)
{
var itemDrop = go.GetComponent<ItemDrop>();
if (itemDrop != null && itemDrop.m_itemData.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Trophy)
{
amount *= 2;
}
}
newList.Add(new System.Collections.Generic.KeyValuePair<GameObject, int>(go, amount));
}
Character character2 = __instance.GetComponent<Character>();
int stars = character2 != null ? character2.GetLevel() - 1 : 0;
if (stars > 0)
{
GameObject coinsPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>("Coins");
if (coinsPrefab != null)
{
int extraCoins = stars * UnityEngine.Random.Range(1, 26);
newList.Add(new System.Collections.Generic.KeyValuePair<GameObject, int>(coinsPrefab, extraCoins));
}
}
__result = newList;
}
}
[HarmonyPatch(typeof(MineRock5), "DamageArea")]
public static class Furling_MineRock5_DamageArea_Patch
{
public static void Prefix(HitData hit, out bool __state)
{
__state = false;
if (hit == null) return;
Character attacker = hit.GetAttacker();
if (attacker != null && attacker == Player.m_localPlayer && FurlingRace.IsFurling() && BossProgressionManager.GetCurrentProgressionState() >= 5)
{
IsMining = true;
__state = true;
}
}
public static void Postfix(bool __state)
{
if (__state) IsMining = false;
}
}
[HarmonyPatch(typeof(MineRock), "RPC_Hit")]
public static class Furling_MineRock_RPC_Damage_Patch
{
public static void Prefix(HitData hit, out bool __state)
{
__state = false;
if (hit == null) return;
Character attacker = hit.GetAttacker();
if (attacker != null && attacker == Player.m_localPlayer && FurlingRace.IsFurling() && BossProgressionManager.GetCurrentProgressionState() >= 5)
{
IsMining = true;
__state = true;
}
}
public static void Postfix(bool __state)
{
if (__state) IsMining = false;
}
}
[HarmonyPatch(typeof(Destructible), "RPC_Damage")]
public static class Furling_Destructible_RPC_Damage_Patch
{
public static void Prefix(HitData hit, out bool __state)
{
__state = false;
if (hit == null) return;
Character attacker = hit.GetAttacker();
if (attacker != null && attacker == Player.m_localPlayer && FurlingRace.IsFurling() && BossProgressionManager.GetCurrentProgressionState() >= 5)
{
IsMining = true;
__state = true;
}
}
public static void Postfix(bool __state)
{
if (__state) IsMining = false;
}
}
[HarmonyPatch(typeof(DropTable), "GetDropList", new System.Type[] { typeof(int) })]
public static class Furling_DropTable_GetDropList_Patch
{
public static void Postfix(ref System.Collections.Generic.List<GameObject> __result)
{
if (IsMining && __result != null)
{
var extraDrops = new System.Collections.Generic.List<GameObject>();
foreach (var go in __result)
{
if (go == null) continue;
string lower = go.name.ToLower();
if (lower.Contains("copperore") || lower.Contains("tinore") || lower.Contains("ironscrap") || lower.Contains("silverore") || lower.Contains("blackmetalscrap") || lower.Contains("flametalore"))
{
extraDrops.Add(go);
}
}
__result.AddRange(extraDrops);
}
}
}
// ── "In the Mist He/She Was Standing" (The Queen, state >= 7) ─────────
// Eitr foods (blue foods) have double digestion time.
// We halve the rate at which food m_time decrements for eitr foods.
[HarmonyPatch(typeof(Player), "UpdateFood")]
public static class Furling_UpdateFood_EitrDuration_Patch
{
// Prefix: halve dt for eitr foods by doubling the denominator via a custom flag
// Easiest approach: Postfix after the vanilla update, then undo half the time consumed.
public static void Postfix(Player __instance, float dt)
{
if (__instance != Player.m_localPlayer) return;
if (!FurlingRace.IsFurling()) return;
if (BossProgressionManager.GetCurrentProgressionState() < 7) return;
// Valheim decrements food.m_time by dt each call.
// We give back half of dt for eitr foods, effectively halving consumption.
var foods = HarmonyLib.Traverse.Create(__instance).Field<System.Collections.Generic.List<Player.Food>>("m_foods").Value;
if (foods == null) return;
foreach (var food in foods)
{
if (food == null || food.m_item == null) continue;
// Blue food = eitr > 0
if (food.m_item.m_shared.m_foodEitr > 0f)
{
// Give back half of dt that vanilla subtracted
food.m_time += dt * 0.5f;
// Clamp to max burn time so we don't exceed the original duration
float maxTime = food.m_item.m_shared.m_foodBurnTime;
if (food.m_time > maxTime) food.m_time = maxTime;
}
}
}
}
}
}

View file

@ -0,0 +1,16 @@
using System;
namespace RacesOfValheim
{
public static class FurlingProgression
{
public static void UpdateProgression()
{
if (!FurlingRace.IsFurling()) return;
int state = BossProgressionManager.GetCurrentProgressionState();
// Progression logic based on defeated bosses
}
}
}

View file

@ -0,0 +1,44 @@
using BepInEx;
using HarmonyLib;
using UnityEngine;
using System.Collections.Generic;
namespace RacesOfValheim
{
public class FurlingRace : MonoBehaviour
{
private static FurlingRace _instance;
public static FurlingRace Instance
{
get
{
if (_instance == null)
{
GameObject go = new GameObject("FurlingRace");
_instance = go.AddComponent<FurlingRace>();
DontDestroyOnLoad(go);
}
return _instance;
}
}
public static bool IsFurling()
{
return Player.m_localPlayer != null && Player.m_localPlayer.GetPlayerModel() == 5; // Assumed ID for Furling
}
public void CreateModAssets()
{
Jotunn.Logger.LogInfo("Initializing Furling Race...");
FurlingStatusEffects.RegisterStatusEffects();
}
private void Update()
{
if (!IsFurling()) return;
// Through Fire and Flames (Fader)
FurlingFireAbility.Tick();
}
}
}

View file

@ -0,0 +1,14 @@
using Jotunn.Managers;
using Jotunn.Entities;
using UnityEngine;
namespace RacesOfValheim
{
public static class FurlingStatusEffects
{
public static void RegisterStatusEffects()
{
// Register custom status effects for Furling
}
}
}