<?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=HPL2%2FHPL2_Helper_Scripts%2FGlitcher</id>
	<title>HPL2/HPL2 Helper Scripts/Glitcher - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=HPL2%2FHPL2_Helper_Scripts%2FGlitcher"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Glitcher&amp;action=history"/>
	<updated>2026-04-28T10:49:32Z</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=HPL2/HPL2_Helper_Scripts/Glitcher&amp;diff=6791&amp;oldid=prev</id>
		<title>Mrbehemo at 02:46, 11 February 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Glitcher&amp;diff=6791&amp;oldid=prev"/>
		<updated>2024-02-11T02:46:35Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 02:46, 11 February 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l34&quot; &gt;Line 34:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 34:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Glitcher=&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=Glitcher=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Glitcher is the name of the object that manages the &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;bobbing &lt;/del&gt;entities.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Glitcher is the name of the object that manages the &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;glitching &lt;/ins&gt;entities.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki:diff::1.12:old-6595:rev-6791 --&gt;
&lt;/table&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Glitcher&amp;diff=6595&amp;oldid=prev</id>
		<title>Mrbehemo: Final draft of first version done.</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Glitcher&amp;diff=6595&amp;oldid=prev"/>
		<updated>2023-11-27T01:01:50Z</updated>

		<summary type="html">&lt;p&gt;Final draft of first version done.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Glitcher.hps&amp;quot; - part of ''[[HPL2/HPL2 Helper Scripts]]'', a modder-made package of .hps files by Aetheric Games, containing script classes and functions that may be useful to HPL2 modders and custom story creators. See the [[HPL2/HPL2 Helper Scripts|main page]] for more information, including [[HPL2/HPL2 Helper Scripts#Set-up|set-up instructions]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Summary=&lt;br /&gt;
The script class cGlitcher manages a list of entity groups that should appear to erratically twitch and move, without any animated models or shaders.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Glitch entities===&lt;br /&gt;
One &amp;quot;''glitch''&amp;quot; contains at least one entity which, at semi-random intervals, should move to a slightly different position. The multiple entities within a glitch a here called &amp;quot;alt entities&amp;quot; or &amp;quot;alts&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the glitch contains only one alt entity, it will only &amp;quot;twitch&amp;quot; without changing. If multiple entities are added to the glitch, then they will be substituted. The entities can be different types: for example, multiple versions of a statue, in slightly different poses. Or they can just be a different scale or rotation, which can have a similar effect.&lt;br /&gt;
&lt;br /&gt;
Furthermore, glitches containing mutliple entities will quickly fade between alts rather than switching instantly. Glitches contain only one alt must twitch instantly without any fading. The fade time reduces as the intensity of the glitching increases.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Intensity===&lt;br /&gt;
The amount of the glitching is controlled by Glitcher's ''intensity'' calculations. Intensity affects the interval and likelihood of glitches occuring, as well that the smoothness of the entities fading as they are substituted.&lt;br /&gt;
&lt;br /&gt;
Itensity responds to the player's Sanity level, but it can also be controlled influenced in script with SetIntensity() method. The Intensity property can be used to check what the current intensity level is.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Player distance===&lt;br /&gt;
Each glitching entity can have a specific distance that the player must be within for the glitches to occur. When the player is beyond this distance, the glitching will pause. The level designer should balance the player distance against the size of the entity, the visibility of the glitches, and the size of the space the player might see it in. The default distance is 24.0f units, but this can be overridden in the Add() arguments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Save data===&lt;br /&gt;
Glitcher saves its data for each level to GameVars so that it can be automatically restored when the player returns to the level or reloads a game that was saved in the level. Any entities that were registered with Glitcher at the time of saving will be re-registered and their glitching state will be restored. The restoration of the loaded state occurs on the first frame once the game has started. If the game starts and Glitcher hasn't yet been initialised, then it will check to see if there is saved data from a previous session, and restore it. If the game starts and Glitcher was already initialised in OnStart() or OnEnter(), then the load will be skipped.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
'''Advanced users''' may wish to examine &amp;quot;HelperScripts_Glitcher.hps&amp;quot; to see how it makes use of other script classes. There are also some private variables that could to tweaked to fit the needs of a specific project, such as default player distance, maximum number of glitchers, and the default numbers involved in the intensity and fading calculations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Glitcher=&lt;br /&gt;
Glitcher is the name of the object that manages the bobbing entities.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
&amp;quot;HelperScripts_Glitcher.hps&amp;quot; declares an object called '''Glitcher''', of the new script class cGlitcher. To access its properties and methods, just use &amp;quot;Glitcher.&amp;quot; followed by the function call or property. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
if (Glitcher.IsEntGlitching(&amp;quot;IllusionThing&amp;quot;))&lt;br /&gt;
Glitcher.Intensity = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
Glitcher provides the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsActive====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsActive&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsActive returns whether there are currently any active glitches.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Glitcher.IsActive) DoStuff();&lt;br /&gt;
// The condition succeeds if Glitcher is currently glitching some entities.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Intensity====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Intensity&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only float property Intensity returns the current intensity value resulting from the sanity bias and min-max intensities. If no glitches are currently active, the intensity value will be zero.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Glitcher.Intensity &amp;gt; 0.5f) DoStuff();&lt;br /&gt;
// The condition succeeds if Glitcher intensity is over 50%.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FadeDuration====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float FadeDuration&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only float property FadeDuration returns the current fading time resulting from the sanity bias and min-max intensities. If no glitches are currently active, the returned value will be zero.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
FadeLightTo(&amp;quot;someLight&amp;quot;, 1.0f, 0.6f, 0.4f, 1.0f, 12.0f, Glitcher.FadeDuration);&lt;br /&gt;
// This example imagines that the level designer wants a light to fade with the same speed a glitching entities.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GlitchCount====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint GlitchCount&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property GlitchCount returns the number of glitches that have been registered in Glitcher.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Glitcher.GlitchCount &amp;gt; 8) ClearGlitches();&lt;br /&gt;
// The condition succeeds if Glitcher is currently glitching more than eight entities.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
Glitcher provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Adding glitches===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Add()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Add(string asEntAltOne, float afJitterScale = 1.0f, float afChanceScale = 1.0f, float afMaxPlayerDist = 24.0f, string asGlitchSound = &amp;quot;&amp;quot;)&lt;br /&gt;
bool Add(string asEntAltOne, string asEntAltTwo, float afJitterScale = 1.0f, float afChanceScale = 1.0f, float afMaxPlayerDist = 24.0f, string asGlitchSound = &amp;quot;&amp;quot;)&lt;br /&gt;
bool Add(string asEntAltOne, string asEntAltTwo, string asEntAltThree, float afJitterScale = 1.0f, float afChanceScale = 1.0f, float afMaxPlayerDist = 24.0f, string asGlitchSound = &amp;quot;&amp;quot;)&lt;br /&gt;
bool Add(string[] asEntAlts, float afJitterScale = 1.0f, float afChanceScale = 1.0f, float afMaxPlayerDist = 24.0f, string asGlitchSound = &amp;quot;&amp;quot;)&lt;br /&gt;
bool Add(cListString asEntAlts, float afJitterScale = 1.0f, float afChanceScale = 1.0f, float afMaxPlayerDist = 24.0f, string asGlitchSound = &amp;quot;&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Registers an entity or multiple entities as a glitch. Returns true if the glitch was successfully added.&lt;br /&gt;
&amp;lt;br&amp;gt;Entity names can be provided as one, two or three individual strings, or array of strings, or a cListString.&lt;br /&gt;
&amp;lt;br&amp;gt;afJitterScale is optional. If omitted it defaults to 1.0f. The jitter scale multiplies the distance an entity can move when it twitches. The default jitter scale of 1.0 means movements of up to 5cm.&lt;br /&gt;
&amp;lt;br&amp;gt;afChanceScale is optional. If omitted it defaults to 1.0f. The chance scale multiplies the likelihood that a glitch will occur at each interval.&lt;br /&gt;
&amp;lt;br&amp;gt;Also optionally, the player distance and glitch sounds can be overridden. Otherwise the Glitcher defaults are used.&lt;br /&gt;
#''string asEntAltOne, string[] asEntAlts, cListString asEntAlts'' - The name of an entity, an array of entity names, or a list of entity names to include in the glitch as alt entities.&lt;br /&gt;
#''string asEntAltTwo'' - If specifying entities as individual strings, this is a second entity to include. (Optional)&lt;br /&gt;
#''string asEntAltThree'' - If specifying entities as individual strings, this is a third entity to include. (Optional)&lt;br /&gt;
#''float afJitterScale'' - Multiplies the distance that the mesh can move when it twitches. (Optional, default = 1.0f)&lt;br /&gt;
#''float afChanceScale'' - Multiplies the likelihood that a glitch will occur on each interval. (Optional, default = 1.0f)&lt;br /&gt;
#''float afMaxPlayerDist'' - If using an array of strings, afMaxPlayerDist can be used to override the default player distance for this glitch. (Optional, default = 24.0f)&lt;br /&gt;
#''float asGlitchSound'' - If using an array of strings, asGlitchSound can be used to override the default sound played when a glitch occurs. (Optional, default = &amp;quot;&amp;quot;, no sound)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Glitcher.Add(&amp;quot;SpookyTree1&amp;quot;, &amp;quot;SpookyTree2&amp;quot;, 10.0f, 50.0f, &amp;quot;forest_tree_creak.snt&amp;quot;);&lt;br /&gt;
// A glitch is created with two alt entities.&lt;br /&gt;
// The jitter scale is 10.0f, which means that each twitch could be up to 0.5m.&lt;br /&gt;
// The max player distance is 50.0f, which would allow the movement to be see from afar.&lt;br /&gt;
// The glitch is assigned a sound to play on each twitch.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListString listStatueA;&lt;br /&gt;
listStatueA.Add(&amp;quot;statue_A_0&amp;quot;);&lt;br /&gt;
listStatueA.Add(&amp;quot;statue_A_1&amp;quot;);&lt;br /&gt;
listStatueA.Add(&amp;quot;statue_A_2&amp;quot;);&lt;br /&gt;
listStatueA.Add(&amp;quot;statue_A_3&amp;quot;);&lt;br /&gt;
Glitcher.Add(listStatueA);&lt;br /&gt;
// A glitch is created with default settings, using alt entities listed in listStatueA.&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
Glitcher.Add(String.StringRange(&amp;quot;statue_A_&amp;quot;, 0, 3, &amp;quot;&amp;quot;));&lt;br /&gt;
// The StringRange() method is used to produce a list of entity names - the outcome is the same as example 2.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddSeries()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool AddSeries(string asPrefix, uint aulPostfixDigits = 0, float afJitterScale = 1.0f, float afChanceScale = 1.0f, float afMaxPlayerDist = 24.0f, string asGlitchSound = &amp;quot;&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Registers a series of named entities as a glitch. Returns true if the glitch was successfully added.&lt;br /&gt;
&amp;lt;br&amp;gt;AddSeries() is useful when the alt entities have a regular naming pattern but it is unknown at the time of scripting how many there will be. Entity names are provided in the format &amp;quot;someNamePrefix1&amp;quot;. The first part of the name is asPrefix. The number is an index from 0 to 128. AddSeries() counts from 0 and stops when it comes to an entity that doesn't exist.&lt;br /&gt;
&amp;lt;br&amp;gt;aulPostfixDigits can be used optionally to specify leading zeroes in the entity names. For example, if the entity names are formatted as &amp;quot;someNamePrefix01&amp;quot; then aulPostfixDigits should be 2.&lt;br /&gt;
&amp;lt;br&amp;gt;afJitterScale is optional. If omitted it defaults to 1.0f. The jitter scale multiplies the distance an entity can move when it twitches. The default jitter scale of 1.0 means movements of up to 5cm.&lt;br /&gt;
&amp;lt;br&amp;gt;afChanceScale is optional. If omitted it defaults to 1.0f. The chance scale multiplies the likelihood that a glitch will occur at each interval.&lt;br /&gt;
&amp;lt;br&amp;gt;Also optionally, the player distance and glitch sounds can be overridden. Otherwise the Glitcher defaults are used.&lt;br /&gt;
#''string asPrefix'' - The first part of an entity name, to be appended with an index.&lt;br /&gt;
#''uint aulPostfixDigits'' - The number of digits to expect in an entity name, including leading zeroes. (Optional, default = 0, no leading zeroes)&lt;br /&gt;
#''float afJitterScale'' - Multiplies the distance that the mesh can move when it twitches. (Optional, default = 1.0f)&lt;br /&gt;
#''float afChanceScale'' - Multiplies the likelihood that a glitch will occur on each interval. (Optional, default = 1.0f)&lt;br /&gt;
#''float afMaxPlayerDist'' - If using an array of strings, afMaxPlayerDist can be used to override the default player distance for this glitch. (Optional, default = mfDefaultMaxPlayerDist)&lt;br /&gt;
#''float asGlitchSound'' - If using an array of strings, asGlitchSound can be used to override the default sound played when a glitch occurs. (Optional, default = &amp;quot;&amp;quot;, no sound)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
// Example 1:&lt;br /&gt;
Glitcher.AddSeries(&amp;quot;SpookyTree&amp;quot;, 1.0f, 0.5f);&lt;br /&gt;
// A glitch is created with as many alt entities as are found matching the pattern &amp;quot;SpookyTree0&amp;quot;, &amp;quot;SpookyTreek1&amp;quot; etc..&lt;br /&gt;
// The chance scale provided is 50%, so this glitcher is half as likely to twitch than default.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
Glitcher.Add(&amp;quot;statue_A_&amp;quot;, 3);&lt;br /&gt;
// A glitch is created with default settings, with as many alt entities as are found matching the pattern &amp;quot;statue_A_0&amp;quot;, &amp;quot;statue_A_1&amp;quot; etc..&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Adding glitches from Slimer===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddFromSlimer_InstsToSingles()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool AddFromSlimer_InstsToSingles(string asSequence)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Registers a series of entities as a glitch, using the default settings. The entities are sourced from Slimer. If sequences of entities have been prepared for use in Slimer, this method allows them to be passed easily to Glitcher. Note that the glitch state may override the sequence state and vice versa.&lt;br /&gt;
&amp;lt;br&amp;gt;In particular, AddFromSlimer_InstsToSingles() creates glitches with a single alt entity in each. Each of the instance entities in the specified sequence becomes an individual glitch with only one alt.&lt;br /&gt;
&amp;lt;br&amp;gt;Returns true if the glitch was successfully added.&lt;br /&gt;
#''string asSequence'' - The name of the Slimer sequence to add.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Glitcher.AddFromSlimer_InstsToSingles(&amp;quot;CutsceneSequenceA&amp;quot;);&lt;br /&gt;
// Each of the entities registered with Slimer for the sequence &amp;quot;CutsceneSequenceA&amp;quot; is now registered with Glitcher.&lt;br /&gt;
// Each individual Slimer instance entity has become an individual glitch with a single alt.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddFromSlimer_StepsToAlts()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool AddFromSlimer_StepsToAlts(string asSequence)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Registers a series of entities as a glitch, using the default settings. The entities are sourced from Slimer. If sequences of entities have been prepared for use in Slimer, this method allows them to be passed easily to Glitcher. Note that the glitch state may override the sequence state and vice versa.&lt;br /&gt;
&amp;lt;br&amp;gt;In particular, AddFromSlimer_StepsToAlts() creates glitches with multiple alt entities in each. The Slimer steps in the specified sequence become individual glitches, and the instance entities in each of the steps become the alts.&lt;br /&gt;
&amp;lt;br&amp;gt;Returns true if the glitch was successfully added.&lt;br /&gt;
#''string asSequence'' - The name of the Slimer sequence to add.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Glitcher.AddFromSlimer_InstsToSingles(&amp;quot;CutsceneSequenceA&amp;quot;);&lt;br /&gt;
// Each of the entities registered with Slimer for the sequence &amp;quot;CutsceneSequenceA&amp;quot; is now registered with Glitcher.&lt;br /&gt;
// Each individual Slimer step has become a glitch with multiple alts.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Resetting/removing glitches===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ClearGlitches()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearGlitches()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Cancels all registered glitches and empties the list. Does not return entities to their original states.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Glitcher.ClearGlitches();&lt;br /&gt;
// All registered glitches are cleared but no entity changes were made.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ResetAll()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ResetAll(bool abHideAllEnts = false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Cancels all registered glitches and empties the list, and resets intensity variables to their defaults.&lt;br /&gt;
&amp;lt;br&amp;gt;Does not return entities to their original states, but if abHideAllEnts is true, all registered entities will be set as inactive. abHideAllEnts is optional and defaults to false if omitted.&lt;br /&gt;
#''bool abHideAllEnts'' - If true, all registered glitch entities will be hidden. (Optional, default = false)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Glitcher.ResetAll(true);&lt;br /&gt;
// All registered glitches are cleared, intensity variable are reset, and any entities that were part of a glitch have been hidden.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Intensity===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetIntensity()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetIntensity(float afIntensity)&lt;br /&gt;
void SetIntensity(float afMin, float afMax, float afSanityBias, float afSanityExp = 1.5f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Overrides the intensity range and calculations. If only one float is specified, that will become the actual exact intensity used, with influence from player Sanity.&lt;br /&gt;
&amp;lt;br&amp;gt;Optionally, the min, max and sanity bias can be specified. The min and max limit the intensity value by clamping the inverted sanity. Sanity bias defines how much influence player sanity has on the final intensity. If sanity bias is 1, the intensity will be equal to the inverse of sanity clamped to the min and max. If the bias is 0, the intensity will be equal to the mid point of the min and max. The default value for the bias is 0.666.&lt;br /&gt;
&amp;lt;br&amp;gt;An optional sanity exponent can also be specified. The default value is 1.5. This is the exponent that is applied to the inverse of sanity, adding a to curve the relationship between sanity and intensity. Higher afSanityExp values mean that when the player sanity is high, the intensity is less changeable but when the player sanity gets low, the glitch intensity will increase more suddenly.&lt;br /&gt;
#''float afIntensity or float afMin'' - Either the exact intensity value to used, or the minimum limit of player Sanity to influence intensity.&lt;br /&gt;
#''float afMax'' - The the maximum limit of player Sanity to influence intensity. (Optional with afMin and afSanityBias)&lt;br /&gt;
#''float afSanityBias'' - The extent (0.0 - 1.0) that player Sanity should influence intensity. (Optional with afMax and afSanityBias, default = 0.666f)&lt;br /&gt;
#''float afSanityExp'' - The exponent to apply to Sanity. (0.0 - 1.0) that player Sanity should influence intensity. (Optional with afMin, afMax and afSanityBias, default = 1.5f)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Glitcher.SetIntensity(0.5f);&lt;br /&gt;
Glitcher.SetIntensity(0.5f, 0.5f, 0.0f);&lt;br /&gt;
// These two lines have the same effect. Intensity is manually set to 50%, regardless of player Sanity.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
Glitcher.SetIntensity(0.0f, 0.5f, 1.0f);&lt;br /&gt;
// Intensity is limited between 0% - 50%, and player Sanity has 100% influence. (Sanity exponent is default 1.5f.)&lt;br /&gt;
// If Sanity is 100%	Intensity = 0%&lt;br /&gt;
// If Sanity is 80%		Intensity = 20%&lt;br /&gt;
// If Sanity is 60%		Intensity = 50%&lt;br /&gt;
// If Sanity is 40%		Intensity = 50%&lt;br /&gt;
// If Sanity is 20%		Intensity = 50%&lt;br /&gt;
// If Sanity is 0%		Intensity = 50%&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
Glitcher.SetIntensity(0.0f, 0.5f, 0.25f);&lt;br /&gt;
// Intensity is limited between 0% - 50%, ''but player Sanity only has 25% influence''. (Sanity exponent is default 1.5f.)&lt;br /&gt;
// If Sanity is 100%	Intensity = 19%&lt;br /&gt;
// If Sanity is 80%		Intensity = 21%&lt;br /&gt;
// If Sanity is 60%		Intensity = 25%&lt;br /&gt;
// If Sanity is 40%		Intensity = 35%&lt;br /&gt;
// If Sanity is 20%		Intensity = 35%&lt;br /&gt;
// If Sanity is 0%		Intensity = 35%&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
Glitcher.SetIntensity(0.0f, 0.6f, 1.0f, 0.5f);&lt;br /&gt;
// Intensity is limited between 0% - 60%, and player Sanity has 100% influence. ''Sanity exponent is reduced to 0.5f, so intensity rises sharply.''&lt;br /&gt;
// If Sanity is 100%	Intensity = 0% &lt;br /&gt;
// If Sanity is 80%		Intensity = 45%  &lt;br /&gt;
// If Sanity is 60%		Intensity = 63%&lt;br /&gt;
// If Sanity is 40%		Intensity = 78%&lt;br /&gt;
// If Sanity is 20%		Intensity = 78%&lt;br /&gt;
// If Sanity is 0%		Intensity = 78%&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ResetIntensity()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ResetIntensity()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns all intensity values to their defaults. (Min = 0.0f, Max = 1.0f, Bias = 0.666f, Exp = 1.5f)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Glitcher.ResetIntensity();&lt;br /&gt;
// Min, max intensity and sanity bias and exponent have been reset.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Querying glitches===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsEntGlitching()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEntGlitching(string asEntity)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if the named entity already exists as one alt in a glitch in the glitch list.&lt;br /&gt;
#''string asEntity'' - The entity to check for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Glitcher.IsEntGlitching(&amp;quot;statue_1A&amp;quot;)) DoStuff();&lt;br /&gt;
// The condition succeeds if the entity &amp;quot;statue_1A&amp;quot; is part of a registered glitch.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cNodeGlitching=&lt;br /&gt;
cNodeGlitching is a list node class used by cGlitcher to manage individual glitches. It is '''not recommended''' to work with cNodeGlitching directly. Instead, just use the methods of Glitcher and let it manage them for you.&lt;br /&gt;
&lt;br /&gt;
'''Advanced users''' who intend to access cNodeGlitching instances may find the following information useful.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cNodeGlitching has constructors taking an array of entity names, or taking a single entity name. Both have an alternative version with additional args.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cNodeGlitching(string asAltName)&lt;br /&gt;
cNodeGlitching(string asAltName, float afJitterScale float afChanceScale float afMaxPlayerDist string asGlitchSound)&lt;br /&gt;
cNodeGlitching(string[] asAltNames)&lt;br /&gt;
cNodeGlitching(string[] asAltNames, float afJitterScale, float afChanceScale, float afMaxPlayerDist, string asGlitchSound)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
cNodeBobbing has the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsActive====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsActive&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsActive ''updates'' whether the bobber should be active based on the player distance and returns the result.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CurrentAltIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint CurrentAltIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property CurrentAltIndex returns the index of this glitch's current alt entity.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CurrentAltName====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string CurrentAltName&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only string property CurrentAltName returns the index of this glitch's current alt entity.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AltNames====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] AltNames&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only string array property AltNames returns a handle to this glitch's array of alt entity names.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====NumberOfAlts====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint NumberOfAlts&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property NumberOfAlts gets the number of alt entities that have been registered to this glitch.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====JitterDist====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float JitterDist&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only float property JitterDist returns how far the glitch can move on each twitch.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ChanceScale====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float ChanceScale&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only float property ChanceScale returns likelihood that this glitch will twitch at each interval.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PlayerDistSqr====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float PlayerDistSqr&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only float property PlayerDistSqr returns the square of the maximum player distance to animate this glitch.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GlitchSound====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string GlitchSound&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only string property GlitchSound returns the glitch's sound filename.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CheckActive()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool CheckActive()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Updates whether the glitcher should be active based on the player distance and returns the result.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SelectNextAlt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint SelectNextAlt()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Selects a alternate entity and assigns it as the current alt. If there is only one alt, no change is made. If there are only two alts, they will alternate (flip-flop). If there are more than two alts, then a random one will be selected. The current alt is excluded so that it won't be chosen twice. (Yes, the definition of &amp;quot;alternate&amp;quot; means that there are two states, so the concept of &amp;quot;alt entities&amp;quot; here is technically erroneous.)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DoGlitch()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void DoGlitch(float afIntensity, float afFadeDuration, float afFadeDelay)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If a random chance succeeds (based on the intensity and fChanceScale), then this selects a new alt entity and applies the twitch.&lt;br /&gt;
#''float afIntensity'' - The current intensity, passed from cGlitcher.&lt;br /&gt;
#''float afFadeDuration'' - The current fading time, passed from cGlitcher.&lt;br /&gt;
#''float afFadeDelay'' - The current time to wait before fading in, passed from cGlitcher.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Miscellaneous=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Global functions===&lt;br /&gt;
&amp;quot;HelperScripts_Glitcher.hps&amp;quot; defines a global timer callback, used by cGlitcher to handle latent entity fading. It is '''not recommended''' to work with these directly. Instead, just use the methods of Glitcher and let it manage them for you.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void GlitcherLatentFade(string &amp;amp;in asTimer)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
</feed>