From 7a19c66a2484d194f35510225b71bcd11f29629d Mon Sep 17 00:00:00 2001 From: mikx Date: Sun, 22 Mar 2026 15:40:17 -0400 Subject: [PATCH] (1.6.14) EventSystem Added Reagent to reward --- MxValheim/EventSystem/Patch.cs | 1 + MxValheim/EventSystem/Reward.cs | 25 +++++++++++++++++++++++++ MxValheim/MxValheim.cs | 19 ++++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/MxValheim/EventSystem/Patch.cs b/MxValheim/EventSystem/Patch.cs index 00520b6..421e347 100644 --- a/MxValheim/EventSystem/Patch.cs +++ b/MxValheim/EventSystem/Patch.cs @@ -122,6 +122,7 @@ namespace MxValheim.EventSystem Reward.GiveEpicLootDust(); Reward.GiveEpicLootShard(); Reward.GiveEpicLootEssence(); + Reward.GiveEpicLootReagent(); Reward.GiveEpicLootRune(); } } diff --git a/MxValheim/EventSystem/Reward.cs b/MxValheim/EventSystem/Reward.cs index 0d854a6..a63d19d 100644 --- a/MxValheim/EventSystem/Reward.cs +++ b/MxValheim/EventSystem/Reward.cs @@ -130,6 +130,30 @@ namespace MxValheim.EventSystem } } + public static void GiveEpicLootReagent() + { + System.Random rand = new System.Random(); + + int qty = rand.Next(1, Profiles.serverLevel); + + string[] rarity = GetRarityList(Watcher.eventPoints); + + string itemName = $"Reagent{globalRarity}"; + + Player player = Player.m_localPlayer; + if (player == null) return; + + GameObject prefab = ObjectDB.instance.GetItemPrefab(itemName); + if (prefab != null) + { + GiveItemSafe(itemName, player, qty); + } + else + { + Debug.LogWarning($"Item {itemName} not found in ObjectDB!"); + } + } + public static void GiveEpicLootRune() { System.Random rand = new System.Random(); @@ -289,6 +313,7 @@ namespace MxValheim.EventSystem { "Ghost", 100 }, { "Skeleton", 60 }, { "Skeleton_NoArcher", 60 }, // Melee only variant + { "Skeleton_Poison", 60 }, // --- Swamp --- { "Blob", 50 }, diff --git a/MxValheim/MxValheim.cs b/MxValheim/MxValheim.cs index 2ca75a0..23041f2 100644 --- a/MxValheim/MxValheim.cs +++ b/MxValheim/MxValheim.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using System.Text; using System.Threading; using System.Xml; using TMPro; @@ -33,7 +34,7 @@ public class MxValheimMod : BaseUnityPlugin private const string ModGUID = "ovh.mxdev.mxvalheim"; private const string ModName = "MxValheim"; - private const string ModVersion = "1.6.13"; + private const string ModVersion = "1.6.14"; public static ConfigEntry Config_DebugRandomEventInterval; public static ConfigEntry Config_bowDrawSpeedBonusPerLevel; @@ -44,6 +45,10 @@ public class MxValheimMod : BaseUnityPlugin public static string internalDataEventSystem = Path.Combine(internalDataPath, "EventSystem.json"); public static string DropConfigPath => Path.Combine(internalConfigsPath, "items_drop.json"); public static string WeightConfigPath => Path.Combine(internalConfigsPath, "items_weight.json"); + public static string EnemyExpConfigPath => Path.Combine(internalConfigsPath, "enemies_expvalue.mx"); + public static Dictionary EnemyExpSettings = new Dictionary(); + public static string EnemyRewardConfigPath => Path.Combine(internalConfigsPath, "enemies_rewardvalue.mx"); + public static Dictionary EnemyRewardSettings = new Dictionary(); public static string AutoDoorConfigPath => Path.Combine(internalConfigsPath, "auto_doors.json"); public static DoorRoot CachedConfig; public static Dictionary WeightSettings = new Dictionary(); @@ -376,9 +381,21 @@ public class MxValheimMod : BaseUnityPlugin File.WriteAllText(DropConfigPath, JsonConvert.SerializeObject(DropSettings, Newtonsoft.Json.Formatting.Indented)); } + byte[] jsonEncryptedB64 = null; + json = File.ReadAllText(DropConfigPath); DropSettings = JsonConvert.DeserializeObject>(json); Logger.LogInfo($"Successfully parsed {DropSettings.Count} items."); + + /*jsonEncryptedB64 = Convert.FromBase64String(File.ReadAllText(EnemyRewardConfigPath)); + json = Encoding.UTF8.GetString(jsonEncryptedB64); + EnemyRewardSettings = JsonConvert.DeserializeObject>(json); + Logger.LogInfo($"Successfully parsed {EnemyRewardSettings.Count} enemy reward value."); + + jsonEncryptedB64 = Convert.FromBase64String(File.ReadAllText(EnemyExpConfigPath)); + json = Encoding.UTF8.GetString(jsonEncryptedB64); + EnemyExpSettings = JsonConvert.DeserializeObject>(json); + Logger.LogInfo($"Successfully parsed {EnemyExpSettings.Count} enemy exp value.");*/ } public void LoadDoorConfig()