Your First Left 4 Dead Map: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
(52 intermediate revisions by 17 users not shown)
Line 1: Line 1:
{{Split-apart}}
{{LanguageBar}}
<center>
 
{| border=1 cellpadding="2" cellspacing="1"
|
'''This article is currently a work in progress and will not likely be completed until after Left 4 Dead's SDK is released.'''<br>'''Right now, this page is mostly a collection of notes.'''
|}
</center><br>
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 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: [[Your_First_Map|Basic level construction]] is already covered in other topics.
This tutorial is not intended for new mappers: The [[L4D Level Design Basics Tutorial]] tutorial covers this topic for novices.
 
----
----
<center>[[Image:Tut title.png]]</center>
<center>[[File:Tut title.png]]</center>


== Introduction sequences ==
[[File:1st_l4d_map_1.gif|frame|right|The map layout.]]
In the first chapter, to create the "zoom in effect" the game uses 4 "<code>info_survivor_position</code>" entities and 4 "<code>point_viewcontrol_survivor</code>" 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.
For this tutorial we will be making a simple 2 level campaign that never ends. Sounds fun, right?  Well, the purpose really isn't to create a full campaign, but to explain the basics of level construction in L4D.
* <code>logic_choreographed_scene</code>
* <code>point_viewcontrol_multiplayer</code>
* <code>point_viewcontrol_survivor</code>
* <code>info_survivor_position</code>
* <code>env_fade</code>
:{| border=1 cellpadding="2" cellspacing="1"
|- align=left
! &nbsp;
! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once
|-
| [[Image:Io11.png]] || OnGameplayStart || director || ForceSurvivourPosition || &nbsp; || 0.00 || No
|-
| [[Image:Io11.png]] || OnGameplayStart || director || ReleaseSurvivourPosition || &nbsp; || 0.01 || No
|}


== Spawn areas ==
<br>
The initial spawn area consists of:
First, lets cover what our L4D campaign will need to work right:
* an <code>info_player_start</code> to give players a starting point
* A director
* health kits, usually 4 <code>weapon_first_aid_kit_spawn</code> entities
* Spawn points for each survivor
* 2 weapons; <code>weapon_smg_spawn</code> and <code>weapon_pumpshotgun_spawn</code>.
* 2 safe room doors
* an ammunition resupply, <code>weapon_ammo_spawn</code>
* Some weapons, ammo, and health
* A rescue closet
* A change-level
* A fog controller (for the particle effects)
<br>
The image on the right will be used for our map layout during this tutorial.{{clr}}


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:
== The Spawn Room ==
* a <code>weapon_rifle_spawn</code>, <code>weapon_autoshotgun_spawn</code>, and a <code>weapon_hunting_rifle_spawn</code>.


If your spawn area has a "prop_door_rotating_checkpoint" to exit by, make sure the model is set to <code>models/props_doors/checkpoint_door_01.mdl</code>, the keyvalue "body" has value of 1, the Spawn Position is set to "Closed" (spawnpos keyvalue 0), and the "Starts Open" flag is '''un'''checked.
<b>Survivor Spawns:</b>
<br>
In order for each of the survivors to have their own spawn point, you must have three different types of entity in your map. These are <code>info_player_start</code>    <code>info_director</code> and <code>info_survivor_position</code>.<br><br>


== The Director ==
<b>1)</b> Add one <code>info_player_start</code> and an <code>info_director</code> into your spawn room. (<b>Note:</b> these can go anywhere). Name the <code>info_director</code> 'director'.<br>
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.  
<b>2)</b> Place four <code>info_survivor_positions</code>. Where you put these is where the survivors will start.(<b>Note:</b> if you want each spawn to spawn a random survivor, just leave it as it is. However, if you want to specify where a certain survivor will spawn you must set the <b>SurvivorName</b> flag to that survivor's name.<br>
* <code>info_director</code>  
<b>3) </b>Double click on your <code>info_director</code> to bring up the properties screen. Goto the output tab, where we will add two outputs to force the survivors to goto their proper spawns. <br>
<b>4) </b>Add the outputs:<br><br>


=== Creating areas for the infected to spawn. ===
<code>OnGameplayStart,  director,  ForceSurvivorPositions, Delay = 0.00, Fire only once = no</code><br>
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 <code>func_simpleladder</code> (with team set to 2) on the back side of the barrier, for them to climb over.
<code>OnGameplayStart,  director, ReleaseSurvivorPositions, Delay = 0.01, Fire only once = no</code><br><br>
----


== Item and weapon caches ==
Setting spawn flags to randomize the locations.
* <code>weapon_molotov_spawn</code>
* <code>weapon_pipe_bomb_spawn</code>
* <code>weapon_pistol_spawn</code>
* <code>weapon_pain_pills_spawn</code>
* <code>weapon_ammo_spawn</code>
* <code>weapon_smg_spawn</code>
* <code>weapon_first_aid_kit_spawn</code>
* <code>weapon_hunting_rifle_spawn</code>
* <code>weapon_rifle_spawn</code>
* <code>weapon_autoshotgun_spawn</code>
* <code>weapon_pumpshotgun_spawn</code>


== 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 <code>info_survivor_rescue</code> entities with a <code>prop_door_rotating</code> to enter and exit by.


== Panic events ==
Now that that is done place a <code>env_fog_controller</code> in your map. make sure the fog_controller's "Fog Enable" property is set to "Yes". This will control particles ect. You can also make your map foggy using this entity.
Triggering the info_director and summoning the horde.
* <code>info_game_event_proxy</code>
* <code>ambient_generic</code>
* <code>logic_timer</code>


* '''Examples'''
For a supplies area create a small brush to act as a table and add these entities on top:
** Car alarms
* health kits, 4 <code>weapon_first_aid_kit_spawn</code> entities
** Door alarms
* 2 weapons; <code>weapon_smg_spawn</code> and <code>weapon_pumpshotgun_spawn</code>.
** Fire alarms
* an ammunition resupply, <code>weapon_ammo_spawn</code>, set the world model to <code>models/props/terror/ammo_stack.mdl</code>
** Smoke detectors
** Metal detectors
** Explosions


== Crescendo events ==
Now for an exit add a "<code>prop_door_rotating_checkpoint</code>" entity. For it's properties, name it "checkpoint_exit", set its "body" property to "1", the "Spawn Position" to "Closed" (spawnpos keyvalue 0), the "world model" to "models/props_doors/checkpoint_door_01.mdl", and the make sure the "Starts Open" flag is unchecked. Make sure the side of the door with the EXIT sign in the center is facing the inside of the room.
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.
{{note|If the prop_door_rotating_checkpoint set in anymore then 8 units from the wall outside the safehouse, the infected may try to climb over it.}}


* <code>func_button</code>
That should finish the starting point, but before we move on, lets add a <code>info_landmark</code> to the room as well, name it "landmark_a". Well go more into detail on this later.
* <code>filter_activator_team</code>
* <code>info_game_event_proxy</code>
* <code>logic_relay</code>


:{| border=1 cellpadding="2" cellspacing="1"
== Rescue closets ==
|- align=left
Next we'll make the two small rooms near the number 2 into places for dead players to respawn (referred to as a rescue closets). Rescue closets are fairly basic and only consist of 4 entities, 3 <code>info_survivor_rescue</code> entities and a <code>prop_door_rotating</code>.  Add the 3 <code>info_survivor_rescue</code> entities to the inside of each room. Next up is the door. You will want a space with a width of 56 and height of 104 for the door to sit in, add the <code>prop_door_rotating</code> and set it's world model to "models/props_doors/doormain01.mdl".
! &nbsp;
! My Output > !! Target Entity !! Target Input !! Parameter !! Delay !! Only Once
|- align=left
| [[Image:Io11.png]] || OnTrigger || director || PanicEvent || &nbsp; || 1.00 || No
|}


