Scripting:TWTrapAIEcology: Difference between revisions
The Watcher [PHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs) (Created page with "TWTrapAIEcology is a script that allows a controlled population of AIs to be spawned dynamically during play. Periodically this script will check whether the number of curren...") |
The Watcher [PHRhYmxlIGNsYXNzPSJ0d3BvcHVwIj48dHI+PHRkIGNsYXNzPSJ0d3BvcHVwLWVudHJ5dGl0bGUiPkdyb3Vwczo8L3RkPjx0ZD51c2VyPGJyIC8+YnVyZWF1Y3JhdDxiciAvPnN5c29wPGJyIC8+PC90ZD48L3RyPjwvdGFibGU+] (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
TWTrapAIEcology is a script that allows a controlled population of AIs to be spawned dynamically during play. | TWTrapAIEcology is a script that allows a controlled population of AIs to be spawned dynamically during play. | ||
Periodically this script will check whether the number of currently spawned AIs has reached a configurable population limit. If the count is less than the limit, the script will select an AI archetype to spawn, and then choose a spawn point at which the AI should be created. If AIs are killed and despawn, the population drops, and new AIs will be spawned to replace them. Note that this only works ''if the AI despawns'' - use the TWTrapAIEcologyDespawn script to make that happen | Periodically this script will check whether the number of currently spawned AIs has reached a configurable population limit. If the count is less than the limit, the script will select an AI archetype to spawn, and then choose a spawn point at which the AI should be created. If AIs are killed and despawn, the population drops, and new AIs will be spawned to replace them. Note that this only works ''if the AI despawns'' - use the [[Scripting:TWTrapAIEcologyDespawn|TWTrapAIEcologyDespawn]] script to make that happen. | ||
At most one AI is spawned each time the script checks the current population. This is a deliberate restriction imposed to prevent AIs being spawned on top of each other. | At most one AI is spawned each time the script checks the current population. This is a deliberate restriction imposed to prevent AIs being spawned on top of each other. | ||
Line 7: | Line 7: | ||
The AI archetype is chosen based on links from the TWTrapAIEcology host object to archetypes. By default the script will use weighted random selection if multiple AI archetypes are linked, and if only a single AI archetype is linked that is always used. | The AI archetype is chosen based on links from the TWTrapAIEcology host object to archetypes. By default the script will use weighted random selection if multiple AI archetypes are linked, and if only a single AI archetype is linked that is always used. | ||
[[Image:SpawnPoint.png|thumb|right|320px|Example from demo.osm]] | [[Image:SpawnPoint.png|thumb|right|320px|Example from demo.osm]] | ||
The spawn point is chosen based on links from the TWTrapAIEcology to concrete objects in the world. If multiple spawn points are linked, one is chosen at random, whereas if only one spawn point is linked that one is always used. The default behaviour is to try and find the first randomly selected spawn point that is not visible on screen. | The spawn point is chosen based on links from the TWTrapAIEcology to concrete objects in the world. If multiple spawn points are linked, one is chosen at random, whereas if only one spawn point is linked that one is always used. The default behaviour is to try and find the first randomly selected spawn point that is not visible on screen. If all spawn points are on screen, spawning is aborted. This behaviour can be disabled if desired - the spawn point is sent a TurnOn message when an AI spawns there, so particle effects can be tiggered. | ||
It is important to note that, while a fnord (a Marker or similar) could be used to mark the location of a spawn point, using a standard fnord is '''NOT''' | It is important to note that, while a fnord (a <code>Marker</code> or similar) could be used to mark the location of a spawn point, using a standard fnord is '''NOT recommended''' if you want to spawn AIs off screen. fnord objects are not rendered, and this means that the engine can not determine whether the object is on screen: it will always say it is not because, well, you can't see it; it's not rendered! While this is a fine and useful attribute for a normal fnord to have, if you want to make sure that AIs are always spawned off screen, you can't use a fnord unless you give it a transparent, physicsless object and change its Render Type to 'Normal'. An example using this setup can be found in the TWScript Demo mission. | ||
Revision as of 17:29, 21 June 2020
TWTrapAIEcology is a script that allows a controlled population of AIs to be spawned dynamically during play.
Periodically this script will check whether the number of currently spawned AIs has reached a configurable population limit. If the count is less than the limit, the script will select an AI archetype to spawn, and then choose a spawn point at which the AI should be created. If AIs are killed and despawn, the population drops, and new AIs will be spawned to replace them. Note that this only works if the AI despawns - use the TWTrapAIEcologyDespawn script to make that happen.
At most one AI is spawned each time the script checks the current population. This is a deliberate restriction imposed to prevent AIs being spawned on top of each other.
The AI archetype is chosen based on links from the TWTrapAIEcology host object to archetypes. By default the script will use weighted random selection if multiple AI archetypes are linked, and if only a single AI archetype is linked that is always used.
The spawn point is chosen based on links from the TWTrapAIEcology to concrete objects in the world. If multiple spawn points are linked, one is chosen at random, whereas if only one spawn point is linked that one is always used. The default behaviour is to try and find the first randomly selected spawn point that is not visible on screen. If all spawn points are on screen, spawning is aborted. This behaviour can be disabled if desired - the spawn point is sent a TurnOn message when an AI spawns there, so particle effects can be tiggered.
It is important to note that, while a fnord (a Marker
or similar) could be used to mark the location of a spawn point, using a standard fnord is NOT recommended if you want to spawn AIs off screen. fnord objects are not rendered, and this means that the engine can not determine whether the object is on screen: it will always say it is not because, well, you can't see it; it's not rendered! While this is a fine and useful attribute for a normal fnord to have, if you want to make sure that AIs are always spawned off screen, you can't use a fnord unless you give it a transparent, physicsless object and change its Render Type to 'Normal'. An example using this setup can be found in the TWScript Demo mission.
|
|