-
Notifications
You must be signed in to change notification settings - Fork 120
Making a Custom Tower
This page will serve as an overview for creating a custom Tower. Having at least a partial understanding of the ModContent system is recommended if you want a better understanding of what exactly these steps do.
The first and most important part of making a custom Tower is to create a new class in your project that extends from ModTower
. As soon as you add in : ModTower
to your class, your IDE should prompt you to override a number of required Properties and one required Method. The explanations for those are as follows:
TowerSet
: 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
.
BaseTower
: The id of the default BTD Tower that your Tower is going to be copied from by default. So, if your Tower is most similar to a Dart Monkey, for instance, you should do public override string BaseTower => TowerType.DartMonkey;
Cost
: The base cost that your Tower should be on Medium difficulty.
TopPathUpgrades
: The number of Upgrades your Tower has / will have in its Top path.
MiddlePathUpgrades
: The number of Upgrades your Tower has / will have in its Middle path.
BottomPathUpgrades
: The number of Upgrades your Tower has / will have in its Bottom path.
Description
: The text description to use for this Tower, as seen in the Upgrade menu and stuff.
ModifyBaseTowerModel(TowerModel towerModel)
is the only required method for you to override, and it's the most important. Here you will handle actually making your Tower different from the one you defined in BaseTower
.
The towerModel
variable represents a TowerModel
object that has already been prepared by the Mod Helper for you to edit. Basically all of the simple things like name
, id
, tiers
, appliedUpgrades
, display
have already been taken care of at this point, so the main thing you need to do here is change the Tower's behaviors
.
All this method actually needs to do is set up the 0-0-0 version of your Tower, because the ModUpgrade
system will be doing the rest.
The Icon and Portrait for your Tower are defaulted to being .png files named TowerClass
-Portrait and TowerClass
-Icon where TowerClass
is the name of your class that extends ModTower
.
If you want to change this, then you can override the Portrait
/ Icon
properties.
This is one of the main reasons you'd want to use the Mod Helper for your custom Tower rather than doing it all yourself. Instead of having to define the behavior of every different crosspath of your Tower yourself, the Mod Helper can let you define your individual upgrades and write the exact changes that they apply to the TowerModel
.
For every Upgrade you want your Tower to have, create a class for it that extends ModUpgrade<TowerClass>
, where TowerClass
is your ModTower
extending class that this upgrade is for. When you do, you'll have to override the following:
Path
: Which path this is an upgrade for. Use the provided TOP
, MIDDLE, and
BOTTOM` constants. (But they are just 0, 1, and 2)
Tier
: What tier the upgrade is, 1 - 5.
Cost
: The cost that your Upgrade should be on Medium difficulty.
Description
: The text description to use for this Upgrade, as seen in the Selection Menu and Upgrade Menu.
Similarly to ModTower
, there's just one required method to override, and it's the most important.
ApplyUpgrade(TowerModel towerModel)
should contain the code to change a TowerModel
from one that doesn't have the effects of this upgrade to one that does.
Also similarly to TowerModel
, the basic information of the tower is already there, so if you want this upgrade to have different effects depending on what tier the tower is, you can access towerModel.tiers
or even towerModel.appliedUpgrades
(just remember to use ModContent.UpgradeID<T>()
to use the exact name).
By default, ModUpgrade
s will be applied by doing all the top path ones first, then the middle path, then the bottom path, going in tier order 1 - 5 within the paths. If you want to change that, look at the optional Priority
property.
The Icon associated with your Upgrade and the Portrait for your Tower when this is its strongest upgrade are defaulted to being .png files named UpradeClass
-Portrait and UpradeClass
-Icon where UpradeClass
is the name of your class that extends ModUpgrade
.
If you want to change this, then you can override the Portrait
/ Icon
properties.
The Mod Helper uses the same logic as the base game does for deciding that towers with two highest tier upgrades at the same tier should have portraits determined as Middle > Top > Bottom.
Just using the above steps, you can create a fully functioning Custom Tower. It's just gonna look exactly like the BaseTower
we copied from :/
If you want to give your Tower a custom look, you have two different options, with a third in the works by us.
First, you can use the 2D Display Model system to just have your Tower rendered as an unanimated png. This is good if you don't want to dip your toes into the world of 3D Display Models even a little bit.
Second, you can create ModTowerDisplay
classes that are copies of existing BTD 3D models and change their colors and properties.
The first thing you need to do is to add public override bool Use2DModel => true;
to your ModTower
class.
Then, you'll decide if you want to override the Get2DTexture(int[] tiers)
method in your ModTower
class.
Get2DTexture
takes in an int[3]
and returns the file name of a the correct texture to display for the tower (no directory path or .png).
By default, if you had a ModTower
CardMonkey with tiers 2-3-0, it would try (in order): CardMonkey-230, CardMonkey-X3X, CardMonkey-2XX, CardMonkey.
If you want to provide different functionality for getting the png file name for your tower, then override this method and do so, otherwise just include as many .pngs as you want with appropriate names and the ModTower
will use them.
Before you even start this, make sure you've read through how to use normal ModDisplays. Once you understand that, then this should be very straightforward.
Instead of extending ModDisplay
with your class, extend ModTowerDisplay<TowerClass>
where TowerClass
is your class that extends ModTower
.
When you do this, instead of if requiring you to override ModifyDisplayNode(UnityDisplayNode node)
, it'll require you to override UseForTower(int[] tiers)
.
UseForTower
simply takes in an int[3]
of the Tower's tiers and just returns true
or false
for if your Tower should use this Model at those given tiers.
ModifyDisplayNode
is not required to be overridden, but that's just because it now has the default behavior of setting the Mesh Texture of the Node to be a .png file with the same name as the class. If you want to do something more than that, you'll still want to override this method.
AS OF 4/11/2023 NEW WIKI EDITS ARE BEING MAINTAINED AT https://gurrenm3.github.io/BTD-Mod-Helper/wiki
Join our Discord server: https://discord.gg/PBwGjDQ4vX