Creating a Guardian Scenario Map

From Valve Developer Community
(Redirected from Mp guardian player dist max)
Jump to: navigation, search
English
Counter-Strike: Global Offensive Level Creation
Csgo icon guardian.png

Guardian (internally Cooperative) is a game mode in Counter-Strike: Global Offensive Counter-Strike: Global Offensive . This site covers the special requirements to make this game mode work for a map.

The mode was first introduced around Operation: Bloodhound 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.

Game Mode Description

The Guardian Scenario is about defending a bombsite as CT or defending a hostage as T against waves of rushing enemy bots.

  • The human players spawn near the target they must defend, either a bomb site or a hostage.
  • The game 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 next wave of bots spawn.
  • 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. 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 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 mp_maxrounds 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.

There are two steps to play Guardian on a map:

  1. Invoke the commands game_type 4, game_mode 0 and map <mapname>, or all in one command: map <mapname> guardian (see CS:GO Game Mode Commands).
  2. 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.
    • Write the commands in any .cfg file in csgo/cfg/ and execute it using exec <filename> and restart the game, e.g. using mp_restartgame 1.
    • Write the commands in gamemode_cooperative or 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.
    • Write the commands in any .cfg file in csgo/cfg/ and execute it using VScript, see below.


Note.png Note: Maps are capable of doing step 2 on their own, see below. The official maps do not do that so that it is possible to play different guardian configs on the same map.
Tip.png Tip: Valve has prepared a number of guardian configs for the official maps as a part of the Operations which can be found at csgo/maps/cfg/guardian_[...].cfg. For some de_ maps, there are even two for each bomb spot. To use one of those files in step 2, copy-paste it (or even the entire csgo/maps/cfg folder) into csgo/cfg/.
To do: Is there a way to execute files at csgo/maps/cfg/ without copy-pasting? Sadly, commands like exec ../maps/cfg/[...] do not function.
Deprecated: Any file inside csgo/maps/cfg/ with the prefix guardian_opXX_[...].cfg is up to date and works correctly on the destined map. The other files might use outdated commands/syntaxes and need to be edited to work correctly.
Idea:To stay organized, make a subfolder for guardian, for example csgo/cfg/guardian/ and execute files inside it using exec guardian/<filename>.

Making a Map only for Guardian

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. But should you still want to, it's still supported. It might be a more interesting gameplay experience!

Valve had created the new map gd_crashsite as well as some edits: gd_bank, gd_cbble, gd_lake and gd_sugarcane but 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.

Setting up a bombsite and Counter-Terrorist Spawns

The first thing any gd_ map will need is a bombsite. Ensure it is fair and balanced. Don't make more than one.

Place CT spawns inside the bombsite zone so that they know where to defend when they spawn.

Setting up Terrorist Spawns

There should be several corridors from your bombsite to the terrorist spawns.

There should be 5 to 10 spawns that are placed throughout the map. The terrorists will spawn randomly at these points and will rush the bombsite.

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 to make a map support Guardian. This section is about what to execute and the effects of certain console commands.

The easiest way to create a config is to copy-paste an existing config by Valve and to adjust the ConVars at your liking. There are explanations as comments inside the latest files. In the following, we use the file csgo/maps/cfg/guardian_op10_dust2_a.cfg as a leitmotif and split it up into subsections. This is the state of the file when it was last changed on 2021-01-21.

To do: 

  • Document several new ConVars that have been added with Operation Riptide.
    • custom bomb spot bounds (mp_guardian_bomb_plant_[...])
    • custom hostage spawn point(s) (mp_hostages_spawn_force_positions_xyz)
    • ...?
  • Deliver a minimal, generic config that makes the mode work.


Game Mode, Round and Spawn Settings

//GUARDIAN MISSION SETTINGS

// map
// de_dust 2 A site
// dm_reset_spawns to reset spawn/bomb site

// the index of the bombsite that CTs will spawn at (the index is different per map)
mp_guardian_target_site 								0

// what team will spawn randomly, 3 is team CT
mp_randomspawn 										3
mp_maxrounds 										30
mp_roundtime 										30
bot_difficulty										1	
bot_quota											7
mp_autoteambalance									0

