AddOutput
AddOutput
is an input available in all Source games. Its primary purpose is registering additional actions for when entity's chosen output fires. In other words, it "adds" an output.
Syntax:
<output> <target>:[input]:[parameter_override]:[delay]:[times to fire (-1 or 0 = infinity, 1 = once, 2 = twice ...)]
- < > = mandatory parameter
- [ ] = optional parameter, if left unspecified the preceding
:
symbol can be left out if no latter optional parameters need to be specified - output - existing output on the given entity
- target - targetname of the targeted entity (special targetnames like !caller, !activator, !self etc. are also supported)
- input - input to be used on targeted entity (if left blank
Use
input us used) - parameter_override - parameter (if left blank and the given output holds a value then that will be automatically filled in)
- delay - delay in seconds (left blank means 0)
- times to fire - number of times this output can fire this action (left blank means -1)
Example
We have a math_counter named counter
.
The following shows an output that could be setup on a trigger_once in Hammer:
My output named: OnStartTouch Target entities named: counter Via this input: AddOutput With a parameter override of: OutValue car:skin
The following are equivalent
OutValue car:skin
OutValue car:skin:::
OutValue car:skin::0:-1
The parameter_override is left blank which means it will be filled with value of math_counter's OutValue.

\"
characters). It will cause fatal errors with opening and/or compiling your map and may need to be fixed by manually editing the VMF in a text editor. Instead, use detailed quotes (i.e. “
and ”
) or two apostrophes ( '' ).Using AddOutput to change keyvalues
Because of the way outputs work, AddOutput also allows changing any entity's keyvalues. This includes targetname, rendercolor, solid and more. As this is not something AddOutput was designed for, not all keys will work as expected when changed this way.
Syntax: <key> <value>
Due to how much AddOutput lets you manipulate entities properties it might be therefore a way to optimize maps which utilize env_entity_maker, point_teleport, game_text and more which count as edict.


Examples of keyvalues whose change might not have desired effect
- classname
- classname is first key read from a map file and determines what C++ class to use to spawn an entity, therefore changing this later via AddOutput will not truly change an entity into a different one. But there are sometimes checks in code that determine some behavior purely on the value of
classname
for example see Preserved entities. ([Todo] some more example) Warning:Doing this in games with save files is not advised, as saving an entity with the wrong classname means it won't be recreated properly (or at all).
Warning:Changing the classname of a player causes problems and should be avoided at all costs.
Note:Certain entities rely upon classname, so this is generally discouraged.
- parentname
- Won't have an effect when changed via AddOutput as parent/child hierarchy is setup when all entities are being spawned and not later.
- SourceEntityName of ambient_generic
- ambient_generic searches for the entity named SourceEntityName when it spawns so changing it later via AddOutput won't have an effect.

Limitations
- It's not possible to add an output with this that uses AddContext input because AddContext also uses ':' in its syntax.
- Colons (:) are automatically converted to commas when parsed by AddOutput. As such, standard colons are unavailable to be used by values set by AddOutput, which mainly impacts entities such as game_text which let the mapper set some custom text.
- Since AddOutput uses a space in its syntax, outputs and keyvalues which have spaces cannot be modified. Fortunately, this is unlikely to ever be an issue, as no vanilla entities use spaces for these.
Firing AddOutput via ent_fire
Because AddOutput uses a space in its syntax, it's required to enclose the ent_fire parameter in quotes.
To add output:
ent_fire <entity name> addoutput "<output> <target>:[input]:[parameter_override]:[delay]:[times to fire]"
To change keyvalue:
ent_fire <entity name> addoutput "<key> <value>"
Examples
- Format:
<key> <value>
{ "classname" "trigger_once" . . . 'OnStartTouch" "game_text,AddOutput,message There is a fire ahead. Go the other way!,0,1 'OnStartTouch" "game_text,Display,,0.02,1 }
This changes the text of a game_text and then displays it. This is useful as to prevent having an unneccesary amount of game_text which counts as edict
- Format:
<output> <targetname>:<input>:<parameter>:<delay>:<refire>
{ "classname" "tf_logic_auto" . . . 'OnMapSpawn" "team_round_timer_red,AddOutput,OnFinished game_round_win:RoundWin::0:-1,0,-1 }
This adds an output to an entity with the targetname "team_round_timer_red".
- Trigger_Multiple
- Name: Ghost
- Outputs
- My Output Named: OnEndTouch
- Targets entities named: !activator
- Via this input: Alpha
- With a parameter override of: 255
- After a delay in seconds: 0.10
- My Output Named: OnStartTouch
- Targets entities named: !activator
- Via this input: AddOutput
- With a parameter override of: rendermode 1
- After a delay in seconds: 0.00
- My Output Named: OnStartTouch
- Targets entities named: !activator
- Via this input: Alpha
- With a parameter override of: 120
- After a delay in seconds: 0.00
Results in translucent player when standing in the trigger_multiple (OnStartTouch) and visible again when not in the trigger_multiple (OnEndTouch).
See alsо
- Optimizing Edict's & Mapping Tricks - Using AddOutput to reduce mapspawn edicts on really large maps