env_global
Code classes:
CEnvGlobal
CLogicalEntity
CServerOnlyEntity
CBaseEntity
(all ents)
env_global
is a point entity present in all Source games. It controls game-specific global states, such as whether the 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/Command | Parameters or default value | Parameter Type | Effect |
---|---|---|---|
dump_globals |
| Dumps data for all set global states. | |
global_set | globalname state | string, integer | Set the status of a global state. First parameter is the name of it, second is a number.
|
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 |
---|---|---|
gordon_precriminal | Gordon pre-criminal | Creates the pre-criminal (passive) NPC behavior seen in Point Insertion. |
antlion_allied | Antlions are player allies | Makes antlions friendly to the player and allows them to listen to bugbait. |
suit_no_sprint | Suit sprint function not yet enabled | Disables the HEV suit's sprint function. (Not required if the HEV suit is not equipped.) |
super_phys_gun | Super phys gun is enabled | Enables the supercharged gravity gun seen in the Citadel. Not functional in Half-Life 2: Deathmatch. |
friendly_encounter | Friendly encounter sequence (lower weapons, etc.) | Indicates a friendly encounter sequence. Appears to just keep the player's weapons lowered. |
gordon_invulnerable | Gordon is invulnerable | Makes the player invulnerable to damage. Secondary effects of damage still appear, such as being knocked back and view shaking. |
no_seagulls_on_jeep | Don't spawn seagulls on the jeep | Prevents seagulls from spawning on the jeep. |
ep2_alyx_injured (only available in Episodic) | Episode 2: Alyx injured | Invokes Alyx's "injured" behavior:
Note: This applies to the |
ep_alyx_darknessmode (only available in Episodic) | 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 Episodic) | 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. |
player_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.