Mutation Gametype (L4D2)
This article is a stub. You can help by adding to it. |
Contents
Introduction
With the "Expanded Mutation System" update, game modes are now handled via individual gamemode definition files. This gives a convenient way to create additional game mode entries that are based off the main four: coop, realism, versus, and scavenge, as well as brand new modes with advanced custom scripting.
Legacy mutations using the L4D2 Gamemodes File gamemodes.txt can still be used, but only one add-on can be active at a time.
Important aspects of mutations:
- A mutation is a modified game mode that mainly consists of modified cvars and a mutation vscript.
- A mutation name is the game mode entry name set in the mode definition file.
- All mutations can be loaded via the main menu GUI, but can also be loaded via console
map <map name> <game mode name>
Examples: map c1m1_hotel mutation13 or map c1m1_hotel survival - Cvars are placed in a game mode definition.
- A vscript of the same name (<game mode name>.nut) is also loaded to complete additional tasks. For example, it may contain a function to replace weapons. Map-specific vscripts (<mapname>_<game mode name>.nut) are also loaded.
Custom mutations
To do: discuss workflow, useful commands for development and testing
Alternate instructions: Custom Mutations Tutorial (Steam Forums)
Preparation
Testing
Example game mode definition file
The definition files are added as \left 4 dead 2\left4dead2\modes\<modename>.txt
For a list of nearly all of the available cvars in L4D2, please see List of L4D2 Cvars


"my_example_mode" // Name of the game mode and also the name of the vscript that will automatically load when a game mode is started, either via console or GUI. { "base" "none" // Game mechanics are inherited from this mode. It can be coop/versus/survival/scavenge/realism or an other mutation. It can also be "none" for novel game modes. "maxplayers" "4" // Set the number of players allowed. Allowed values are 1, 4 and 8. "hasdifficulty" "1" // Sets if difficulty is allowed. "singlechapter" "1" // Checks if there is only one level (Used in Survival/Scavenge). "playercontrolledzombies" "1" // Allows/Disallows players to control infected. "hasroundlimit" "1" // Has rounds? // These settings control how the mode is displayed in the Mutations menu. "DisplayTitle" "Example Gamemode!" "Description" "An example mode to demonstrate the mutation system." "Author" "Me!" "Image" "vgui/my_thumbnail_material" // Normally 512 x 256 pixels // This is the part where cvars can be added to alter the game mode, this allows hidden cvars as well. convar { pain_pills_decay_rate 0.27 z_speed 500 } }
Mutation vscript examples
For all of the official mutation vscripts, along with other official vscripts, please see L4D2 Vscripts

Chainsaw Massacre (mutation7.nut)
//----------------------------------------------------- Msg("Activating Mutation 7\n"); DirectorOptions <- { ActiveChallenge = 1 cm_InfiniteFuel = 1 cm_ShouldHurry = 1 weaponsToRemove = { weapon_pistol = 0 weapon_pistol_magnum = 0 weapon_smg = 0 weapon_pumpshotgun = 0 weapon_autoshotgun = 0 weapon_rifle = 0 weapon_hunting_rifle = 0 weapon_smg_silenced = 0 weapon_shotgun_chrome = 0 weapon_rifle_desert = 0 weapon_sniper_military = 0 weapon_shotgun_spas = 0 weapon_grenade_launcher = 0 weapon_rifle_ak47 = 0 weapon_smg_mp5 = 0 weapon_rifle_sg552 = 0 weapon_sniper_awp = 0 weapon_sniper_scout = 0 weapon_rifle_m60 = 0 weapon_melee = 0 weapon_upgradepack_incendiary = 0 weapon_upgradepack_explosive = 0 ammo = 0 upgrade_item = 0 } function AllowWeaponSpawn( classname ) { if ( classname in weaponsToRemove ) { return false; } return true; } function ShouldAvoidItem( classname ) { if ( classname in weaponsToRemove ) { return true; } return false; } DefaultItems = [ "weapon_chainsaw", "weapon_pistol", ] function GetDefaultItem( idx ) { if ( idx < DefaultItems.len() ) { return DefaultItems[idx]; } return 0; } } removed_weapon_spawns <- false; function Update() { if( !removed_weapon_spawns ) { EntFire( "weapon_spawn", "kill" ); removed_weapon_spawns = true; } }
Headshot! (mutation2.nut)
//----------------------------------------------------- Msg("Activating Mutation 2\n"); DirectorOptions <- { ActiveChallenge = 1 cm_HeadshotOnly = 1 }
Gib Fest (mutation14.nut)
//----------------------------------------------------- Msg("Activating Mutation 14\n"); DirectorOptions <- { ActiveChallenge = 1 weaponsToRemove = { weapon_pistol = 0 weapon_pistol_magnum = 0 weapon_smg = 0 weapon_pumpshotgun = 0 weapon_autoshotgun = 0 weapon_rifle = 0 weapon_hunting_rifle = 0 weapon_smg_silenced = 0 weapon_shotgun_chrome = 0 weapon_rifle_desert = 0 weapon_sniper_military = 0 weapon_shotgun_spas = 0 weapon_grenade_launcher = 0 weapon_rifle_ak47 = 0 weapon_smg_mp5 = 0 weapon_rifle_sg552 = 0 weapon_sniper_awp = 0 weapon_sniper_scout = 0 weapon_rifle_m60 = 0 weapon_melee = 0 weapon_chainsaw = 0 ammo = 0 } function AllowWeaponSpawn( classname ) { if ( classname in weaponsToRemove ) { return false; } return true; } DefaultItems = [ "weapon_rifle_m60", "weapon_pistol_magnum", ] function GetDefaultItem( idx ) { if ( idx < DefaultItems.len() ) { return DefaultItems[idx]; } return 0; } } removed_weapon_spawns <- false; function Update() { if( !removed_weapon_spawns ) { EntFire( "weapon_spawn", "kill" ); removed_weapon_spawns = true; } }
See also
- Decompiled Official Vscripts
- L4D2 Gamemodes File
- L4D2 Vscript Examples
- L4D2 Vscripts
- List of L4D2 Cvars
- VScript
External links
- Custom Mutations Tutorial (Steam Forums)
- "All Mutations Unlocked" (Steam Forums)