// whether or not to use respawn waves
// 1 will have then spawn in rolling waves
// 1 will have then spawn in rolling waves
// 2 has them spawn only when the whole team is dead
mp_use_respawn_waves									2
mp_respawn_on_death_t									1

// who wins if time runs out (-1 == map default, 0 == draw, 2 == Ts, 3 == CTs)
mp_default_team_winner_no_objective							2

For hostage maps, replace mp_respawn_on_death_t 1 and mp_guardian_target_site by:

mp_respawn_on_death_ct 1

mp_guardian_force_collect_hostages_timeout 			1
mp_hostages_spawn_same_every_round					1
mp_hostages_spawn_force_positions					0 // play around with the value
Tip.png Tip: You can define custom spawnpoints for the human players using mp_guardian_clear_all_player_spawns and mp_guardian_add_player_spawn_pt <x> <y> <z> <pitch> <yaw> <roll>. These six values can be obtained with getpos.

Bot AI Settings

mp_bot_ai_bt "scripts/ai/guardian/bt_op10_dust2_a.kv3"

See mp_bot_ai_bt for more details to that command. To get generic bots, use "scripts/ai/guardian/bt_config.kv3" as the value for it.

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.

Economy and Equipment Settings

// economy settings
mp_startmoney										800
mp_maxmoney											16000
mp_afterroundmoney									0
mp_buytime											1800
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

//Override for buy status map info. 0 = everyone can buy, 1 = ct 2 = t 3 = nobody
sv_buy_status_override									0
mp_buy_anywhere                                     					1
mp_buy_during_immunity                              					0

// player weapons and equipment
//ct
mp_ct_default_primary									""
mp_ct_default_secondary									"weapon_usp_silencer"
mp_free_armor											0
sv_guardian_health_refresh_per_wave						50
sv_guardian_respawn_health							    50
//t
mp_t_default_primary									""
mp_t_default_secondary									""
//mp_t_default_grenades									""

// set new items from other game modes
sv_guardian_extra_equipment_ct							"item_assaultsuit"	
//sv_guardian_extra_equipment_t						
//sv_guardian_refresh_ammo_for_items_on_waves
Tip.png Tip: If you want to restrict the human players from buying certain weapons, you can either adjust cash values or make use of mp_items_prohibited to disallow exact items.
Tip.png Tip: It is possible to use something like mp_items_prohibited "33" to restrict weapon_mp7, so weapon_mp5sd is equipped automatically. This example is from csgo/maps/cfg/guardian_op09_card2.cfg.
Tip.png Tip: You can also use extraordinary items:
sv_guardian_extra_equipment_ct exojump as seen in csgo/maps/cfg/guardian_op09_card4.
sv_guardian_extra_equipment_t weapon_shield as seen in csgo/maps/cfg/guardian_op09_card13.cfg.

Bot Settings

// 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

//sv_guardian_max_wave_for_heavy						0
//sv_guardian_min_wave_for_heavy						0
//sv_guardian_heavy_count								0


// bot weapons. if zero, bots may not use weapon type
bot_allow_shotguns									0					
bot_allow_rifles									1
bot_allow_machine_guns                              0
bot_allow_snipers									1
Note.png Note: All bots use the same AI. This means they might try to escort hostages or to pick up the dropped bomb although they are on the wrong team.

Player Mission Settings

// # of kills needed witht he special weapon to win the match

mp_guardian_special_kills_needed					15

// which weapon is needed to get kills with to win the match
// if this is blank, the players just need to survive until the round timer expires to win
// make sure mp_default_team_winner_no_objective is set to have the CTs win if this is set to blank!

mp_guardian_special_weapon_needed					"%weapon_ssg08%"  
mp_guardian_loc_weapon								""

The value of mp_guardian_special_weapon_needed determines the condition(s) that kills must pass to be counted for the human team. It can be one or a combination of the following:

