Smart Terrain Tutorial

From Mod Wiki

Lately some people asked me how to create and script smart terrains. To avoid responding for each single email i decided to create this little tutorial. Before i start i would like to tell you that i'm not an expert in this kind of stuff and some things are still not clear for me so i might not be able to explain it properly.
My English isn't perfect so please bear with me. Also i will use ST as Smart Terrain abbreviation. This tutorial treats about npc's STs but for mutants it's almost the same. I assume you are familiar with:

First you have to think about your ST, where to spawn it, how many npcs/mutants will "work" for your ST, when ST should be activated/terminated, how many states your ST will have and so on. I guess the best way would be to show you how to get it working by an example. So let's say we want to spawn ST in Cordon for 3 bandits.

type is a name of our new ST (required)
cond describes conditions which have to be met (optional)
capacity ST npcs/mutants quantity i.e. how many npcs/mutants our ST can handle (required)
squad, groups no idea what they are used for, maybe they are not used at all but i might be wrong (both are optional)
respawn name of the stash (blue box) where items will be spawn when ST respawn will be called (optional)

2. Spawning npcs/mutants and assigning (binding) them to our ST: in this case for each mutant/npc we have to add to its logic:

custom_data= <<END[smart_terrains]esc_bandits_smart_terrain= true
END

3. Adding job (logic) for each npc/mutant from our ST (for each state). Let's say our ST have two states: state 0 (describes what npcs/mutants are doing during day) and state 1 (during night). We have 3 bandits, so say: