User:Brandished/Sandbox 1
For this tutorial we will be making a simple 2 level campaign that never ends. Sounds fun, right? Well, maybe not, but the purpose really isn't to have 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
- A starting point
- 2 safe house doors
- Some weapons, ammo, and health
- A rescue closet
- A change-level
- A fog controller
Here we have our sample map layout.
Well make the room on the far left the starting point by adding an info_player_start
entity to there. Next, let's add an info_director
and a env_fog_controller
, make sure the fog_controller's "Fog Enable" property is set to "Yes".
For a supplies area will create a small brush to act as a table and add:
- health kits, 4
weapon_first_aid_kit_spawn
entities - 2 weapons;
weapon_smg_spawn
andweapon_pumpshotgun_spawn
. - an ammunition resupply,
weapon_ammo_spawn
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.
That should finish the starting point, but before we move on, lets add a info_landmark
to the room as well, name it "landmark_1". Well go more into detail on this later.
Rescue closets
Next well make this room into a place 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 the room, next up is the door. You will want a space with the dimensions of 56 width by 104 height for the door to sit in. Add the prop_door_rotating
and set it's world model to "models/props_doors/doormainmain01.mdl".
The safe house and changing levels
Now to split this campaign into another chapters with a safe room. To start with, well add another "prop_door_rotating_checkpoint
" entity for the safe houses entrance. This one is set up a bit different then 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 the 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 cneter of the room near the ceiling, then open it's properties and name it "landmark_2". 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_2" and for the "next map" property, enter "map_02".
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 compiled and loaded, then open up the console in game and 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 error message on the screen when the map loads. With "nav_edit 1" still set, lets take a look at what nav_generate did. Well do this using the "select_with_attribute A" command. What this console command does is select 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.
Open the console and type:
- select_with_attribute DOOR
- Notice the 4 nav squares that were highlighted, this tells the bot AI there is a door in this location.
Now type:
- select_with_attribute CHECKPOINT
Now type:
- select_with_attribute RESCUE_CLOSET
Now type:
- select_with_attribute ESCAPE_ROUTE