You can read and reply to posts and download all mods without registering.
We're an independent and non-profit fan-site. Find out more about us here.
This is based on the LGS Grimoire, examining the OMs plus my own experimentation. Thanks are also due to Telliamed and Nameless_voice for advice and for custom scripts. Any comments or corrections, please PM The Pixie at TTLG.
The Ecology is a pretty complicated construction, but a standard feature of Shock missions. At its simplest, it consists of an Ecology object, which determines the timing and numbers, a monster generator (such as a DirectMonsterGen), which determines what is spawned. But it can be much more complicated than that...
The Ecology object
The Ecology object comes with the TriggerEcology script on it.
Every ecology on the level has its own identifying number. You assign this by adding the Script --> EcoType property, with some number unique to that level. All spawned AIs are given this property; it can then be used by the game engine to track the population of the ecology. You can give AIs this property so they are considered part of the ecology from the start.
Apart from the EcoType, the other settings for the Ecology object are done through the Script --> Ecology property (there is also an EcoState property, used in-game). The Ecology checks its population every N seconds (where N is the period field value). If the number of AIs is below the minimum, it sends a TurnOn, if between the minimum and maximum, there will be a 1 in P chance of a TurnOn signal (where P is the random field value). If the count is over the maximum, no signal is sent. Incidentally, the average time between TurnOn messages if between the maximum and the minimum is N times P, so if N is 10 seconds, and P is 6, you will get AIs spawning on average every 60 seconds.
The Ecology has two modes, Normal and Alarm, each has its own set of parameters. The Alarm values are used if the Ecology goes into alarm mode. For the alarm values there is also a recovery value; the number of seconds until it resets (it gets very confused if this is left at 0 and a Security Camera is attached, by the way).
By the way, there is an alernative script, TriggerEcologyDiff, which does more-or-less the same, but the spawning parameters are affected by configuration values in shock.cfg, so can be adjusted by the player. These are no_spawn lower_spawn_min and raise_spawn_rand
no_spawn
lower_spawn_min
raise_spawn_rand
Monster Generator
The Ecology has to be SwitchLinked to a marker or trap with the TrapSpawn script on it. DirectMonsterGen (for alarm ecologies) and RandMonsterGen (for normal ecologies) are traps set up like this with different default flags. While the Ecology determines the timing, it is the monster generator that determines what is spawned.
As well as the script, this also needs the Script --> EcoType property and the Script --> Spawn property. When an AI is spawned, the script will add the EcoType property to the AI, giving it the same value that it has itself. The Ecology object can then track exactly how many AIs are around, and behave accordingly. It is therefore necessary to set the EcoType property on the monster generator to the same value as it has on the Ecology object.
The Script --> Spawn property has four pairs of fields to set up up to four different AIs. The first field of the pair is the AI name as it appears in the hierarchy, the second value is the relative probability of that AI. Looks to me as though LGS originally did these as percentages, then tuned, as they seem to add up to somewhere around 100. You can leave fields blank if you want less than four AI types. To spawn new monsters, you will have to edit the hierarchy, which means making a custom gamesys (there are plenty of other good reasons to do that).
The final field in the Script --> Spawn property is called Supply, and is the maximum number of AIs that the trap will generate. Set to zero if you do not want a limit. A note by Lance Botelle has another idea (see here) but this is what I found.
The field before that is a set of flags.
Spawn Markers determine where the monsters will appear. They are actually the same as Markers (or Traps if it comes to that), but if you use Spawn Markers, you will know what they are for when you look through your mission in three months time.
Each Spawn Marker must have a SpawnPoint link from the generator. Make sure you put them high enough off the ground and away from wall, otherwise the AIs will get stuck (this may mean smaller AIs appear in mid-air though).
A Spawn Marker can have the AI > Ability Settings > Patrol: Does Patrol property; spawned AIs will then patrol. You may be able to use AI > Ability Settings > Patrol: Random Sequence too (LGS did, but Telliamed's script summary suggests not).
Security Systems
A SwitchLink from a Security Camera to an Ecology will allow the Ecology to go into alert mode when the camera sees the player. You also need a SwitchLnk back from the Ecology to the Security Camera, so that after the recovery time, when the Ecology goes back to normal, the camera is reset too.
A SwitchLink from a Security Computer to the Ecology will allow the player to disable the alarm system. Alarm Ecologies should be kept well apart from each other (perhaps restrict to one a level) otherwise the player could get confused when he hacks the Security Station for one, but alerts the camera for another ecology.
Turrets should also have a SwitchLink from the Ecology, so that they also are deactivated when the Security Computer is hacked. You can also put in a SwitchLink from the Ecology to an object with the AlarmScreen script; this will activate a Tweq when in alarm mode (I do not know of any object in the hierarchy that uses this).
Dynamic Ecologies
By inserting QuestBit filters between the Ecology and the monster generator, you can change the system in-game. Say we have a QuestBit called SpawnType, which can change during the name. Connect the Ecology to a QB Filter, the QB Filter to a Anti-QB Trigger, and the Anti-QB Trigger to a DirectMonsterGen. For the two filters, set the Script --> QB Name property to SpawnType, and the Script --> QB Val property to 1 and 2 respectively. Now, the DirectMonsterGen will only generator monsters if SpawnType has the value 1.
You can connect your Ecology to a whole set of these systems, adjusting the Script --> QB Val property appropriately. Each DirectMonsterGen can be set to generator a different set of AIs, but connected to the same Spawn Points. Thus, the AIs that appear will depend on the value of SpawnType. One use of this could be to make the area more difficult as the player gets more skills, weapons and armour.
Alarm and Reset messages
One of the confusing things for me when I started to use ShockEd after building Thief missions was that the SwitchLink is used for much more than the ControlDevice link is. Thief's CD link carries TurnOn messages and TurnOff messages, and that is it. The SwitchLink send them and lots more besides (I guess for any situation where one script communicates with another, but without needing to send any data as well). The TriggerEcology script uses, among others, Alarm and Reset messages. When it receives the Alarm message, it goes into alarm mode, and broadcasts Alarm to all objects that have a SwitchLink from it. When it receives the Reset message (or when the timer expires - which is also done as a message), it goes out of alarm mode, and broadcasts Reset to all objects that have a SwitchLink from it. Those objects that are interested in Alarm and Reset can act accordinly. The Security Computer, Security Camera and Turret, as well as the AlarmScreen script all use these Alarm and Reset messages.
Most objects or scripts do not handle these messages; it would be nice if we could translate Alarm and Reset into TunOn and TurnOff, and then link all sorts of other devices into the security system... And this is pretty easy with custom scripts. Custom scripts may seem scary, but they are actually pretty easy to use. The one you need is NVRelayTrap, in the module NVScript.osm. You will need to download the file from here:
NVScript v1.2.0
Unzip it, and put the file NVScript.osm into your SS2 directory. You need to ensure that anyone playing your FM also has this file. In ShockEd, in the command area, type script_load nvscript That loads in the all the scripts in the module, just as you did with allobjs.osm. You only need to do that once for your FM, to have all the new scripts available.
script_load nvscript
To make a trap that will translate messages, create a Traps object, add the property S --> Scripts: NVRelayTrap The NVRelayTrap script simply takes a message, and passes it on (just like a Relay Trap in Thief), however, you can configure it to respond to or send any message you like.
S --> Scripts: NVRelayTrap
The Alarm2TurnOnTrap: To translate from Alarm and Reset to TunOn and TurnOff, add the property:Scripts --> Objlist arg: NVRelayTrapOn="Alarm";NVRelayTrapOff="Reset"This tells the script to treat incoming Alarm message as TurnOn message (and ignore incoming TurnOn messages), and Reset message as TurnOff. So now, if it receives an Alarm message, it will respond, and pass on a TurnOn (which it defaults to).
Scripts --> Objlist arg: NVRelayTrapOn="Alarm";NVRelayTrapOff="Reset"
The TurnOn2AlarmTrap: To translate from TunOn and TurnOff to Alarm and Reset, add the property (notice the extra 'T's)Scripts --> Objlist arg: NVRelayTrapTOn="Alarm";NVRelayTrapTOff="Reset"This tells the script to send out Alarm instead of TurnOn and Reset instead of TurnOff.
Scripts --> Objlist arg: NVRelayTrapTOn="Alarm";NVRelayTrapTOff="Reset"
SwitchLink from the Ecology to an Alarm2TurnOnTrap to lights that come on during a security alert, to security doors that automatically close during an alert, to toxic gas emission, etc. SwitchLink from panic buttons, tripwire traps and (via inverters) reset buttons to a TurnOn2AlarmTrap and then to the Ecology.
Level design
LGS recommend using separate ecologies for alarms or normal spawning, and an important difference is that your alarm ecologies should have the GotoLoc flag set on the generator, so monsters go straight to the player. The DirectMonsterGen trap is set up for this.
For normal ecologies, use RandMonsterGen trap, which does not have GotoLoc turned on. You can have several normal ecologies, perhaps having each spawn a different set of monsters, appropriate to the area. The normal Ecology object I examined in medsci1.mis (1187) had a period of 120, minimum of 1, maximum of 2, and a rand of 3. The RandMonsterGen trap had Raycast, rather than PlrDist, as well as SelfMarker and was linked to four Spawn Points, all well spread out, and placed in corridors. Monsters will materialise in places where it is believable that they could have come from "the other direction" whereever the player is, and will not spawn when the player will see it happen. The Spawn Points have AI Patrol set on them, so the AIs will wander around and cover more ground.
Alarm ecologies should be fairly small so that AIs arrive promptly when alarmed, and are not still trying to reach the player five minutes after the alarm has stopped. Position of the Security Computer needs much consideration; can it be hacked before the camera sees the player, can it be quickly reached once in alarm mode? If you have more than one alarm ecology, link all your Security Computers to every ecology, so that hacking the computer will disable them all (unless thy are well separated, and the player cannot get from one to the other during the two minutes of grace.
The alarm ecology in medsci1.mis (109) has a period of 15, minimum of 2, maximum of 2, recovery of 120 and a rand of 0. The DirectMonsterGen trap had Raycast as well as PlrDist, and SelfMarker and was linked to one Spawn Point. The Security Camera is at a corner of a corridor; the Spawn Point and the DirectMonsterGen were placed at either end of the corridor, behind doors to other corridors.
The Demo Mission
The demo mission of this post tries to illustrate some of these concepts. To use it, unzip the file, and open it in DromEd. There are no extra files included, but it will work best if you have NVScript.osm in your SS2 directory.
There are two Ecology systems in the large open area. The first is a simple, normal Ecology, spawning monsters continuously, on either side of the bridge. The generated AIs are set to patrol back and forth over the bridge.
The second Ecology is rather more complicated. It is an Alarm system, connected to a security camera, a turret and a security computer. You can hack the security computer to disable the turret and ecology.
Also, on the left there is an alarm screen (of sorts; the command elevator screen will change to a engineering elevator screen when the system is alarmed - it was the best I could find in the hierarchy). This uses the AlarmScreen script, which activates the Tweq --> Model property, changing the screen. You could use any two objects. I set this up with (but I am no expert at Tweq):Tweq --> Model: Stop Tweq, Wrap, Scripts, [None], 0, elecom, eleng,,,,Tweq --> ModelsState: [None], [None], 0, 0
It also illustrates how to set up a dynamic Ecology. The buttons right of the Security Computer set the QuestBit SpawnType, allowing you to choose whether hybrids, cyborgs or rumblers are generated (rumblers will only appear in the two furthest Spawn Points, by the way, and are a bit slow as they only just fit). SpawnType is initially zero, stopping all spawning; you will have to press one to get anything to spawn.
The upper button left of the Security Computer bypasses the ecology altogether, and will cause an AI to spawn instantly. It just sends a TurnOn message straight to the QB filters and generators.
The lower two buttons left of the Security Computer use NVRelayTrap to allow you to put the ecology in and out of alarm mode (if NVScript.osm is in your SS2 directory). The light over the switches to the right goes on when the ecology is in alarm mode, and out again afterwards. An ambient sound should also be heard.