Skip to Main Content
Table of Contents

BTD_Mod_Helper​.Api​.Towers​.ModTower


BloonsTD6 Mod Helper

BTD_Mod_Helper.Api.Towers

ModTower Class

Class for adding a custom Tower to the game. Use alongside ModUpgrade to define its upgrades,
and optionally ModTowerDisplay to define custom displays for it.

public abstract class ModTower : BTD_Mod_Helper.Api.NamedModContent

Inheritance System.ObjectModContentNamedModContent  ModTower

Derived
ModHero
ModSubTower
ModTower<T>
ModVanillaParagon

Fields

ModTower.MAGIC Field

The string to use for the Magic tower set

protected const string MAGIC = "Magic";

Field Value

System.String

ModTower.MILITARY Field

The string to use for the Military tower set

protected const string MILITARY = "Military";

Field Value

System.String

ModTower.PRIMARY Field

The string to use for the Primary tower set

protected const string PRIMARY = "Primary";

Field Value

System.String

ModTower.SUPPORT Field

The string to use for the Support tower set

protected const string SUPPORT = "Support";

Field Value

System.String

Properties

ModTower.AlwaysIncludeInChallenge Property

Whether to always make this tower be included in challenges / Bosses / Odysseys etc

public virtual bool AlwaysIncludeInChallenge { get; }

Property Value

System.Boolean

ModTower.BaseTower Property

The id of the default BTD Tower that your Tower is going to be copied from by default.

public abstract string BaseTower { get; }

Property Value

System.String

ModTower.BottomPathUpgrades Property

The number of upgrades the tower has in it's 3rd / bottom path

public virtual int BottomPathUpgrades { get; }

Property Value

System.Int32

ModTower.Cost Property

The in game cost of this tower (on Medium difficulty)

public abstract int Cost { get; }

Property Value

System.Int32

ModTower.DontAddToShop Property

Makes this Tower not actually add itself to the shop, useful for making subtowers

public virtual bool DontAddToShop { get; }

Property Value

System.Boolean

ModTower.Hotkey Property

Hotkey to use for placing this tower from the shop

public virtual BTD_Mod_Helper.Api.ModOptions.ModSettingHotkey Hotkey { get; }

Property Value

ModSettingHotkey

ModTower.Icon Property

The Icon for the Tower's purchase button, by default "[Name]-Icon"


(Name of .png or .jpg, not including file extension)

public virtual string Icon { get; }

Property Value

System.String

ModTower.IconReference Property

If you're not going to use a custom .png for your Icon, use this to directly control its SpriteReference

public virtual SpriteReference IconReference { get; }

Property Value

Il2CppNinjaKiwi.Common.ResourceUtils.SpriteReference

ModTower.IncludeInMonkeyTeams Property

Whether this tower should be allowed to be included in Monkey Teams

public virtual bool IncludeInMonkeyTeams { get; }

Property Value

System.Boolean

ModTower.MiddlePathUpgrades Property

The number of upgrades the tower has in it's 2nd / middle path

public virtual int MiddlePathUpgrades { get; }

Property Value

System.Int32

ModTower.ParagonMode Property

Defines whether / how this ModTower has a Paragon

public virtual BTD_Mod_Helper.Api.Towers.ParagonMode ParagonMode { get; }

Property Value

ParagonMode

ModTower.PixelsPerUnit Property

For 2D towers, the ratio between pixels and display units. Higher number -> smaller tower.

public virtual float PixelsPerUnit { get; }

Property Value

System.Single

ModTower.Portrait Property

The Portrait for the 0-0-0 tower, by default "[Name]-Portrait"


(Name of .png or .jpg, not including file extension)

public virtual string Portrait { get; }

Property Value

System.String

ModTower.PortraitReference Property

If you're not going to use a custom .png for your Portrait, use this to directly control its SpriteReference

public virtual SpriteReference PortraitReference { get; }

Property Value

Il2CppNinjaKiwi.Common.ResourceUtils.SpriteReference

ModTower.ShopTowerCount Property

How many of this tower you can buy at once during a game. By default -1 for no limit.

public virtual int ShopTowerCount { get; }

Property Value

System.Int32

ModTower.TopPathUpgrades Property

The number of upgrades the tower has in it's 1st / top path

public virtual int TopPathUpgrades { get; }

Property Value

System.Int32

ModTower.TowerSet Property

The family of Monkeys that your Tower should be put in.


For now, just use one of the default constants provided of PRIMARY, MILITARY, MAGIC, or SUPPORT.

public abstract TowerSet TowerSet { get; }

Property Value

Il2CppAssets.Scripts.Models.TowerSets.TowerSet

ModTower.Use2DModel Property

Whether this Tower should display 2-dimensionally, and search for png images

public virtual bool Use2DModel { get; }

Property Value

System.Boolean

Methods

ModTower.Get2DScale(int[]) Method

Gets the scale to use for a 2d tower at the given tiers

public virtual float Get2DScale(params int[] tiers);

Parameters

tiers System.Int32[]

Returns

System.Single

ModTower.Get2DTexture(int[]) Method

If this is a 2D tower, gets the name of the .png to use for a given set of tiers


Default Behavior Example: For CardMonkey with tiers 2-3-0, it would try (in order):
CardMonkey-230, CardMonkey-X3X, CardMonkey-2XX, CardMonkey
Get2DScale(int[])

public virtual string Get2DTexture(params int[] tiers);

Parameters

tiers System.Int32[]

Returns

System.String

ModTower.GetBaseTowerModel(int[]) Method

