Merge pull request 'start draugh race' (#1) from fix-skeleton-race into main
Reviewed-on: #1
This commit is contained in:
commit
4928eb6ae7
7 changed files with 522 additions and 16 deletions
|
|
@ -469,7 +469,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
public static bool Prefix(Hud __instance, Player player)
|
||||
{
|
||||
if (player == Player.m_localPlayer && AswidRace.IsAswid())
|
||||
if (player == Player.m_localPlayer && (AswidRace.IsAswid() || DraughRace.IsDraugh()))
|
||||
{
|
||||
if (__instance.m_staminaBar2Root != null && __instance.m_staminaBar2Root.gameObject.activeSelf)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ namespace RacesOfValheim
|
|||
{ "Tick", "TrophyTick" },
|
||||
{ "Ulv", "TrophyUlv" },
|
||||
{ "Cultist", "TrophyCultist" },
|
||||
{ "Bat", "TrophyBat" },
|
||||
{ "Asksvin", "TrophyAsksvin" },
|
||||
{ "Volture", "TrophyVolture" }
|
||||
};
|
||||
|
|
@ -50,7 +49,10 @@ namespace RacesOfValheim
|
|||
{ "Hare", "CookedHareMeat" },
|
||||
{ "Asksvin", "CookedAsksvinMeat" },
|
||||
{ "Volture", "CookedVoltureMeat" },
|
||||
{ "Tick", "Bloodbag" }, // Fallback to Bloodbag if BloodClot doesn't exist
|
||||
{ "Tick", "BloodPudding" },
|
||||
{ "Deathsquito", "BloodPudding" },
|
||||
{ "Leech", "BloodPudding" },
|
||||
{ "Ulv", "BloodPudding" },
|
||||
{ "Seeker", "CookedBugMeat" },
|
||||
{ "SeekerBrute", "CookedBugMeat" },
|
||||
{ "SeekerBrood", "CookedBugMeat" }
|
||||
|
|
|
|||
180
JotunnModStub/Draugh/DraughFoodPatches.cs
Normal file
180
JotunnModStub/Draugh/DraughFoodPatches.cs
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
using HarmonyLib;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Jotunn.Entities;
|
||||
using Jotunn.Managers;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
[HarmonyPatch]
|
||||
public static class DraughFoodPatches
|
||||
{
|
||||
private static List<object> hiddenFoods = new List<object>();
|
||||
|
||||
// Mapping from raw prefab/item name to the cooked prefab name
|
||||
public static readonly Dictionary<string, string> rawToCookedMapping = new Dictionary<string, string>
|
||||
{
|
||||
{ "RawMeat", "CookedMeat" },
|
||||
{ "NeckTail", "NeckTailGrilled" },
|
||||
{ "FishRaw", "FishCooked" },
|
||||
{ "LoxMeat", "CookedLoxMeat" },
|
||||
{ "SerpentMeatRaw", "SerpentMeatCooked" },
|
||||
{ "WolfMeat", "CookedWolfMeat" },
|
||||
{ "DeerMeat", "CookedDeerMeat" },
|
||||
{ "HareMeat", "CookedHareMeat" },
|
||||
{ "ChickenMeat", "CookedChickenMeat" },
|
||||
{ "BugMeat", "CookedBugMeat" },
|
||||
{ "VoltureMeat", "RoastedVoltureMeat" },
|
||||
{ "GreydwarfEye", "DeerStew" },
|
||||
{ "Entrails", "Sausages" },
|
||||
{ "Bloodbag", "BloodPudding" }
|
||||
};
|
||||
|
||||
[HarmonyPatch(typeof(Humanoid), "UseItem")]
|
||||
[HarmonyPrefix]
|
||||
public static bool UseItem_Prefix(Humanoid __instance, Inventory inventory, ItemDrop.ItemData item, bool fromInventoryGui)
|
||||
{
|
||||
Player player = __instance as Player;
|
||||
if (player == null || player != Player.m_localPlayer || !DraughRace.IsDraugh() || item == null || item.m_shared == null) return true;
|
||||
|
||||
// Intercept right click on raw items.
|
||||
// In UseItem, if it's a Consumable, Valheim will process it. If it's our EdibleUncooked_, it's a Consumable!
|
||||
if (item.m_shared.m_name.StartsWith("$item_edibleuncooked_") || item.m_dropPrefab?.name.StartsWith("EdibleUncooked_") == true)
|
||||
{
|
||||
return true; // Let native EatFood process our custom item
|
||||
}
|
||||
|
||||
string prefabName = item.m_dropPrefab != null ? item.m_dropPrefab.name : "";
|
||||
string cleanName = prefabName;
|
||||
if (string.IsNullOrEmpty(cleanName)) cleanName = item.m_shared.m_name.Replace("$item_", "");
|
||||
|
||||
// Is it one of the raw items in our mapping?
|
||||
if (rawToCookedMapping.ContainsKey(cleanName))
|
||||
{
|
||||
// We want to seamlessly swap it with EdibleUncooked_<cleanName>
|
||||
string customPrefabName = "EdibleUncooked_" + cleanName;
|
||||
GameObject customPrefab = ObjectDB.instance.GetItemPrefab(customPrefabName);
|
||||
if (customPrefab != null)
|
||||
{
|
||||
ItemDrop customItemDrop = customPrefab.GetComponent<ItemDrop>();
|
||||
if (customItemDrop != null)
|
||||
{
|
||||
// Check if we can eat it (duplicate check bypass logic handled inside EatFood)
|
||||
bool ate = player.EatFood(customItemDrop.m_itemData);
|
||||
if (ate)
|
||||
{
|
||||
inventory.RemoveItem(item, 1);
|
||||
}
|
||||
return false; // Skip native UseItem
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Jotunn.Logger.LogWarning($"[DraughFood] Could not find custom prefab: {customPrefabName}");
|
||||
}
|
||||
}
|
||||
|
||||
// If it's a normal consumable (like standard cooked food or berries), we should block it!
|
||||
if (item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Consumable)
|
||||
{
|
||||
bool isFood = item.m_shared.m_food > 0 || item.m_shared.m_foodStamina > 0 || item.m_shared.m_foodEitr > 0;
|
||||
if (isFood)
|
||||
{
|
||||
player.Message(MessageHud.MessageType.Center, "Draugr consume only raw flesh, eyes, entrails or blood.");
|
||||
return false; // Block it
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), "EatFood")]
|
||||
[HarmonyPrefix]
|
||||
public static bool EatFood_Prefix(Player __instance, ItemDrop.ItemData item, ref bool __result)
|
||||
{
|
||||
hiddenFoods.Clear();
|
||||
|
||||
if (__instance != Player.m_localPlayer || !DraughRace.IsDraugh()) return true;
|
||||
if (item == null || item.m_shared == null) return true;
|
||||
|
||||
// Handle the bypass logic (duplicate food) ONLY for our custom uncooked foods
|
||||
string prefabName = item.m_dropPrefab != null ? item.m_dropPrefab.name : "";
|
||||
if (prefabName.StartsWith("EdibleUncooked_"))
|
||||
{
|
||||
var m_foods = Traverse.Create(__instance).Field("m_foods").GetValue<System.Collections.IList>();
|
||||
if (m_foods != null)
|
||||
{
|
||||
if (m_foods.Count >= 3)
|
||||
{
|
||||
// Check if we can refresh an existing identical food (if time is low)
|
||||
bool refreshed = false;
|
||||
foreach (object foodObj in m_foods)
|
||||
{
|
||||
Player.Food f = foodObj as Player.Food;
|
||||
if (f != null && f.m_item.m_shared.m_name == item.m_shared.m_name && f.CanEatAgain())
|
||||
{
|
||||
f.m_time = 0f;
|
||||
f.m_item = item.Clone();
|
||||
|
||||
var consumeEffects = Traverse.Create(__instance).Field("m_consumeItemEffects").GetValue<EffectList>();
|
||||
if (consumeEffects != null) consumeEffects.Create(__instance.transform.position, Quaternion.identity, __instance.transform, 1f, -1);
|
||||
|
||||
var zanim = Traverse.Create(__instance).Field("m_zanim").GetValue<ZSyncAnimation>();
|
||||
if (zanim != null) zanim.SetTrigger("eat");
|
||||
|
||||
if (item.m_shared.m_food > 0f) __instance.Heal(item.m_shared.m_food, true);
|
||||
|
||||
refreshed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (refreshed)
|
||||
{
|
||||
__result = true;
|
||||
return false; // Skip native EatFood
|
||||
}
|
||||
|
||||
// Inventory full
|
||||
__result = false;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Temporarily hide duplicates to force Valheim to add a new slot
|
||||
for (int i = m_foods.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var foodObj = m_foods[i];
|
||||
var foodItem = Traverse.Create(foodObj).Field("m_item").GetValue<ItemDrop.ItemData>();
|
||||
if (foodItem != null && foodItem.m_shared.m_name == item.m_shared.m_name)
|
||||
{
|
||||
hiddenFoods.Add(foodObj);
|
||||
m_foods.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), "EatFood")]
|
||||
[HarmonyPostfix]
|
||||
public static void EatFood_Postfix(Player __instance, ItemDrop.ItemData item, ref bool __result)
|
||||
{
|
||||
if (hiddenFoods.Count > 0)
|
||||
{
|
||||
var m_foods = Traverse.Create(__instance).Field("m_foods").GetValue<System.Collections.IList>();
|
||||
if (m_foods != null)
|
||||
{
|
||||
foreach (var h in hiddenFoods)
|
||||
{
|
||||
m_foods.Add(h);
|
||||
}
|
||||
}
|
||||
hiddenFoods.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
119
JotunnModStub/Draugh/DraughPatches.cs
Normal file
119
JotunnModStub/Draugh/DraughPatches.cs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
[HarmonyPatch(typeof(VisEquipment), "UpdateColors")]
|
||||
public static class DraughSkinColorPatch
|
||||
{
|
||||
public static void Postfix(VisEquipment __instance)
|
||||
{
|
||||
if (!__instance.m_isPlayer) return;
|
||||
Player player = __instance.GetComponent<Player>();
|
||||
if (player == null) return;
|
||||
|
||||
string race = "Human";
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid())
|
||||
race = nview.GetZDO().GetString("RacesOfValheim_Race", "Human");
|
||||
else if (player.m_customData != null && player.m_customData.TryGetValue("Race", out string savedRace))
|
||||
race = savedRace;
|
||||
|
||||
if (race != "Draugh") return;
|
||||
|
||||
if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null)
|
||||
{
|
||||
// Sickly grayish-green undead skin color (corpse green)
|
||||
Color draughColor = new Color(0.25f, 0.4f, 0.28f, 1f);
|
||||
__instance.m_bodyModel.material.SetColor("_SkinColor", draughColor);
|
||||
}
|
||||
|
||||
// Desaturate and darken hair and beard
|
||||
Vector3 origHairVec = Traverse.Create(__instance).Field("m_hairColor").GetValue<Vector3>();
|
||||
Color origHair = new Color(origHairVec.x, origHairVec.y, origHairVec.z);
|
||||
float l = 0.299f * origHair.r + 0.587f * origHair.g + 0.114f * origHair.b;
|
||||
Color desatHair = Color.Lerp(origHair, new Color(l, l, l), 0.75f) * 0.7f; // 75% desaturated, 30% darker
|
||||
desatHair.a = 1f;
|
||||
|
||||
var hairObj = Traverse.Create(__instance).Field("m_hairItemInstance").GetValue<GameObject>();
|
||||
if (hairObj != null)
|
||||
{
|
||||
foreach (var r in hairObj.GetComponentsInChildren<Renderer>())
|
||||
if (r.material != null && r.material.HasProperty("_SkinColor")) r.material.SetColor("_SkinColor", desatHair);
|
||||
}
|
||||
var hairList = Traverse.Create(__instance).Field("m_hairItemInstances").GetValue<System.Collections.Generic.List<GameObject>>();
|
||||
if (hairList != null)
|
||||
{
|
||||
foreach (var h in hairList)
|
||||
if (h != null)
|
||||
foreach (var r in h.GetComponentsInChildren<Renderer>())
|
||||
if (r.material != null && r.material.HasProperty("_SkinColor")) r.material.SetColor("_SkinColor", desatHair);
|
||||
}
|
||||
|
||||
var beardObj = Traverse.Create(__instance).Field("m_beardItemInstance").GetValue<GameObject>();
|
||||
if (beardObj != null)
|
||||
{
|
||||
foreach (var r in beardObj.GetComponentsInChildren<Renderer>())
|
||||
if (r.material != null && r.material.HasProperty("_SkinColor")) r.material.SetColor("_SkinColor", desatHair);
|
||||
}
|
||||
var beardList = Traverse.Create(__instance).Field("m_beardItemInstances").GetValue<System.Collections.Generic.List<GameObject>>();
|
||||
if (beardList != null)
|
||||
{
|
||||
foreach (var b in beardList)
|
||||
if (b != null)
|
||||
foreach (var r in b.GetComponentsInChildren<Renderer>())
|
||||
if (r.material != null && r.material.HasProperty("_SkinColor")) r.material.SetColor("_SkinColor", desatHair);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")]
|
||||
public static class Draugh_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");
|
||||
|
||||
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 != "Draugh") return;
|
||||
|
||||
// Future model swaps (e.g. Draugr head) or hiding items can go here
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Character), "Damage")]
|
||||
public static class Draugh_Damage_Patch
|
||||
{
|
||||
public static void Prefix(Character __instance, HitData hit)
|
||||
{
|
||||
if (hit == null || __instance == null || !__instance.IsPlayer()) return;
|
||||
if (__instance != Player.m_localPlayer) return;
|
||||
|
||||
if (!DraughRace.IsDraugh()) return;
|
||||
|
||||
// Apply specific damage modifiers for Draugh
|
||||
// -20% damage received from slash, pierce, blunt
|
||||
hit.m_damage.m_blunt *= 0.8f;
|
||||
hit.m_damage.m_slash *= 0.8f;
|
||||
hit.m_damage.m_pierce *= 0.8f;
|
||||
|
||||
// +50% damage received from fire, spirit
|
||||
hit.m_damage.m_fire *= 1.5f;
|
||||
hit.m_damage.m_spirit *= 1.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
162
JotunnModStub/Draugh/DraughRace.cs
Normal file
162
JotunnModStub/Draugh/DraughRace.cs
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
public class DraughRace : MonoBehaviour
|
||||
{
|
||||
public static DraughRace Instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void CreateModAssets()
|
||||
{
|
||||
// Generate EdibleUncooked prefabs for Draugh raw food logic
|
||||
foreach (var mapping in DraughFoodPatches.rawToCookedMapping)
|
||||
{
|
||||
string rawPrefabName = mapping.Key;
|
||||
string cookedPrefabName = mapping.Value;
|
||||
|
||||
GameObject rawPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(rawPrefabName);
|
||||
GameObject cookedPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(cookedPrefabName);
|
||||
|
||||
if (rawPrefab != null && cookedPrefab != null)
|
||||
{
|
||||
ItemDrop rawDrop = rawPrefab.GetComponent<ItemDrop>();
|
||||
ItemDrop cookedDrop = cookedPrefab.GetComponent<ItemDrop>();
|
||||
|
||||
if (rawDrop != null && cookedDrop != null)
|
||||
{
|
||||
string customName = "EdibleUncooked_" + rawPrefabName;
|
||||
Jotunn.Entities.CustomItem customItem = new Jotunn.Entities.CustomItem(customName, cookedPrefabName);
|
||||
|
||||
ItemDrop customDrop = customItem.ItemDrop;
|
||||
customDrop.m_itemData.m_shared.m_name = rawDrop.m_itemData.m_shared.m_name;
|
||||
customDrop.m_itemData.m_shared.m_description = rawDrop.m_itemData.m_shared.m_description;
|
||||
customDrop.m_itemData.m_shared.m_icons = rawDrop.m_itemData.m_shared.m_icons;
|
||||
customDrop.m_itemData.m_shared.m_foodBurnTime *= 1.5f;
|
||||
|
||||
Jotunn.Managers.ItemManager.Instance.AddItem(customItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsDraugh()
|
||||
{
|
||||
return Player.m_localPlayer != null &&
|
||||
Player.m_localPlayer.m_customData.ContainsKey("Race") &&
|
||||
Player.m_localPlayer.m_customData["Race"] == "Draugh";
|
||||
}
|
||||
|
||||
private GameObject draughVFX = null;
|
||||
private float foodCheckTimer = 0f;
|
||||
private int lastProgressionState = -1;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Player.m_localPlayer == null) return;
|
||||
|
||||
if (IsDraugh() && !Player.m_localPlayer.IsDead())
|
||||
{
|
||||
EnsureVFX(true);
|
||||
|
||||
foodCheckTimer += Time.deltaTime;
|
||||
if (foodCheckTimer >= 2f)
|
||||
{
|
||||
foodCheckTimer = 0f;
|
||||
int currentState = BossProgressionManager.GetCurrentProgressionState();
|
||||
if (currentState != lastProgressionState)
|
||||
{
|
||||
lastProgressionState = currentState;
|
||||
UpdateFoodEitr(currentState >= 6); // 6 = Yagluth Defeated
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EnsureVFX(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFoodEitr(bool enableEitr)
|
||||
{
|
||||
if (ObjectDB.instance == null) return;
|
||||
|
||||
foreach (var mapping in DraughFoodPatches.rawToCookedMapping)
|
||||
{
|
||||
string customPrefabName = "EdibleUncooked_" + mapping.Key;
|
||||
GameObject customPrefab = ObjectDB.instance.GetItemPrefab(customPrefabName);
|
||||
if (customPrefab != null)
|
||||
{
|
||||
ItemDrop drop = customPrefab.GetComponent<ItemDrop>();
|
||||
if (drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null)
|
||||
{
|
||||
if (enableEitr)
|
||||
{
|
||||
drop.m_itemData.m_shared.m_foodEitr = drop.m_itemData.m_shared.m_food / 2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
drop.m_itemData.m_shared.m_foodEitr = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureVFX(bool enable)
|
||||
{
|
||||
if (enable && Player.m_localPlayer != null)
|
||||
{
|
||||
if (draughVFX == null)
|
||||
{
|
||||
GameObject draugrPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>("Draugr");
|
||||
if (draugrPrefab != null)
|
||||
{
|
||||
draughVFX = new GameObject("DraughAuraVFX");
|
||||
draughVFX.transform.SetParent(Player.m_localPlayer.transform, false);
|
||||
draughVFX.transform.localPosition = new Vector3(0, 1f, 0);
|
||||
|
||||
// Find all ParticleSystems in Draugr prefab
|
||||
ParticleSystem[] pss = draugrPrefab.GetComponentsInChildren<ParticleSystem>(true);
|
||||
foreach (ParticleSystem ps in pss)
|
||||
{
|
||||
// We only want looping ambient effects (flies, smoke)
|
||||
if (ps.main.loop)
|
||||
{
|
||||
GameObject psCopy = Instantiate(ps.gameObject, draughVFX.transform);
|
||||
psCopy.name = ps.gameObject.name;
|
||||
psCopy.SetActive(true);
|
||||
|
||||
// Ensure it's positioned correctly
|
||||
psCopy.transform.localPosition = ps.transform.localPosition;
|
||||
psCopy.transform.localRotation = ps.transform.localRotation;
|
||||
|
||||
// Make the green smoke 50% larger. We exclude "flies" in case they are separate.
|
||||
if (!psCopy.name.ToLower().Contains("flies"))
|
||||
{
|
||||
psCopy.transform.localScale = ps.transform.localScale * 1.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (draughVFX != null && !draughVFX.activeSelf)
|
||||
{
|
||||
draughVFX.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (draughVFX != null && draughVFX.activeSelf)
|
||||
{
|
||||
draughVFX.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -31,6 +31,7 @@ namespace RacesOfValheim
|
|||
gameObject.AddComponent<AswidRace>();
|
||||
gameObject.AddComponent<FurlingRace>();
|
||||
gameObject.AddComponent<TrolRace>();
|
||||
gameObject.AddComponent<DraughRace>();
|
||||
PrefabManager.OnVanillaPrefabsAvailable += CreateAllModAssets;
|
||||
CommandManager.Instance.AddConsoleCommand(new ResetRaceCommand());
|
||||
CommandManager.Instance.AddConsoleCommand(new CheckProgressionCommand());
|
||||
|
|
@ -46,6 +47,7 @@ namespace RacesOfValheim
|
|||
AswidRace.Instance.CreateModAssets();
|
||||
FurlingRace.Instance.CreateModAssets();
|
||||
TrolRace.Instance.CreateModAssets();
|
||||
DraughRace.Instance.CreateModAssets();
|
||||
}
|
||||
// --- RACE SELECTION UI ---
|
||||
public void ShowRaceSelectionMenu()
|
||||
|
|
@ -175,17 +177,16 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
// Row 1 (y = 100)
|
||||
CreateRaceButtonWithConfirm("Human", new Vector2(-300, 100), GetHumanIcon(), "The versatile founders of Midgard. Balanced stats with no specific weaknesses.", SelectHuman);
|
||||
CreateRaceButtonWithConfirm("Fenrir", new Vector2(0, 100), GetFenrirIcon(), "Cursed by the blood of the wolf. Fast and deadly, but vulnerable to silver.", SelectFenrir);
|
||||
CreateRaceButtonWithConfirm("Skadi", new Vector2(300, 100), GetSkadiIcon(), "Children of the mountains. Resistant to frost, at home in the freezing cold.", SelectSkadi);
|
||||
CreateRaceButtonWithConfirm("Human", new Vector2(-450, 100), GetHumanIcon(), "The versatile founders of Midgard. Balanced stats with no specific weaknesses.", SelectHuman);
|
||||
CreateRaceButtonWithConfirm("Fenrir", new Vector2(-150, 100), GetFenrirIcon(), "Cursed by the blood of the wolf. Fast and deadly, but vulnerable to silver.", SelectFenrir);
|
||||
CreateRaceButtonWithConfirm("Skadi", new Vector2(150, 100), GetSkadiIcon(), "Children of the mountains. Resistant to frost, at home in the freezing cold.", SelectSkadi);
|
||||
CreateRaceButtonWithConfirm("Skeleton", new Vector2(450, 100), GetSkeletonIcon(), "Undead warriors. Immune to poison, but brittle against blunt trauma.", SelectSkeleton);
|
||||
|
||||
// Row 2 (y = 0)
|
||||
CreateRaceButtonWithConfirm("Skeleton", new Vector2(-300, 0), GetSkeletonIcon(), "Undead warriors. Immune to poison, but brittle against blunt trauma.", SelectSkeleton);
|
||||
CreateRaceButtonWithConfirm("Aswid", new Vector2(0, 0), GetAswidIcon(), "Fierce night stalker. Strong and resilient, transforms into a bat.", SelectAswid);
|
||||
CreateRaceButtonWithConfirm("Furling", new Vector2(300, 0), GetFurlingIcon(), "Cunning goblin-like creatures. Agile and resourceful.", SelectFurling);
|
||||
|
||||
// Row 3 (y = -100)
|
||||
CreateRaceButtonWithConfirm("Trol", new Vector2(0, -100), GetTrolIcon(), "Massive brute strength. Towering over others but slow to react.", SelectTrol);
|
||||
// Row 2 (y = -20)
|
||||
CreateRaceButtonWithConfirm("Aswid", new Vector2(-450, -20), GetAswidIcon(), "Fierce night stalker. Strong and resilient, transforms into a bat.", SelectAswid);
|
||||
CreateRaceButtonWithConfirm("Furling", new Vector2(-150, -20), GetFurlingIcon(), "Cunning goblin-like creatures. Agile and resourceful.", SelectFurling);
|
||||
CreateRaceButtonWithConfirm("Trol", new Vector2(150, -20), GetTrolIcon(), "Massive brute strength. Towering over others but slow to react.", SelectTrol);
|
||||
CreateRaceButtonWithConfirm("Draugh", new Vector2(450, -20), GetDraughIcon(), "Undead warriors of the swamps. Accustomed to damp and decay.", SelectDraugh);
|
||||
|
||||
GUIManager.BlockInput(true);
|
||||
}
|
||||
|
|
@ -487,6 +488,48 @@ namespace RacesOfValheim
|
|||
return null;
|
||||
}
|
||||
|
||||
private void SelectDraugh()
|
||||
{
|
||||
if (Player.m_localPlayer != null)
|
||||
{
|
||||
Player.m_localPlayer.m_customData["Race"] = "Draugh";
|
||||
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Draugh");
|
||||
|
||||
VisEquipment visEq = Player.m_localPlayer.GetComponent<VisEquipment>();
|
||||
if (visEq != null)
|
||||
{
|
||||
if (!Player.m_localPlayer.m_customData.ContainsKey("OriginalSkinColor_X"))
|
||||
{
|
||||
Vector3 currentSkinColor = Traverse.Create(visEq).Field("m_skinColor").GetValue<Vector3>();
|
||||
Player.m_localPlayer.m_customData["OriginalSkinColor_X"] = currentSkinColor.x.ToString();
|
||||
Player.m_localPlayer.m_customData["OriginalSkinColor_Y"] = currentSkinColor.y.ToString();
|
||||
Player.m_localPlayer.m_customData["OriginalSkinColor_Z"] = currentSkinColor.z.ToString();
|
||||
}
|
||||
|
||||
Traverse.Create(visEq).Method("SetSkinColor", new Vector3(0.25f, 0.4f, 0.28f)).GetValue();
|
||||
visEq.GetType().GetMethod("UpdateColors", 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 Draugh.");
|
||||
CloseRaceSelectionMenu();
|
||||
}
|
||||
}
|
||||
|
||||
private Sprite GetDraughIcon()
|
||||
{
|
||||
GameObject trophyPrefab = PrefabManager.Cache.GetPrefab<ItemDrop>("TrophyDraugr")?.gameObject;
|
||||
if (trophyPrefab != null)
|
||||
{
|
||||
ItemDrop trophyDrop = trophyPrefab.GetComponent<ItemDrop>();
|
||||
if (trophyDrop != null && trophyDrop.m_itemData.m_shared.m_icons.Length > 0)
|
||||
{
|
||||
return trophyDrop.m_itemData.m_shared.m_icons[0];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void CloseRaceSelectionMenu()
|
||||
{
|
||||
if (raceSelectionMenu != null)
|
||||
|
|
@ -549,8 +592,8 @@ namespace RacesOfValheim
|
|||
__instance.GetSEMan().AddStatusEffect("SE_FenrirCurse".GetStableHashCode(), true);
|
||||
}
|
||||
|
||||
// If Skadi, Aswid, Furling or Trol, re-trigger visual update to set skin color
|
||||
if (__instance.m_customData.ContainsKey("Race") && (__instance.m_customData["Race"] == "Skadi" || __instance.m_customData["Race"] == "Aswid" || __instance.m_customData["Race"] == "Furling" || __instance.m_customData["Race"] == "Trol"))
|
||||
// If Skadi, Aswid, Furling, Trol or Draugh, re-trigger visual update to set skin color
|
||||
if (__instance.m_customData.ContainsKey("Race") && (__instance.m_customData["Race"] == "Skadi" || __instance.m_customData["Race"] == "Aswid" || __instance.m_customData["Race"] == "Furling" || __instance.m_customData["Race"] == "Trol" || __instance.m_customData["Race"] == "Draugh"))
|
||||
{
|
||||
VisEquipment visEq = __instance.GetComponent<VisEquipment>();
|
||||
if (visEq != null) visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
public static bool Prefix(Player __instance)
|
||||
{
|
||||
if ((SkeletonRace.IsSkeleton() || AswidRace.IsAswid()) && __instance == Player.m_localPlayer)
|
||||
if ((SkeletonRace.IsSkeleton() || AswidRace.IsAswid() || DraughRace.IsDraugh()) && __instance == Player.m_localPlayer)
|
||||
{
|
||||
// Infinite stamina: skip the original UseStamina method
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue