<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=HPL3%2FSOMA%2FScripting%2FDistortion_Effect_Handler</id>
	<title>HPL3/SOMA/Scripting/Distortion Effect Handler - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=HPL3%2FSOMA%2FScripting%2FDistortion_Effect_Handler"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Scripting/Distortion_Effect_Handler&amp;action=history"/>
	<updated>2026-10-04T04:27:58Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Scripting/Distortion_Effect_Handler&amp;diff=7227&amp;oldid=prev</id>
		<title>TiMan: Add a sourced SOMA guide with explanations and stock-script examples.</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL3/SOMA/Scripting/Distortion_Effect_Handler&amp;diff=7227&amp;oldid=prev"/>
		<updated>2026-10-02T12:12:01Z</updated>

		<summary type="html">&lt;p&gt;Add a sourced SOMA guide with explanations and stock-script examples.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{shortPageTitle}}&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Before you start ==&lt;br /&gt;
# Open the map script inside your own mod. Keep its generated includes, &amp;lt;code&amp;gt;cScrMap : iScrMap&amp;lt;/code&amp;gt; class and callback structure. See [[HPL3/SOMA/Getting Started/Add Your First Script|Add your first script]] if you have not edited a map script yet.&lt;br /&gt;
# Add the helper include shown below alongside the script’s other includes.&lt;br /&gt;
# 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.&lt;br /&gt;
&lt;br /&gt;
== Follow the stock example ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;helpers/helper_modules.hps&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== DistortionEffect_AddInstance ===&lt;br /&gt;
Adds the entity has an instance that will help create a distortion effect if the player is near enough.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;a_idEntity&amp;lt;/code&amp;gt; || The entity who this will be connected to.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afMaxDistance&amp;lt;/code&amp;gt; || The distance at which the effect will start.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afMinDistance&amp;lt;/code&amp;gt; || The distance when the effect will be at max&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afMaxAmount&amp;lt;/code&amp;gt; || The max amount the effect will have from this entity.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;aEasing&amp;lt;/code&amp;gt; || The easing function used to fade between max and min&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;script/custom_depth/agent_fixed_human.hps&amp;lt;/code&amp;gt;, SOMA calls &amp;lt;code&amp;gt;DistortionEffect_AddInstance&amp;lt;/code&amp;gt; as follows.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
DistortionEffect_AddInstance(mBaseObj.GetID(), 15, 3, 0.4);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Value in this stock call&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;a_idEntity&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;mBaseObj.GetID()&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afMaxDistance&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;15&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afMinDistance&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afMaxAmount&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;0.4&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an excerpt from that stock script; its referenced names and variables belong to that script.&lt;br /&gt;
&lt;br /&gt;
=== DistortionEffect_RemoveInstance ===&lt;br /&gt;
Removes an instance that will create the distortion effect.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;a_idEntity&amp;lt;/code&amp;gt; || The entity to break the connection with&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;script/custom_depth/agent_construct_worker.hps&amp;lt;/code&amp;gt;, SOMA calls &amp;lt;code&amp;gt;DistortionEffect_RemoveInstance&amp;lt;/code&amp;gt; as follows.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
DistortionEffect_RemoveInstance(mBaseObj.GetID());&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Value in this stock call&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;a_idEntity&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;mBaseObj.GetID()&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an excerpt from that stock script; its referenced names and variables belong to that script.&lt;br /&gt;
&lt;br /&gt;
== Check your change ==&lt;br /&gt;
Save the script and restart the map in development mode with &amp;lt;code&amp;gt;F5&amp;lt;/code&amp;gt;. If the script fails, open &amp;lt;code&amp;gt;F1&amp;lt;/code&amp;gt; and use '''Show Error List''' or '''Show HPL Log'''. See [[HPL3/SOMA/Getting Started/Test Debug and Continue|the development loop]] for the launch and debugging steps.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[HPL3/Scripting/User Modules Overview|User modules]]&lt;br /&gt;
* [[HPL3/SOMA/Scripting/Modules Helper|SOMA module helpers]]&lt;br /&gt;
&lt;br /&gt;
[[Category:English]]&lt;/div&gt;</summary>
		<author><name>TiMan</name></author>
		
	</entry>
</feed>