Player States

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


Player states select the current player interaction or control mode. SOMA registers normal control, grab, push, terminal interaction, conversation and custom-controls states, among others. The custom-controls helper installs named callbacks for look, movement, actions and leaning before changing the player state.

States

Name ScriptFile ScriptClass
State_Normal player/PlayerState_Normal.hps cScrPlayerState_Normal
State_Interact_Grab player/PlayerState_Interact_Grab.hps cScrPlayerState_Interact_Grab
State_Interact_Push player/PlayerState_Interact_Push.hps cScrPlayerState_Interact_Push
State_Interact_Wheel player/PlayerState_Interact_Wheel.hps cScrPlayerState_Interact_Wheel
State_Interact_Slide player/PlayerState_Interact_Slide.hps cScrPlayerState_Interact_Slide
State_Interact_SwingDoor player/PlayerState_Interact_SwingDoor.hps cScrPlayerState_Interact_SwingDoor
State_Interact_Lever player/PlayerState_Interact_Lever.hps cScrPlayerState_Interact_Lever
State_Interact_Tear player/PlayerState_Interact_Tear.hps cScrPlayerState_Interact_Tear
State_Interact_Terminal player/PlayerState_Interact_Terminal.hps cScrPlayerState_Interact_Terminal
State_Interact_HandheldTerminal player/PlayerState_Interact_HandheldTerminal.hps cScrPlayerState_Interact_HandheldTerminal
State_Interact_Read player/PlayerState_Interact_Read.hps cScrPlayerState_Interact_Read
State_Interact_MovingButton player/PlayerState_Interact_MovingButton.hps cScrPlayerState_Interact_MovingButton
State_Ladder player/PlayerState_Ladder.hps cScrPlayerState_Ladder
State_ClimbLedge player/PlayerState_ClimbLedge.hps cScrPlayerState_ClimbLedge
State_InteractiveCameraAnimation player/PlayerState_InteractiveCameraAnimation.hps cScrPlayerState_InteractiveCameraAnimation
State_Sit player/PlayerState_Sit.hps cScrPlayerState_Sit
State_Conversation player/PlayerState_Conversation.hps cScrPlayerState_Conversation
State_Dead player/PlayerState_Dead.hps cScrPlayerState_Dead
State_Interact_ZoomArea player/PlayerState_Interact_ZoomArea.hps cScrPlayerState_Interact_ZoomArea
State_CustomControls player/PlayerState_CustomControls.hps cScrPlayerState_CustomControls
State_Null player/PlayerState_Null.hps cScrPlayerState_Null

MoveStates

Name ScriptFile ScriptClass
MoveState_Normal main/MoveState_Normal.hps cScrMoveState_Normal
MoveState_Climb main/MoveState_Climb.hps cScrMoveState_Climb
MoveState_Dead main/MoveState_Dead.hps cScrMoveState_Dead

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_ChangeStateToCustomControls

Changes the player state so that the normal controls are used for something else.

Parameter Meaning
asLookInputCallback Overrides look controls. If false is returned, normal controls are overridden. Syntax: bool F(const cVector2f &in avLookAmount)
asMoveInputCallback Overrides move controls. If false is returned, normal controls are overridden. Syntax: bool F(const cVector2f &in avMoveAmount)
asActionInputCallback Overrides action input. If false is returned, normal controls are overridden. Syntax: bool F(int alAction, bool abPressed)
asLeanInputCallback Overrides lean input. If false is returned, normal controls are overridden. Syntax: bool F(float afAmount)

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

Player_ChangeStateToCustomControls("LoaderArm_Look", "LoaderArm_Move", "LoaderArm_Action", "LoaderArm_Lean");
Parameter Value in this stock call
asLookInputCallback "LoaderArm_Look"
asMoveInputCallback "LoaderArm_Move"
asActionInputCallback "LoaderArm_Action"
asLeanInputCallback "LoaderArm_Lean"

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