Shake
This page describes SOMA’s Shake effect.
Shake moves the camera for a specified hold period plus fade-in and fade-out periods. Its helper documentation says the largest of multiple requested shakes is used; spatial sources increase its strength as the player approaches.
Contents
Before you start
- Open the map script inside your own mod. Keep its generated includes,
cScrMap : iScrMapclass and callback structure. See Add your first script if you have not edited a map script yet. - Add the helper include shown below alongside the script’s other includes.
- 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_Shake_Start
Makes the screen shake for a certain amount of time. Returns id to the current shaking. If several calls to shake has been made the largest one is used.
| Parameter | Meaning |
|---|---|
afAmount |
The strength of the shake. |
afTime |
The time it shakes at full intensity (fade in and fade out are added to this). |
afFadeInTime |
The time before it reaches full strength. |
afFadeOutTime |
The time, after afTime is up, that it will take for the shake to reach zero strength. |
avDirAmount |
The amount it will shake in each direction in camera space |
afFrequency |
Times per seconds the shake will change offset. 0=every update (ie max). |
In maps/chapter02/02_04_theta_outside/02_04_theta_outside.hps, SOMA calls Effect_Shake_Start as follows.
Effect_Shake_Start(0.2, 2, 12, 0);
| Parameter | Value in this stock call |
|---|---|
afAmount |
0.2
|
afTime |
2
|
afFadeInTime |
12
|
afFadeOutTime |
0
|
This is an excerpt from that stock script; its referenced names and variables belong to that script.
Effect_Shake_SetSourceEntity
Sets an entity as the source of a shake instance. The shake instance will increase in strength as the player gets closer to the entity.
| Parameter | Meaning |
|---|---|
alID |
The id of the shake (returned by Effect_Shake_Start). |
asSourceEntity |
entity to be used as source. |
afMinDist |
distance to entity where the shake will be at its most powerful. |
afMaxDist |
distance where shake will have faded out completely. |
aEasingType |
the curve the strength of the shake will follow as you move further from the entity. |
In maps/_e3/_e3_01_02/_e3_01_02.hps, SOMA calls Effect_Shake_SetSourceEntity as follows.
Effect_Shake_SetSourceEntity(lID, "StairsDoor", 2, 7);
| Parameter | Value in this stock call |
|---|---|
alID |
lID
|
asSourceEntity |
"StairsDoor"
|
afMinDist |
2
|
afMaxDist |
7
|
This is an excerpt from that stock script; its referenced names and variables belong to that script.
Effect_Shake_FadeOut
Fades out one or all shake instances.
| Parameter | Meaning |
|---|---|
alID |
The id of the shake (returned by Effect_Shake_Start). -1 = fade out all active shakes. |
afFadeOutTime |
the time 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.