Counter-Strike: Global Offensive/Game Modes/Guardian

Guardian (internally cooperative) is a game mode in .
This site covers the special requirements to make this game mode work for a map.
The mode was first introduced around as a way to play co-op with a friend inside specific maps.
The gd_ prefix is for maps that are designed primarily for this game mode, but it has no internal purpose. Valve had created the new map gd_crashsite as well as some edits: gd_bank, gd_cbble, gd_lake and gd_sugarcane. Only gd_cbble still exists in the current game files and has a modified T spawn: The fountain is a bomb spot with some additional cover.
Valve originally planned the Guardian game mode to be played on special gd_ maps, but then moved away from it when they realised that it is easier to make regular maps support this game mode instead of creating new maps only for it. On the other hand, one could still make a map that is designed for this game mode, it might be a more interesting gameplay experience!
==Game Mode Description==
* The human players play against bots. They spawn near a bomb site as CT or near a hostage as T and must defend it against waves of rushing bots.
* Each round starts with a freezetime and buying. From then on, bots will spawn in waves. When all bots are dead, the players receive health and are allowed to buy until the bots respawn for the next wave.
* The human players win the round and the game by making a given number of kills under special conditions, e.g. with a specified weapon. The condition and the number of special kills that has already been made can be seen in a HUD element on the left. As soon as the required number of kills is reached, all players are stopped and an end panel is shown after which the next map loads.
* The human players lose a round immediately, all players are stopped and the round restarts...
** if the human players are all dead,
** if a bomb has been planted on their bomb site or
** if their hostage has been picked up.
* The human players lose the game if is reached and they did not win a round.
==Playing Guardian on any Map==
The Guardian game mode can be programmed almost entirely with console commands so that the only map requirements are player spawns and at least one bombsite or hostage. This means that all regular de_ or cs_ maps are eligible for Guardian. Since it is even possible to play custom Bomb Defusal scenarios on maps, provided there is a proper Guardian Config being used.
There are two steps to play Guardian on a map:
# Invoke the commands game_type 4, game_mode 0 and map <mapname>, or all in one command: map <mapname> guardian (see CS:GO Game Modes).
# In-game, the adjustment of some ConVars is required (especially to make bots spawn in waves) and more adjustments can be made to customize a mission. However, there is no official way to accomplish the execution of these console commands. There are some options:
#* Execute the commands manually in-game. You don't want to do that.
#* Create new CFG file in csgo/maps/cfg/ (or simply csgo/cfg/) and write the commands. Execute it using execwithwhitelist <filename>.cfg */maps or exec <filename>.cfg */maps (or simply exec <filename>) and restart the game, e.g. using mp_restartgame 1.
#* Write the commands in csgo/cfg/gamemode_cooperative_server. Advantage: These files are executed automatically. For publishing, a custom variant of these files can be packed into a map, overriding a local file!
#* Use a VScript and its functions SendToConsole or SendToConsoleServer to execute the commands.
#* If you are the maker of the map, you can add a VScript that does the CFG execiton when the map loads, see below. This however might override any CFGs that are executed earlier such that it is not possible to play a different guardian scenario on this particular map other than the one that the VScript defines.
==Guardian Configs==
As mentioned above, besides launching the map in the Guardian game mode, there is "just" a number of console commands that have to be executed get a proper Guardian Scenario. This section is about what to execute and the effects of certain console commands and convars.
In the following, you find a baseline for a Guardian Config. Of course it does not contain map specific settings (e.g. spawn points defined by coordinates), so it alone won't deliver too good results but it should make any map at least playable for this game mode. In Hostage Rescue it can happen that the human players spawn and die immediately because they are to far away from the hostage.
===Boundaries===
The location where the Guardian Scenario is played depends and can also be manipulated.
* On Bomb Defusal maps, setting the convar mp_guardian_target_site to 0 or 1 determines the location, either bomb site A or B. Set this to -1 if there is no bomb site.
* On Hostage Rescue maps, a specific hostage that is already on the map can be selected using or alternatively, a new hostage can be placed using .
* On maps, one can create a Bomb Defusal scenario by using and the commands mp_guardian_bomb_plant_[...] to define the boundaries (see below) of a custom bomb target as well as a custom X decal with mp_guardian_bomb_plant_custom_x_mark_location "<x> <y> <z>".
Typically, the human players should stay near the location where the Guardian Scenario takes place. This is achieved with boundaries such that if the human player leaves them, their view fades to gray, they receive a warning and if they go even further, they receive lethal damage. These boundaries can be defined as a sphere (if possible) or using custom bounds (always possible).
* If there is a func_bomb_target or a hostage_entity, then it is possible to use the sphere around its origin as bounds. In this case, the convar mp_guardian_player_dist_min can be set to describe the radius of the inner sphere where the human players can move freely. Then the convar mp_guardian_player_dist_max can be set to a larger radius: The human players receive damage if they step outside this larger sphere. The area between the inner and outer sphere is used for the transition to gray.
* Custom bounds consist of an arbitrary number of convex prisms and each convex prism consists of an arbitrary number of points. Valve has implemented a system in-game to create, visualize (!) and save such structures, see below. When some bounds are defined, then mp_guardian_player_dist_min and _max get a slightly different meaning. When a player starts to run outside of the bounds, the fade to gray starts right at the border of the bounds and damage starts at a distance of max - min, for example after 100 units if min=800, max=900 which by the way would have the same effect as min=1370, max=1470 and so forth.
===Spawn Points===
With no adjustments, the players would spawn at the default info_player_(counter)terrorist entities.
The definite solution to get custom spawn points are the following commands. Use the clear command once followed by at least 2 human spawns or 5 enemy spawns, respectively. In-game, you can obtain the coordinates with .
In Bomb Defusal, it is also possible to set to 3. This convar determines which teams should spawn randomly (at entities) where 0 means none, 1: both teams, 2: Ts and 3: CTs. Normally, those spawns are generated across the entire Nav Mesh, however, in it is special that they are only generated near the one that is specified by mp_guardian_target_site, if any. These spawns can be re-generated with and viewed with if the generation was successful.
Sadly this system cannot be used in Hostage Rescue, thus mp_randomspawn should be 0 and it is easier to set the spawn points with the above commands.
===Player Mission===
By game logic, the human players win a round (and the game) as soon as they score a certain number of special kills that meet certain conditions which can be set with the following convars.
// Human players' objective
mp_guardian_special_kills_needed	10		// The number of special kills needed to win the game
mp_guardian_special_weapon_needed	"awp"	// The condition(s) that a kill must meet to increment the kills needed to complete the mission
mp_guardian_loc_string_hud	"#guardian_mission_type_kills"	// Localized string token to use on hud for this mission, otherwise defaults to "Get Kills: <weapon>"
mp_guardian_loc_weapon		""				// Override to weapon dialog var applied to UI
 stands for the number of kills that the human players must score to win the game.
