Skip to main content

Light styles

Light styles make your lights flicker, pulse, fade or go out while the map runs. They can also switch the whole map between day and night without a new compile. A light style is a pattern of brightness that the engine plays on a group of lights. A trigger_lightstyle changes the style of named lights, and a global_light_control changes many lights at once.

The light styles room of co_sbo_showcase shows flicker, candle, pulse and a power failure with a red alarm light, and the west wall of its courtyard switches between day and night.

The showcase light styles room: a fluorescent flicker, a candle, a slow pulse, then a power failure where the lights fade out, a red alarm pulses and the lights come back

Light styles: flicker, candle, pulse and a power failure with a red alarm

Styles and patterns​

A pattern is a string of letters from a for dark to z for bright, where m is normal brightness. The engine plays the pattern at 10 letters a second and starts again at the end, so mmamammmmammamamaaamammma is a flicker. Each light belongs to one style, and the styles have these numbers:

StyleWhich lights
0Every light without a name and with the normal appearance
1 to 12The preset styles of Half-Life, set with the Appearance of a light
32 to 63Named lights, where the compiler gives each name its own style

Lights with the same name have the same style, so you can change lights separately only if they have a name. Before the game uses a pattern from the map, it cleans it: capital letters become small letters, the game removes other characters, and it keeps only the first 63 letters. An empty pattern counts as m.

trigger_lightstyle​

When you trigger a trigger_lightstyle, it gives a new appearance to its target lights.

KeyDescriptionDefault
Light(s) to affect
target
The name of the lights. !activator also works
New appearance
appearance
One of the presets in the table belowNormal (steady) (0)
Custom appearance
pattern
A pattern of letters. If you set one, the entity ignores New appearance
Fade time
m_iFade
How many whole seconds the lights take to fade to the new appearance0
Hold time
m_iWait
How many seconds the new appearance stays before the lights go back to their own style. Decimals such as 0.6 work, and -1 keeps the new appearance permanently-1
Reset light styles at round start
round_reset
See Round resetNo (0)
ValueAppearanceValueAppearance
0Normal (steady)10Fluorescent flicker
1Flicker A11Slow pulse, noblack
2Slow, strong pulse12Underwater
3Candle A13Off
4Fast strobe14Slow fade in
5Gentle pulse15Medium fade in
6Flicker B16Fast fade in
7Candle B17Slow fade out
8Candle C18Medium fade out
9Slow strobe19Fast fade out

During a fade, the brightness changes evenly over the Fade time, from the first letter of the current pattern to the first letter of the new pattern, in steps every 0.1 seconds, and then the new pattern plays. A light's own style is its pattern while it is on, and a while it is off. If you turn a light on or off by its name, this ends a fade or a hold on it. The entity skips a target that isn't a named light, light_spot or light_environment. With developer 1 set in the console, the console reports it.

global_light_control​

When you trigger a global_light_control, it sets one pattern on many styles. Without flags, that is style 0, which is the style of every light that has no name.

KeyDescriptionDefault
Pattern
pattern
The pattern to setm
Only these named lights
target_entity
If you give a name, only the styles of the lights with this name change, and the entity ignores its flags
Reset light styles at round start
round_reset
See Round resetNo (0)

It has these flags:

  • Also styles 1-63 (65536) - The styles 1 to 63, which are the presets and the named lights, also change
  • Not the default style (131072) - Style 0, the style of lights without a name, doesn't change

With no flags, only style 0 changes. A global_light_control without a name sets its pattern when the map starts. This gives the whole map a different base light without a new compile.

global_light_control switches the whole map between day and night

The whole map switched between day and night

Round reset​

If a trigger_lightstyle or global_light_control has Reset light styles at round start set to Yes, the light styles go back to their patterns from the map start at each round start, so a power failure in one round doesn't continue into the next round. The reset includes:

  • The styles of the world
  • Each named light's own style, and the light stays on or off as it is at that moment
  • The pattern of each global_light_control without a name

Fades and holds of a trigger_lightstyle end with the reset.

The reset happens once at each round start, also if many entities have the key.

Players who join​

The engine sends the current pattern of every style to a player who connects. So players who join late, and spectators, see the lights in their current state.

Notes​

  • The engine has 64 styles, from 0 to 63, and the compiler gives named lights the styles 32 to 63
  • A pattern can have up to 63 letters
  • A face of the map holds the light of up to four styles, and when more styles reach one face, the compiler leaves some of them out, so those lights don't light that face at all. See Compiler notes for more details
note

ZHLT, VHLT, SDHLT, ReSDHLT and hltools give the style of its name to every named entity with a style key other than 0, not only to lights. For this reason, trigger_lightstyle uses the key appearance. See Compiler notes for more details.

Changes since 1.38​

  • Light styles can change while the map runs, with trigger_lightstyle and global_light_control

See also​