Your First Left 4 Dead Map

From Valve Developer Community
Jump to navigation Jump to search

This article is currently a work in progress and will not likely be completed until after Left 4 Dead's SDK is released.
Right now, this page is mostly a collection of notes.


This tutorial will cover the basics of Left 4 Dead map creation. It will explain the required entities, such as the director, weapons, and spawns. It will also answer some of the questions that Left 4 Dead mappers will have. This tutorial is not intended for new mappers: Basic level construction is already covered in other topics.


Tut title.png

Introduction sequences

In the first chapter, to create the "zoom in effect" the game uses 4 "info_survivor_position" entities and 4 "point_viewcontrol_survivor" entities. Although leaving these 8 entities out won't create any problems, the introduction sequence should at least be considered as a final touch before releasing a map to the public.

  • logic_choreographed_scene
  • point_viewcontrol_multiplayer
  • point_viewcontrol_survivor
  • info_survivor_position
  • env_fade
  My Output > Target Entity Target Input Parameter Delay Only Once
Io11.png OnGameplayStart director ForceSurvivourPosition   0.00 No
Io11.png OnGameplayStart director ReleaseSurvivourPosition   0.01 No

Spawn areas

The initial spawn area consists of:

  • an info_player_start to give players a starting point
  • health kits, usually 4 weapon_first_aid_kit_spawn entities
  • 2 weapons; weapon_smg_spawn and weapon_pumpshotgun_spawn.
  • an ammunition resupply, weapon_ammo_spawn

For spawn areas in later chapters of the campaign, you do not have to keep using the same weapons you used in the first map as most players will likely have already swapped these for other more powerful weapons they've found along the way. These more powerful weapons you can use in the spawn areas for the later chapters will usually consist of:

  • a weapon_rifle_spawn, weapon_autoshotgun_spawn, and a weapon_hunting_rifle_spawn.

If your spawn area has a "prop_door_rotating_checkpoint" to exit by, make sure the model is set to models/props_doors/checkpoint_door_01.mdl, the keyvalue "body" has value of 1, the Spawn Position is set to "Closed" (spawnpos keyvalue 0), and the "Starts Open" flag is unchecked.

The Director

Instead of fixed spawn points for enemies, Left 4 Dead uses the "Director" to place enemies and items in varying positions and quantities based upon each player's current situation, status, skill and location.

  • info_director

Creating areas for the infected to spawn.

The director will spawn infected that are out of the line of sight, so for particularly difficult maps have plenty of places out of sight. Sometimes a spawn area is outside the normal player boundary. To let the infected into the playable area, there must be a func_simpleladder (with team set to 2) on the back side of the barrier, for them to climb over.

Item and weapon caches

Setting spawn flags to randomize the locations.

  • weapon_molotov_spawn
  • weapon_pipe_bomb_spawn
  • weapon_pistol_spawn
  • weapon_pain_pills_spawn
  • weapon_ammo_spawn
  • weapon_smg_spawn
  • weapon_first_aid_kit_spawn
  • weapon_hunting_rifle_spawn
  • weapon_rifle_spawn
  • weapon_autoshotgun_spawn
  • weapon_pumpshotgun_spawn

Rescue closets

Bringing dead players back into the game. Players respawn in a random closet that only their teammates can let them out of. Respawning players come back with basic equipment and without full health.

Rescue closets are fairly basic and only consist a room with containing three info_survivor_rescue entities with a prop_door_rotating to enter and exit by.

Panic events

Triggering the info_director and summoning the horde.

  • info_game_event_proxy
  • ambient_generic
  • logic_timer
  • Examples
    • Car alarms
    • Door alarms
    • Fire alarms
    • Smoke detectors
    • Metal detectors
    • Explosions

Crescendo events

Intermediate objectives. "Crescendo Events" are much like smaller versions of the big finale battle at the end of each campaign, and occur at interesting places along the way. There setup is very similar to panic events, except that they cannot be skipped. An in-game example being the Waterworks part of No Mercy, the survivors must fend off a horde of infected while they wait for the lift to arrive.

  • func_button
  • filter_activator_team
  • info_game_event_proxy
  • logic_relay
  My Output > Target Entity Target Input Parameter Delay Only Once
Io11.png OnTrigger director PanicEvent   1.00 No


The safe house and changing levels

Each campaign is divided into several chapters marked by safe rooms, which are checkpoints where players can heal, re-arm, and dead players can return.

  • prop_door_rotating_checkpoint
  • info_landmark

One method for changing levels

Add a trigger_changelevel inside the safe house at the end of the level and have it come in contact with the floor space inside the room. The trigger brush doesn't necessarily have to overlap the floor space, but it does have to at least touch it, or a good portion of where the nav square(s) will be generated. If the trigger_changelevel doesn't come in contact with the floor space, you will have nav errors when the map is loaded and may have to manually mark the nav squares.

Make sure the info_landmark is named and that the landmark name is specified inside the trigger_changelevel settings along with the name of the next map to be loaded. For the prop_door_rotating_checkpoint, make sure the model is set to models/props_doors/checkpoint_door_02.mdl and the "Starts Open" option is checked inside the "flags" tab.

Building the navigation mesh

For survivor bots and infected to be able to move, you will need to create a navigation mesh ("mapname.nav" file) for your map. To build a basic mesh you need to have the map already compile and loaded, then open up the console in game and type the following:

sv_cheats 1
nav_edit 1
nav_mark_walkable
nav_generate
nav_analyze
nav_edit 0
sv_cheats 0