Allows you to change the base TowerModel your tower will use at different tiers. Note that you'd need to be
careful if you entirely changed the base tower you're working with at different tiers, as it will still attempt
to apply all the appropriate upgrades. If you would like a ModUpgrade to only have an effect at a given tier,
you could do something like:

public override void ApplyUpgrade(TowerModel towerModel) {  
    if (towerModel.tiers[Path] != Tier) return;  
    ...  
}  
public virtual TowerModel GetBaseTowerModel(params int[] tiers);

Parameters

tiers System.Int32[]

Length 3 array of Top/Mid/Bot tiers

Returns

Il2CppAssets.Scripts.Models.Towers.TowerModel
The base TowerModel to use

ModTower.GetPortraitReferenceForTiers(int[]) Method

Gets the portrait reference this tower should use for the given tiers


Looks for the highest tier ModUpgrade this tower has that defined a
PortraitReference,
falling back to the tower's own base PortraitReference by default.

public SpriteReference GetPortraitReferenceForTiers(params int[] tiers);

Parameters

tiers System.Int32[]

Returns

Il2CppNinjaKiwi.Common.ResourceUtils.SpriteReference

ModTower.GetTowerIndex(List) Method

When adding this tower to the shop, gets the index at which to add the tower relative to the existing ones.


By default, the tower will be put at the end of the TowerSet category that it's in.

public virtual int GetTowerIndex(System.Collections.Generic.List<TowerDetailsModel> towerSet);

Parameters

towerSet System.Collections.Generic.List<Il2CppAssets.Scripts.Models.TowerSets.TowerDetailsModel>

Returns

System.Int32

ModTower.GetUpgradePathModel(ModUpgrade, int[]) Method

Creates an UpgradePathModel for a particular upgrade and new tiers

public virtual UpgradePathModel GetUpgradePathModel(BTD_Mod_Helper.Api.Towers.ModUpgrade modUpgrade, int[] newTiers);

Parameters

modUpgrade ModUpgrade

The upgrade

newTiers System.Int32[]

The new desired tiers of the tower

Returns

Il2CppAssets.Scripts.Models.Towers.Upgrades.UpgradePathModel

ModTower.IsUpgradePathClosed(TowerToSimulation, int, bool) Method

Allows you to override whether an UpgradePath should be closed or not for a tower

public virtual System.Nullable<bool> IsUpgradePathClosed(TowerToSimulation tower, int path, bool defaultClosed);

Parameters

tower Il2CppAssets.Scripts.Unity.Bridge.TowerToSimulation

The TowerToSimulation

path System.Int32

What path this is for

defaultClosed System.Boolean

Whether it'd be naturally closed or not

Returns

System.Nullable<System.Boolean>
Whether the upgrade path should be closed, or null for no change

ModTower.IsValidCrosspath(int[]) Method

Another way to modify the allowable crosspaths for your tower. By default, checks that the highest tier is at
most 5, the next highest is at most 2, and the last one is 0


Used in the default implementation of TowerTiers()

public virtual bool IsValidCrosspath(params int[] tiers);

Parameters

tiers System.Int32[]

Returns

System.Boolean

ModTower.MaxUpgradePips(TowerToSimulation, int, int) Method

Allows you to override how many possible Upgrade pips it should show as being possible for a tower to get

public virtual System.Nullable<int> MaxUpgradePips(TowerToSimulation tower, int path, int defaultMax);

Parameters

tower Il2CppAssets.Scripts.Unity.Bridge.TowerToSimulation

The TowerToSimulation

path System.Int32

What path this is for

defaultMax System.Int32

The default maximum

Returns

System.Nullable<System.Int32>
The new maximum amount of upgrade pips, or null for no change

ModTower.ModifyBaseTowerModel(TowerModel) Method

Implemented by a ModTower to modify the base tower model before applying any/all ModUpgrades


Things like the TowerModel's name, cost, tier, and upgrades are already taken care of before this point

public abstract void ModifyBaseTowerModel(TowerModel towerModel);

Parameters

towerModel Il2CppAssets.Scripts.Models.Towers.TowerModel

The Base Tower Model

ModTower.ModifyTowerModelForMatch(TowerModel, GameModel) Method

Further modifies this tower when you go into a new match.
Useful for making conditional effects happen based on settings.


The normal ApplyUpgrade effects for all upgrades will have already been applied on game start,
so this will simply modify all the TowerModels for this ModTower.

public virtual void ModifyTowerModelForMatch(TowerModel towerModel, GameModel gameModel);

Parameters

towerModel Il2CppAssets.Scripts.Models.Towers.TowerModel

gameModel Il2CppAssets.Scripts.Models.GameModel

ModTower.ModifyTowerModelForMatch(TowerModel, IReadOnlyList) Method

Further modifies this tower when you go into a new match.
Useful for making conditional effects happen based on settings.


The normal ApplyUpgrade effects for all upgrades will have already been applied on game start,
so this will simply modify all the TowerModels for this ModTower.

public virtual void ModifyTowerModelForMatch(TowerModel towerModel, System.Collections.Generic.IReadOnlyList<ModModel> gameModes);

Parameters

towerModel Il2CppAssets.Scripts.Models.Towers.TowerModel

gameModes System.Collections.Generic.IReadOnlyList<Il2CppAssets.Scripts.Models.ModModel>

ModTower.TowerTiers() Method

Returns all the valid tiers for the TowerModels of this Tower

public virtual System.Collections.Generic.IEnumerable<int[]> TowerTiers();

Returns

System.Collections.Generic.IEnumerable<System.Int32[]>

To learn how to download BTD Mod Helper and install mods, click here