L4D2 Level Design/Scavenge Finale

Scavenge finales consist of an arena where infected attempt to stop survivors from filling up an escape vehicle with gas cans scattered throughout the map. Versus mode scoring depends on the number of gas cans filled during a round. Compared to a standard finale, there are some additional entities and a reliance on vscripts in order for scavenge finale to work.
== Components ==
c1m4_atrium decompiled will be used as a reference. Another map is c6m3_port, which also features L4D1 survivors bots. This is a rough list of components involved with scavenge finale:
*Scavenge-specific Entities:
**game_scavenge_progress_display
**weapon_scavenge_item_spawn
**point_prop_use_target
*Other entities:
**logic_timer
**info_director
**trigger_finale with Finale Type set to Scavenge
*3 vscripts
**c1m4_atrium.nut 
**c1m4_atrium_finale.nut
**c1m4_delay.nut
== Map ==
In general, the space needs to provide obstacles between the survivors and the gas cans. The obstacle is typically distance/terrain between the nozzle (point_prop_use_target) and the gas can.
=== Weapons ===
Consider that the survivors need starting weapons for when they reach the finale. They still need to be able to stock up for the challenge ahead of them. There should also be weapons and items on the way so that survivors can hold out for a bit to heal or resupply. There will be many different ways someone playing your map will go, for example someone that likes to take their time compared to someone that sparatically runs through your map to try and quickly grab the cans to escape.
=== Environment ===
These are merely suggestions:
*Make branching paths so that the survivors can duck in and out of buildings for supplies or even gascans for the finale.
*Keep in mind players dont constantly want to have to go down narrow hallways make open areas for large combat scenarios where the survivors can go down a street for example but be attacked by infected spawning in nearby building or special infected attacking them from rooftops.
*The distance between the gas can and goal is a balance of advantages between two teams.
=== Scavenge finale entities ===
*Firstly you will need a trigger_finale so the survivors can start the finale. In that entity you will find various settings. One of these is the finale type. It's default is set to standard. You will want to change this to scavenge. For now leave the use delay the same, but change the first use delay to five seconds. This lets the survivors know what their doing by making a sound play. (This is not necessary but it does help)
*Second you want to place a game_scavenge_progress_display. Inside it, you can change the max value to whatever you want. For the purpose of this tutorial we'll make it 8. Then change its name to something unique. For ours it will be scav_progshower. Next you will need a math_counter. Change its name property to scav_counter, then leave its initial value to 0. Make the max value the same number you set in the game_scavenge_progress_display. For this tutorial, we have it set to 8. Leave it's min value at 0.
*Third you will need to make the location where you will fill up. This can be anything you choose. For this tutorial, we will be using the nozzle prop radio_generator_fillup.mdl. You will need to place a prop_dynamic, then in its model field look up radio_generator_fillup. Place this within reachable distance from the player (player height is about 64 units so a good height will be 45 to 50 units). Set its glow color to any color of your choice.
*Fourth you will need to place a point_prop_use_target on the nozzle.
Go to your nozzle and open its properties and set its name field to scav_nozzle. Then go back to your point_prop_use_target and open up its output menu. Add a new output with the following settings :
*My output named: OnUseFinished 
*Targets entities named: Scav_counter 
*Via this input: Add 
*With a parameter override of: +1
This means when a player finishes filling up the nozzle with a gas can, point_prop_use_target will add a point to scav_counter.
=== Gas cans ===
In the entities tab look up weapon_scavenge_item_spawn. Place it down and go into its properties. Change its name to scav_gascans.
Then go back to your finale trigger, go into its properties, go to outputs tab and click add
Input the following:
*My output named: UseStart
*Targets entities named: scav_gascans
*Via this input: TurnGlowsOn
(The above means when the finale has started, all entities named scav_gascans will glow.)
Add another output with the following:
*My output named: UseStart
*Targets entities named: scav_nozzle
*Via this input: StartGlowing
(Similarly to above, this will make the nozzle glow.)
Next go to your entities tab and look up logic_auto. Place it down and go to its outputs tab and click add.
Input the following:
*My output named: OnMapSpawn
*Targets entities named: scav_gascans
*Via this input: TurnGlowsOff
Add another output and input the following:
*My output named: OnMapSpawn
*Targets entities named: scav_nozzle
*Via this input: StopGlowing
(The above two ensure they do not glow until we start the finale.)
Add another output and input the following:
*My output named: OnMapSpawn
*Targets entities named: scav_progshower
*Via this input: TurnOff
(This ensures the progress shower isn't active until we enable it.)
=== Escape vehicle ===
*This is usually a prop_dynamic with animations but it really can be anything.
For the purpose of this tutorial we'll just use the C130 for the prop_dynamic escape vehicle.
Go to the texture browser and look up trigger. It will look like this:
 
Make a brush the size of your escape vehicle. This would be the inside of the C130. Hit enter to create it, then hit ctrl+t to tie to entity. Under the class type put in trigger_multiple and give it the name escape_trigger. Then set the entire team number to survivor and set start disabled to yes. Then close out of its properties. 
Go back to your math_counter and to the outputs tab. Add a new output:
*My output named: OnHitMax
*Targets entities named: Scav_finale_starter
*Via this input: FinaleEscapeVehicleReadyForSurvivors
*Fire Once Only: click the checkbox
*My output named: OnHitMax
*Targets entities named: escape_trigger
*Via this input: Enable
*Fire Once Only: click the checkbox
*My output named: OnHitMax
*Targets entities named: scav_gascans
*Via this input: TurnGlowsOff
*Fire Once Only: click the checkbox
*My output named: OnHitMax
*Targets entities named: scav_usenozzle
*Via this input: Kill
*Fire Once Only: click the checkbox
*My output named: OnHitMax
*Targets entities named: scav_nozzle
*Via this input: StopGlowing
*Fire Once Only: click the checkbox
Then go back to your finale_trigger and change its name field to Scav_finale_starter.
=== Escape sequence ===
You will need to make a box outside the reach of your map with 4 info_survivor_position. In the properties, change the first info_survivor_position to 1. Change the second to 2 and so on until you've reached 4. Then change their names to whatever order you put them. (Ex. survivor_pos1 survivor_pos2 etc.)
 
*Go to your trigger_escape (the trigger brush you made in the escape vehicle) and add a new output with the following:
*My output named: OnEntireTeamStartTouch
*Targets entities named: Scav_finale_starter
*Via this input: FinaleEscapeForceSurvivorPositions
*My output named: OnEntireTeamStartTouch
*Targets entities named: Scav_finale_starter
*Via this input: FinaleEscapeFinished
Then go back to the texture browser. Look for clip; it will look like this:
Surround the survivor positions outside the reach of your map with this brush and hit enter to create it. Then click crtl+t to tie to entity. Change class type to func_brush. Look for Solid BSP and set it to yes. Then find Solidity and set it to always solid. Lastly, change its name to clip_scavend, hit apply, and close its properties menu.
Go back to your trigger_multiple and in the properties field click add 
*My output named: OnEntireTeamStartTouch
*Targets entities named: clip_scavend
*Via this input: Kill
Cover the floor of the escape vehicle with nodraw so you can walk on it and create navigation meshes within it.
Then in the entities tab look for point_veiwcontrol_multiplayer. Place this somewhere to view your escape vehicle leaving, then open up its properties and name it outro_cam. Then look for an env_fade entity and place 2 of them. Name the first one fade1 and set its hold time to 1. Then set its fade out/in to .15.
(What this does is instead of seeing the player and then quickly switching to the camera, it allows for a fade to happen. The survivors will teleport to their positions and then the view will come back to the camera.)
In the outputs tab of the first fade click add
*My output named: OnFade
*Target entities named: fade2
*Via this input: Fade
*After a delay of: 6
 
Then go back to the trigger_escape that is inside the escape vehicle and go to its outputs click add
*My output named: OnEntireTeamStartTouch
*Target entities named: outro_cam
*Via this input: Enable
Go to the fade2 entity and in its outputs tab click add
*My output named: OnFade
*Target entities named: outro_stats
*Via this input: RollCredits
Then in the entities tab look up env_outro_credits.
In its properties set its name field as outro_stats.
=== Nav mesh ===
Run your map, once you are in the level hit the tilde key {~} to open the developer console then type
*sv_cheats 1- This allows cheats to be enabled in game
*noclip- Allows free movement around the map, you will not be blocked by anything
*nav_edit 1- Enables nav mesh editting
*z_debug 1- Allows you to see navigation attributes and all zombies on the map
*director_stop- Stops the director from spawning zombies
*nb_delete_all- Deletes all npc's on the map
Then go to you finale area and open the developer console and type in
*nav_mark_walkable- Marks a walkable point in the map marked by a purple pyramid that can be generated into nav meshes
*nav_generate_incremental- Generates the nav meshes to a certain distance from the nav_mark_walkable
Then make sure you have the areas selected that you want around the finale trigger, as well as distanced areas for the zombies to spawn from. Then type in the following in the developer console: 
*mark Finale- This an attribute for nav meshes that is used in the final level of a campaign and is used in conjunction with a trigger_finale.
Then go to your player start area and mark those areas with checkpoint and player start.
Finally you need to go to your escape vehicle and mark those nav areas inside with rescue vehicle.
After that is done, type the following in the developer console:
*nav_analyze- (This analyzes all the nav meshes and writes a file named "yourmapname".nav in the maps folder of your left4dead2 folder.)
This is all you need to make a scavenge finale, I hope this helped
== VScripts ==
There are three vscripts are involved in this scavenge finale. Note that some code is redundant or commented out, possibly marks of the development process. Included are additional comments:
===c1m4_atrium.nut===
This script needs to be loaded on MapSpawn manually as a Director script, using the BeginScript input of the info_director entity. It sets the number of gas cans, the default CommonLimit, unblocks the rescue vehicle nav area, and (for some reason) declares the function GasCanPoured(). 
*The number of gas cans will decrease if it is a single player game
*Since human players will be navigating on the rescue vehicle, the rescue vehicle nav area is unblocked. 
*GasCanPoured() will be called either by the director (OnTeamScored) or point_prop_use_target (OnUsedFinished) whenever a gas can is successfully poured.
===c1m4_atrium_finale.nut===
This script is loaded as soon as the finale is forced to start (when the elevator opens at the lowest floor of the atrium). It contains most of the finale settings and logic.
*There are multiple finale stages, either onslaught, panic, or tank. The first stage is an onslaught and uses InitialOnslaughtOptions for DirectorOptions. The will end once gas cans are picked up four times or one gas can is successfully poured, leading to a PANIC stage
*The rest of the onslaughts run off c1m4_delay.nut for DirectorOptions. This onslaught is time dependent and has a lower tolerance for the number of gas can touches before moving to the next stage.
===c1m4_delay.nut===
This script is loaded whenever an onslaught stage is started, with the exception of the first one.
*Calls logic_timer entities to start a timer to move onto the next stage
*The stage ends either by expired time (timer_delay_end) or gas can pour and touch (timer_delay_abort)
Category:Left 4 Dead 2