Here's a map that includes some tips on making a TD. This is intended to show you how to create a strong foundation to build upon but is not meant to be something you copy 1:1. Obviously each map is unique and has it's own needs. The most important thing here is that it shows you how to setup your map in a structured way, step by step.
Speaking of structure, I recommend avoiding the use of the
For Each action when it comes to logic related to multiple Players. Instead, use a
Player Group variable as they're specifically designed for this type of behavior. I show how to do this in the map.
Here's an example:
-
Player Group - Pick every player in Player_Group_Users_Playing and do (Actions)
-

Loop - Actions
-


Unit - Create 1 Ghoul for Computer at (Center of MyRegion[(Player number of (Picked player))]) facing Default building facing degrees
^ This trigger will only create units for a User if they're actively playing the game. This would be useful if you didn't want Leavers/Unused Players from spawning units.
But maybe at some point you'll change your mind, in which case the fix is extremely simple:
-
Player Group - Pick every player in Player_Group_Users_All and do (Actions)
-

Loop - Actions
-


Unit - Create 1 Ghoul for Computer at (Center of MyRegion[(Player number of (Picked player))]) facing Default building facing degrees
^ I changed the Player Group to one that contains all of your Users regardless of whether they're playing or not.
So in this particular case you would swap the Player Group variable for a different one that contains the correct set of players. OR, let's say that you were referencing this Player Group across 20 different triggers and it'd be a hassle to have to find and change each one. In that case you could simply change which players get added to it in the first place, which would update all 20 triggers in the process. In other words, in a well designed system you can change ONE thing and have it reflect across ALL of your triggers.
TLDR: Smart design like this makes it easy to change, improve, and expand upon your systems throughout the development process. It also makes the creation of triggers a breeze and more enjoyable because you have all of these pre-defined variables that you can quickly reference with confidence -> "I know for a fact that there will only ever be
active users in the
Player_Group_Users_Playing group".