== The safe house and changing levels ==
Now to connect this map to another inside the campaign with a safe room.  To start with, we'll add another "<code>prop_door_rotating_checkpoint</code>" entity to the entrance of area 3 for the safe houses door.  This one is set up a bit different from the last one.  Open its properties and set the name to "checkpoint_entrance", the "body" property to "0", the "Spawn Position" to "Open Forward" (spawnpos keyvalue 1), the "world model" to "models/props_doors/checkpoint_door_02.mdl", and then make sure the "Starts Open" flag is checked. You want the side of the door with the picture of the house facing outside.


== The safe house and changing levels ==
To finish setting up the transition from one map to the next we still need to add an <code>info_landmark</code> and a <code>trigger_changelevel</code>. First add the <code>info_landmark</code> to the center of the room near the ceiling, then open it's properties and name it "landmark_b".  Now create a large brush to cover the floorspace inside the safehouse and tie it to the <code>trigger_changelevel</code> entity, make sure the brush comes in contact with the floorspace inside the room (doesn't necessarily have to overlap the floor space, but it does have to at least touch it). Open the changelevel's properties and set the landmark name to the one we just created, "landmark_b" and for the "next map" property, enter "lst_l4dmap_b".
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.
* <code>prop_door_rotating_checkpoint</code>
* <code>info_landmark</code>


=== One method for changing levels ===
== Building a navigation mesh ==
Add a <code>trigger_changelevel</code> inside the safe house at the end of the level and have it come in contact with the floor space inside the roomThe 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 <code>trigger_changelevel</code> 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.
For the 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 compiled and loadedOnce the map is running, aim your crosshairs at the floor space, open up the console in game, and then type the following:
: <code>sv_cheats 1; nav_edit 1; nav_mark_walkable; nav_generate</code>


Make sure the <code>info_landmark</code> is named and that the landmark name is specified inside the <code>trigger_changelevel</code> settings along with the name of the next map to be loaded. For the <code>prop_door_rotating_checkpoint</code>, make sure the model is set to <code>models/props_doors/checkpoint_door_02.mdl</code> and the "Starts Open" option is checked inside the "flags" tab.
The map will be reloaded after you type nav_generate, and if all goes well, we should no longer have the "NAV ERRORS - Map is unplayable!" message displayed on the screen when the map loads. This is because nav_generate assigned certain attributes to the nav mesh through a process known as "nav marking".


== Building the navigation mesh ==
You can see the changes using the "select_with_attribute A" command. What this console command does is select all the nav areas that have been "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.
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:
: <code>sv_cheats 1</code>
: <code>nav_edit 1</code>
: <code>nav_mark_walkable</code>
: <code>nav_generate</code>
: <code>nav_analyze</code>
: <code>nav_edit 0</code>
: <code>sv_cheats 0</code>


The map is reloaded twice during the process, once after <code>nav_generate</code> and again after <code>nav_analyze</code>, but the game should stay in edit mode when the map is reloaded.
For example, with "nav_edit 1" set, you would open the console and type:
: select_with_attribute DOOR
:: 4 nav squares should be highlighted telling the bot AI there is a door in these locations.


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.
: select_with_attribute CHECKPOINT
:: The nav areas in the safehouse at the end of the level should be highlighted.


{{Note|For more information related to advanced mesh creation and editing, please refer to [[Navigation Meshes]].}}
: select_with_attribute RESCUE_CLOSET
:: The two two rescue closets should have there nav squares highlighted


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.
: select_with_attribute ESCAPE_ROUTE
:: Now a lot of nav squares are highlighted forming a path from the player spawn to the nav areas marked "checkpoint" at the end of the level.


