From 0766f9fd5b1eba15cba01bb11e6eaf1c40fa4a2b Mon Sep 17 00:00:00 2001 From: doombubbles Date: Wed, 25 Oct 2023 18:12:44 -0700 Subject: [PATCH] Fix for v39; Don't bypass challenge rules --- LATEST.md | 3 ++- ModHelperData.cs | 4 +-- README.md | 2 +- Unlimited5thTiersMod.cs | 55 +++++++++++++++++------------------------ 4 files changed, 27 insertions(+), 37 deletions(-) diff --git a/LATEST.md b/LATEST.md index c92b164..a5da41e 100644 --- a/LATEST.md +++ b/LATEST.md @@ -1 +1,2 @@ -- Should now work in even more situations, such as with Insta Monkeys / the Insta Monkey Rework mod \ No newline at end of file +- Recompiled for BTD6 v39 +- Unlimited 5th Tiers no longer bypasses challenge rule restrictions \ No newline at end of file diff --git a/ModHelperData.cs b/ModHelperData.cs index f28cad3..a1f42cf 100644 --- a/ModHelperData.cs +++ b/ModHelperData.cs @@ -2,8 +2,8 @@ public static class ModHelperData { - public const string WorksOnVersion = "35.0"; - public const string Version = "1.1.4"; + public const string WorksOnVersion = "39.2"; + public const string Version = "1.1.5"; public const string Name = "Unlimited 5th Tiers +"; public const string Description = diff --git a/README.md b/README.md index 51f842a..01bfc7b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ### Lets you use any amount of fith tier towers in BTD6, and more -Screenshot +Screenshot ### Features diff --git a/Unlimited5thTiersMod.cs b/Unlimited5thTiersMod.cs index 3c089a4..a273cf2 100644 --- a/Unlimited5thTiersMod.cs +++ b/Unlimited5thTiersMod.cs @@ -5,7 +5,7 @@ using Il2CppAssets.Scripts.Models; using Il2CppAssets.Scripts.Models.Towers; using Il2CppAssets.Scripts.Models.Towers.Behaviors; -using Il2CppAssets.Scripts.Models.Towers.Mods; +using Il2CppAssets.Scripts.Models.TowerSets; using Il2CppAssets.Scripts.Simulation.Input; using Il2CppAssets.Scripts.Simulation.Towers; using Il2CppAssets.Scripts.Simulation.Towers.Behaviors; @@ -22,7 +22,7 @@ public class Unlimited5thTiersMod : BloonsTD6Mod /// /// Sun Temples with 4 Sacrifice Groups /// - public override void OnNewGameModel(GameModel gameModel, List mods) + public override void OnNewGameModel(GameModel gameModel) { foreach (var superMonkey in gameModel.GetTowersWithBaseId(TowerType.SuperMonkey)) { @@ -36,38 +36,24 @@ public override void OnNewGameModel(GameModel gameModel, List mods) /// /// Unlimited 5th Tiers /// - [HarmonyPatch(typeof(TowerInventory), nameof(TowerInventory.IsPathTierLocked))] - internal static class TowerInventory_IsPathTierLocked + [HarmonyPatch(typeof(TowerInventory), nameof(TowerInventory.SetTowerTierRestrictions))] + internal static class TowerInventory_SetTowerTierRestrictions { - [HarmonyPrefix] - private static bool Prefix(int tier, ref bool __result) + [HarmonyPostfix] + private static void Postfix(TowerInventory __instance, IEnumerable towers) { - if (tier == 5 && Settings.AllowUnlimited5thTiers) - { - __result = false; - return false; - } + if (!Settings.AllowUnlimited5thTiers) return; - return true; - } - } - - /// - /// Unlimited 5th Tiers - /// - [HarmonyPatch(typeof(TowerInventory), nameof(TowerInventory.HasUpgradeInventory))] - internal static class TowerInventory_HasInventory - { - [HarmonyPrefix] - private static bool Prefix(TowerModel def, ref bool __result) - { - if (def.tier == 5 && Settings.AllowUnlimited5thTiers) + towers.ForEach(towerDetails => { - __result = true; - return false; - } - - return true; + if (towerDetails.Is()) + { + for (var path = 0; path < 3; path++) + { + __instance.AddTierRestriction(towerDetails.towerId, path, 5, 9999999); + } + } + }); } } @@ -88,7 +74,7 @@ public static void Postfix(MonkeyTemple __instance) } /// - /// Non-maxed Vengeful Temples + /// Multiple Vengeful Temples /// [HarmonyPatch(typeof(MonkeyTemple), nameof(MonkeyTemple.CheckTCBOO))] internal class MonkeyTemple_CheckTCBOO @@ -103,8 +89,11 @@ internal static bool Prefix(MonkeyTemple __instance) __instance.monkeyTempleModel.checkForThereCanOnlyBeOne && __instance.lastSacrificed != __instance.Sim.time.elapsed) { - var superMonkeys = __instance.Sim.towerManager.GetTowersByBaseId(TowerType.SuperMonkey).ToList() - .Where(tower => tower.Id != __instance.tower.Id).ToList(); + var superMonkeys = __instance.Sim.towerManager + .GetTowersByBaseId(TowerType.SuperMonkey) + .ToList() + .Where(tower => tower.Id != __instance.tower.Id) + .ToList(); var robocop = superMonkeys.FirstOrDefault(tower => tower.towerModel.tiers[1] == 5); var batman = superMonkeys.FirstOrDefault(tower => tower.towerModel.tiers[2] == 5); if (batman != default && robocop != default)