SEED - Templates via Spawnargs

From The DarkMod Wiki
Jump to navigationJump to search

Introduction

The SEED can create random entities with random placements. The normal way to do so is to create "target entities" as blueprints/templates. While this method works, it has the drawback that all blueprints/templates need to be spawned as entities at map start, just so the SEED can read out their properties. If then only some of these targets end up used, you just wasted time and memory to spawn/load/process entities and their models/textures, even tho they are never used in the actual map.

If you f.i. wanted to have the SEED spawn randomly either one apple or one pear, the traditional "target" method requires you to place one SEED, one apple and one pear entity, for a total of 3 entities, even tho during runtime only one entity would actually survive. With this method you only need on entity (the SEED itself) and it will only spawn the necessary entities later.

To overcome this, the mechanism of defining targets via spawnargs on the SEED entity was added.

Examples

A few pre-made entities exist that use this technique to spawn a variable amount of entities, f.i. atdm:random_food. You will find them under "darkmod/Randoms" in DarkRadiant when right-clicking and choosing "Create Entity".

Overview

The spawnargs to define a new template always start with template and some optional suffix like "_skin" and so on.

You can use multiple of these by inserting any suffix after "template", and combine it with a overall max_entities count, too:

"remove"           "1"           // remove the SEED after spawning the entities
"wait_for_trigger" "1"           // Optional, wait for a trigger before spawning anything
"max_entities"     "4"           // Will only spawn at most 4 entities
"template"         "atdm:moveable_food_apple"
"template_count"   "3"
"template_skin"    "tdm_fruit_brownish"
"template_1"        "atdm:moveable_food_pear"
"template_1_count"  "2"

This would spawn at most 3 apples and at most 2 pears, but overall not more than 4 entities. Remember to make the SEED space big enough so that all to-be spawned entities will fit!

Spawnargs

template

This is either an entityDef name like atdm:moveable_food_apple, or a model name like models/darkmod/decorative/games/cards_stack02.lwo. In the latter case, "func_static" will be used as class for the template.

template_count

Sets the maximum amount of entities to generate from this template. template_max_entities is an alias for this. If not set, will default to 1.

template_skin

Sets the skin on the template. Can also be a random skin like:

 "template_skin"  "'', red, green"

Other SEED Spawnargs

All the normal SEED spawnargs like seed_combine, seed_floor are supported in the form of template_XYZ. Example

 template         models/darkmod/nature/boletus_tall.lwo
 template_map     splat
 template_offset  0 0 6