Again, the console commands to kick start the director are:
[[File:L4d_select_door.jpg|200px|thumb|left|using select_with_attribute DOOR]]
: <code>sv_cheats 1</code>
[[File:L4d_select_checkpoint.jpg|200px|thumb|left|using select_with_attribute CHECKPOINT]]
: <code>director_stop</code>
[[File:L4d_select_rescuecloset.jpg|200px|thumb|left|using select_with_attribute RESCUE_CLOSET]]
: <code>director_start</code>
{{clr}}
: <code>sv_cheats 0</code>


=== NAV Marking ===
=== 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.
In this case, nav_generate did a fairly good job at locating and assigning the final checkpoint, rescue closets, and other attributes to the nav mesh, but you may not always be so luckyTo manually assign attributes to nav squares, you will need use 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
For example, before we can get our level working correctly, we will have to manually "mark" one additional location on the nav mesh that nav_generate missed, a starting checkpoint. To do this, we need to be in nav editing mode with:
  sv_cheats 1
  sv_cheats 1
  nav_edit 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:
Now inside the starting safe room we will label one nav square at a time by pointing the targeting reticule at them then typing this into the console:
  mark CHECKPOINT
  mark CHECKPOINT
To speed things up, you can use the nav gui interface by opening up the console again and typing:
Or, to speed things up, you can use the nav gui by opening up the console again and typing:
  nav_gui
  nav_gui
[[File:L4d_select_checkpoint2.jpg|200px|thumb|right|the nav mesh now with both checkpoints marked]]
With the nav gui enabled, you can now left click multiple meshes, and use the <code>mark CHECKPOINT</code> console command to set the attribute for all the selected areas.
With the nav gui enabled, you can now left click multiple meshes, and use the <code>mark CHECKPOINT</code> console command to set the attribute for all the selected areas.


Two other useful commands with nav marking are:
If you make a mistake, you can remove a single attribute from a selected nav area by using:
* <code>select_with_attribute A</code>
* <code>nav_clear_attribute A</code>
** This selects all nav areas marked with the attribute "A". For instance, by using <code>select_with_attribute CHECKPOINT</code>, all the nav areas that have been marked with the CHECKPOINT attribute would be highlighted.
** where A is the attribute you wish to remove (eg: <code>nav_clear_attribute CHECKPOINT</code>)
 
Or, if you wanted to remove all nav attributes from the selected area, you could use:
* <code>wipe_attributes</code>
* <code>wipe_attributes</code>
** 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 <code>nav_save</code>, then re-analyze it with <code>nav_analyze</code>
Once you have finished with nav marking, be sure to save the changes to your map with <code>nav_save</code>, then re-analyze it with <code>nav_analyze</code>


