Env global: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Added the "Entity also in GoldSrc" Template.)
(Filled in some info on env_global and global states)
Line 5: Line 5:
{{base point|env_global}} It controls game-specific global states, such as whether the [[weapon_physcannon|gravity gun]] should become the super gravity gun in HL2.
{{base point|env_global}} It controls game-specific global states, such as whether the [[weapon_physcannon|gravity gun]] should become the super gravity gun in HL2.


For this entity to take effect from the map's start, the '''Set Initial State''' [[flag]] must be checked.
Global states persist across level transitions, regardless of their status. Use the <code>dump_globals</code> console command to list all stored global states. {{note|Global states are not stored until an <code>env_global</code> receives any commands that modify the state, such as turning it on or off or changing the counter. Use the <code>Set Initial State</code> [[flag]] for the global to be added on spawn.}}
 
To remove a global from the table entirely, set its state to "Dead" using the <code>Remove</code> input. It will remove itself on the next level transition. {{confirm}}
 
Globals and their current state (in integer form) are added to all entites' response data for use in the [[Response System]].


==Keyvalues==
==Keyvalues==
Line 21: Line 25:
:* Episodic: Alyx darkness mode
:* Episodic: Alyx darkness mode
:* Ep2 Counter: Hunters to run over before they dodge
:* Ep2 Counter: Hunters to run over before they dodge
{{tip|Global states are not exclusive to these choices, and may be any text.}}
}}
}}
{{ScrollBox|title=EnvGlobal|
{{ScrollBox|title=EnvGlobal|
{{KV|Initial State|choices|Whether the entity should be active when the map starts.
{{KV|Initial State|choices|Used by <code>Set Initial State</code> to determine what the global state should be set to when the map starts.
:* Off
:* Off
:* On
:* On
:* Dead ({{todo|What does that mean?}})
:* Dead
}}
}}
{{KV|Counter|int|An integer counter value associated with this global.|since=EP2}}
{{KV|Counter|int|An integer counter value associated with this global.|since=EP2}}

Revision as of 09:36, 2 August 2018

Env global.png

Template:Base point It controls game-specific global states, such as whether the gravity gun should become the super gravity gun in HL2.

Global states persist across level transitions, regardless of their status. Use the dump_globals console command to list all stored global states.

Note.pngNote: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 global to be added on spawn.

To remove a global from the table entirely, set its state to "Dead" using the Remove input. It will remove itself on the next level transition. [confirm]

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

Keyvalues

Global State to Set ([todo internal name (i)]) <choices>
Game-specific global state that this entity sets. In practice all of Valve's FGDs include the HL2 states regardless of whether the game understands them.
  • Gordon pre-criminal
  • Antlions are player allies
  • Suit sprint function not yet enabled
  • Super phys gun is enabled
    Note.pngNote:Doesn't work in HL2:DM.
  • Friendly encounter sequence (lower weapons, etc.)
  • Gordon is invulnerable
  • Don't spawn seagulls on the jeep
  • Episode 2: Alyx injured
  • Episodic: Alyx darkness mode
  • Ep2 Counter: Hunters to run over before they dodge
Tip.pngTip:Global states are not exclusive to these choices, and may be any text.
EnvGlobal:
Initial State ([todo internal name (i)]) <choices>
Used by Set Initial State to determine what the global state should be set to when the map starts.
  • Off
  • On
  • Dead
Counter ([todo internal name (i)]) <integer> (in all games since Half-Life 2: Episode Two)
An integer counter value associated with this global.
Icon-Bug.pngBug:There is an aliasing problem for this keyvalue. To make it work, simply change its name in the source code DEFINE_OUTPUT declaration.  [todo tested in ?]
Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Flags

  • Set Initial State: Whether this entity defines the global state when the map starts.

Inputs

EnvGlobal:
TurnOn / TurnOff
Sets the global's state.
Toggle
Toggles state of global between ON and OFF.
Remove
Set state of global to DEAD.
AddToCounter <integerRedirectInput/integer> (in all games since Half-Life 2: Episode Two)
Adds the specified amount to the counter.
SetCounter <integerRedirectInput/integer> (in all games since Half-Life 2: Episode Two)
Sets the value of the counter.
GetCounter  (in all games since Half-Life 2: Episode Two)
Fires this entity's Counter output.

Outputs

EnvGlobal:
counter <integerRedirectInput/integer> (in all games since Half-Life 2: Episode Two)
Outputs the integer value of this entity. May depend on global state.