User:Brandished/Sandbox 1

From Valve Developer Community
Jump to navigation Jump to search

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's the map's layout and set up.

To start with we'll add an info_director and a env_fog_controller. Make sure to the "Fog Enable" property is set to "Yes".

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.

To give the players a starting point, add an info_player_start.

Supplies area:

  • 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

Now for an exit lets 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 "model" to "models/props_doors/checkpoint_door_01.mdl", and the uncheck the "Starts Open" flag.

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.

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
  • trigger_changelevel
Note.pngNote: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. Keep in mind the trigger_changelevel has to come in contact with the floor space inside the safe house due to how nav generation works. 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. 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 a 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

The map will be reloaded after you type nav_generate

After running nav_generate we no longer have the nav error message on the screen when the map loads. Lets take a look at what nav_generate did:

select_with_attribute DOOR

Now 4 nav squares should be highlighted...

select_with_attribute CHECKPOINT
select_with_attribute RESCUE_CLOSET
select_with_attribute ESCAPE_ROUTE