{{note|More info on the nav marking can be found in the thread here:}}
== Getting the infected to spawn ==
::[http://forums.l4dmaps.net/showthread.php?t=135 Setting up the NAV for autospawning Zombies without triggers (l4dmaps.net)].
Now that the nav mesh is built, you should be able to get the infected to spawn by using the console commands:
: <code>director_stop</code>
: <code>director_start</code>
You should only have to do this once inside the map, then every time you load the map after that the director should start on its own.


== Finale ==
== Making the second chapter ==
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.
With the first map out of the way, the second map can be made quite easily. Back in Hammer, with the map we just compiled still loaded, go up to the file menu and choose "Save As". Now type in "lst_l4dmap_b" to save the current map under a new name. Go up to the exit menu and hit "Select all", hit CTRL and M to bring up the translation tool and type 180 into the Z field and hit "Ok".
* Setting up the radio
* Adding rescue vehicles


== Notes ==
Change the name of the <code>info_landmark</code> entities so that the one in the starting room is named "landmark_b" and the one in the ending safehouse is named "landmark_a". Remember "landmark_a" we created in the first map?  We're going to link the changelevel in our new map to it, open the trigger_changelevel's properties and replace "landmark_b" with "landmark_a" and "lst_l4dmap_b" with "lst_l4dmap_a". After changing up the names, finish up by compiling the map and repeating the nav creation steps you used for the previous map, don't forget to mark the spawn room with the checkpoint attribute. If all goes well, you should now have a working 2 level campaign.
<!--
This is a rough list of notes for now, eventually these notes should be integrated into this article (if possible), or to separate articles and removed from here.
-->
=== Doors ===
[[image:Doors.jpg|thumb|right|200px|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


* For a basic tutorial on creating and setting up doors in Left 4 Dead, see:<br>[http://forums.l4dmaps.net/f11/doors-in-left-4-dead-t140.html Doors in Left4Dead (l4dmaps.net)] {{clr}}
== Additional possibilities ==
 
For spawn areas in later chapters of the campaign, you do not have to keep using the <code>weapon_smg_spawn</code> and <code>weapon_pumpshotgun_spawn</code> 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 wayThese more powerful weapons you can use in the spawn areas for the later chapters will usually consist of:
== FAQ ==
* a <code>weapon_rifle_spawn</code>, <code>weapon_autoshotgun_spawn</code>, and a <code>weapon_hunting_rifle_spawn</code>.
* '''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".
<br>
* '''Why won't the survivor bots move?'''
** The most likely cause is a faulty or missing ".nav" file. ''See [[Navigation Meshes]]''
<br>
* '''Why is the molotov fire / Smoker's smoke cloud not visible in-game?'''
** This is usually due to the lack of a <code>env_fog_controller</code> entity.  Also, check to make sure there were no errors generated during the map's compile process.
<br>
* '''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.
<br>
* '''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".
<br>
 
== 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 <code>nav_analyze</code> in the console after changes are made to the ".bsp".
 
:{| class=standard-table
|
The nav errors below will cause the message "'''NAV ERRORS - Map is unplayable!'''" to be displayed in game when the map is loaded.
|}
* '''Missing [[Navigation Meshes|nav file]].'''
* '''Missing Battlefield check found N areas'''
* '''GetGoalArea: Cannot find SPAWN_RESCUE_CLOSET area in FINALE, thus cannot guarantee reachability of goal area.'''
** Regarding respawn closets; there are 2 essential steps for making them work properly. Place 3 [[Info survivor position]] entities in a room or closet then in game use the <code>mark RESCUE_CLOSET</code> console command to identify the closet/room as a rescue area. This process is explained above in "NAV MARKING". Equally important is labeling the "player start" and checkpoint meshes using <code>mark CHECKPOINT</code> and <code>mark PLAYER_START</code> respectively.
* '''GetGoalArea: Cannot find end area - no checkpoint or finale located.'''
** This error is due to lack of one of the following: 1.) A missing [[Prop door rotating checkpoint]] entity. 2.) Not identifying a navigation mesh with <code>mark CHECKPOINT</code>. 3.) Not identifying a navigation mesh with <code>mark FINALE</code>.
* '''ComputeFlowDistances: ERROR - Cannot compute flow.'''
** The "Flow" of the map refers to the ability of the AI to travel from the spawn location to the designated Saferoom/final checkpoint. If there are any breaks in the navigation mesh (meshes that are not connected via <code>nav_connect</code> or <code>nav_splice</code>), L4D cannot compute the path necessary to travel the map. {{note|<code>Nav_generate</code> can leave certain essential meshes from being connected, sometimes manual connection is required.}}
 
{{note|It is possible to remove the "NAV ERRORS - Map is unplayable!" error message.  One method found is to make sure your map has an <code>info_player_start</code>, <code>info_director</code>, 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 <code>env_fog</code> and <code>light_environment</code> 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 ==
== See also ==
* [[Left 4 Dead Level Creation]]
* [[Left 4 Dead Level Creation]]
* [[Navigation Meshes]]
* [[Navigation Meshes]]
* [[Left 4 Dead Navigation Meshes]]


[[Category:Left 4 Dead]]
[[Category:Left 4 Dead]]
[[Category:Left 4 Dead level design]]

Latest revision as of 07:55, 16 February 2025

English (en)Português do Brasil (pt-br)Русский (ru)中文 (zh)中文(臺灣) (zh-tw)Translate (Translate)

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: The L4D Level Design Basics Tutorial tutorial covers this topic for novices.


Tut title.png
The map layout.

For this tutorial we will be making a simple 2 level campaign that never ends. Sounds fun, right? Well, the purpose really isn't to create a full campaign, but to explain the basics of level construction in L4D.


First, lets cover what our L4D campaign will need to work right:

  • A director
  • Spawn points for each survivor
  • 2 safe room doors
  • Some weapons, ammo, and health
  • A rescue closet
  • A change-level
  • A fog controller (for the particle effects)


The image on the right will be used for our map layout during this tutorial.

The Spawn Room

Survivor Spawns:
In order for each of the survivors to have their own spawn point, you must have three different types of entity in your map. These are info_player_start info_director and info_survivor_position.

1) Add one info_player_start and an info_director into your spawn room. (Note: these can go anywhere). Name the info_director 'director'.
2) Place four info_survivor_positions. Where you put these is where the survivors will start.(Note: if you want each spawn to spawn a random survivor, just leave it as it is. However, if you want to specify where a certain survivor will spawn you must set the SurvivorName flag to that survivor's name.
3) Double click on your info_director to bring up the properties screen. Goto the output tab, where we will add two outputs to force the survivors to goto their proper spawns.
4) Add the outputs:

