Sway

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting(Redirected from HPL3/Scripting/Sway)
Jump to navigation Jump to search


This page describes SOMA’s Sway effect.

Sway offsets the player camera and sets camera roll. The implementation uses player forward movement to increase its amplitude and a sine/cosine cycle for the offset; FadeOut reduces the target size to zero.

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

Effect_Sway_FadeIn

Parameter Meaning
afSize max X size of sway
afTime fade in time
afRate how many sways per second
afAngle sway will be around a line on XZ plane - this sets the y-axis rotation of it (degrees : 0 = along X axis)
afInitialAmount how big is the initial sway size? (0.0f - 1.0f) If negative, has no effect.
afYMul multiplier of afSwaySize for y
afDecay how fast the swaying dies away (1.0f = never dies)
afMoveFactor how much of the player's move speed to factor in

In maps/chapter03/03_03_omicron_descent/03_03_omicron_descent.hps, SOMA calls Effect_Sway_FadeIn as follows.

Effect_Sway_FadeIn(0.05f, 1.0f, 1.0f, 0.0f);
Parameter Value in this stock call
afSize 0.05f
afTime 1.0f
afRate 1.0f
afAngle 0.0f

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

Effect_Sway_SetDirect

Parameter Meaning
afSize max X size of sway
afRate how many sways per second
afAngle sway will be around a line on XZ plane - this sets the y-axis rotation of it (degrees : 0 = along X axis)
afInitialAmount how big is the initial sway size? (0.0f - 1.0f). If negative, has no effect.
afYMul multiplier of afSwaySize for y
afDecay how fast the swaying dies away (1.0f = never dies)
afMoveFactor how much of the player's move speed to factor in

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

Effect_Sway_SetDirect(fSwaySize, fSwayRate, mfSwayTimer, 
									1.0f, 0.25f, 1.0f, 0.0f);
Parameter Value in this stock call
afSize fSwaySize
afRate fSwayRate
afAngle mfSwayTimer
afInitialAmount 1.0f
afYMul 0.25f
afDecay 1.0f
afMoveFactor 0.0f

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

Effect_Sway_FadeOut

Parameter Meaning
afTime How long it takes to fade out.

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.

See also