If set to 0 or a negative value, the game ends as soon as the humans score one kill.
 determines the condition(s) that kills must pass to be counted as a special kill. It can be one or a combination of the following:
:
Expression 	What kind of kills count?  	 	
"" 	Every kill. Does not work when changed to during a round. 	 	
awp, ak47, ... 	Only kills with the specified weapon (omitting the weapon_ prefix). Does not work when changed to during a round. 	 	
%weapon_awp%, %weapon_ak47%, ... 	Only kills with the specified weapon. See Category:CS:GO Weapons for a list of weapons. Does not work with , . 	 	
%weapon_secondary% 	Only pistol kills: Glock-18, P2000, USP-S, Dual Berettas, P250, Tec-9, CZ75-Auto, Fiveseven, Desert Eagle, R8 Revolver. 	 	
%weapon_smg% 	Only SMG kills: MAC-10, MP9, MP7, MP5-SD, UMP-45, P90, PP-Bizon. 	 	
%weapon_heavy% 	Only heavy weapon kills: Nova, XM1014, Sawed-Off, MAG-7, M249, Negev. 	 	
%weapon_rifle% 	Only rifle kills: Galil AR, FAMAS, AK-47, M4A4, M4A1-S, SSG 08, SG 553, AUG, AWP, G3SG1, SCAR-20. 	 	
%weapon_grenade% 	Only grenade kills, including grenade impact kills: Molotov, Incendiary Grenade, Decoy Grenade, Flashbang, HE Grenade, Smoke Grenade, Tactical Awareness Grenade, Snowball.	 	
%weapon_melee% 	Only melee kills: Knife, Axe, Hammer, Wrench, . 	 	
%weapon_knife% 	Only knife kills. 	 	
%cond_damage_burn% 	Only kills caused by fire. 	 	
%cond_damage_headshot% 	Only kills caused by a headshot. 	 	
%cond_damage_collateral% 	Only kills caused by a bullet that has already killed another enemy on its path. 	 	
%cond_match_ts_unique_weapon% 	Only kills with weapons that the human team has not scored any kill with yet. 	 	
%cond_player_airborne%%cond_victim_airborne%	Only kills where the killer/victim is in midair. 	 	
%cond_player_blind%%cond_victim_blind% 	Only kills where the killer/victim is (or has just been) under the flashbang effect. 	 	
%cond_player_zoomed% 	Only kills where the killer has scoped with a weapon. 	 	
%cond_victim_distance% <= 10 	Only kills where the victim is at most 10 meters away from the killer (distance from eye to eye?). 	 	
%<invalid_expression>% 	No kill. 	 	
!%...% 	NOT operator: A kill must NOT meet the condition to be counted. 	 	
%...% 	%...% 	OR operator: A kill must meet ANY of these conditions to be counted.	
%...% && %...% 	AND operator: A kill must meet ALL of these conditions to be counted. 	 	
( ... ) 	Brackets can be used to group expressions and to influence the order of evaluation of the previous three operators. Note that due to operator precedence !A && B 	C is equivalent to ((!A) && B) 	C.
 is the mission text shown on the left of the screen. This can be any text surrounded by quotation marks, but for language compatiblity, there are predefined string tokens that can be found at csgo/resource/csgo_<language>.txt and used with a preceding hash sign. It makes sense to use one of the following:
