using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Shopkeep")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Shopkeep")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("0b261f31-75b2-4405-b7ec-25e6fade4c16")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace Shopkeep; public class BercansDestroy : MonoBehaviour { private void OnDestroy() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown foreach (Transform item in ((Component)this).transform) { Transform val = item; if (((Object)((Component)val).gameObject).name.Contains("Haldor")) { Object.Destroy((Object)(object)((Component)val).gameObject); } } } } [BepInPlugin("com.yourname.shopkeep", "Shopkeep", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Shopkeep : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("com.yourname.shopkeep"); private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Shopkeep mod loaded!"); harmony.PatchAll(); PrefabManager.OnVanillaPrefabsAvailable += RegisterNPC; } private void RegisterNPC() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registering Shopkeep NPC..."); ShopkeepNPC.Register(); PrefabManager.OnVanillaPrefabsAvailable -= RegisterNPC; } } public class ItemEffects { private const string VitalityKey = "Shopkeep_Vitality"; private const string EnduranceKey = "Shopkeep_Endurance"; private const string BurdenKey = "Shopkeep_Burden"; private const int MaxScrollUses = 3; public static void ApplyMysteryBox(Player player) { List<(string, int, float)> list = new List<(string, int, float)> { ("Wood", 50, 30f), ("FineWood", 20, 20f), ("Coins", 500, 25f), ("Copper", 10, 15f), ("Tin", 10, 15f), ("Bronze", 10, 12f), ("Iron", 10, 12f), ("Silver", 10, 10f), ("BlackMetal", 10, 8f), ("Flametal", 5, 4f), ("Chitin", 15, 15f), ("Crystal", 10, 10f), ("Ruby", 5, 8f), ("FreezeGland", 10, 10f), ("Blueberries", 20, 20f), ("SerpentStew", 3, 10f), ("BloodPudding", 3, 10f), ("LoxPie", 3, 8f), ("CookedMeat", 10, 15f), ("CarrotSeeds", 10, 15f), ("TurnipSeeds", 10, 15f), ("OnionSeeds", 10, 12f), ("BarleySeed", 10, 10f), ("FlaxSeed", 10, 10f), ("MeadHealthMedium", 3, 10f), ("MeadStaminaMedium", 3, 10f), ("MeadPoisonResist", 2, 8f), ("AxeIron", 1, 3f), ("AxeBlackMetal", 1, 2f), ("BattleaxeBlackmetal", 1, 1f), ("PickaxeBronze", 1, 3f), ("PickaxeIron", 1, 2f), ("SwordBronze", 1, 3f), ("SwordIron", 1, 2f), ("SwordBlackmetal", 1, 1f), ("SwordMistwalker", 1, 0.5f), ("BowFineWood", 1, 3f), ("BowHuntsman", 1, 2f), ("BowDraugrFang", 1, 1f), ("APPLY_VITALITY", 1, 2f), ("APPLY_ENDURANCE", 1, 2f), ("APPLY_BURDEN", 1, 2f) }; float num = 0f; foreach (var item in list) { num += item.Item3; } float num2 = Random.Range(0f, num); float num3 = 0f; foreach (var item2 in list) { num3 += item2.Item3; if (num2 <= num3) { if (item2.Item1 == "APPLY_VITALITY") { ApplyScrollOfVitality(player); MessageHud.instance.ShowMessage((MessageType)2, "Mystery Box: You found a Scroll of Vitality!", 0, (Sprite)null, false); } else if (item2.Item1 == "APPLY_ENDURANCE") { ApplyScrollOfEndurance(player); MessageHud.instance.ShowMessage((MessageType)2, "Mystery Box: You found a Scroll of Endurance!", 0, (Sprite)null, false); } else if (item2.Item1 == "APPLY_BURDEN") { ApplyScrollOfBurden(player); MessageHud.instance.ShowMessage((MessageType)2, "Mystery Box: You found a Scroll of Burden!", 0, (Sprite)null, false); } else { ((Humanoid)player).GetInventory().AddItem(item2.Item1, item2.Item2, 1, 0, 0L, "", false); MessageHud.instance.ShowMessage((MessageType)2, $"Mystery Box: You found {item2.Item1} x{item2.Item2}!", 0, (Sprite)null, false); } break; } } } public static void ApplyScrollOfVitality(Player player) { int scrollUses = GetScrollUses(player, "Shopkeep_Vitality"); if (scrollUses >= 3) { MessageHud.instance.ShowMessage((MessageType)2, "You have already reached the limit for Scroll of Vitality!", 0, (Sprite)null, false); return; } player.m_customData["Shopkeep_Vitality"] = (scrollUses + 1).ToString(); ((Character)player).SetMaxHealth(((Character)player).GetMaxHealth() + 25f); MessageHud.instance.ShowMessage((MessageType)2, $"Scroll of Vitality: Max health increased by 25! ({scrollUses + 1}/{3})", 0, (Sprite)null, false); } public static void ApplyScrollOfEndurance(Player player) { int scrollUses = GetScrollUses(player, "Shopkeep_Endurance"); if (scrollUses >= 3) { MessageHud.instance.ShowMessage((MessageType)2, "You have already reached the limit for Scroll of Endurance!", 0, (Sprite)null, false); return; } player.m_customData["Shopkeep_Endurance"] = (scrollUses + 1).ToString(); player.SetMaxStamina(((Character)player).GetMaxStamina() + 25f, false); MessageHud.instance.ShowMessage((MessageType)2, $"Scroll of Endurance: Max stamina increased by 25! ({scrollUses + 1}/{3})", 0, (Sprite)null, false); } public static void ApplyScrollOfBurden(Player player) { int scrollUses = GetScrollUses(player, "Shopkeep_Burden"); if (scrollUses >= 3) { MessageHud.instance.ShowMessage((MessageType)2, "You have already reached the limit for Scroll of Burden!", 0, (Sprite)null, false); return; } player.m_customData["Shopkeep_Burden"] = (scrollUses + 1).ToString(); player.m_maxCarryWeight += 100f; MessageHud.instance.ShowMessage((MessageType)2, $"Scroll of Burden: Carry weight increased by 100! ({scrollUses + 1}/{3})", 0, (Sprite)null, false); } private static int GetScrollUses(Player player, string key) { if (player.m_customData.ContainsKey(key)) { return int.Parse(player.m_customData[key]); } return 0; } } [HarmonyPatch(typeof(Player), "OnSpawned")] public class StatRestorePatch { private static void Postfix(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { if (__instance.m_customData.ContainsKey("Shopkeep_Vitality")) { int num = int.Parse(__instance.m_customData["Shopkeep_Vitality"]); ((Character)__instance).SetMaxHealth(((Character)__instance).GetMaxHealth() + (float)num * 25f); } if (__instance.m_customData.ContainsKey("Shopkeep_Endurance")) { int num2 = int.Parse(__instance.m_customData["Shopkeep_Endurance"]); __instance.SetMaxStamina(((Character)__instance).GetMaxStamina() + (float)num2 * 25f, false); } if (__instance.m_customData.ContainsKey("Shopkeep_Burden")) { int num3 = int.Parse(__instance.m_customData["Shopkeep_Burden"]); __instance.m_maxCarryWeight += (float)num3 * 100f; } } } } public class ShopkeepInteract : MonoBehaviour, Interactable, Hoverable { public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if ((Object)(object)val == (Object)null) { return false; } ShopUI.Show(); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { return "Bercans\n[E] Browse Wares"; } public string GetHoverName() { return "Bercans"; } } public class ShopkeepNPC { public static void Register() { //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Expected O, but got Unknown //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrefabManager.Instance.CreateClonedPrefab("Bercans", "piece_bone_throne"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"Failed to clone prefab!"); return; } Interactable[] componentsInChildren = val.GetComponentsInChildren(); foreach (Interactable val2 in componentsInChildren) { Object.Destroy((Object)(object)((val2 is Object) ? val2 : null)); } GameObject prefab = PrefabManager.Instance.GetPrefab("Haldor"); if ((Object)(object)prefab != (Object)null) { GameObject val3 = Object.Instantiate(prefab, val.transform); val3.transform.localPosition = new Vector3(0f, 0.3f, 0.3f); val3.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); val3.transform.localScale = new Vector3(1f, 1f, 1f); Trader component = val3.GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Character component2 = val3.GetComponent(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } BaseAI component3 = val3.GetComponent(); if ((Object)(object)component3 != (Object)null) { Object.Destroy((Object)(object)component3); } ZNetView component4 = val3.GetComponent(); if ((Object)(object)component4 != (Object)null) { Object.Destroy((Object)(object)component4); } MonoBehaviour[] componentsInChildren2 = val3.GetComponentsInChildren(); foreach (MonoBehaviour val4 in componentsInChildren2) { ((Behaviour)val4).enabled = false; } } val.AddComponent(); PieceConfig val5 = new PieceConfig(); val5.Name = "Bercans"; val5.Description = "A traveling merchant with rare wares."; val5.PieceTable = "Hammer"; val5.AddRequirement(new RequirementConfig("Coins", 10000, 0, true)); PieceManager.Instance.AddPiece(new CustomPiece(val, false, val5)); Debug.Log((object)"Bercans registered!"); } } public class ShopKeyListener : MonoBehaviour { private void Update() { if (ZInput.GetButtonDown("Escape") || ZInput.GetButtonDown("JoyButtonB")) { ShopUI.Hide(); } } } public class ShopUI { private struct ShopItem { public string itemName; public string displayName; public int price; public int amount; public string category; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__6_0; internal void b__6_0() { Hide(); } } private static GameObject shopPanel; private static bool isOpen = false; private static List shopItems = new List { new ShopItem { itemName = "CookedMeat", displayName = "Cooked Meat", price = 50, amount = 5, category = "Food" }, new ShopItem { itemName = "Bread", displayName = "Bread", price = 8, amount = 50, category = "Food" }, new ShopItem { itemName = "FishCooked", displayName = "Cooked Fish", price = 60, amount = 5, category = "Food" }, new ShopItem { itemName = "SerpentStew", displayName = "Serpent Stew", price = 250, amount = 3, category = "Food" }, new ShopItem { itemName = "LoxPie", displayName = "Lox Meat Pie", price = 300, amount = 3, category = "Food" }, new ShopItem { itemName = "BloodPudding", displayName = "Blood Pudding", price = 200, amount = 3, category = "Food" }, new ShopItem { itemName = "MeadHealthMinor", displayName = "Minor Health Mead", price = 150, amount = 1, category = "Potions" }, new ShopItem { itemName = "MeadHealthMedium", displayName = "Medium Health Mead", price = 250, amount = 1, category = "Potions" }, new ShopItem { itemName = "MeadStaminaMinor", displayName = "Minor Stamina Mead", price = 150, amount = 1, category = "Potions" }, new ShopItem { itemName = "MeadStaminaMedium", displayName = "Medium Stamina Mead", price = 250, amount = 1, category = "Potions" }, new ShopItem { itemName = "MeadPoisonResist", displayName = "Poison Resistance Mead", price = 300, amount = 1, category = "Potions" }, new ShopItem { itemName = "MeadFrostResist", displayName = "Frost Resistance Mead", price = 300, amount = 1, category = "Potions" }, new ShopItem { itemName = "MysteryBox", displayName = "Mystery Box", price = 500, amount = 1, category = "Special" }, new ShopItem { itemName = "ScrollOfVitality", displayName = "Scroll of Vitality (+25 Health)", price = 2000, amount = 1, category = "Special" }, new ShopItem { itemName = "ScrollOfEndurance", displayName = "Scroll of Endurance (+25 Stamina)", price = 2000, amount = 1, category = "Special" }, new ShopItem { itemName = "ScrollOfBurden", displayName = "Scroll of Burden (+100 Carry Weight)", price = 2000, amount = 1, category = "Special" } }; public static void Show() { if (isOpen) { Hide(); return; } CreateUI(); isOpen = true; GUIManager.BlockInput(true); } public static void Hide() { if ((Object)(object)shopPanel != (Object)null) { Object.Destroy((Object)(object)shopPanel); shopPanel = null; } isOpen = false; GUIManager.BlockInput(false); } private static void CreateUI() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Expected O, but got Unknown //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Expected O, but got Unknown //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) shopPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(-400f, 0f), 1400f, 1500f, true); shopPanel.AddComponent(); GUIManager.Instance.CreateText("Free Gold Market", shopPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -60f), GUIManager.Instance.AveriaSerifBold, 36, GUIManager.Instance.ValheimOrange, true, Color.black, 1200f, 60f, false); int playerCoins = GetPlayerCoins(); GUIManager.Instance.CreateText($"Your Coins: {playerCoins}", shopPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -110f), GUIManager.Instance.AveriaSerifBold, 24, Color.yellow, true, Color.black, 1200f, 40f, false); GameObject val = GUIManager.Instance.CreateButton("X", shopPanel.transform, new Vector2(1f, 1f), new Vector2(1f, 1f), new Vector2(-25f, -25f), 40f, 40f); ButtonClickedEvent onClick = val.GetComponent