Wake Handler

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


The Wake Handler controls falling asleep immediately and waking up over time. Wake_SetAsleep sends the asleep flag to the module; Wake_StartWakeup sends the desired wakeup time.

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"

Wake_SetAsleep

Puts the player instantly to sleep (or awake)

Parameter Meaning
abAsleep if true then the player is asleep, if false then awake

In maps/chapter04/04_01_tau_outside/04_01_tau_outside.hps, SOMA calls Wake_SetAsleep as follows.

Wake_SetAsleep(true);
Parameter Value in this stock call
abAsleep true

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

Wake_StartWakeup

Wakes up the player.

Parameter Meaning
afTime time to take to wake up.

In maps/chapter04/04_01_tau_outside/04_01_tau_outside.hps, SOMA calls Wake_StartWakeup as follows.

Wake_StartWakeup(5.0f);
Parameter Value in this stock call
afTime 5.0f

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

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

In the Tau Outside sequence, Wake_SetAsleep(true) selects the asleep state and its GUI draws a black background. Later, Wake_StartWakeup(5.0f) enters the waking-up state for five seconds and starts an image-trail effect for that interval. The duration is accumulated from the GUI time step.

See also