OnGameplayStart, director, ForceSurvivorPositions, Delay = 0.00, Fire only once = no
OnGameplayStart, director, ReleaseSurvivorPositions, Delay = 0.01, Fire only once = no




Now that that is done place a env_fog_controller in your map. make sure the fog_controller's "Fog Enable" property is set to "Yes". This will control particles ect. You can also make your map foggy using this entity.

For a supplies area create a small brush to act as a table and add these entities on top:

  • health kits, 4 weapon_first_aid_kit_spawn entities
  • 2 weapons; weapon_smg_spawn and weapon_pumpshotgun_spawn.
  • an ammunition resupply, weapon_ammo_spawn, set the world model to models/props/terror/ammo_stack.mdl

Now for an exit add a "prop_door_rotating_checkpoint" entity. For it's properties, name it "checkpoint_exit", set its "body" property to "1", the "Spawn Position" to "Closed" (spawnpos keyvalue 0), the "world model" to "models/props_doors/checkpoint_door_01.mdl", and the make sure the "Starts Open" flag is unchecked. Make sure the side of the door with the EXIT sign in the center is facing the inside of the room.

Note.pngNote:If the prop_door_rotating_checkpoint set in anymore then 8 units from the wall outside the safehouse, the infected may try to climb over it.

That should finish the starting point, but before we move on, lets add a info_landmark to the room as well, name it "landmark_a". Well go more into detail on this later.

Rescue closets

Next we'll make the two small rooms near the number 2 into places for dead players to respawn (referred to as a rescue closets). Rescue closets are fairly basic and only consist of 4 entities, 3 info_survivor_rescue entities and a prop_door_rotating. Add the 3 info_survivor_rescue entities to the inside of each room. Next up is the door. You will want a space with a width of 56 and height of 104 for the door to sit in, add the prop_door_rotating and set it's world model to "models/props_doors/doormain01.mdl".

The safe house and changing levels

Now to connect this map to another inside the campaign with a safe room. To start with, we'll add another "prop_door_rotating_checkpoint" entity to the entrance of area 3 for the safe houses door. This one is set up a bit different from the last one. Open its properties and set the name to "checkpoint_entrance", the "body" property to "0", the "Spawn Position" to "Open Forward" (spawnpos keyvalue 1), the "world model" to "models/props_doors/checkpoint_door_02.mdl", and then make sure the "Starts Open" flag is checked. You want the side of the door with the picture of the house facing outside.

