How to make a tower - Praytic/youtd2 GitHub Wiki
Introduction
The following steps describe how to make a tower based on an existing tower from the original game. You may also use these steps to create a new custom tower.
Define tower properties
- See tower properties on this website: https://interactive.youtd.best/towers/
- When you've found your tower, open it's family by clicking on the "Family ID" number. This will show all of the towers in the family.
- Open tower_properties.csv in a spreadsheet editor.
- When opening the file, a dialog with options should come up. Select "Comma" as a separator and accept the dialog.
- Add a new row below the first row, the one that contains column names.
- Fill in properties.
- Note that everything related to specials, spells and other effects is defined in scripts, not the csv file.
- Repeat for other towers in the family.
Create tower script
- Create new script in the
Scenes/Towers/TowerBehaviors
folder. - Select
TowerBehavior
as base class of the script. - Name the script like this:
[name of first tier tower without spaces] + 1.gd
. For example:TinyShrub1.gd
.
This script file is used to define tower spells and effects. Only one script is created per tower family because scripts for towers of same family do the same thing with increasing numbers for each tier. This means that one script can be defined and change values based on tower tier.
You can learn about writing the tower script on this page: How to script a tower.
Create tower sprite
- Create new scene in the
Scenes/Towers/TowerSprites
folder. - Select
Sprite2D
as root type of the scene. - Name the scene file like this:
[name of first tier tower without spaces] + [tier number].tscn
. For example:TinyShrub3.tscn
. - Repeat for all tiers of the tower family.
You should define the following properties of the tower sprite:
- Texture of the sprite
- Position of the sprite
- Scale of the sprite
Load tower in the game
Once you have finished the tower script, sprite scene and added properties, the game will load the tower automatically into the game.