Expression Meaning
"" or any or any invalid expression Every kill
awp, ak47, etc. Only kills with the specified weapon (omitting the weapon_ prefix)
%weapon_awp%, %weapon_ak47%, etc. Only kills with the specified weapon (see List of CS:GO Entities for a list of weapons)
%weapon_secondary% Only pistol kills
%weapon_knife% Only knife kills
%weapon_grenade% Only grenade kills
%cond_match_ts_unique_weapon% Only weapons that the human team has not done any kill with yet
%cond_player_zoomed% Only kills where the killer has scoped with a weapon
%cond_damage_headshot% Only kills caused by a headshot
%cond_damage_burn% Only kills caused by fire
(%cond_victim_distance% <= 10) Only kills against players that are at most 10 meters away from the killer
!%[...]% NOT: A kill must NOT meet the condition to be counted.
%[...]% || %[...]% OR: A kill must meet ANY of these conditions to be counted.
%[...]% && %[...]% AND: A kill must meet ALL of these conditions to be counted.
( [...] ) Influences the order of evaluation of the previous three.

The value of mp_guardian_loc_string_hud 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_english.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

These strings can contain the expression {s:weapon} which will be replaced by the value of mp_guardian_loc_weapon. If not set, the game tries to pick it 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 an example 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_card5 "%weapon_p90% || %weapon_awp%" "" "#quest_weapon_awp_or_p90"
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"

Boundary Settings

// radius around the bombsite players can move, min is where warning starts, max is where damage occurs
mp_guardian_player_dist_min							1000									
mp_guardian_player_dist_max							1200

//guardian bounds config
mp_guardian_clear_all_bounds
mp_guardian_new_bounds
mp_guardian_add_bounds_pt 539.2 2774.0 -114.8
mp_guardian_add_bounds_pt 1044.7 3070.0 349.3
mp_guardian_add_bounds_pt 1572.0 3070.0 -114.8
[...]
mp_guardian_add_bounds_pt 527.0 2082.0 349.3
mp_guardian_new_bounds
mp_guardian_add_bounds_pt 539.3 2058.0 95.4
mp_guardian_add_bounds_pt 478.2 2042.0 367.8
mp_guardian_add_bounds_pt 458.2 2042.0 95.4
[...]
mp_guardian_add_bounds_pt 548.0 2091.5 367.8

If there are no bounds set, the values of mp_guardian_player_dist_min and mp_guardian_player_dist_max are primarily used. The first determines at which range from the target bomb site the player view starts to fade gray and a warning appears. The second determines at which range from the bombsite damage starts. This way, the playable area is a sphere with the origin of a bomb site as center.

Alternatively, it is possible to define custom boundaries to get other shapes. If there are bounds defined, the DIFFERENCE of the ConVars mp_guardian_player_dist_min and mp_guardian_player_dist_max (mathematically: the value of max - min) is then used to determine the distance from the defined bounds until the warning and damage occur. If these two convars have the values 1000 and 1200 it means that damage occurs to players that are not at most 200 units away from the interiors of all defined bounds. The same would apply to the values 2000 and 2200.

  • Use mp_guardian_clear_all_bounds to clear all existing bounds, possibly from previously played maps. Do this once even if you don't use these bounds.
    • Use mp_guardian_new_bounds to start a new area.
      • Use mp_guardian_add_bounds_pt <x> <y> <z> to add a new corner point of the boundary. An idea is to get a prism which means that in the end, there are only two different z-coordinates used for the corners. For each vertical edge, one corner is enough. Enter top and bottom corners alternately and go through the corners clockwise or counter-clockwise. Use noclip to fly to a corner, enter getpos (to get your eyes' position) or getpos_exact (for your feet's position) and copy-paste the coordinates to the config. Note that the last point added will internally be connected to the first point of the last area that had been begun in the previous step.
      • Alternatively, use mp_guardian_shoot_point to add the point under your crosshair. A really helpful side effect of using this command is that all defined bounds will be shown in-game. When you're done, use mp_guardian_emit_bounds_config to print the points that you've shot in the console to copy-paste them to your config.

Automatic execution of Guardian Configs

Using VScript it is possible to fire events depending on the game mode, which is also used for Wingman. The following 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 - will execute commands to the console only if the current game mode is Guardian.

TYPE <- ScriptGetGameType()
MODE <- ScriptGetGameMode()

if (TYPE == 4 && MODE == 0) // Guardian uses game_type 4 and game_mode 0
{
	// EITHER: execute a .cfg file, as long as this works.
	
	SendToConsole("exec <filename>")
	
	// OR to be safe: execute every single command:
	
	SendToConsoleServer("...") // replace dots with a console command
	SendToConsoleServer("...")
	// ...
}