Skip to content

Commit

Permalink
Added a delay for the custom bloon spawning, making it have the Boss …
Browse files Browse the repository at this point in the history
…bloon tag, fixed the issue where it would turn into the other bloon state if it had any from the base bloon, and can now give more cash per pop
  • Loading branch information
DarkTerraYT committed Nov 4, 2023
1 parent f4df0dd commit 85de2fb
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 64 deletions.
36 changes: 17 additions & 19 deletions Bloon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
using Il2CppAssets.Scripts.Models.Bloons;
using Il2Cpp;
using static Extension.CustomBloon;
using System.Collections.Generic;
using Il2CppAssets.Scripts.Models.Bloons.Behaviors;

namespace Extension
{
internal class Bloon : ModBloon
{
public override bool Camo => CustomBloon.Camo;
public override bool Fortified => CustomBloon.Fortified;
public override bool Regrow => CustomBloon.Regrow;
public override float RegrowRate => CustomBloon.RegrowRate;

public override string BaseBloon => BaseBloonType;

public override IEnumerable<string> DamageStates => new string[] { };

public override string Icon => "BloonI";

public override void ModifyBaseBloonModel(BloonModel bloonModel)
Expand All @@ -27,6 +36,8 @@ public override void ModifyBaseBloonModel(BloonModel bloonModel)
bloonModel.leakDamage = LeakDamage;
}

bloonModel.GetBehavior<DistributeCashModel>().cash = CashPerPop;

if (CustomBloonDisplay)
{
bloonModel.ApplyDisplay<Display.CustomBloonDisplay>();
Expand All @@ -36,30 +47,17 @@ public override void ModifyBaseBloonModel(BloonModel bloonModel)
if (!TowerDisplay) { bloonModel.SetDisplayGUID(Ext.GetDisplay(DisplayFromWhat, 0)); }
else { bloonModel.SetDisplayGUID(Ext.GetDisplay(DisplayFromWhat, 1)); }
}

if (Regrow)
{
bloonModel.isGrow = true;
bloonModel.IsRegrowBloon();
bloonModel.MakeChildrenRegrow();
}
if (Fortified)
{
bloonModel.isFortified = true;
bloonModel.IsFortifiedBloon();
bloonModel.MakeChildrenFortified();
}
if (Camo)
{
bloonModel.isCamo = true;
bloonModel.IsCamoBloon();
bloonModel.MakeChildrenCamo();
}
if (Moab)
{
bloonModel.AddTag("Moab");
bloonModel.isMoab = true;
bloonModel.IsMoabBloon();
}
if (Boss)
{
bloonModel.AddTag("Boss");
bloonModel.isBoss = true;
}
if (Immune)
{
bloonModel.bloonProperties = BloonProperties.Immune;
Expand Down
88 changes: 51 additions & 37 deletions CustomBloon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@
using BTD_Mod_Helper;
using Extension;
using BTD_Mod_Helper.Api.ModOptions;
using System.Collections.Generic;
using System.ComponentModel;
using HarmonyLib;
using Il2CppAssets.Scripts.Models.Bloons;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppAssets.Scripts.Unity;
using BTD_Mod_Helper.Api;
using Il2CppSystem.IO;
using BTD_Mod_Helper.Extensions;
using Il2CppAssets.Scripts.Models;

[assembly: MelonInfo(typeof(Extension.CustomBloon), ModHelperData.Name, ModHelperData.Version, ModHelperData.RepoOwner)]
[assembly: MelonGame("Ninja Kiwi", "BloonsTD6")]
Expand Down Expand Up @@ -76,7 +68,7 @@ public class CustomBloon : BloonsTD6Mod
{
requiresRestart = true,
category = BloonSettings,
description = "Use The Custom Bloon Display? If the file is null then will be the one I made"
description = "Use The Custom Bloon Display?"
};
public static readonly ModSettingBool TowerDisplay = new(false)
{
Expand All @@ -88,41 +80,20 @@ public class CustomBloon : BloonsTD6Mod
{
requiresRestart = true,
category = BloonSettings,
description = "Which Bloon Should This Look Like? Used When Use Custom Bloon Display Isn't Used. ONLY PUT IN A TOWER ID IF TOWER DISPLAY IS ENABLED!"
description = "Which Bloon Should This Look Like? Used When Use Custom Bloon Display Isn't Used. ONLY PUT IN A TOWER ID IF TOWER DISPLAY IS ENABLED! IDs are like this -> NinjaMonkey for the 000 abd NinjaMonkey-402 when it has upgrades. For Heros it's HeroName or HeroName Level. This could look like Geraldo or Geraldo 12. IDs for bloons is just the name like Ddt"
};
public static readonly ModSettingBool Regrow = new(false)
{
requiresRestart = true,
category = BloonSettings,
description = "Is This a Regrow Bloon?"
};
public static readonly ModSettingBool Camo = new(false)
{
requiresRestart = true,
category = BloonSettings,
description = "Is This a Camo Bloon?"
};
public static readonly ModSettingBool Fortified = new(false)
{
requiresRestart = true,
category = BloonSettings,
description = "Is This Bloon Fortified?"
};
public static readonly ModSettingBool Moab = new(false)
public static readonly ModSettingInt CashPerPop = new(1)
{
requiresRestart = true,
category = BloonSettings,
description = "Is This a Moab Bloon?"
description = "How much cash is awarded per pop. Warning if you make this too big, you will reach the 32 bit integer (signed integer) limit\""
};

/* Might Be Added In The Future
public static readonly ModSettingBool Boss = new(false)
public static readonly ModSettingDouble CashPerPopMultiplier = new(1)
{
requiresRestart = true,
category = BloonSettings,
description = "Bloonarius, Lych, Vortex, Dreadbloon, and Phayze"
description = "The multiplier for how much cash you get. 0.5 is half and 2 is double. Warning if you make this too big, you will reach the 32 bit integer (signed integer) limit"
};
*/

public static readonly ModSettingCategory RoundSetSettings = new("Round Set Settings");

Expand Down Expand Up @@ -164,7 +135,14 @@ public class CustomBloon : BloonsTD6Mod
category = RoundSetSettings,
description = "Only set this to true if you want only the custom bloon to spawn"
};
static readonly ModSettingCategory BloonProperties = new("BloonProperites");
public static readonly ModSettingInt RoundDelay = new(0)
{
requiresRestart = true,
category = RoundSetSettings,
description = "How many rounds until the round the bloon spawns",
min = 0
};
static readonly ModSettingCategory BloonProperties = new("Bloon Properites");

public static readonly ModSettingBool Lead = new(false)
{
Expand Down Expand Up @@ -202,6 +180,42 @@ public class CustomBloon : BloonsTD6Mod
category = BloonProperties,
description = "Can't be popped at all"
};
public static readonly ModSettingBool Regrow = new(false)
{
requiresRestart = true,
category = BloonProperties,
description = "Is This a Regrow Bloon?"
};
public static readonly ModSettingDouble RegrowRate = new(1)
{
requiresRestart = true,
category = BloonProperties,
description = "How many layers regrow per second"
};
public static readonly ModSettingBool Camo = new(false)
{
requiresRestart = true,
category = BloonProperties,
description = "Is This a Camo Bloon?"
};
public static readonly ModSettingBool Fortified = new(false)
{
requiresRestart = true,
category = BloonProperties,
description = "Is This Bloon Fortified?"
};
public static readonly ModSettingBool Moab = new(false)
{
requiresRestart = true,
category = BloonProperties,
description = "Is This a Moab Bloon?"
};
public static readonly ModSettingBool Boss = new(false)
{
requiresRestart = true,
category = BloonProperties,
description = "Makes the bloon a boss bloon. "
};

public override void OnApplicationStart()
{
Expand Down
35 changes: 27 additions & 8 deletions CustomRoundSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,44 @@ namespace Extension
{
internal class CustomRoundSet : ModRoundSet
{
int nextRound = FirstAppearance;
public override string BaseRoundSet => RoundSetType.Default;
public override int DefinedRounds => LastAppearance + 1;
public override string Icon => "Icon";
public override string DisplayName => "Custom Bloon";

public override void ModifyRoundModels(RoundModel roundModel, int round)
{
if (round >= FirstAppearance)
if(nextRound <= round)
{
if (OnlySpawnCustomBloon)
nextRound = round;
}

if (round == nextRound)
{
if (round >= FirstAppearance)
{
roundModel.ClearBloonGroups();
if (OnlySpawnCustomBloon)
{
roundModel.ClearBloonGroups();
}
roundModel.AddBloonGroup(BloonID<Bloon>(), SpawnsPerRound);
AffectedRounds++;
if (round >= LastAppearance)
{
ModHelper.Msg<CustomBloon>("Modified " + AffectedRounds + " Rounds");
}
}
roundModel.AddBloonGroup(BloonID<Bloon>(), SpawnsPerRound);
ModHelper.Msg<CustomBloon>("Modified Round " + round);
AffectedRounds++;
if (round >= LastAppearance)
if (round > FirstAppearance)
{
ModHelper.Msg<CustomBloon>("Modified " + AffectedRounds + " Rounds");
if (nextRound + RoundDelay > LastAppearance)
{
nextRound = LastAppearance;
}
else
{
nextRound += RoundDelay;
}
}
}
}
Expand Down

0 comments on commit 85de2fb

Please sign in to comment.