The map is reloaded twice during the process, once after nav_generate and again after nav_analyze, but the game should stay in edit mode when the map is reloaded.

Save fine tuning the mesh until after you are completely finished with the map's layout. The build sequence above should only be used for testing purposes. A nav mesh should be thoroughly examined and edited before releasing a map.

Note.pngNote:For more information related to advanced mesh creation and editing, please refer to Navigation Meshes.

After a map is compiled and the nav mesh is built, sometimes the director still won't spawn infected after the map is loaded. To fix this, assuming you've built the nav mesh already and "sv_cheats" is set to 1, type "director_stop" then "director_start" (without the quotes). You only have to do this once inside the map, then every time you load the map after that the director should start on it's own.

Again, the console commands to kick start the director are:

sv_cheats 1
director_stop
director_start
sv_cheats 0

NAV Marking

Sometimes you may be able to get rid of nav errors using nav_generate alone, but not always. Sometimes, after building the nav mesh, nav areas inside a map will have to be manually marked using the MARK command via 'mark A', where A is the attribute you wish to mark the nav area with.

For example, if you wanted to create a safe room at the beginning of your map, after turning on nav editing with

sv_cheats 1
nav_edit 1

you'd need to label one nav area at a time by point your reticule at each nav mesh area in the safe room, then typing this into the console:

mark CHECKPOINT

To speed things up, you can use the nav gui interface by opening up the console again and typing:

nav_gui

With the nav gui enabled, you can now left click multiple meshes, and use the mark CHECKPOINT console command to set the attribute for all the selected areas.

Two other useful commands with nav marking are:

  • select_with_attribute A
    • This selects all nav areas marked with the attribute "A". For instance, by using select_with_attribute CHECKPOINT, all the nav areas that have been marked with the CHECKPOINT attribute would be highlighted.
  • wipe_attributes
    • This removes all the nav attributes assigned to the targeted areas

Once you have finished with nav marking, be sure to save the changes to your map with nav_save, then re-analyze it with nav_analyze

Note.pngNote:More info on the nav marking can be found in the thread here:
Setting up the NAV for autospawning Zombies without triggers (l4dmaps.net).

Finale

Ending the campaign. In the final chapter of each campaign, the players must defend a position from an onslaught of Infected until a rescue vehicle arrives.

  • Setting up the radio
  • Adding rescue vehicles

Notes

Doors

The door model and skin can vary. Use this picture for reference.
Type: prop_door_rotating
Frame Dimensions: width: 56, height: 104
World Model: models/props_doors/doormainmetal01.mdl

FAQ

  • How do I make the infected spawn?
    • Your map must have a info_director that is enabled, you also may have to use the console command "director_start".


  • Why won't the survivor bots move?


  • Why is the molotov fire / Smoker's smoke cloud not visible in-game?
    • This is usually due to the lack of a env_fog_controller entity. Also, check to make sure there were no errors generated during the map's compile process.


  • Why won't my rescue closets work?
    • Rescue closets will not function correctly if there are any nav errors present in the map (the "NAV ERRORS - Map is unplayable!" message appears in game). You will want to make sure the map's nav mesh is properly set-up.


  • How do I play my map in VS Mode?
    • VS Mode is enabled through the map's name. To create a VS Mode map, simply prefix the map's name with "l4d_vs_". For example, if you had a map named "oiltanker_engineroom", to make it into a VS map, just rename it to "l4d_vs_oiltanker_engineroom".


Error messages and what they mean

Navigation mesh related errors

  • The nav file was built for an older compile.
    • This error message means the ".nav" file for a map is older then the ".bsp" itself. This should not be a problem unless the map's layout was changed after the ".nav" file was created. This can be remedied by running nav_analyze in the console after changes are made to the ".bsp".

The nav errors below will cause the message "NAV ERRORS - Map is unplayable!" to be displayed in game when the map is loaded.

  • Missing nav file.
  • Missing Battlefield check found N areas
  • GetGoalArea: Cannot find SPAWN_RESCUE_CLOSET area in FINALE, thus cannot guarantee reachability of goal area.
  • GetGoalArea: Cannot find end area - no checkpoint or finale located.
  • ComputeFlowDistances: ERROR - Cannot compute flow.
Note.pngNote:It is possible to remove the "NAV ERRORS - Map is unplayable!" error message. One method found is to make sure your map has an info_player_start, info_director, and a nav mesh, then follow the steps in "One method for changing levels" and "Building the navigation mesh" above.

Others

  • WARN: CL4DBasePanel::UpdateProgressBar called outside of level loading, discarded!
  • Engine Error: 81/ - weapon_ammo_spawn: UTIL_SetModel: not precached: models/props_unique/spawn_apartment/coffeeammo.mdl
  • Engine Error: CModelLoader::FindModel: NULL name
    • This is caused by compiling the map using an outdated FGD. Older FGDs do not have the new values for the env_fog and light_environment entities, therefore you are compiling a BSP with missing information.
  • Assert, File: U:\dev\terror\src\tier0\memstd.cpp, Line: 1623, Assert: ***** OUT OF MEMORY! attempted allocation size: 536873088 ****
    • Underneath this error message, there is a button labeled "Break in Dubugger". Click this. Your game will crash, but once you relaunch, load your map again. It should load up fine the second time.
    • Alternatively, next to the "Ignore this assertion [#] time(s)", putting any number for how many times you would like the engine to skip that error.

See also