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 BepInEx.Configuration; using GridEditor; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("FTKMore&BetterMissions")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FTKMore&BetterMissions")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("31fb7257-e463-4401-952b-d59a2470617a")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace FTKMoreBetterMissions; [BepInPlugin("FTKMoreBetterMissions", "FTK More & Better Missions", "1.0.0")] public class Main : BaseUnityPlugin { public static ConfigEntry ConfigMaxSideQuests; public static ConfigEntry ConfigGoldMinPercent; public static ConfigEntry ConfigGoldMaxPercent; private void Awake() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) ConfigMaxSideQuests = ((BaseUnityPlugin)this).Config.Bind("General", "MaxSideQuests", 8, "Número máximo de misiones que pueden aparecer en un tablón de pueblo. (Valores recomendados: 4-12)"); ConfigGoldMinPercent = ((BaseUnityPlugin)this).Config.Bind("Gold", "MinPercent", -50f, "Porcentaje mínimo de reducción del oro base. Ej: -50 significa que puede bajar hasta un 50% menos."); ConfigGoldMaxPercent = ((BaseUnityPlugin)this).Config.Bind("Gold", "MaxPercent", 40f, "Porcentaje máximo de aumento del oro base. Ej: 40 significa que puede subir hasta un 40% más."); new Harmony("FTKMoreBetterMissions").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"FTK More & Better Missions loaded!"); } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static class MiniHexTown_MaxSideQuests_Patch { private static void Postfix(ref int __result) { if (__result == GameLogic.Instance.GetGameDef().m_SideQuestsPerTown) { __result = Main.ConfigMaxSideQuests.Value; } } } [HarmonyPatch(typeof(QuestGenerator), "_assignBountyQuestReward")] public static class QuestGenerator_BountyReward_Patch { private static List equippableItems; static QuestGenerator_BountyReward_Patch() { LoadEquippableItems(); } private static void LoadEquippableItems() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) equippableItems = new List(); FTK_weaponStats2DB dB = FTK_weaponStats2DB.GetDB(); if (((GEDataArray)(object)dB)?.m_Array != null) { FTK_weaponStats2[] array = ((GEDataArray)(object)dB).m_Array; foreach (FTK_weaponStats2 val in array) { if (val != null) { ID @enum = FTK_itembase.GetEnum(((GEDataBase)val).m_ID); if ((int)@enum != -1 && !equippableItems.Contains(@enum)) { equippableItems.Add(@enum); } } } } FTK_itemsDB dB2 = FTK_itemsDB.GetDB(); if (((GEDataArray)(object)dB2)?.m_Array != null) { FTK_items[] array2 = ((GEDataArray)(object)dB2).m_Array; foreach (FTK_items val2 in array2) { if (val2 != null && (((FTK_itembase)val2).m_Equippable || ((FTK_itembase)val2).m_IsWeapon || ((FTK_itembase)val2).m_IsShield)) { ID enum2 = FTK_itembase.GetEnum(((GEDataBase)val2).m_ID); if ((int)enum2 != -1 && !equippableItems.Contains(enum2)) { equippableItems.Add(enum2); } } } } Debug.Log((object)$"[FTKMoreBetterMissions] Cargados {equippableItems.Count} objetos equipables."); } private static ID GetRandomEquippableItem() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (equippableItems.Count == 0) { Debug.LogError((object)"[FTKMoreBetterMissions] No hay objetos equipables."); return (ID)(-1); } return equippableItems[Random.Range(0, equippableItems.Count)]; } private static int GetGodbeardAmount() { float value = Random.value; if (value < 0.4f) { return 1; } if (value < 0.7f) { return 2; } if (value < 0.85f) { return 3; } if (value < 0.93f) { return 4; } if (value < 0.98f) { return 6; } return 8; } private static int GetVariedGold(int baseGold) { float num = Main.ConfigGoldMinPercent.Value / 100f; float num2 = Main.ConfigGoldMaxPercent.Value / 100f; float value = Random.value; float value2 = Random.value; float num3 = (value + value2) / 2f; float num4 = Mathf.Lerp(num, num2, num3); int num5 = Mathf.RoundToInt((float)baseGold * (1f + num4)); return Mathf.Max(1, num5); } private static void Postfix(SideQuestProperties _sideQuest, GameStage _stage) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if ((int)_sideQuest.m_RewardType == 5) { return; } int rewardAmount = _sideQuest.m_RewardAmount; float num = 0.25f; float num2 = 0.1f; float value = Random.value; if (value < num2) { _sideQuest.m_RewardType = (Reward)4; _sideQuest.m_RewardItem = (ID)0; _sideQuest.m_RewardAmount = GetGodbeardAmount(); } else if (value < num + num2) { ID randomEquippableItem = GetRandomEquippableItem(); if ((int)randomEquippableItem != -1) { _sideQuest.m_RewardType = (Reward)4; _sideQuest.m_RewardItem = randomEquippableItem; _sideQuest.m_RewardAmount = 1; } else { _sideQuest.m_RewardType = (Reward)1; _sideQuest.m_RewardAmount = GetVariedGold(rewardAmount); } } else { _sideQuest.m_RewardType = (Reward)1; _sideQuest.m_RewardAmount = GetVariedGold(rewardAmount); } } }