Covering terrain: advanced template selection
Table of contents:
- 1. Templates with multiple names
- 2. Referencing multiple templates
- 3. Using template maps
- 4. Related articles & example map
1. Templates with multiple names
In the previous tutorial, Covering terrain with props, we gave all of our templates the same name. This made it easy to cover terrain with a variety of props, but the downside is that we can't select a specific template. What if we want to cover one area with a standard variety of shrubs, rocks and cactuses, and another area with only shrubs?
It turns out that templates can be given multiple names, by using a comma-separated list:
property name | value |
---|---|
Name | prop_desert, prop_cactus |
In the above picture, each template has both a generic name (prop_desert
) and a specific name (prop_cactus
, prop_rock
or prop_shrub
). This means that we can keep using the name prop_desert
to get a variety of props, but we can also use a specific name to select a particular template:
2. Referencing multiple templates
Similar to how templates can have multiple names, instance-creating macro entities can also reference multiple templates. For example, a macro_cover
entity with the following settings will randomly select either prop_shrub
or prop_rock
for each instance that it creates:
property name | value |
---|---|
Template entity | prop_shrub, prop_rock |
It's also possible to specify custom weights. For example, the following gives an 80% chance (4/5) of selecting a shrub, and a 20% chance (1/5) of selecting a rock:
property name | value |
---|---|
Template entity | prop_shrub: 4, prop_rock: 1 |
This lets us use different ratios for different areas:
3. Using template maps
So far, we have only used local templates. But what if we wanted to use our templates in another map? With local templates, we'd have to copy them to that map, but that's a bit tedious and it can quickly become hard to manage templates when they've been copied into many different maps.
Fortunately there's a better way: we can put our templates inside 'template maps'. Any map (.map, .rmf or .jmf file) that is placed in the MESS\template_maps
directory (or whatever your template-maps-directory is set to) can be used by macro entities like macro_cover
. For example, the following macro_cover
will select the prop_shrub
template that is inside MESS\template_maps\examples\desert_props.map
:
property name | value |
---|---|
Template map path | examples/desert_props.map |
Template entity | prop_shrub |
If only a 'Template map path' is specified, but no 'Template entity', then the entire template map is used as a template. We can make use of that by putting the following macro_insert
entity at the center of our desert_props.map
template map:
property name | value |
---|---|
Template entity | prop_desert |
This means that we can use examples/desert_props.map
without having to specify a template entity, and it'll automatically give us one of the prop_desert
templates: