env_global

From Source Entities
Jump to navigation Jump to search

Code classes:

Env global.png

env_global is a point entity present in all Source games. It controls game-specific global states, such as whether the Hl2.png gravity gun should become super-charged.

Global states persist across level changes (when done with changelevel or trigger_changelevel), regardless of their status. Global states are not stored until an env_global receives any commands that modify the state, such as turning it on or off, or changing the counter. Use the Set Initial State flag for the setting to be added when the map loads.

Can be used in multiplayer games to store info across rounds (other entities will reset to their values set in Hammer). This also includes across maps.

Globals and their current state (in integer form) are added to all entities' response data for use in the Response System.

Tip: In code, use GlobalEntity_GetState(string) to check a global's state. E.g. GlobalEntity_GetState( "ep_alyx_darknessmode" ) == GLOBAL_ON.

ConVars/Commands[edit | edit source]

ConVar/CommandParameters or default valueParameter TypeEffect
dump_globalsDumps data for all set global states.
global_setglobalname statestring, integerSet the status of a global state. First parameter is the name of it, second is a number.
  • 0 = off
  • 1 = on
  • 2 = dead
A global can also be created instantly with this command.

Flags[edit | edit source]

  • 1: Set Initial State - Makes this entity define the global state once the server loads the map.

Keyvalues[edit | edit source]

Global State to Set (globalstate) <choices>
The global state this entity is linked to. In practice all of Valve's FGDs include the HL2 states regardless of whether the game understands them. Global states are not exclusive to these choices and any text can be used.
Internal (actual) Name Editor (SmartEdit) Name Description
Hl2.pnggordon_precriminal Gordon pre-criminal Creates the pre-criminal (passive) NPC behavior seen in Point Insertion.
Hl2.pngantlion_allied Antlions are player allies Makes antlions friendly to the player and allows them to listen to bugbait.
Hl2.pngsuit_no_sprint Suit sprint function not yet enabled Disables the HEV suit's sprint function. (Not required if the HEV suit is not equipped.)
Hl2.pngsuper_phys_gun Super phys gun is enabled Enables the supercharged gravity gun seen in the Citadel. Not functional in Hl2.pngHalf-Life 2: Deathmatch.
Hl2.pngP2.pngfriendly_encounter Friendly encounter sequence (lower weapons, etc.) Indicates a friendly encounter sequence. Appears to just keep the player's weapons lowered.
Hl2.pnggordon_invulnerable Gordon is invulnerable Makes the player invulnerable to damage. Secondary effects of damage still appear, such as being knocked back and view shaking.
Hl2.pngno_seagulls_on_jeep Don't spawn seagulls on the jeep Prevents seagulls from spawning on the jeep.
ep2_alyx_injured (only available in Hl2.pngEpisodic) Episode 2: Alyx injured Invokes Alyx's "injured" behavior:
  • Increases time between shots
  • Triples bullet spread

Note: This applies to the weapon_alyxgun entity, not specifically Alyx.

ep_alyx_darknessmode (only available in Hl2.pngEpisodic) Episodic: Alyx darkness mode Enables "darkness mode", as seen during the "Lowlife" chapter of Episode One. Despite the name, this also affects the player, zombies, and even fires in various ways to make them more realistic for darkness.
hunters_to_run_over (only available in Hl2.pngEpisodic) Ep2 Counter: Hunters to run over before they dodge The number of hunters that should be run over before they start dodging vehicles. By default, hunters will try to dodge incoming vehicles. If this global is declared and its counter is greater than 0, hunters will not try to dodge incoming vehicles. Instead, this global's counter will decrement by 1 each time a hunter is killed by a vehicle. When it reaches 0, hunters will return to dodging vehicles.
P2.pngCsgo-small.pngplayer_regenerates_health (Not in FGD) Health Regenerates
Initial State (initialstate) <choices>
Used by Set Initial State to determine what the global state should be set to when the map starts.
  • 0: Off
  • 1: On
  • 2: Dead (Dead globals get turned off permanently, and can never be put back to Off or On.)
Counter (counter) <integer>
An integer counter value associated with this global.
Bug: This keyvalue shares its name with the Counter output, leading to a conflict that results in neither working.
Fix: Change the name of either in code.

Inputs[edit | edit source]

TurnOn
Sets the global's state to ON.
TurnOff
Sets the global's state to OFF.
Toggle
Switches state of the global between ON and OFF.
Remove
Set state of global to DEAD.
AddToCounter <integer>
Adds the specified amount to the counter. Not useful because Counter output never fires.
SetCounter <integer>
Sets the value of the counter. Not useful because Counter output never fires.
GetCounter
No effect.

Outputs[edit | edit source]

Counter <integer>
Does not fire due to conflict with the keyvalue of the same name.

See Also[edit | edit source]