Game Helper

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting
Revision as of 14:05, 2 October 2026 by TiMan (talk | contribs) (Add a sourced SOMA guide with explanations and stock-script examples.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


The Game helper file in SOMA is script/helpers/helper_game.hps.

Saving, checkpoint and achievement helpers connect map scripts to the corresponding game handlers. A checkpoint supplies the state to reload after the player dies; its optional callback receives the death count and death source.

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_game.hps"

Game_AutoSave

Saves the current position of the game.

In maps/chapter05/05_01_phi_inside/05_01_phi_inside.hps, SOMA calls Game_AutoSave as follows.

Game_AutoSave();

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

CheckPoint_Setup

Sets a checkpoint for the player. If the player dies the game will be reloaded to the state it was when this was called.

Parameter Meaning
asCallback Function called after player has died and just before he starts again. Syntax: void F(int alNumDeathsAtCheckPoint, const tString&in asDeathSource)

In maps/chapter04/04_03_tau_escape/04_03_tau_escape.hps, SOMA calls CheckPoint_Setup as follows.

CheckPoint_Setup();

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

The checkpoint callback signature is void F(int alNumDeathsAtCheckPoint, const tString&in asDeathSource). Its string parameter is the death source; it is not a timer name. Game_AutoSave forwards its checkpoint and delayed-save flags to the save handler.

See also