Player Helper

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


The Player helper file in SOMA is script/helpers/helper_player.hps.

Player helpers control the player’s movement, camera, interactions, tools and health. For scripted camera attention, StartLookAt turns toward a named entity and StopLookAt ends that turn.

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

Player_StartLookAt

Rotate the player camera towards the positon of an entity/area.

Parameter Meaning
asEntityName name of the entity/area to rotate camera towards.
afAcc acceleration of the camera movement.
afSpeedMul distance towards camera multiplied with this value sets the camera speed.
afMaxSpeed maximum speed of camera movement.

In maps/chapter04/04_02_tau_inside/04_02_tau_inside.hps, SOMA calls Player_StartLookAt as follows.

Player_StartLookAt("ARK", 1, 1, 3);
Parameter Value in this stock call
asEntityName "ARK"
afAcc 1
afSpeedMul 1
afMaxSpeed 3

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

Player_StopLookAt

Stop rotating the camera towards a target specified with Player_StartLookAt()

Parameter Meaning
afDeacc deacceleration of the camera movement. 0 means 'stop now'

In maps/_e3/_e3_01_02/_e3_01_02.hps, SOMA calls Player_StopLookAt as follows.

Player_StopLookAt(2);
Parameter Value in this stock call
afDeacc 2

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

Player_SetInteractionAllowed

Turn on or off the player's ability to interact with the world.

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 ARK example points the camera toward the ARK entity. The helper first resolves that name: a missing entity returns without turning the camera, and an entity without a physics body or mesh produces an error. Use Player_StopLookAt to stop the scripted turn.

See also