Half-Life 2

Half-Life 2

133 arvostelua
Useful Console Commands to Tweak Your HL2
Tekijältä V92
Commands & console variables you can change to affect minor gameplay elements in Half-Life 2 and other Source Engine games.
3
   
Palkinto
Lisää suosikkeihin
Lisätty suosikkeihin
Poista suosikeista
Introduction
I've dived into the console commands for HL2 & Source in general multiple times over the years, and I felt like documenting some of the more useful commands that ship with the game, but are otherwise little-known or unused.

Odds are, you'll know most of these. If I manage to teach you about one more command you didn't know about, I'd consider that a win.

Many of these are also usable in other Source games, such as Garry's Mod or Synergy, so feel free to experiment.

Let's get started, then.
Basics
There's actually a lot of useful commands you can find. These are some of the basics you would probably get the most use out of.

  • clear - Clears the console text. You'll probably use this one the most.
  • help <string> - get the help string tied to a command
  • find <string> - find any commands that have the search string in them or their descriptions.
  • toggle <command> <intervals> - toggle a console variable on/off or cycle values. i.e. toggle npc_citizen_auto_player_squad would toggle the boolean on & off each time the command was used, while using toggle sk_max_357 1 3 6 would set the max .357 ammo to 1, then 3, then 6 each time the command was used.
  • bind <command> - Bind a command to the key specified.
  • bindtoggle <command> - Bind a command to the key specified, but treat as a toggle. i.e. bindtoggle sv_cheats would toggle cheats on and off with each key press.
Developer Settings
  • developer <int> - Enable developer mode. developer 1 will mostly print the console feed to the top corner of the screen. developer 2 will print extremely verbose feedback including map I/O systems being run and time stamps. Recommend to only use developer 1 unless you're trying to find issues with your map's functions or bug hunting. Can be used at startup by using the -dev launch command.
  • con_notifytime <int> - How many seconds to show the console feed on-screen. Set to 0 to disable the screen popups.
  • phys_penetration_error_time <int> - How long to show the VPHYSICS PENETRATION ERROR text on objects that are stuck in the world. This happens a lot on maps with physics props just slightly too low into the ground (d2_coast_11 is a really big example of this). Setting this to 0 is recommended unless you're doing some serious head-scratching bug testing, as it's mostly an error you can ignore.
Performance Tweaks
  • npc_citizen_dont_precache_all <bool> - toggle the precaching of all citizens to prevent hiccups & stuttering.
  • g_ragdoll_maxcount <int> - how many corpses can be rendered at once. 0 will make them disappear immediately, while 100 would let 100 different corpses appear at once.
  • cl_ejectbrass <int> - Toggle brass ejection/shell casings on weapons. Useful for low-performance systems.
  • cl_detaildist <int> - How far away to render detail sprites. Set to 0 on maps with broken detail sprites, or crank it up for pretty photos. 1200 is a decent setting for average play on good machines.
  • cl_detailfade <int> - Distance in Hammer Units at which props begin to fade in. Default of 400 is fine for average usage.
Flushing
  • r_flushlod - flushes the model cache. Can be used to prevent overfilling it (hitting the max of 2048 will crash the game), or to empty the cache to see the changes to a recompiled model on the spot.
  • mat_reloadalltextures - empty & reload the texture cache.
  • reload - reloads the most recent save, or reloads the entire map depending on the circumstances.
  • impulse 203 - Remove the object you're aiming at. Dangerous command: use at own risk.
  • hud_reloadscheme - Reload the HUD files.
  • vehicle_flushscript - Reload the vehicle script files.
  • r_cleardecals - Clear all dynamic decals (blood, bullet holes, etc.) from the map.
Game Settings
  • hl2_episodic <bool> - enable some minor effects used in EP1 & EP2. May not be immediately visible or very obvious. Recommended to leave off in HL2 as it will make Zombies burst into flames & break in half on damage.
  • sv_unlockedchapters <int> - Unlock or lock chapters in the game. Set to 0 to essentially reset progression, or to 99 to unlock all features. SiN Episodes uses the 99 setting to enable the HARDCORPS new game plus mode, for example.
  • sv_infinite_aux_power <bool> - Toggle infinite suit power (i.e. sprinting, torch battery, oxygen, etc.)
  • sk_auto_reload_time <int> - How many seconds after it was holstered to auto-reload the weapon. If set to 3, it will reload the weapon three seconds after being holstered. Setting it to 0 will cause the weapon to be reloaded immediately on holster. You can't disable this setting, but you can set the time to 9999 to make it take so long you'd never notice. I personally recommend 90 as that's a long enough time to be useful without being intrusive.
  • sv_restrict_aspect_ratio_fov <int> - Restrict the effective FOV. 0 is unclamped. 1 is capped on anything >=1.85:1 ratios. 2 is capped on ALL ratios.
Saving
  • sv_autosave <bool> - Toggle autosaving; saving on level transitions will still occur.
  • save_screenshot <int 0-2> - Save a screenshot on the save. 0 = no screenshot, 1 = manual saves only, 2 = always.
  • save_history_count <int> - How many save iterations to keep. Default is 1, while 3 would keep 3 copies of the saves.
  • save_console <bool> - Toggle console-style saving.
  • autosave - Force an autosave.
  • autosavedangerous - Force a "dangerous" autosave. These are used when an autosave occurs while enemies are nearby.
  • save_disable <bool> - COMPLETELY disable saving, even quick saves. If you die, the game resets to the start. Bring your A-game. Warning: will break maps that tie their area portal states to the autosave triggers.
Interface & HUD
  • hud_deathnotice_time <int> - how long to show death notices on the top right before making them fade. Set to 0 to disable the feed visibility.
  • closecaption <bool> - Toggle full closed captioning support. Not compatible with cc_subtitles.
  • cc_subtitles <bool> - Toggle subtitles. Not compatible with closedcaption.
  • mat_yuv <bool> - toggle the entire game to be in YUV grayscale[en.wikipedia.org]. As compared to a custom color correction scheme, this will affect everything, including VGUI & menu elements.
  • mat_colorcorrection <bool> - Toggle colour correction capabilities. If you're on a map that has some god-awful colour corrections like some obnoxious GMod RP maps do, you'll enjoy turning this off.
  • hud_showemptyweaponslots <bool> - Toggle showing weapon slots if there is no weapon currently in them. i.e. show the Shotgun/Crossbow slot if neither have been picked up.
  • hud_quickinfo <bool> - toggle the Xbox-style reticle that shows health on the left & magazine left on the right.
  • hud_draw_fixed_reticle <bool> - toggle the fixed reticle for the quick info command around the normal crosshair.
  • hud_draw_active_reticle <bool> - make the fixed reticle change colours when over friendly or enemy NPCs.
  • cl_showpausedimage <bool> - Hide the PAUSED text when the game is paused.
  • cl_showhelp <bool> - disable the HUD hints.
  • hud_jeephint_numentries <int> - max number of hints to show for the Jeep. Set to 0 to disable the hints.
  • hud_airboathint_numentries <int> - same as abouve, but for the Airboat. Set to 0 to disable hints.
  • commentary <bool> - Toggle developer commentary mode. This is the command used by the game when toggling commentary mode.
  • radar_range <int> - Set the range at which the EP2 Muscle Car's radar scans for caches.

An example of mat_yuv 1
Sound System
  • dsp_off <bool> - Toggle DSP effects. Useful for testing sounds without background interference.
  • stopsoundscape - Stop the currently active soundscape. Useful for the same reason as abouve.
  • stopsound - Stops all sounds currently playing. Will not stop soundscape the player is current inside the volume of. This command is known to break sounds, so use sparingly.
  • snd_restart - restart the sound system of the game. It is greatly advised to use this command over stopsound as this command won't break soundscapes, soundscripts, or entity sounds.
Inputs & Controls
  • key_listboundkeys - return a list of all your bound keys
  • key_findbinding <string> - find keys bound to a specific string in the command name
  • key_updatelayout - updates the keyboard layout in-game to the current Windows setting; i.e. DVORAK or QWERTZ
Movement
  • toggle_duck - toggle the player's crouch status. The same as using +duck, but a toggle instead of a hold.
  • sv_stickysprint <bool> - Change the sprint from hold to toggle. Will continue sprinting until the player stops moving.
Ladders
  • sv_autoladderdismount <bool> - Toggle auto-mounting of ladders when near an exit point. If turned off, you'll need to press +use to dismount manually.
  • sv_ladderautomountdot <float> - The dot product[en.wikipedia.org] of how close you have to look at a dismount point to trigger getting off on it. 1 would make it have almost no automount, while 0 would mount it even if you're not facing it. Default of 0.4 is fine in most situtations.
  • sv_ladder_useonly <bool> - Toggle whether you can auto-mount a ladder by being close, or if you must use your use key to grab it.
Flashlight
  • impulse 100 - Toggle the flashlight.
  • r_flashlightfov <int> - the field of view that flashlight will have. Default is 45, while setting it to 90 will drastically improve the effectiveness of the torch, especially on ultrawide resolutions like 21:9 or 32:9
  • r_newflashlight <bool> - Toggle between HL1-style flashlight or HL2 style. HL1 style emits from the crosshair, while HL2 style emits from the player.
  • r_flashlightlockposition <bool> - Lock the flashlight to whatever position it was created at, making it independent of the player. Will delete itself when turned off.
AI System
  • notarget - NPCs will ignore the player, but otherwise operate normally.
  • ai_disable - Completely disables the AI system. May break maps & level progression. Use at own risk.
  • ai_norebuildgraph <bool> - Hides the NODEGRAPH OUT OF DATE, REBUILDING text. HDtF wishes they knew about this one.
Squad Behavior
  • npc_citizen_auto_player_squad <bool> - Citizens will immediately join the player's squad, and can't be removed until they die.
  • npc_citizen_auto_player_squad_allow_use <bool> - Allows the player to manually add/remove Citizens from their squad by pressing +use on them. Requires npc_citizen_auto_player_squad 0 to properly work.
  • npc_citizen_insignia <bool> - places a visible model on the Citizens in your squad. In the case of HL2, it's a chef hat.
  • player_squad_autosummon_time <int> - How long the squad must be in one position after being sent there before they will automatically go back to following the player. Default of 5 is annoyingly low. Set to something like 64 in order to make them stay for a while.
  • player_squad_autosummon_time_after_combat <int> - Similar to above, but after a combat phase. Default of 8 is similarly annoyingly low. Set to another higher number based on user preference to make the follow or wait. 32 is a decent number.
  • player_squad_autosummon_move_tolerance <int> - How far the player can move away before they will autosummon based on distance. Useful to set to something like 64 or such in case you forget them. Default of 20 is somewhat low if doing more fine-tuned placement. This is not in Hammer units![github.com]
  • player_squad_autosummon_player_tolerance <int> - Similar to above. Setting both to the same value probably wouldn't hurt, but I need more data. Default of 10 is pretty low, however.
  • player_squad_transient_commands <bool> - Toggle the entire autosummon functionality. The squad command panel will also change from a blank text display (where the SQUAD FOLLOWING text will appear) to show SQUAD STATIONED instead. If you combine this with npc_citizen_auto_player_squad 0 and npc_citizen_auto_player_squad_allow_use 1 you can very effectively make the NPC stay and hold down one spot.
  • impulse 50 - The send/recall command.
Rebels/Citizens
  • npc_citizen_explosive_resist <bool> - When set to 0, Citizens will essentially die to one grenade or explosion as a one-hit-kill.
  • npc_citizen_squad_marker <bool> - similar to the previous command, but puts a crosshair gizmo beneath your squad members' feet.
  • sk_citizen_heal_ally <int> - how much medics will heal you, per medshot.
  • sk_citizen_heal_ally_delay <int> - how many seconds between heals.
  • sk_citizen_heal_ally_min_pct <float> - how low your health must be before they will heal you in a decimal. i.e. 0.9 would be 90/100 health.
  • sk_citizen_giveammo_player_delay <int> - how long in seconds the NPCs must wait before they give you more ammo.
Other NPCs
  • monk_headshot_freq <int> - how many shots Father Grigori must fire before it will guarantee a headshot. Default of 2 means every two normal shots will guarantee a headshot next, while 0 will make everything a headshot. Higher values will create a longer interval before another headshot.
  • sk_helicopter_num_bombs1 / sk_helicopter_num_bombs2 / sk_helicopter_num_bombs3 <int> - How many bombs should the npc_helicopter drop at any given time, per difficulty. Default for easy & medium are 3, hard is 5.
  • sk_helicopter_grenaderadius <int> - The explosion radius of the helicopter bombs. Setting to <= 0 will cause all players in the entire world to be affected by the screen shake.
Spawning & Creation
  • ch_createjeep - create a Jeep; same as impulse 82.
  • ch_createairboat - create an Airboat; same as impulse 83.
  • npc_create <NPC class name> - spawn an NPC of the specified class. i.e. npc_create npc_citizen or npc_create npc_combine_s.
  • npc_create_equipment <weapon script name> - spawns NPCs with the specified weapon name. i.e. npc_create_equipment weapon_shotgun.
  • prop_physics_create <model path> - Spawn a physics prop of the specified type. i.e. prop_physics_create props_c17/oildrum001_explosive.
  • prop_dynamic_create <model path> - Spawns a dynamic prop of the specified type. Might present errors if the model has no prop_data or $staticprop flags in the compiled model.
  • impulse 201 - Spray command.
Items
  • sk_battery <int> - how much item_suit power item_battery pickups will provide. Default is 15. Picking up weapon_stunstick entities in HL2 will provide 50% of this value, rounded up[github.com].
  • sk_ammo_qty_scale1 <float> - How much ammo to provide on pickup in easy difficulty. Default 1.2.
  • sk_ammo_qty_scale2 <float> - How much ammo to provide on pickup in normal difficulty. Default 1.0.
  • sk_ammo_qty_scale3 <float> - How much ammo to provide on pickup in hard difficulty. Default 0.6.
  • sk_max_<ammo type> <int> - Controls how much ammo the player can pickup of a given ammo type. Setting any of the values to -2 is unlimited ammo.
