L4D2 EMS/Appendix: Spawning Infected
From Valve Developer Community
As in L4D, the Director is really in charge here. You can give the director hints, you can poke and prod the director to do specific things. But at the end of it all, you are configuring it and letting it run. With that in mind, there are a fair number of tools you have available for this.
- The "Stage" the Director is running
- This is something like PANIC (where the director uses the option table to decide what sorts of things comprise and PANIC event, and when it is done) or ESCAPE or DELAY
- The Options table
- This is the configuration the director uses for all "controlling the game" type decisions - what sorts of specials and how many it can spawn, how big the main mobs are, etc.
- The (last resort) "z_spawn" attempt
- This is essentially a table driven version of the z_spawn console command, callable from Squirrel. It is ok to use for specific one-shot type spawning of a special, but not really made for significant use or complex scenarios.
Where do spawns happen
In L4D, each map has a computed flow, from the start to end. When spawning mobs, they can be spawned ahead in the flow or behind. And some special ones (like a tank) will always spawn ahead and wait for the players to come to them. Plus of course the director wants spawns to be not too close and not too far, and not in line of sight. It also tracks nav mesh areas that have recently spawned mobs and doesn't reuse them, for instance.
For the new expanded mutations, that really isn't enough flexibility. In particular, in a mutation that involves staying in a confined area, you want to spawn all around it, not "up" or "down" the flow for some path that isn't part of the mutation. And you don't want areas to be used up. And you might want spawns from very specific areas, like the old boarded up house, or down behind the stadium. So we've added a bunch of new flags and settings to try and expand the variety of spawn location control. That said, remember... the Director is still in charge, and is sometimes the decisions it makes are a bit unfathomable.
Anyway, here are a bunch of SessionOptions that configure the Director's spawn behavior - some old, some new
- SpawnSetRule: What general rule does the director use for spawning. Choices are
- SPAWN_FINALE spawn in finale nav areas only
- SPAWN_BATTLEFIELD spawn in battlefield nav areas only
- SPAWN_SURVIVORS use the areas near/explored by the survivors (@TODO: is this actually right?)
- SPAWN_POSITIONAL use the SpawnSetPosition/Radius to pick the spawn area
- SpawnSetRadius/SpawnSetPosition: A radius in units, a Vector(x,y,z) center point for POSITIONAL spawning
- SpawnDirectionMask: a bitfield (using SPAWNDIR_N, _NE, _E, etc) of directors to spawn from _relative to_ a map entity named "Compass" in your map. So the idea is that if you are making a mutation in a confined area, put the compass at the middle (angle determines north) and then you can spawn relative directions around it. Note this layers onto the SpawnSetRule - i.e. if you set a POSITIONAL rule south of the compass, and then set a SpawnDirectonMask of SPAWNDIR_N, the Director will never find a valid place to spawn (since the position is saying "pick from this radius south of here" and the mask is saying "now take that list of valid places and find one north").
- EnforceFinaleNavSpawnRules:@TODO is this real? what does it do?
- WanderingZombieDensityModifier: Set to 0 to have no wandering zombies, else there will still be wanderers even if you are have set other fields to 0 and arent in a panic.
Panic Waves... and how much Panic they cause, and when the Director decides they are done
- MegaMobSize (and CommonLimit) A Panic lasts until MegaMobSize commons spawn, and no more than CommonLimit will ever be out at once. So MegaMobSize 50 CommonLimit 2 is a long slow gentle PANIC, and MegaMobSize 80 CommonLimit 80 is over instantly, with a lot of zombies around. MegaMobSize/CommonLimit 1000 is a good way to crash the game.
- <SpecialType>Limits: No more than this # of this type of special will be up at once. _NOT_ how many come during the wave - just max at one time
- Total<SpecialType>: If you want 10 boomers in the wave, set this to 10. (Note: ignored if Max<SpecialType> is 0. Also ignored if not running in the mutation mode.
- TotalSpecials: Dont care what type, but need this many specials before being "done"
- MaxSpecials: No more than this many specials can be out at once