:
mp_guardian_loc_string_hud 	Displayed Text in English 
"" 	Get kills: {s:weapon}
"#guardian_mission_type_kills" 	Get kills: {s:weapon}
"#guardian_mission_type_headshots" 	Get headshots: {s:weapon}
"#guardian_mission_type_unscoped" 	Get unscoped kills: {s:weapon}
"#guardian_mission_type_enemy_weapon" 	Get kills with enemy's {s:weapon}
"#guardian_mission_type_enemy_airborne"	Get airborne kills: {s:weapon}
"#guardian_mission_type_flashbang" 	Kill blinded enemies
"#guardian_mission_type_ct_weapons" 	Get kills with Counter-Terrorist weapons
 is what the expression {s:weapon} will be replaced with. Ideally, this is also a localized string, but it is rarely needed at all because the game already does a good job picking a string itself. Some of the existing strings are:
:
mp_guardian_loc_weapon 	Displayed Text in English 
#quest_enemy_weapon 	Enemy Weapon
#quest_weapon_CZ75a_or_enemy_weapon	CZ75-Auto or any enemy weapon
#quest_weapon_sniperrifle 	any sniper rifle
#quest_weapon_m4 	any M4 rifle
#quest_weapon_starter_ct 	any default CT pistol
#quest_weapon_ct 	Counter-Terrorist weapon
#quest_weapon_t 	Terrorist weapon
#quest_weapon_any_pistol 	any pistol
#quest_weapon_any_weapon 	any weapon
#quest_weapon_any_shotgun 	any shotgun
#quest_weapon_any_smg 	any smg
#quest_weapon_ssg08_or_mag7 	SSG 08 or MAG-7
#quest_weapon_awp_or_p90 	AWP or P90
#quest_weapon_unique_pistol 	Different Pistols
The following are examples from the existing files inside csgo/maps/cfg/ to give you an idea of how these three commands can be used together:
:
Filename 	mp_guardian_special_weapon_needed 	mp_guardian_loc_string_hud 	mp_guardian_loc_weapon  	 	 	 	 	 	 	 	 	
guardian_op09_card1 	"%weapon_ssg08% 	%weapon_mag7%" 	"" 	"#quest_weapon_ssg08_or_mag7"	 	 	 	 	 	 	 	
guardian_op09_card1_2 	"%weapon_p90% 	%weapon_awp%" 	"" 	"#quest_weapon_awp_or_p90" 	 	 	 	 	 	 	 	
guardian_op09_card4 	"%weapon_nova% 	%weapon_xm1014% 	%weapon_mag7% 	%weapon_sawedoff%" 	"" 	"#quest_weapon_any_shotgun"	 	 	 	 	 	
guardian_op09_card7_1 	"%weapon_awp% && !%cond_player_zoomed%" 	"#guardian_mission_type_unscoped" 	"" 	 	 	 	 	 	 	 	 	
guardian_op09_card8 	"%weapon_m4a1% 	%weapon_m4a1_silencer% 	%weapon_hkp2000% 	%weapon_usp_silencer% 	%weapon_famas% 	%weapon_aug% 	%weapon_mag7% 	%weapon_scar20% 	%weapon_fiveseven%	%weapon_mp9%" 	"#guardian_mission_type_ct_weapons"	""
guardian_op09_card9 	"%weapon_usp_silencer% && %cond_damage_headshot%" 	"#guardian_mission_type_headshots" 	"" 	 	 	 	 	 	 	 	 	
guardian_op09_card11_1 	"%weapon_grenade%" 	"" 	"" 	 	 	 	 	 	 	 	 	
guardian_op09_card11_2 	"( %weapon_incgrenade% 	%weapon_molotov% ) && %cond_damage_burn%"	"" 	"" 	 	 	 	 	 	 	 	
guardian_op10_ancient_a 	"%weapon_nova% 	%weapon_mag7% 	%weapon_sawedoff% 	%weapon_xm1014%" 	"" 	"#SFUI_WPNHUD_Shotgun" 	 	 	 	 	 	
guardian_op10_apollo 	"%cond_match_ts_unique_weapon% && %weapon_secondary%"	"" 	"#quest_weapon_unique_pistol"	 	 	 	 	 	 	 	 	
guardian_op10_dust2_b 	"(%cond_victim_distance% <= 10)" 	"" 	"#quest_1071_hud_var_desc" 	 	 	 	 	 	 	 	 	
guardian_op10_nuke_b 	"(%weapon_mp9% 	%weapon_mp7% 	%weapon_mp5sd% 	%weapon_ump45% 	%weapon_mp9% 	%weapon_bizon% 	%weapon_p90% 	%weapon_mac10%)"	"" 	"#quest_weapon_any_smg"	 	
guardian_op10_overpass_a	"(%weapon_aug% && %cond_damage_headshot%)" 	"" 	"#quest_1067_hud_var_desc" 	 	 	 	 	 	 	 	 	
guardian_op10_train_b 	"%weapon_ssg08% 	%weapon_awp% 	%weapon_scar20% 	%weapon_g3sg1%" 	"" 	"#quest_weapon_sniperrifle"	 	 	 	 	 	
guardian_op10_vertigo_b 	"%weapon_glock% 	%weapon_tec9% 	%weapon_sawedoff% 	%weapon_mac10% 	%weapon_galilar%	%weapon_ak47% 	%weapon_sg556%	%weapon_g3sg1%" 	"" 	"#quest_weapon_t" 	 	
===Economy and Equipment===
From here on, you can bring up any ideas that you might have for the mission. There is no right or wrong configuration. Regard the following snippets as inspiration. There are a lot of convars that you can manipulate.
// economy settings
mp_startmoney						800		// Only given on game start! Not given when humans lose and the round restarts!
mp_afterroundmoney					800		// Given every new round, except the first, so set this to the same as mp_startmoney
mp_maxmoney							16000
cash_player_killed_enemy_default	300 // Money award to player when they kill an enemy (which then gets scaled per weapon)
cash_player_killed_enemy_factor		1		
cash_player_get_killed				0 // Money a player can get when they are killed by another player
cash_player_bomb_planted			300
cash_team_survive_guardian_wave				1000
cash_team_elimination_bomb_map				0
cash_team_loser_bonus						-16000
cash_team_loser_bonus_consecutive_rounds	0
cash_team_bonus_shorthanded					0 // Should set to 0 because teams are unbalanced
mp_guardian_bot_money_per_wave	800	// The amount of money bots get time each wave the players complete. This # is abs
sv_buy_status_override	0		// Teams that are allowed to buy (-1: don't override, 0: everyone 1: no one, 2: Ts, 3: CTs)
mp_buy_anywhere			1		// Buy anywhere (still, humans can only buy between waves!)
mp_buytime				1800	// Buy forever (round duration in seconds)
mp_buy_during_immunity	0
mp_buy_allow_guns		255	// 0: none, 255: all, sum up what shall be allowed: 1=pistols, 2=SMGs, 4=rifles, 8=shotguns, 16=snipers, 32=heavy
mp_buy_allow_grenades	1
mp_items_prohibited		0	// can disable specific items
// default equipment
mp_free_armor				0
mp_ct_default_primary		""
mp_ct_default_secondary		"weapon_hkp2000"
mp_ct_default_melee			"weapon_knife"
mp_ct_default_grenades		""
mp_t_default_primary		""
mp_t_default_secondary		"weapon_glock"
mp_t_default_melee			"weapon_knife"
mp_t_default_grenades		""
sv_guardian_extra_equipment_ct				""	// Extra starting equipment for CT players in guardian modes
sv_guardian_extra_equipment_t				""	// Extra starting equipment for Terrorist players in guardian modes
sv_guardian_starting_equipment_humans		"weapon_healthshot"	// Extra starting equipment for human players in guardian modes (not whitelisted)
sv_guardian_health_refresh_per_wave			50	// Health given to survivors per wave in guardian mode.
sv_guardian_spawn_health_ct					100	// Starting health in guardian modes.
sv_guardian_spawn_health_t					100	// Starting health in guardian modes.
sv_guardian_respawn_health					50	// Starting health of guardian players when respawned.
sv_guardian_refresh_ammo_for_items_on_waves	""	// List of additional weapons to refill ammo on waves.
===Bots===
// initial bot difficulty
bot_difficulty 2
// bot gets easier on team T each time they win a round
sv_bots_get_easier_each_win								1
sv_bots_get_harder_after_each_wave						2
sv_bots_force_rebuy_every_round							0
sv_auto_adjust_bot_difficulty 							0
// heavy weapons guy
sv_guardian_heavy_all	0	// 1: every bot is a heavy
sv_guardian_heavy_count	0	// max the number of heavies that will come
sv_guardian_max_wave_for_heavy	0	// last wave number that can have a heavy
sv_guardian_min_wave_for_heavy	0	// first wave number that can have a heavy
// bot weapons. if zero, bots may not use weapon type
bot_allow_machine_guns		1	// If nonzero, bots may use SMGs.
bot_allow_pistols			1	// If nonzero, bots may use pistols.
bot_allow_rifles			1	// If nonzero, bots may use rifles.
bot_allow_shotguns			1	// If nonzero, bots may use shotguns.
bot_allow_snipers 			1	// If nonzero, bots may use sniper rifles.
bot_allow_sub_machine_guns	1	// If nonzero, bots may use sub-machine guns.
bot_allow_rogues			1	// If nonzero, bots may occasionally go 'rogue'. Rogue bots do not obey radio commands
mp_guardian_give_random_grenades_to_bots 1	// If set guardian bots will be given grenades at the beginning of the wave.
sv_guardian_reset_c4_every_wave	0	// 0: the C4 stays where bots have dropped it after a wave. 1: they spawn with the C4
The AI for the bots can be set with .
In short: Bots can be programmed map specifically using .kv3 text files (as seen in csgo/scripts/ai/guardian/) which allow the programmer to make bots 
* teleport (e.g. closer to the interesting part of the map),
* throw grenades with exact lineups,
* rush to a specified coordiante.
* ...
==Automatic execution of Guardian Configs==
local TYPE	= ScriptGetGameType()
local MODE	= ScriptGetGameMode()
local ROUND	= ScriptGetRoundsPlayed()
if (TYPE == 4 && MODE == 0 && ROUND == 0) // Guardian uses game_type 4 and game_mode 0
{
	SendToConsole(format("execwithwhitelist guardian_%s.cfg */maps", GetMapName()))
	// SendToConsole(format("exec guardian/%s", GetMapName()))
}
Using VScript it is possible to fire events depending on the game mode, which is also used for .
The code on the right is an example for a VScript that - if saved as .nut file inside csgo/scripts/vscripts/ and used as an Entity Script of an entity in the map - can execute commands to the console when the map loads but only if the current game mode is Guardian.
In this particular case it executes the CFG file under csgo/maps/cfg/ that has the same name as the current map but with the prefix guardian_.
Category:Counter-Strike: Global Offensive
Category:Level Design
Category:Tutorials