To finish setting up the transition from one map to the next we still need to add an info_landmark and a trigger_changelevel. First add the info_landmark to the center of the room near the ceiling, then open it's properties and name it "landmark_b". Now create a large brush to cover the floorspace inside the safehouse and tie it to the trigger_changelevel entity, make sure the brush comes in contact with the floorspace inside the room (doesn't necessarily have to overlap the floor space, but it does have to at least touch it). Open the changelevel's properties and set the landmark name to the one we just created, "landmark_b" and for the "next map" property, enter "lst_l4dmap_b".

Building a navigation mesh

For the 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 compiled and loaded. Once the map is running, aim your crosshairs at the floor space, open up the console in game, and then type the following:

sv_cheats 1; nav_edit 1; nav_mark_walkable; nav_generate

The map will be reloaded after you type nav_generate, and if all goes well, we should no longer have the "NAV ERRORS - Map is unplayable!" message displayed on the screen when the map loads. This is because nav_generate assigned certain attributes to the nav mesh through a process known as "nav marking".

You can see the changes using the "select_with_attribute A" command. What this console command does is select all the nav areas that have been "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.

For example, with "nav_edit 1" set, you would open the console and type:

select_with_attribute DOOR
4 nav squares should be highlighted telling the bot AI there is a door in these locations.
select_with_attribute CHECKPOINT
The nav areas in the safehouse at the end of the level should be highlighted.
select_with_attribute RESCUE_CLOSET
The two two rescue closets should have there nav squares highlighted
select_with_attribute ESCAPE_ROUTE
Now a lot of nav squares are highlighted forming a path from the player spawn to the nav areas marked "checkpoint" at the end of the level.
using select_with_attribute DOOR
using select_with_attribute CHECKPOINT
using select_with_attribute RESCUE_CLOSET

NAV Marking

In this case, nav_generate did a fairly good job at locating and assigning the final checkpoint, rescue closets, and other attributes to the nav mesh, but you may not always be so lucky. To manually assign attributes to nav squares, you will need use the MARK command via 'mark A', where A is the attribute you wish to mark the nav area with.

For example, before we can get our level working correctly, we will have to manually "mark" one additional location on the nav mesh that nav_generate missed, a starting checkpoint. To do this, we need to be in nav editing mode with:

sv_cheats 1
nav_edit 1

Now inside the starting safe room we will label one nav square at a time by pointing the targeting reticule at them then typing this into the console:

mark CHECKPOINT

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

nav_gui
the nav mesh now with both checkpoints marked

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.

If you make a mistake, you can remove a single attribute from a selected nav area by using:

  • nav_clear_attribute A
    • where A is the attribute you wish to remove (eg: nav_clear_attribute CHECKPOINT)

Or, if you wanted to remove all nav attributes from the selected area, you could use:

  • wipe_attributes

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

Getting the infected to spawn

Now that the nav mesh is built, you should be able to get the infected to spawn by using the console commands:

director_stop
director_start

You should only have to do this once inside the map, then every time you load the map after that the director should start on its own.

Making the second chapter

With the first map out of the way, the second map can be made quite easily. Back in Hammer, with the map we just compiled still loaded, go up to the file menu and choose "Save As". Now type in "lst_l4dmap_b" to save the current map under a new name. Go up to the exit menu and hit "Select all", hit CTRL and M to bring up the translation tool and type 180 into the Z field and hit "Ok".

Change the name of the info_landmark entities so that the one in the starting room is named "landmark_b" and the one in the ending safehouse is named "landmark_a". Remember "landmark_a" we created in the first map? We're going to link the changelevel in our new map to it, open the trigger_changelevel's properties and replace "landmark_b" with "landmark_a" and "lst_l4dmap_b" with "lst_l4dmap_a". After changing up the names, finish up by compiling the map and repeating the nav creation steps you used for the previous map, don't forget to mark the spawn room with the checkpoint attribute. If all goes well, you should now have a working 2 level campaign.

Additional possibilities

For spawn areas in later chapters of the campaign, you do not have to keep using the weapon_smg_spawn and weapon_pumpshotgun_spawn 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.

See also