This article's documentation is for anything that uses the Source engine. Click here for more information.

logic_auto

From Valve Developer Community
Jump to navigation Jump to search
English (en)Português do Brasil (pt-br)Русский (ru)Translate (Translate)
Logic auto.png

logic_auto is a point entity available in all Source Source games.

Class hierarchy
CLogicAuto
CBaseEntity
logicauto.cpp

It fires outputs immediately after a map loads, unlike most other entities that wait for input first. It can be set to check a global state before firing, which allows you to fire events based on what took place in a previous map.

Warning.pngWarning:Attempting to directly access or modify the player may cause Access Violation errors, because the outputs are fired before the player has spawned. Adding a slight time delay may overcome this.
Warning.pngWarning:This entity counts as an edict, not a logical entity as one would expect, and therefore it can contribute to the entity limit. If this is an issue, use logic_relay and its OnSpawn output.
Note.pngNote:In Counter-Strike: Source Counter-Strike: Source and Counter-Strike: Global Offensive Counter-Strike: Global Offensive when a map loads and when the round is reset (Counter-Strike: Global Offensive CS:GO including resets for warmup and resets in any other game mode), this entity fires the 3 outputs OnNewGame/OnBackgroundMap (exactly one of these, see below), OnMapSpawn and OnMultiNewMap in this order.
Note.pngNote:In Counter-Strike: Global Offensive CS:GO the output OnMultiNewRound is actually fired in response to the game events round_start and teamplay_round_start and does not depend on the Global State to Read. When a round is reset, it is fired before the previous 3, but not when a map is loaded.

Keyvalues

Global State to Read (globalstate) <choices>
If set, this specifies a global state to check before firing. Outputs are only fired if this global state exists and if it is turned on.
Note.pngNote:Valve's FGDs always include the Half-Life 2 Half-Life 2 global states here, but any value can be entered. See env_global for a list of default global states in each game.

Flags

[ 1 ] : Remove on fire
Whether the logic_auto is deleted after firing. Delayed outputs will still work, however.

Outputs

OnMapSpawn
Fired shortly after the entity spawns (including loading saves).
OnNewGame
Fired when the map is loaded to start a new game.
OnLoadGame
Fired when the map is loaded from a saved game.
OnMapTransition
Fired when the map is loaded due to a level transition.
OnBackgroundMap
Fired when the map is loaded as a background to the main menu using map_background.
OnMultiNewMap
Fired shortly after the entity spawns but only in multiplayer and if the round wasn't restarted
Note.pngNote:In Left 4 Dead series fires only on first map load in a session. Any subsequent round restart or transition to next chapter will have OnMultiNewRound fired
OnMultiNewRound
Fired shortly after the entity spawns but only in multiplayer and if round was restarted
Warning.pngWarning:Team Fortress 2 Does not get fired when tournament mode is enabled (mp_tournament 1). Use OnMapSpawn instead
OnDemoMapSpawn  (only in Left 4 Dead 2)
Fired when the map is loaded in Demo Mode.
Only in SiN Episodes SiN Episodes
OnViolenceLow
Fired when the map is loaded for any reason if the game is in low-violence mode.
OnViolenceHigh
Fired when the map is loaded for any reason if the game is not in low-violence mode.

See Also