Skip to content

Commit

Permalink
Fix for v39; Don't bypass challenge rules
Browse files Browse the repository at this point in the history
  • Loading branch information
doombubbles committed Oct 26, 2023
1 parent d8f0dab commit 0766f9f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 37 deletions.
3 changes: 2 additions & 1 deletion LATEST.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Should now work in even more situations, such as with Insta Monkeys / the Insta Monkey Rework mod
- Recompiled for BTD6 v39
- Unlimited 5th Tiers no longer bypasses challenge rule restrictions
4 changes: 2 additions & 2 deletions ModHelperData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

### Lets you use any amount of fith tier towers in BTD6, and more

<img alt="Screenshot" src="https://github.com/doombubbles/BTD6-Mods/blob/main/Unlimited5thTiers/image.png?raw=true" height="300" />
<img alt="Screenshot" src="image.png" height="300" />

### Features

Expand Down
55 changes: 22 additions & 33 deletions Unlimited5thTiersMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,7 +22,7 @@ public class Unlimited5thTiersMod : BloonsTD6Mod
/// <summary>
/// Sun Temples with 4 Sacrifice Groups
/// </summary>
public override void OnNewGameModel(GameModel gameModel, List<ModModel> mods)
public override void OnNewGameModel(GameModel gameModel)
{
foreach (var superMonkey in gameModel.GetTowersWithBaseId(TowerType.SuperMonkey))
{
Expand All @@ -36,38 +36,24 @@ public override void OnNewGameModel(GameModel gameModel, List<ModModel> mods)
/// <summary>
/// Unlimited 5th Tiers
/// </summary>
[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<TowerDetailsModel> towers)
{
if (tier == 5 && Settings.AllowUnlimited5thTiers)
{
__result = false;
return false;
}
if (!Settings.AllowUnlimited5thTiers) return;

return true;
}
}

/// <summary>
/// Unlimited 5th Tiers
/// </summary>
[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<ShopTowerDetailsModel>())
{
for (var path = 0; path < 3; path++)
{
__instance.AddTierRestriction(towerDetails.towerId, path, 5, 9999999);
}
}
});
}
}

Expand All @@ -88,7 +74,7 @@ public static void Postfix(MonkeyTemple __instance)
}

/// <summary>
/// Non-maxed Vengeful Temples
/// Multiple Vengeful Temples
/// </summary>
[HarmonyPatch(typeof(MonkeyTemple), nameof(MonkeyTemple.CheckTCBOO))]
internal class MonkeyTemple_CheckTCBOO
Expand All @@ -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<Tower>();
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)
Expand Down

0 comments on commit 0766f9f

Please sign in to comment.