Distortion Effect Handler
This handler connects entities to a proximity-based distortion amount. AddInstance specifies where the effect starts, where it reaches maximum strength and the easing curve between those distances; RemoveInstance breaks the connection.
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_modules.hps"
DistortionEffect_AddInstance
Adds the entity has an instance that will help create a distortion effect if the player is near enough.
| Parameter | Meaning |
|---|---|
a_idEntity |
The entity who this will be connected to. |
afMaxDistance |
The distance at which the effect will start. |
afMinDistance |
The distance when the effect will be at max |
afMaxAmount |
The max amount the effect will have from this entity. |
aEasing |
The easing function used to fade between max and min |
In script/custom_depth/agent_fixed_human.hps, SOMA calls DistortionEffect_AddInstance as follows.
DistortionEffect_AddInstance(mBaseObj.GetID(), 15, 3, 0.4);
| Parameter | Value in this stock call |
|---|---|
a_idEntity |
mBaseObj.GetID()
|
afMaxDistance |
15
|
afMinDistance |
3
|
afMaxAmount |
0.4
|
This is an excerpt from that stock script; its referenced names and variables belong to that script.
DistortionEffect_RemoveInstance
Removes an instance that will create the distortion effect.
| Parameter | Meaning |
|---|---|
a_idEntity |
The entity to break the connection with |
In script/custom_depth/agent_construct_worker.hps, SOMA calls DistortionEffect_RemoveInstance as follows.
DistortionEffect_RemoveInstance(mBaseObj.GetID());
| Parameter | Value in this stock call |
|---|---|
a_idEntity |
mBaseObj.GetID()
|
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.