Weapons
  • impulse 101 - The classic. Give all weapons.
  • lastinv - switch the last weapon used. Useful when making quick-switch commands in chain bindings.
  • use <weapon script name> - instantly select a weapon from your inventory. i.e. use weapon_357.
  • phys_swap - instantly swap to the Gravity Gun. Essentially the same as using use weapon_physcannon.
  • bug_swap - instantly swap to the Bugbait. Essentially the same as using use weapon_bugbait.
  • give <weapon script name> - Give the specified weapon. i.e. give weapon_357.
  • givecurrentammo - Give the maximum amount of ammo for the currently equipped weapon.
  • hud_fastswitch <int 0-2> - Set the fast switch setting. 0 = disabled, 1 = PC fast switch, 2 = console-style selection.
  • toggle_zoom - toggle the player's Suit Zoom. The same as using +zoom, but a toggle instead of a hold. Unlike +zoom, will not block the player from firing.
  • impulse 200 - Holster your weapon view model. Will just disappear if the weapon lacks an ACT_VM_HOLSTER activity. Cheat flagged.
  • viewmodel_fov <int> - Change the field of view of the view model. 74 is a good number, as going any higher causes the inverted view model bug when using zoom. Cheat flagged.
  • sk_weapon_ar2_alt_fire_duration <int> - How long a prop_combine_ball will last until it self-destructs, in seconds. Default is 2.
  • sk_weapon_ar2_alt_fire_mass <int> - The physical mass of the prop_combine_ball when it hits a surface. Higher mass values will cause more screen shaking. Default of 150.
  • sk_plr_num_shotgun_pellets <int> - How many pellets the player's shotgun blasts will fire. Default of 7.
  • pistol_use_new_accuracy <bool> - When enabled, will make the first shot accurate and rapid follow up shots inaccurate. When disabled, the pistol will be locked to a 4 degree spread cone. (Source)[github.com]
Vehicles
  • sv_airboat_wheel_fix <bool> - Works around the wheel being misnamed on the airboat (wheele_rr vs wheel_rr) for people who prefer 'fixed' handling. Only affects new spawns.
Conclusion
I might find more over time, and I might have some stuff wrong. Feel free to suggest changes, or to ask for clarifications.

I've also attached a blank bind config file that you can view for an idea of all the keys you can assign. I'm using a US English Standard QWERTY keyboard, so please take note of that if you use something else like DVORAK or QWERTZ.

https://pastebin.com/FT8V1Pbu
16 kommenttia
[OSU44] Smahpah 19.8.2023 klo 21.35 
how do i both, see the npc nodegraph and 2, how do i move around when my camera and position is locked (for example, backgrounds)
fjrjirigj30ggneoeeo 10.3.2022 klo 19.38 
is there a list for launch options for source engine games? for use of tweaking performance, for example, like changing resolution or turning on vsync upon launching. because, whenever i launch a source game in which it has one of the launch options like changing specific directx version, the ingame graphics settings, including resolution and vsync, force themselves to reset, and its a bit time consuming and annoying to change them back.
V92  [tekijä] 27.2.2022 klo 20.55 
@reality

That's tied to the AR2 ball AFAIK.
john_fallout 27.2.2022 klo 19.18 
how do you disinigrate people liike the portal fizzle thing (sorry for the vague question)
V92  [tekijä] 7.2.2022 klo 17.04 
@aeris

It uses the same color values as the Buggy's tau cannon crosshair. It'll turn to red over enemies.
Aeris 7.2.2022 klo 3.24 
I have put your clean scripts folder inside custom\mycustomstuff (just to let u know I did it right here) with nothing else,
and still the reticle doesn't have any color change.

BTW what color would the fixed reticle change into?
By normal it have the same brownish-yellow color like the regular quick-info reticle. The only color change is the quick-info reticle that turn red during low ammo or low health.
V92  [tekijä] 7.2.2022 klo 2.48 
@aeris

As a test, try throwing this in your custom folder and see if it works.

https://cdn.discordapp.com/attachments/890800091659649075/940197292454080592/scripts-sanitized_weapons.7z
Aeris 7.2.2022 klo 2.41 
Yeah I made some minor script changes myself based on the original one but I didn't touch anything related to the fonts.

I just removed all my stuff from my custom folder and the fixed reticle still doesn't have any color change.
V92  [tekijä] 7.2.2022 klo 2.10 
@aeris

It works in HL2. Are you using custom weapon scripts or vanilla? The crosshairs use fonts found in the halflife2.ttf fonts in the resource folder, defined by a letter in the weapon script's entries.