Light Flash Handler

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting
Jump to navigation Jump to search


This handler creates temporary point lights that fade in, hold their brightness and fade out before being destroyed. LightFlash_Add accepts either a named entity or a world position; its radius is fixed during the flash.

Before you start

  1. Open the map script inside your own mod. Keep its generated includes, cScrMap : iScrMap class and callback structure. See Add your first script if you have not edited a map script yet.
  2. Add the helper include shown below alongside the script’s other includes.
  3. Read the stock example before copying its calls: named entities, voice subjects, materials and callbacks must belong to the map or resources you are using.

Follow the stock example

#include "helpers/helper_modules.hps"

LightFlash_Add

Creates a flash of light at the position of an entity. Returns id of the flash.

Parameter Meaning
afTime The time that light stays at full intensity
afFadeInTime How long it takes to fade in
afFadeOutTime How long it takes to fade out
asTargetEntity Entity at which it will be created.
aColor The color of the light.
afRadius The radius of the light (this will NOT be faded, it starts with this radius, and then just color fades in)
afBrightness The brightness of the light.

In maps/chapter02/02_01_ms_curie_outside/02_01_ms_curie_outside.hps, SOMA calls LightFlash_Add as follows.

LightFlash_Add(0.25f,0.1f,0.2f,"CortexChipTool", cColor_White, 0.15f, 2.0f);
Parameter Value in this stock call
afTime 0.25f
afFadeInTime 0.1f
afFadeOutTime 0.2f
asTargetEntity "CortexChipTool"
aColor cColor_White
afRadius 0.15f
afBrightness 2.0f

This is an excerpt from that stock script; its referenced names and variables belong to that script.

LightFlash_Add

Creates a flash of light at the position of an entity. Returns id of the flash.

Parameter Meaning
afTime The time that light stays at full intensity
afFadeInTime How long it takes to fade in
afFadeOutTime How long it takes to fade out
avTargetPos Position at which it will be created.
aColor The color of the light.
afRadius The radius of the light (this will NOT be faded, it starts with this radius, and then just color fades in)
afBrightness The brightness of the light.

Check your change

Save the script and restart the map in development mode with F5. If the script fails, open F1 and use Show Error List or Show HPL Log. See the development loop for the launch and debugging steps.

Read the example

The Curie example makes a white point-light flash at CortexChipTool. Its fade-in takes 0.1 seconds, the full-brightness hold takes 0.25 seconds and the fade-out takes 0.2 seconds. The light starts with radius 0.15 and brightness 2; the handler changes brightness during the fade, then destroys the light.

See also