Skip to content

Switchable (Emergency) Lighting

To implement switchable lighting we will need: light_surface (2 pcs.) trigger_changetarget (2 pcs.) env_render (2 pcs.) multi_manager (3 pcs.) trigger_auto (1 pc.) func_door (1 pc.) func_rot_button (1 pc.) func_wall (1 pc.) func_detail (1 pc.) Note: In this method, for the emergency lighting…

Mapping·6 min read·SkripViews:22
Contents
  1. Preparing the lighting for the logic
  2. Logic
  3. Final stage
SwitchableLighting

To implement switchable lighting we will need:

  • light_surface (2 pcs.)
  • trigger_changetarget (2 pcs.)
  • env_render (2 pcs.)
  • multi_manager (3 pcs.)
  • trigger_auto (1 pc.)
  • func_door (1 pc.)
  • func_rot_button (1 pc.)
  • func_wall (1 pc.)
  • func_detail (1 pc.)

Note: This method implements the emergency lighting with a brush entity (func_wall) that contains the emergency light sources. When the emergency lighting is on, the polygons of the emergency lamps are added to the wpoly count.

How it works: We create 2 light sources as two light_surface entities, one for the main light and one for the emergency light. We duplicate the brushes with the main light texture and turn them into an entity. At the start of the game the emergency lamps must be hidden, otherwise they will be displayed as unlit on top of the main light. We use trigger_auto for that. To switch the lighting mode we use a lever (func_rot_button) that toggles between the main and emergency light. To fix one bug, we use func_door.

Preparing the lighting for the logic

1. In my case, the main light texture is named light01_pl and the emergency one light01_sl. These stand for Primary Lighting and Secondary Lighting.

It is assumed that the main light is already placed on the map. If not, you need to do that first.

After placing the main light source, you need to convert all brushes with the main light texture into func_detail:

Parameters:

Func_detail

Value

Detail Level

2

Passable

yes

Note on func_detail: If the lamps touch another func_detail, remember that the lamps' Detail Level must always be higher than that of the other func_detail.

2. The next step is to duplicate the main light brushes. After duplicating the main light, hide the unused objects by selecting the duplicated object and pressing Ctrl+H. Now we need to replace the main light texture on all the lamps with the emergency one. You can do this in Texture Application Mode (Shift+A). A window opens; choose Replace…, and you will see 2 fields. Find: the texture to replace; Replace: the texture to replace it with. In my case it looks like this: Find: light01_pl Replace: light01_sl. We do the same for the side faces of the emergency lighting brushes to get rid of unneeded polygons. In the Find field we enter the name of the lamp's side-face texture, and in the Replace field the texture named noclip. In the end, only the emergency lighting texture should remain.

We turn the duplicated main light into a func_wall, adding only a name:

Parameters:

Func_wall

Value

Name

SecondaryLight

3. Placing the two light_surface entities.

Main light parameters:

Light_surface

Value

//

Texture Name

light01_pl

Texture name

Texture Brightness

225

Texture brightness

Color

200 220 255

R G B color

Adjust Emit Scale

70

Light multiplier. It is best set somewhere between 10 and 100, depending on the room and the size of the lamp.

Name

PrimaryLight

Name for interacting with LS

We leave the other parameters and flags of the main light untouched.

Emergency light parameters:

Light_surface

Value

//

Texture Name

light01_sl

Texture name

Texture Brightness

100

Texture brightness

Color

255 250 208

R G B color

Adjust Emit Scale

40

Light multiplier. It is best set somewhere between 10 and 100, depending on the room and the size of the lamp.

Name

SecondaryLight

Name for interacting with LS

Filter Entity Name

SecondaryLight

Searches specifically for the emergency light sources to light.

Flags:

Flags

Initially Dark

Off at the start.

4. The next step is to create a button, in my case a lever, that will switch between the main and emergency light.

Parameters:

func_rot_button

Value

Name

control_lighting

Target

light01

Flags:

Flags

Not Solid

Makes the lever non-solid

Toggle

The lever will not return to its initial position by itself until it is activated.

The other values and flags are up to you.

Logic

1. Let's hide the emergency light, the func_wall object, using env_render entities:

Parameters for hiding:

Env_render

Value

Name

SecondaryLight_off

Target

SecondaryLight

Render Mode

Texture

FX Amount

0

Parameters for showing:

Env_render

Value

Name

SecondaryLight_on

Target

SecondaryLight

Render Mode

Normal

FX Amount

255

Note: If you plan to use detail textures on the light sources, remember that a detail texture is applied to a brush entity only when Render mode is Normal. In any other mode, the detail texture will not be applied to that surface belonging to the brush entity!

2. Let's create 2 multi_managers to switch from the main light to the emergency light and back:

Note: To add new parameters you need to turn off the SmartEdit button

Parameters of the 1st mm:

Multi_manager

Value

//

targetname

light01

multi_manager name

PrimaryLight

0.0

Turns the main light off

SecondaryLight

0.5

Turns the emergency light on

SecondaryLight_on

0.5

Makes the func_wall visible.

light01_off

0.5

Switches the lever's target from light01 to light02

Parameters of the 2nd mm:

Multi_manager

Value

//

targetname

light02

multi_manager name

SecondaryLight

0.0

Turns the emergency light off

SecondaryLight_off

0.0

Hides the func_wall lamps

PrimaryLight

0.5

Turns the main light on

light02_off

0.5

Switches the lever's target from light02 to light01

3. In the multi_managers we specified changing the lever's target parameter. For that we need 2 trigger_changetarget entities:

Parameters of the 1st trigger_changetarget:

trigger_changetarget

Value

//

Name

light01_off

Name used to call it

Target

control_lighting

Name of the lever whose target will be changed

New Target

light02

The lever's new target.

Parameters of the 2nd trigger_changetarget:

trigger_changetarget

Value

//

Name

light02_off

Name used to call it

Target

control_lighting

Name of the lever whose target will be changed

New Target

light01

The lever's new target.

Final stage

1. We place a trigger_auto to hide the inactive lamps in the first round:

Parameters:

Trigger_auto

Value

Target

SecondaryLight_off

2. We fix a bug: if a round ends while the emergency lighting is on, then in the new round the emergency lamps will be on and the lever's target stays as it was in the previous round. We will fix this behavior with a magic func_door:

Parameters:

Func_door

Value

Target

lighting_fix_mm

Delay before close

-1

Flags:

Flags

Starts Open

Activate at the start of the round.

Passable

Remove collision.

We create a multi_manager:

Parameters:

Multi_manager

Value

//

targetname

lighting_fix_mm

multi_manager name

SecondaryLight_off

0.0

Hides the func_wall lamps.

light02_off

0.0

Switches the lever's target.

Example map:

https://www.dropbox.com/s/jcagc98x8t7qo4v/SwitchableLighting.rar?dl=0