<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mrbehemo</id>
	<title>Frictional Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mrbehemo"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page/Special:Contributions/Mrbehemo"/>
	<updated>2026-04-03T19:55:11Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6796</id>
		<title>HPL2/HPL2 Helper Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6796"/>
		<updated>2024-03-03T07:27:04Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
=Introduction=&lt;br /&gt;
''HPL2 Helper Scripts'' by Aetheric Games is a package of .hps files containing script classes and functions that may be useful to HPL2 modders and custom story creators. It is compatible with ATDD version 1.5 and later.&lt;br /&gt;
&lt;br /&gt;
Would you like to...&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
...make 500 candles blow out in a big wave? ...make haunted objects hover in the air? ...spawn dozens of random debris objects throughout an area? ...make a particle system move along a spline? ...manage a list of quest objectives? ...compare the distances between entities? ...make puzzles based on position and rotation? ...store an array in a global game variable? ...seamlessly teleport the player into an ''almost'' identical room? ...make a statue that twitches when the player has low sanity?&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Well, this script package isn't going to magically do those things for you, but it gives you a ''lot'' of tools to help you do them yourself.&lt;br /&gt;
&lt;br /&gt;
The scripts are divided into two categories: ''utilities'' and ''features''. The ''utilities'' scripts include tools for general scripting, like new maths functions, or linked lists and vector classes. The ''features'' scripts are more specific solutions that make use of the utilities, such as a way to spawn entities at specific locations, script a large chain of events or to make entities twitch and flicker. Some modders might prefer to just adopt the ''utilities'' scripts. It's up to you!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''[[HPL2/HPL2 Helper Scripts#Set-up|See below for download and set-up instructions.]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Contents=&lt;br /&gt;
The documentation and help is organised by file. '''''Lots of help, and full details of the new classes and functions, can be found on the following pages:'''''&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Utilities==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Debug|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Debug'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides more control and options for debug messages and logging.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/GameVars|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''GameVars'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Extends the functionality of the saved game global and local variable wrappers.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Lists|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Lists'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for linked list classes.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/LoadWatcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''LoadWatcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides an &amp;quot;OnLoad()&amp;quot; global function.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Math|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Math'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended maths functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/String|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''String'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended string functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Vectors|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Vectors'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for vector classes.&lt;br /&gt;
||&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;||&lt;br /&gt;
==Features==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Bobber|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Bobber'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for floating or hovering entities, without physics.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Fader|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Fader'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing global ambient sounds.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Glitcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Glitcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing entities that appear to glitch or flicker.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Slimer|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Slimer'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing large sequences of entity actions.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Spawner|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Spawner'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for spawning entities at specific map locations.&lt;br /&gt;
:&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&amp;amp;nbsp;&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
::&amp;amp;nbsp;&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Misc|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Miscellaneous'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Bits and pieces that don't fit anywhere else.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Set-up=&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First, download ''HPL2 Helper Scripts'' from the [https://steamcommunity.com/sharedfiles/filedetails/?id=3101276708 Steam Workshop page] or [https://www.moddb.com/mods/hpl2-helper-scripts ModDb page] and unzip it.&lt;br /&gt;
&lt;br /&gt;
If you get it on Steam Workshop, you'll find the actual folder in your Steam Workshop downloads.&lt;br /&gt;
&lt;br /&gt;
The current version is [[HPL2/HPL2_Helper_Scripts#Version_1.1.2C_03.2F02.2F24|1.1]].&lt;br /&gt;
&lt;br /&gt;
Once you have unzipped the folder, there are three options for how you add it into your mod. '''If you are unsure, just go with option A'''.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option A: The full feature-set package===&lt;br /&gt;
::If you want to be able to use all the new functions and classes, go with option A.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_FullPackage.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_FullPackage.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option B: The utilities-only package===&lt;br /&gt;
::Choose option B if you want to have access to the functions and classes in the ''utilities'' category, but don't need the stuff in the ''features'' category.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_UtilitiesOnly.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_UtilitiesOnly.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option C: Pick-n-mix===&lt;br /&gt;
::Advanced modders might prefer to only adopt the specific script files they need. Go nuts! But also be aware of the #include dependencies in each script file, as many of them are interdependent. You might find it easiest to start with option A or B and then remove scripts later that you definitely haven't used. You're also fully allowed and encouraged to just use HPL2HelperScripts as a learning resource or even to just copy snippets here and there.&lt;br /&gt;
&lt;br /&gt;
=Licence and Credits=&lt;br /&gt;
You are free to use ''HPL2 Helper Scripts'' in whatever way you see fit, no rights reserved by Aetheric Games. (As long as you're not going against any licence terms between you and Frictional Games, of course!) Aetheric Games is mostly just one person, mrbehemo, me (hello), and this has been a ''stupid'' amount of work, so if you find it helpful then it would be very cool of you to give me a credit in your mod or custom story. You can list it as &amp;quot;HPL2&amp;amp;nbsp;Helper&amp;amp;nbsp;Scripts&amp;amp;nbsp;by&amp;amp;nbsp;Aetheric&amp;amp;nbsp;Games&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This script package would not have been possible without the work of the tireless and patient Luis Rodero of Frictional Games, and the ever present pillar of the community, Mudbill. &lt;br /&gt;
&lt;br /&gt;
=Support=&lt;br /&gt;
''HPL2 Helper Scripts'' is made by mrbehemo of Aetheric Games. If you need support, here's what to do:&lt;br /&gt;
#First be sure that you're familar with the official [[HPL2/Engine_Scripts|HPL2 scripting reference]] and the [[HPL2/ScriptReference|community scripting guide]].&lt;br /&gt;
#And second, be sure that you've read the relevant parts of this documentation, including the FAQ.&lt;br /&gt;
#And then if you're still stuck I'll be happy to hear from you and will help if I can. Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server].&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
Fervently Anticipated Questions. Nobody's asked anything yet... &lt;br /&gt;
* I've added one or more scripts to my project separately, but I'm getting errors. What should I check?&lt;br /&gt;
** The script files are very interdependent. Check the .hps files you've added - they will have #include directives near the top for every other script they rely on. Either make sure you've also added ''those'' into your project.&lt;br /&gt;
* What's &amp;quot;#include&amp;quot;? What's &amp;quot;OnUpdate()&amp;quot;?&lt;br /&gt;
** Those are new features added with the ATDD [[HPL2/1.5 Update|1.5 update]].&lt;br /&gt;
* I want to make something weird happen, like make 100 flying naked guys do a loop-de-loop around the player. How?&lt;br /&gt;
** Sounds fun and is probably do-able! Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server] if you want advice.&lt;br /&gt;
* Can I get the player's camera direction yet?&lt;br /&gt;
** No, sorry. I investigated multiple ways of doing that, as have many people over the years. There's just no reliable way of doing it in HPL2 without branching the source code.&lt;br /&gt;
* What's a uint and why have you used them everywhere?&lt;br /&gt;
** A &amp;quot;U-int&amp;quot; is an unsigned integer, that is, an integer that can only be positive. I think it's best to use uint in scenarios where negative numbers are nonsensical. Behind the scenes it minimises the the chance of conversion issues, and also minimises warnings in the error output.&lt;br /&gt;
* Why are all your function arguments passed by reference, and why is that not reflected in the docs?&lt;br /&gt;
** In Angelscript there's a tiny, tiny performance saving gained from passing arguments by reference (and by using const where possible). It's not enough of a saving for modders and gameplay scripters to bother with, but since I was writing hundreds of them, it was an easy thing to do. It's not reflected in the docs because most non-advanced modders don't know what &amp;quot;pass by reference&amp;quot; means, or need to know.&lt;br /&gt;
* I looked at your code and you did it all weird. Why did you do it weird?&lt;br /&gt;
** It's probably because of the version of Angelscript that is integrated into HPL2. It has some surprising versatility but also some surprising limitations.&lt;br /&gt;
* Why did you do any of this?&lt;br /&gt;
** I know, I know - HPL2 is old now, I should have done this for The Bunker or whatever. Actually, I was just tidying up The Trapdoor (ATDD mod) for a Steam release, and I got carried away with refactoring it... and then, half a million characters of script later, this had happened. Hope it's useful. If not, it was a good exercise for me. Maybe ''you'' would like to port these scripts to HPL3 as and where needed! Go ahead, just be sure to credit and it'd be cool to let me know.&lt;br /&gt;
&lt;br /&gt;
=Change Log=&lt;br /&gt;
It should be simple to upgrade existing projects to use the current version, but take note of the changes listed below. You may need to make some minor edits.&lt;br /&gt;
&lt;br /&gt;
==Version 1.1, 03/02/24==&lt;br /&gt;
* General&lt;br /&gt;
** Changed some more spammy debug messages in level 2 to level 3 in various classes.&lt;br /&gt;
** Fixed various sign mismatch warnings between ints and uints.&lt;br /&gt;
&lt;br /&gt;
* Debug&lt;br /&gt;
** Default log verbosity is now 2 instead of 3.&lt;br /&gt;
&lt;br /&gt;
* GameVars&lt;br /&gt;
** Added SetIntAsUint() method, which is just SetInt() with an explicit cast.&lt;br /&gt;
&lt;br /&gt;
* Lists&lt;br /&gt;
** New properties for all list types: DefaultValue, Capacity&lt;br /&gt;
** New methods for all list types: Fill(), Extend(), AddUnique(), ToString()&lt;br /&gt;
** Fixed silent exception that occured when Insert() was used with index 0.&lt;br /&gt;
** Fixed silent exception that occured when Pop() was used with a count of 0 or 1.&lt;br /&gt;
** Fixed behaviour of Find() and RemoveItem() in cListGeneric.&lt;br /&gt;
** Added '''==''' operator to cListBase for checking if two lists of the same type are equal.&lt;br /&gt;
** Added optional argument abExtend to Set() methods.&lt;br /&gt;
** Fixed issue with incorrectly overloading Pop(), by moving the generic Pop() from cListBase to its correct place in cListGeneric.&lt;br /&gt;
&lt;br /&gt;
* Math&lt;br /&gt;
** New method in cMath: DistToEntity()&lt;br /&gt;
** RandomVector3d() and RandomVector2d(), when using the vecNormal option or when no range is specified, now have a chance of returning a vector with negative axes, whereas previously they were always positive.&lt;br /&gt;
&lt;br /&gt;
* String&lt;br /&gt;
** New method in cString: NearlyEqual()&lt;br /&gt;
** SplitToList() and SplitToArray() now handle empty strings by returning an empty collection. (As to opposed to previously returning a collection of one empty string.)&lt;br /&gt;
** Added list behaviour to Str class.&lt;br /&gt;
&lt;br /&gt;
* Vectors&lt;br /&gt;
** New methods in cVector: DotProduct(), CrossProduct()&lt;br /&gt;
** New methods in cSpline: GetSegmentHandle(), GetMinLength()&lt;br /&gt;
** Both cVector and cPoint now implement '''* / *= /=''' operators as ''per component'' multipliers, e.g. [2, 2, 2] * [1, 3, 0.5] = [2, 6, 1]&lt;br /&gt;
** If cVector * cVector was previously used where a dot product was the intended result, that should now be replaced by the DotProduct() method.&lt;br /&gt;
** Tweaked the bezier behaviour that uses a single control point to better approximate a quadratic bezier.&lt;br /&gt;
&lt;br /&gt;
* Fader&lt;br /&gt;
** New methods in cFader: PlayMusicTracked(), StopMusicTracked(), IsMusicPlaying(), DuckStart(), DuckRestore()&lt;br /&gt;
** New properties in cFader: IsMusicPlaying, MusicPlayingCount&lt;br /&gt;
** Group 0 now counts as &amp;quot;no group&amp;quot;.&lt;br /&gt;
** Added &amp;quot;Null&amp;quot; behaviour - Fader sounds initialised with a name containing &amp;quot;Null&amp;quot; will not be associated with a sound entity in the map, but they can be included in a group and have a play state as normal.&lt;br /&gt;
** Fader sounds can now be marked as StopOnMusic. If Fader.PlayMusic() and Fader.StopMusic() are used, then Fader sounds with StopOnMusic will fade out when music starts.&lt;br /&gt;
&lt;br /&gt;
* Glitcher&lt;br /&gt;
** Fixed the afChanceScale multiplier when adding glitches. (Was previously inverted).&lt;br /&gt;
** Slightly reduced the default max glitch frequency, for smoother fades.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6793</id>
		<title>HPL2/HPL2 Helper Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6793"/>
		<updated>2024-02-11T03:21:41Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
=Introduction=&lt;br /&gt;
''HPL2 Helper Scripts'' by Aetheric Games is a package of .hps files containing script classes and functions that may be useful to HPL2 modders and custom story creators. It is compatible with ATDD version 1.5 and later.&lt;br /&gt;
&lt;br /&gt;
Would you like to...&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
...make 500 candles blow out in a big wave? ...make haunted objects hover in the air? ...spawn dozens of random debris objects throughout an area? ...make a particle system move along a spline? ...manage a list of quest objectives? ...compare the distances between entities? ...make puzzles based on position and rotation? ...store an array in a global game variable? ...seamlessly teleport the player into an ''almost'' identical room? ...make a statue that twitches when the player has low sanity?&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Well, this script package isn't going to magically do those things for you, but it gives you a ''lot'' of tools to help you do them yourself.&lt;br /&gt;
&lt;br /&gt;
The scripts are divided into two categories: ''utilities'' and ''features''. The ''utilities'' scripts include tools for general scripting, like new maths functions, or linked lists and vector classes. The ''features'' scripts are more specific solutions that make use of the utilities, such as a way to spawn entities at specific locations, script a large chain of events or to make entities twitch and flicker. Some modders might prefer to just adopt the ''utilities'' scripts. It's up to you!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''[[HPL2/HPL2 Helper Scripts#Set-up|See below for download and set-up instructions.]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Contents=&lt;br /&gt;
The documentation and help is organised by file. '''''Lots of help, and full details of the new classes and functions, can be found on the following pages:'''''&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Utilities==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Debug|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Debug'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides more control and options for debug messages and logging.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/GameVars|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''GameVars'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Extends the functionality of the saved game global and local variable wrappers.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Lists|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Lists'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for linked list classes.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/LoadWatcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''LoadWatcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides an &amp;quot;OnLoad()&amp;quot; global function.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Math|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Math'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended maths functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/String|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''String'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended string functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Vectors|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Vectors'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for vector classes.&lt;br /&gt;
||&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;||&lt;br /&gt;
==Features==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Bobber|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Bobber'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for floating or hovering entities, without physics.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Fader|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Fader'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing global ambient sounds.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Glitcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Glitcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing entities that appear to glitch or flicker.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Slimer|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Slimer'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing large sequences of entity actions.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Spawner|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Spawner'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for spawning entities at specific map locations.&lt;br /&gt;
:&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&amp;amp;nbsp;&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
::&amp;amp;nbsp;&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Misc|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Miscellaneous'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Bits and pieces that don't fit anywhere else.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Set-up=&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First, download ''HPL2 Helper Scripts'' from the [https://steamcommunity.com/sharedfiles/filedetails/?id=3101276708 Steam Workshop page] or [https://www.moddb.com/mods/hpl2-helper-scripts ModDb page] and unzip it.&lt;br /&gt;
&lt;br /&gt;
If you get it on Steam Workshop, you'll find the actual folder in your Steam Workshop downloads.&lt;br /&gt;
&lt;br /&gt;
The current version is [[HPL2/HPL2_Helper_Scripts#Version_1.1.2C_03.2F02.2F24|1.1]].&lt;br /&gt;
&lt;br /&gt;
Once you have zipped the folder, there are three options for how you add it into your mod. '''If you are unsure, just go with option A'''.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option A: The full feature-set package===&lt;br /&gt;
::If you want to be able to use all the new functions and classes, go with option A.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_FullPackage.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_FullPackage.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option B: The utilities-only package===&lt;br /&gt;
::Choose option B if you want to have access to the functions and classes in the ''utilities'' category, but don't need the stuff in the ''features'' category.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_UtilitiesOnly.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_UtilitiesOnly.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option C: Pick-n-mix===&lt;br /&gt;
::Advanced modders might prefer to only adopt the specific script files they need. Go nuts! But also be aware of the #include dependencies in each script file, as many of them are interdependent. You might find it easiest to start with option A or B and then remove scripts later that you definitely haven't used. You're also fully allowed and encouraged to just use HPL2HelperScripts as a learning resource or even to just copy snippets here and there.&lt;br /&gt;
&lt;br /&gt;
=Licence and Credits=&lt;br /&gt;
You are free to use ''HPL2 Helper Scripts'' in whatever way you see fit, no rights reserved by Aetheric Games. (As long as you're not going against any licence terms between you and Frictional Games, of course!) Aetheric Games is mostly just one person, mrbehemo, me (hello), and this has been a ''stupid'' amount of work, so if you find it helpful then it would be very cool of you to give me a credit in your mod or custom story. You can list it as &amp;quot;HPL2&amp;amp;nbsp;Helper&amp;amp;nbsp;Scripts&amp;amp;nbsp;by&amp;amp;nbsp;Aetheric&amp;amp;nbsp;Games&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This script package would not have been possible without the work of the tireless and patient Luis Rodero of Frictional Games, and the ever present pillar of the community, Mudbill. &lt;br /&gt;
&lt;br /&gt;
=Support=&lt;br /&gt;
''HPL2 Helper Scripts'' is made by mrbehemo of Aetheric Games. If you need support, here's what to do:&lt;br /&gt;
#First be sure that you're familar with the official [[HPL2/Engine_Scripts|HPL2 scripting reference]] and the [[HPL2/ScriptReference|community scripting guide]].&lt;br /&gt;
#And second, be sure that you've read the relevant parts of this documentation, including the FAQ.&lt;br /&gt;
#And then if you're still stuck I'll be happy to hear from you and will help if I can. Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server].&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
Fervently Anticipated Questions. Nobody's asked anything yet... &lt;br /&gt;
* I've added one or more scripts to my project separately, but I'm getting errors. What should I check?&lt;br /&gt;
** The script files are very interdependent. Check the .hps files you've added - they will have #include directives near the top for every other script they rely on. Either make sure you've also added ''those'' into your project.&lt;br /&gt;
* What's &amp;quot;#include&amp;quot;? What's &amp;quot;OnUpdate()&amp;quot;?&lt;br /&gt;
** Those are new features added with the ATDD [[HPL2/1.5 Update|1.5 update]].&lt;br /&gt;
* I want to make something weird happen, like make 100 flying naked guys do a loop-de-loop around the player. How?&lt;br /&gt;
** Sounds fun and is probably do-able! Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server] if you want advice.&lt;br /&gt;
* Can I get the player's camera direction yet?&lt;br /&gt;
** No, sorry. I investigated multiple ways of doing that, as have many people over the years. There's just no reliable way of doing it in HPL2 without branching the source code.&lt;br /&gt;
* What's a uint and why have you used them everywhere?&lt;br /&gt;
** A &amp;quot;U-int&amp;quot; is an unsigned integer, that is, an integer that can only be positive. I think it's best to use uint in scenarios where negative numbers are nonsensical. Behind the scenes it minimises the the chance of conversion issues, and also minimises warnings in the error output.&lt;br /&gt;
* Why are all your function arguments passed by reference, and why is that not reflected in the docs?&lt;br /&gt;
** In Angelscript there's a tiny, tiny performance saving gained from passing arguments by reference (and by using const where possible). It's not enough of a saving for modders and gameplay scripters to bother with, but since I was writing hundreds of them, it was an easy thing to do. It's not reflected in the docs because most non-advanced modders don't know what &amp;quot;pass by reference&amp;quot; means, or need to know.&lt;br /&gt;
* I looked at your code and you did it all weird. Why did you do it weird?&lt;br /&gt;
** It's probably because of the version of Angelscript that is integrated into HPL2. It has some surprising versatility but also some surprising limitations.&lt;br /&gt;
* Why did you do any of this?&lt;br /&gt;
** I know, I know - HPL2 is old now, I should have done this for The Bunker or whatever. Actually, I was just tidying up The Trapdoor (ATDD mod) for a Steam release, and I got carried away with refactoring it... and then, half a million characters of script later, this had happened. Hope it's useful. If not, it was a good exercise for me. Maybe ''you'' would like to port these scripts to HPL3 as and where needed! Go ahead, just be sure to credit and it'd be cool to let me know.&lt;br /&gt;
&lt;br /&gt;
=Change Log=&lt;br /&gt;
It should be simple to upgrade existing projects to use the current version, but take note of the changes listed below. You may need to make some minor edits.&lt;br /&gt;
&lt;br /&gt;
==Version 1.1, 03/02/24==&lt;br /&gt;
* General&lt;br /&gt;
** Changed some more spammy debug messages in level 2 to level 3 in various classes.&lt;br /&gt;
** Fixed various sign mismatch warnings between ints and uints.&lt;br /&gt;
&lt;br /&gt;
* Debug&lt;br /&gt;
** Default log verbosity is now 2 instead of 3.&lt;br /&gt;
&lt;br /&gt;
* GameVars&lt;br /&gt;
** Added SetIntAsUint() method, which is just SetInt() with an explicit cast.&lt;br /&gt;
&lt;br /&gt;
* Lists&lt;br /&gt;
** New properties for all list types: DefaultValue, Capacity&lt;br /&gt;
** New methods for all list types: Fill(), Extend(), AddUnique(), ToString()&lt;br /&gt;
** Fixed silent exception that occured when Insert() was used with index 0.&lt;br /&gt;
** Fixed silent exception that occured when Pop() was used with a count of 0 or 1.&lt;br /&gt;
** Fixed behaviour of Find() and RemoveItem() in cListGeneric.&lt;br /&gt;
** Added '''==''' operator to cListBase for checking if two lists of the same type are equal.&lt;br /&gt;
** Added optional argument abExtend to Set() methods.&lt;br /&gt;
** Fixed issue with incorrectly overloading Pop(), by moving the generic Pop() from cListBase to its correct place in cListGeneric.&lt;br /&gt;
&lt;br /&gt;
* Math&lt;br /&gt;
** New method in cMath: DistToEntity()&lt;br /&gt;
** RandomVector3d() and RandomVector2d(), when using the vecNormal option or when no range is specified, now have a chance of returning a vector with negative axes, whereas previously they were always positive.&lt;br /&gt;
&lt;br /&gt;
* String&lt;br /&gt;
** New method in cString: NearlyEqual()&lt;br /&gt;
** SplitToList() and SplitToArray() now handle empty strings by returning an empty collection. (As to opposed to previously returning a collection of one empty string.)&lt;br /&gt;
** Added list behaviour to Str class.&lt;br /&gt;
&lt;br /&gt;
* Vectors&lt;br /&gt;
** New methods in cVector: DotProduct(), CrossProduct()&lt;br /&gt;
** New methods in cSpline: GetSegmentHandle(), GetMinLength()&lt;br /&gt;
** Both cVector and cPoint now implement '''* / *= /=''' operators as ''per component'' multipliers, e.g. [2, 2, 2] * [1, 3, 0.5] = [2, 6, 1]&lt;br /&gt;
** If cVector * cVector was previously used where a dot product was the intended result, that should now be replaced by the DotProduct() method.&lt;br /&gt;
** Tweaked the bezier behaviour that uses a single control point to better approximate a quadratic bezier.&lt;br /&gt;
&lt;br /&gt;
* Fader&lt;br /&gt;
** New methods in cFader: PlayMusicTracked(), StopMusicTracked(), IsMusicPlaying(), DuckStart(), DuckRestore()&lt;br /&gt;
** New properties in cFader: IsMusicPlaying, MusicPlayingCount&lt;br /&gt;
** Group 0 now counts as &amp;quot;no group&amp;quot;.&lt;br /&gt;
** Added &amp;quot;Null&amp;quot; behaviour - Fader sounds initialised with a name containing &amp;quot;Null&amp;quot; will not be associated with a sound entity in the map, but they can be included in a group and have a play state as normal.&lt;br /&gt;
** Fader sounds can now be marked as StopOnMusic. If Fader.PlayMusic() and Fader.StopMusic() are used, then Fader sounds with StopOnMusic will fade out when music starts.&lt;br /&gt;
&lt;br /&gt;
* Glitcher&lt;br /&gt;
** Fixed the afChanceScale multiplier when adding glitches. (Was previously inverted).&lt;br /&gt;
** Slightly reduced the default max glitch frequency, for smoother fades.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Fader&amp;diff=6792</id>
		<title>HPL2/HPL2 Helper Scripts/Fader</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Fader&amp;diff=6792"/>
		<updated>2024-02-11T03:20:11Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added IsMusicPlaying, MusicPlayingCount, IsMusicPlaying(), StartMusicTracked(), StopMusicTracked(), DuckStart(), DuckRestore(), and added more intro info.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Fader.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 cFader manages a list of sound entities in a level that are set to play ambient sounds.&lt;br /&gt;
&lt;br /&gt;
The intent is that, rather than having many localised ambient sounds around the level, the level designer can use a handful of sound entities to provide a non-3d &amp;quot;soundscape&amp;quot; and then use scripting to switch between them, and layer them to the desired extent.&lt;br /&gt;
&lt;br /&gt;
Fader handles the fading so that sounds are not cut off suddenly if, for example, a player moves repeatedly over a trigger. Since we can't smoothly change a fade that is already in progress, Fader waits and applies new changes as soon as possible, with the idea that smooth fading is more important than accurate timing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Initialising loops===&lt;br /&gt;
For Fader to control a looping sound, the sound entity (placed in the map in Level Editor) must be registered with Fader. This is done using InitLoop(), typically in the OnEnter() callback of the level.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void OnEnter()&lt;br /&gt;
{&lt;br /&gt;
	Fader.InitLoop(&amp;quot;MySound&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Groups and Priority===&lt;br /&gt;
Each Fader sound can be assigned a group. Only one sound from each group can play at a time. This can be used to build up a layered soundscape and swap out a specific layer. If the group is zero, that counts as &amp;quot;no group&amp;quot;. Multiple group-zero sounds can play at once.&lt;br /&gt;
&amp;lt;br&amp;gt;Each Fader sound is also assigned a priority, or prio. If the maximum number of sounds are player and another tries to play, a random sound with the lowest priority will fade out. The StopLowPriority() method can also be used to manually stop the lowest priority sounds.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Music===&lt;br /&gt;
Fader doesn't do anything special with regards to playing music files, but when the music is stopped and started via Fader using PlayMusicTracked() and StopMusicTracked(), then Fader can keep track of it. Fader sounds can be marked as &amp;quot;StopOnMusic&amp;quot; so that they can fade out when music starts. The basic script functions don't provide a way to query whether music is playing, but Fader provides the properties IsMusicPlaying and MusicPlayingCount.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Ducking===&lt;br /&gt;
Fader sounds that are currently playing can be temporarily faded out and back in using DuckStart() and DuckRestore(). This could be useful for cutscenes or dramatic moments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Sound files===&lt;br /&gt;
Ideally, .snt files for use with Fader should have the following settings:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	FadeEnd=&amp;quot;True&amp;quot; FadeStart=&amp;quot;True&amp;quot; Stream=&amp;quot;True&amp;quot; Loop=&amp;quot;True&amp;quot; Use3D=&amp;quot;False&amp;quot; Blockable=&amp;quot;False&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
(In theory, Fader will work ''to a certain extent'' with any other .snt file settings, but not as intended. This has not been tested.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Save data===&lt;br /&gt;
Fader 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 sounds that were initialised with Fader at the time of saving will be re-initialised, and their play state will be restored.&lt;br /&gt;
&lt;br /&gt;
The restoration of the loaded state occurs on the first frame once the game has started. If the game starts and Fader 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 Fader 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_Fader.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 the maximum concurrent sounds and the default fade times.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Fader=&lt;br /&gt;
Fader is the name of the object that manages the sound fading.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
&amp;quot;HelperScripts_Fader.hps&amp;quot; declares an object called '''Fader''', of the new script class cFader. To access its properties and methods, just use &amp;quot;Fader.&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;
Fader.InitLoop(&amp;quot;ForestAmbienceLoop&amp;quot;);&lt;br /&gt;
if (Fader.IsAnyPlaying) DoStuff();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
Fader provides the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SoundsCount====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint SoundsCount&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property SoundsCount returns the number of sounds registered with Fader.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Fader.SoundsCount == 0) Fader.InitLoop(&amp;quot;ForestAmbienceLoop&amp;quot;);&lt;br /&gt;
// The condition succeeds if no sounds have been registered with Fader yet, and the first one is registered in response.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SoundsPlayingCount====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint SoundsPlayingCount&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property SoundsPlayingCount returns the number of Fader sounds that are currently playing.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Fader.SoundsPlayingCount &amp;gt; 5) StopMusic(10.0f, 1);&lt;br /&gt;
// The condition succeeds if there are more than 5 Fader sounds currently playing, in which case the music is faded out.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsAnyPlaying====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsAnyPlaying&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsAnyPlaying returns whether there are currently any Fader sounds playing.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Fader.IsAnyPlaying) DoStuff();&lt;br /&gt;
// The condition succeeds if any Fader sound is currently playing or fading in.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsMusicPlaying====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsMusicPlaying&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsMusicPlaying returns whether music is currently playing, as long as the music was started or stopped by Fader. See also the IsMusicPlaying() method, to check if music is playing at a specific music prio.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====MusicPlayingCount====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint MusicPlayingCount&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only uint property MusicPlayingCount returns the number of music tracks currently playing. (If there are tracks with different prio values, only the one with the highest prio will be heard, but the rest will also be considered &amp;quot;playing&amp;quot;.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
Fader provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Adding/removing loops===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====InitLoop()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool InitLoop(string asNewSound, bool abStartImmediately = false)&lt;br /&gt;
bool InitLoop(string asNewSound, bool abStartImmediately, float afFadeInTime = 2.5f, float afFadeOutTime = 2.5f, const afPriority = 1.0f, uint aulGroup = 0, bool abStopOnMusic = false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sets up a sound entity in the map to be controlled by Fader, typically during the OnEnter() callback of the level. asNewSound is the name of the sound entity as named in the Level Editor. Returns true if the sound was successfully added. abStartImmediately is optional and can be omitted. If true, the sound will fade in ASAP, otherwise it be ready to start later.&lt;br /&gt;
&amp;lt;br&amp;gt;afFadeInTime and afFadeOutTime can be used to assign longer or short transitions to this sound, but you can also omit it and Fader will use the defaults instead.&lt;br /&gt;
&amp;lt;br&amp;gt;afPriority is optional. If omitted it defaults to mfPriorityDefault (1.0f). The priority of a sound is used if a sound needs to be removed from play. The sound chosen to be stopped will be one with the lowest priority value (and the oldest if there are equal lowest priorities).&lt;br /&gt;
&amp;lt;br&amp;gt;aulGroup is also optional. If specified with a value greater than zero, this serves to group sounds together into channels. Normally sounds layer on top when they start to play, but only one sound with the same aulGroup number greater than zero can play at once. The new sound will replace others with the same aulGroup.&lt;br /&gt;
&amp;lt;br&amp;gt;abStopOnMusic is also option. It defaults to false if omited. If true, this sound will fade out whenever music starts that is tracked by Fader.&lt;br /&gt;
#''string asNewSound'' - The name of the sound entity in the map (not the .snt file).&lt;br /&gt;
#''bool abStartImmediately'' - Whether the sound should be playing from the start. (Optional, default = false)&lt;br /&gt;
#''float afFadeInTime'' - Used to override the default fade timing for this sound. (Optional together with afFadeOutTime, default = 2.5f)&lt;br /&gt;
#''float afFadeInTime'' - Used to override the default fade timing for this sound. (Optional together with afFadeInTime, default = 2.5f)&lt;br /&gt;
#''float afPriority'' - How important is this sound? Lowest priority sounds get replaced first. (Optional, default = 1.0f)&lt;br /&gt;
#''uint aulGroup'' - If &amp;gt; 0, only one sound in each group can play at once. (Optional, default = 0)&lt;br /&gt;
#''bool abStopOnMusic'' - If true, the sound will fade out whenever music is playing that is tracked by Fader. (Optional, default = false)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Fader.InitLoop(&amp;quot;CitySounds&amp;quot;);&lt;br /&gt;
// The sound entity &amp;quot;CitySounds&amp;quot; is registered with Fader, with default settings.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
Fader.InitLoop(&amp;quot;BasementCreaks&amp;quot;, false, 4.0f, 8.0f, 2.0f);&lt;br /&gt;
// The sound entity &amp;quot;BasementCreaks&amp;quot; is registered with Fader, with specific fade times and priority.&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
Fader.InitLoop(&amp;quot;MountainWindQuiet&amp;quot;, true, 1.0f, 2);&lt;br /&gt;
Fader.InitLoop(&amp;quot;MountainWindLoud&amp;quot;, false, 2.0f, 2);&lt;br /&gt;
// Two complementary sounds are registered. Since they are in the same group (2), only one of them can play at once.&lt;br /&gt;
// If Fader ever has to decide which one of the two it should stop, it will chose &amp;quot;MountainWindQuiet&amp;quot; as it has the lower priority.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ClearAllLoops()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearAllLoops()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
De-registers all registered sounds. Since sounds are typically added once with InitLoop() when the player enters the level, ClearAllLoops() should only be needed in exceptional cases. Does not change the current play state of the actual sound loops.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Fader.InitLoop(&amp;quot;NiceSounds&amp;quot;);&lt;br /&gt;
Fader.InitLoop(&amp;quot;SpookySounds&amp;quot;, true);&lt;br /&gt;
Fader.ClearAllLoops();&lt;br /&gt;
// Both the &amp;quot;NiceSounds&amp;quot; and &amp;quot;SpookySounds&amp;quot; entities are de-registered. Since &amp;quot;SpookySounds&amp;quot; was set to start playing, it will probably continue playing without Fader.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Starting/stoppping sounds===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StartLoop()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool StartLoop(string asStartLoop)&lt;br /&gt;
bool StartLoop(string asStartLoop, float afOverrideFadeTime)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Starts a loop playing as soon as possible. Returns true if the sound was successfully prepared to start.&lt;br /&gt;
&amp;lt;br&amp;gt;Optionally, you can override the fade-in time for the sound with afOverrideFadeTime. If omitted, the sound's default fade time will be used if it has one, or the Fader default fade time if it doesn't.&lt;br /&gt;
#''string asStartLoop'' - Name of the sound entity in the map to start playing.&lt;br /&gt;
#''float afOverrideFadeTime'' - Overrides the fade time for the sound. (Optional, default = default fade time)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Fader.StartLoop(&amp;quot;canyon.mid&amp;quot;);&lt;br /&gt;
// If there is a Fader sound with the name &amp;quot;canyon.mid&amp;quot;, it will fade in and play, with its default fade time.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
Fader.StartLoop(&amp;quot;roblox_oof_10hourloop&amp;quot;, 60.0f);&lt;br /&gt;
// If there is a Fader sound with the name &amp;quot;roblox_oof_10hourloop&amp;quot;, it will fade in and play over the course of a minute.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StopLoop()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void StopLoop(string asSoundToRemove)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the specified sound is currently playing, this will stop it as soon as possible.&lt;br /&gt;
#''string asSoundToRemove'' - The name of the sound entity to be stopped in the map.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Fader.StopLoop(&amp;quot;lofi_beats_to_hide_from_grunts_to&amp;quot;);&lt;br /&gt;
// If there is a Fader sound with the name &amp;quot;lofi_beats_to_hide_from_grunts_to&amp;quot; and if it is currently playing, it will fade out and stop.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StopAllLoops()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void StopAllLoops()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Stops all playing sounds as soon as possible.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Fader.StopAllLoops();&lt;br /&gt;
// Any sounds that are currently playing will fade out and stop.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StopLowPriority()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void StopLowPriority()&lt;br /&gt;
void StopLowPriority(float afThreshold)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Checks the priority of currently playing sounds, and if any of them have a priority less than or equal to the specified value, they will be stopped as soon as possible.&lt;br /&gt;
&amp;lt;br&amp;gt;If afThreshold is omitted, a sound with the lowest prority will be removed.&lt;br /&gt;
#''float afThreshold'' - Any sounds with this priority or less will be stopped. (Optional, default is lowest priorty)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Fader.StopLowPriority(2.0f);&lt;br /&gt;
// Any currently playing sounds with a priority of 2.0f or less will fade out and stop.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (Fader.SoundsPlayingCount &amp;gt;= lTooManySounds) Fader.StopLowPriority();&lt;br /&gt;
// If the number of sounds playing is greater than the limit set by lTooManySounds, then a single low-priority sound will fade out and stop.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StopGroup()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void StopGroup(uint aulGroup)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Checks the group number of currently playing sounds, and if any of them have the specified group number, they will be stopped as soon as possible.&lt;br /&gt;
#''uint aulGroup'' - Any sounds with this group number will be stopped.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Fader.StopGroup(4);&lt;br /&gt;
// All sounds in group 4 will fade out and stop.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DuckStart()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void DuckStart()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Fades out all currently playing sounds, storing them in a temporary list. DuckRestore() can be used to resume the sounds that have been ducked. Calling DuckStart() again (before DuckRestore()) will erase the list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Fader.StartLoop(&amp;quot;lofiBeats&amp;quot;);&lt;br /&gt;
// a short while later&lt;br /&gt;
Fader.DuckStart();&lt;br /&gt;
// a while later still&lt;br /&gt;
Fader.DuckRestore();&lt;br /&gt;
// The sound named &amp;quot;lofiBeats&amp;quot; will start, duck and then restore.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DuckRestore()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void DuckStart()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Resumes sounds that have been temporarily stoped by DuckStart(), and clears the temporary list. Any Fader sounds that were started since DuckStart() will be stopped.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Fader.StartLoop(&amp;quot;lofiBeats&amp;quot;);&lt;br /&gt;
// a short while later&lt;br /&gt;
Fader.DuckStart();&lt;br /&gt;
// a while later still&lt;br /&gt;
Fader.DuckRestore();&lt;br /&gt;
// The sound named &amp;quot;lofiBeats&amp;quot; will start, duck and then restore.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Music===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PlayMusicTracked()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void PlayMusicTracked(string asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Starts music, same as the global function Fader.PlayMusicTracked(), only this method is tracked by Fader and can affect Fader sounds.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StopMusicTracked()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void StopMusicTracked(float afFadeTime, int alPrio)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Stops music, same as the global function Fader.StopMusicTracked(), only this method is tracked by Fader and can affect Fader sounds.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsMusicPlaying()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsMusicPlaying( int alPrio)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if music is playing with the given priority. See also the IsMusicPlaying and MusicPlayingCount properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Querying sounds===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsLoopPlaying()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsLoopPlaying(string asLoop)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given the name of a sound entity in the map, this returns true if it is currently playing in Fader.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;quot;Currently playing&amp;quot; includes fading in, but not fading out.  If the sound has not been initialised as a Fader loop, this will return false regardless of whether it is actually playing.&lt;br /&gt;
#''string asLoop'' - The name of the sound entity to check.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Fader.IsLoopPlaying(&amp;quot;DistantMusic&amp;quot;)) DoStuff();&lt;br /&gt;
// The condition succeeds if the sound &amp;quot;DistantMusic&amp;quot; is currently playing.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DebugOutput()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void DebugOutput()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Writes the current state of all registered Fader loops as a Debug message with priority 3.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cFaderSound=&lt;br /&gt;
cFaderSound is a list node class used by cFader to manage individual loops. It is '''not recommended''' to work with cFaderSound directly. Instead, just use the methods of Fader and let it manage them for you.&lt;br /&gt;
&lt;br /&gt;
'''Advanced users''' who intend to access cFaderSound instances may find the following information useful.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cNodeBobbing has three constructors, from full control to minimal args that use default settings:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cFaderSound(string asName)&lt;br /&gt;
cFaderSound(string asName, enumFaderState aFaderState)&lt;br /&gt;
cFaderSound(string asName, float afFadeInTime, float afFadeOutTime, float afPriority, uint aulGroup, enumFaderState aFaderState)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Fields==&lt;br /&gt;
cFaderSound has no public properties, but is does have some public fields: &amp;lt;code&amp;gt;string msName; uint mulGroup; enumFaderState mFaderState;&amp;lt;/code&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_Fader.hps&amp;quot; defines five global timer callbacks used by cFader to handle latent fading. It is '''not recommended''' to work with cFaderSound directly. Instead, just use the methods of Fader 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 Fader_StartLoop_LatentRetry(string &amp;amp;in asRetrySound)&lt;br /&gt;
void Fader_StartFocus_LatentDone(string &amp;amp;in asFadedSound)&lt;br /&gt;
void Fader_Play_LatentRetry(string &amp;amp;in asFadedSound)&lt;br /&gt;
void Fader_StopFocus_LatentDone(string &amp;amp;in asFadedSound)&lt;br /&gt;
void Fader_Stop_LatentRetry(string &amp;amp;in asFadedSound)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Enums===&lt;br /&gt;
&amp;quot;HelperScripts_Fader.hps&amp;quot; defines the enumerator enumFaderState.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Glitcher&amp;diff=6791</id>
		<title>HPL2/HPL2 Helper Scripts/Glitcher</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Glitcher&amp;diff=6791"/>
		<updated>2024-02-11T02:46:35Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&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 glitching 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>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Vectors&amp;diff=6790</id>
		<title>HPL2/HPL2 Helper Scripts/Vectors</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Vectors&amp;diff=6790"/>
		<updated>2024-02-11T02:43:22Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added cBezier GetSegmentHandle() and GetMinLength()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Vectors.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;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_Vectors.hps&amp;quot; adds support for various vector classes. For beginners or other people not familiar with classes, this is best thought of as new variable types.&lt;br /&gt;
&lt;br /&gt;
At its simplest, vector is a type holds multiple numbers, and is usually used to represent spatial co-ordinates or movement. Some advantages to using a vector over individual numbers is that you can pass the vector as a single argument, or use it in arithmetic as if it was single scalar number. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1 - The basic way:&lt;br /&gt;
float fSpeedX = 1.5f;&lt;br /&gt;
float fSpeedY = 0.0f;&lt;br /&gt;
float fSpeedZ = 0.75f;&lt;br /&gt;
float fCurrentX = GetEntityPosX(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
float fCurrentY = GetEntityPosY(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
float fCurrentZ = GetEntityPosZ(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
SetEntityPos(&amp;quot;myEntity&amp;quot;, fCurrentX + (fSpeedX * afStep), fCurrentY + (fSpeedY * afStep), fCurrentZ + (fSpeedZ * afStep));&lt;br /&gt;
&lt;br /&gt;
// Example 2 - The Helper Scripts way:&lt;br /&gt;
cVector vSpeed = new cVector(1.5f, 0.0f, 0.75f);&lt;br /&gt;
cVector vCurrent = GetEntityPosVec(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
SetEntityPosVec(&amp;quot;myEntity&amp;quot;, vCurrent + (vSpeed * afStep));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These two examples have the same effect, but with much simpler code.&lt;br /&gt;
&lt;br /&gt;
Various methods are provided, in both the vector classes and in Math, for working with vectors; for example, to find out the length of a line, working out rotations, plotting paths and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Vector types===&lt;br /&gt;
Available vector classes:&lt;br /&gt;
&amp;lt;code&amp;gt;cVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cPoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cRotator&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;cBezier&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cSpline&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
Declare a vector like any other variable, and use its various properties, operations and methods list on this page to work with it. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector myVector;			// Declares a new cVector, called myVector. By default it's a 3d vector.&lt;br /&gt;
cVector my2dVector(2);		// Declares a new cVector, set up to have 2 dimensions.&lt;br /&gt;
cVector myVector.X = 2.0f;	// Assigns the value 2.0f to the X component of myVector.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cPoint and cRotator classes work similarly. (A cPoint is a vector containing integers instead of floats, and a cRotator is a vector intended for working with pitch-yaw-roll rotations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component properties===&lt;br /&gt;
The simplest way to access the components of a 2d or 3d vector is through the named properties. A 2d or 3d cVector provides X and Y, or X, Y and Z properties. cRotator has Pitch, Yaw and Roll. See the notes below for more details on each class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Indices===&lt;br /&gt;
Like arrays, you can ''get'' the items in the vector using an index operator, e.g. myVector[0], myVector[1], myVector[2] are the same as the X, Y and Z properties. However, ''unlike arrays'', this is '''read-only'''.&lt;br /&gt;
&lt;br /&gt;
(This seems to be because the version of AngelScript used in HPL2 seems to only allow the index operator to ''get'' and not ''set''. If I'm wrong and you can make this work, let me know!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
cRotator inherits from cVector. Advanced users who want to make their own derived vector types are advised to read over the cVector definition and derived class definitions to see how they inherit.&lt;br /&gt;
&lt;br /&gt;
cVector and cPoint can both be used for 2d or 3d vectors. The vector classes are designed to be agnostic of dimensionality. The maximum number of dimensions for all vector classes is defined by ulVectorDimMax. The default value is 16, but an advanced user may want to edit that value. cVector and it's derived classes can have any number of dimensions from 0 to, in theory, 65535, although either extreme would be ridiculous. Using a maximum larger than 65535 could cause problems.&lt;br /&gt;
&lt;br /&gt;
Arithmetic, and some methods, can work with differently dimensioned vectors. For example &amp;lt;code&amp;gt;a[X,Y,Z] + b[X,Y]&amp;lt;/code&amp;gt; has the same effect as &amp;lt;code&amp;gt;a[X,Y,Z] + b[X,Y,0]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cVector=&lt;br /&gt;
The cVector class defines a type that contains a series of float values, typically used to represent a spatial location or movement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cVectors are declared similarly to a data type variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector myVector;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default constructor makes an empty 3d vector:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector myVector;						// Makes a 3d vector&lt;br /&gt;
cVector myVector = cVector();			// Makes a 3d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
You can make an empty vector with a specific dimension (the number of components) by passing an integer to the constructor:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	cVector myVector = cVector(3);		// Makes a 3d vector&lt;br /&gt;
&lt;br /&gt;
	cVector myVector = cVector(2);		// Makes a 2d vector&lt;br /&gt;
	cVector myVector = cVector(4);		// Makes a 4d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A vector can be initialised with any number dimension up to ulVectorDimMax (default 16).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
cVector provides the following public properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====X====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property X provides access to the first component in the cVector (provided it has at least one component).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.X;&lt;br /&gt;
vMyVector.X = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Y====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Y&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property Y provides access to the second component in the cVector (provided it has at least two components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.Y;&lt;br /&gt;
vMyVector.Y = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Z====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Z&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property Z provides access to the third component in the cVector (provided it has at least three components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.Z;&lt;br /&gt;
vMyVector.Z = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====W====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float W&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property W provides access to the fourth component in the cVector (provided it has at least four components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.W;&lt;br /&gt;
vMyVector.W = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dimension====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Dimension&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Dimension returns the number of components in the cVector. The dimension of the cVector can be set by the constructor or, see also: Resize().&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (vMyVector.Dimension &amp;gt;=3) vMyVector.Z = 0.0f;&lt;br /&gt;
// The condition succeeds if the cVector has at least three components, and then the value of the 3rd component is assigned 0.0f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the index of the last component in the cVector. This is the same as Dimension - 1.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float fMyFloat = vMyVector[vMyVector.LastIndex];&lt;br /&gt;
// The float fMyFloat is assigned whatever value is found in the final component of the cVector.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some '''arithmetic''' operators have been implemented for '''a cVector with another cVector''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  *  /  +=  -=  *=  /= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional '''arithmetic''' operators have been implemented for '''a cVector with a float''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  *  /  +=  -=  *=  /= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; to multiply or divide a vector by a scalar value (float or double) will scale the vector, component-wise.&lt;br /&gt;
&amp;lt;br&amp;gt;Using &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; to multiply a scalar value by a vector (ie. reversing the order) provides the same componenet-wise result. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;[1.0, 2.0, 3.0] * 1.5 = [1.5, 3.0, 4.5]&lt;br /&gt;
1.5 * [1.0, 2.0, 3.0] = [1.5, 3.0, 4.5]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
But of course, reversing the order with &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; will return a different result. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;[1.0, 2.0, 3.0] / 2.0 = [0.5, 1.0, 1.5]&lt;br /&gt;
2.0 / [1.0, 2.0, 3.0] = [2.0, 1.0, 0.666666]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
As of version 1.1, using &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; to multiply two vectors together will return the two vectors multiplied component-wise. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;[2.0, 2.0, 2.0] * [2.0, 0.0, 0.25] = [4.0, 0.0, 0.5]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;As of version 1.1, using &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; to divide two vectors will return the first vectors divided by the second vector, component-wise, using safe divide. E.g:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;[2.0, 2.0, 2.0] / [2.0, 0.0, 0.25] = [1.0, 0.0, 8.0]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;(Prior to version 1.1, * would return the dot product and / was not implemented. In version 1.1, the dot product can be calculated with the DotProduct() method instead.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''equality''' operator &amp;lt;code&amp;gt; == &amp;lt;/code&amp;gt; checks for an exact match between two cVectors. '''Comparison''' operators &amp;lt;code&amp;gt; &amp;gt; &amp;gt;= &amp;lt; &amp;lt;= &amp;lt;/code&amp;gt; compare the '''square length''' of the vectors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''index''' operator &amp;lt;code&amp;gt; myVector[i] &amp;lt;/code&amp;gt; allows read-only access to the vector's components by index.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''assignment''' operator &amp;lt;code&amp;gt; = &amp;lt;/code&amp;gt; assigns a new value by duplicating the components. This may also '''resize''' the dimension of the vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting values===&lt;br /&gt;
cVector provides the following methods for assigning values to the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetIndex(uint aulIndex, float afValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to a component by index. E.g., the X component is at index 0, Y is index 1, etc.. Returns false if index is outside of the dimension of the vector, or true if it was successfully set.&lt;br /&gt;
#''uint aulIndex'' - The index to set with a new value.&lt;br /&gt;
#''float afValue'' - The value to set at the index.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyVector.SetIndex(1, 3.0f);&lt;br /&gt;
vMyVector.Y = 3.0f;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir2d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir2d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cVector into a 2d vector pointing in that direction.&lt;br /&gt;
&lt;br /&gt;
Uses typical screen coordinate directions, where up is -y, right is +x. If forward is given then that is considered to be right (+x).&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyVector.SetDir2d(dirLeft);&lt;br /&gt;
// vMyVector becomes -1,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir3d====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir3d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cVector into a 3d vector pointing in that direction. &lt;br /&gt;
&lt;br /&gt;
Uses HPL2's &amp;quot;right-handed, x=left&amp;quot; coordinate system, so the forward direction is considered to be 0,0,1. Right is -1,0,0 and up is 0,1,0.&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyVector.SetDir3d(dirLeft);&lt;br /&gt;
// vMyVector becomes 1,0,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting values===&lt;br /&gt;
cVector provides the following method for retrieving values from the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetIndex(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves a component by index. E.g., the X component is at index 0, Y is index 1, etc.&lt;br /&gt;
#''uint aulIndex'' - The index whose value to get.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.GetIndex(2);&lt;br /&gt;
fMyFloat = vMyVector.Z;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Length===&lt;br /&gt;
cVector provides the following methods for working with vector length:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Length()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Length()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the euclidean length of the vector as a float. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vMyRectangle = cVector(10.0f, 15.0f);&lt;br /&gt;
float fMyHypotenuse = vMyRectangle.Length();&lt;br /&gt;
// fMyHypotenuse becomes the length of the diagonal line across a rectangle 10m by 15m.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LengthSqr()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float LengthSqr()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the squared length of the vector, which can be more efficient than calculating the actual length in some use cases, e.g. when you only need to compare two lengths without knowing the exact values. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool bIsVecALonger = vVecA.LengthSqr() &amp;gt; vVecB.LengthSqr();&lt;br /&gt;
// bIsVecALonger becomes true if vVecA is longer than vVecB, without calculating the final lengths.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normal()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector Normal()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Calculates the normal of this vector and returns it as a copy. This vector is not changed. The normal vector points in the same direction, but has a length of one.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection.Normal() * fSpeed;&lt;br /&gt;
// If vDirection is a vector of unknown length pointing in some direction, this would set vVelocity to be a vector pointing in the same direction, but with a length of exactly fSpeed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normalize()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Normalize()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Normalizes a vector in place. This vector becomes the normal vector, and the original values are forgotten. The normal vector points in the same direction, but has a length of one.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection;&lt;br /&gt;
vVelocity.Normalize(); // Length of vVelocity has now become 1.&lt;br /&gt;
vVelocity *= 3.0f;&lt;br /&gt;
// This example has the same result as the previous one, for Normal().&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Vector products===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DotProduct()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float DotProduct(cVector avB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Calculates the dot product of this and the given vector avB, and returns it as a float.&lt;br /&gt;
#''cVector avB'' - The other vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CrossProduct()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector CrossProduct(cVector avB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Caulculates the cross product of this and the given vector avB, and returns it as a new vector.&lt;br /&gt;
#''cVector avB'' - The other vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Strings from cVector===&lt;br /&gt;
cVector provides the following methods for converting vectors to strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 2, the format &amp;quot;(x=_, y=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 3, the format &amp;quot;(x=_, y=_, z=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 0, the string &amp;quot;empty cVector&amp;quot; is returned.&lt;br /&gt;
&amp;lt;br&amp;gt;For any other dimension, ToStringAsIndices() is called instead.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringAsIndices()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToStringAsIndices()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string, in the format &amp;quot;([0]=_, [1]=_, [2]=_ ...)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced===&lt;br /&gt;
The following methods exist for advanced users and should be used with caution:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Resize(uint aulNewDim)		// Changes the dimension of the vector.&lt;br /&gt;
bool Append(float afValue)		// Increases the dimension of this cVector by one, and adds the given float as a new component.&lt;br /&gt;
bool Append(cVector avValues)	// Increases the dimension of this cVector to accomodate the given cVector, and appends its components.&lt;br /&gt;
const float[]@ ReadArray()		// Returns a handle to the cVector's component array data.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cPoint=&lt;br /&gt;
The cPoint class defines a vector type that contains a series of int values, typically used to represent a location or movement on a grid, or pixels.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cPoints are declared similarly to a data type variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cPoint myPoint;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default constructor makes an empty 3d vector:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cPoint myPoint;						// Makes a 3d vector&lt;br /&gt;
cPoint myPoint = cPoint();			// Makes a 3d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
You can make an empty vector with a specific dimension (the number of components) by passing an integer to the constructor:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	cPoint myPoint = cPoint(3);		// Makes a 3d vector&lt;br /&gt;
&lt;br /&gt;
	cPoint myPoint = cPoint(2);		// Makes a 2d vector&lt;br /&gt;
	cPoint myPoint = cPoint(4);		// Makes a 4d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A vector can be initialised with any number dimension up to ulVectorDimMax (default 16).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
cPoint provides the following public properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====X====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property X provides access to the first component in the cPoint (provided it has at least one component).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.X;&lt;br /&gt;
vMyPoint.X = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Y====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Y&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property Y provides access to the second component in the cPoint (provided it has at least two components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.Y;&lt;br /&gt;
vMyPoint.Y = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Z====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Z&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property Z provides access to the third component in the cPoint (provided it has at least three components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.Z;&lt;br /&gt;
vMyPoint.Z = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====W====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int W&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property W provides access to the fourth component in the cPoint (provided it has at least four components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.W;&lt;br /&gt;
vMyPoint.W = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dimension====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Dimension&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Dimension returns the number of components in the cPoint. The dimension of the cPoint can be set by the constructor or, see also: Resize().&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (vMyPoint.Dimension &amp;gt;=3) vMyPoint.Z = 0;&lt;br /&gt;
// The condition succeeds if the cPoint has at least three components, and then the value of the 3rd component is assigned 0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the index of the last component in the cPoint. This is the same as Dimension - 1.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int fMyInt = vMyPoint[vMyPoint.LastIndex];&lt;br /&gt;
// The int fMyInt is assigned whatever value is found in the final component of the cPoint.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: the results of division operations with ints maybe truncated. That is, in integer calculations, 1 / 2 = 0.&lt;br /&gt;
&lt;br /&gt;
'''Arithmetic''' operators have been implemented for '''a cPoint with another cPoint''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  *  /  +=  -=  *=  /= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional '''arithmetic''' operators have been implemented for '''a cPoint with an int''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  *  /  +=  -=  *=  /= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''multiplication''' operator &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; used with a cPoint and an int, or a pair of cPoint, will scale the point component-wise.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''equality''' operator &amp;lt;code&amp;gt; == &amp;lt;/code&amp;gt; checks for an exact match between two cPoints. '''Comparison''' operators &amp;lt;code&amp;gt; &amp;gt; &amp;gt;= &amp;lt; &amp;lt;= &amp;lt;/code&amp;gt; compare the '''square length''' of the vectors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''index''' operator &amp;lt;code&amp;gt; myVector[i] &amp;lt;/code&amp;gt; allows read-only access to the vector's components by index.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''assignment''' operator &amp;lt;code&amp;gt; = &amp;lt;/code&amp;gt; assigns a new value by duplicating the components. This may also '''resize''' the dimension of the vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting values===&lt;br /&gt;
cPoint provides the following methods for assigning values to the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetIndex(uint aulIndex, int alValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to a component by index. E.g., the X component is at index 0, Y is index 1, etc.. Returns false if index is outside of the dimension of the vector, or true if it was successfully set.&lt;br /&gt;
#''uint aulIndex'' - The index to set with a new value.&lt;br /&gt;
#''int alValue'' - The value to set at the index.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyPoint.SetIndex(1, 3);&lt;br /&gt;
vMyPoint.Y = 3;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir2d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir2d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cPoint into a 2d vector pointing in that direction.&lt;br /&gt;
&lt;br /&gt;
Uses typical screen coordinate directions, where up is -y, right is +x. If forward is given then that is considered to be right (+x).&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyPoint.SetDir2d(dirLeft);&lt;br /&gt;
// vMyPoint becomes -1,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir3d====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir3d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cPoint into a 3d vector pointing in that direction. &lt;br /&gt;
&lt;br /&gt;
Uses HPL2's &amp;quot;right-handed, x=left&amp;quot; coordinate system, so the forward direction is considered to be 0,0,1. Right is -1,0,0 and up is 0,1,0.&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyPoint.SetDir3d(dirLeft);&lt;br /&gt;
// vMyPoint becomes 1,0,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting values===&lt;br /&gt;
cPoint provides the following method for retrieving values from the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetIndex(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves a component by index. E.g., the X component is at index 0, Y is index 1, etc.&lt;br /&gt;
#''uint aulIndex'' - The index whose value to get.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.GetIndex(2);&lt;br /&gt;
fMyInt = vMyPoint.Z;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Length===&lt;br /&gt;
cPoint provides the following methods for working with vector length:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Length()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Length()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the euclidean length of the vector as a truncated int. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cPoint vMyRectangle = cPoint(10, 15);&lt;br /&gt;
int lMyHypotenuse = vMyRectangle.Length();&lt;br /&gt;
// lMyHypotenuse becomes the length of the diagonal line across a rectangle 10m by 15m.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LengthSqr()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int LengthSqr()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the squared length of the vector, which can be more efficient than calculating the actual length in some use cases, e.g. when you only need to compare two lengths without knowing the exact values. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool bIsVecALonger = vVecA.LengthSqr() &amp;gt; vVecB.LengthSqr();&lt;br /&gt;
// bIsVecALonger becomes true if vVecA is longer than vVecB, without calculating the final lengths.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normal()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cPoint Normal()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Calculates the truncated integer normal of this vector and returns it as a copy. This vector is not changed. The normal vector points in the same direction, but has a length of approximately one, while the components remain whole numbers.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection.Normal();&lt;br /&gt;
// If vDirection is a vector of unknown length pointing in some direction, this would set vVelocity to be a vector pointing in the same direction, but with a length of approximately one.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normalize()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Normalize()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Normalizes a vector in place. This vector becomes the normal vector, and the original values are forgotten. The normal vector points in the same direction, but has a length of approximately one.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection;&lt;br /&gt;
vVelocity.Normalize(); // Length of vVelocity has now become approximately one.&lt;br /&gt;
vVelocity *= 3.0f;&lt;br /&gt;
// This example has the same result as the previous one, for Normal().&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Strings from cPoint===&lt;br /&gt;
cPoint provides the following methods for converting vectors to strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 2, the format &amp;quot;(x=_, y=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 3, the format &amp;quot;(x=_, y=_, z=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 0, the string &amp;quot;empty cPoint&amp;quot; is returned.&lt;br /&gt;
&amp;lt;br&amp;gt;For any other dimension, ToStringAsIndices() is called instead.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringAsIndices()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToStringAsIndices()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string, in the format &amp;quot;([0]=_, [1]=_, [2]=_ ...)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced===&lt;br /&gt;
The following methods exist for advanced users and should be used with caution:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Resize(uint aulNewDim)		// Changes the dimension of the vector.&lt;br /&gt;
bool Append(float afValue)		// Increases the dimension of this cPoint by one, and adds the given float as a new component.&lt;br /&gt;
bool Append(cPoint avValues)	// Increases the dimension of this cPoint to accomodate the given cPoint, and appends its components.&lt;br /&gt;
const int[]@ ReadArray()		// Returns a handle to the cPoint's component data array.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cRotator=&lt;br /&gt;
The cRotator class defines a type that contains a series of float values, intended to represent an angular orientation, or a rotation. cRotator inherits from cVector, but also defines some properties and methods specific to working with rotation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
There are two ways to assign the pitch, yaw and roll values in the constructor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The angle values can be set directly in the constructor using degrees or radians. An optional enumAngleUnits is used to specify whether using degrees. The default is radians.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Initialising angles in degrees:&lt;br /&gt;
cRotator(pitchDegrees, yawDegrees, rollDegrees, angleDegrees)&lt;br /&gt;
&lt;br /&gt;
// Initialise the angles in radians&lt;br /&gt;
cRotator(pitchRadians, yawRadians, rollRadians)&lt;br /&gt;
cRotator(pitchRadians, yawRadians, rollRadians, angleRadians)&lt;br /&gt;
&lt;br /&gt;
// These two rotators are equivalent:&lt;br /&gt;
cRotator myDegrees = cRotator(90.0f, 180.0f, 45.0f, true);&lt;br /&gt;
cRotator myRadians = cRotator(Math.Pi, Math.Tau, Math.Pi / 2.0f);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The angle values can be set in the constructor using an enumOrthoDir option. enumOrthoDir can be dirForward, dirBackward, dirLeft, dirRight, dirUp, or dirDown.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cRotator yawRight = cRotator(dirRight);&lt;br /&gt;
cRotator pitchDown = cRotator(dirDown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The angle values can be set with the Pitch, Yaw and Roll properties:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
myRotator.Pitch = Math.Pi / 2.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The pitch, yaw and roll properties are treated as radians by default. To specify degrees or radians explicitly, the pitchDeg, yawDeg, rollDeg, and pitchRad, yawRad, rollRad properties can be used, e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
myRotator.YawDeg = 180;&lt;br /&gt;
myRotator.RollRad = Math.Pi * 3.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Internally the cRotator class stores angle values as radians between negative and positive Pi. (Equivalent to -180 degrees to 180 degrees.) Angles outside of this range are wrapped around. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cRotator rotation = cRotator(0.0f, 90.0f, 0.0f, true);&lt;br /&gt;
rotation += cRotator(0.0f, 120.0f, 0.0f, true);&lt;br /&gt;
// rotation is now (degrees) 0.0f, -150.0f, 0.0f&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, &amp;quot;rotation&amp;quot; is initialised with 90d yaw, and then rotated a further &lt;br /&gt;
120d clockwise. Rather than 210d clockwise, the resulting yaw is 150 anti-clockwise (-150);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pitch====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Pitch&lt;br /&gt;
float PitchRad&lt;br /&gt;
float PitchDeg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float properties Pitch and PitchRad provide access to the pitch component in radians. PitchDeg provides access to the pitch component in degrees.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyRotator.Pitch;&lt;br /&gt;
vMyRotator.PitchDeg = 90.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Yaw====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Yaw&lt;br /&gt;
float YawRad&lt;br /&gt;
float YawDeg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float properties Yaw and YawRad provide access to the pitch component in radians. YawDeg provides access to the pitch component in degrees.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyRotator.Yaw;&lt;br /&gt;
vMyRotator.YawDeg = 90.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Roll====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Roll&lt;br /&gt;
float RollRad&lt;br /&gt;
float RollDeg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float properties Roll and RollRad provide access to the pitch component in radians. RollDeg provides access to the pitch component in degrees.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyRotator.Roll;&lt;br /&gt;
vMyRotator.RollDeg = 90.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
In addition to methods inherited from cVector, cRotator provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
string ToStringRad()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as radians in a string with the format &amp;quot;(p=_, y=_, r=_)(rad)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringDeg()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToStringDeg()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as degrees in a string with the format &amp;quot;(p=_, y=_, r=_)(deg)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cBezier=&lt;br /&gt;
&lt;br /&gt;
The cBezier class defines a curved line in space, with a couple of basic functions. Technically it is a cubic bezier defined by 4 points: a start, an end, and two control points for influencing the curve. It can also roughly approximate a quadratic bezier if constructed with only one control point.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cBezier has four constructors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cBezier(cVector avStart, cVector avCtrl1, cVector avCtrl2, cVector avEnd)	// Creates a cubic bezier with two control points.&lt;br /&gt;
cBezier(cVector avStart, cVector avCtrl, cVector avEnd)						// Creates bezier approximating a quadratic bezier.&lt;br /&gt;
cBezier(cVector avStart, cVector avEnd)										// Creates a bezier that behaves like a straight line.&lt;br /&gt;
cBezier()																	// Creates a bezier that starts and ends at 0,0,0, with zero length.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Properties:==&lt;br /&gt;
To access the internal vector positions in the bezier, you can use the properties: Start, End, CtrlStart and CtrlEnd.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cBezier manualBezier;&lt;br /&gt;
cVector someLocation = cVector(10.0f, 11.0f, 12.0f);&lt;br /&gt;
manualBezier.Start = someLocation;&lt;br /&gt;
manualBezier.End = someLocation * 1.5f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Start====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector Start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property Start can be used to get or set the start point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====End====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector End&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property End can be used to get or set the end point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CtrlStart====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector CtrlStart&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property CtrlStart can be used to get or set the first control point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CtrlEnd====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector CtrlEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property CtrlEnd can be used to get or set the second control point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
cBezier provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetPoint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetPoint(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the curve from 0.0f to 1.0f, this returns the position at that point. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' - The time on the curve (0.0 - 1.0) to get the position of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.33f;&lt;br /&gt;
cVector vLocationOnCurve = vMyBezier.GetPoint(vProgressOnCurve);&lt;br /&gt;
// vLocationOnCurve becomes the position in space that is 33% of the journey along the curve.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetTangent()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetTangent(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the curve from 0.0f to 1.0f, this returns a normal vector that approximates the forward direction of the curve at that position. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' -  The time on the curve (0.0 - 1.0) to get the tangent of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.66f;&lt;br /&gt;
cVector vDirectionOnCurve = vMyBezier.GetTangent(vProgressOnCurve);&lt;br /&gt;
// vDirectionOnCurve becomes the forward direction of the curve at the point of 66% through the journey along it.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetApproxLength()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetApproxLength(enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Estimates the approximate length of the curve.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - Can be lengthFinal or lengthSquared. (Optional, default = lengthFinal)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the bezier as a string, including the x,y,z components of all four vector positions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cSpline=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The cSpline class defines an array of Beziers that can be treated like a continuous path made of multiple curved segments. Internally cSpline is a cBezier array of a fixed maximum size (default = 16). The cSpline can be initialised using existing beziers, or with a single curve defined by args in the constructor.&lt;br /&gt;
&lt;br /&gt;
For further control over how the curve is built, the cSpline can be declare as empty with segments added afterwards. Segments can be added to the spline either as whole cBezier segments using AddSegment(), or by adding one cVector point at a time using AddPoint().&lt;br /&gt;
&lt;br /&gt;
With the AddPoint() method, the spline is defined by providing the positions it should move through as individual points in space. Specific tangents can be provided (forward direction and scale) for each point, but are optional. When the final point is added, abLast should be specified as true to finish the spline and apply automatic tangents where needed. The automatic tangents make sure that path through each point is smooth, unless specific tangents were specified through AddPoint().&lt;br /&gt;
&lt;br /&gt;
Alternatively, with the AddSegment() method, the spline can be defined by providing each segment as a Bezier. The end of the previous segment will be updated to match the new one. (This is not quite the same as passing an array of Beziers to the constructor, as in that case the constructor will not attempt to match the end points, and they will not be smooth or even continuous unless defined that way by the script.)&lt;br /&gt;
&lt;br /&gt;
The spline does not have constant velocity. That is to say, each segment has an equal share of the &amp;quot;time&amp;quot;, regardless of the size of the segment, and within each segment the control points can cause acceleration. Easing can be effected by varying the size of the segments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cSpline has seven constructors in total, with various options for initialising a curve.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructing empty splines===&lt;br /&gt;
If the cSpline should start empty, ready for AddSegment() or AddPoint(), one of the following constructors should be used:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cSpline()							// Creates an empty spline with a maximum size of 16 bezier segments.&lt;br /&gt;
cSpline(uint aulSegments)			// Creates an empty spline with capacity for the number of bezier segments specified by aulSegments.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructing with cBezier===&lt;br /&gt;
If the cSpline should be populated with one or more existing bezier curves, one of the following constructors should be used:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cSpline(cBezier aSegmentsArray)		// Takes an existing cBezier array and uses that to populate the new spline.&lt;br /&gt;
cSpline(cBezier@ ahBezier)			// Uses a reference to an existing cBezier to populate the new spline with a single segment.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructing with cVector===&lt;br /&gt;
Finally, if the cSpline should be populated a curve or line defined by cVector arguments, one of these constructors will help:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cSpline(cVector avStart, cVector avCtrlStart, cVector avCtrlEnd, cVector avEnd)&lt;br /&gt;
// Takes four vector positions and builds a cubic bezier to populate the new spline with a single segment.&lt;br /&gt;
&lt;br /&gt;
cSpline(cVector avStart, cVector avCtrl, cVector avEnd)&lt;br /&gt;
// Takes three vector positions and builds a approximation of a quadratic bezier to populate the new spline with a single segment.&lt;br /&gt;
&lt;br /&gt;
cSpline(cVector avStart, cVector avEnd)&lt;br /&gt;
// Takes two vector positions and populate the new spline with a single segment in the form of a straight line between two points.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
cBezier provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddSegment()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool AddSegment(cBezier ahSegment, bool abSnap = true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Appends a bezier onto the spline as new segment. Returns false if the spline is already full, or true if it was successfully added.&lt;br /&gt;
&amp;lt;br&amp;gt;abSnap is optional. If omitted, it defaults to true. If abSnap is true then the end point and exit tangent of the previous segment will be adjusted to connect to the start point and entrance tangent of the new one.&lt;br /&gt;
#''cBezier ahSegment'' - A bezier to be appended to the spline.&lt;br /&gt;
#''bool abSnap'' - Whether to adjust the previous segment to connect to the new one. (Optional, default = true)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetSegmentHandle()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cBezier@ GetSegmentHandle(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Looks up the spline segment at the give index and returns a handle to its cBezier.&lt;br /&gt;
#''uint aulIndex'' - The index of the segment to be returned.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====UpdateSegment()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool UpdateSegment(uint aulIndex, cBezier ahSegment, bool abSnap = true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Updates an existing segment by index, replacing it with a new bezier. Returns false if the segment does not already exist, or true if it was successfully updated.&lt;br /&gt;
&amp;lt;br&amp;gt;abSnap is optional. If omitted, it defaults to true. If abSnap is true then the end point and exit tangent of the previous segment, and the start point and entrance tangent of the next segment will be adjusted to connect to the updated segment.&lt;br /&gt;
#''uint aulIndex'' - The index of the segment to be replaced.&lt;br /&gt;
#''cBezier ahSegment'' - A bezier to be replace the bezier at the given index. to the spline.&lt;br /&gt;
#''bool abSnap'' - Whether to adjust the previous and next segments to connect to the updated one. (Optional, default = true)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddPoint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool AddPoint(bool abLast = false, cVector avNextPosition, cVector avNextTangent)&lt;br /&gt;
bool AddPoint(bool abLast = false, cVector avNextPosition)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Appends a position to the end of the spline. Returns false if the spline is already full, or true if it was successfully added.&lt;br /&gt;
&amp;lt;br&amp;gt;avNextTangent is optional and can be omitted. It specifies the tangent as the velocity (direction and scale) of the spline at the new point. If omitted, no tangent is used at this time, but once you have finished adding points, abLast = true should be used and automatic tangents will be applied at that time.&lt;br /&gt;
&amp;lt;br&amp;gt;The automatic tangents are only applied to points where no tangent was given, and only once the spine is marked as &amp;quot;finished&amp;quot; by using abLast = true;&lt;br /&gt;
#''bool abLast'' - Whether this is the last point to be added. (Optional, default = false)&lt;br /&gt;
#''cVector avNextPosition'' - A position in space to add to the spline.&lt;br /&gt;
#''cVector avNextTangent'' - The forward velocity of the spline as it passes through the new position. (Optional, default = auto)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetPoint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetPoint(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the entire spline from 0.0f to 1.0f, this returns the position at that point. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' - The time on the curve (0.0 - 1.0) to get the position of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.33f;&lt;br /&gt;
cVector vLocationOnCurve = vMySpline.GetPoint(vProgressOnCurve);&lt;br /&gt;
// vLocationOnCurve becomes the position in space that is 33% of the journey along the spline.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetTangent()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetTangent(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the entire spline from 0.0f to 1.0f, this returns a normal vector that approximates the forward direction of the curve at that position. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' -  The time on the curve (0.0 - 1.0) to get the tangent of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.66f;&lt;br /&gt;
cVector vDirectionOnCurve = vMySpline.GetTangent(vProgressOnCurve);&lt;br /&gt;
// vDirectionOnCurve becomes the forward direction of the spline at the point of 66% through the journey along it.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetApproxLength()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetApproxLength(enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Estimates the approximate length of the entire spline.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - Can be lengthFinal or lengthSquared. (Optional, default = lengthFinal)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetMinLength()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetMinLength(enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the minimum length of that the entire spline could be, if each segment was a straight line.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - Can be lengthFinal or lengthSquared. (Optional, default = lengthFinal)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a string describing the spline, including the x,y,z components of its start and end points, and the number of segments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Vectors&amp;diff=6789</id>
		<title>HPL2/HPL2 Helper Scripts/Vectors</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Vectors&amp;diff=6789"/>
		<updated>2024-02-11T02:37:39Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added DotProduct(), CrossProduct(), vector * and /&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Vectors.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;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_Vectors.hps&amp;quot; adds support for various vector classes. For beginners or other people not familiar with classes, this is best thought of as new variable types.&lt;br /&gt;
&lt;br /&gt;
At its simplest, vector is a type holds multiple numbers, and is usually used to represent spatial co-ordinates or movement. Some advantages to using a vector over individual numbers is that you can pass the vector as a single argument, or use it in arithmetic as if it was single scalar number. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1 - The basic way:&lt;br /&gt;
float fSpeedX = 1.5f;&lt;br /&gt;
float fSpeedY = 0.0f;&lt;br /&gt;
float fSpeedZ = 0.75f;&lt;br /&gt;
float fCurrentX = GetEntityPosX(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
float fCurrentY = GetEntityPosY(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
float fCurrentZ = GetEntityPosZ(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
SetEntityPos(&amp;quot;myEntity&amp;quot;, fCurrentX + (fSpeedX * afStep), fCurrentY + (fSpeedY * afStep), fCurrentZ + (fSpeedZ * afStep));&lt;br /&gt;
&lt;br /&gt;
// Example 2 - The Helper Scripts way:&lt;br /&gt;
cVector vSpeed = new cVector(1.5f, 0.0f, 0.75f);&lt;br /&gt;
cVector vCurrent = GetEntityPosVec(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
SetEntityPosVec(&amp;quot;myEntity&amp;quot;, vCurrent + (vSpeed * afStep));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These two examples have the same effect, but with much simpler code.&lt;br /&gt;
&lt;br /&gt;
Various methods are provided, in both the vector classes and in Math, for working with vectors; for example, to find out the length of a line, working out rotations, plotting paths and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Vector types===&lt;br /&gt;
Available vector classes:&lt;br /&gt;
&amp;lt;code&amp;gt;cVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cPoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cRotator&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;cBezier&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cSpline&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
Declare a vector like any other variable, and use its various properties, operations and methods list on this page to work with it. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector myVector;			// Declares a new cVector, called myVector. By default it's a 3d vector.&lt;br /&gt;
cVector my2dVector(2);		// Declares a new cVector, set up to have 2 dimensions.&lt;br /&gt;
cVector myVector.X = 2.0f;	// Assigns the value 2.0f to the X component of myVector.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cPoint and cRotator classes work similarly. (A cPoint is a vector containing integers instead of floats, and a cRotator is a vector intended for working with pitch-yaw-roll rotations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component properties===&lt;br /&gt;
The simplest way to access the components of a 2d or 3d vector is through the named properties. A 2d or 3d cVector provides X and Y, or X, Y and Z properties. cRotator has Pitch, Yaw and Roll. See the notes below for more details on each class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Indices===&lt;br /&gt;
Like arrays, you can ''get'' the items in the vector using an index operator, e.g. myVector[0], myVector[1], myVector[2] are the same as the X, Y and Z properties. However, ''unlike arrays'', this is '''read-only'''.&lt;br /&gt;
&lt;br /&gt;
(This seems to be because the version of AngelScript used in HPL2 seems to only allow the index operator to ''get'' and not ''set''. If I'm wrong and you can make this work, let me know!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
cRotator inherits from cVector. Advanced users who want to make their own derived vector types are advised to read over the cVector definition and derived class definitions to see how they inherit.&lt;br /&gt;
&lt;br /&gt;
cVector and cPoint can both be used for 2d or 3d vectors. The vector classes are designed to be agnostic of dimensionality. The maximum number of dimensions for all vector classes is defined by ulVectorDimMax. The default value is 16, but an advanced user may want to edit that value. cVector and it's derived classes can have any number of dimensions from 0 to, in theory, 65535, although either extreme would be ridiculous. Using a maximum larger than 65535 could cause problems.&lt;br /&gt;
&lt;br /&gt;
Arithmetic, and some methods, can work with differently dimensioned vectors. For example &amp;lt;code&amp;gt;a[X,Y,Z] + b[X,Y]&amp;lt;/code&amp;gt; has the same effect as &amp;lt;code&amp;gt;a[X,Y,Z] + b[X,Y,0]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cVector=&lt;br /&gt;
The cVector class defines a type that contains a series of float values, typically used to represent a spatial location or movement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cVectors are declared similarly to a data type variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector myVector;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default constructor makes an empty 3d vector:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector myVector;						// Makes a 3d vector&lt;br /&gt;
cVector myVector = cVector();			// Makes a 3d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
You can make an empty vector with a specific dimension (the number of components) by passing an integer to the constructor:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	cVector myVector = cVector(3);		// Makes a 3d vector&lt;br /&gt;
&lt;br /&gt;
	cVector myVector = cVector(2);		// Makes a 2d vector&lt;br /&gt;
	cVector myVector = cVector(4);		// Makes a 4d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A vector can be initialised with any number dimension up to ulVectorDimMax (default 16).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
cVector provides the following public properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====X====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property X provides access to the first component in the cVector (provided it has at least one component).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.X;&lt;br /&gt;
vMyVector.X = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Y====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Y&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property Y provides access to the second component in the cVector (provided it has at least two components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.Y;&lt;br /&gt;
vMyVector.Y = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Z====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Z&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property Z provides access to the third component in the cVector (provided it has at least three components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.Z;&lt;br /&gt;
vMyVector.Z = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====W====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float W&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property W provides access to the fourth component in the cVector (provided it has at least four components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.W;&lt;br /&gt;
vMyVector.W = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dimension====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Dimension&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Dimension returns the number of components in the cVector. The dimension of the cVector can be set by the constructor or, see also: Resize().&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (vMyVector.Dimension &amp;gt;=3) vMyVector.Z = 0.0f;&lt;br /&gt;
// The condition succeeds if the cVector has at least three components, and then the value of the 3rd component is assigned 0.0f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the index of the last component in the cVector. This is the same as Dimension - 1.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float fMyFloat = vMyVector[vMyVector.LastIndex];&lt;br /&gt;
// The float fMyFloat is assigned whatever value is found in the final component of the cVector.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some '''arithmetic''' operators have been implemented for '''a cVector with another cVector''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  *  /  +=  -=  *=  /= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional '''arithmetic''' operators have been implemented for '''a cVector with a float''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  *  /  +=  -=  *=  /= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; to multiply or divide a vector by a scalar value (float or double) will scale the vector, component-wise.&lt;br /&gt;
&amp;lt;br&amp;gt;Using &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; to multiply a scalar value by a vector (ie. reversing the order) provides the same componenet-wise result. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;[1.0, 2.0, 3.0] * 1.5 = [1.5, 3.0, 4.5]&lt;br /&gt;
1.5 * [1.0, 2.0, 3.0] = [1.5, 3.0, 4.5]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
But of course, reversing the order with &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; will return a different result. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;[1.0, 2.0, 3.0] / 2.0 = [0.5, 1.0, 1.5]&lt;br /&gt;
2.0 / [1.0, 2.0, 3.0] = [2.0, 1.0, 0.666666]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
As of version 1.1, using &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; to multiply two vectors together will return the two vectors multiplied component-wise. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;[2.0, 2.0, 2.0] * [2.0, 0.0, 0.25] = [4.0, 0.0, 0.5]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;As of version 1.1, using &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; to divide two vectors will return the first vectors divided by the second vector, component-wise, using safe divide. E.g:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;[2.0, 2.0, 2.0] / [2.0, 0.0, 0.25] = [1.0, 0.0, 8.0]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;(Prior to version 1.1, * would return the dot product and / was not implemented. In version 1.1, the dot product can be calculated with the DotProduct() method instead.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''equality''' operator &amp;lt;code&amp;gt; == &amp;lt;/code&amp;gt; checks for an exact match between two cVectors. '''Comparison''' operators &amp;lt;code&amp;gt; &amp;gt; &amp;gt;= &amp;lt; &amp;lt;= &amp;lt;/code&amp;gt; compare the '''square length''' of the vectors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''index''' operator &amp;lt;code&amp;gt; myVector[i] &amp;lt;/code&amp;gt; allows read-only access to the vector's components by index.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''assignment''' operator &amp;lt;code&amp;gt; = &amp;lt;/code&amp;gt; assigns a new value by duplicating the components. This may also '''resize''' the dimension of the vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting values===&lt;br /&gt;
cVector provides the following methods for assigning values to the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetIndex(uint aulIndex, float afValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to a component by index. E.g., the X component is at index 0, Y is index 1, etc.. Returns false if index is outside of the dimension of the vector, or true if it was successfully set.&lt;br /&gt;
#''uint aulIndex'' - The index to set with a new value.&lt;br /&gt;
#''float afValue'' - The value to set at the index.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyVector.SetIndex(1, 3.0f);&lt;br /&gt;
vMyVector.Y = 3.0f;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir2d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir2d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cVector into a 2d vector pointing in that direction.&lt;br /&gt;
&lt;br /&gt;
Uses typical screen coordinate directions, where up is -y, right is +x. If forward is given then that is considered to be right (+x).&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyVector.SetDir2d(dirLeft);&lt;br /&gt;
// vMyVector becomes -1,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir3d====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir3d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cVector into a 3d vector pointing in that direction. &lt;br /&gt;
&lt;br /&gt;
Uses HPL2's &amp;quot;right-handed, x=left&amp;quot; coordinate system, so the forward direction is considered to be 0,0,1. Right is -1,0,0 and up is 0,1,0.&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyVector.SetDir3d(dirLeft);&lt;br /&gt;
// vMyVector becomes 1,0,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting values===&lt;br /&gt;
cVector provides the following method for retrieving values from the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetIndex(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves a component by index. E.g., the X component is at index 0, Y is index 1, etc.&lt;br /&gt;
#''uint aulIndex'' - The index whose value to get.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.GetIndex(2);&lt;br /&gt;
fMyFloat = vMyVector.Z;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Length===&lt;br /&gt;
cVector provides the following methods for working with vector length:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Length()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Length()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the euclidean length of the vector as a float. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vMyRectangle = cVector(10.0f, 15.0f);&lt;br /&gt;
float fMyHypotenuse = vMyRectangle.Length();&lt;br /&gt;
// fMyHypotenuse becomes the length of the diagonal line across a rectangle 10m by 15m.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LengthSqr()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float LengthSqr()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the squared length of the vector, which can be more efficient than calculating the actual length in some use cases, e.g. when you only need to compare two lengths without knowing the exact values. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool bIsVecALonger = vVecA.LengthSqr() &amp;gt; vVecB.LengthSqr();&lt;br /&gt;
// bIsVecALonger becomes true if vVecA is longer than vVecB, without calculating the final lengths.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normal()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector Normal()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Calculates the normal of this vector and returns it as a copy. This vector is not changed. The normal vector points in the same direction, but has a length of one.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection.Normal() * fSpeed;&lt;br /&gt;
// If vDirection is a vector of unknown length pointing in some direction, this would set vVelocity to be a vector pointing in the same direction, but with a length of exactly fSpeed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normalize()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Normalize()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Normalizes a vector in place. This vector becomes the normal vector, and the original values are forgotten. The normal vector points in the same direction, but has a length of one.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection;&lt;br /&gt;
vVelocity.Normalize(); // Length of vVelocity has now become 1.&lt;br /&gt;
vVelocity *= 3.0f;&lt;br /&gt;
// This example has the same result as the previous one, for Normal().&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Vector products===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DotProduct()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float DotProduct(cVector avB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Calculates the dot product of this and the given vector avB, and returns it as a float.&lt;br /&gt;
#''cVector avB'' - The other vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CrossProduct()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector CrossProduct(cVector avB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Caulculates the cross product of this and the given vector avB, and returns it as a new vector.&lt;br /&gt;
#''cVector avB'' - The other vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Strings from cVector===&lt;br /&gt;
cVector provides the following methods for converting vectors to strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 2, the format &amp;quot;(x=_, y=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 3, the format &amp;quot;(x=_, y=_, z=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 0, the string &amp;quot;empty cVector&amp;quot; is returned.&lt;br /&gt;
&amp;lt;br&amp;gt;For any other dimension, ToStringAsIndices() is called instead.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringAsIndices()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToStringAsIndices()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string, in the format &amp;quot;([0]=_, [1]=_, [2]=_ ...)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced===&lt;br /&gt;
The following methods exist for advanced users and should be used with caution:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Resize(uint aulNewDim)		// Changes the dimension of the vector.&lt;br /&gt;
bool Append(float afValue)		// Increases the dimension of this cVector by one, and adds the given float as a new component.&lt;br /&gt;
bool Append(cVector avValues)	// Increases the dimension of this cVector to accomodate the given cVector, and appends its components.&lt;br /&gt;
const float[]@ ReadArray()		// Returns a handle to the cVector's component array data.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cPoint=&lt;br /&gt;
The cPoint class defines a vector type that contains a series of int values, typically used to represent a location or movement on a grid, or pixels.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cPoints are declared similarly to a data type variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cPoint myPoint;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default constructor makes an empty 3d vector:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cPoint myPoint;						// Makes a 3d vector&lt;br /&gt;
cPoint myPoint = cPoint();			// Makes a 3d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
You can make an empty vector with a specific dimension (the number of components) by passing an integer to the constructor:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	cPoint myPoint = cPoint(3);		// Makes a 3d vector&lt;br /&gt;
&lt;br /&gt;
	cPoint myPoint = cPoint(2);		// Makes a 2d vector&lt;br /&gt;
	cPoint myPoint = cPoint(4);		// Makes a 4d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A vector can be initialised with any number dimension up to ulVectorDimMax (default 16).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
cPoint provides the following public properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====X====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property X provides access to the first component in the cPoint (provided it has at least one component).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.X;&lt;br /&gt;
vMyPoint.X = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Y====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Y&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property Y provides access to the second component in the cPoint (provided it has at least two components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.Y;&lt;br /&gt;
vMyPoint.Y = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Z====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Z&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property Z provides access to the third component in the cPoint (provided it has at least three components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.Z;&lt;br /&gt;
vMyPoint.Z = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====W====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int W&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property W provides access to the fourth component in the cPoint (provided it has at least four components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.W;&lt;br /&gt;
vMyPoint.W = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dimension====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Dimension&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Dimension returns the number of components in the cPoint. The dimension of the cPoint can be set by the constructor or, see also: Resize().&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (vMyPoint.Dimension &amp;gt;=3) vMyPoint.Z = 0;&lt;br /&gt;
// The condition succeeds if the cPoint has at least three components, and then the value of the 3rd component is assigned 0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the index of the last component in the cPoint. This is the same as Dimension - 1.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int fMyInt = vMyPoint[vMyPoint.LastIndex];&lt;br /&gt;
// The int fMyInt is assigned whatever value is found in the final component of the cPoint.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: the results of division operations with ints maybe truncated. That is, in integer calculations, 1 / 2 = 0.&lt;br /&gt;
&lt;br /&gt;
'''Arithmetic''' operators have been implemented for '''a cPoint with another cPoint''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  *  /  +=  -=  *=  /= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional '''arithmetic''' operators have been implemented for '''a cPoint with an int''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  *  /  +=  -=  *=  /= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''multiplication''' operator &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; used with a cPoint and an int, or a pair of cPoint, will scale the point component-wise.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''equality''' operator &amp;lt;code&amp;gt; == &amp;lt;/code&amp;gt; checks for an exact match between two cPoints. '''Comparison''' operators &amp;lt;code&amp;gt; &amp;gt; &amp;gt;= &amp;lt; &amp;lt;= &amp;lt;/code&amp;gt; compare the '''square length''' of the vectors.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''index''' operator &amp;lt;code&amp;gt; myVector[i] &amp;lt;/code&amp;gt; allows read-only access to the vector's components by index.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The '''assignment''' operator &amp;lt;code&amp;gt; = &amp;lt;/code&amp;gt; assigns a new value by duplicating the components. This may also '''resize''' the dimension of the vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting values===&lt;br /&gt;
cPoint provides the following methods for assigning values to the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetIndex(uint aulIndex, int alValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to a component by index. E.g., the X component is at index 0, Y is index 1, etc.. Returns false if index is outside of the dimension of the vector, or true if it was successfully set.&lt;br /&gt;
#''uint aulIndex'' - The index to set with a new value.&lt;br /&gt;
#''int alValue'' - The value to set at the index.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyPoint.SetIndex(1, 3);&lt;br /&gt;
vMyPoint.Y = 3;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir2d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir2d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cPoint into a 2d vector pointing in that direction.&lt;br /&gt;
&lt;br /&gt;
Uses typical screen coordinate directions, where up is -y, right is +x. If forward is given then that is considered to be right (+x).&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyPoint.SetDir2d(dirLeft);&lt;br /&gt;
// vMyPoint becomes -1,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir3d====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir3d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cPoint into a 3d vector pointing in that direction. &lt;br /&gt;
&lt;br /&gt;
Uses HPL2's &amp;quot;right-handed, x=left&amp;quot; coordinate system, so the forward direction is considered to be 0,0,1. Right is -1,0,0 and up is 0,1,0.&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyPoint.SetDir3d(dirLeft);&lt;br /&gt;
// vMyPoint becomes 1,0,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting values===&lt;br /&gt;
cPoint provides the following method for retrieving values from the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetIndex(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves a component by index. E.g., the X component is at index 0, Y is index 1, etc.&lt;br /&gt;
#''uint aulIndex'' - The index whose value to get.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.GetIndex(2);&lt;br /&gt;
fMyInt = vMyPoint.Z;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Length===&lt;br /&gt;
cPoint provides the following methods for working with vector length:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Length()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Length()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the euclidean length of the vector as a truncated int. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cPoint vMyRectangle = cPoint(10, 15);&lt;br /&gt;
int lMyHypotenuse = vMyRectangle.Length();&lt;br /&gt;
// lMyHypotenuse becomes the length of the diagonal line across a rectangle 10m by 15m.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LengthSqr()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int LengthSqr()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the squared length of the vector, which can be more efficient than calculating the actual length in some use cases, e.g. when you only need to compare two lengths without knowing the exact values. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool bIsVecALonger = vVecA.LengthSqr() &amp;gt; vVecB.LengthSqr();&lt;br /&gt;
// bIsVecALonger becomes true if vVecA is longer than vVecB, without calculating the final lengths.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normal()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cPoint Normal()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Calculates the truncated integer normal of this vector and returns it as a copy. This vector is not changed. The normal vector points in the same direction, but has a length of approximately one, while the components remain whole numbers.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection.Normal();&lt;br /&gt;
// If vDirection is a vector of unknown length pointing in some direction, this would set vVelocity to be a vector pointing in the same direction, but with a length of approximately one.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normalize()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Normalize()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Normalizes a vector in place. This vector becomes the normal vector, and the original values are forgotten. The normal vector points in the same direction, but has a length of approximately one.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection;&lt;br /&gt;
vVelocity.Normalize(); // Length of vVelocity has now become approximately one.&lt;br /&gt;
vVelocity *= 3.0f;&lt;br /&gt;
// This example has the same result as the previous one, for Normal().&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Strings from cPoint===&lt;br /&gt;
cPoint provides the following methods for converting vectors to strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 2, the format &amp;quot;(x=_, y=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 3, the format &amp;quot;(x=_, y=_, z=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 0, the string &amp;quot;empty cPoint&amp;quot; is returned.&lt;br /&gt;
&amp;lt;br&amp;gt;For any other dimension, ToStringAsIndices() is called instead.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringAsIndices()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToStringAsIndices()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string, in the format &amp;quot;([0]=_, [1]=_, [2]=_ ...)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced===&lt;br /&gt;
The following methods exist for advanced users and should be used with caution:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Resize(uint aulNewDim)		// Changes the dimension of the vector.&lt;br /&gt;
bool Append(float afValue)		// Increases the dimension of this cPoint by one, and adds the given float as a new component.&lt;br /&gt;
bool Append(cPoint avValues)	// Increases the dimension of this cPoint to accomodate the given cPoint, and appends its components.&lt;br /&gt;
const int[]@ ReadArray()		// Returns a handle to the cPoint's component data array.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cRotator=&lt;br /&gt;
The cRotator class defines a type that contains a series of float values, intended to represent an angular orientation, or a rotation. cRotator inherits from cVector, but also defines some properties and methods specific to working with rotation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
There are two ways to assign the pitch, yaw and roll values in the constructor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The angle values can be set directly in the constructor using degrees or radians. An optional enumAngleUnits is used to specify whether using degrees. The default is radians.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Initialising angles in degrees:&lt;br /&gt;
cRotator(pitchDegrees, yawDegrees, rollDegrees, angleDegrees)&lt;br /&gt;
&lt;br /&gt;
// Initialise the angles in radians&lt;br /&gt;
cRotator(pitchRadians, yawRadians, rollRadians)&lt;br /&gt;
cRotator(pitchRadians, yawRadians, rollRadians, angleRadians)&lt;br /&gt;
&lt;br /&gt;
// These two rotators are equivalent:&lt;br /&gt;
cRotator myDegrees = cRotator(90.0f, 180.0f, 45.0f, true);&lt;br /&gt;
cRotator myRadians = cRotator(Math.Pi, Math.Tau, Math.Pi / 2.0f);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The angle values can be set in the constructor using an enumOrthoDir option. enumOrthoDir can be dirForward, dirBackward, dirLeft, dirRight, dirUp, or dirDown.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cRotator yawRight = cRotator(dirRight);&lt;br /&gt;
cRotator pitchDown = cRotator(dirDown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The angle values can be set with the Pitch, Yaw and Roll properties:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
myRotator.Pitch = Math.Pi / 2.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The pitch, yaw and roll properties are treated as radians by default. To specify degrees or radians explicitly, the pitchDeg, yawDeg, rollDeg, and pitchRad, yawRad, rollRad properties can be used, e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
myRotator.YawDeg = 180;&lt;br /&gt;
myRotator.RollRad = Math.Pi * 3.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Internally the cRotator class stores angle values as radians between negative and positive Pi. (Equivalent to -180 degrees to 180 degrees.) Angles outside of this range are wrapped around. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cRotator rotation = cRotator(0.0f, 90.0f, 0.0f, true);&lt;br /&gt;
rotation += cRotator(0.0f, 120.0f, 0.0f, true);&lt;br /&gt;
// rotation is now (degrees) 0.0f, -150.0f, 0.0f&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, &amp;quot;rotation&amp;quot; is initialised with 90d yaw, and then rotated a further &lt;br /&gt;
120d clockwise. Rather than 210d clockwise, the resulting yaw is 150 anti-clockwise (-150);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pitch====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Pitch&lt;br /&gt;
float PitchRad&lt;br /&gt;
float PitchDeg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float properties Pitch and PitchRad provide access to the pitch component in radians. PitchDeg provides access to the pitch component in degrees.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyRotator.Pitch;&lt;br /&gt;
vMyRotator.PitchDeg = 90.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Yaw====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Yaw&lt;br /&gt;
float YawRad&lt;br /&gt;
float YawDeg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float properties Yaw and YawRad provide access to the pitch component in radians. YawDeg provides access to the pitch component in degrees.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyRotator.Yaw;&lt;br /&gt;
vMyRotator.YawDeg = 90.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Roll====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Roll&lt;br /&gt;
float RollRad&lt;br /&gt;
float RollDeg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float properties Roll and RollRad provide access to the pitch component in radians. RollDeg provides access to the pitch component in degrees.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyRotator.Roll;&lt;br /&gt;
vMyRotator.RollDeg = 90.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
In addition to methods inherited from cVector, cRotator provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
string ToStringRad()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as radians in a string with the format &amp;quot;(p=_, y=_, r=_)(rad)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringDeg()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToStringDeg()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as degrees in a string with the format &amp;quot;(p=_, y=_, r=_)(deg)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cBezier=&lt;br /&gt;
&lt;br /&gt;
The cBezier class defines a curved line in space, with a couple of basic functions. Technically it is a cubic bezier defined by 4 points: a start, an end, and two control points for influencing the curve. It can also roughly approximate a quadratic bezier if constructed with only one control point.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cBezier has four constructors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cBezier(cVector avStart, cVector avCtrl1, cVector avCtrl2, cVector avEnd)	// Creates a cubic bezier with two control points.&lt;br /&gt;
cBezier(cVector avStart, cVector avCtrl, cVector avEnd)						// Creates bezier approximating a quadratic bezier.&lt;br /&gt;
cBezier(cVector avStart, cVector avEnd)										// Creates a bezier that behaves like a straight line.&lt;br /&gt;
cBezier()																	// Creates a bezier that starts and ends at 0,0,0, with zero length.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Properties:==&lt;br /&gt;
To access the internal vector positions in the bezier, you can use the properties: Start, End, CtrlStart and CtrlEnd.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cBezier manualBezier;&lt;br /&gt;
cVector someLocation = cVector(10.0f, 11.0f, 12.0f);&lt;br /&gt;
manualBezier.Start = someLocation;&lt;br /&gt;
manualBezier.End = someLocation * 1.5f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Start====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector Start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property Start can be used to get or set the start point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====End====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector End&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property End can be used to get or set the end point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CtrlStart====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector CtrlStart&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property CtrlStart can be used to get or set the first control point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CtrlEnd====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector CtrlEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property CtrlEnd can be used to get or set the second control point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
cBezier provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetPoint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetPoint(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the curve from 0.0f to 1.0f, this returns the position at that point. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' - The time on the curve (0.0 - 1.0) to get the position of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.33f;&lt;br /&gt;
cVector vLocationOnCurve = vMyBezier.GetPoint(vProgressOnCurve);&lt;br /&gt;
// vLocationOnCurve becomes the position in space that is 33% of the journey along the curve.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetTangent()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetTangent(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the curve from 0.0f to 1.0f, this returns a normal vector that approximates the forward direction of the curve at that position. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' -  The time on the curve (0.0 - 1.0) to get the tangent of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.66f;&lt;br /&gt;
cVector vDirectionOnCurve = vMyBezier.GetTangent(vProgressOnCurve);&lt;br /&gt;
// vDirectionOnCurve becomes the forward direction of the curve at the point of 66% through the journey along it.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetApproxLength()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetApproxLength(enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Estimates the approximate length of the curve.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - Can be lengthFinal or lengthSquared. (Optional, default = lengthFinal)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the bezier as a string, including the x,y,z components of all four vector positions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cSpline=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The cSpline class defines an array of Beziers that can be treated like a continuous path made of multiple curved segments. Internally cSpline is a cBezier array of a fixed maximum size (default = 16). The cSpline can be initialised using existing beziers, or with a single curve defined by args in the constructor.&lt;br /&gt;
&lt;br /&gt;
For further control over how the curve is built, the cSpline can be declare as empty with segments added afterwards. Segments can be added to the spline either as whole cBezier segments using AddSegment(), or by adding one cVector point at a time using AddPoint().&lt;br /&gt;
&lt;br /&gt;
With the AddPoint() method, the spline is defined by providing the positions it should move through as individual points in space. Specific tangents can be provided (forward direction and scale) for each point, but are optional. When the final point is added, abLast should be specified as true to finish the spline and apply automatic tangents where needed. The automatic tangents make sure that path through each point is smooth, unless specific tangents were specified through AddPoint().&lt;br /&gt;
&lt;br /&gt;
Alternatively, with the AddSegment() method, the spline can be defined by providing each segment as a Bezier. The end of the previous segment will be updated to match the new one. (This is not quite the same as passing an array of Beziers to the constructor, as in that case the constructor will not attempt to match the end points, and they will not be smooth or even continuous unless defined that way by the script.)&lt;br /&gt;
&lt;br /&gt;
The spline does not have constant velocity. That is to say, each segment has an equal share of the &amp;quot;time&amp;quot;, regardless of the size of the segment, and within each segment the control points can cause acceleration. Easing can be effected by varying the size of the segments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cSpline has seven constructors in total, with various options for initialising a curve.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructing empty splines===&lt;br /&gt;
If the cSpline should start empty, ready for AddSegment() or AddPoint(), one of the following constructors should be used:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cSpline()							// Creates an empty spline with a maximum size of 16 bezier segments.&lt;br /&gt;
cSpline(uint aulSegments)			// Creates an empty spline with capacity for the number of bezier segments specified by aulSegments.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructing with cBezier===&lt;br /&gt;
If the cSpline should be populated with one or more existing bezier curves, one of the following constructors should be used:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cSpline(cBezier aSegmentsArray)		// Takes an existing cBezier array and uses that to populate the new spline.&lt;br /&gt;
cSpline(cBezier@ ahBezier)			// Uses a reference to an existing cBezier to populate the new spline with a single segment.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructing with cVector===&lt;br /&gt;
Finally, if the cSpline should be populated a curve or line defined by cVector arguments, one of these constructors will help:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cSpline(cVector avStart, cVector avCtrlStart, cVector avCtrlEnd, cVector avEnd)&lt;br /&gt;
// Takes four vector positions and builds a cubic bezier to populate the new spline with a single segment.&lt;br /&gt;
&lt;br /&gt;
cSpline(cVector avStart, cVector avCtrl, cVector avEnd)&lt;br /&gt;
// Takes three vector positions and builds a approximation of a quadratic bezier to populate the new spline with a single segment.&lt;br /&gt;
&lt;br /&gt;
cSpline(cVector avStart, cVector avEnd)&lt;br /&gt;
// Takes two vector positions and populate the new spline with a single segment in the form of a straight line between two points.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
cBezier provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddSegment()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool AddSegment(cBezier ahSegment, bool abSnap = true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Appends a bezier onto the spline as new segment. Returns false if the spline is already full, or true if it was successfully added.&lt;br /&gt;
&amp;lt;br&amp;gt;abSnap is optional. If omitted, it defaults to true. If abSnap is true then the end point and exit tangent of the previous segment will be adjusted to connect to the start point and entrance tangent of the new one.&lt;br /&gt;
#''cBezier ahSegment'' - A bezier to be appended to the spline.&lt;br /&gt;
#''bool abSnap'' - Whether to adjust the previous segment to connect to the new one. (Optional, default = true)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====UpdateSegment()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool UpdateSegment(uint aulIndex, cBezier ahSegment, bool abSnap = true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Updates an existing segment by index, replacing it with a new bezier. Returns false if the segment does not already exist, or true if it was successfully updated.&lt;br /&gt;
&amp;lt;br&amp;gt;abSnap is optional. If omitted, it defaults to true. If abSnap is true then the end point and exit tangent of the previous segment, and the start point and entrance tangent of the next segment will be adjusted to connect to the updated segment.&lt;br /&gt;
#''uint aulIndex'' - The index of the segment to be replaced.&lt;br /&gt;
#''cBezier ahSegment'' - A bezier to be replace the bezier at the given index. to the spline.&lt;br /&gt;
#''bool abSnap'' - Whether to adjust the previous and next segments to connect to the updated one. (Optional, default = true)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddPoint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool AddPoint(bool abLast = false, cVector avNextPosition, cVector avNextTangent)&lt;br /&gt;
bool AddPoint(bool abLast = false, cVector avNextPosition)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Appends a position to the end of the spline. Returns false if the spline is already full, or true if it was successfully added.&lt;br /&gt;
&amp;lt;br&amp;gt;avNextTangent is optional and can be omitted. It specifies the tangent as the velocity (direction and scale) of the spline at the new point. If omitted, no tangent is used at this time, but once you have finished adding points, abLast = true should be used and automatic tangents will be applied at that time.&lt;br /&gt;
&amp;lt;br&amp;gt;The automatic tangents are only applied to points where no tangent was given, and only once the spine is marked as &amp;quot;finished&amp;quot; by using abLast = true;&lt;br /&gt;
#''bool abLast'' - Whether this is the last point to be added. (Optional, default = false)&lt;br /&gt;
#''cVector avNextPosition'' - A position in space to add to the spline.&lt;br /&gt;
#''cVector avNextTangent'' - The forward velocity of the spline as it passes through the new position. (Optional, default = auto)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetPoint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetPoint(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the entire spline from 0.0f to 1.0f, this returns the position at that point. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' - The time on the curve (0.0 - 1.0) to get the position of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.33f;&lt;br /&gt;
cVector vLocationOnCurve = vMySpline.GetPoint(vProgressOnCurve);&lt;br /&gt;
// vLocationOnCurve becomes the position in space that is 33% of the journey along the spline.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetTangent()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetTangent(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the entire spline from 0.0f to 1.0f, this returns a normal vector that approximates the forward direction of the curve at that position. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' -  The time on the curve (0.0 - 1.0) to get the tangent of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.66f;&lt;br /&gt;
cVector vDirectionOnCurve = vMySpline.GetTangent(vProgressOnCurve);&lt;br /&gt;
// vDirectionOnCurve becomes the forward direction of the spline at the point of 66% through the journey along it.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetApproxLength()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetApproxLength(enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Estimates the approximate length of the entire spline.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - Can be lengthFinal or lengthSquared. (Optional, default = lengthFinal)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a string describing the spline, including the x,y,z components of its start and end points, and the number of segments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/String&amp;diff=6788</id>
		<title>HPL2/HPL2 Helper Scripts/String</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/String&amp;diff=6788"/>
		<updated>2024-02-11T02:16:02Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_String.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;
=Summary=&lt;br /&gt;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_String.hps&amp;quot; provides some extended maths functionality for modders. The new String class contains additional string functions, including replacement, sequence generation and more.&lt;br /&gt;
&lt;br /&gt;
Despite the name, this is not a string class itself, and does not contain text or replace the &amp;quot;string&amp;quot; type. String should be used similarly to Math, as a library of functions. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string welcomeText = &amp;quot;I bid you welcome to my cabinet of perturbation.&amp;quot;;&lt;br /&gt;
string cabinetType = &amp;quot;liquor&amp;quot;;&lt;br /&gt;
welcomeText = String.ReplaceAll(welcomeText, &amp;quot;perturbation&amp;quot;, cabinetType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;HelperScripts_String.hps&amp;quot; also defines the Str class. The Str class is intended to provide something like a template parameter, or a loosely typed variable, for string formatting.&lt;br /&gt;
&lt;br /&gt;
=String=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
&amp;quot;HelperScripts_String.hps&amp;quot; script declares an object called '''String''', of the new script class cString. To access its methods, just use &amp;quot;String.&amp;quot; followed by the function call. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
String.Replace(&amp;quot;catfish&amp;quot;, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
String has no public properties. &lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
===Length===&lt;br /&gt;
String provides the following methods for working with string sizes:&lt;br /&gt;
&lt;br /&gt;
====IsEmpty()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEmpty(string asString, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if the string is empty (&amp;quot;&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), only the length of the string will be considered. With any other trim option, whitespace and control characters will be not be counted. E.g. &amp;quot; &amp;quot; would count as empty if a trim option other than trimNone was used.&lt;br /&gt;
#''string asString'' - The string to check if empty.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd or trimAll. (Optional, default = trimNone)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool bA = String.IsEmpty(&amp;quot; &amp;quot;);&lt;br /&gt;
bool bB = String.IsEmpty(&amp;quot; &amp;quot;, trimAll);&lt;br /&gt;
// bA is assigned false. bB is assigned true, as the empty space is not counted.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Length()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Length(string asString, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the number of characters in the string.&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), only the length of the string will be considered. This is the same as asString.length(). With any other trim option, whitespace and control characters will be not be counted. E.g. &amp;quot; &amp;quot; would count as empty if a trim option other than trimNone was used.&lt;br /&gt;
#''string asString'' - The string to check the length of.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimNone)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
int lA = String.Length(&amp;quot; words words words   &amp;quot;);&lt;br /&gt;
int lB = String.Length(&amp;quot; words words words   &amp;quot;, trimEnd);&lt;br /&gt;
int lC = String.Length(&amp;quot; words words words   &amp;quot;, trimAll);&lt;br /&gt;
// lA becomes 21, lB becomes 18 and lC becomes 17.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
while (sSleepy.Length() &amp;lt; 20) sSleepy += &amp;quot;z&amp;quot;;&lt;br /&gt;
// The while loop continues until the string is at least 20 characters long.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Trim()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Trim(string &amp;amp;in asString, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Removes whitespace and control characters from the beginning and end of a string. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
&amp;lt;br&amp;gt; aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, the string will not be trimmed. With trimStart, whitespace and control characters will be removed from the start of the string. With trimEnd, whitespace and control characters will be removed from the end of the string. With trimAll (default), whitespace and control characters will be removed from both ends of the string.&lt;br /&gt;
#''string asString'' - The string to trim.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sSpooky = &amp;quot;  sppoooky  &amp;quot;;&lt;br /&gt;
sSpooky = String.Trim(aSpooky, trimStart);&lt;br /&gt;
// The initial spaces have been removed. sSpooky now equals &amp;quot;sppoooky  &amp;quot;.&lt;br /&gt;
sSpooky = String.Trim(aSpooky);&lt;br /&gt;
// Now the trailing spaces have been removed too. sSpooky now equals &amp;quot;spoooky&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parsing===&lt;br /&gt;
String provides the following methods for parsing strings:&lt;br /&gt;
&lt;br /&gt;
====ToInt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int ToInt(string asString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If possible, returns an integer converted from a string, else returns 0. This is the same as the normal global function StringToInt(), but is included here for consistency.&lt;br /&gt;
&lt;br /&gt;
====ToFloat()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float ToFloat(string asString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If possible, returns a float converted from a string, else returns 0.0f. This is the same as the normal global function StringToFloat(), but is included here for consistency.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToBool()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool ToBool(string asString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If possible, returns a boolean converted from a string, else returns false. This is the same as the normal global function StringToBool(), but is included here for consistency.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Characters===&lt;br /&gt;
String provides the following miscellaneous methods for working with character codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CharToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string CharToString(uint8 auiChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an ASCII character code, this returns a string containing that single character. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''uint8 auiChar'' - An ASCII character code to be converted to a string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sSymbols = String.CharToString(126) + String.CharToString(64) + String.CharToString(63);&lt;br /&gt;
// sSymbols now says &amp;quot;~@?&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StringToChar()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint8 StringToChar(string asSingleChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a single character string, this returns that character as an ASCII code. If the string is empty then 0 is returned (null character). If the string is longer than one character, the rest are ignored. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''string asSingleChar'' - A string containing a character to be converted to a character code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
uint8 uiCharacter = String.StringToChar(sSomeText);&lt;br /&gt;
if (uiCharacter &amp;gt;= 48 &amp;amp;&amp;amp; ul8Character &amp;lt;= 57) DoStuff();&lt;br /&gt;
// The condition succeeds if the first character of sSomeText is a numeric digit (ASCII codes 48-57).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CharArrayToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string CharArrayToString(uint8[] ausCharArray, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an array of ASCII codes, this returns those character joined into a string. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), any whitespace or control characters in the array will be included. With trimStart, any whitespace or control characters at the start of the array will be excluded. With trimEnd, any whitespace or control characters at the end of the array will be excluded. With trimAll, any whitespace or control characters at either end of the array will be excluded.&lt;br /&gt;
#''uint8[] ausCharArray'' - An array of ASCII character codes (unsigned 8bit ints), to be joined.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimNone)&lt;br /&gt;
See StringToCharArray() for an example.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StringToCharArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint8[] StringToCharArray(string asString, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string, this splits the string and returns it as an array of ASCII codes. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), any whitespace or control characters in the string will be included. With trimStart, any whitespace or control characters at the start of the string will be excluded. With trimEnd, any whitespace or control characters at the end of the string will be excluded. With trimAll, any whitespace or control characters at either end of the string will be excluded.&lt;br /&gt;
#''string asString'' - A string to be split.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimNone)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string Rot13(string asInput)&lt;br /&gt;
{&lt;br /&gt;
	uint8[] chars = String.StringToCharArray(asInput, trimAll);&lt;br /&gt;
	for (uint i = 0; i &amp;lt; chars.length(); i++)&lt;br /&gt;
	{&lt;br /&gt;
		if (chars[i] &amp;gt;= 65 &amp;amp;&amp;amp; chars[i] &amp;lt;= 90 || chars[i] &amp;gt;= 141 &amp;amp;&amp;amp; chars[i] &amp;lt;= 172)&lt;br /&gt;
		{&lt;br /&gt;
			chars[i] += 13;&lt;br /&gt;
			if (chars[i] &amp;gt; 90 &amp;amp;&amp;amp; chars[i] &amp;lt; 141 || chars[i] &amp;gt; 172) &lt;br /&gt;
			{&lt;br /&gt;
				chars[i] -= 26;&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return String.CharArrayToString(chars );&lt;br /&gt;
}&lt;br /&gt;
// This example is a whole Rot13 function. The string arg asInput is broken into an array of chars. Any char that is a upper or lower case alphabet letter is moved 13 characters. Then the char array is made back into a string and returned.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case===&lt;br /&gt;
String provides the following methods for changing the case of a string:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToUpper()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToUpper(string asString)&lt;br /&gt;
uint8 ToUpper(uint8 auiChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string or a character code, this returns the character(s) as upper case. If any character is a lower case letter, it will be swapped for upper case. Otherwise they are unchanged. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''string asString, uint8 auiChar'' - A string or a single character code to be changed to upper case.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sUpper = String.ToUpper(&amp;quot;Dark Descent&amp;quot;);&lt;br /&gt;
// sUpper is assigned &amp;quot;DARK DESCENT&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (String.ToUpper(sSomeTextA) == String.ToUpper(sSomeTextB))&lt;br /&gt;
// The condition succeeds if sSomeTextA and sSomeTextB are equal, regardless of their capitalisation.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToLower()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToLower(string asString)&lt;br /&gt;
uint8 ToLower(uint8 auiChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string or a character code, this returns the character(s) as lower case. If any character is a upper case letter, it will be swapped for lower case. Otherwise they are unchanged. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''string asString, uint8 auiChar'' - A string or a single character code to be changed to lower case.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sLower = String.ToLower(&amp;quot;Dark Descent&amp;quot;);&lt;br /&gt;
// sLower is assigned &amp;quot;dark descent&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Searching===&lt;br /&gt;
String provides the following methods for changing the case of a string:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Contains()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Contains(string asString, string asSubString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if asSubString can be found in asString. This is the same as the normal global function StringContains(), but is included in String for consistency.&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asSubString'' - The string to search for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (String.Contains(sCurrentObjective, &amp;quot;thalers&amp;quot;);&lt;br /&gt;
// The condition succeeds if the string sCurrentObjective contains the substring &amp;quot;thalers&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Find()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Find(string asString, string asSubString, enumStringCase aCaseOption = caseSensitive, enumStringDirection aDirOption = dirFromStart)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches for a substring within a string, and the returns the index of the first character of the first instance of the substring.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aDirOption can be omitted, or optionally can be either dirFromStart, or dirFromEnd. With dirFromStart (default), the string is searched from the left, and the index returned is the first instance. With dirFromEnd, the string is searched from the right, and the index returned is the last instance.&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asSubString'' - The string to search for.&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringDirection aDirOption'' - dirFromStart or dirFromEnd. (Optional, default = dirFromStart)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = String.Find(&amp;quot;Grunt&amp;quot;, &amp;quot;run&amp;quot;);&lt;br /&gt;
int lB = String.Find(&amp;quot;Agrippa&amp;quot;, &amp;quot;RIP&amp;quot;, caseInsensitive);&lt;br /&gt;
int lC = String.Find(&amp;quot;Herbert&amp;quot;, &amp;quot;er&amp;quot;);&lt;br /&gt;
int lD = String.Find(&amp;quot;Herbert&amp;quot;, &amp;quot;er&amp;quot;, dirFromEnd);&lt;br /&gt;
// lA is assigned 1. lB is assigned 2.&lt;br /&gt;
// lC is assigned 1, but searching from the end lD is assigned 4.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====NearlyEqual()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool NearlyEqual(string asA, string asB, uint aulErrors = 0, enumStringCase aCaseOption = caseInsensitive, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Compares two strings and returns true if they are the almost identical, with options for ignoring case and/or leading and trailing whitespace.&lt;br /&gt;
&amp;lt;br&amp;gt;The argument aulErrors defines how many characters are allowed to be different for the strings to considered &amp;quot;nearly equal&amp;quot;. If omitted, zero errors are allowed. Errors are counted 'after' any trimming takes place.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt; aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, the string will not be trimmed. With trimStart, whitespace and control characters will be removed from the start of the string. With trimEnd, whitespace and control characters will be removed from the end of the string. With trimAll (default), whitespace and control characters will be removed from both ends of the string.&lt;br /&gt;
#''string asA'' - The first string to compare.&lt;br /&gt;
#''string asB'' - The second string to compare.&lt;br /&gt;
#''uint aulErrors'' - How many characters are allowed to not match, after trimming. (Optional, default = 0)&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (asPasswordGuess == sPasswordAnswer) OpenDoor();&lt;br /&gt;
else if (String.NearlyEqual(asPasswordGuess, sPasswordAnswer, 1, caseInsensitive)) GiveHint();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Substrings===&lt;br /&gt;
String provides the following methods for working with parts of strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sub()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Sub(string asString, uint aulStart, uint aulCount)&lt;br /&gt;
string Sub(string asString, uint aulStart)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns part of a string. This is the same as the normal global function StringSub(), except that aulCount can be omitted. If aulCount is specified, the substring returned starts at aulStart and proceeds for aulCount characters. If aulCount is omitted then the substring starts at aulStart and proceeds to the end of the original string.&lt;br /&gt;
#''string asString'' - The string to get the substring from.&lt;br /&gt;
#''uint aulStart'' - The index of the character that is the start of the substring.&lt;br /&gt;
#''uint aulCount'' - The number of characters in the substring. (Optional, default = the remaining length of the string)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sA = String.Sub(&amp;quot;grunt&amp;quot;, 1, 3);&lt;br /&gt;
string sB = String.Sub(&amp;quot;grunt&amp;quot;, 1);&lt;br /&gt;
// sA is assigned &amp;quot;run&amp;quot;. sB is assigned &amp;quot;runt&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Replace()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Replace(string asString, string asFind, string asReplace, enumStringCase aCaseOption = caseSensitive, enumStringDirection aDirOption = dirFromStart)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches through a string and if it finds an instance of a given substring, it replaces it with another. Replace() replaces the first instance found. To replace all instances, consider ReplaceAll().&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt; aDirOption can be omitted, or optionally can be either dirFromStart, or dirFromEnd. With dirFromStart (default), the string is searched from the left, and the index returned is the first instance. With dirFromEnd, the string is searched from the right, and the index returned is the last instance.&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asFind'' - The string to search for.&lt;br /&gt;
#''asReplace'' - The string that will replace asFind if it is found.&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringDirection aDirOption'' - dirFromStart or dirFromEnd. (Optional, default = dirFromStart)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sMyStringA = &amp;quot;catfish catfood&amp;quot;;&lt;br /&gt;
string sMyStringB = String.Replace(sMyStringA, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;);&lt;br /&gt;
string sMyStringC = String.Replace(sMyStringA, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;, dirFromEnd);&lt;br /&gt;
// sMyStringB becomes &amp;quot;dogfish catfood&amp;quot;. sMyStringC becomes &amp;quot;catfish dogfood&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ReplaceAll()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ReplaceAll(string asString, string asFind, string asReplace, enumStringCase aCaseOption = caseSensitive)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches through a string and replaces all instances of a substring with another. To avoid an infinite loop, asReplace can't contain a match to asFind it would. Consider using Replace() instead.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asFind'' - The string to search for.&lt;br /&gt;
#''asReplace'' - The string that will replace asFind if it is found.&lt;br /&gt;
#''aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sMyStringA = &amp;quot;catfish catfood&amp;quot;;&lt;br /&gt;
string sMyStringB = String.ReplaceAll(sMyStringA, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;);&lt;br /&gt;
// sMyStringB becomes &amp;quot;dogfish dogfood&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Format()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Format(string asString, Str[] argArray)&lt;br /&gt;
string Format(string asString, Str arg0, Str arg1, ... Str arg7)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
A minimal version of the string formatting methods found in other languages. It doesn't provide number formating options, but it does allow an arbirtrary number of variables to be inserted into a string, regardless of data type, using the Str class. The Str class is just a container for a variable that can be turned into a string. In other languages we might use a template or a loosely typed variable. This is the method used by the cDebug class.&lt;br /&gt;
&amp;lt;br&amp;gt;Format() returns a string in which tokens like &amp;quot;{i}&amp;quot; have been replaced, where i is the index of the additional arguments, starting from zero. If an argument is supplied but the text doesn't contain a corresponding token, then the argument won't be included. If the text contains a token but not corresponding argument is supplied, then the token will remain in the output text.&lt;br /&gt;
&amp;lt;br&amp;gt;Up to eight individual Str arguments can be provides, or an array of Str. (Unfortunately, anonymous arrays as arguments are not supported, so the array must be declared.)&lt;br /&gt;
#''string asString'' - A template string containing tokens (&amp;quot;{i}&amp;quot;) to be replaced by the other arguments.&lt;br /&gt;
#''argArray or arg0'' - An array of Str instances, or a single Str instance, to replace tokens in the string.&lt;br /&gt;
#''arg1 - arg7'' - If not using an array, an additional 7 single Str arguments can be optionally given.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sNewString = String.Format(&amp;quot;I got {0} problems but this script ain't {1}.&amp;quot;, Str(99), Str(&amp;quot;one&amp;quot;));&lt;br /&gt;
// sNewString is assigned &amp;quot;I got 99 problems but this script ain't one.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
Str[] myArray = { Str(&amp;quot;Daniel&amp;quot;), Str(&amp;quot;London&amp;quot;), Str(&amp;quot;Mayfair&amp;quot;) };&lt;br /&gt;
string myOutput = String.Format(&amp;quot;My name is {0}, I live in {1} at... at... {2}...&amp;quot;, myArray);&lt;br /&gt;
// myOutput becomes &amp;quot;My name is Daniel, I live in London at... at... Mayfair...&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Arrays and lists===&lt;br /&gt;
String provides the following methods for splitting and joining collections of strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Join()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Join(string[] asStringArray, string asSeparator = &amp;quot;&amp;quot;, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
string Join(cListBase asGenericList, string asSeparator = &amp;quot;&amp;quot;, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a collection of strings, this returns them joined into a single string. The collection can be a string array (string[]), a list of strings (cListString), or any type other type of list. (The ToStringArray() method of the cListBase class is used, which in turn calls the ToString() method of each node. For most list classes this will return valid strings, but if the instanced list is itself cListBase or cListGeneric, empty strings will be returned.)&lt;br /&gt;
&amp;lt;br&amp;gt;Optionally, a separator string can be included, which will be inserted between each item. If omitted, asSeparator defaults to &amp;quot;&amp;quot; - i.e., no separator. Example uses could be &amp;quot; &amp;quot; or &amp;quot;_&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, the strings in the array will not be trimmed. With trimStart, whitespace will be removed from the start of the strings before they are joined. With trimEnd, whitespace will be removed from the end of the strings before they are joined. With trimAll (default), whiltespace will be removed from both ends of the strings before they are joined. Additionally any empty strings will be ignored unless trimNone is used.&lt;br /&gt;
#''string[] asStringArray, cListString asListString'' - An array of strings, a list of strings, or any other list type that can output strings, to be joined.&lt;br /&gt;
#''stromg asSeparator'' - A substring to insert between each joined string. (Optional, default = &amp;quot;&amp;quot;)&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
float[] fNumbers = { 2.33f, 3.44f, 4.55f, 5.66f };&lt;br /&gt;
string sNumberText = String.Join(fNumbers, &amp;quot; &amp;gt;&amp;gt; &amp;quot;);&lt;br /&gt;
// sNumberText will read &amp;quot;2.33 &amp;gt;&amp;gt; 3.44 &amp;gt;&amp;gt; 4.55 &amp;gt;&amp;gt; 5.66&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListString sJumble = String.Join(String.SplitToList(&amp;quot;The Inner Sanctum, my most precious chamber, Daniel.&amp;quot;).Shuffle(), &amp;quot; &amp;quot;);&lt;br /&gt;
// sJumble becomes the words of the string, in a random order. First the string is split into a list of strings, the list's Shuffle() method is called, and the result is passed to Join().&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SplitToList()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListString SplitToList(string asString, string asDelimiter = &amp;quot; &amp;quot;, enumStringCase aCaseOption = caseSensitive, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string and a substring to use as a delimiter, this returns the string split up into a list of substrings. If the delimiter is omitted then it defaults to &amp;quot; &amp;quot; - a single space, so the returned list contains the individual words in the string.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, strings in the resulting list will not be trimmed. With trimStart, whitespace will be removed from the start of the strings in the resulting list. With trimEnd, whitespace will be removed from the end of the strings in the resulting list. With trimAll (default), whiltespace will be removed from both ends of the strings in the resulting array. Additionally any empty strings will be ignored unless trimNone is used.&lt;br /&gt;
#''string asString'' - A string to be split into a list.&lt;br /&gt;
#''string asDelimiter'' - A substring to search for in asString, for the boundary of each split. (Optional, default = &amp;quot; &amp;quot;)&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myListA = String.SplitToList(&amp;quot;cat_dog_catfish_dogfish&amp;quot;, &amp;quot;_&amp;quot;);&lt;br /&gt;
cListString myListB = String.SplitToList(&amp;quot;cat_dog_catfish_dogfish&amp;quot;, &amp;quot;_Dog&amp;quot;);&lt;br /&gt;
cListString myListC = String.SplitToList(&amp;quot;cat_dog_catfish_dogfish&amp;quot;, &amp;quot;_Dog&amp;quot;, caseInsensitive);&lt;br /&gt;
// myListA is created with the items &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;, &amp;quot;catfish&amp;quot; and &amp;quot;dogfish&amp;quot;.&lt;br /&gt;
// myListB is created with the no items, as the delimiter is not found with the defaul caseSensitive option.&lt;br /&gt;
// myListC is created with the items &amp;quot;cat&amp;quot;, &amp;quot;_catfish&amp;quot; and &amp;quot;fish&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SplitToArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] SplitToArray(string asString, string asDelimiter = &amp;quot; &amp;quot;, enumStringCase aCaseOption = caseSensitive, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string and a substring to use as a delimiter, this returns the string split up into an array of substrings. If the delimiter is omitted then it defaults to &amp;quot; &amp;quot; - a single space, so the returned array contains the individual words in the string. Consider also: SplitToList().&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the delimiter must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, strings in the resulting array will not be trimmed. With trimStart, whitespace will be removed from the start of the strings in the resulting array. With trimEnd, whitespace will be removed from the end of the strings in the resulting array. With trimAll (default), whiltespace will be removed from both ends of the strings in the resulting array. Additionally any empty strings will be ignored unless trimNone is used.&lt;br /&gt;
&amp;lt;br&amp;gt;(The max length of the array is 256, but advanced users could edit that if needed.)&lt;br /&gt;
#''string asString'' - A string to be split into an array.&lt;br /&gt;
#''asDelimiter'' - A substring to search for in asString, for the boundary of each split. (Optional, default = &amp;quot; &amp;quot;)&lt;br /&gt;
#''aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
For an example, see SplitToList()&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Sequences===&lt;br /&gt;
String provides the following methods for working with numbered string sequences:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StringRange()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] StringRange(string asPrefix, uint alRangeFirst, uint alRangeLast, string asSuffix)&lt;br /&gt;
string[] StringRange(string asPrefix, string asRangeFirst, string asRangeLast, string asSuffix)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns an array of strings where each string in the array is made up of a prefix, followed by an iterator from given range, and then a suffix. The prefix and/or suffix can be &amp;quot;&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;Accepts the iterator range as either integers or characters, expressed as an inclusive min and inclusive max. Any integers or any ASCII characters could be used, as long as the min/first is less than the max/last.&lt;br /&gt;
#''string asPrefix'' - A string to add at the start of the output strings.&lt;br /&gt;
#''int alRangeFirst, string asRangeFirst'' - An integer or a single character string for the start of the iteration. (inclusive).&lt;br /&gt;
#''int alRangeLast, string asRangeLast'' - An integer or a single character string for the end of the interation (inclusive).&lt;br /&gt;
#''string asSuffix'' - A string to add at the end of the output strings.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string[] sDoorNames = String.StringRange(&amp;quot;door&amp;quot;, 2, 5);&lt;br /&gt;
for (uint i = 0; i &amp;lt; sDoorNames.length(); i++) SetSwingDoorLocked(sDoorNames, true, true);&lt;br /&gt;
// Creates an array of strings containing &amp;quot;door2&amp;quot;, &amp;quot;door3&amp;quot;, &amp;quot;door4&amp;quot; and &amp;quot;door5&amp;quot;, and passes each of them to SetSwingDoorLocked().&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string[] sStuffAndJunk = StringRange(&amp;quot;stuff_&amp;quot;, &amp;quot;A&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;_andJunk&amp;quot;);&lt;br /&gt;
// sStuffAndJunk is assigned with the strings &amp;quot;stuff_A_andJunk&amp;quot;, &amp;quot;stuff_B_andJunk&amp;quot; and &amp;quot;stuff_C_andJunk&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IntToStringFixedDigits()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string IntToStringFixedDigits(uint aulNumber, uint8 auiDigits, enumLimitType aLimitOption = limitClamped)&lt;br /&gt;
string IntToStringFixedDigits(int alNumber, uint8 auiDigits, enumLimitType aLimitOption = limitClamped)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a string representing an unsigned or positive int, with the specified number of characters, adding leading zeros if needed. aulNumber is the number to convert. auiDigits is the number of digits. E.g. 42 as 3 digits returns the string &amp;quot;042&amp;quot;. auiDigits is an unsigned 8-bit int (0-255), because the max uint is only 10 digits. (Hey, if you want to try any make a string that's 2^32 followed by 245 zeros, that's none of my business!)&lt;br /&gt;
&amp;lt;br&amp;gt;aLimitOption is optional and can be omitted, or it can be limitFree, limitClamped or limitWrapped. With limitFree, the number is not clamped, so auiDigits is a minimum. E.g. 1 as 2 digits returns &amp;quot;01&amp;quot; but 123 as 2 digits returns &amp;quot;123&amp;quot;. With limitClamped (default), the number will be clamped within the range of the digits. E.g. 123 as 2 digits returns &amp;quot;99&amp;quot;. With limitWrapped, the number will be modulated. E.g. 123 as 2 digits returns &amp;quot;23&amp;quot;.&lt;br /&gt;
#''uint aulNumber, int alNumber' - An unsigned integer to be respresented in the string. If the supplied int is signed and less than zero, it will be treated as zero.&lt;br /&gt;
#''uint8 auiDigits'' - The min number of digits to include in the string.&lt;br /&gt;
#''enumLimitType aLimitOption'' - Can be limitFree, limitClamped or limitWrapped. (Optional, default = limitClamped)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sNum = String.IntToStringFixedDigits(1188, 4, limitWrapped);&lt;br /&gt;
// sNum becomes &amp;quot;0088&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
for (uint i = 1; i &amp;lt;= 12; i++) SetSwingDoorLocked(&amp;quot;door_&amp;quot; + String.IntToStringFixedDigits(i, 3), true, true);&lt;br /&gt;
// This example imagines that the level has 12 doors named in the style &amp;quot;door_001&amp;quot;, &amp;quot;door_002&amp;quot;, ... &amp;quot;door_009&amp;quot;, &amp;quot;door_010&amp;quot;, &amp;quot;door_011&amp;quot;, &amp;quot;door_012&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Str class=&lt;br /&gt;
The Str class is used in the String.Format() and Debug.Message() methods.&lt;br /&gt;
&amp;lt;br&amp;gt;It's purpose is to provide something like a template parameter, or a loosely typed variable, for string formatting. The main goal is just to let modders pass values for string formatting without requiring hundreds of overloads. It's definitely clunkier in debug mode, but outside of debug mode it's more efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
The Str constructors can be passed a reference to a single string, int, uint, float, double, bool, cVector, cRotator, cPoint, cBezier, cSpline, or a list type.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Str(3)&lt;br /&gt;
Str(myInt)&lt;br /&gt;
Str(myVector)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
Str has no public properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
The only method is the ToString() function:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the stored variable as a string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Debug.Message(3, &amp;quot;Created new rotator {0} for puzzle #{1}.&amp;quot;, Str(myRotator), Str(myInt));&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
SetLevelDoorLockedText(&amp;quot;BigDoor&amp;quot;, &amp;quot;BigDoorMessages&amp;quot;, String.Format(&amp;quot;Door_Zone{0}_Type{1}&amp;quot;, Str(doorZone), Str(doorType)));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/String&amp;diff=6787</id>
		<title>HPL2/HPL2 Helper Scripts/String</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/String&amp;diff=6787"/>
		<updated>2024-02-11T02:14:22Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added NearlyEqual()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_String.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;
=Summary=&lt;br /&gt;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_String.hps&amp;quot; provides some extended maths functionality for modders. The new String class contains additional string functions, including replacement, sequence generation and more.&lt;br /&gt;
&lt;br /&gt;
Despite the name, this is not a string class itself, and does not contain text or replace the &amp;quot;string&amp;quot; type. String should be used similarly to Math, as a library of functions. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string welcomeText = &amp;quot;I bid you welcome to my cabinet of perturbation.&amp;quot;;&lt;br /&gt;
string cabinetType = &amp;quot;liquor&amp;quot;;&lt;br /&gt;
welcomeText = String.ReplaceAll(welcomeText, &amp;quot;perturbation&amp;quot;, cabinetType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;HelperScripts_String.hps&amp;quot; also defines the Str class. The Str class is intended to provide something like a template parameter, or a loosely typed variable, for string formatting.&lt;br /&gt;
&lt;br /&gt;
=String=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
&amp;quot;HelperScripts_String.hps&amp;quot; script declares an object called '''String''', of the new script class cString. To access its methods, just use &amp;quot;String.&amp;quot; followed by the function call. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
String.Replace(&amp;quot;catfish&amp;quot;, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
String has no public properties. &lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
===Length===&lt;br /&gt;
String provides the following methods for working with string sizes:&lt;br /&gt;
&lt;br /&gt;
====IsEmpty()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEmpty(string asString, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if the string is empty (&amp;quot;&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), only the length of the string will be considered. With any other trim option, whitespace and control characters will be not be counted. E.g. &amp;quot; &amp;quot; would count as empty if a trim option other than trimNone was used.&lt;br /&gt;
#''string asString'' - The string to check if empty.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd or trimAll. (Optional, default = trimNone)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool bA = String.IsEmpty(&amp;quot; &amp;quot;);&lt;br /&gt;
bool bB = String.IsEmpty(&amp;quot; &amp;quot;, trimAll);&lt;br /&gt;
// bA is assigned false. bB is assigned true, as the empty space is not counted.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Length()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Length(string asString, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the number of characters in the string.&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), only the length of the string will be considered. This is the same as asString.length(). With any other trim option, whitespace and control characters will be not be counted. E.g. &amp;quot; &amp;quot; would count as empty if a trim option other than trimNone was used.&lt;br /&gt;
#''string asString'' - The string to check the length of.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimNone)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
int lA = String.Length(&amp;quot; words words words   &amp;quot;);&lt;br /&gt;
int lB = String.Length(&amp;quot; words words words   &amp;quot;, trimEnd);&lt;br /&gt;
int lC = String.Length(&amp;quot; words words words   &amp;quot;, trimAll);&lt;br /&gt;
// lA becomes 21, lB becomes 18 and lC becomes 17.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
while (sSleepy.Length() &amp;lt; 20) sSleepy += &amp;quot;z&amp;quot;;&lt;br /&gt;
// The while loop continues until the string is at least 20 characters long.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====NearlyEqual()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool NearlyEqual(string asA, string asB, uint aulErrors = 0, enumStringCase aCaseOption = caseInsensitive, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Compares two strings and returns true if they are the almost identical, with options for ignoring case and/or leading and trailing whitespace.&lt;br /&gt;
&amp;lt;br&amp;gt;The argument aulErrors defines how many characters are allowed to be different for the strings to considered &amp;quot;nearly equal&amp;quot;. If omitted, zero errors are allowed. Errors are counted 'after' any trimming takes place.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt; aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, the string will not be trimmed. With trimStart, whitespace and control characters will be removed from the start of the string. With trimEnd, whitespace and control characters will be removed from the end of the string. With trimAll (default), whitespace and control characters will be removed from both ends of the string.&lt;br /&gt;
#''string asA'' - The first string to compare.&lt;br /&gt;
#''string asB'' - The second string to compare.&lt;br /&gt;
#''uint aulErrors'' - How many characters are allowed to not match, after trimming. (Optional, default = 0)&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (asPasswordGuess == sPasswordAnswer) OpenDoor();&lt;br /&gt;
else if (String.NearlyEqual(asPasswordGuess, sPasswordAnswer, 1, caseInsensitive)) GiveHint();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Trim()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Trim(string &amp;amp;in asString, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Removes whitespace and control characters from the beginning and end of a string. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
&amp;lt;br&amp;gt; aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, the string will not be trimmed. With trimStart, whitespace and control characters will be removed from the start of the string. With trimEnd, whitespace and control characters will be removed from the end of the string. With trimAll (default), whitespace and control characters will be removed from both ends of the string.&lt;br /&gt;
#''string asString'' - The string to trim.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sSpooky = &amp;quot;  sppoooky  &amp;quot;;&lt;br /&gt;
sSpooky = String.Trim(aSpooky, trimStart);&lt;br /&gt;
// The initial spaces have been removed. sSpooky now equals &amp;quot;sppoooky  &amp;quot;.&lt;br /&gt;
sSpooky = String.Trim(aSpooky);&lt;br /&gt;
// Now the trailing spaces have been removed too. sSpooky now equals &amp;quot;spoooky&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parsing===&lt;br /&gt;
String provides the following methods for parsing strings:&lt;br /&gt;
&lt;br /&gt;
====ToInt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int ToInt(string asString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If possible, returns an integer converted from a string, else returns 0. This is the same as the normal global function StringToInt(), but is included here for consistency.&lt;br /&gt;
&lt;br /&gt;
====ToFloat()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float ToFloat(string asString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If possible, returns a float converted from a string, else returns 0.0f. This is the same as the normal global function StringToFloat(), but is included here for consistency.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToBool()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool ToBool(string asString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If possible, returns a boolean converted from a string, else returns false. This is the same as the normal global function StringToBool(), but is included here for consistency.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Characters===&lt;br /&gt;
String provides the following miscellaneous methods for working with character codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CharToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string CharToString(uint8 auiChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an ASCII character code, this returns a string containing that single character. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''uint8 auiChar'' - An ASCII character code to be converted to a string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sSymbols = String.CharToString(126) + String.CharToString(64) + String.CharToString(63);&lt;br /&gt;
// sSymbols now says &amp;quot;~@?&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StringToChar()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint8 StringToChar(string asSingleChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a single character string, this returns that character as an ASCII code. If the string is empty then 0 is returned (null character). If the string is longer than one character, the rest are ignored. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''string asSingleChar'' - A string containing a character to be converted to a character code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
uint8 uiCharacter = String.StringToChar(sSomeText);&lt;br /&gt;
if (uiCharacter &amp;gt;= 48 &amp;amp;&amp;amp; ul8Character &amp;lt;= 57) DoStuff();&lt;br /&gt;
// The condition succeeds if the first character of sSomeText is a numeric digit (ASCII codes 48-57).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CharArrayToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string CharArrayToString(uint8[] ausCharArray, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an array of ASCII codes, this returns those character joined into a string. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), any whitespace or control characters in the array will be included. With trimStart, any whitespace or control characters at the start of the array will be excluded. With trimEnd, any whitespace or control characters at the end of the array will be excluded. With trimAll, any whitespace or control characters at either end of the array will be excluded.&lt;br /&gt;
#''uint8[] ausCharArray'' - An array of ASCII character codes (unsigned 8bit ints), to be joined.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimNone)&lt;br /&gt;
See StringToCharArray() for an example.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StringToCharArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint8[] StringToCharArray(string asString, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string, this splits the string and returns it as an array of ASCII codes. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), any whitespace or control characters in the string will be included. With trimStart, any whitespace or control characters at the start of the string will be excluded. With trimEnd, any whitespace or control characters at the end of the string will be excluded. With trimAll, any whitespace or control characters at either end of the string will be excluded.&lt;br /&gt;
#''string asString'' - A string to be split.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimNone)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string Rot13(string asInput)&lt;br /&gt;
{&lt;br /&gt;
	uint8[] chars = String.StringToCharArray(asInput, trimAll);&lt;br /&gt;
	for (uint i = 0; i &amp;lt; chars.length(); i++)&lt;br /&gt;
	{&lt;br /&gt;
		if (chars[i] &amp;gt;= 65 &amp;amp;&amp;amp; chars[i] &amp;lt;= 90 || chars[i] &amp;gt;= 141 &amp;amp;&amp;amp; chars[i] &amp;lt;= 172)&lt;br /&gt;
		{&lt;br /&gt;
			chars[i] += 13;&lt;br /&gt;
			if (chars[i] &amp;gt; 90 &amp;amp;&amp;amp; chars[i] &amp;lt; 141 || chars[i] &amp;gt; 172) &lt;br /&gt;
			{&lt;br /&gt;
				chars[i] -= 26;&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return String.CharArrayToString(chars );&lt;br /&gt;
}&lt;br /&gt;
// This example is a whole Rot13 function. The string arg asInput is broken into an array of chars. Any char that is a upper or lower case alphabet letter is moved 13 characters. Then the char array is made back into a string and returned.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case===&lt;br /&gt;
String provides the following methods for changing the case of a string:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToUpper()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToUpper(string asString)&lt;br /&gt;
uint8 ToUpper(uint8 auiChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string or a character code, this returns the character(s) as upper case. If any character is a lower case letter, it will be swapped for upper case. Otherwise they are unchanged. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''string asString, uint8 auiChar'' - A string or a single character code to be changed to upper case.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sUpper = String.ToUpper(&amp;quot;Dark Descent&amp;quot;);&lt;br /&gt;
// sUpper is assigned &amp;quot;DARK DESCENT&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (String.ToUpper(sSomeTextA) == String.ToUpper(sSomeTextB))&lt;br /&gt;
// The condition succeeds if sSomeTextA and sSomeTextB are equal, regardless of their capitalisation.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToLower()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToLower(string asString)&lt;br /&gt;
uint8 ToLower(uint8 auiChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string or a character code, this returns the character(s) as lower case. If any character is a upper case letter, it will be swapped for lower case. Otherwise they are unchanged. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''string asString, uint8 auiChar'' - A string or a single character code to be changed to lower case.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sLower = String.ToLower(&amp;quot;Dark Descent&amp;quot;);&lt;br /&gt;
// sLower is assigned &amp;quot;dark descent&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Searching===&lt;br /&gt;
String provides the following methods for changing the case of a string:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Contains()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Contains(string asString, string asSubString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if asSubString can be found in asString. This is the same as the normal global function StringContains(), but is included in String for consistency.&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asSubString'' - The string to search for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (String.Contains(sCurrentObjective, &amp;quot;thalers&amp;quot;);&lt;br /&gt;
// The condition succeeds if the string sCurrentObjective contains the substring &amp;quot;thalers&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Find()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Find(string asString, string asSubString, enumStringCase aCaseOption = caseSensitive, enumStringDirection aDirOption = dirFromStart)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches for a substring within a string, and the returns the index of the first character of the first instance of the substring.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aDirOption can be omitted, or optionally can be either dirFromStart, or dirFromEnd. With dirFromStart (default), the string is searched from the left, and the index returned is the first instance. With dirFromEnd, the string is searched from the right, and the index returned is the last instance.&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asSubString'' - The string to search for.&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringDirection aDirOption'' - dirFromStart or dirFromEnd. (Optional, default = dirFromStart)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = String.Find(&amp;quot;Grunt&amp;quot;, &amp;quot;run&amp;quot;);&lt;br /&gt;
int lB = String.Find(&amp;quot;Agrippa&amp;quot;, &amp;quot;RIP&amp;quot;, caseInsensitive);&lt;br /&gt;
int lC = String.Find(&amp;quot;Herbert&amp;quot;, &amp;quot;er&amp;quot;);&lt;br /&gt;
int lD = String.Find(&amp;quot;Herbert&amp;quot;, &amp;quot;er&amp;quot;, dirFromEnd);&lt;br /&gt;
// lA is assigned 1. lB is assigned 2.&lt;br /&gt;
// lC is assigned 1, but searching from the end lD is assigned 4.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Substrings===&lt;br /&gt;
String provides the following methods for working with parts of strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sub()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Sub(string asString, uint aulStart, uint aulCount)&lt;br /&gt;
string Sub(string asString, uint aulStart)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns part of a string. This is the same as the normal global function StringSub(), except that aulCount can be omitted. If aulCount is specified, the substring returned starts at aulStart and proceeds for aulCount characters. If aulCount is omitted then the substring starts at aulStart and proceeds to the end of the original string.&lt;br /&gt;
#''string asString'' - The string to get the substring from.&lt;br /&gt;
#''uint aulStart'' - The index of the character that is the start of the substring.&lt;br /&gt;
#''uint aulCount'' - The number of characters in the substring. (Optional, default = the remaining length of the string)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sA = String.Sub(&amp;quot;grunt&amp;quot;, 1, 3);&lt;br /&gt;
string sB = String.Sub(&amp;quot;grunt&amp;quot;, 1);&lt;br /&gt;
// sA is assigned &amp;quot;run&amp;quot;. sB is assigned &amp;quot;runt&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Replace()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Replace(string asString, string asFind, string asReplace, enumStringCase aCaseOption = caseSensitive, enumStringDirection aDirOption = dirFromStart)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches through a string and if it finds an instance of a given substring, it replaces it with another. Replace() replaces the first instance found. To replace all instances, consider ReplaceAll().&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt; aDirOption can be omitted, or optionally can be either dirFromStart, or dirFromEnd. With dirFromStart (default), the string is searched from the left, and the index returned is the first instance. With dirFromEnd, the string is searched from the right, and the index returned is the last instance.&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asFind'' - The string to search for.&lt;br /&gt;
#''asReplace'' - The string that will replace asFind if it is found.&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringDirection aDirOption'' - dirFromStart or dirFromEnd. (Optional, default = dirFromStart)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sMyStringA = &amp;quot;catfish catfood&amp;quot;;&lt;br /&gt;
string sMyStringB = String.Replace(sMyStringA, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;);&lt;br /&gt;
string sMyStringC = String.Replace(sMyStringA, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;, dirFromEnd);&lt;br /&gt;
// sMyStringB becomes &amp;quot;dogfish catfood&amp;quot;. sMyStringC becomes &amp;quot;catfish dogfood&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ReplaceAll()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ReplaceAll(string asString, string asFind, string asReplace, enumStringCase aCaseOption = caseSensitive)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches through a string and replaces all instances of a substring with another. To avoid an infinite loop, asReplace can't contain a match to asFind it would. Consider using Replace() instead.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asFind'' - The string to search for.&lt;br /&gt;
#''asReplace'' - The string that will replace asFind if it is found.&lt;br /&gt;
#''aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sMyStringA = &amp;quot;catfish catfood&amp;quot;;&lt;br /&gt;
string sMyStringB = String.ReplaceAll(sMyStringA, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;);&lt;br /&gt;
// sMyStringB becomes &amp;quot;dogfish dogfood&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Format()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Format(string asString, Str[] argArray)&lt;br /&gt;
string Format(string asString, Str arg0, Str arg1, ... Str arg7)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
A minimal version of the string formatting methods found in other languages. It doesn't provide number formating options, but it does allow an arbirtrary number of variables to be inserted into a string, regardless of data type, using the Str class. The Str class is just a container for a variable that can be turned into a string. In other languages we might use a template or a loosely typed variable. This is the method used by the cDebug class.&lt;br /&gt;
&amp;lt;br&amp;gt;Format() returns a string in which tokens like &amp;quot;{i}&amp;quot; have been replaced, where i is the index of the additional arguments, starting from zero. If an argument is supplied but the text doesn't contain a corresponding token, then the argument won't be included. If the text contains a token but not corresponding argument is supplied, then the token will remain in the output text.&lt;br /&gt;
&amp;lt;br&amp;gt;Up to eight individual Str arguments can be provides, or an array of Str. (Unfortunately, anonymous arrays as arguments are not supported, so the array must be declared.)&lt;br /&gt;
#''string asString'' - A template string containing tokens (&amp;quot;{i}&amp;quot;) to be replaced by the other arguments.&lt;br /&gt;
#''argArray or arg0'' - An array of Str instances, or a single Str instance, to replace tokens in the string.&lt;br /&gt;
#''arg1 - arg7'' - If not using an array, an additional 7 single Str arguments can be optionally given.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sNewString = String.Format(&amp;quot;I got {0} problems but this script ain't {1}.&amp;quot;, Str(99), Str(&amp;quot;one&amp;quot;));&lt;br /&gt;
// sNewString is assigned &amp;quot;I got 99 problems but this script ain't one.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
Str[] myArray = { Str(&amp;quot;Daniel&amp;quot;), Str(&amp;quot;London&amp;quot;), Str(&amp;quot;Mayfair&amp;quot;) };&lt;br /&gt;
string myOutput = String.Format(&amp;quot;My name is {0}, I live in {1} at... at... {2}...&amp;quot;, myArray);&lt;br /&gt;
// myOutput becomes &amp;quot;My name is Daniel, I live in London at... at... Mayfair...&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Arrays and lists===&lt;br /&gt;
String provides the following methods for splitting and joining collections of strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Join()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Join(string[] asStringArray, string asSeparator = &amp;quot;&amp;quot;, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
string Join(cListBase asGenericList, string asSeparator = &amp;quot;&amp;quot;, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a collection of strings, this returns them joined into a single string. The collection can be a string array (string[]), a list of strings (cListString), or any type other type of list. (The ToStringArray() method of the cListBase class is used, which in turn calls the ToString() method of each node. For most list classes this will return valid strings, but if the instanced list is itself cListBase or cListGeneric, empty strings will be returned.)&lt;br /&gt;
&amp;lt;br&amp;gt;Optionally, a separator string can be included, which will be inserted between each item. If omitted, asSeparator defaults to &amp;quot;&amp;quot; - i.e., no separator. Example uses could be &amp;quot; &amp;quot; or &amp;quot;_&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, the strings in the array will not be trimmed. With trimStart, whitespace will be removed from the start of the strings before they are joined. With trimEnd, whitespace will be removed from the end of the strings before they are joined. With trimAll (default), whiltespace will be removed from both ends of the strings before they are joined. Additionally any empty strings will be ignored unless trimNone is used.&lt;br /&gt;
#''string[] asStringArray, cListString asListString'' - An array of strings, a list of strings, or any other list type that can output strings, to be joined.&lt;br /&gt;
#''stromg asSeparator'' - A substring to insert between each joined string. (Optional, default = &amp;quot;&amp;quot;)&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
float[] fNumbers = { 2.33f, 3.44f, 4.55f, 5.66f };&lt;br /&gt;
string sNumberText = String.Join(fNumbers, &amp;quot; &amp;gt;&amp;gt; &amp;quot;);&lt;br /&gt;
// sNumberText will read &amp;quot;2.33 &amp;gt;&amp;gt; 3.44 &amp;gt;&amp;gt; 4.55 &amp;gt;&amp;gt; 5.66&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListString sJumble = String.Join(String.SplitToList(&amp;quot;The Inner Sanctum, my most precious chamber, Daniel.&amp;quot;).Shuffle(), &amp;quot; &amp;quot;);&lt;br /&gt;
// sJumble becomes the words of the string, in a random order. First the string is split into a list of strings, the list's Shuffle() method is called, and the result is passed to Join().&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SplitToList()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListString SplitToList(string asString, string asDelimiter = &amp;quot; &amp;quot;, enumStringCase aCaseOption = caseSensitive, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string and a substring to use as a delimiter, this returns the string split up into a list of substrings. If the delimiter is omitted then it defaults to &amp;quot; &amp;quot; - a single space, so the returned list contains the individual words in the string.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, strings in the resulting list will not be trimmed. With trimStart, whitespace will be removed from the start of the strings in the resulting list. With trimEnd, whitespace will be removed from the end of the strings in the resulting list. With trimAll (default), whiltespace will be removed from both ends of the strings in the resulting array. Additionally any empty strings will be ignored unless trimNone is used.&lt;br /&gt;
#''string asString'' - A string to be split into a list.&lt;br /&gt;
#''string asDelimiter'' - A substring to search for in asString, for the boundary of each split. (Optional, default = &amp;quot; &amp;quot;)&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myListA = String.SplitToList(&amp;quot;cat_dog_catfish_dogfish&amp;quot;, &amp;quot;_&amp;quot;);&lt;br /&gt;
cListString myListB = String.SplitToList(&amp;quot;cat_dog_catfish_dogfish&amp;quot;, &amp;quot;_Dog&amp;quot;);&lt;br /&gt;
cListString myListC = String.SplitToList(&amp;quot;cat_dog_catfish_dogfish&amp;quot;, &amp;quot;_Dog&amp;quot;, caseInsensitive);&lt;br /&gt;
// myListA is created with the items &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;, &amp;quot;catfish&amp;quot; and &amp;quot;dogfish&amp;quot;.&lt;br /&gt;
// myListB is created with the no items, as the delimiter is not found with the defaul caseSensitive option.&lt;br /&gt;
// myListC is created with the items &amp;quot;cat&amp;quot;, &amp;quot;_catfish&amp;quot; and &amp;quot;fish&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SplitToArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] SplitToArray(string asString, string asDelimiter = &amp;quot; &amp;quot;, enumStringCase aCaseOption = caseSensitive, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string and a substring to use as a delimiter, this returns the string split up into an array of substrings. If the delimiter is omitted then it defaults to &amp;quot; &amp;quot; - a single space, so the returned array contains the individual words in the string. Consider also: SplitToList().&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the delimiter must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, strings in the resulting array will not be trimmed. With trimStart, whitespace will be removed from the start of the strings in the resulting array. With trimEnd, whitespace will be removed from the end of the strings in the resulting array. With trimAll (default), whiltespace will be removed from both ends of the strings in the resulting array. Additionally any empty strings will be ignored unless trimNone is used.&lt;br /&gt;
&amp;lt;br&amp;gt;(The max length of the array is 256, but advanced users could edit that if needed.)&lt;br /&gt;
#''string asString'' - A string to be split into an array.&lt;br /&gt;
#''asDelimiter'' - A substring to search for in asString, for the boundary of each split. (Optional, default = &amp;quot; &amp;quot;)&lt;br /&gt;
#''aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
For an example, see SplitToList()&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Sequences===&lt;br /&gt;
String provides the following methods for working with numbered string sequences:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StringRange()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] StringRange(string asPrefix, uint alRangeFirst, uint alRangeLast, string asSuffix)&lt;br /&gt;
string[] StringRange(string asPrefix, string asRangeFirst, string asRangeLast, string asSuffix)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns an array of strings where each string in the array is made up of a prefix, followed by an iterator from given range, and then a suffix. The prefix and/or suffix can be &amp;quot;&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;Accepts the iterator range as either integers or characters, expressed as an inclusive min and inclusive max. Any integers or any ASCII characters could be used, as long as the min/first is less than the max/last.&lt;br /&gt;
#''string asPrefix'' - A string to add at the start of the output strings.&lt;br /&gt;
#''int alRangeFirst, string asRangeFirst'' - An integer or a single character string for the start of the iteration. (inclusive).&lt;br /&gt;
#''int alRangeLast, string asRangeLast'' - An integer or a single character string for the end of the interation (inclusive).&lt;br /&gt;
#''string asSuffix'' - A string to add at the end of the output strings.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string[] sDoorNames = String.StringRange(&amp;quot;door&amp;quot;, 2, 5);&lt;br /&gt;
for (uint i = 0; i &amp;lt; sDoorNames.length(); i++) SetSwingDoorLocked(sDoorNames, true, true);&lt;br /&gt;
// Creates an array of strings containing &amp;quot;door2&amp;quot;, &amp;quot;door3&amp;quot;, &amp;quot;door4&amp;quot; and &amp;quot;door5&amp;quot;, and passes each of them to SetSwingDoorLocked().&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string[] sStuffAndJunk = StringRange(&amp;quot;stuff_&amp;quot;, &amp;quot;A&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;_andJunk&amp;quot;);&lt;br /&gt;
// sStuffAndJunk is assigned with the strings &amp;quot;stuff_A_andJunk&amp;quot;, &amp;quot;stuff_B_andJunk&amp;quot; and &amp;quot;stuff_C_andJunk&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IntToStringFixedDigits()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string IntToStringFixedDigits(uint aulNumber, uint8 auiDigits, enumLimitType aLimitOption = limitClamped)&lt;br /&gt;
string IntToStringFixedDigits(int alNumber, uint8 auiDigits, enumLimitType aLimitOption = limitClamped)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a string representing an unsigned or positive int, with the specified number of characters, adding leading zeros if needed. aulNumber is the number to convert. auiDigits is the number of digits. E.g. 42 as 3 digits returns the string &amp;quot;042&amp;quot;. auiDigits is an unsigned 8-bit int (0-255), because the max uint is only 10 digits. (Hey, if you want to try any make a string that's 2^32 followed by 245 zeros, that's none of my business!)&lt;br /&gt;
&amp;lt;br&amp;gt;aLimitOption is optional and can be omitted, or it can be limitFree, limitClamped or limitWrapped. With limitFree, the number is not clamped, so auiDigits is a minimum. E.g. 1 as 2 digits returns &amp;quot;01&amp;quot; but 123 as 2 digits returns &amp;quot;123&amp;quot;. With limitClamped (default), the number will be clamped within the range of the digits. E.g. 123 as 2 digits returns &amp;quot;99&amp;quot;. With limitWrapped, the number will be modulated. E.g. 123 as 2 digits returns &amp;quot;23&amp;quot;.&lt;br /&gt;
#''uint aulNumber, int alNumber' - An unsigned integer to be respresented in the string. If the supplied int is signed and less than zero, it will be treated as zero.&lt;br /&gt;
#''uint8 auiDigits'' - The min number of digits to include in the string.&lt;br /&gt;
#''enumLimitType aLimitOption'' - Can be limitFree, limitClamped or limitWrapped. (Optional, default = limitClamped)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sNum = String.IntToStringFixedDigits(1188, 4, limitWrapped);&lt;br /&gt;
// sNum becomes &amp;quot;0088&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
for (uint i = 1; i &amp;lt;= 12; i++) SetSwingDoorLocked(&amp;quot;door_&amp;quot; + String.IntToStringFixedDigits(i, 3), true, true);&lt;br /&gt;
// This example imagines that the level has 12 doors named in the style &amp;quot;door_001&amp;quot;, &amp;quot;door_002&amp;quot;, ... &amp;quot;door_009&amp;quot;, &amp;quot;door_010&amp;quot;, &amp;quot;door_011&amp;quot;, &amp;quot;door_012&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Str class=&lt;br /&gt;
The Str class is used in the String.Format() and Debug.Message() methods.&lt;br /&gt;
&amp;lt;br&amp;gt;It's purpose is to provide something like a template parameter, or a loosely typed variable, for string formatting. The main goal is just to let modders pass values for string formatting without requiring hundreds of overloads. It's definitely clunkier in debug mode, but outside of debug mode it's more efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
The Str constructors can be passed a reference to a single string, int, uint, float, double, bool, cVector, cRotator, cPoint, cBezier, cSpline, or a list type.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Str(3)&lt;br /&gt;
Str(myInt)&lt;br /&gt;
Str(myVector)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
Str has no public properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
The only method is the ToString() function:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the stored variable as a string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Debug.Message(3, &amp;quot;Created new rotator {0} for puzzle #{1}.&amp;quot;, Str(myRotator), Str(myInt));&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
SetLevelDoorLockedText(&amp;quot;BigDoor&amp;quot;, &amp;quot;BigDoorMessages&amp;quot;, String.Format(&amp;quot;Door_Zone{0}_Type{1}&amp;quot;, Str(doorZone), Str(doorType)));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Math&amp;diff=6786</id>
		<title>HPL2/HPL2 Helper Scripts/Math</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Math&amp;diff=6786"/>
		<updated>2024-02-11T02:02:11Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added DistToEntity()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Math.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;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_Math.hps&amp;quot; provides some extended maths functionality for modders. The new Math class contains additional functions for a variety of purposes including interpolation, vectors, and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Math=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
&amp;quot;HelperScripts_Math.hps&amp;quot; script declares an object called '''Math''', of the new script class cDebug. To access its properties and methods, just use &amp;quot;Math.&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;
Math.Lerp(a, b, 0.75f);&lt;br /&gt;
x = Math.Pi;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
Math provides the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pi====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Pi&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only property Pi returns Pi as a float.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Examples:&lt;br /&gt;
float fRightAngleRadians = Math.Pi / 2.0f;&lt;br /&gt;
float fOneEightyDegrees = Math.RadiansToDegrees(Math.Pi);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Tau====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Tau&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only proerpty Tau returns Tau as a float. (Tau = 2*Pi)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Examples:&lt;br /&gt;
float fRightAngleRadians = Math.Tau / 4.0f;&lt;br /&gt;
float fThreeSixtyDegrees = Math.RadiansToDegrees(Math.Tau);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Arithmetic===&lt;br /&gt;
Math provides the following miscellaneous methods for working with numbers:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pow====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Pow(float afBase, float afExp)&lt;br /&gt;
int Pow(int alBase, uint aulExp)&lt;br /&gt;
uint Pow(uint aulBase, uint aulExp)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the base raised to the power the of exponent. This is the same as the normal global function MathPow(), except that it can also take an int or a uint.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Examples:&lt;br /&gt;
uint ulA = Math.Pow(9, 2);&lt;br /&gt;
float fB = Math.Pow(3.0f, 3.0f);&lt;br /&gt;
float fC = Math.Pow(3.0f, 1.0f/3.0f);&lt;br /&gt;
// ulA will become 81.&lt;br /&gt;
// fB will become 27. fC will become ~1.44225.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sqrt====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Sqrt(float afX)&lt;br /&gt;
int Sqrt(int alX)&lt;br /&gt;
uint Sqrt(uint aulX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the square root of the given number. This is the same as the normal global function MathSqrt(), except that it can also take an int or a uint, in which case the answer will be truncated.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Examples:&lt;br /&gt;
float fA = Math.Sqrt(2.0f);&lt;br /&gt;
int lB = Math.Sqrt(2);&lt;br /&gt;
// fA will become ~1.41421.&lt;br /&gt;
// lB will become 1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====NearlyEqual()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool NearlyEqual(float afA, float afB, float afT = 0.00001f)&lt;br /&gt;
bool NearlyEqual(double adA, double adB, double adT = 0.00001)&lt;br /&gt;
bool NearlyEqual(cVector avA, cVector avB, float afT = 0.00001f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if A and B are equal within a tolerance of T. If omitted, afT defaults to 0.00001.&lt;br /&gt;
&amp;lt;br&amp;gt;Accepts either float, double, or cVector. For vectors, avA and avB must have the same number of dimensions, and each pair of dimensions must be nearly equal,&lt;br /&gt;
#''float afA, double adA, or cVector avA'' - The first value to compare.&lt;br /&gt;
#''float afB, double adB, or cVector avB'' - The second value to compare.&lt;br /&gt;
#''float afT, double afT'' - A tolerance with which to compare the values. '''(Optional, default = 0.00001)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if(Math.NearlyEqual(afScore, fTarget, 0.1f))&lt;br /&gt;
// The condition succeeds if the score is near to the target by 0.1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SafeDivide()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float SafeDivide(float afA, float afB)&lt;br /&gt;
double SafeDivide(double adA, double adB)&lt;br /&gt;
int SafeDivide(int alA, int alB)&lt;br /&gt;
uint SafeDivide(uint aulA, uint aulB)&lt;br /&gt;
cVector SafeDivide(cVector avA, float afB)&lt;br /&gt;
cPoint SafeDivide(cPoint avA, float alB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Avoids divide by zero by checking for zeros first. If either value is zero, it just returns zero.&lt;br /&gt;
&amp;lt;br&amp;gt;Accepts a pair of numbers of the same type, or a vector and an appropriate number type.&lt;br /&gt;
#''float afA, double adA, int alA, uint aulA, cVector avA, or cPoint avA'' - The value to be divided.&lt;br /&gt;
#''float afB, double adB, int alB, or uint aulB'' - The value to be divided by.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int risky = 10 / Math.RandomInt(0, 3); // 1 in 3 chance of &amp;quot;divide by zero&amp;quot; error.&lt;br /&gt;
int safe = Math.SafeDivide(10, Math.RandomInt(0, 3)); // zero chance of &amp;quot;divide by zero&amp;quot; error.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DegreesToRadians()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float DegreesToRadians(float afD)&lt;br /&gt;
double DegreesToRadians(double adD)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Converts degrees to radians and returns the result. (360 degrees is equal to 2*Pi radians.)&lt;br /&gt;
#''float afD, double adD'' - An angle in degrees, to be converted to radians.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Math.DegreesToRadians(fDeg) == Math.Pi / 2.0f) DoStuff();&lt;br /&gt;
// The condition will succeed if fDeg is 90.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RadiansToDegrees()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float RadiansToDegrees(float afD)&lt;br /&gt;
double RadiansToDegrees(double adD)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Converts radians to degrees and returns the result. (360 degrees is equal to 2*Pi radians.)&lt;br /&gt;
#''float afD, double adD'' - An angle in radians, to be converted to degrees.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Math.DegreesToRadians(Math.Tau * fX) == 90) DoStuff();&lt;br /&gt;
// The condition will succeed if fX is 0.25f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsEven()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEven(int alX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if the given integer is an even number, or false if it is odd.&lt;br /&gt;
#''int alX'' - An int to check if even.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++)&lt;br /&gt;
{&lt;br /&gt;
	if (Math.IsEven(i)) DoStuff();&lt;br /&gt;
	else DoOtherStuff();&lt;br /&gt;
}&lt;br /&gt;
// A different function is called depending on whether the loop counter is odd or even.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
int x = Math.RandomInt();&lt;br /&gt;
bool bEvenA = Math.IsEven(x);&lt;br /&gt;
bool bEvenB = x % 2 == 0;&lt;br /&gt;
// bEvenA and bEvenB are equal.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sign()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Sign(int alX)&lt;br /&gt;
uint Sign(float aulX)&lt;br /&gt;
float Sign(uint afX)&lt;br /&gt;
double Sign(double adX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Identifies whether a given number is positive, negative or zero, and returns the answer as either 1, -1 or 0.&lt;br /&gt;
#''int alX, uint aulX, float afX, or double adX'' - The number who's sign will be checked.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
if (Math.Sign(fPrevious - fCurrent) == 1) sChange = &amp;quot;increased&amp;quot;;&lt;br /&gt;
else if (Math.Sign(fPrevious - fCurrent) == -1) sChange = &amp;quot;decreased&amp;quot;;&lt;br /&gt;
else sChange = &amp;quot;no change&amp;quot;;&lt;br /&gt;
// Assuming fCurrent and fPrevious represent some value that is changing over time, this sets a string to represent that change.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
int lRando = Math.RandomInt(-50, -25);&lt;br /&gt;
bool bRandoIsNeg = Math.Sign(lRando) == -1;&lt;br /&gt;
// There is a roughly 1/3 chance that bRandoIsNeg will be true.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Abs()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Abs(float afX)&lt;br /&gt;
double Abs(double adX)&lt;br /&gt;
int Abs(int alX)&lt;br /&gt;
uint Abs(uint aulX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the absolute value of the number, ignoring it's sign. This is the same as the global function MathAbs(), except that it also takes an int, uint or double.&lt;br /&gt;
#''float afX, double adX, int alX, uint aulX'' - A postive or negative value, to be returned as absolute.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = Math.Abs(10);&lt;br /&gt;
int lB = Math.Abs(-10);&lt;br /&gt;
// lA and lB both become 10.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Min()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Min(float afA, float afB)&lt;br /&gt;
double Min(double adA, double adB)&lt;br /&gt;
int Min(int alA, int alB)&lt;br /&gt;
uint Min(uint aulA, uint aulB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Compares two numbers and returns whichever one is the smaller value. This is the same as the global function MathMin(), except that it also takes an int, uint or double.&lt;br /&gt;
#''float afA, double adA, int alA, uint aulA'' - The first number to be compared.&lt;br /&gt;
#''float afB, double adB, int alB, uint aulB'' - The second number to be compared.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = Math.Min(10, lB);&lt;br /&gt;
// If lB is less than 10, lA will become equal to lB. Otherwise lA will become 10.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Max()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Max(float afA, float afB)&lt;br /&gt;
double Max(double adA, double adB)&lt;br /&gt;
int Max(int alA, int alB)&lt;br /&gt;
uint Max(uint aulA, uint aulB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Compares two numbers and returns whichever one is the larger value. This is the same as the global function MathMin(), except that it also takes an int, uint or double.&lt;br /&gt;
#''float afA, double adA, int alA, uint aulA'' - The first number to be compared.&lt;br /&gt;
#''float afB, double adB, int alB, uint aulB'' - The second number to be compared.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = Math.Max(10, lB);&lt;br /&gt;
// If lB is more than 10, lA will become equal to lB. Otherwise lA will become 10.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Clamp()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Clamp(float afX, float afMin, float afMax)&lt;br /&gt;
double Clamp(double adX, double adMin, double adMax)&lt;br /&gt;
int Clamp(int alX, int alMin, int alMax)&lt;br /&gt;
uint Clamp(uint aulX, uint aulMin, uint aulMax)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Limits a number to an allowed range. If the number is within the range then it is returned, otherwise the min or max is returned. This is the same as the global function MathClamp(), except that it also takes an int, uint or double.&lt;br /&gt;
#''float afX, double adX, int alX, uint aulX'' - The number to be compared.&lt;br /&gt;
#''float afMin, double adMin, int alMin, uint aulMin'' - The minimum of the allowed range.&lt;br /&gt;
#''float afMax, double adMax, int alMax, uint aulMax'' - The maximum of the allowed range.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = Math.Clamp(15, 10, 20);&lt;br /&gt;
float fB = Math.Clamp(25.0f, 10.0f, 20.0f);&lt;br /&gt;
// lA will be 15, but fB will be limited to 20.0f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Wrap()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Wrap(float afX, float afMin = 0.0f, float afMax = 1.0f);&lt;br /&gt;
double Wrap(double adX, double adMin = 0.0, double adMax = 1.0);&lt;br /&gt;
int Wrap(int alX, int alMin = 0, int alMax = 100);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a given number limited between a min and max using wrapping. Accepts float, double and int. Wrap() works similarly to Clamp(), except that if the given number is outside of the min and max, it will wrap back around using modulation.&lt;br /&gt;
&amp;lt;br&amp;gt;E.g. 2.75 wrapped between 1.0 and 2.0 will be 1.75.&lt;br /&gt;
&amp;lt;br&amp;gt;-1.25 wrapped between 0.0 and 1.0 will be 0.75.&lt;br /&gt;
#''float afX, double adX, or int alX'' - The number to be wrapped.&lt;br /&gt;
#''float afMin, double adMin, or int alMin'' - The inclusive lower boundary for wrapping. (Optional, float/double default = 0.0, int default = 0)&lt;br /&gt;
#''float afMax, double adMax, or int alMax'' - The exclusive upper boundary for wrapping. (Optional, float/double default = 1.0, int default = 100)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float fA = 2.75f;&lt;br /&gt;
float fB = -1.25f;&lt;br /&gt;
int lC = 125;&lt;br /&gt;
int lD = 100;&lt;br /&gt;
float fA_Wrapped = Math.Wrap(fA, 1.0, 2.0);&lt;br /&gt;
float fB_Wrapped = Math.Wrap(fB);&lt;br /&gt;
int lC_Wrapped = Math.Wrap(lC);&lt;br /&gt;
int lD_Wrapped = Math.Wrap(lD);&lt;br /&gt;
// The value of fA_Wrapped will be 1.75f.&lt;br /&gt;
// The value of fB_Wrapped will be 0.75f.&lt;br /&gt;
// The value of lC_Wrapped will be 25.&lt;br /&gt;
// The value of lD_Wrapped will be 0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Rounding===&lt;br /&gt;
Math provides the following methods for converting floats to ints:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Floor()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Floor(float afX)&lt;br /&gt;
int Floor(double adX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns an int converted from a float or a double, by rounding 'down'.&lt;br /&gt;
#''float afX, double adX'' - The number to be rounded and returned as an int.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = Math.Floor(0.1f);&lt;br /&gt;
int lB = Math.Floor(0.5f);&lt;br /&gt;
int lC = Math.Floor(0.9f);&lt;br /&gt;
int lD = Math.Floor(-1.1f);&lt;br /&gt;
int lE = Math.Floor(-1.5f);&lt;br /&gt;
int lF = Math.Floor(-1.9f);&lt;br /&gt;
// lA, lB and lC all become 0.&lt;br /&gt;
// lD, lE and lF all become -2.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Ceiling()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Ceiling(float afX)&lt;br /&gt;
int Ceiling(double adX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns an int converted from a float or a double, by rounding 'up'.&lt;br /&gt;
#''float afX, double adX'' - The number to be rounded and returned as an int.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = Math.Floor(0.1f);&lt;br /&gt;
int lB = Math.Floor(0.5f);&lt;br /&gt;
int lC = Math.Floor(0.9f);&lt;br /&gt;
int lD = Math.Floor(-1.1f);&lt;br /&gt;
int lE = Math.Floor(-1.5f);&lt;br /&gt;
int lF = Math.Floor(-1.9f);&lt;br /&gt;
// lA, lB and lC all become 1.&lt;br /&gt;
// lD, lE and lF all become -1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Round()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Round(float afX)&lt;br /&gt;
int Round(double adX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns an int converted from a float or a double, by rounding to the nearest whole number. When the float is on the midpoint (.5), Round() rounds 'away from zero'.&lt;br /&gt;
#''float afX, double adX'' - The number to be rounded and returned as an int.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = Math.Floor(0.1f);&lt;br /&gt;
int lB = Math.Floor(0.5f);&lt;br /&gt;
int lC = Math.Floor(0.9f);&lt;br /&gt;
int lD = Math.Floor(-1.1f);&lt;br /&gt;
int lE = Math.Floor(-1.5f);&lt;br /&gt;
int lF = Math.Floor(-1.9f);&lt;br /&gt;
// lA becomes 0. lB and lC both become 1.&lt;br /&gt;
// lD becomes -1. lE and lF both become -2.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RoundMidToEven()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int RoundMidToEven(float afX)&lt;br /&gt;
int RoundMidToEven(double adX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns an int converted from a float or a double, by rounding to the nearest whole number. When the float is on the midpoint (.5), RoundMidToEven() rounds 'towards the nearest even integer'.&lt;br /&gt;
#''float afX, double adX'' - The number to be rounded and returned as an int.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = Math.Floor(0.1f);&lt;br /&gt;
int lB = Math.Floor(0.5f);&lt;br /&gt;
int lC = Math.Floor(0.9f);&lt;br /&gt;
int lD = Math.Floor(-1.1f);&lt;br /&gt;
int lE = Math.Floor(-1.5f);&lt;br /&gt;
int lF = Math.Floor(-1.9f);&lt;br /&gt;
// lA and lB both become 0. lC becomes 1.&lt;br /&gt;
// lD becomes -1. lE and lF both become -2.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Truncate()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Truncate(float afX)&lt;br /&gt;
int Truncate(double adX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns an int converted from a float or a double, by 'discarding the fractional part', rounding towards zero even if the fraction is part the midpoint.&lt;br /&gt;
&amp;lt;br&amp;gt; This is effectively the same as using &amp;quot;int(fX)&amp;quot;.&lt;br /&gt;
#''float afX, double adX'' - The number to be rounded and returned as an int.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = Math.Floor(0.1f);&lt;br /&gt;
int lB = Math.Floor(0.5f);&lt;br /&gt;
int lC = Math.Floor(0.9f);&lt;br /&gt;
int lD = Math.Floor(-1.1f);&lt;br /&gt;
int lE = Math.Floor(-1.5f);&lt;br /&gt;
int lF = Math.Floor(-1.9f);&lt;br /&gt;
// lA, lB and lC all become 0.&lt;br /&gt;
// lD, lE and lF all become -1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Interpolation===&lt;br /&gt;
Math provides the following methods for interpolating between values:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Lerp()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Lerp(float afA, float afB, float afAlpha, enumLimitType aLimitOption = limitFree)&lt;br /&gt;
double Lerp(double adA, double adB, double adAlpha, enumLimitType aLimitOption = limitFree)&lt;br /&gt;
cVector Lerp(cVector avA, cVector avB, float afAlpha, enumLimitType aLimitOption = limitFree)&lt;br /&gt;
int Lerp(int alA, int alB, float afAlpha, enumLimitType aLimitOption = limitFree)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Linear interpolation: maps an alpha of 0.0-1.0, between values A and B.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;aLimitOption is optional and can be omitted, or it can be limitFree, limitClamped or limitWrapped.&lt;br /&gt;
&amp;lt;br&amp;gt;With limitFree (default) the alpha is not clamped.&lt;br /&gt;
&amp;lt;br&amp;gt;With limitClamped, the alpha value is limited to 0.0f-1.0f. E.g., -0.5f is the same as 0.0f, 3.0f is the same as 1.0f.&lt;br /&gt;
&amp;lt;br&amp;gt;With limitWrapped, the alpha values over 1 wrap around to zero. E.g., 1.5f is the same as 0.5f, -1.25f is the same as 0.75f.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;Accepts either float, double, or cVector. Can also work with two int values (and a float alpha), but note that the result will be truncated towards zero.&lt;br /&gt;
#''float afA, double adA, cVector avA, or int alA'' - The value corresponding to alpha 0.&lt;br /&gt;
#''float afB, double adB, cVector avB, or int alB'' - The value corresponding to alpha 1.&lt;br /&gt;
#''float afAlpha, double afAlpha'' - The alpha value of the interpolation.&lt;br /&gt;
#''enumLimitType aLimitOption'' - limitFree, limitClamped or limitWrapped '''(Optional, default = limitFree)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
float fA = 5.0f;&lt;br /&gt;
float fB = 10.0f;&lt;br /&gt;
float fC = Math.Lerp(fA, fB, 2.0f/3.0f);&lt;br /&gt;
// fC is 8 1/3, which is 2/3 of the way from 5 to 10.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
FadeGlobalSoundSpeed(Math.Lerp(0.5f, 1.0f, GetPlayerSanity() / 100.0f) 1.0f);&lt;br /&gt;
// As the player loses sanity, sounds get slower.&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
cVector vPlayerPos = Math.GetPlayerPosVec();&lt;br /&gt;
cVector vTargetPos = cVector(10.0f, 3.0f, 5.5f);&lt;br /&gt;
cVector vHalfwayToTarget = Math.Lerp(vPlayerPos, vTargetPos, 0.5f);&lt;br /&gt;
// vHalfwayToTarget is the midpoint between the player's location and the target location&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====WeightedAvg()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float WeightAvg(float afA, float afB, float afWeight = 0.5f)&lt;br /&gt;
double WeightAvg(double afA, double afB, double adWeight = 0.5)&lt;br /&gt;
cVector WeightAvg(cVector afA, cVector afB, float afWeight = 0.5f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Weighted average: returns a value interpolated between A and B, where weight defines how much &amp;quot;drag&amp;quot; there is. A common usage is to smooth out a number that is changing over time.&lt;br /&gt;
&amp;lt;br&amp;gt;The weight value can be thought of a how much A is &amp;quot;worth&amp;quot; compared to B (if B is &amp;quot;worth&amp;quot; 1.0). The lower the weight value, the closer to B the result will be. If weight is omitted it defaults to 0.5. Accepts pairs of float, double, or cVector.&lt;br /&gt;
#''float afA, double adA, or cVector avA'' - The current value of the interpolation.&lt;br /&gt;
#''float afB, double adB, or cVector avB'' - The target value of the interpolation.&lt;br /&gt;
#''float afWeight, double adWeight'' - The weight of the current value on the interpolation. '''(Optional, default = 0.5)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
float fA = 100.0f;&lt;br /&gt;
float fB = 200.0f;&lt;br /&gt;
float fC = Math.WeightAvg(fA, fB, 2.0f);&lt;br /&gt;
// fC is 133 1/3, which is 1/3 of the way from 100 to 200.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
vFollowPos = Math.Lerp(Math.GetPlayerPosVec(), vFollowPos, 0.25f);&lt;br /&gt;
// An item placed at vFollowPos every frame will smoothly follow the player.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SnappingWeightedAvg()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float SnappingWeightedAvg(float afA, float afB, float afWeight, float afSnapSize = 0.001f)&lt;br /&gt;
double SnappingWeightedAvg(double afA, double afB, double adWeight, double adSnapSize = 0.001)&lt;br /&gt;
cVector SnappingWeightedAvg(cVector afA, cVector afB, float afWeight, float afSnapSize = 0.001f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Same as weighted average, but the new value will snap to A or B if it is in range. This can help to reduce slowly trailing values that don't noticebly change. If it is omitted, asSnapSize defaults to 0.001.&lt;br /&gt;
#''float afA, double adA, or cVector avA'' - The current value of the interpolation.&lt;br /&gt;
#''float afB, double adB, or cVector avB'' - The target value of the interpolation.&lt;br /&gt;
#''float afWeight, double adWeight'' - The weight of the current value on the interpolation.&lt;br /&gt;
#''float afSnapSize, double adSnapSize'' - The tolerance for snapping to A or B. (Optional, default = 0.001)&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Vector math===&lt;br /&gt;
Math provides the following methods for mathematic operations on vectors:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Length()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Length(cVector aVector, enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
int Length(cPoint aVector, enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the length a vector, i.e. it's displacement from 0,0,0.&lt;br /&gt;
&amp;lt;br&amp;gt;You can also use a cPoint to get the length as an int, but note that the result will be truncated. E.g. cVector(1.0f, 3.0f) has a length equal to the square root of 10, but cPoint(1, 3) has a length of 3 exactly.&lt;br /&gt;
&amp;lt;br&amp;gt;aSquaredOption can be omitted, or optionally can be either lengthFinal, lengthSquared. With lengthFinal (default), the value returned is the actual length. With lengthSquared, the value returned is length^2. This is much cheaper to calculate and good enough for a lot of situations. E.g. if you want to know which vector is longer but the actual length doesn't matter.&lt;br /&gt;
&amp;lt;br&amp;gt;Note: you can also use the Length() method of the vector classes. (e.g. myVec.Length() )&lt;br /&gt;
#''cVector aVector, cPoint aPoint'' - The vector to calculate the length of.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - lengthFinal or lengthSquared '''(Optional, default = lengthFinal)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cVector vMyRectangle = cVector(10.0f, 15.0f);&lt;br /&gt;
float fMyHypotenuse = Math.Length(myRectangle);&lt;br /&gt;
// fMyHypotenuse becomes the length of the diagonal line across a rectangle 10m by 15m.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
bool bIsVecALonger = Math.Length(vVecA, lengthSquared) &amp;gt; Math.Length(vVecB, lengthSquared);&lt;br /&gt;
// bIsVecALonger becomes true if vVecA is longer than vVecB, without calculating the final lengths.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Distance()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Distance(cVector avA, cVector avB, enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the displacement between two vectors, e.g. the distance between two points in space.&lt;br /&gt;
&amp;lt;br&amp;gt;aSquaredOption can be omitted, or optionally can be either lengthFinal, lengthSquared. With lengthFinal (default), the value returned is the actual length. With lengthSquared, the value returned is length^2. This is much cheaper to calculate and good enough for a lot of situations. E.g. if you want to know which vector is longer but the actual length doesn't matter.&lt;br /&gt;
#''cVector avA'' - The start position of the distance.&lt;br /&gt;
#''cVector avB'' - The end position of the distance.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - lengthFinal or lengthSquared '''(Optional, default = lengthFinal)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vSomeplace = cVector(10.0f, 0.0f 15.0f);&lt;br /&gt;
cVector vSomeplaceElse = cVector(20.0f, 2.0f 25.0f);&lt;br /&gt;
float fDistance = Math.Distance(vSomeplace, vSomeplaceElse);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DistToPlayer()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float DistToPlayer(string asEntity, enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the distance from an entity to the player.&lt;br /&gt;
&amp;lt;br&amp;gt;aSquaredOption can be omitted, or optionally can be either lengthFinal, lengthSquared. With lengthFinal (default), the value returned is the actual length. With lengthSquared, the value returned is length^2. This is much cheaper to calculate and good enough for a lot of situations. E.g. if you want to know which vector is longer but the actual length doesn't matter.&lt;br /&gt;
#''string asEntity'' - The entity whose location to compare to the player.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - lengthFinal or lengthSquared '''(Optional, default = lengthFinal)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Math.DistToPlayer(&amp;quot;Orb&amp;quot;) &amp;lt; 12.0f) SetPlayerSanity(0.0f);&lt;br /&gt;
// When the player is less than 12m away from the orb, they lose all sanity points.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DistToEntity()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float DistToEntity(string asEntityA, string asEntityB, enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the distance between two named entities.&lt;br /&gt;
&amp;lt;br&amp;gt;aSquaredOption can be omitted, or optionally can be either lengthFinal, lengthSquared. With lengthFinal (default), the value returned is the actual length. With lengthSquared, the value returned is length^2. This is much cheaper to calculate and good enough for a lot of situations. E.g. if you want to know which vector is longer but the actual length doesn't matter.&lt;br /&gt;
#''string asEntityA'' - The first entity whose location will be compared.&lt;br /&gt;
#''string asEntityB'' - The second entity whose location will be compared.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - lengthFinal or lengthSquared '''(Optional, default = lengthFinal)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Math.DistToEntity(&amp;quot;OrbPieceA&amp;quot;, &amp;quot;OrbPieceB&amp;quot;) &amp;lt; 1.0f)&lt;br /&gt;
{&lt;br /&gt;
	cVector snapPos = Math.Lerp(Math.GetEntityPosVec(&amp;quot;OrbPieceA&amp;quot;), Math.GetEntityPosVec(&amp;quot;OrbPieceB&amp;quot;), 0.5f);&lt;br /&gt;
	Math.SetEntityPosVec(&amp;quot;OrbPieceA&amp;quot;, snapPos);&lt;br /&gt;
	Math.SetEntityPosVec(&amp;quot;OrbPieceB&amp;quot;, snapPos);&lt;br /&gt;
}&lt;br /&gt;
// When the two orb pieces are less than a metre apart, they snap together.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetRelative()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetRelative(cVector avPosition, cVector avOriginA, cVector avOriginB)&lt;br /&gt;
cPoint GetRelative(cPoint avPosition, cPoint avOriginA, cPoint avOriginB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a world position vector in relation to origin A, this will return a world position with the same displacement from origin B. See also: TeleportPlayerRelative() and TeleportEntityRelative().&lt;br /&gt;
#''cVector avPosition or cPoint avPosition'' - A vector defining a start position.&lt;br /&gt;
#''cVector avOriginA or cPoint avOriginA'' - A position in relation to the start position.&lt;br /&gt;
#''cVector avOriginB or cPoint avOriginB'' - A position in relation to the output position.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vMirrorWorldPlayerPos = Math.GetRelative(Math.GetPlayerPosVec(), vNormalWorldCentre, vMirrorWorldCentre) * cVector(1.0f, 1.0f, -1.0f);&lt;br /&gt;
// This convoluted example is something you might be interested in if you were trying to make a fake mirror, perhaps.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====TeleportPlayerRelative()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportPlayerRelative(string asAreaA, string asAreaB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Moves the player to a location relative to a named area B, whilst maintaining their position relative to area A.&lt;br /&gt;
#''string asAreaA'' - Name of an area (or other entity) in relation to the player's current position.&lt;br /&gt;
#''string asAreaB'' - Name of an area (or other entity) in relation to the player's new position.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Math.TeleportPlayerRelative(&amp;quot;Room1Area&amp;quot;, &amp;quot;Room2Area&amp;quot;);&lt;br /&gt;
// Assuming Room1Area and Room2Area are the same size/shape, if the player is inside Room1Area, they will teleport to the same position inside Room2Area.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====TeleportEntityRelative()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportPlayerRelative(string asEntity, string asAreaA, string asAreaB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Moves the named entity to a location relative to a named area B, whilst maintaining its position relative to area A.&lt;br /&gt;
#''string asEntity'' - Name of the entity to teleport.&lt;br /&gt;
#''string asAreaA'' - Name of an area (or other entity) in relation to the player's current position.&lt;br /&gt;
#''string asAreaB'' - Name of an area (or other entity) in relation to the player's new position.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Math.TeleportEntityRelative(&amp;quot;FatSackOfThalers&amp;quot;, &amp;quot;Room1Area&amp;quot;, &amp;quot;Room2Area&amp;quot;);&lt;br /&gt;
// Assuming Room1Area and Room2Area are the same size/shape, if FatSackOfThalers is inside Room1Area, it will teleport to the same position inside Room2Area.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normal()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector Normal(cVector avX)&lt;br /&gt;
cPoint Normal(cPoint avX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a normalized copy of a vector, without changing the original. (A normalized vector has the same direction, but with a length forced to 1.) Accepts a cVector or cPoint. Uses SafeDivide() to avoid ...impossible geometry!&lt;br /&gt;
#''cVector avX or cPoint avX'' - The vector to calculate the normal off.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = Math.Normal(vDirection) * fSpeed;&lt;br /&gt;
// If vDirection is a vector of unknown length pointing in some direction, this would set vVelocity to be a vector pointing in the same direction, but with a length of exactly fSpeed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normalize()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Normal(cVector avX)&lt;br /&gt;
void Normal(cPoint avX)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Normalizes the specified vector in place, replacing the original. (A normalized vector has the same direction, but with a length forced to 1.) Accepts a cVector or cPoint. Uses SafeDivide() to avoid ...impossible geometry!&lt;br /&gt;
#''cVector avX or cPoint avX'' - The vector to be replaced with its normal.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection;&lt;br /&gt;
Math.Normalize(vVelocity); // Length of vVelocity has now become 1.&lt;br /&gt;
vVelocity *= 3.0f;&lt;br /&gt;
// This example has the same result as the previous one, for Math.Normal().&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DotProduct()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float DotProduct(cVector avA, cVector avB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the dot product (a.k.a. inner product) of two vectors. The * operator between two vectors also returns the dot product.&lt;br /&gt;
#''cVector avA'' - The first vector to use in the dot product calculation.&lt;br /&gt;
#''cVector avB'' - The second vector to use in the dot product calculation.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float fDotMath = Math.DotProduct(vMyVecA, vMyVecB);&lt;br /&gt;
float fDotStar = vMyVecA * vMyVecB;&lt;br /&gt;
// fDotMath is equal to fDotStar&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CrossProduct3d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector CrossProduct3d(cVector avA, cVector avB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the cross product of two 3d vectors.&lt;br /&gt;
#''cVector avA'' - The first vector to use in the cross product calculation.&lt;br /&gt;
#''cVector avB'' - The second vector to use in the cross product calculation.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vMyVecC = Math.CrossProduct3d(vMyVecA, vMyVecB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ParallelVectors()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float ParallelVectors(cVector avA, cVector avB, bool abAbsolute = true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given two vectors or two 3d vectors, ParallelVectors will return a float indicating how parallel they are. If the returned float is 0 (or nearly 0), then the vectors are perpendicular (or nearly perpendicular). If the returned float is 1 (or nearly 1), then the vectors are parallel (or nearly parallel).&lt;br /&gt;
&amp;lt;br&amp;gt; abAbsolute is optional. If omitted, it defaults to true. If true, the return value will always be positive and indicates whether the vectors are parallel. If abAbsolute is false, the return value may be negative. A value of -1 would indicate that the vectors are&lt;br /&gt;
parallel, but pointing in the opposite direction.&lt;br /&gt;
#''cVector avA'' - First vector to compare.&lt;br /&gt;
#''cVector avB'' - Second vector to compare.&lt;br /&gt;
#''bool abAbsolute'' - If false, a negative return value indicates parallel-but-opposite. '''(Optional, default = true)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
float fRighthand = Math.ParallelVectors(cVector(0.0f, 0.0f, 1.0f), cVector(-1.0f, 0.0f, 0.0f));&lt;br /&gt;
float fBackDiagonal = Math.ParallelVectors(cVector(0.0f, 0.0f, 1.0f), cVector(0.5f, 0.0f, -1.0f), false);&lt;br /&gt;
// The value of fRighthand will be 0. The value of fBackDiagonal will be -0.894427.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
bfollowingPath =  ParallelVectors(vPlayerPosCurr - vPlayerPosPrev, vPathDir, false) &amp;gt; 0.75f;&lt;br /&gt;
// Assuming vPlayerPosCurr is the current position of the player, and vPlayerPosPrev is the previous position of the player, and vPathDir is some direction we want the player to move along, then the bool bFollowingPath becomes true if the player is moving roughly in the direction of the path.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsParallel()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsParallel(cVector avA, cVector avB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given two vectors, IsParallel() returns true if they are parallel, allowing for a small margin of error.&lt;br /&gt;
#''cVector avA'' - First vector to compare.&lt;br /&gt;
#''cVector avB'' - Second vector to compare.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
bool bPar = Math.IsParallel(cVector(1.0f, 0.0f, 0.0f), cVector(0.0f, 0.0f, 0.1f));&lt;br /&gt;
// The value of bPar will be false.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (Math.IsParallel(Math.GetEntityPosVec(&amp;quot;puzzlePieceA&amp;quot;) - Math.GetEntityPosVec(&amp;quot;puzzlePieceB&amp;quot;), Math.GetEntityPosVec(&amp;quot;puzzlePieceB&amp;quot;) - Math.GetEntityPosVec(&amp;quot;puzzlePieceC&amp;quot;))) PuzzleSolved();&lt;br /&gt;
// The condition succeeds when the three puzzle pieces have been placed in a line.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsPerpendicular()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsPerpendicular(cVector avA, cVector avB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given two vectors, IsPerpendicular() returns true if they are are perpendicular, allowing for a small margin of error.&lt;br /&gt;
#''cVector avA'' - First vector to compare.&lt;br /&gt;
#''cVector avB'' - Second vector to compare.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
bool bPar = Math.IsPerpendicular(cVector(1.0f, 0.0f, 0.0f), cVector(0.0f, 0.0f, 0.1f));&lt;br /&gt;
// The value of bPar will be true.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (Math.IsPerpendicular(Math.GetEntityPosVec(&amp;quot;puzzlePieceA&amp;quot;) - Math.GetEntityPosVec(&amp;quot;puzzlePieceB&amp;quot;), Math.GetEntityPosVec(&amp;quot;puzzlePieceB&amp;quot;) - Math.GetEntityPosVec(&amp;quot;puzzlePieceC&amp;quot;))) PuzzleSolved();&lt;br /&gt;
// The condition succeeds when the three puzzle pieces have been placed in a right-angled triangle.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RotateVector2d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector RotateVector2d(cVector avA, float afB, enumAngleUnits aUnits = angleDegrees)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a 2d vector and an angle, this rotates the vector by the specified amount and returns the new rotated 2d vector. A positive angle is a clockwise rotation, negative is anticlockwise.&lt;br /&gt;
&amp;lt;br&amp;gt;aUnits can be omitted, or optionally it can be angleDegrees or angleRadians. With angleDegrees (default), the given angle afB is taken as degrees. With angleRadians, the given angle afB is taken as radians.&lt;br /&gt;
#''cVector avA'' - The vector to be rotated.&lt;br /&gt;
#''float afB'' - The angle to rotate by.&lt;br /&gt;
#''enumAngleUnits aUnits'' - angleDegrees or angleRadians. '''(Optional, default = angleDegrees)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cVector vVecA = cVector(1.0f, 0.0f);&lt;br /&gt;
cVector vVecB = cVector(0.0f, 1.0f);&lt;br /&gt;
cVector vVecC = Math.RotateVector2d(vVecA, 90.0f);&lt;br /&gt;
// vVecB and vVecC are equal.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cVector vDirOnPlane = Math.RotateVector2d(cVector(-1.0f, 0.0f), Math.Pi * Math.RandomFloat(-0.125f, 0.125f));&lt;br /&gt;
// vDirOnPlane becomes a random 2d vector pointing roughly rightwards.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AngleToVector2d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector AngleToVector2d(float afA, enumAngleUnits aUnits = angleDegrees)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Converts an angle on a 2d plane to a 2d forward vector, using either degrees or radians.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that 0d rotation is pointing upward, and in the returned vector the origin is in the top-left: 0 degrees = 12 o'clock = (0, -1); 90 degrees = 3 o'clock = (1, 0)&lt;br /&gt;
&amp;lt;br&amp;gt;aUnits can be omitted, or optionally it can be angleDegrees or angleRadians. With angleDegrees (default), the given angle afB is taken as degrees. With angleRadians, the given angle afB is taken as radians.&lt;br /&gt;
#''float afR, float afD'' - The angle to convert to a 2d vector.&lt;br /&gt;
#''enumAngleUnits aUnits'' - angleDegrees or angleRadians. '''(Optional, default = angleDegrees)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vVecA = Math.AngleToVector2d(90.0f);&lt;br /&gt;
cVector vVecB = Math.AngleToVector2d(180.0f);&lt;br /&gt;
cVector vVecC = Math.RotateVector2d(vVecA, 90.0f);&lt;br /&gt;
// vVecB and vVecC are equal.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Vector2dToAngle()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Vector2dToAngle(cVector avA, enumAngleUnits aUnits = angleDegrees)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Converts a 2d forward vector to an angle on the 2d plane, using either degrees or radians.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that 0d rotation is pointing upward, and in the returned vector the origin is in the top-left: 0 degrees = 12 o'clock = (0, -1); 90 degrees = 3 o'clock = (1, 0)&lt;br /&gt;
&amp;lt;br&amp;gt;aUnits can be omitted, or optionally it can be angleDegrees or angleRadians. With angleDegrees (default), the given angle afB is taken as degrees. With angleRadians, the given angle afB is taken as radians.&lt;br /&gt;
#''cVector avA'' - A 2d vector to convert to an angle.&lt;br /&gt;
#''enumAngleUnits aUnits'' - angleDegrees or angleRadians. '''(Optional, default = angleDegrees)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float fRad = Math.Vector2dToAngle(cVector(3.0f, 1.5f));&lt;br /&gt;
// fRad is equal to 3/8*Pi.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RotateVector3d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector RotateVector3d(cVector avA, cRotator arB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a 3d vector and a pitch-yaw-roll rotator, this rotates the vector by the specified amount, and returns the new rotated vector.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that HPL2 uses a &amp;quot;right-handed, x=left&amp;quot; coordinate system, so the forward direction is considered to be 0,0,1.&lt;br /&gt;
#''cVector avA'' - The vector to be rotated.&lt;br /&gt;
#''cRotator arB'' - The rotator containing the pitch, yaw and roll angles.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cVector vForward = cVector(0.0f, 0.0f 1.0f);&lt;br /&gt;
cRotator vPitchDown = cRotator(5.0f, 0.0f, 5.0f, angleDegrees);&lt;br /&gt;
vForward = Math.RotateVector3d(vForward, vPitchDown);&lt;br /&gt;
// vForward has been tilted slightly downwards and leaned slightly rightwards.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cVector vForward = cVector(0.0f, 0.0f 1.0f);&lt;br /&gt;
cRotator vBarrelRoll = cRotator(0.0f, 0.0f, 180.0f, angleDegrees);&lt;br /&gt;
vForward = Math.RotateVector3d(vForward, vBarrelRoll);&lt;br /&gt;
// vForward hasn't changed. Roll on it's own does nothing to a vector, since a vector has no sense of &amp;quot;orientation&amp;quot;, only &amp;quot;forward&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RotatorToVector3d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector RotatorToVector3d(cRotator arRot, enumOrthoDir aDirectionOption = dirForward)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Converts a rotator with pitch, yaw and roll angles into a 3d directional vector. This is basically the same as RotateVector3d() but perhaps more convenient.&lt;br /&gt;
&amp;lt;br&amp;gt;aDirectionOption is optional and specifies an orthogonal world vector to use. It can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown. If omitted it defaults to dirForward.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that HPL2 uses a &amp;quot;right-handed, x=left&amp;quot; coordinate system, so the forward direction is considered to be 0,0,1. If an entity was facing 0,0,1 before rotation, then RotatorToVector3d() with dirForward would return it's facing direction after rotation.&lt;br /&gt;
#''cRotator arRot'' - Rotator containing pitch, yaw, roll values to convert to a vector.&lt;br /&gt;
#''enumOrthoDir aDirectionOption'' - Which orthoginal world vector to rotate. '''(Optional, default = dirForward)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cRotator vPitchUp = cRotator(-0.25f * Math.Pi, 0.0f, 0.0f, angleRadians);&lt;br /&gt;
cVector vForwardUp = Math.RotatorToVector3d(vPitchDown);&lt;br /&gt;
cVector vRightUp = Math.RotatorToVector3d(vPitchDown, dirRight);&lt;br /&gt;
// vForwardUp points forward, tilted up by 45 degrees. vRightUp points rightward, tilted up by 45 degrees.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Vector3dToRotator()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cRotator Vector3dToRotator(cVector avForward)&lt;br /&gt;
cRotator Vector3dToRotator(cVector avForward, cVector avUp)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Converts a 3d directional vector to pitch, yaw and roll, and returns the result as a rotator.&lt;br /&gt;
&amp;lt;br&amp;gt;If only one vector is given then it represents the forward direction, and the returned rotator will have a yaw and pitch rotated to that forward direction. The roll will be zero.&lt;br /&gt;
&amp;lt;br&amp;gt;An optional second vector can be provided in order to calculate roll. If the second vector is given then the first represents the forward direction and the second represents the upward direction. The returned rotator will include a roll angle calculated using the upward direction.&lt;br /&gt;
#''cVector avForward'' - The forward directional vector to be converted to a rotator.&lt;br /&gt;
#''cVector avUp'' - Optional upward directional vector used to calculate roll. '''(Optional, default = no roll)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cRotator vMyRot = Math.Vector3dToRotator(cVector(-1.0f, 0.0f, -1.0f));&lt;br /&gt;
if (vMyRot.YawDeg &amp;gt; 90.0f) DoStuff();&lt;br /&gt;
// The condition succeeds because vMyRot becomes a yaw rotation of 135 degrees clockwise.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Vector replacements===&lt;br /&gt;
The following math methods are intended to replace some of the normal global functions that use separate X, Y and Z floats:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetPlayerPosVec()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetPlayerPosVec()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the player's location as a 3d cVector, instead of [[HPL2/Engine_Scripts#Player|GetPlayerPosX/Y/Z()]], which only return a single float.)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vPlayerCurrPos = Math.GetPlayerPosVec();&lt;br /&gt;
// Stores the player's current location in a cVector.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetPlayerPosVec()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerPosVec(cVector avPos)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Moves the player to a location given as a 3d cVector, instead of [[HPL2/Engine_Scripts#Player|SetPlayerPos()]], which takes separate 3 floats.&lt;br /&gt;
#''cVector avPos'' - The new location for the player.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vOrigin;&lt;br /&gt;
Math.SetPlayerPosVec(vOrigin);&lt;br /&gt;
// Teleports the player to the world origin.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====MovePlayerHeadPosVec()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void MovePlayerHeadPosVec(cVector avPos, float afSpeed, float afSlowDownDist)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Changes the position of the camera on the player's body, using a 3d cVector, instead of [[HPL2/Engine_Scripts#Player|MovePlayerHeadPos()]], which takes separate 3 floats.&lt;br /&gt;
#''cVector avPos'' - The new location for the player's head.&lt;br /&gt;
#''float afSpeed - The speed at which the change happens.&lt;br /&gt;
#''float afSlowDownDist - The distance at which to start slowing down (prevents the head from abruptly stopping).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Math.MovePlayerHeadPosVec(my3dVector, 1.5f, 0.1f);&lt;br /&gt;
// Moves the player camera to whatever offset is assigned to my3dVector.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetEntityPosVec()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetEntityPosVec(string asEntity)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the named entity's location as a 3d cVector, instead of [[HPL2/Engine_Scripts#Entities|GetEntityPosX/Y/Z()]], which only return a single float.&lt;br /&gt;
#''string asEntity'' - The entity to be moved.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vHammerCurrPos = Math.GetEntityPosVec(&amp;quot;hammer&amp;quot;);&lt;br /&gt;
// Stores the hammer's current location in a cVector.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetEntityPosVec()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPosVec(string asEntity, cVector avPos)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Moves the named entity to a location given as a 3d cVector, instead of [[HPL2/Engine_Scripts#Entities|SetEntityPos()]], which takes separate 3 floats.&lt;br /&gt;
#''string asEntity'' - The entity to be moved.&lt;br /&gt;
#''cVector avPos'' - The new location for the entity.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Math.SetEntityPosVec(&amp;quot;anvil&amp;quot;, Math.GetPlayerPosVec() + cVector(0.0f, 3.0f, 0.0f));&lt;br /&gt;
// Teleports the entity &amp;quot;anvil&amp;quot; to 3m above the player.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddPropForceVec etc====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddPropForceVec(string asName, cVector avForce, string asCoordSystem = &amp;quot;world&amp;quot;)&lt;br /&gt;
void AddPropImpulseVec(string asName, cVector avImpulse, string asCoordSystem = &amp;quot;world&amp;quot;)&lt;br /&gt;
void AddBodyForceVec(string asName, cVector avForce, string asCoordSystem = &amp;quot;world&amp;quot;)&lt;br /&gt;
void AddBodyImpulseVec(string asName, cVector avImpulse, string asCoordSystem = &amp;quot;world&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
These functions are provided as a way to use the global functions [[HPL2/Engine_Scripts#Props|AddPropForce() etc.]], with a vector specifying the force or impulse, rather than floats. Could be useful if you want to use it with e.g. RandomVector3d(). See the documentation for the original functions for more information. The asCoordSystem string argument is optional in these versions.&lt;br /&gt;
#''string asName'' - The name of the entity or body to push.&lt;br /&gt;
#''cVector avForce, cVector avImpulse'' - A 3d vector to use for the force or impulse.&lt;br /&gt;
#''string asCoordSystem'' - Frame of reference for the force. '''(Optional, default = &amp;quot;world&amp;quot;)'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RotatePropToSpeedVec()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void RotatePropToSpeedVec(string asName, float afAcc, float afGoalSpeed, cVector avAxes, bool abResetSpeed = false, string&amp;amp; asOffsetArea = &amp;quot;&amp;quot;)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
This function is provided as a way to use the global function [[HPL2/Engine_Scripts#Props|RotatePropToSpeed()]] with a vector as the axis multiplier, instead of floats. Could be useful if you want to use it with e.g. RandomVector3d(). See the documentation for the original function for more information. The asOffsetArea string and abResetSpeed bool arguments are optional in this version.&lt;br /&gt;
#''string asName'' - Name of the prop to rotate.&lt;br /&gt;
#''float afAcc'' - Acceleration used to reach desired speed.&lt;br /&gt;
#''float afGoalSpeed'' - The desired speed.&lt;br /&gt;
#''cVector avAxes'' - The 3d vector to use as the axis multiplier.&lt;br /&gt;
#''bool abResetSpeed'' - Whether to reset the speed after the goal is reached. '''(Optional, default = false)'''&lt;br /&gt;
#''string asOffsetArea'' - The area to rotate around. If empty, the center of the body is used. '''(Optional, default = &amp;quot;&amp;quot;)'''&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Randomness===&lt;br /&gt;
Math provides the following methods for returning random values:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomBool()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RandomBool()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a bool with a 50% chance of being true.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
bool bSomeBool = Math.RandomBool();&lt;br /&gt;
// bSomeBool might be true or false.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (Math.RandomBool) SimonIsDuplicate();&lt;br /&gt;
else SimonIsOriginal();&lt;br /&gt;
// No explanation.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomFloat()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float RandomFloat()&lt;br /&gt;
float RandomFloat(float afMin, float afMax)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a random float. The min and max numbers are optional. If a min and max are provided, this is the same as the normal global function RandFloat(). (Note the name difference: Math.RandomFloat() vs RandFloat().)&lt;br /&gt;
&amp;lt;br&amp;gt;If the min and max numbers are omitted, then RandomFloat() will return a random float between zero and one.&lt;br /&gt;
#''float afMin'' - The minimum range of the random number. '''(Optional, together with afMax)'''&lt;br /&gt;
#''float afMax'' - The maximum range of the random number. '''(Optional, together with afMin)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float fA = Math.RandomFloat();&lt;br /&gt;
float fB = Math.RandomFloat(-0.25f, 0.25f);&lt;br /&gt;
float fC = Math.RandomFloat() * 0.5f - 0.25f;&lt;br /&gt;
// fA becomes a random float in the range 0.0...1.0.&lt;br /&gt;
// fB and fC both have the same range: -0.25...0.25.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomInt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int RandomInt()&lt;br /&gt;
int RandomInt(int alMin, int alMax)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a random int. The min and max numbers are optional. If a min and max are provided, this is the same as the normal global function RandInt(). (Note the name difference: Math.RandomInt() vs RandInt().)&lt;br /&gt;
&amp;lt;br&amp;gt;If the min and max numbers are omitted, then RandomInt() will return a random integer in the maximum range of a signed 32bit integer: -2^31...2^31-1 (-2147483648...2147483647).&lt;br /&gt;
#''int alMin'' - The inclusive minimum range of the random number. '''(Optional, together with alMax)'''&lt;br /&gt;
#''int alMax'' - The exclusive maximum range of the random number. '''(Optional, together with alMin)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = Math.RandomInt();&lt;br /&gt;
int lB = Math.RandomInt(0, 6);&lt;br /&gt;
int lC = Math.RandomInt(1, 7);&lt;br /&gt;
// lA becomes any possible signed 32bit int.&lt;br /&gt;
// lB and lC both have 6 possible outcomes: lB could be 0...5, and lC could be 1...6.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomUint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint RandomUint()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a random uint in the maximum range possible. The upper limit of an unsigned 32bit int should be 2^32, but we only have the means of generating 'signed' ints in script, so RandomUint() will actually return a random integer from zero to 2^31-1, inclusive (0...2147483647).&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomInt16()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int16 RandomInt16()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a random int16 in the maximum range of a signed 16bit integer, inclusive: -2^15...2^15-1 (-32768...32767).&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomUint16()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint16 RandomInt16()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a random uint16 in the maximum range of an usigned 16bit integer, inclusive: 0...2^16-1 (0...65535).&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomInt8()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int8 RandomInt16()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a random int8 in the maximum range of a signed 8bit integer, inclusive: -2^7...2^7-1 (-128...127).&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomUint8()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint8 RandomInt16()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a random uint8 in the maximum range of an usigned 8bit integer, inclusive: 0...2^16-1 (0...255).&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomVector2d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector RandomVector2d(float afMin = 0.0f, float afMax = 1.0f, enumVecType aVecOption = vecFree)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a random 2d vector. aVecOption can be omitted, or optionally can be either vecFree, vecOrtho or vecNormal. With vecFree (default), a vector is returned where each dimension is an unrelated random number from afMin to afMax. With vecOrtho, a vector is returned with length afMax, pointing in one positive or negative orthogonal direction. With vecNormal, a normal vector is returned, scaled by afMax (with a length of afMax and a random direction).&lt;br /&gt;
&amp;lt;br&amp;gt;afMin and afMax are also optional. If omitted, they default to 0.0f and 1.0f.&lt;br /&gt;
#''float afMin'' - Used with afMax to specify the minimum extent of the random vector. (Optional with afMax, default = 0.0f)&lt;br /&gt;
#''float afMax'' - Used with afMin 'or on it's own' to specify the maximum extent of the random vector. (Optional, default = 1.0f)&lt;br /&gt;
#''enumVecType aVecOption'' - vecFree, vecOrtho or vecNormal. Specifies the type of random vector returned. (Optional, default = vecFree)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vA = Math.RandomVector2d(5.0f, 10.0f);&lt;br /&gt;
cVector vB = Math.RandomVector2d(vecOrtho);&lt;br /&gt;
cVector vC = Math.RandomVector2d(3.5f, vecNormal);&lt;br /&gt;
// vA becomes a 2d vector where x and y are both random floats in the range of 5.0...10.00.&lt;br /&gt;
// vB becomes a 2d vector with a length of 1.0, pointing directly up, down, left or right.&lt;br /&gt;
// vC becomes a 2d vector pointing in any 2d direction, with a length of 3.5.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomVector3d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector RandomVector3d(float afMin = 0.0f, float afMax = 1.0f, enumVecType aVecOption = vecFree)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a random 3d vector. aVecOption can be omitted, or optionally can be either vecFree, vecOrtho or vecNormal. With vecFree (default), a vector is returned where each dimension is an unrelated random number from afMin to afMax. With vecOrtho, a vector is returned with length afMax, pointing in one positive or negative orthogonal direction. With vecNormal, a normal vector is returned, scaled by afMax (with a length of afMax and a random direction).&lt;br /&gt;
&amp;lt;br&amp;gt;afMin and afMax are also optional. If omitted, they default to 0.0f and 1.0f.&lt;br /&gt;
#''float afMin'' - Used with afMax to specify the minimum extent of the random vector. (Optional with afMax, default = 0.0f)&lt;br /&gt;
#''float afMax'' - Used with afMin 'or on it's own' to specify the maximum extent of the random vector. (Optional, default = 1.0f)&lt;br /&gt;
#''enumVecType aVecOption'' - vecFree, vecOrtho or vecNormal. Specifies the type of random vector returned. (Optional, default = vecFree)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vA = Math.RandomVector3d(5.0f, 10.0f);&lt;br /&gt;
cVector vB = Math.RandomVector3d(vecOrtho);&lt;br /&gt;
cVector vC = Math.RandomVector3d(3.5f, vecNormal);&lt;br /&gt;
// vA becomes a 3d vector where x, y and z are all random floats in the range of 5.0...10.00.&lt;br /&gt;
// vB becomes a 3d vector with a length of 1.0, pointing directly forward, backward, up, down, left or right.&lt;br /&gt;
// vC becomes a 3d vector pointing in any 3d direction, with a length of 3.5.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomVectorInBounds()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector RandomVectorInBounds(cVector avMin, cVector avMax, enumVecType aVecOption = vecFree)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a pair of cVector to define the extents of a rectangle or box, this will return a random position within those extents.&lt;br /&gt;
&amp;lt;br&amp;gt;aVecOption can be omitted, or optionally can be either vecFree, vecOrtho or vecNormal. With vecFree (default), a vector is returned where each dimension is an unrelated random number from afMin to afMax. With vecOrtho, a vector is returned with length afMax, pointing in one positive or negative orthogonal direction. With vecNormal, a normal vector is returned, scaled by afMax (with a length of afMax and a random direction).&lt;br /&gt;
&amp;lt;br&amp;gt;To put it another way: vecFree returns a position inside a quad/cuboid, vecOrtho returns a single extent of the quad/cuboid, and vecNormal returns a point on a circle/sphere that fits the quad/cuboid.&lt;br /&gt;
#''cVector avMin'' - A cVector defining the minimum extent of the range for the random position.&lt;br /&gt;
#''cVector avMax'' - A cVector defining the maximum extent of the range for the random position.&lt;br /&gt;
#''enumVecType aVecOption'' - vecFree, vecOrtho or vecNormal. Specifies the type of random vector returned. (Optional, default = vecFree)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cVector vA = Math.RandomVectorInBounds(cVector(-5.0f, -5.0f, -5.0f), cVector(5.0f, 5.0f, 5.0f));&lt;br /&gt;
cVector vB = Math.RandomVectorInBounds(cVector(-5.0f, 0.0f, 2.0f), cVector(5.0f, 10.0f, 2.0f));&lt;br /&gt;
// vA becomes random position in a cube centred on 0,0,0, with a size of 10m.&lt;br /&gt;
// vB becomes random position on an x/y plane 2m forward, -5,0,2...5,10,2.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cVector vMyRoom_FloorCornerA = cVector(20.0f. 0.0f, 30.0f);&lt;br /&gt;
cVector vMyRoom_FloorCornerB = cVector(10.0f. 0.0f, 15.0f);&lt;br /&gt;
float fMyRoom_CeilingHeight = 4.0f;&lt;br /&gt;
cVector vMyRoom_RandomPosOnFloor = Math.RandomVectorInBounds(vMyRoom_FloorCornerA, vMyRoom_FloorCornerB);&lt;br /&gt;
cVector vMyRoom_RandomPosOnCeiling = Math.RandomVectorInBounds(vMyRoom_FloorCornerA, vMyRoom_FloorCornerB) + cVector(0.0f, fMyRoom_CeilingHeight, 0.0f);&lt;br /&gt;
cVector vMyRoom_RandomPosInRoom = Math.RandomVectorInBounds(vMyRoom_FloorCornerA, vMyRoom_FloorCornerB + cVector(0.0f, fMyRoom_CeilingHeight, 0.0f));&lt;br /&gt;
cVector vMyRoom_RandomSurface = Math.RandomVectorInBounds(vMyRoom_FloorCornerA, vMyRoom_FloorCornerB + cVector(0.0f, fMyRoom_CeilingHeight, 0.0f), vecOrtho);&lt;br /&gt;
cVector vMyRoom_RandomSphere = Math.RandomVectorInBounds(vMyRoom_FloorCornerA, vMyRoom_FloorCornerB + cVector(0.0f, fMyRoom_CeilingHeight, 0.0f), vecNormal);&lt;br /&gt;
// Assuming that we have a room that is cuboid in shape:&lt;br /&gt;
// vMyRoom_RandomPosOnFloor and vMyRoom_RandomPosOnCeiling become random points on the floor and ceiling.&lt;br /&gt;
// vMyRoom_RandomPosInRoom becomes a random position anywhere in the room.&lt;br /&gt;
// vMyRoom_RandomSurface becomes a point in the centre of either the ceiling, floor or any of the four walls.&lt;br /&gt;
// vMyRoom_RandomSphere becomes a random position inside the a sphere that reaches from the centre of the room to the nearest surface.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RandomRotator()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cRotator RandomRotator(float afMinPitch = -Pi, float afMaxPitch = Pi, float afMinYaw = -Pi, float afMaxYaw = Pi, float afMinRoll = -Pi, float afMaxRoll = Pi, enumAngleUnits aUnits = angleRadians)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a random rotator. The arguments are optional all together. If all are omitted, the rotator will have an entirely random orientation. If all are included, then the random orientation will be within the specified range.&lt;br /&gt;
&amp;lt;br&amp;gt; aUnits is optional and defaults to angleRadians if omitted. If angleRadians (default) the min and max values are assumed to be in radians. If angleDegrees, they are assumed to be in degrees.&lt;br /&gt;
#''float afMinPitch'' - Lower limit for pitch. (Optional with all together, default = -Pi)&lt;br /&gt;
#''float afMaxPitch'' - Upper limit for pitch. (Optional with all together, default = Pi)&lt;br /&gt;
#''float afMinYaw'' - Lower limit for yaw. (Optional with all together, default = -Pi)&lt;br /&gt;
#''float afMaxYaw'' - Upper limit for yaw. (Optional with all together, default = Pi)&lt;br /&gt;
#''float afMinRoll'' - Lower limit for roll. (Optional with all together, default = -Pi)&lt;br /&gt;
#''float afMaxRoll'' - Upper limit for roll. (Optional with all together, default = Pi)&lt;br /&gt;
#''enumAngleUnits aUnits'' - angleRadians, or angleDegrees. (Optional, default = angleRadians)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cRotator vRotA = Math.RandomRotator();&lt;br /&gt;
cRotator vRotB = Math.RandomRotator(-5.0f, 5.0f, -180.0f, 180.0f, 0.0f, 0.0f, angleDegrees);&lt;br /&gt;
cRotator vRotC = Math.RandomRotator(-Math.Pi/36.0f, Math.Pi/36.0f, -Math.Pi, Math.Pi, 0.0f, 0.0f);&lt;br /&gt;
// vRotA becomes a random rotator with any possible orientation.&lt;br /&gt;
// vRotB and vRotC both have the same possible range, one provided in degrees, the other in radians. In both cases the rotation is tilted slightly up or down and pitched to any direction, with no roll.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6785</id>
		<title>HPL2/HPL2 Helper Scripts/Lists</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6785"/>
		<updated>2024-02-11T01:52:41Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Lists.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;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_Lists.hps&amp;quot; adds support for linked list classes. For beginners or other people not familiar with classes, these are best thought of as new variable types. A linked list, or just &amp;quot;list&amp;quot;, is a type of collection that works similarly to an array. Both lists and arrays are ways of grouping multiple variables together under one name.&lt;br /&gt;
&lt;br /&gt;
There are three main advantages to using lists over arrays. The first is that it is more efficient (and more performant) to insert, remove or re-order items in the list than it would be with an array. The second is that lists can also take up less memory than arrays. The memory requirement of an array is defined by its maximum capacity, whereas the memory requirement of a list is only as much as its current content. And therefore the third advantage is that it is not necessary to know in advance how big a list needs to be - it expands automatically as items are added. (And of course, advanced users may note that there are exceptions when an array would be more efficient, but most users won't need to worry about this.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
Declare a list like any other variable, then use the methods below to work with it. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt myList;		// Declares a new cListInt, called myList, ready to collect integers.&lt;br /&gt;
myList.Add(68);			// Appends the first integer (68) to the list at index 0.&lt;br /&gt;
myList.Add(419);		// Appends the second integer (419) to the list at index 1.&lt;br /&gt;
myList.Get(0);			// Retrieves the integer at index 0.&lt;br /&gt;
myList.Set(1, 99);		// Overwrites the integer at index 1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Indices===&lt;br /&gt;
Like arrays, you can ''get'' the items in the list using an index operator, e.g. myList[0], myList[22], myList[LastIndex]. And like arrays, the index number is '''zero based'''. In a list or array of ten items, the first index is 0 and the last index is 9.&lt;br /&gt;
&lt;br /&gt;
Getting an item from a list by its index is equivalent to using the Get() method. However, ''unlike arrays'', this is '''read-only'''. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);		// OK&lt;br /&gt;
string myStringOne = myToDoList[1];				// OK&lt;br /&gt;
&lt;br /&gt;
myToDoList.Set(0, &amp;quot;Paint over the lines.&amp;quot;);		// OK&lt;br /&gt;
myToDoList[1] = &amp;quot;Cut the cheese.&amp;quot;;				// Not OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(This seems to be because the version of AngelScript used in HPL2 seems to only allow the index operator to ''get'' and not ''set''. If I'm wrong and you can make this work, let me know!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
&amp;quot;HelperScripts_Lists.hps&amp;quot; also defines cListNodeBase and several derived node classes for each type of list. The list classes all inherit from the base class cListBase, which defines some shared functionality and handles anything that doesn't depend on the type of the stored data.&lt;br /&gt;
&lt;br /&gt;
Additionally, cListGeneric is an extra list class intended for advanced users. It extends the cListBase class without defining an inner data type, to help with making custom node classes derived from cListNodeBase. Advanced users attempting this may find it helpful to take a look at the cListBase and cListGeneric definition, and to read up on how AngelScript uses object handles. Examples can be found in most of the ''features'' scripts, e.g. &amp;quot;HelperScripts_Slimer.hps&amp;quot;, which implements multiple custom node classes and nested lists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=List classes=&lt;br /&gt;
&lt;br /&gt;
Available list classes: &amp;lt;code&amp;gt;cListInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListPoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;List classes&amp;quot; section refers to all the list types unless otherwise stated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
Lists can be declared in the same way as other variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat listOfFloats;					// Declares a list of floats.&lt;br /&gt;
cListString listOfStrings;					// Declares a list of strings.&lt;br /&gt;
&lt;br /&gt;
myListOfFloats.Add(0.001f);					// Calling a method of the referred list.&lt;br /&gt;
int numStrings = myListOfStrings.Count;		// Accessing a property of the referred list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with capacity===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(uint aulMaxSize)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the list is initialised with a constructor, then a maximum capacity can be specified for the list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the list is declared without a specific capacity, then the default maximum capacity is assigned, which is 65535 (or 2^16 - 1).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat listOfFloatsDefault;&lt;br /&gt;
cListVector listOfVectorsDefault;&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfUpToFiveFloats = cListFloat(5);&lt;br /&gt;
cListVector listOfUpTo1000Vectors = cListVector(1000);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default 65535 (2^16-1) is the maximum capacity that can be indexed. Using this a or smaller arbitrary limit can help to catch runaway bugs. '''Advanced users''' may try changing the value of mulCountMax to use a smaller default maximum. Using a larger maximum will likely cause problems.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that arrays require as much memory as their full capacity even when empty, but lists are only ever as big as their content, so lowering the maximum size of the list does not help performance. But it might be useful in certain situations where a limit is required by design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with data===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(float[] afArray)&lt;br /&gt;
cListBase(cListBase aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Lists can be initialised with data by passing an array of values of the relevant type, or an existing list. The default capacity is used for the new list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the source is an array, the new list will contain copies of the array's contents. If the source is an existing list, then the new list will copy the ''link'' to the original items. Both the old and new lists will point to the same data, and changing one will change the other. To avoid this, see the [[HPL2/HPL2_Helper_Scripts/Lists#Copy.28.29|Copy()]] method.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListFloat myFirstList = cListFloat(myArray);			// Makes a new float list by copying items from the float array.&lt;br /&gt;
cListFloat mySecondList = myFirstList;					// Makes a new float list containing the same items as the other list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat(float afSingleFloat)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
All the derived list classes ('''except for cListGeneric and cListInt''') can be initialised with data by passing a single value of the relevant type, to become the first item in the list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat myList = cListFloat(1.2f);				// Makes a new float list with a single value.&lt;br /&gt;
myList.Add(2.3f);									// myList now contains: 1.2f, 2.3f&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
'''All list classes''' provide the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Count====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Count&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Count returns the current number of items in the list.&lt;br /&gt;
(The property Length and the method length() are provided for consistency with arrays, and are both equivalent to Count.)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat myList;&lt;br /&gt;
uint ulCountA = myList.Count;&lt;br /&gt;
myList.Add(99.99f);&lt;br /&gt;
uint ulCountB = myList.Count;&lt;br /&gt;
// ulCountA is 0. ulCountB is 1.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (listNumbers.Count &amp;lt; 6) listNumber.Add(42);&lt;br /&gt;
// The condition succeeds if the count is less than 6, and another number is added.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the last valid index, or -1 if the list is empty.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
uint ulA = myListOfStrings.LastIndex;&lt;br /&gt;
uint ulB = myListOfStrings.Count - 1;&lt;br /&gt;
// ulA and ulB are equal&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string sLatest = myListOfStrings[myListOfStrings.LastIndex];&lt;br /&gt;
// sLatest becomes whatever string was added to the list most recently.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Capacity====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Capacity&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Capacity returns the maximum count of items in the list. This will be the default limit, unless one was specified on construction.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt someList;&lt;br /&gt;
someList.Add(1);&lt;br /&gt;
uint spaceRemaining = someList.Capacity - someList.Count;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsEmpty====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEmpty&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsEmpty returns true if the list is empty, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (myList.IsEmpty) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list contains no items.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsFull====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsFull&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsFull returns true if the list is full to its maximum capacity, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (!myList.IsFull) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list has space for another item.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DefaultValue====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int DefaultValue&lt;br /&gt;
float DefaultValue&lt;br /&gt;
double DefaultValue&lt;br /&gt;
bool DefaultValue&lt;br /&gt;
string DefaultValue&lt;br /&gt;
cVector DefaultValue&lt;br /&gt;
cPoint DefaultValue&lt;br /&gt;
cRotator DefaultValue&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only property DefaultValue returns the value that this list type uses as a default. The default value is defined by each list class and used instead of a null item. (e.g.: -1, 0.0f, false, &amp;quot;&amp;quot;)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
someItem = myList.Pop();&lt;br /&gt;
if (someItem == myList.DefaultValue) Debug.Message(1, &amp;quot;Nothing left to pop!&amp;quot;);&lt;br /&gt;
// The condition succeeds if item returned from the list was the default item, probably because the list was empty.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Assignment====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase = cListBase&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The assignment operator (equals sign &amp;quot;=&amp;quot;) assigns a new set of data to the list, copied from another list. Note: the list contains handles to the data, not the data itself. So when a list is copied, ''both'' lists now refer to the same data, and any changes made to either will affect both.&lt;br /&gt;
&amp;lt;br&amp;gt;If the intent is to make a duplicate of the ''data'' rather than the list handles, then the Copy() method is recommended.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Equality===&lt;br /&gt;
&lt;br /&gt;
The logical equality operator (double equals sign &amp;quot;==&amp;quot;) can be used to compare two lists of the same type, just like with other values. It will return true if the lists contain the same number of items and the coresponding data items in the lists have equal values, or if the two lists both point to the same data.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB;&lt;br /&gt;
listA.Add(&amp;quot;four&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;five&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;size&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listC = listB;&lt;br /&gt;
&lt;br /&gt;
bool test1 = listA == listB;&lt;br /&gt;
bool test2 = listB == listC;&lt;br /&gt;
// test1 will be false because listA and listB contain values that are not equal.&lt;br /&gt;
// test2 will be true because listB and listC both point to the same items.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for assigning items to the list:&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(int alItem)&lt;br /&gt;
bool Add(float afItem)&lt;br /&gt;
bool Add(double adItem)&lt;br /&gt;
bool Add(bool abItem)&lt;br /&gt;
bool Add(string asItem)&lt;br /&gt;
bool Add(cVector avItem)&lt;br /&gt;
bool Add(cPoint avItem)&lt;br /&gt;
bool Add(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Creates a new item appended to the list. If the list is full or the item cannot be added, it returns false. If it was successfull appended, it returns true.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfFloats.Add(1.0f);&lt;br /&gt;
myListOfPoints.Add(cPoint(10, 15, 20));&lt;br /&gt;
// The new values are appended to the list.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!listNumbers.Add(-1.0f)) Debug.Message(1, &amp;quot;Error - could not add to list!&amp;quot;);&lt;br /&gt;
// The condition succeeds if Add failed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Set()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Set(uint aulIndex, int alItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, float afItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, double adItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, bool abItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, string asItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, cVector avItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, cPoint avItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, cRotator avItem, bool abExtend = true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to an indexed item in the list.&lt;br /&gt;
&amp;lt;br&amp;gt;abExtend is optional. If the given index is not valid and abExtend is omitted or true, then the list will be extended to fit the new index, using Extend() with default values. If the given index is not valid and abExtend is false, then the item will not be set.&lt;br /&gt;
&amp;lt;br&amp;gt;Set() returns true if the item was succesfully set. If the item could not be set or if the list could not be extended to fit it, Set() returns false.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be changed.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be assigned.&lt;br /&gt;
#''bool abExtend'' - Whether to extend the list to fit the new item, if necessary. '''(Optional, default = true)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfBools.Set(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, replacing the previous one.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListString myListOfStrings;&lt;br /&gt;
myListOfInts.Set(3, &amp;quot;three&amp;quot;);&lt;br /&gt;
myListOfInts.Set(6, &amp;quot;six&amp;quot;, true);&lt;br /&gt;
myListOfInts.Set(10, &amp;quot;ten&amp;quot;, false);&lt;br /&gt;
// Setting &amp;quot;three&amp;quot; and &amp;quot;size&amp;quot; succeeded by extending the list.&lt;br /&gt;
// Setting &amp;quot;ten&amp;quot; failed because index 10 does not exist, and abExtend is false.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Extend()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Extend(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If given index is not valid, then Extend() adds default items (e.g.: -1, 0.0f, false, &amp;quot;&amp;quot;) until the last valid index becomes the given index. Returns false if the list could not be extended to the specified index.&lt;br /&gt;
#''uint aulIndex'' - The index which become the new last index, if higher.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString twentyEmptyStrings;&lt;br /&gt;
twentyEmptyStrings.Extend(19);&lt;br /&gt;
// twentyEmptyStrings now contains... twenty empty strings.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Insert()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Insert(uint aulIndex, int alItem)&lt;br /&gt;
bool Insert(uint aulIndex, float afItem)&lt;br /&gt;
bool Insert(uint aulIndex, double adItem)&lt;br /&gt;
bool Insert(uint aulIndex, bool abItem)&lt;br /&gt;
bool Insert(uint aulIndex, string asItem)&lt;br /&gt;
bool Insert(uint aulIndex, cVector avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cPoint avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Inserts a new item into the list at the given index. (The item previous at that index becomes the next one.) If the given index is not a valid place to insert an item, then then return value will be false. Otherwise the item is inserted and it returns true.&lt;br /&gt;
#''uint aulIndex'' - The index where the new item will be inserted.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be inserted.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfBools.Insert(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, displacing the previous one to index 8.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!myList.Insert(10, &amp;quot;hello&amp;quot;) myList.Add(&amp;quot;hello&amp;quot;);&lt;br /&gt;
// Attempts to insert the string at index 10, and if that fails the string is appended instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Concatenate()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Concatenate(cListBase aList)&lt;br /&gt;
bool Concatenate(int[] alArray)&lt;br /&gt;
bool Concatenate(float[] afArray)&lt;br /&gt;
bool Concatenate(double[] adArray)&lt;br /&gt;
bool Concatenate(bool[] abArray)&lt;br /&gt;
bool Concatenate(string[] asArray)&lt;br /&gt;
bool Concatenate(cVector[] avArray)&lt;br /&gt;
bool Concatenate(cPoint[] avArray)&lt;br /&gt;
bool Concatenate(cRotator[] avArray)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Takes either a second list or array of the same type and appends it to this one. It first checks to make sure there is enough capacity. Returns true if items were successfully added, or false if not.&lt;br /&gt;
&amp;lt;br&amp;gt;If an array is supplied, new list items are created to match them. If a list is suplied the items are '''not duplicated''' - both lists refer to the same items in memory, and changing them will change both lists.&lt;br /&gt;
#''cListBase aList (or any list type), or an array of int[], float[], double[], bool[], string[], cVector[], cPoint[] or cRotator[]'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
float[] arrayOfFloatsB = { 3.0f, 4.0f };&lt;br /&gt;
listOfFloatsA.Concatenate(arrayOfFloatsB);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 4.0f.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfFloatsB;&lt;br /&gt;
listOfFloatsB.Add(3.0f);&lt;br /&gt;
listOfFloatsB.Add(4.0f);&lt;br /&gt;
&lt;br /&gt;
listOfFloatsA.Concatenate(listOfFloatsB);&lt;br /&gt;
listOfFloatsA.Set(3, 99.9f);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 99.9f.&lt;br /&gt;
// listOfFloatsB now contains 3.0f, 99.9f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for retrieving items from the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Get()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Get(uint aulIndex)&lt;br /&gt;
float Get(uint aulIndex)&lt;br /&gt;
double Get(uint aulIndex)&lt;br /&gt;
bool Get(uint aulIndex)&lt;br /&gt;
string Get(uint aulIndex)&lt;br /&gt;
cVector Get(uint aulIndex)&lt;br /&gt;
cPoint Get(uint aulIndex)&lt;br /&gt;
cRotator Get(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, if it exists. If the item does not exist in the list, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;br&amp;gt;See GetIfValid() if you want to be sure the item exists. You can also use an index operator (e.g. myList[i]) to get list items.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);&lt;br /&gt;
string myStringLast = myToDoList.Get(myToDoList.LastIndex);&lt;br /&gt;
// myStringZero becomes the value from the start of the list.&lt;br /&gt;
// myStringLast becomes the value that happens to be at the end of the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIfValid()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GetIfValid(uint aulIndex, int &amp;amp;out alTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, float &amp;amp;out afTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, double &amp;amp;out adTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, bool &amp;amp;out abTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, string &amp;amp;out asTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cVector &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cPoint &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cRotator &amp;amp;out avTarget)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, as long as it is valid.&lt;br /&gt;
&amp;lt;br&amp;gt;The second parameter is an ''ouput'' parameter. If the item at the given index exists then '''the item is assigned to the Target &amp;amp;out parameter''', and the function returns true. If the item doesn't exist in the list, the function returns false.&lt;br /&gt;
&amp;lt;br&amp;gt;See Get() if you don't care about validation and just want to return the item.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
#''int alTarget, float afTarget, double adTarget, bool abTarget, string asTarget, cVector avTarget, cPoint avTarget, or cRotator avTarget'' - The variable, of the appropriate type, where the retrieved item will be '''stored'''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int retrievedInteger;&lt;br /&gt;
if(!myListOfInts.GetIfValid(3, retrievedInteger)) retrievedInteger = -1;&lt;br /&gt;
// retrievedInteger will be assigned the value retrieved from index 3 in the list, if it exists.&lt;br /&gt;
// If it doesn't exist, the condition will succeed and retrievedInteger with be assigned -1 instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetRandom()&lt;br /&gt;
float GetRandom()&lt;br /&gt;
double GetRandom()&lt;br /&gt;
bool GetRandom()&lt;br /&gt;
string GetRandom()&lt;br /&gt;
cVector GetRandom()&lt;br /&gt;
cPoint GetRandom()&lt;br /&gt;
cRotator GetRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list and returns it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pop()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Pop()&lt;br /&gt;
float Pop()&lt;br /&gt;
double Pop()&lt;br /&gt;
bool Pop()&lt;br /&gt;
string Pop()&lt;br /&gt;
cVector Pop()&lt;br /&gt;
cPoint Pop()&lt;br /&gt;
cRotator Pop()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the last item in the list, and removes that item. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lA = listNumbers.Pop();&lt;br /&gt;
int lB = listNumbers.Pop();&lt;br /&gt;
int lC = listNumbers.Pop();&lt;br /&gt;
// lA, lB, and lC have become 23, 16, and 15. myArray now contains only 4 and 8.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PopRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int PopRandom()&lt;br /&gt;
float PopRandom()&lt;br /&gt;
double PopRandom()&lt;br /&gt;
bool PopRandom()&lt;br /&gt;
string PopRandom()&lt;br /&gt;
cVector PopRandom()&lt;br /&gt;
cPoint PopRandom()&lt;br /&gt;
cRotator PopRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list, returns it and them removes it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors, and that value is no longer available in the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Copy()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt Copy(cListInt aList)&lt;br /&gt;
cListFloat Copy(cListFloat aList)&lt;br /&gt;
cListDouble Copy(cListDouble aList)&lt;br /&gt;
cListBool Copy(cListBool aList)&lt;br /&gt;
cListVector Copy(cListVector aList)&lt;br /&gt;
cListPoint Copy(cListPoint aList)&lt;br /&gt;
cListRotator Copy(cListRotator aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a new list that is a duplicate of this list. The items in the new list are new items. Changing either list will not affect the other.&lt;br /&gt;
#''cListBase aList (or any list type)'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Removing list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for removing items from the list: (See also: Pop() and PopRandom())&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAt(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and removes the given index.&lt;br /&gt;
Returns true if the index was valid and was removed, or false if not.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myList.RemoveAt(7);&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (myList.RemoveAt(7)) myList.Append(&amp;quot;something new&amp;quot;);&lt;br /&gt;
// If the removal was successful, then a new value is appended.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveItem(int alItem)&lt;br /&gt;
bool RemoveItem(float afItem)&lt;br /&gt;
bool RemoveItem(double adItem)&lt;br /&gt;
bool RemoveItem(bool abItem)&lt;br /&gt;
bool RemoveItem(string asItem)&lt;br /&gt;
bool RemoveItem(cVector avItem)&lt;br /&gt;
bool RemoveItem(cPoint avItem)&lt;br /&gt;
bool RemoveItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and removes the first matching item it finds. Returns true if the item was found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
myListOfBools.RemoveItem(false);&lt;br /&gt;
// The first instance of false in the list will be removed.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
int  lRemoved = 0;&lt;br /&gt;
int[] myArray = { 4, 8, 0, 15, 16, 0, 23, 0 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
while (listNumbers.Remove(0))&lt;br /&gt;
{&lt;br /&gt;
    lRemoved++;&lt;br /&gt;
	DoStuff();&lt;br /&gt;
}&lt;br /&gt;
// The Remove() call will repeat until it returns false, at which point the value of lRemoved will be 3.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAll()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAll(int alItem)&lt;br /&gt;
bool RemoveAll(float aItem)&lt;br /&gt;
bool RemoveAll(double aItem)&lt;br /&gt;
bool RemoveAll(bool aItem)&lt;br /&gt;
bool RemoveAll(string aItem)&lt;br /&gt;
bool RemoveAll(cVector aItem)&lt;br /&gt;
bool RemoveAll(cPoint aItem)&lt;br /&gt;
bool RemoveAll(cRotator aItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and removes the all matching items. Returns true if any items were found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
myListOfFloats.RemoveAll(0.0f);&lt;br /&gt;
// All the zeros will be removed from the list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Searching lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for searching for items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Find()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Find(int alItem)&lt;br /&gt;
int Find(float afItem)&lt;br /&gt;
int Find(double adItem)&lt;br /&gt;
int Find(bool abItem)&lt;br /&gt;
int Find(string asItem)&lt;br /&gt;
int Find(cVector avItem)&lt;br /&gt;
int Find(cPoint avItem)&lt;br /&gt;
int Find(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns the index of the first match. If the item is not found, -1 is returned instead.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
uint lIndexTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
uint lIndexFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// lIndexTwentyTwo becomes 1. lIndexFortyFour becomes -1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Contains()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Contains(int alItem)&lt;br /&gt;
bool Contains(float afItem)&lt;br /&gt;
bool Contains(double adItem)&lt;br /&gt;
bool Contains(bool abItem)&lt;br /&gt;
bool Contains(string asItem)&lt;br /&gt;
bool Contains(cVector avItem)&lt;br /&gt;
bool Contains(cPoint avItem)&lt;br /&gt;
bool Contains(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns true if found, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
bool bHasTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
bool bHasFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// bHasTwentyTwo becomes true. bHasFortyFour becomes false.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CountItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint CountItem(int alItem)&lt;br /&gt;
uint CountItem(float afItem)&lt;br /&gt;
uint CountItem(double adItem)&lt;br /&gt;
uint CountItem(bool abItem)&lt;br /&gt;
uint CountItem(string asItem)&lt;br /&gt;
uint CountItem(cVector avItem)&lt;br /&gt;
uint CountItem(cPoint avItem)&lt;br /&gt;
uint CountItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and returns the number of matches found.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myListOfStrings;&lt;br /&gt;
myListOfStrings.Add(&amp;quot;up&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;sideways&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
int lNumDown = myListOfStrings.CountItem(&amp;quot;down&amp;quot;);&lt;br /&gt;
int lNumForward = myListOfStrings.CountItem(&amp;quot;forward&amp;quot;);&lt;br /&gt;
// lNumDown becomes 2. lNumForward becomes 0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Numeric lists===&lt;br /&gt;
Some of the derived list classes dealing with numeric values provide the methods for arithmetic operations across the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Min()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Min()&lt;br /&gt;
float Min()&lt;br /&gt;
double Min()&lt;br /&gt;
bool Min()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns false if there is a false - like logical AND over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fSmallest = fRandomList.Min();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the smallest is assigned to fSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Max()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Max()&lt;br /&gt;
float Max()&lt;br /&gt;
double Max()&lt;br /&gt;
bool Max()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - like logical OR over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fLargest = fRandomList.Max();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the largest is assigned to fLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMin()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMin()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lSmallest = fRandomList.FindMin();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the smallest is assigned to lSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMax()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMax()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lLargest = fRandomList.FindMax();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the largest is assigned to lLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sum()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Sum()&lt;br /&gt;
float Sum()&lt;br /&gt;
double Sum()&lt;br /&gt;
bool Sum()&lt;br /&gt;
cVector Sum()&lt;br /&gt;
cPoint Sum()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the total of all the items in the list, added together. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - the same as logical OR. For vectors, this is equivalent to the combined path of each vector.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lTot = listNumbers.Sum();&lt;br /&gt;
// lTot becomes 108.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListPoint listGridSteps;&lt;br /&gt;
listGridSteps.Add(cPoint(1, 0));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(-1, 0));&lt;br /&gt;
&lt;br /&gt;
cPoint vFinalPos = listGridSteps.Sum()&lt;br /&gt;
// This example imagines a puzzle involving steps on a grid. Each step is stored in a list of points and the final position is the sum of the list. (0,2 in this case.)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Average()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Average()&lt;br /&gt;
float Average()&lt;br /&gt;
double Average()&lt;br /&gt;
bool Average()&lt;br /&gt;
cVector Average()&lt;br /&gt;
cPoint Average()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the mean average of all the items in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that for ints, the answer will be truncated. For bools, this basically returns true if there are more true items than false. For vectors this is like finding the &amp;quot;centre of balance&amp;quot; of some points.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lAvg = listNumbers.Average();&lt;br /&gt;
// lAvg becomes 18.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListVector listGruntPos;&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt1&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt2&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt3&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
SetEntityPosVec(&amp;quot;orb&amp;quot;, listGruntPos.Average());&lt;br /&gt;
// This example imagines an effect where an entity is positioned at the mid-point between 3 enemies.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Ordering lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for ordering items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Swap()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Swap(uint aulA, uint aulB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Swaps the places of two items in the array. Returns false if either of the indeces are invalid, or true if the swap went ahead.&lt;br /&gt;
#''uint aulA'' - The index of the first item to be swapped.&lt;br /&gt;
#''uint aulB'' - The index of the second item to be swapped.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Swap(0, 1);&lt;br /&gt;
myListOfInts.Swap(1, 2);&lt;br /&gt;
// After the two swaps, the list is in numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sort()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Sort(abDescending = false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Re-orders a list of numbers, to put them in numerical order, using bubble sort. Bubble sort is simple but inefficient, so sorting large lists very frequently will have a performance impact. cListInt, cListFloat, cListDouble, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For vectors, the list will be sorted by square length.&lt;br /&gt;
#''bool abDescending (optional, default = false)'' - If true, the items will be ordered highest-to-lowest, otherwise lowest-to-highest.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Sort();&lt;br /&gt;
// The list is now sorted into ascending numerical order.&lt;br /&gt;
myListOfInts.Sort(true);&lt;br /&gt;
// The list is now sorted into descending numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Shuffle()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Shuffle()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Changes the order of the list to a new, random order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
for (int i = 1; i &amp;lt;= 10; i++) myListOfInts.Add(i);&lt;br /&gt;
myListOfInts.Shuffle();&lt;br /&gt;
// The list now contains the numbers 1 to 10, in a random order with no repetition or missing numbers.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Converting lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for converting lists into other types of collections:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int[] ToArray()&lt;br /&gt;
float[] ToArray()&lt;br /&gt;
double[] ToArray()&lt;br /&gt;
string[] ToArray()&lt;br /&gt;
cVector[] ToArray()&lt;br /&gt;
cPoint[] ToArray()&lt;br /&gt;
cRotator[] ToArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes a new array, where each element in the array is a copy of an item from the list, and returns the array.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] ToStringArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes a new array, where each element in the array is a string version of each item in the list, and returns the array. (Uses the ToString() method of each node class.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a new string representing the whole list, by getting string versions of each item in the list and joining them. (Uses the ToString() method of each node class, and the Join() method of cString.) (Coming soon, this entry is a placeholder!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Node classes=&lt;br /&gt;
The node classes contain the actual items in the lists and provide ways to access the data or links between nodes. Generally, it is '''not recommended''' to work with these directly, but use the functions of the list classes instead. More '''advanced users''' can extend the cListNodeBase class, or any class, and use it with cListGeneric.&lt;br /&gt;
&lt;br /&gt;
Available node classes: &amp;lt;code&amp;gt;cListNodeInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodePoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Behaviours===&lt;br /&gt;
In the derived node classes, the default constructor creates a node with a default item, or an argument can be provided to set the initial value. For example, in the cListNodeInt class:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeInt() 					// Creates an int node with value 0.&lt;br /&gt;
cListNodeInt(int alItem)		// Creates an int node with value alItem.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Properties===&lt;br /&gt;
All dervied node classes have one public property, named Item:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Item&lt;br /&gt;
float Item&lt;br /&gt;
double Item&lt;br /&gt;
bool Item&lt;br /&gt;
string Item&lt;br /&gt;
cVector Item&lt;br /&gt;
cPoint Item&lt;br /&gt;
cRotator Item&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The property Item can get or set the data item in the node, using the appropriate type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNext(cListNodeBase@ ahNext)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a handle to the next node. To break the link, assign null or use ClearNext().&lt;br /&gt;
#''cListNodeBase@ ahNext'' - A handle to an instance of cListNodeBase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeBase@ GetNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ClearNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Resets the handle to the next node to null&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6784</id>
		<title>HPL2/HPL2 Helper Scripts/Lists</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6784"/>
		<updated>2024-02-11T01:52:02Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added DefaultValue, Capacity, Fill(), Extend(), AddUnique(), ToString(), ==&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Lists.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;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_Lists.hps&amp;quot; adds support for linked list classes. For beginners or other people not familiar with classes, these are best thought of as new variable types. A linked list, or just &amp;quot;list&amp;quot;, is a type of collection that works similarly to an array. Both lists and arrays are ways of grouping multiple variables together under one name.&lt;br /&gt;
&lt;br /&gt;
There are three main advantages to using lists over arrays. The first is that it is more efficient (and more performant) to insert, remove or re-order items in the list than it would be with an array. The second is that lists can also take up less memory than arrays. The memory requirement of an array is defined by its maximum capacity, whereas the memory requirement of a list is only as much as its current content. And therefore the third advantage is that it is not necessary to know in advance how big a list needs to be - it expands automatically as items are added. (And of course, advanced users may note that there are exceptions when an array would be more efficient, but most users won't need to worry about this.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
Declare a list like any other variable, then use the methods below to work with it. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt myList;		// Declares a new cListInt, called myList, ready to collect integers.&lt;br /&gt;
myList.Add(68);			// Appends the first integer (68) to the list at index 0.&lt;br /&gt;
myList.Add(419);		// Appends the second integer (419) to the list at index 1.&lt;br /&gt;
myList.Get(0);			// Retrieves the integer at index 0.&lt;br /&gt;
myList.Set(1, 99);		// Overwrites the integer at index 1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Indices===&lt;br /&gt;
Like arrays, you can ''get'' the items in the list using an index operator, e.g. myList[0], myList[22], myList[LastIndex]. And like arrays, the index number is '''zero based'''. In a list or array of ten items, the first index is 0 and the last index is 9.&lt;br /&gt;
&lt;br /&gt;
Getting an item from a list by its index is equivalent to using the Get() method. However, ''unlike arrays'', this is '''read-only'''. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);		// OK&lt;br /&gt;
string myStringOne = myToDoList[1];				// OK&lt;br /&gt;
&lt;br /&gt;
myToDoList.Set(0, &amp;quot;Paint over the lines.&amp;quot;);		// OK&lt;br /&gt;
myToDoList[1] = &amp;quot;Cut the cheese.&amp;quot;;				// Not OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(This seems to be because the version of AngelScript used in HPL2 seems to only allow the index operator to ''get'' and not ''set''. If I'm wrong and you can make this work, let me know!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
&amp;quot;HelperScripts_Lists.hps&amp;quot; also defines cListNodeBase and several derived node classes for each type of list. The list classes all inherit from the base class cListBase, which defines some shared functionality and handles anything that doesn't depend on the type of the stored data.&lt;br /&gt;
&lt;br /&gt;
Additionally, cListGeneric is an extra list class intended for advanced users. It extends the cListBase class without defining an inner data type, to help with making custom node classes derived from cListNodeBase. Advanced users attempting this may find it helpful to take a look at the cListBase and cListGeneric definition, and to read up on how AngelScript uses object handles. Examples can be found in most of the ''features'' scripts, e.g. &amp;quot;HelperScripts_Slimer.hps&amp;quot;, which implements multiple custom node classes and nested lists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=List classes=&lt;br /&gt;
&lt;br /&gt;
Available list classes: &amp;lt;code&amp;gt;cListInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListPoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;List classes&amp;quot; section refers to all the list types unless otherwise stated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
Lists can be declared in the same way as other variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat listOfFloats;					// Declares a list of floats.&lt;br /&gt;
cListString listOfStrings;					// Declares a list of strings.&lt;br /&gt;
&lt;br /&gt;
myListOfFloats.Add(0.001f);					// Calling a method of the referred list.&lt;br /&gt;
int numStrings = myListOfStrings.Count;		// Accessing a property of the referred list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with capacity===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(uint aulMaxSize)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the list is initialised with a constructor, then a maximum capacity can be specified for the list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the list is declared without a specific capacity, then the default maximum capacity is assigned, which is 65535 (or 2^16 - 1).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat listOfFloatsDefault;&lt;br /&gt;
cListVector listOfVectorsDefault;&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfUpToFiveFloats = cListFloat(5);&lt;br /&gt;
cListVector listOfUpTo1000Vectors = cListVector(1000);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default 65535 (2^16-1) is the maximum capacity that can be indexed. Using this a or smaller arbitrary limit can help to catch runaway bugs. '''Advanced users''' may try changing the value of mulCountMax to use a smaller default maximum. Using a larger maximum will likely cause problems.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that arrays require as much memory as their full capacity even when empty, but lists are only ever as big as their content, so lowering the maximum size of the list does not help performance. But it might be useful in certain situations where a limit is required by design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with data===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(float[] afArray)&lt;br /&gt;
cListBase(cListBase aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Lists can be initialised with data by passing an array of values of the relevant type, or an existing list. The default capacity is used for the new list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the source is an array, the new list will contain copies of the array's contents. If the source is an existing list, then the new list will copy the ''link'' to the original items. Both the old and new lists will point to the same data, and changing one will change the other. To avoid this, see the [[HPL2/HPL2_Helper_Scripts/Lists#Copy.28.29|Copy()]] method.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListFloat myFirstList = cListFloat(myArray);			// Makes a new float list by copying items from the float array.&lt;br /&gt;
cListFloat mySecondList = myFirstList;					// Makes a new float list containing the same items as the other list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat(float afSingleFloat)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
All the derived list classes ('''except for cListGeneric and cListInt''') can be initialised with data by passing a single value of the relevant type, to become the first item in the list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat myList = cListFloat(1.2f);				// Makes a new float list with a single value.&lt;br /&gt;
myList.Add(2.3f);									// myList now contains: 1.2f, 2.3f&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
'''All list classes''' provide the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Count====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Count&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Count returns the current number of items in the list.&lt;br /&gt;
(The property Length and the method length() are provided for consistency with arrays, and are both equivalent to Count.)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat myList;&lt;br /&gt;
uint ulCountA = myList.Count;&lt;br /&gt;
myList.Add(99.99f);&lt;br /&gt;
uint ulCountB = myList.Count;&lt;br /&gt;
// ulCountA is 0. ulCountB is 1.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (listNumbers.Count &amp;lt; 6) listNumber.Add(42);&lt;br /&gt;
// The condition succeeds if the count is less than 6, and another number is added.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the last valid index, or -1 if the list is empty.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
uint ulA = myListOfStrings.LastIndex;&lt;br /&gt;
uint ulB = myListOfStrings.Count - 1;&lt;br /&gt;
// ulA and ulB are equal&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string sLatest = myListOfStrings[myListOfStrings.LastIndex];&lt;br /&gt;
// sLatest becomes whatever string was added to the list most recently.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Capacity====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Capacity&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Capacity returns the maximum count of items in the list. This will be the default limit, unless one was specified on construction.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt someList;&lt;br /&gt;
someList.Add(1);&lt;br /&gt;
uint spaceRemaining = someList.Capacity - someList.Count;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsEmpty====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEmpty&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsEmpty returns true if the list is empty, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (myList.IsEmpty) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list contains no items.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsFull====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsFull&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsFull returns true if the list is full to its maximum capacity, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (!myList.IsFull) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list has space for another item.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====DefaultValue====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int DefaultValue&lt;br /&gt;
float DefaultValue&lt;br /&gt;
double DefaultValue&lt;br /&gt;
bool DefaultValue&lt;br /&gt;
string DefaultValue&lt;br /&gt;
cVector DefaultValue&lt;br /&gt;
cPoint DefaultValue&lt;br /&gt;
cRotator DefaultValue&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only property DefaultValue returns the value that this list type uses as a default. The default value is defined by each list class and used instead of a null item. (e.g.: -1, 0.0f, false, &amp;quot;&amp;quot;)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
someItem = myList.Pop();&lt;br /&gt;
if (someItem == myList.DefaultValue) Debug.Message(1, &amp;quot;Nothing left to pop!&amp;quot;);&lt;br /&gt;
// The condition succeeds if item returned from the list was the default item, probably because the list was empty.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Assignment====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase = cListBase&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The assignment operator (equals sign &amp;quot;=&amp;quot;) assigns a new set of data to the list, copied from another list. Note: the list contains handles to the data, not the data itself. So when a list is copied, ''both'' lists now refer to the same data, and any changes made to either will affect both.&lt;br /&gt;
&amp;lt;br&amp;gt;If the intent is to make a duplicate of the ''data'' rather than the list handles, then the Copy() method is recommended.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Equality===&lt;br /&gt;
&lt;br /&gt;
The logical equality operator (double equals sing &amp;quot;==&amp;quot;) can be used to compare two lists of the same type, just like with other values. It will return true if the lists contain the same number of items and the coresponding data items in the lists have equal values, or if the two lists both point to the same data.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB;&lt;br /&gt;
listA.Add(&amp;quot;four&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;five&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;size&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listC = listB;&lt;br /&gt;
&lt;br /&gt;
bool test1 = listA == listB;&lt;br /&gt;
bool test2 = listB == listC;&lt;br /&gt;
// test1 will be false because listA and listB contain values that are not equal.&lt;br /&gt;
// test2 will be true because listB and listC both point to the same items.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for assigning items to the list:&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(int alItem)&lt;br /&gt;
bool Add(float afItem)&lt;br /&gt;
bool Add(double adItem)&lt;br /&gt;
bool Add(bool abItem)&lt;br /&gt;
bool Add(string asItem)&lt;br /&gt;
bool Add(cVector avItem)&lt;br /&gt;
bool Add(cPoint avItem)&lt;br /&gt;
bool Add(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Creates a new item appended to the list. If the list is full or the item cannot be added, it returns false. If it was successfull appended, it returns true.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfFloats.Add(1.0f);&lt;br /&gt;
myListOfPoints.Add(cPoint(10, 15, 20));&lt;br /&gt;
// The new values are appended to the list.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!listNumbers.Add(-1.0f)) Debug.Message(1, &amp;quot;Error - could not add to list!&amp;quot;);&lt;br /&gt;
// The condition succeeds if Add failed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Set()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Set(uint aulIndex, int alItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, float afItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, double adItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, bool abItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, string asItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, cVector avItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, cPoint avItem, bool abExtend = true)&lt;br /&gt;
bool Set(uint aulIndex, cRotator avItem, bool abExtend = true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to an indexed item in the list.&lt;br /&gt;
&amp;lt;br&amp;gt;abExtend is optional. If the given index is not valid and abExtend is omitted or true, then the list will be extended to fit the new index, using Extend() with default values. If the given index is not valid and abExtend is false, then the item will not be set.&lt;br /&gt;
&amp;lt;br&amp;gt;Set() returns true if the item was succesfully set. If the item could not be set or if the list could not be extended to fit it, Set() returns false.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be changed.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be assigned.&lt;br /&gt;
#''bool abExtend'' - Whether to extend the list to fit the new item, if necessary. '''(Optional, default = true)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfBools.Set(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, replacing the previous one.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListString myListOfStrings;&lt;br /&gt;
myListOfInts.Set(3, &amp;quot;three&amp;quot;);&lt;br /&gt;
myListOfInts.Set(6, &amp;quot;six&amp;quot;, true);&lt;br /&gt;
myListOfInts.Set(10, &amp;quot;ten&amp;quot;, false);&lt;br /&gt;
// Setting &amp;quot;three&amp;quot; and &amp;quot;size&amp;quot; succeeded by extending the list.&lt;br /&gt;
// Setting &amp;quot;ten&amp;quot; failed because index 10 does not exist, and abExtend is false.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Extend()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Extend(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If given index is not valid, then Extend() adds default items (e.g.: -1, 0.0f, false, &amp;quot;&amp;quot;) until the last valid index becomes the given index. Returns false if the list could not be extended to the specified index.&lt;br /&gt;
#''uint aulIndex'' - The index which become the new last index, if higher.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString twentyEmptyStrings;&lt;br /&gt;
twentyEmptyStrings.Extend(19);&lt;br /&gt;
// twentyEmptyStrings now contains... twenty empty strings.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Insert()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Insert(uint aulIndex, int alItem)&lt;br /&gt;
bool Insert(uint aulIndex, float afItem)&lt;br /&gt;
bool Insert(uint aulIndex, double adItem)&lt;br /&gt;
bool Insert(uint aulIndex, bool abItem)&lt;br /&gt;
bool Insert(uint aulIndex, string asItem)&lt;br /&gt;
bool Insert(uint aulIndex, cVector avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cPoint avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Inserts a new item into the list at the given index. (The item previous at that index becomes the next one.) If the given index is not a valid place to insert an item, then then return value will be false. Otherwise the item is inserted and it returns true.&lt;br /&gt;
#''uint aulIndex'' - The index where the new item will be inserted.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be inserted.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfBools.Insert(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, displacing the previous one to index 8.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!myList.Insert(10, &amp;quot;hello&amp;quot;) myList.Add(&amp;quot;hello&amp;quot;);&lt;br /&gt;
// Attempts to insert the string at index 10, and if that fails the string is appended instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Concatenate()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Concatenate(cListBase aList)&lt;br /&gt;
bool Concatenate(int[] alArray)&lt;br /&gt;
bool Concatenate(float[] afArray)&lt;br /&gt;
bool Concatenate(double[] adArray)&lt;br /&gt;
bool Concatenate(bool[] abArray)&lt;br /&gt;
bool Concatenate(string[] asArray)&lt;br /&gt;
bool Concatenate(cVector[] avArray)&lt;br /&gt;
bool Concatenate(cPoint[] avArray)&lt;br /&gt;
bool Concatenate(cRotator[] avArray)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Takes either a second list or array of the same type and appends it to this one. It first checks to make sure there is enough capacity. Returns true if items were successfully added, or false if not.&lt;br /&gt;
&amp;lt;br&amp;gt;If an array is supplied, new list items are created to match them. If a list is suplied the items are '''not duplicated''' - both lists refer to the same items in memory, and changing them will change both lists.&lt;br /&gt;
#''cListBase aList (or any list type), or an array of int[], float[], double[], bool[], string[], cVector[], cPoint[] or cRotator[]'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
float[] arrayOfFloatsB = { 3.0f, 4.0f };&lt;br /&gt;
listOfFloatsA.Concatenate(arrayOfFloatsB);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 4.0f.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfFloatsB;&lt;br /&gt;
listOfFloatsB.Add(3.0f);&lt;br /&gt;
listOfFloatsB.Add(4.0f);&lt;br /&gt;
&lt;br /&gt;
listOfFloatsA.Concatenate(listOfFloatsB);&lt;br /&gt;
listOfFloatsA.Set(3, 99.9f);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 99.9f.&lt;br /&gt;
// listOfFloatsB now contains 3.0f, 99.9f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for retrieving items from the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Get()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Get(uint aulIndex)&lt;br /&gt;
float Get(uint aulIndex)&lt;br /&gt;
double Get(uint aulIndex)&lt;br /&gt;
bool Get(uint aulIndex)&lt;br /&gt;
string Get(uint aulIndex)&lt;br /&gt;
cVector Get(uint aulIndex)&lt;br /&gt;
cPoint Get(uint aulIndex)&lt;br /&gt;
cRotator Get(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, if it exists. If the item does not exist in the list, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;br&amp;gt;See GetIfValid() if you want to be sure the item exists. You can also use an index operator (e.g. myList[i]) to get list items.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);&lt;br /&gt;
string myStringLast = myToDoList.Get(myToDoList.LastIndex);&lt;br /&gt;
// myStringZero becomes the value from the start of the list.&lt;br /&gt;
// myStringLast becomes the value that happens to be at the end of the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIfValid()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GetIfValid(uint aulIndex, int &amp;amp;out alTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, float &amp;amp;out afTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, double &amp;amp;out adTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, bool &amp;amp;out abTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, string &amp;amp;out asTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cVector &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cPoint &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cRotator &amp;amp;out avTarget)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, as long as it is valid.&lt;br /&gt;
&amp;lt;br&amp;gt;The second parameter is an ''ouput'' parameter. If the item at the given index exists then '''the item is assigned to the Target &amp;amp;out parameter''', and the function returns true. If the item doesn't exist in the list, the function returns false.&lt;br /&gt;
&amp;lt;br&amp;gt;See Get() if you don't care about validation and just want to return the item.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
#''int alTarget, float afTarget, double adTarget, bool abTarget, string asTarget, cVector avTarget, cPoint avTarget, or cRotator avTarget'' - The variable, of the appropriate type, where the retrieved item will be '''stored'''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int retrievedInteger;&lt;br /&gt;
if(!myListOfInts.GetIfValid(3, retrievedInteger)) retrievedInteger = -1;&lt;br /&gt;
// retrievedInteger will be assigned the value retrieved from index 3 in the list, if it exists.&lt;br /&gt;
// If it doesn't exist, the condition will succeed and retrievedInteger with be assigned -1 instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetRandom()&lt;br /&gt;
float GetRandom()&lt;br /&gt;
double GetRandom()&lt;br /&gt;
bool GetRandom()&lt;br /&gt;
string GetRandom()&lt;br /&gt;
cVector GetRandom()&lt;br /&gt;
cPoint GetRandom()&lt;br /&gt;
cRotator GetRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list and returns it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pop()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Pop()&lt;br /&gt;
float Pop()&lt;br /&gt;
double Pop()&lt;br /&gt;
bool Pop()&lt;br /&gt;
string Pop()&lt;br /&gt;
cVector Pop()&lt;br /&gt;
cPoint Pop()&lt;br /&gt;
cRotator Pop()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the last item in the list, and removes that item. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lA = listNumbers.Pop();&lt;br /&gt;
int lB = listNumbers.Pop();&lt;br /&gt;
int lC = listNumbers.Pop();&lt;br /&gt;
// lA, lB, and lC have become 23, 16, and 15. myArray now contains only 4 and 8.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PopRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int PopRandom()&lt;br /&gt;
float PopRandom()&lt;br /&gt;
double PopRandom()&lt;br /&gt;
bool PopRandom()&lt;br /&gt;
string PopRandom()&lt;br /&gt;
cVector PopRandom()&lt;br /&gt;
cPoint PopRandom()&lt;br /&gt;
cRotator PopRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list, returns it and them removes it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors, and that value is no longer available in the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Copy()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt Copy(cListInt aList)&lt;br /&gt;
cListFloat Copy(cListFloat aList)&lt;br /&gt;
cListDouble Copy(cListDouble aList)&lt;br /&gt;
cListBool Copy(cListBool aList)&lt;br /&gt;
cListVector Copy(cListVector aList)&lt;br /&gt;
cListPoint Copy(cListPoint aList)&lt;br /&gt;
cListRotator Copy(cListRotator aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a new list that is a duplicate of this list. The items in the new list are new items. Changing either list will not affect the other.&lt;br /&gt;
#''cListBase aList (or any list type)'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Removing list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for removing items from the list: (See also: Pop() and PopRandom())&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAt(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and removes the given index.&lt;br /&gt;
Returns true if the index was valid and was removed, or false if not.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myList.RemoveAt(7);&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (myList.RemoveAt(7)) myList.Append(&amp;quot;something new&amp;quot;);&lt;br /&gt;
// If the removal was successful, then a new value is appended.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveItem(int alItem)&lt;br /&gt;
bool RemoveItem(float afItem)&lt;br /&gt;
bool RemoveItem(double adItem)&lt;br /&gt;
bool RemoveItem(bool abItem)&lt;br /&gt;
bool RemoveItem(string asItem)&lt;br /&gt;
bool RemoveItem(cVector avItem)&lt;br /&gt;
bool RemoveItem(cPoint avItem)&lt;br /&gt;
bool RemoveItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and removes the first matching item it finds. Returns true if the item was found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
myListOfBools.RemoveItem(false);&lt;br /&gt;
// The first instance of false in the list will be removed.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
int  lRemoved = 0;&lt;br /&gt;
int[] myArray = { 4, 8, 0, 15, 16, 0, 23, 0 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
while (listNumbers.Remove(0))&lt;br /&gt;
{&lt;br /&gt;
    lRemoved++;&lt;br /&gt;
	DoStuff();&lt;br /&gt;
}&lt;br /&gt;
// The Remove() call will repeat until it returns false, at which point the value of lRemoved will be 3.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAll()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAll(int alItem)&lt;br /&gt;
bool RemoveAll(float aItem)&lt;br /&gt;
bool RemoveAll(double aItem)&lt;br /&gt;
bool RemoveAll(bool aItem)&lt;br /&gt;
bool RemoveAll(string aItem)&lt;br /&gt;
bool RemoveAll(cVector aItem)&lt;br /&gt;
bool RemoveAll(cPoint aItem)&lt;br /&gt;
bool RemoveAll(cRotator aItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and removes the all matching items. Returns true if any items were found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
myListOfFloats.RemoveAll(0.0f);&lt;br /&gt;
// All the zeros will be removed from the list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Searching lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for searching for items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Find()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Find(int alItem)&lt;br /&gt;
int Find(float afItem)&lt;br /&gt;
int Find(double adItem)&lt;br /&gt;
int Find(bool abItem)&lt;br /&gt;
int Find(string asItem)&lt;br /&gt;
int Find(cVector avItem)&lt;br /&gt;
int Find(cPoint avItem)&lt;br /&gt;
int Find(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns the index of the first match. If the item is not found, -1 is returned instead.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
uint lIndexTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
uint lIndexFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// lIndexTwentyTwo becomes 1. lIndexFortyFour becomes -1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Contains()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Contains(int alItem)&lt;br /&gt;
bool Contains(float afItem)&lt;br /&gt;
bool Contains(double adItem)&lt;br /&gt;
bool Contains(bool abItem)&lt;br /&gt;
bool Contains(string asItem)&lt;br /&gt;
bool Contains(cVector avItem)&lt;br /&gt;
bool Contains(cPoint avItem)&lt;br /&gt;
bool Contains(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns true if found, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
bool bHasTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
bool bHasFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// bHasTwentyTwo becomes true. bHasFortyFour becomes false.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CountItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint CountItem(int alItem)&lt;br /&gt;
uint CountItem(float afItem)&lt;br /&gt;
uint CountItem(double adItem)&lt;br /&gt;
uint CountItem(bool abItem)&lt;br /&gt;
uint CountItem(string asItem)&lt;br /&gt;
uint CountItem(cVector avItem)&lt;br /&gt;
uint CountItem(cPoint avItem)&lt;br /&gt;
uint CountItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and returns the number of matches found.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myListOfStrings;&lt;br /&gt;
myListOfStrings.Add(&amp;quot;up&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;sideways&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
int lNumDown = myListOfStrings.CountItem(&amp;quot;down&amp;quot;);&lt;br /&gt;
int lNumForward = myListOfStrings.CountItem(&amp;quot;forward&amp;quot;);&lt;br /&gt;
// lNumDown becomes 2. lNumForward becomes 0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Numeric lists===&lt;br /&gt;
Some of the derived list classes dealing with numeric values provide the methods for arithmetic operations across the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Min()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Min()&lt;br /&gt;
float Min()&lt;br /&gt;
double Min()&lt;br /&gt;
bool Min()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns false if there is a false - like logical AND over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fSmallest = fRandomList.Min();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the smallest is assigned to fSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Max()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Max()&lt;br /&gt;
float Max()&lt;br /&gt;
double Max()&lt;br /&gt;
bool Max()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - like logical OR over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fLargest = fRandomList.Max();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the largest is assigned to fLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMin()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMin()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lSmallest = fRandomList.FindMin();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the smallest is assigned to lSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMax()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMax()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lLargest = fRandomList.FindMax();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the largest is assigned to lLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sum()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Sum()&lt;br /&gt;
float Sum()&lt;br /&gt;
double Sum()&lt;br /&gt;
bool Sum()&lt;br /&gt;
cVector Sum()&lt;br /&gt;
cPoint Sum()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the total of all the items in the list, added together. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - the same as logical OR. For vectors, this is equivalent to the combined path of each vector.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lTot = listNumbers.Sum();&lt;br /&gt;
// lTot becomes 108.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListPoint listGridSteps;&lt;br /&gt;
listGridSteps.Add(cPoint(1, 0));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(-1, 0));&lt;br /&gt;
&lt;br /&gt;
cPoint vFinalPos = listGridSteps.Sum()&lt;br /&gt;
// This example imagines a puzzle involving steps on a grid. Each step is stored in a list of points and the final position is the sum of the list. (0,2 in this case.)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Average()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Average()&lt;br /&gt;
float Average()&lt;br /&gt;
double Average()&lt;br /&gt;
bool Average()&lt;br /&gt;
cVector Average()&lt;br /&gt;
cPoint Average()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the mean average of all the items in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that for ints, the answer will be truncated. For bools, this basically returns true if there are more true items than false. For vectors this is like finding the &amp;quot;centre of balance&amp;quot; of some points.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lAvg = listNumbers.Average();&lt;br /&gt;
// lAvg becomes 18.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListVector listGruntPos;&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt1&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt2&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt3&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
SetEntityPosVec(&amp;quot;orb&amp;quot;, listGruntPos.Average());&lt;br /&gt;
// This example imagines an effect where an entity is positioned at the mid-point between 3 enemies.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Ordering lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for ordering items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Swap()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Swap(uint aulA, uint aulB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Swaps the places of two items in the array. Returns false if either of the indeces are invalid, or true if the swap went ahead.&lt;br /&gt;
#''uint aulA'' - The index of the first item to be swapped.&lt;br /&gt;
#''uint aulB'' - The index of the second item to be swapped.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Swap(0, 1);&lt;br /&gt;
myListOfInts.Swap(1, 2);&lt;br /&gt;
// After the two swaps, the list is in numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sort()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Sort(abDescending = false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Re-orders a list of numbers, to put them in numerical order, using bubble sort. Bubble sort is simple but inefficient, so sorting large lists very frequently will have a performance impact. cListInt, cListFloat, cListDouble, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For vectors, the list will be sorted by square length.&lt;br /&gt;
#''bool abDescending (optional, default = false)'' - If true, the items will be ordered highest-to-lowest, otherwise lowest-to-highest.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Sort();&lt;br /&gt;
// The list is now sorted into ascending numerical order.&lt;br /&gt;
myListOfInts.Sort(true);&lt;br /&gt;
// The list is now sorted into descending numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Shuffle()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Shuffle()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Changes the order of the list to a new, random order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
for (int i = 1; i &amp;lt;= 10; i++) myListOfInts.Add(i);&lt;br /&gt;
myListOfInts.Shuffle();&lt;br /&gt;
// The list now contains the numbers 1 to 10, in a random order with no repetition or missing numbers.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Converting lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for converting lists into other types of collections:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int[] ToArray()&lt;br /&gt;
float[] ToArray()&lt;br /&gt;
double[] ToArray()&lt;br /&gt;
string[] ToArray()&lt;br /&gt;
cVector[] ToArray()&lt;br /&gt;
cPoint[] ToArray()&lt;br /&gt;
cRotator[] ToArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes a new array, where each element in the array is a copy of an item from the list, and returns the array.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] ToStringArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes a new array, where each element in the array is a string version of each item in the list, and returns the array. (Uses the ToString() method of each node class.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a new string representing the whole list, by getting string versions of each item in the list and joining them. (Uses the ToString() method of each node class, and the Join() method of cString.) (Coming soon, this entry is a placeholder!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Node classes=&lt;br /&gt;
The node classes contain the actual items in the lists and provide ways to access the data or links between nodes. Generally, it is '''not recommended''' to work with these directly, but use the functions of the list classes instead. More '''advanced users''' can extend the cListNodeBase class, or any class, and use it with cListGeneric.&lt;br /&gt;
&lt;br /&gt;
Available node classes: &amp;lt;code&amp;gt;cListNodeInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodePoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Behaviours===&lt;br /&gt;
In the derived node classes, the default constructor creates a node with a default item, or an argument can be provided to set the initial value. For example, in the cListNodeInt class:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeInt() 					// Creates an int node with value 0.&lt;br /&gt;
cListNodeInt(int alItem)		// Creates an int node with value alItem.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Properties===&lt;br /&gt;
All dervied node classes have one public property, named Item:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Item&lt;br /&gt;
float Item&lt;br /&gt;
double Item&lt;br /&gt;
bool Item&lt;br /&gt;
string Item&lt;br /&gt;
cVector Item&lt;br /&gt;
cPoint Item&lt;br /&gt;
cRotator Item&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The property Item can get or set the data item in the node, using the appropriate type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNext(cListNodeBase@ ahNext)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a handle to the next node. To break the link, assign null or use ClearNext().&lt;br /&gt;
#''cListNodeBase@ ahNext'' - A handle to an instance of cListNodeBase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeBase@ GetNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ClearNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Resets the handle to the next node to null&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Vectors&amp;diff=6783</id>
		<title>HPL2/HPL2 Helper Scripts/Vectors</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Vectors&amp;diff=6783"/>
		<updated>2024-02-11T01:46:05Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Vectors.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;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_Vectors.hps&amp;quot; adds support for various vector classes. For beginners or other people not familiar with classes, this is best thought of as new variable types.&lt;br /&gt;
&lt;br /&gt;
At its simplest, vector is a type holds multiple numbers, and is usually used to represent spatial co-ordinates or movement. Some advantages to using a vector over individual numbers is that you can pass the vector as a single argument, or use it in arithmetic as if it was single scalar number. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1 - The basic way:&lt;br /&gt;
float fSpeedX = 1.5f;&lt;br /&gt;
float fSpeedY = 0.0f;&lt;br /&gt;
float fSpeedZ = 0.75f;&lt;br /&gt;
float fCurrentX = GetEntityPosX(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
float fCurrentY = GetEntityPosY(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
float fCurrentZ = GetEntityPosZ(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
SetEntityPos(&amp;quot;myEntity&amp;quot;, fCurrentX + (fSpeedX * afStep), fCurrentY + (fSpeedY * afStep), fCurrentZ + (fSpeedZ * afStep));&lt;br /&gt;
&lt;br /&gt;
// Example 2 - The Helper Scripts way:&lt;br /&gt;
cVector vSpeed = new cVector(1.5f, 0.0f, 0.75f);&lt;br /&gt;
cVector vCurrent = GetEntityPosVec(&amp;quot;myEntity&amp;quot;);&lt;br /&gt;
SetEntityPosVec(&amp;quot;myEntity&amp;quot;, vCurrent + (vSpeed * afStep));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These two examples have the same effect, but with much simpler code.&lt;br /&gt;
&lt;br /&gt;
Various methods are provided, in both the vector classes and in Math, for working with vectors; for example, to find out the length of a line, working out rotations, plotting paths and more.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Vector types===&lt;br /&gt;
Available vector classes:&lt;br /&gt;
&amp;lt;code&amp;gt;cVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cPoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cRotator&amp;lt;/code&amp;gt;,  &amp;lt;code&amp;gt;cBezier&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cSpline&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
Declare a vector like any other variable, and use its various properties, operations and methods list on this page to work with it. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector myVector;			// Declares a new cVector, called myVector. By default it's a 3d vector.&lt;br /&gt;
cVector my2dVector(2);		// Declares a new cVector, set up to have 2 dimensions.&lt;br /&gt;
cVector myVector.X = 2.0f;	// Assigns the value 2.0f to the X component of myVector.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cPoint and cRotator classes work similarly. (A cPoint is a vector containing integers instead of floats, and a cRotator is a vector intended for working with pitch-yaw-roll rotations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Component properties===&lt;br /&gt;
The simplest way to access the components of a 2d or 3d vector is through the named properties. A 2d or 3d cVector provides X and Y, or X, Y and Z properties. cRotator has Pitch, Yaw and Roll. See the notes below for more details on each class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Indices===&lt;br /&gt;
Like arrays, you can ''get'' the items in the vector using an index operator, e.g. myVector[0], myVector[1], myVector[2] are the same as the X, Y and Z properties. However, ''unlike arrays'', this is '''read-only'''.&lt;br /&gt;
&lt;br /&gt;
(This seems to be because the version of AngelScript used in HPL2 seems to only allow the index operator to ''get'' and not ''set''. If I'm wrong and you can make this work, let me know!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
cRotator inherits from cVector. Advanced users who want to make their own derived vector types are advised to read over the cVector definition and derived class definitions to see how they inherit.&lt;br /&gt;
&lt;br /&gt;
cVector and cPoint can both be used for 2d or 3d vectors. The vector classes are designed to be agnostic of dimensionality. The maximum number of dimensions for all vector classes is defined by ulVectorDimMax. The default value is 16, but an advanced user may want to edit that value. cVector and it's derived classes can have any number of dimensions from 0 to, in theory, 65535, although either extreme would be ridiculous. Using a maximum larger than 65535 could cause problems.&lt;br /&gt;
&lt;br /&gt;
Arithmetic, and some methods, can work with differently dimensioned vectors. For example &amp;lt;code&amp;gt;a[X,Y,Z] + b[X,Y]&amp;lt;/code&amp;gt; has the same effect as &amp;lt;code&amp;gt;a[X,Y,Z] + b[X,Y,0]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cVector=&lt;br /&gt;
The cVector class defines a type that contains a series of float values, typically used to represent a spatial location or movement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cVectors are declared similarly to a data type variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector myVector;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default constructor makes an empty 3d vector:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector myVector;						// Makes a 3d vector&lt;br /&gt;
cVector myVector = cVector();			// Makes a 3d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
You can make an empty vector with a specific dimension (the number of components) by passing an integer to the constructor:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	cVector myVector = cVector(3);		// Makes a 3d vector&lt;br /&gt;
&lt;br /&gt;
	cVector myVector = cVector(2);		// Makes a 2d vector&lt;br /&gt;
	cVector myVector = cVector(4);		// Makes a 4d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A vector can be initialised with any number dimension up to ulVectorDimMax (default 16).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
cVector provides the following public properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====X====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property X provides access to the first component in the cVector (provided it has at least one component).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.X;&lt;br /&gt;
vMyVector.X = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Y====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Y&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property Y provides access to the second component in the cVector (provided it has at least two components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.Y;&lt;br /&gt;
vMyVector.Y = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Z====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Z&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property Z provides access to the third component in the cVector (provided it has at least three components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.Z;&lt;br /&gt;
vMyVector.Z = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====W====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float W&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float property W provides access to the fourth component in the cVector (provided it has at least four components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.W;&lt;br /&gt;
vMyVector.W = 1.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dimension====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Dimension&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Dimension returns the number of components in the cVector. The dimension of the cVector can be set by the constructor or, see also: Resize().&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (vMyVector.Dimension &amp;gt;=3) vMyVector.Z = 0.0f;&lt;br /&gt;
// The condition succeeds if the cVector has at least three components, and then the value of the 3rd component is assigned 0.0f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the index of the last component in the cVector. This is the same as Dimension - 1.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float fMyFloat = vMyVector[vMyVector.LastIndex];&lt;br /&gt;
// The float fMyFloat is assigned whatever value is found in the final component of the cVector.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some '''arithmetic''' operators have been implemented for '''a cVector with another cVector''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  =  +=  -= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional '''arithmetic''' operators have been implemented for '''a cVector with a float''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  *  /  +=  -=  *=  /= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''multiplication''' operator &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; used with a cVector on another cVector will return the '''dot product''' of the two vectors, as a float.&lt;br /&gt;
&lt;br /&gt;
The '''equality''' operator &amp;lt;code&amp;gt; == &amp;lt;/code&amp;gt; checks for an exact match between two cVectors. '''Comparison''' operators &amp;lt;code&amp;gt; &amp;gt; &amp;gt;= &amp;lt; &amp;lt;= &amp;lt;/code&amp;gt; compare the '''square length''' of the vectors.&lt;br /&gt;
&lt;br /&gt;
The '''index''' operator &amp;lt;code&amp;gt; myVector[i] &amp;lt;/code&amp;gt; allows read-only access to the vector's components by index.&lt;br /&gt;
&lt;br /&gt;
The '''assignment''' operator &amp;lt;code&amp;gt; = &amp;lt;/code&amp;gt; assigns a new value by duplicating the components. This may also '''resize''' the dimension of the vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting values===&lt;br /&gt;
cVector provides the following methods for assigning values to the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetIndex(uint aulIndex, float afValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to a component by index. E.g., the X component is at index 0, Y is index 1, etc.. Returns false if index is outside of the dimension of the vector, or true if it was successfully set.&lt;br /&gt;
#''uint aulIndex'' - The index to set with a new value.&lt;br /&gt;
#''float afValue'' - The value to set at the index.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyVector.SetIndex(1, 3.0f);&lt;br /&gt;
vMyVector.Y = 3.0f;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir2d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir2d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cVector into a 2d vector pointing in that direction.&lt;br /&gt;
&lt;br /&gt;
Uses typical screen coordinate directions, where up is -y, right is +x. If forward is given then that is considered to be right (+x).&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyVector.SetDir2d(dirLeft);&lt;br /&gt;
// vMyVector becomes -1,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir3d====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir3d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cVector into a 3d vector pointing in that direction. &lt;br /&gt;
&lt;br /&gt;
Uses HPL2's &amp;quot;right-handed, x=left&amp;quot; coordinate system, so the forward direction is considered to be 0,0,1. Right is -1,0,0 and up is 0,1,0.&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyVector.SetDir3d(dirLeft);&lt;br /&gt;
// vMyVector becomes 1,0,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting values===&lt;br /&gt;
cVector provides the following method for retrieving values from the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetIndex(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves a component by index. E.g., the X component is at index 0, Y is index 1, etc.&lt;br /&gt;
#''uint aulIndex'' - The index whose value to get.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyVector.GetIndex(2);&lt;br /&gt;
fMyFloat = vMyVector.Z;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Length===&lt;br /&gt;
cVector provides the following methods for working with vector length:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Length()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Length()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the euclidean length of the vector as a float. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cVector vMyRectangle = cVector(10.0f, 15.0f);&lt;br /&gt;
float fMyHypotenuse = vMyRectangle.Length();&lt;br /&gt;
// fMyHypotenuse becomes the length of the diagonal line across a rectangle 10m by 15m.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LengthSqr()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float LengthSqr()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the squared length of the vector, which can be more efficient than calculating the actual length in some use cases, e.g. when you only need to compare two lengths without knowing the exact values. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool bIsVecALonger = vVecA.LengthSqr() &amp;gt; vVecB.LengthSqr();&lt;br /&gt;
// bIsVecALonger becomes true if vVecA is longer than vVecB, without calculating the final lengths.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normal()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector Normal()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Calculates the normal of this vector and returns it as a copy. This vector is not changed. The normal vector points in the same direction, but has a length of one.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection.Normal() * fSpeed;&lt;br /&gt;
// If vDirection is a vector of unknown length pointing in some direction, this would set vVelocity to be a vector pointing in the same direction, but with a length of exactly fSpeed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normalize()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Normalize()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Normalizes a vector in place. This vector becomes the normal vector, and the original values are forgotten. The normal vector points in the same direction, but has a length of one.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection;&lt;br /&gt;
vVelocity.Normalize(); // Length of vVelocity has now become 1.&lt;br /&gt;
vVelocity *= 3.0f;&lt;br /&gt;
// This example has the same result as the previous one, for Normal().&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Strings from cVector===&lt;br /&gt;
cVector provides the following methods for converting vectors to strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 2, the format &amp;quot;(x=_, y=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 3, the format &amp;quot;(x=_, y=_, z=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 0, the string &amp;quot;empty cVector&amp;quot; is returned.&lt;br /&gt;
&amp;lt;br&amp;gt;For any other dimension, ToStringAsIndices() is called instead.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringAsIndices()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToStringAsIndices()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string, in the format &amp;quot;([0]=_, [1]=_, [2]=_ ...)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced===&lt;br /&gt;
The following methods exist for advanced users and should be used with caution:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Resize(uint aulNewDim)		// Changes the dimension of the vector.&lt;br /&gt;
bool Append(float afValue)		// Increases the dimension of this cVector by one, and adds the given float as a new component.&lt;br /&gt;
bool Append(cVector avValues)	// Increases the dimension of this cVector to accomodate the given cVector, and appends its components.&lt;br /&gt;
const float[]@ ReadArray()		// Returns a handle to the cVector's component array data.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cPoint=&lt;br /&gt;
The cPoint class defines a vector type that contains a series of int values, typically used to represent a location or movement on a grid, or pixels.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cPoints are declared similarly to a data type variable:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cPoint myPoint;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default constructor makes an empty 3d vector:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cPoint myPoint;						// Makes a 3d vector&lt;br /&gt;
cPoint myPoint = cPoint();			// Makes a 3d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
You can make an empty vector with a specific dimension (the number of components) by passing an integer to the constructor:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
	cPoint myPoint = cPoint(3);		// Makes a 3d vector&lt;br /&gt;
&lt;br /&gt;
	cPoint myPoint = cPoint(2);		// Makes a 2d vector&lt;br /&gt;
	cPoint myPoint = cPoint(4);		// Makes a 4d vector&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A vector can be initialised with any number dimension up to ulVectorDimMax (default 16).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
cPoint provides the following public properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====X====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int X&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property X provides access to the first component in the cPoint (provided it has at least one component).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.X;&lt;br /&gt;
vMyPoint.X = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Y====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Y&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property Y provides access to the second component in the cPoint (provided it has at least two components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.Y;&lt;br /&gt;
vMyPoint.Y = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Z====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Z&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property Z provides access to the third component in the cPoint (provided it has at least three components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.Z;&lt;br /&gt;
vMyPoint.Z = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====W====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int W&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property W provides access to the fourth component in the cPoint (provided it has at least four components).&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.W;&lt;br /&gt;
vMyPoint.W = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Dimension====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Dimension&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Dimension returns the number of components in the cPoint. The dimension of the cPoint can be set by the constructor or, see also: Resize().&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (vMyPoint.Dimension &amp;gt;=3) vMyPoint.Z = 0;&lt;br /&gt;
// The condition succeeds if the cPoint has at least three components, and then the value of the 3rd component is assigned 0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the index of the last component in the cPoint. This is the same as Dimension - 1.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int fMyInt = vMyPoint[vMyPoint.LastIndex];&lt;br /&gt;
// The int fMyInt is assigned whatever value is found in the final component of the cPoint.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: the results of division operations with ints maybe truncated. That is, in integer calculations, 1 / 2 = 0.&lt;br /&gt;
&lt;br /&gt;
Some '''arithmetic''' operators have been implemented for '''a cPoint with another cPoint''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  =  +=  -= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional '''arithmetic''' operators have been implemented for '''a cPoint with an int''':&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt; +  -  *  /  +=  -=  *=  /= &amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The '''multiplication''' operator &amp;lt;code&amp;gt;*&amp;lt;/code&amp;gt; used with a cPoint on another cPoint will return the '''dot product''' of the two vectors, as a truncated int.&lt;br /&gt;
&lt;br /&gt;
The '''equality''' operator &amp;lt;code&amp;gt; == &amp;lt;/code&amp;gt; checks for an exact match between two cPoints. '''Comparison''' operators &amp;lt;code&amp;gt; &amp;gt; &amp;gt;= &amp;lt; &amp;lt;= &amp;lt;/code&amp;gt; compare the '''square length''' of the vectors.&lt;br /&gt;
&lt;br /&gt;
The '''index''' operator &amp;lt;code&amp;gt; myVector[i] &amp;lt;/code&amp;gt; allows read-only access to the vector's components by index.&lt;br /&gt;
&lt;br /&gt;
The '''assignment''' operator &amp;lt;code&amp;gt; = &amp;lt;/code&amp;gt; assigns a new value by duplicating the components. This may also '''resize''' the dimension of the vector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting values===&lt;br /&gt;
cPoint provides the following methods for assigning values to the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetIndex(uint aulIndex, int alValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to a component by index. E.g., the X component is at index 0, Y is index 1, etc.. Returns false if index is outside of the dimension of the vector, or true if it was successfully set.&lt;br /&gt;
#''uint aulIndex'' - The index to set with a new value.&lt;br /&gt;
#''int alValue'' - The value to set at the index.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyPoint.SetIndex(1, 3);&lt;br /&gt;
vMyPoint.Y = 3;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir2d()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir2d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cPoint into a 2d vector pointing in that direction.&lt;br /&gt;
&lt;br /&gt;
Uses typical screen coordinate directions, where up is -y, right is +x. If forward is given then that is considered to be right (+x).&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyPoint.SetDir2d(dirLeft);&lt;br /&gt;
// vMyPoint becomes -1,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetDir3d====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SetDir3d(enumOrthoDir aDirection)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an enumOrthoDir option, this converts the existing cPoint into a 3d vector pointing in that direction. &lt;br /&gt;
&lt;br /&gt;
Uses HPL2's &amp;quot;right-handed, x=left&amp;quot; coordinate system, so the forward direction is considered to be 0,0,1. Right is -1,0,0 and up is 0,1,0.&lt;br /&gt;
#''enumOrthoDir aDirection'' - Can be dirForward, dirBackward, dirLeft, dirRight, dirUp or dirDown&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vMyPoint.SetDir3d(dirLeft);&lt;br /&gt;
// vMyPoint becomes 1,0,0&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting values===&lt;br /&gt;
cPoint provides the following method for retrieving values from the vector components: (See also: X,Y,Z,W properties)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIndex()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetIndex(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves a component by index. E.g., the X component is at index 0, Y is index 1, etc.&lt;br /&gt;
#''uint aulIndex'' - The index whose value to get.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyInt = vMyPoint.GetIndex(2);&lt;br /&gt;
fMyInt = vMyPoint.Z;&lt;br /&gt;
// These two techniques have the same outcome.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Length===&lt;br /&gt;
cPoint provides the following methods for working with vector length:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Length()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Length()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the euclidean length of the vector as a truncated int. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cPoint vMyRectangle = cPoint(10, 15);&lt;br /&gt;
int lMyHypotenuse = vMyRectangle.Length();&lt;br /&gt;
// lMyHypotenuse becomes the length of the diagonal line across a rectangle 10m by 15m.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LengthSqr()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int LengthSqr()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the squared length of the vector, which can be more efficient than calculating the actual length in some use cases, e.g. when you only need to compare two lengths without knowing the exact values. (See also: Math.Length())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool bIsVecALonger = vVecA.LengthSqr() &amp;gt; vVecB.LengthSqr();&lt;br /&gt;
// bIsVecALonger becomes true if vVecA is longer than vVecB, without calculating the final lengths.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normal()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cPoint Normal()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Calculates the truncated integer normal of this vector and returns it as a copy. This vector is not changed. The normal vector points in the same direction, but has a length of approximately one, while the components remain whole numbers.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection.Normal();&lt;br /&gt;
// If vDirection is a vector of unknown length pointing in some direction, this would set vVelocity to be a vector pointing in the same direction, but with a length of approximately one.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Normalize()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Normalize()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Normalizes a vector in place. This vector becomes the normal vector, and the original values are forgotten. The normal vector points in the same direction, but has a length of approximately one.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
vVelocity = vDirection;&lt;br /&gt;
vVelocity.Normalize(); // Length of vVelocity has now become approximately one.&lt;br /&gt;
vVelocity *= 3.0f;&lt;br /&gt;
// This example has the same result as the previous one, for Normal().&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Strings from cPoint===&lt;br /&gt;
cPoint provides the following methods for converting vectors to strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 2, the format &amp;quot;(x=_, y=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 3, the format &amp;quot;(x=_, y=_, z=_)&amp;quot; is used.&lt;br /&gt;
&amp;lt;br&amp;gt;If the dimension is 0, the string &amp;quot;empty cPoint&amp;quot; is returned.&lt;br /&gt;
&amp;lt;br&amp;gt;For any other dimension, ToStringAsIndices() is called instead.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringAsIndices()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToStringAsIndices()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as a string, in the format &amp;quot;([0]=_, [1]=_, [2]=_ ...)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced===&lt;br /&gt;
The following methods exist for advanced users and should be used with caution:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Resize(uint aulNewDim)		// Changes the dimension of the vector.&lt;br /&gt;
bool Append(float afValue)		// Increases the dimension of this cPoint by one, and adds the given float as a new component.&lt;br /&gt;
bool Append(cPoint avValues)	// Increases the dimension of this cPoint to accomodate the given cPoint, and appends its components.&lt;br /&gt;
const int[]@ ReadArray()		// Returns a handle to the cPoint's component data array.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cRotator=&lt;br /&gt;
The cRotator class defines a type that contains a series of float values, intended to represent an angular orientation, or a rotation. cRotator inherits from cVector, but also defines some properties and methods specific to working with rotation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
There are two ways to assign the pitch, yaw and roll values in the constructor.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
1. The angle values can be set directly in the constructor using degrees or radians. An optional enumAngleUnits is used to specify whether using degrees. The default is radians.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Initialising angles in degrees:&lt;br /&gt;
cRotator(pitchDegrees, yawDegrees, rollDegrees, angleDegrees)&lt;br /&gt;
&lt;br /&gt;
// Initialise the angles in radians&lt;br /&gt;
cRotator(pitchRadians, yawRadians, rollRadians)&lt;br /&gt;
cRotator(pitchRadians, yawRadians, rollRadians, angleRadians)&lt;br /&gt;
&lt;br /&gt;
// These two rotators are equivalent:&lt;br /&gt;
cRotator myDegrees = cRotator(90.0f, 180.0f, 45.0f, true);&lt;br /&gt;
cRotator myRadians = cRotator(Math.Pi, Math.Tau, Math.Pi / 2.0f);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. The angle values can be set in the constructor using an enumOrthoDir option. enumOrthoDir can be dirForward, dirBackward, dirLeft, dirRight, dirUp, or dirDown.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cRotator yawRight = cRotator(dirRight);&lt;br /&gt;
cRotator pitchDown = cRotator(dirDown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
The angle values can be set with the Pitch, Yaw and Roll properties:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
myRotator.Pitch = Math.Pi / 2.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The pitch, yaw and roll properties are treated as radians by default. To specify degrees or radians explicitly, the pitchDeg, yawDeg, rollDeg, and pitchRad, yawRad, rollRad properties can be used, e.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
myRotator.YawDeg = 180;&lt;br /&gt;
myRotator.RollRad = Math.Pi * 3.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Internally the cRotator class stores angle values as radians between negative and positive Pi. (Equivalent to -180 degrees to 180 degrees.) Angles outside of this range are wrapped around. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cRotator rotation = cRotator(0.0f, 90.0f, 0.0f, true);&lt;br /&gt;
rotation += cRotator(0.0f, 120.0f, 0.0f, true);&lt;br /&gt;
// rotation is now (degrees) 0.0f, -150.0f, 0.0f&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this example, &amp;quot;rotation&amp;quot; is initialised with 90d yaw, and then rotated a further &lt;br /&gt;
120d clockwise. Rather than 210d clockwise, the resulting yaw is 150 anti-clockwise (-150);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pitch====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Pitch&lt;br /&gt;
float PitchRad&lt;br /&gt;
float PitchDeg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float properties Pitch and PitchRad provide access to the pitch component in radians. PitchDeg provides access to the pitch component in degrees.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyRotator.Pitch;&lt;br /&gt;
vMyRotator.PitchDeg = 90.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Yaw====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Yaw&lt;br /&gt;
float YawRad&lt;br /&gt;
float YawDeg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float properties Yaw and YawRad provide access to the pitch component in radians. YawDeg provides access to the pitch component in degrees.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyRotator.Yaw;&lt;br /&gt;
vMyRotator.YawDeg = 90.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Roll====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float Roll&lt;br /&gt;
float RollRad&lt;br /&gt;
float RollDeg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The float properties Roll and RollRad provide access to the pitch component in radians. RollDeg provides access to the pitch component in degrees.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
fMyFloat = vMyRotator.Roll;&lt;br /&gt;
vMyRotator.RollDeg = 90.0f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
In addition to methods inherited from cVector, cRotator provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
string ToStringRad()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as radians in a string with the format &amp;quot;(p=_, y=_, r=_)(rad)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringDeg()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToStringDeg()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the vector as degrees in a string with the format &amp;quot;(p=_, y=_, r=_)(deg)&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cBezier=&lt;br /&gt;
&lt;br /&gt;
The cBezier class defines a curved line in space, with a couple of basic functions. Technically it is a cubic bezier defined by 4 points: a start, an end, and two control points for influencing the curve. It can also roughly approximate a quadratic bezier if constructed with only one control point.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cBezier has four constructors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cBezier(cVector avStart, cVector avCtrl1, cVector avCtrl2, cVector avEnd)	// Creates a cubic bezier with two control points.&lt;br /&gt;
cBezier(cVector avStart, cVector avCtrl, cVector avEnd)						// Creates bezier approximating a quadratic bezier.&lt;br /&gt;
cBezier(cVector avStart, cVector avEnd)										// Creates a bezier that behaves like a straight line.&lt;br /&gt;
cBezier()																	// Creates a bezier that starts and ends at 0,0,0, with zero length.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Properties:==&lt;br /&gt;
To access the internal vector positions in the bezier, you can use the properties: Start, End, CtrlStart and CtrlEnd.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cBezier manualBezier;&lt;br /&gt;
cVector someLocation = cVector(10.0f, 11.0f, 12.0f);&lt;br /&gt;
manualBezier.Start = someLocation;&lt;br /&gt;
manualBezier.End = someLocation * 1.5f;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Start====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector Start&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property Start can be used to get or set the start point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====End====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector End&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property End can be used to get or set the end point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CtrlStart====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector CtrlStart&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property CtrlStart can be used to get or set the first control point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CtrlEnd====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector CtrlEnd&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The cVector property CtrlEnd can be used to get or set the second control point of the curve with a 3d cVector.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
cBezier provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetPoint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetPoint(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the curve from 0.0f to 1.0f, this returns the position at that point. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' - The time on the curve (0.0 - 1.0) to get the position of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.33f;&lt;br /&gt;
cVector vLocationOnCurve = vMyBezier.GetPoint(vProgressOnCurve);&lt;br /&gt;
// vLocationOnCurve becomes the position in space that is 33% of the journey along the curve.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetTangent()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetTangent(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the curve from 0.0f to 1.0f, this returns a normal vector that approximates the forward direction of the curve at that position. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' -  The time on the curve (0.0 - 1.0) to get the tangent of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.66f;&lt;br /&gt;
cVector vDirectionOnCurve = vMyBezier.GetTangent(vProgressOnCurve);&lt;br /&gt;
// vDirectionOnCurve becomes the forward direction of the curve at the point of 66% through the journey along it.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetApproxLength()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetApproxLength(enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Estimates the approximate length of the curve.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - Can be lengthFinal or lengthSquared. (Optional, default = lengthFinal)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the components of the bezier as a string, including the x,y,z components of all four vector positions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=cSpline=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The cSpline class defines an array of Beziers that can be treated like a continuous path made of multiple curved segments. Internally cSpline is a cBezier array of a fixed maximum size (default = 16). The cSpline can be initialised using existing beziers, or with a single curve defined by args in the constructor.&lt;br /&gt;
&lt;br /&gt;
For further control over how the curve is built, the cSpline can be declare as empty with segments added afterwards. Segments can be added to the spline either as whole cBezier segments using AddSegment(), or by adding one cVector point at a time using AddPoint().&lt;br /&gt;
&lt;br /&gt;
With the AddPoint() method, the spline is defined by providing the positions it should move through as individual points in space. Specific tangents can be provided (forward direction and scale) for each point, but are optional. When the final point is added, abLast should be specified as true to finish the spline and apply automatic tangents where needed. The automatic tangents make sure that path through each point is smooth, unless specific tangents were specified through AddPoint().&lt;br /&gt;
&lt;br /&gt;
Alternatively, with the AddSegment() method, the spline can be defined by providing each segment as a Bezier. The end of the previous segment will be updated to match the new one. (This is not quite the same as passing an array of Beziers to the constructor, as in that case the constructor will not attempt to match the end points, and they will not be smooth or even continuous unless defined that way by the script.)&lt;br /&gt;
&lt;br /&gt;
The spline does not have constant velocity. That is to say, each segment has an equal share of the &amp;quot;time&amp;quot;, regardless of the size of the segment, and within each segment the control points can cause acceleration. Easing can be effected by varying the size of the segments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
cSpline has seven constructors in total, with various options for initialising a curve.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructing empty splines===&lt;br /&gt;
If the cSpline should start empty, ready for AddSegment() or AddPoint(), one of the following constructors should be used:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cSpline()							// Creates an empty spline with a maximum size of 16 bezier segments.&lt;br /&gt;
cSpline(uint aulSegments)			// Creates an empty spline with capacity for the number of bezier segments specified by aulSegments.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructing with cBezier===&lt;br /&gt;
If the cSpline should be populated with one or more existing bezier curves, one of the following constructors should be used:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cSpline(cBezier aSegmentsArray)		// Takes an existing cBezier array and uses that to populate the new spline.&lt;br /&gt;
cSpline(cBezier@ ahBezier)			// Uses a reference to an existing cBezier to populate the new spline with a single segment.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructing with cVector===&lt;br /&gt;
Finally, if the cSpline should be populated a curve or line defined by cVector arguments, one of these constructors will help:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cSpline(cVector avStart, cVector avCtrlStart, cVector avCtrlEnd, cVector avEnd)&lt;br /&gt;
// Takes four vector positions and builds a cubic bezier to populate the new spline with a single segment.&lt;br /&gt;
&lt;br /&gt;
cSpline(cVector avStart, cVector avCtrl, cVector avEnd)&lt;br /&gt;
// Takes three vector positions and builds a approximation of a quadratic bezier to populate the new spline with a single segment.&lt;br /&gt;
&lt;br /&gt;
cSpline(cVector avStart, cVector avEnd)&lt;br /&gt;
// Takes two vector positions and populate the new spline with a single segment in the form of a straight line between two points.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
cBezier provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddSegment()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool AddSegment(cBezier ahSegment, bool abSnap = true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Appends a bezier onto the spline as new segment. Returns false if the spline is already full, or true if it was successfully added.&lt;br /&gt;
&amp;lt;br&amp;gt;abSnap is optional. If omitted, it defaults to true. If abSnap is true then the end point and exit tangent of the previous segment will be adjusted to connect to the start point and entrance tangent of the new one.&lt;br /&gt;
#''cBezier ahSegment'' - A bezier to be appended to the spline.&lt;br /&gt;
#''bool abSnap'' - Whether to adjust the previous segment to connect to the new one. (Optional, default = true)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====UpdateSegment()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool UpdateSegment(uint aulIndex, cBezier ahSegment, bool abSnap = true)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Updates an existing segment by index, replacing it with a new bezier. Returns false if the segment does not already exist, or true if it was successfully updated.&lt;br /&gt;
&amp;lt;br&amp;gt;abSnap is optional. If omitted, it defaults to true. If abSnap is true then the end point and exit tangent of the previous segment, and the start point and entrance tangent of the next segment will be adjusted to connect to the updated segment.&lt;br /&gt;
#''uint aulIndex'' - The index of the segment to be replaced.&lt;br /&gt;
#''cBezier ahSegment'' - A bezier to be replace the bezier at the given index. to the spline.&lt;br /&gt;
#''bool abSnap'' - Whether to adjust the previous and next segments to connect to the updated one. (Optional, default = true)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddPoint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool AddPoint(bool abLast = false, cVector avNextPosition, cVector avNextTangent)&lt;br /&gt;
bool AddPoint(bool abLast = false, cVector avNextPosition)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Appends a position to the end of the spline. Returns false if the spline is already full, or true if it was successfully added.&lt;br /&gt;
&amp;lt;br&amp;gt;avNextTangent is optional and can be omitted. It specifies the tangent as the velocity (direction and scale) of the spline at the new point. If omitted, no tangent is used at this time, but once you have finished adding points, abLast = true should be used and automatic tangents will be applied at that time.&lt;br /&gt;
&amp;lt;br&amp;gt;The automatic tangents are only applied to points where no tangent was given, and only once the spine is marked as &amp;quot;finished&amp;quot; by using abLast = true;&lt;br /&gt;
#''bool abLast'' - Whether this is the last point to be added. (Optional, default = false)&lt;br /&gt;
#''cVector avNextPosition'' - A position in space to add to the spline.&lt;br /&gt;
#''cVector avNextTangent'' - The forward velocity of the spline as it passes through the new position. (Optional, default = auto)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetPoint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetPoint(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the entire spline from 0.0f to 1.0f, this returns the position at that point. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' - The time on the curve (0.0 - 1.0) to get the position of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.33f;&lt;br /&gt;
cVector vLocationOnCurve = vMySpline.GetPoint(vProgressOnCurve);&lt;br /&gt;
// vLocationOnCurve becomes the position in space that is 33% of the journey along the spline.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetTangent()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cVector GetTangent(float afT)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a point on the entire spline from 0.0f to 1.0f, this returns a normal vector that approximates the forward direction of the curve at that position. The float value is known as the &amp;quot;time&amp;quot; on the curve. The velocity is not constant: the control points can cause acceleration in how the movement is calculated.&lt;br /&gt;
#''float afT'' -  The time on the curve (0.0 - 1.0) to get the tangent of.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float vProgressOnCurve = 0.66f;&lt;br /&gt;
cVector vDirectionOnCurve = vMySpline.GetTangent(vProgressOnCurve);&lt;br /&gt;
// vDirectionOnCurve becomes the forward direction of the spline at the point of 66% through the journey along it.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetApproxLength()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetApproxLength(enumLengthType aSquaredOption = lengthFinal)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Estimates the approximate length of the entire spline.&lt;br /&gt;
#''enumLengthType aSquaredOption'' - Can be lengthFinal or lengthSquared. (Optional, default = lengthFinal)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a string describing the spline, including the x,y,z components of its start and end points, and the number of segments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/GameVars&amp;diff=6782</id>
		<title>HPL2/HPL2 Helper Scripts/GameVars</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/GameVars&amp;diff=6782"/>
		<updated>2024-02-11T01:14:01Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_GameVars.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 file &amp;quot;HelperScripts_GameVars.hps&amp;quot; builds on top of the normal saved game global and local variable wrappers, adding the ability to save more variable types to the save game file, including vectors and lists/arrays. &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// The basic way:&lt;br /&gt;
SetLocalVarInt(&amp;quot;myInteger&amp;quot;, 99);&lt;br /&gt;
// The Helper Scripts way:&lt;br /&gt;
GameVars.SetInt(varLocal, &amp;quot;myInteger&amp;quot;, 99);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
GameVars variables work in a similar way to the normal saved game global and local variable wrappers, with three differences:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Scope===&lt;br /&gt;
Firstly, instead of separate functions for local and global variables, GameVars uses an optional argument to specify the scope. Each of the GameVars methods has an optional enumVarScope, which can be either '''varLocal''' or '''varGlobal'''. If omitted, the '''default is scope is global'''. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
GameVars.SetInt(varLocal, &amp;quot;some_number&amp;quot;, 99);		// Does the same thing as SetLocalVarInt(&amp;quot;some_number&amp;quot;, 99);&lt;br /&gt;
GameVars.SetInt(varGlobal, &amp;quot;some_number&amp;quot;, 99);		// Does the same thing as SetGlobalVarInt(&amp;quot;some_number&amp;quot;, 99);&lt;br /&gt;
GameVars.SetInt(&amp;quot;some_number&amp;quot;, 99);					// Does the same thing as SetGlobalVarInt(&amp;quot;some_number&amp;quot;, 99);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The scope could even be used variably, for example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
enumVarScope scopeForRadioMessages = varLocal;&lt;br /&gt;
&lt;br /&gt;
// After interacting with the radio booster:&lt;br /&gt;
scopeForRadioMessages = bRadioBoosterActived ? varGlobal : varLocal;&lt;br /&gt;
&lt;br /&gt;
// On sending a radio message:&lt;br /&gt;
GameVars.SetString(scopeForRadioMessages, &amp;quot;radioMessage&amp;quot;, &amp;quot;SendHelp&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// This example imagines a scenario where the radioMessage state copied to other levels only while the radio booster is active.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Types===&lt;br /&gt;
Secondly, '''additional variable types''' are available. As well as the normal int, float and string game variables, GameVars has methods for storing and retrieving variables as bool, cVector, cPoint and cRotator. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
		GameVars.SetBool(&amp;quot;myBoolean&amp;quot;, true);&lt;br /&gt;
		if (GameVars.GetBool(&amp;quot;myBoolean&amp;quot;))&lt;br /&gt;
		{&lt;br /&gt;
			GameVars.SetVector(&amp;quot;myVector2&amp;quot;, cVector(0.0f, 0.0f));&lt;br /&gt;
		}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Lists===&lt;br /&gt;
And thirdly GameVars can store '''indexed lists''' of variables, in the style of an '''array or linked list'''. For example, SetListInt() can be passed an array of ints or a cListInt. The return value of GetListInt is a cListInt list that can be assigned to a list variable, or used with the index operator directly. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
		bool[] myArrayOfBools = { true, true, false, false, false };&lt;br /&gt;
		GameVars.SetListBool(&amp;quot;myStoredBools&amp;quot;, myArrayOfBools);					// Stores the bools from the array as a game variable list.&lt;br /&gt;
		GameVars.SetListBool(&amp;quot;myStoredBools&amp;quot;, 9, true);							// Sets the value of the bool at index 9 in the stored list.&lt;br /&gt;
		&lt;br /&gt;
		cListString myStringList = GameVars.GetListString(&amp;quot;myStoredStrings&amp;quot;);	// Retrieves the stored list of strings and assigns it to the cListString.&lt;br /&gt;
&lt;br /&gt;
		string aSingleString = GameVars.GetListString(&amp;quot;myStoredStrings&amp;quot;, 3);	// Retrieves the string at index 3 of the stored list and assigns it to the string.&lt;br /&gt;
		string anotherString = GameVars.GetListString(&amp;quot;myStoredStrings&amp;quot;)[3];	// Retrieves the string at index 3 of the stored list and assigns it to the string.&lt;br /&gt;
&lt;br /&gt;
		if (GameVars.GetListBool(varLocal, &amp;quot;myStoredBools&amp;quot;)[0])					// The condition succeeds if the first bool in the stored list is true.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Imporant Note 1: GameVars variable names cannot contain the @ symbol, as it is reserved by GameVars.&lt;br /&gt;
Imporant Note 2: GameVars names cannot be reliably re-used between types.&lt;br /&gt;
If a name is used containing @, or the same name is used for two differently typed GameVars variables, then it might simply not work or it might return erroneous results.&lt;br /&gt;
&lt;br /&gt;
Behind the scenes, GameVars uses one or more ints or floats to store the new types.&lt;br /&gt;
The double and uint types are not provided for, as they could lose precision when stored as floats or int. Use the float and int methods explicitly instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=GameVars=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
&amp;quot;HelperScripts_GameVars.hps&amp;quot; declares an object called '''GameVars''', of the new script class cGameVars. To access its methods, just use &amp;quot;GameVars.&amp;quot; followed by the function call. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
GameVars.SetBool(varLocal, &amp;quot;someBoolean&amp;quot;, false);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
GameVars has no public properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
GameVars provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Single Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Set...()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetInt(enumVarScope aScopeOption, string asName, int alValue)&lt;br /&gt;
void SetFloat(enumVarScope aScopeOption, string asName, float afValue)&lt;br /&gt;
void SetString(enumVarScope aScopeOption, string asName, string asValue)&lt;br /&gt;
void SetBool(enumVarScope aScopeOption, string asName, bool abValue)&lt;br /&gt;
void SetVector(enumVarScope aScopeOption, string asName, cVector avhValue)&lt;br /&gt;
void SetRotator(enumVarScope aScopeOption, string asName, cRotator avhValue)&lt;br /&gt;
void SetPoint(enumVarScope aScopeOption, string asName, cPoint avhValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Stores a single game variable with the given value and name.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the game variable to set.&lt;br /&gt;
#''int alValue, float afValue, string asValue, bool abValue, cVector avhValue, cRotator avhValue, or cPoint avhValue'' - A value of the appropriate type to be set as the named game variable.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
GameVars.SetString(varLocal, &amp;quot;itemName&amp;quot;, &amp;quot;bucket&amp;quot;);&lt;br /&gt;
GameVars.SetVector(varGlobal, &amp;quot;puzzleDir&amp;quot;, cVector(1.0f, 0.0f, 0.0f));&lt;br /&gt;
GameVars.SetBool(&amp;quot;doorOpen&amp;quot;, true);&lt;br /&gt;
// The string game var itemName is set to &amp;quot;bucket&amp;quot; in the local scope (for this level only).&lt;br /&gt;
// The vector game var puzzleDir is set to 1,0,0 in the global scope (for all levels).&lt;br /&gt;
// The bool game var doorOpen is set to true in the global scope (for all levels).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Get...()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetInt(enumVarScope aScopeOption, string asName)&lt;br /&gt;
float GetFloat(enumVarScope aScopeOption, string asName)&lt;br /&gt;
string GetString(enumVarScope aScopeOption, string asName)&lt;br /&gt;
bool GetBool(enumVarScope aScopeOption, string asName)&lt;br /&gt;
cVector GetVector(enumVarScope aScopeOption, string asName)&lt;br /&gt;
cRotator GetRotator(enumVarScope aScopeOption, string asName)&lt;br /&gt;
cPoint GetPoint(enumVarScope aScopeOption, string asName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves a single game variable with the given name and returns it as the appropriate variable type.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the game variable to get.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string itemName GameVars.GetString(varLocal, &amp;quot;itemName&amp;quot;);&lt;br /&gt;
// The script var itemName is assigned the value from the local game var with the same name.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
vHalfSpeed = GameVars.GetVector(&amp;quot;savedSpeed&amp;quot;) / 2.0f;&lt;br /&gt;
// The script vector var vHalfSpeed is assigned with the vector retrieved from the global game var savedSpeed, divided by two.&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
if(GameVars.GetBool(&amp;quot;doorOpen&amp;quot;, true) DoStuff();&lt;br /&gt;
// The condition succeeds if the global game var doorOpen is retrieved as true.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&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;
void AddInt(enumVarScope aScopeOption, string asName, int alValue)&lt;br /&gt;
void AddFloat(enumVarScope aScopeOption, string asName, float afValue)&lt;br /&gt;
void AddVector(enumVarScope aScopeOption, string asName, cVector avhValue)&lt;br /&gt;
void AddRotator(enumVarScope aScopeOption, string asName, cRotator avhValue)&lt;br /&gt;
void AddPoint(enumVarScope aScopeOption, string asName, cPoint avhValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Updates a stored numeric game variable with the given name by adding the given value arithmetically. To subtract, use a negative value. Not to be confused with AddString() (appends text) or AddListItem...() (appends an item to a list).&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the game variable to add to.&lt;br /&gt;
#''int alValue, float afValue, cVector avhValue, cRotator avhValue, or cPoint avhValue'' - A value of the appropriate type to be add to the named game variable.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
GameVars.AddFloat(&amp;quot;runningTotal&amp;quot;, 3.5f);&lt;br /&gt;
// The global float game var runningTotal increases by 3.5.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
GameVars.AddPoint(varLocal, &amp;quot;gridPos&amp;quot; cPoint(0, -1, 0));&lt;br /&gt;
// The local point game var gridPos decreases by 1 in the y axis.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddString(enumVarScope aScopeOption, string asName, string asName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Updates a stored string game variable with the given name by appending the given text.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the string game variable to append to.&lt;br /&gt;
#''string asValue'' - A string to append to the named game variable.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
GameVars.AddString(&amp;quot;message&amp;quot;, &amp;quot; Goodbye!&amp;quot;);&lt;br /&gt;
// The global string game var message is appended with the second string.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====NotBool()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void NotBool(enumVarScope aScopeOption, string asName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Updates a stored bool game variable by inverting it.&lt;br /&gt;
If the stored bool is true, it becomes false and vice versa.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the bool game variable to update.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
GameVars.SetBool(varLocal, &amp;quot;flipflop&amp;quot;, false);&lt;br /&gt;
GameVars.NotBool(varLocal, &amp;quot;flipflop&amp;quot;);&lt;br /&gt;
// The local bool game var flipflop is first set to false but then becomes true.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AndBool()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AndBool(enumVarScope aScopeOption, string asName, bool abValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Updates a stored bool game variable by combining it with the given value, using AND logic.&lt;br /&gt;
The stored bool will be true if both itself and abValue are true.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the bool game variable to update.&lt;br /&gt;
#''bool abValue'' - The bool value to combine with the stored value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
GameVars.SetBool(varGlobal, &amp;quot;flipflop&amp;quot;, false);&lt;br /&gt;
GameVars.AndBool(varGlobal, &amp;quot;flipflop&amp;quot;, true);&lt;br /&gt;
// The global bool game var flipflop stays false.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====OrBool()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void OrBool(enumVarScope aScopeOption, string asName, bool abValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Updates a stored bool game variable by combining it with the given value, using OR logic.&lt;br /&gt;
The stored bool will be true if either itself or abValue are true.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the bool game variable to update.&lt;br /&gt;
#''bool abValue'' - The bool value to combine with the stored value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
GameVars.SetBool(varGlobal, &amp;quot;flipflop&amp;quot;, false);&lt;br /&gt;
GameVars.AndBool(varGlobal, &amp;quot;flipflop&amp;quot;, true);&lt;br /&gt;
// The global bool game var flipflop becomes true.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIntAsUint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint GetIntAsUint(enumVarScope aScopeOption, string asName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves a stored int game variable and returns it as a uint. If the stored int is negative, the returned uint will be 0.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the int game variable to retrieve.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetIntAsUint()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetIntAsUint(enumVarScope aScopeOption, string asName, uint aulValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Takes a uint argument and stores it as an int. This is the same as SetInt(), except that it explicitly casts the uint to int, which avoids type conversion warnings.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the int game variable to set.&lt;br /&gt;
#''uint aulValue'' - The uint value to be stored as an int.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetFloatAsDouble()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
double GetFloatAsDouble(enumVarScope aScopeOption, string asName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves a stored float game variable and returns it as a double.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the int game variable to retrieve.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Lists===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetList...()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetListInt(enumVarScope aScopeOption, string asName, cListInt alValues)&lt;br /&gt;
void SetListFloat(enumVarScope aScopeOption, string asName, cListFloat afValues)&lt;br /&gt;
void SetListString(enumVarScope aScopeOption, string asName, cListString asValues)&lt;br /&gt;
void SetListBool(enumVarScope aScopeOption, string asName, cListBool abValues)&lt;br /&gt;
void SetListVector(enumVarScope aScopeOption, string asName, cListVector avhValues)&lt;br /&gt;
void SetListRotator(enumVarScope aScopeOption, string asName, cListRotator avhValues)&lt;br /&gt;
void SetListPoint(enumVarScope aScopeOption, string asName, cListPoint avhValues)&lt;br /&gt;
&lt;br /&gt;
void SetListInt(enumVarScope aScopeOption, string asName, int[] alValues)&lt;br /&gt;
void SetListFloat(enumVarScope aScopeOption, string asName, float[] afValues)&lt;br /&gt;
void SetListString(enumVarScope aScopeOption, string asName, string[] asValues)&lt;br /&gt;
void SetListBool(enumVarScope aScopeOption, string asName, bool[] abValues)&lt;br /&gt;
void SetListVector(enumVarScope aScopeOption, string asName, cVector[] avhValues)&lt;br /&gt;
void SetListRotator(enumVarScope aScopeOption, string asName, cRotator[] avhValues)&lt;br /&gt;
void SetListPoint(enumVarScope aScopeOption, string asName, cPoint[] avhValues)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Stores a list or array of game variables under a single name.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the game variable to store as a list.&lt;br /&gt;
#''cListInt alValues, cListFloat afValues, cListString asValues, cListBool abValues, cListVector avhValues, cListRotator avhValues, cListPoint avhValues&lt;br /&gt;
int[] alValues, float[] afValues, string[] asValues, bool[] abValues, cVector[] avhValues, cRotator[] avhValues, or cPoint[] avhValues'' - A value of the appropriate type to be set as the named game variable.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
bool[] buttPos = { true, true, false, true };&lt;br /&gt;
GameVars.SetListBool(varLocal, &amp;quot;buttonPositions&amp;quot;, buttPos);&lt;br /&gt;
// The array of bools will be save to a local game var as buttonPositions.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListInt myInts;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) myInts.Add(Math.RandomInt(1, 101));&lt;br /&gt;
GameVars.SetListInt(&amp;quot;mySavedInts&amp;quot;, myInts);&lt;br /&gt;
// Ten random integers will be saved to a global game var as mySavedInts.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetListItem...()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetListItemInt(enumVarScope aScopeOption, string asName, uint aulIndex, int alValue)&lt;br /&gt;
void SetListItemFloat(enumVarScope aScopeOption, string asName, uint aulIndex, float afValue)&lt;br /&gt;
void SetListItemString(enumVarScope aScopeOption, string asName, uint aulIndex, string asValue)&lt;br /&gt;
void SetListItemBool(enumVarScope aScopeOption, string asName, uint aulIndex, bool abValue)&lt;br /&gt;
void SetListItemVector(enumVarScope aScopeOption, string asName, uint aulIndex, cVector avhValue)&lt;br /&gt;
void SetListItemRotator(enumVarScope aScopeOption, string asName, uint aulIndex, cRotator avhValue)&lt;br /&gt;
void SetListItemPoint(enumVarScope aScopeOption, string asName, uint aulIndex, cPoint avhValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Sets the value of a single item in a stored game variable list, at the specified index. If the specified index is past the end of the list (or if the list has not been stored), then the list will be extended with default values.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the stored game variable list.&lt;br /&gt;
#''uint aulIndex'' - The index in the stored list to set the value.&lt;br /&gt;
#''int alValue, float afValue, string asValue, bool abValue, cVector avhValue, cRotator avhValue, or cPoint avhValue'' - A value of the appropriate type to be set as the item in the named game variable list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
bool[] buttPos = { true, true, false, true };&lt;br /&gt;
GameVars.SetListBool(varLocal, &amp;quot;buttonPositions&amp;quot;, buttPos);&lt;br /&gt;
GameVars.SetListItemBool(varLocal, &amp;quot;buttonPositions&amp;quot;, 2, true);&lt;br /&gt;
// All four saved bools in the local game var buttonPositions are now true.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
GameVars.SetListInt(&amp;quot;newListOfInts&amp;quot;, 10, 99);&lt;br /&gt;
// Assuming newListOfInts has not been created yet, a list of 9 default 0's is created, followed by 99.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====AddListItem...()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddListItemInt(enumVarScope aScopeOption, string asName, int alValue)&lt;br /&gt;
void AddListItemFloat(enumVarScope aScopeOption, string asName, float afValue)&lt;br /&gt;
void AddListItemString(enumVarScope aScopeOption, string asName, string asValue)&lt;br /&gt;
void AddListItemBool(enumVarScope aScopeOption, string asName, bool abValue)&lt;br /&gt;
void AddListItemVector(enumVarScope aScopeOption, string asName, cVector avhValue)&lt;br /&gt;
void AddListItemRotator(enumVarScope aScopeOption, string asName, cRotator avhValue)&lt;br /&gt;
void AddListItemPoint(enumVarScope aScopeOption, string asName, cPoint avhValue)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Appends a single item to the end of a stored game variable list.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the stored game variable list.&lt;br /&gt;
#''int alValue, float afValue, string asValue, bool abValue, cVector avhValue, cRotator avhValue, or cPoint avhValue'' - A value of the appropriate type to be appended to the named game variable list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool[] buttPos = { true, true, true, true };&lt;br /&gt;
GameVars.SetListBool(varLocal, &amp;quot;buttonPositions&amp;quot;, buttPos);&lt;br /&gt;
GameVars.AddListItemBool(varLocal, &amp;quot;buttonPositions&amp;quot;, false);&lt;br /&gt;
// The saved list of four true bools in the local game var buttonPositions is now append with a false value.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetList...()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt GetListInt(enumVarScope aScopeOption, string asName)&lt;br /&gt;
cListFloat GetListFloat(enumVarScope aScopeOption, string asName)&lt;br /&gt;
cListString GetListString(enumVarScope aScopeOption, string asName)&lt;br /&gt;
cListBool GetListBool(enumVarScope aScopeOption, string asName)&lt;br /&gt;
cListVector GetListVector(enumVarScope aScopeOption, string asName)&lt;br /&gt;
cListRotator GetListRotator(enumVarScope aScopeOption, string asName)&lt;br /&gt;
cListPoint GetListPoint(enumVarScope aScopeOption, string asName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves an entire stored game variable list and returns it as a linked list of the appropriate type.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the stored game variable list to retrieve.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat myFloats = GetListFloat(&amp;quot;savedFloats&amp;quot;);&lt;br /&gt;
// The script var list myFloats is assigned with the values retrieved from the game var list savedFloats.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
float[] myFloats = GetListFloat(&amp;quot;savedFloats&amp;quot;).ToArray();&lt;br /&gt;
// The script var array myFloats is assigned with the values retrieved from the game var list savedFloats, using the ToArray() method of the list class.&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
float myFloat = GetListFloat(&amp;quot;savedFloats&amp;quot;)[3];&lt;br /&gt;
// The script var float myFloat is assigned with the single value retrieved from index 3 of the game var list savedFloats.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetListItem...()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt GetListItemInt(enumVarScope aScopeOption, string asName, uint aulIndex)&lt;br /&gt;
cListFloat GetListItemFloat(enumVarScope aScopeOption, string asName, uint aulIndex)&lt;br /&gt;
cListString GetListItemString(enumVarScope aScopeOption, string asName, uint aulIndex)&lt;br /&gt;
cListBool GetListItemBool(enumVarScope aScopeOption, string asName, uint aulIndex)&lt;br /&gt;
cListVector GetListItemVector(enumVarScope aScopeOption, string asName, uint aulIndex)&lt;br /&gt;
cListRotator GetListItemRotator(enumVarScope aScopeOption, string asName, uint aulIndex)&lt;br /&gt;
cListPoint GetListItemPoint(enumVarScope aScopeOption, string asName, uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Retrieves a single item from a stored game variable list and returns it as variable of the appropriate type.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the stored game variable list to retrieve the item from.&lt;br /&gt;
#''uint aulIndex'' - The index to get from the stored list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string[] sItems = { &amp;quot;bucket&amp;quot;, &amp;quot;hammer&amp;quot;, &amp;quot;saw&amp;quot;, &amp;quot;pliers&amp;quot; };&lt;br /&gt;
GameVars.SetListString(&amp;quot;itemNames&amp;quot;, sItems);&lt;br /&gt;
string sRetirevedItem = GameVars.GetListItem(&amp;quot;itemNames&amp;quot;, 2);&lt;br /&gt;
// sRetirevedItem becomes &amp;quot;saw&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetListCount()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint GetListCount(enumVarScope aScopeOption, string asName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the number of items stored in a list.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the stored game variable list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
SetNumberOfQuestsInMap(GameVars.GetListCount(varLocal, &amp;quot;activeQuests&amp;quot;));&lt;br /&gt;
// The number of items in the saved game var activeQuests is retrieved and passed to SetNumberOfQuestsInMap() as an arg.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ClearList()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearList(enumVarScope aScopeOption, string asName)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Empties a stored list.&lt;br /&gt;
&amp;lt;br&amp;gt;Note: This works by zeroing the count and does not remove or reset the items in the stored list. If GetList...() is used after ClearList() then it will return an empty list. But if GetListItem...() is used after ClearList(), it will still return the previously stored item.&lt;br /&gt;
&amp;lt;br&amp;gt;aScopeOption is optional. If varLocal is used, the game variable is saved for the current level only. If varGlobal is used or if aScopeOption is omitted, the game variables will be saved for all levels.&lt;br /&gt;
#''enumVarScope aScopeOption'' - Can be either varLocal or varGlobal. (Optional, default = varGlobal)&lt;br /&gt;
#''string asName'' - The name of the stored game variable list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool[] bBunchOfBools = { true, false, false, true };&lt;br /&gt;
GameVars.SetListBool(varLocal, &amp;quot;SavedBools&amp;quot;, bBunchOfBools);&lt;br /&gt;
GameVars.ClearList(&amp;quot;SavedBools);&lt;br /&gt;
&lt;br /&gt;
int lTryGetCount = GameVars.GetListCount(&amp;quot;SavedBools&amp;quot;);&lt;br /&gt;
cListBool bTryGetList = GameVars.GetListBool(&amp;quot;SavedBools&amp;quot;);&lt;br /&gt;
bool bTryGetIndex = GameVars.GetListItemBool(&amp;quot;SavedBools&amp;quot;, 3);&lt;br /&gt;
// After clearing the list, lTryGetCount is assigned 0, and bTryGetList is assigned an empty list.&lt;br /&gt;
// However, bTryGetIndex will be assigned true, and the original value is not erased.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Debug&amp;diff=6781</id>
		<title>HPL2/HPL2 Helper Scripts/Debug</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Debug&amp;diff=6781"/>
		<updated>2024-02-11T01:07:11Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Debug.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 file &amp;quot;HelperScripts_Debug.hps&amp;quot; provides more control and options for how debug messages are written to the screen and to the log. There are three purposes behind Debug.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Verbosity===&lt;br /&gt;
The first is '''verbosity levels'''. Verbosity means &amp;quot;wordiness&amp;quot;. Debug defines three verbosity values that control how much debug information is posted to screen and log files. The modder can control the verbosity level in script, and create lots of debug output whilst only spamming the screen and log when actually needed. The SetVerbosity() method, and the properties VerbosityInLogFile, VerbosityOnScreen and LogInReleaseMode, can be used to set a verbosity level 0-3 for posting messages to the screen in debug mode, to the log in debug mode and to the log in normal mode.&lt;br /&gt;
&amp;lt;br&amp;gt;When using Debug's Message() method to post debug messages, they are given a priority level, 1-3, which is checked against the verbosity level. Priority level 1 should be used for errors, warnings and important messages, level 2 for more general, more frequent debug information, and level 3 for very detailed &amp;quot;spammy&amp;quot; debug messages. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Debug.VerbosityInLogFile = 2;&lt;br /&gt;
Debug.VerbosityOnScreen = 1;&lt;br /&gt;
Debug.Message(1, &amp;quot;With the current settings, this will appear onscreen and in the log.&amp;quot;);&lt;br /&gt;
Debug.Message(2, &amp;quot;With the current settings, this will appear in the log only.&amp;quot;);&lt;br /&gt;
Debug.Message(3, &amp;quot;With the current settings, this won't appear anywhere.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New Types and Formatting===&lt;br /&gt;
Secondly, Debug provides methods to pass multiple '''new argument types'''. As well as composing messages from strings, ints, etc., you can also pass arrays, lists, vectors, or make use of the String.Format() method and Str class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Performance===&lt;br /&gt;
And thirdly, Debug allow modders to include complex debug messages whilst '''computing strings in debug mode only'''. For example, sometimes it's useful to have complex debug messages incorporating lots of variables. Compare these two lines of script:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1 - The basic way:&lt;br /&gt;
AddDebugMessage(&amp;quot;A grunt has arrived, grunt number: &amp;quot; + gruntNum, true);&lt;br /&gt;
AddDebugMessage(&amp;quot;Grunt number &amp;quot; + gruntNum + &amp;quot; has touched area &amp;quot; + triggerName + &amp;quot;!&amp;quot;, true);&lt;br /&gt;
// Example 2 - The Helper Scripts way:&lt;br /&gt;
Debug.Message(3, &amp;quot;A grunt has arrived, grunt number&amp;quot;, gruntNum);&lt;br /&gt;
Debug.Message(3, &amp;quot;Grunt number {0} has touched area {1}!&amp;quot;, Str(gruntNum), Str(triggerName));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Both examples give the same output, visually. In example 1, the work to compose the final string happens at the point of calling AddDebugMessage(), ''regardless of whether debug mode is active or not''. That's not a big deal if it's not used often, but processing a lot of complex debug messages can have a performance impact even while the player is playing the game outside of debug mode. In example 2, Debug provides methods to pass the parts of the string as individual arguments, and the string computation only takes place if the message will actually be posted to the screen or log file. This doesn't improve performance in debug mode, but if a lot of complex debug messages are used then it will improve performance in normal play mode.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Debug=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
&amp;quot;HelperScripts_Debug.hps&amp;quot; declares an object called '''Debug''', of the new script class cDebug. To access its properties and methods, just use &amp;quot;Debug.&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;
Debug.Message(1, &amp;quot;this is an error message!&amp;quot;);&lt;br /&gt;
Debug.LogInReleaseMode = false;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
Debug provides the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====VerbosityInLogFile====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint VerbosityInLogFile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property VerbosityInLogFile can get or set the minimum priority for Debug messages printed to the log file. (See also: SetVerbosity())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Debug.VerbosityInLogFile = 3;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====VerbosityOnScreen====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint VerbosityOnScreen&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The integer property VerbosityOnScreen can get or set the minimum priority for Debug messages shown on-screen. (See also: SetVerbosity())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Debug.VerbosityOnScreen = 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LogInReleaseMode====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool LogInReleaseMode&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The bool property LogInReleaseMode can get or set whether to print debug messages to the log file even when debug mode is off. If set to true, the same priority as VerbosityInLogFile is used. (See also: SetVerbosity())&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Debug.LogInReleaseMode = true;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CheckForDuplicates====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool CheckForDuplicates&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The bool property CheckForDuplicates can get or set whether on-screen messages are checked for duplicates. This is the same as the abCheckForDuplicates argument in the global function AddDebugMessage(). The default is false because, using Debug, the modder can use verbosity levels to control spamming instead.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Debug.CheckForDuplicates = true;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
Debug provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetVerbosity()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetVerbosity(uint aulOnScreen, uint aulLogAlways, uint aulLogDebug)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Changes the verbosity limits at runtime. They are not saved, so they will reset to default on level load. (See also: VerbosityInLogFile, VerbosityOnScreen and LogInReleaseMode properties)&lt;br /&gt;
#''uint aulOnScreen'' - The new minimum priority for Debug messages shown on-screen.&lt;br /&gt;
#''uint aulLogAlways'' - The new minimum priority for Debug messages printed to the log file when debug mode is off.&lt;br /&gt;
#''uint aulLogDebug'' - The new minimum priority for Debug messages printed to the log file when debug mode is on.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Debug.SetVerbosity(0, 1, 3);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====TestPriority()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool TestPriority(uint aulPrio)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if a message of the given priority would be posted at all.&lt;br /&gt;
#''uint aulPrio'' - The priority level to be tested.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (Debug.TestPriority(3))&lt;br /&gt;
{&lt;br /&gt;
    // Do some fancy debug stuff.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Message()===&lt;br /&gt;
&amp;lt;br&amp;gt;Message() can be used to post a debug message to the log and/or screen. It is intended as a replacement for AddDebugMessage() and Print().&lt;br /&gt;
&amp;lt;br&amp;gt;There are multiple overloads of Message() that allow for different types of arguments. In each case the string computation only happens if the message will actually be posted.&lt;br /&gt;
&amp;lt;br&amp;gt;alPrio represents the importance of your message, 1-3. alPrio is checked against the relevant verbosity limit. In general, use priority level 1 for errors, warnings and important messages, level 2 for more general, more frequent debug information, and level 3 for very detailed &amp;quot;spammy&amp;quot; debug messages.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Basic message====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Message(const alPrio, string asText)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Posts a debug message to the log and/or screen. alPrio is optional and defaults to 1 if omitted.&lt;br /&gt;
#''uint alPrio'' - An integer specifying the priority of the message, 1-3 (rare/important-to-verbose/spam). '''(Optional, default = 1)'''&lt;br /&gt;
#''string asText'' - The text of the message.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Debug.Message(3, &amp;quot;Something has happened.&amp;quot;); // Priority 3.&lt;br /&gt;
Debug.Message(&amp;quot;Something else has happened.&amp;quot;); // Priority 1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Message appended with a variable====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Message(uint alPrio, string asText, string arg)&lt;br /&gt;
void Message(uint alPrio, string asText, uint arg)&lt;br /&gt;
void Message(uint alPrio, string asText, int arg)&lt;br /&gt;
void Message(uint alPrio, string asText, float arg)&lt;br /&gt;
void Message(uint alPrio, string asText, double arg)&lt;br /&gt;
void Message(uint alPrio, string asText, bool arg)&lt;br /&gt;
void Message(uint alPrio, string asText, cVector arg)&lt;br /&gt;
void Message(uint alPrio, string asText, cPoint arg)&lt;br /&gt;
void Message(uint alPrio, string asText, cRotator arg)&lt;br /&gt;
void Message(uint alPrio, string asText, cBezier arg)&lt;br /&gt;
void Message(uint alPrio, string asText, cSpline arg)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Appends a single variable to the debug message, evaluating the arguments only if the message will be posted. alPrio is optional and defaults to 1 if omitted.&lt;br /&gt;
#''uint alPrio'' - An integer specifying the priority of the message, 1-3 (rare/important-to-verbose/spam). '''(Optional, default = 1)'''&lt;br /&gt;
#''string asText'' - The text of the message, to be appended to.&lt;br /&gt;
#''string arg, uint arg, int arg, float arg, double arg, bool arg, cVector arg, cPoint arg, cBezier arg, or cSpline arg'' - A variable to be appended to the message.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool bSpookyZone = true;&lt;br /&gt;
Debug.Message(2, &amp;quot;Player is in spooky zone&amp;quot;, bSpookyZone);&lt;br /&gt;
// outputs &amp;quot;Player is in spooky zone: true&amp;quot; at verbosity level 2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Message appended with a list====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Message(uint alPrio, string asText, cListBase ahList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Appends a [[HPL2/HPL2_Helper_Scripts/Lists|list]] object to the message. The list is only evaluated if the message will actually be posted. Any derived list class can be used, including cListInt, cListFloat, cListBool, etc.. Uses the ToStringArray() function of the list, which is turn uses the ToString() function of the relevant node class. alPrio is optional and defaults to 1 if omitted.&lt;br /&gt;
#''uint alPrio'' - An integer specifying the priority of the message, 1-3 (rare/important-to-verbose/spam).  '''(Optional, default = 1)'''&lt;br /&gt;
#''string asText'' - The text of the message.&lt;br /&gt;
#''cListBase ahList'' - A reference to a list class that will be appended to the message.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat myFloats;&lt;br /&gt;
myFloats.Add(11.1f);&lt;br /&gt;
myFloats.Add(2.22f);&lt;br /&gt;
Debug.Message(3, &amp;quot;Let's print some floats&amp;quot;, myFloats);&lt;br /&gt;
// outputs &amp;quot;Let's print some floats: [11.1], [2.22]&amp;quot; at verbosity level 3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Message appended with an array====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Message(uint alPrio, string asText, int[] alArray)&lt;br /&gt;
void Message(uint alPrio, string asText, float[] afArray)&lt;br /&gt;
void Message(uint alPrio, string asText, double[] adArray)&lt;br /&gt;
void Message(uint alPrio, string asText, bool[] abArray)&lt;br /&gt;
void Message(uint alPrio, string asText, string[] asArray)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Appends an array of values to the message. The array is only evaluated if the message will actually be posted. alPrio is optional and defaults to 1 if omitted.&lt;br /&gt;
#''alPrio'' - An integer specifying the priority of the message, 1-3 (rare/important-to-verbose/spam). '''(Optional, default = 1)'''&lt;br /&gt;
#''asText'' - The text of the message.&lt;br /&gt;
#''int[] alArray, float[] afArray, double[] adArray, bool[] abArray, or string[] asArray'' - A reference to a list that will be appended to the message.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string[] someWords = { &amp;quot;good&amp;quot;, &amp;quot;boy&amp;quot;, &amp;quot;Daniel&amp;quot; };&lt;br /&gt;
Debug.Message(1, &amp;quot;You're a&amp;quot;, someWords);&lt;br /&gt;
// outputs &amp;quot;You're a: [good], [boy], [Daniel]&amp;quot; at verbosity level 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Message with string formatting====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Message(const alPrio, Str@[] argArray)&lt;br /&gt;
void Message(uint alPrio, Str arg0, Str arg1, ... Str arg7);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The most versatile overload of Message(). The debug message is a string in which tokens like &amp;quot;{i}&amp;quot; have been replaced, where i is the index of the additional arguments, starting from zero.&lt;br /&gt;
&amp;lt;br&amp;gt;This uses the String.Format() method, allowing an arbitrary number of variables to be inserted into a string, using the Str class, regardless of data type. The Str class is just a container for a variable that can be turned into a string. In other languages we might use a template or a loosely typed variable.&lt;br /&gt;
&amp;lt;br&amp;gt;When using the array version, the Str arguments can be provided as Str@[] - an array of ''handles''. Be sure to declare an array of Str handles (Str@[]) rather than an array of Str instances (Str[]). See Example 3. ('''Advanced users''' may note that Angelscript handles work similarly reference parameters, or pointers in C++.)&lt;br /&gt;
#''alPrio'' - An integer specifying the priority of the message, 1-3 (rare/important-to-verbose/spam). '''(Optional, default = 1)'''&lt;br /&gt;
#''asText'' - The text of the message as a template containing tokens (&amp;quot;{i}&amp;quot;) to be replaced by the other arguments.&lt;br /&gt;
#''Str@[] argArray, or Str arg0'' - An array of Str handles, or a single Str instance, to replace tokens in the string.&lt;br /&gt;
#''Str arg1 ... Str arg7'' - An additional 7 single Str arguments can be given. '''(Optional, when not using an array.)'''&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sPlayerName = &amp;quot;Justine&amp;quot;;&lt;br /&gt;
string sSuitorName = &amp;quot;Basile&amp;quot;;&lt;br /&gt;
int lScore = 7;&lt;br /&gt;
int lScoreMax = 10;&lt;br /&gt;
Debug.Message(1, &amp;quot;{0} has been given {1}/{2} by {3}!&amp;quot;, Str(sSuitorName), Str(lScore), Str(lScoreMax), Str(sPlayerName));&lt;br /&gt;
// Outputs &amp;quot;Basile has been given 7/10 by Justine!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
int lNumMonsters = 13;&lt;br /&gt;
string sMonsterType = &amp;quot;ManPig&amp;quot;;&lt;br /&gt;
Debug.Message(1, &amp;quot;Error: Too many {3}s! {0} out of {1} found. Pork = {2}!&amp;quot;, Str(lNumMonsters), Str(12), Str(lNumMonsters &amp;gt; 12), Str(sMonsterType));&lt;br /&gt;
// Outputs &amp;quot;Error: Too many ManPigs! 13 out of 12 found. Pork = true!&amp;quot;&lt;br /&gt;
// Note that the numbers match the order of the args, not the order of insertion.&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
Str@[] someArgs(2);&lt;br /&gt;
someArgs[0] = Str(&amp;quot;strange&amp;quot;);&lt;br /&gt;
someArgs[1] = Str(&amp;quot;unnartural&amp;quot;);&lt;br /&gt;
Debug.Message(3, &amp;quot;The darkness in the Storage feels {0} and {1}.&amp;quot;, someArgs);&lt;br /&gt;
// Outputs &amp;quot;The darkness in the Storage feels strange and unnatural.&amp;quot;&lt;br /&gt;
// Note the syntax for declaring the array: &amp;quot;Str@[]&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6759</id>
		<title>HPL2/HPL2 Helper Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6759"/>
		<updated>2024-02-03T12:08:19Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
=Introduction=&lt;br /&gt;
''HPL2 Helper Scripts'' by Aetheric Games is a package of .hps files containing script classes and functions that may be useful to HPL2 modders and custom story creators. It is compatible with ATDD version 1.5 and later.&lt;br /&gt;
&lt;br /&gt;
Would you like to...&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
...make 500 candles blow out in a big wave? ...make haunted objects hover in the air? ...spawn dozens of random debris objects throughout an area? ...make a particle system move along a spline? ...manage a list of quest objectives? ...compare the distances between entities? ...make puzzles based on position and rotation? ...store an array in a global game variable? ...seamlessly teleport the player into an ''almost'' identical room? ...make a statue that twitches when the player has low sanity?&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Well, this script package isn't going to magically do those things for you, but it gives you a ''lot'' of tools to help you do them yourself.&lt;br /&gt;
&lt;br /&gt;
The scripts are divided into two categories: ''utilities'' and ''features''. The ''utilities'' scripts include tools for general scripting, like new maths functions, or linked lists and vector classes. The ''features'' scripts are more specific solutions that make use of the utilities, such as a way to spawn entities at specific locations, script a large chain of events or to make entities twitch and flicker. Some modders might prefer to just adopt the ''utilities'' scripts. It's up to you!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''[[HPL2/HPL2 Helper Scripts#Set-up|See below for download and set-up instructions.]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Contents=&lt;br /&gt;
The documentation and help is organised by file. '''''Lots of help, and full details of the new classes and functions, can be found on the following pages:'''''&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Utilities==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Debug|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Debug'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides more control and options for debug messages and logging.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/GameVars|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''GameVars'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Extends the functionality of the saved game global and local variable wrappers.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Lists|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Lists'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for linked list classes.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/LoadWatcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''LoadWatcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides an &amp;quot;OnLoad()&amp;quot; global function.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Math|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Math'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended maths functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/String|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''String'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended string functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Vectors|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Vectors'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for vector classes.&lt;br /&gt;
||&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;||&lt;br /&gt;
==Features==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Bobber|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Bobber'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for floating or hovering entities, without physics.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Fader|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Fader'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing global ambient sounds.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Glitcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Glitcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing entities that appear to glitch or flicker.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Slimer|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Slimer'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing large sequences of entity actions.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Spawner|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Spawner'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for spawning entities at specific map locations.&lt;br /&gt;
:&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&amp;amp;nbsp;&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
::&amp;amp;nbsp;&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Misc|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Miscellaneous'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Bits and pieces that don't fit anywhere else.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Set-up=&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First, download ''HPL2 Helper Scripts'' from the [https://steamcommunity.com/sharedfiles/filedetails/?id=3101276708 Steam Workshop page] or [https://www.moddb.com/mods/hpl2-helper-scripts ModDb page] and unzip it.&lt;br /&gt;
&lt;br /&gt;
If you get it on Steam Workshop, you'll find the actual folder in your Steam Workshop downloads.&lt;br /&gt;
&lt;br /&gt;
The current version is [[HPL2/HPL2_Helper_Scripts#Version_1.1.2C_03.2F02.2F24|1.1]].&lt;br /&gt;
&lt;br /&gt;
Once you have zipped the folder, there are three options for how you add it into your mod. '''If you are unsure, just go with option A'''.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option A: The full feature-set package===&lt;br /&gt;
::If you want to be able to use all the new functions and classes, go with option A.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_FullPackage.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_FullPackage.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option B: The utilities-only package===&lt;br /&gt;
::Choose option B if you want to have access to the functions and classes in the ''utilities'' category, but don't need the stuff in the ''features'' category.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_UtilitiesOnly.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_UtilitiesOnly.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option C: Pick-n-mix===&lt;br /&gt;
::Advanced modders might prefer to only adopt the specific script files they need. Go nuts! But also be aware of the #include dependencies in each script file, as many of them are interdependent. You might find it easiest to start with option A or B and then remove scripts later that you definitely haven't used. You're also fully allowed and encouraged to just use HPL2HelperScripts as a learning resource or even to just copy snippets here and there.&lt;br /&gt;
&lt;br /&gt;
=Licence and Credits=&lt;br /&gt;
You are free to use ''HPL2 Helper Scripts'' in whatever way you see fit, no rights reserved by Aetheric Games. (As long as you're not going against any licence terms between you and Frictional Games, of course!) Aetheric Games is mostly just one person, mrbehemo, me (hello), and this has been a ''stupid'' amount of work, so if you find it helpful then it would be very cool of you to give me a credit in your mod or custom story. You can list it as &amp;quot;HPL2&amp;amp;nbsp;Helper&amp;amp;nbsp;Scripts&amp;amp;nbsp;by&amp;amp;nbsp;Aetheric&amp;amp;nbsp;Games&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This script package would not have been possible without the work of the tireless and patient Luis Rodero of Frictional Games, and the ever present pillar of the community, Mudbill. &lt;br /&gt;
&lt;br /&gt;
=Support=&lt;br /&gt;
''HPL2 Helper Scripts'' is made by mrbehemo of Aetheric Games. If you need support, here's what to do:&lt;br /&gt;
#First be sure that you're familar with the official [[HPL2/Engine_Scripts|HPL2 scripting reference]] and the [[HPL2/ScriptReference|community scripting guide]].&lt;br /&gt;
#And second, be sure that you've read the relevant parts of this documentation, including the FAQ.&lt;br /&gt;
#And then if you're still stuck I'll be happy to hear from you and will help if I can. Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server].&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
Fervently Anticipated Questions. Nobody's asked anything yet... &lt;br /&gt;
* I've added one or more scripts to my project separately, but I'm getting errors. What should I check?&lt;br /&gt;
** The script files are very interdependent. Check the .hps files you've added - they will have #include directives near the top for every other script they rely on. Either make sure you've also added ''those'' into your project.&lt;br /&gt;
* What's &amp;quot;#include&amp;quot;? What's &amp;quot;OnUpdate()&amp;quot;?&lt;br /&gt;
** Those are new features added with the ATDD [[HPL2/1.5 Update|1.5 update]].&lt;br /&gt;
* I want to make something weird happen, like make 100 flying naked guys do a loop-de-loop around the player. How?&lt;br /&gt;
** Sounds fun and is probably do-able! Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server] if you want advice.&lt;br /&gt;
* Can I get the player's camera direction yet?&lt;br /&gt;
** No, sorry. I investigated multiple ways of doing that, as have many people over the years. There's just no reliable way of doing it in HPL2 without branching the source code.&lt;br /&gt;
* What's a uint and why have you used them everywhere?&lt;br /&gt;
** A &amp;quot;U-int&amp;quot; is an unsigned integer, that is, an integer that can only be positive. I think it's best to use uint in scenarios where negative numbers are nonsensical. Behind the scenes it minimises the the chance of conversion issues, and also minimises warnings in the error output.&lt;br /&gt;
* Why are all your function arguments passed by reference, and why is that not reflected in the docs?&lt;br /&gt;
** In Angelscript there's a tiny, tiny performance saving gained from passing arguments by reference (and by using const where possible). It's not enough of a saving for modders and gameplay scripters to bother with, but since I was writing hundreds of them, it was an easy thing to do. It's not reflected in the docs because most non-advanced modders don't know what &amp;quot;pass by reference&amp;quot; means, or need to know.&lt;br /&gt;
* I looked at your code and you did it all weird. Why did you do it weird?&lt;br /&gt;
** It's probably because of the version of Angelscript that is integrated into HPL2. It has some surprising versatility but also some surprising limitations.&lt;br /&gt;
* Why did you do any of this?&lt;br /&gt;
** I know, I know - HPL2 is old now, I should have done this for The Bunker or whatever. Actually, I was just tidying up The Trapdoor (ATDD mod) for a Steam release, and I got carried away with refactoring it... and then, half a million characters of script later, this had happened. Hope it's useful. If not, it was a good exercise for me. Maybe ''you'' would like to port these scripts to HPL3 as and where needed! Go ahead, just be sure to credit and it'd be cool to let me know.&lt;br /&gt;
&lt;br /&gt;
=Change Log=&lt;br /&gt;
It should be simple to upgrade existing projects to use the current version, but take note of the changes listed below. You may need to make some minor edits.&lt;br /&gt;
&lt;br /&gt;
==Version 1.1, 03/02/24==&lt;br /&gt;
* General&lt;br /&gt;
** Changed some more spammy debug messages in level 2 to level 3 in various classes.&lt;br /&gt;
** Fixed various sign mismatch warnings between ints and uints.&lt;br /&gt;
&lt;br /&gt;
* Debug&lt;br /&gt;
** Default log verbosity is now 2 instead of 3.&lt;br /&gt;
&lt;br /&gt;
* GameVars&lt;br /&gt;
** Added SetIntAsUint() method, which is just SetInt() with an explicit cast.&lt;br /&gt;
&lt;br /&gt;
* Lists&lt;br /&gt;
** New properties for all list types: DefaultValue, Capacity&lt;br /&gt;
** New methods for all list types: Fill(), Extend(), AddUnique(), ToString()&lt;br /&gt;
** Fixed silent exception that occured when Insert() was used with index 0.&lt;br /&gt;
** Fixed silent exception that occured when Pop() was used with a count of 0 or 1.&lt;br /&gt;
** Fixed behaviour of Find() and RemoveItem() in cListGeneric.&lt;br /&gt;
** Added '''==''' operator to cListBase for checking if two lists of the same type are equal.&lt;br /&gt;
** Added optional argument abExtend to Set() methods.&lt;br /&gt;
** Fixed issue with incorrectly overloading Pop(), by moving the generic Pop() from cListBase to its correct place in cListGeneric.&lt;br /&gt;
&lt;br /&gt;
* Math&lt;br /&gt;
** New method in cMath: DistToEntity()&lt;br /&gt;
** RandomVector3d() and RandomVector2d(), when using the vecNormal option or when no range is specified, now have a chance of returning a vector with negative axes, whereas previously they were always positive.&lt;br /&gt;
&lt;br /&gt;
* String&lt;br /&gt;
** New method in cString: NearlyEqual()&lt;br /&gt;
** SplitToList() and SplitToArray() now handle empty strings by returning an empty collection. (As to opposed to previously returning a collection of one empty string.)&lt;br /&gt;
** Added list behaviour to Str class.&lt;br /&gt;
&lt;br /&gt;
* Vectors&lt;br /&gt;
** New methods in cVector: DotProduct(), CrossProduct()&lt;br /&gt;
** New methods in cSpline: GetSegmentHandle(), GetMinLength()&lt;br /&gt;
** Both cVector and cPoint now implement '''* / *= /=''' operators as ''per component'' multipliers, e.g. [2, 2, 2] * [1, 3, 0.5] = [2, 6, 1]&lt;br /&gt;
** If cVector * cVector was previously used where a dot product was the intended result, that should now be replaced by the DotProduct() method.&lt;br /&gt;
** Tweaked the bezier behaviour that uses a single control point to better approximate a quadratic bezier.&lt;br /&gt;
&lt;br /&gt;
* Fader&lt;br /&gt;
** New methods in cFader: PlayMusic(), StopMusic(), IsMusicPlaying(), DuckStart(), DuckRestore()&lt;br /&gt;
** Group 0 now counts as &amp;quot;no group&amp;quot;.&lt;br /&gt;
** Added &amp;quot;Null&amp;quot; behaviour - Fader sounds initialised with a name containing &amp;quot;Null&amp;quot; will not be associated with a sound entity in the map, but they can be included in a group and have a play state as normal.&lt;br /&gt;
** Fader sounds can now be marked as StopOnMusic. If Fader.PlayMusic() and Fader.StopMusic() are used, then Fader sounds with StopOnMusic will fade out when music starts.&lt;br /&gt;
&lt;br /&gt;
* Glitcher&lt;br /&gt;
** Fixed the afChanceScale multiplier when adding glitches. (Was previously inverted).&lt;br /&gt;
** Slightly reduced the default max glitch frequency, for smoother fades.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6758</id>
		<title>HPL2/HPL2 Helper Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6758"/>
		<updated>2024-02-03T12:05:25Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
=Introduction=&lt;br /&gt;
''HPL2 Helper Scripts'' by Aetheric Games is a package of .hps files containing script classes and functions that may be useful to HPL2 modders and custom story creators. It is compatible with ATDD version 1.5 and later.&lt;br /&gt;
&lt;br /&gt;
Would you like to...&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
...make 500 candles blow out in a big wave? ...make haunted objects hover in the air? ...spawn dozens of random debris objects throughout an area? ...make a particle system move along a spline? ...manage a list of quest objectives? ...compare the distances between entities? ...make puzzles based on position and rotation? ...store an array in a global game variable? ...seamlessly teleport the player into an ''almost'' identical room? ...make a statue that twitches when the player has low sanity?&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Well, this script package isn't going to magically do those things for you, but it gives you a ''lot'' of tools to help you do them yourself.&lt;br /&gt;
&lt;br /&gt;
The scripts are divided into two categories: ''utilities'' and ''features''. The ''utilities'' scripts include tools for general scripting, like new maths functions, or linked lists and vector classes. The ''features'' scripts are more specific solutions that make use of the utilities, such as a way to spawn entities at specific locations, script a large chain of events or to make entities twitch and flicker. Some modders might prefer to just adopt the ''utilities'' scripts. It's up to you!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''[[HPL2/HPL2 Helper Scripts#Set-up|See below for download and set-up instructions.]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Contents=&lt;br /&gt;
The documentation and help is organised by file. '''''Lots of help, and full details of the new classes and functions, can be found on the following pages:'''''&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Utilities==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Debug|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Debug'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides more control and options for debug messages and logging.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/GameVars|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''GameVars'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Extends the functionality of the saved game global and local variable wrappers.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Lists|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Lists'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for linked list classes.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/LoadWatcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''LoadWatcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides an &amp;quot;OnLoad()&amp;quot; global function.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Math|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Math'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended maths functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/String|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''String'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended string functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Vectors|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Vectors'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for vector classes.&lt;br /&gt;
||&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;||&lt;br /&gt;
==Features==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Bobber|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Bobber'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for floating or hovering entities, without physics.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Fader|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Fader'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing global ambient sounds.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Glitcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Glitcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing entities that appear to glitch or flicker.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Slimer|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Slimer'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing large sequences of entity actions.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Spawner|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Spawner'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for spawning entities at specific map locations.&lt;br /&gt;
:&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&amp;amp;nbsp;&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
::&amp;amp;nbsp;&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Misc|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Miscellaneous'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Bits and pieces that don't fit anywhere else.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Set-up=&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First, download ''HPL2 Helper Scripts'' from the [https://steamcommunity.com/sharedfiles/filedetails/?id=3101276708 Steam Workshop page] or [https://www.moddb.com/mods/hpl2-helper-scripts ModDb page] and unzip it.&lt;br /&gt;
&lt;br /&gt;
If you get it on Steam Workshop, you'll find the actual folder in your Steam Workshop downloads.&lt;br /&gt;
&lt;br /&gt;
The current version is [[HPL2/HPL2_Helper_Scripts#Version_1.1.2C_03.2F02.2F24|1.1]].&lt;br /&gt;
&lt;br /&gt;
Once you have zipped the folder, there are three options for how you add it into your mod. '''If you are unsure, just go with option A'''.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option A: The full feature-set package===&lt;br /&gt;
::If you want to be able to use all the new functions and classes, go with option A.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_FullPackage.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_FullPackage.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option B: The utilities-only package===&lt;br /&gt;
::Choose option B if you want to have access to the functions and classes in the ''utilities'' category, but don't need the stuff in the ''features'' category.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_UtilitiesOnly.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_UtilitiesOnly.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option C: Pick-n-mix===&lt;br /&gt;
::Advanced modders might prefer to only adopt the specific script files they need. Go nuts! But also be aware of the #include dependencies in each script file, as many of them are interdependent. You might find it easiest to start with option A or B and then remove scripts later that you definitely haven't used. You're also fully allowed and encouraged to just use HPL2HelperScripts as a learning resource or even to just copy snippets here and there.&lt;br /&gt;
&lt;br /&gt;
=Licence and Credits=&lt;br /&gt;
You are free to use ''HPL2 Helper Scripts'' in whatever way you see fit, no rights reserved by Aetheric Games. (As long as you're not going against any licence terms between you and Frictional Games, of course!) Aetheric Games is mostly just one person, mrbehemo, me (hello), and this has been a ''stupid'' amount of work, so if you find it helpful then it would be very cool of you to give me a credit in your mod or custom story. You can list it as &amp;quot;HPL2&amp;amp;nbsp;Helper&amp;amp;nbsp;Scripts&amp;amp;nbsp;by&amp;amp;nbsp;Aetheric&amp;amp;nbsp;Games&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This script package would not have been possible without the work of the tireless and patient Luis Rodero of Frictional Games, and the ever present pillar of the community, Mudbill. &lt;br /&gt;
&lt;br /&gt;
=Support=&lt;br /&gt;
''HPL2 Helper Scripts'' is made by mrbehemo of Aetheric Games. If you need support, here's what to do:&lt;br /&gt;
#First be sure that you're familar with the official [[HPL2/Engine_Scripts|HPL2 scripting reference]] and the [[HPL2/ScriptReference|community scripting guide]].&lt;br /&gt;
#And second, be sure that you've read the relevant parts of this documentation, including the FAQ.&lt;br /&gt;
#And then if you're still stuck I'll be happy to hear from you and will help if I can. Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server].&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
Fervently Anticipated Questions. Nobody's asked anything yet... &lt;br /&gt;
* I've added one or more scripts to my project separately, but I'm getting errors. What should I check?&lt;br /&gt;
** The script files are very interdependent. Check the .hps files you've added - they will have #include directives near the top for every other script they rely on. Either make sure you've also added ''those'' into your project.&lt;br /&gt;
* What's &amp;quot;#include&amp;quot;? What's &amp;quot;OnUpdate()&amp;quot;?&lt;br /&gt;
** Those are new features added with the ATDD [[HPL2/1.5 Update|1.5 update]].&lt;br /&gt;
* I want to make something weird happen, like make 100 flying naked guys do a loop-de-loop around the player. How?&lt;br /&gt;
** Sounds fun and is probably do-able! Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server] if you want advice.&lt;br /&gt;
* Can I get the player's camera direction yet?&lt;br /&gt;
** No, sorry. I investigated multiple ways of doing that, as have many people over the years. There's just no reliable way of doing it in HPL2 without branching the source code.&lt;br /&gt;
* What's a uint and why have you used them everywhere?&lt;br /&gt;
** A &amp;quot;U-int&amp;quot; is an unsigned integer, that is, an integer that can only be positive. I think it's best to use uint in scenarios where negative numbers are nonsensical. Behind the scenes it minimises the the chance of conversion issues, and also minimises warnings in the error output.&lt;br /&gt;
* Why are all your function arguments passed by reference, and why is that not reflected in the docs?&lt;br /&gt;
** In Angelscript there's a tiny, tiny performance saving gained from passing arguments by reference (and by using const where possible). It's not enough of a saving for modders and gameplay scripters to bother with, but since I was writing hundreds of them, it was an easy thing to do. It's not reflected in the docs because most non-advanced modders don't know what &amp;quot;pass by reference&amp;quot; means, or need to know.&lt;br /&gt;
* I looked at your code and you did it all weird. Why did you do it weird?&lt;br /&gt;
** It's probably because of the version of Angelscript that is integrated into HPL2. It has some surprising versatility but also some surprising limitations.&lt;br /&gt;
* Why did you do any of this?&lt;br /&gt;
** I know, I know - HPL2 is old now, I should have done this for The Bunker or whatever. Actually, I was just tidying up The Trapdoor (ATDD mod) for a Steam release, and I got carried away with refactoring it... and then, half a million characters of script later, this had happened. Hope it's useful. If not, it was a good exercise for me. Maybe ''you'' would like to port these scripts to HPL3 as and where needed! Go ahead, just be sure to credit and it'd be cool to let me know.&lt;br /&gt;
&lt;br /&gt;
=Change Log=&lt;br /&gt;
It should be simple to upgrade existing projects to use the current version, but take note of the changes listed below. You may need to make some minor edits.&lt;br /&gt;
&lt;br /&gt;
==Version 1.1, 03/02/24==&lt;br /&gt;
* General&lt;br /&gt;
** Changed some more spammy debug messages in level 2 to level 3 in various classes.&lt;br /&gt;
** Fixed various sign mismatch warnings between ints and uints.&lt;br /&gt;
&lt;br /&gt;
* Debug&lt;br /&gt;
** Default log verbosity is now 2 instead of 3.&lt;br /&gt;
&lt;br /&gt;
* GameVars&lt;br /&gt;
** Added SetIntAsUint() method, which is just SetInt() with an explicit cast.&lt;br /&gt;
&lt;br /&gt;
* Lists&lt;br /&gt;
** New properties for all list types: DefaultValue, Capacity&lt;br /&gt;
** New methods for all list types: Fill(), Extend(), AddUnique(), ToString()&lt;br /&gt;
** Fixed silent exception that occured when Insert() was used with index 0.&lt;br /&gt;
** Fixed silent exception that occured when Pop() was used with a count of 0 or 1.&lt;br /&gt;
** Fixed behaviour of Find() and RemoveItem() in cListGeneric.&lt;br /&gt;
** Added '''==''' operator to cListBase for checking if two lists of the same type are equal.&lt;br /&gt;
** Added optional argument abExtend to Set() methods.&lt;br /&gt;
** Fixed issue with incorrectly overloading Pop(), by moving the generic Pop() from cListBase to its correct place in cListGeneric.&lt;br /&gt;
&lt;br /&gt;
* Math&lt;br /&gt;
** New method in cMath: DistToEntity()&lt;br /&gt;
** RandomVector3d() and RandomVector2d(), when using the vecNormal option or when no range is specified, now have a chance of returning a vector with negative axes, whereas previously they were always positive.&lt;br /&gt;
&lt;br /&gt;
* String&lt;br /&gt;
** New method in cString: NearlyEqual()&lt;br /&gt;
** SplitToList() and SplitToArray() now handle empty strings by returning an empty collection. (As to opposed to previously returning a collection of one empty string.)&lt;br /&gt;
** Added list behaviour to Str class.&lt;br /&gt;
&lt;br /&gt;
* Vectors&lt;br /&gt;
** New methods in cVector: DotProduct(), CrossProduct()&lt;br /&gt;
** New methods in cSpline: GetSegmentHandle(), GetMinLength()&lt;br /&gt;
** Both cVector and cPoint now implement '''* / *= /=''' operators as ''per component'' multipliers, e.g. [2, 2, 2] * [1, 3, 0.5] = [2, 6, 1]&lt;br /&gt;
** If cVector * cVector was previously used where a dot product was the intended result, that should now be replaced by the DotProduct() method.&lt;br /&gt;
** Tweaked the bezier behaviour that uses a single control point to better approximate a quadratic bezier.&lt;br /&gt;
&lt;br /&gt;
* Fader&lt;br /&gt;
** New methods in cFader: PlayMusic(), StopMusic(), DuckStart(), DuckRestore()&lt;br /&gt;
** Group 0 now counts as &amp;quot;no group&amp;quot;.&lt;br /&gt;
** Added &amp;quot;Null&amp;quot; behaviour - Fader sounds initialised with a name containing &amp;quot;Null&amp;quot; will not be associated with a sound entity in the map, but they can be included in a group and have a play state as normal.&lt;br /&gt;
** Fader sounds can now be marked as StopOnMusic. If Fader.PlayMusic() and Fader.StopMusic() are used, then Fader sounds with StopOnMusic will fade out when music starts.&lt;br /&gt;
&lt;br /&gt;
* Glitcher&lt;br /&gt;
** Fixed the afChanceScale multiplier when adding glitches. (Was previously inverted).&lt;br /&gt;
** Slightly reduced the default max glitch frequency, for smoother fades.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6757</id>
		<title>HPL2/HPL2 Helper Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6757"/>
		<updated>2024-02-03T11:53:08Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
=Introduction=&lt;br /&gt;
''HPL2 Helper Scripts'' by Aetheric Games is a package of .hps files containing script classes and functions that may be useful to HPL2 modders and custom story creators. It is compatible with ATDD version 1.5 and later.&lt;br /&gt;
&lt;br /&gt;
Would you like to...&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
...make 500 candles blow out in a big wave? ...make haunted objects hover in the air? ...spawn dozens of random debris objects throughout an area? ...make a particle system move along a spline? ...manage a list of quest objectives? ...compare the distances between entities? ...make puzzles based on position and rotation? ...store an array in a global game variable? ...seamlessly teleport the player into an ''almost'' identical room? ...make a statue that twitches when the player has low sanity?&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Well, this script package isn't going to magically do those things for you, but it gives you a ''lot'' of tools to help you do them yourself.&lt;br /&gt;
&lt;br /&gt;
The scripts are divided into two categories: ''utilities'' and ''features''. The ''utilities'' scripts include tools for general scripting, like new maths functions, or linked lists and vector classes. The ''features'' scripts are more specific solutions that make use of the utilities, such as a way to spawn entities at specific locations, script a large chain of events or to make entities twitch and flicker. Some modders might prefer to just adopt the ''utilities'' scripts. It's up to you!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''[[HPL2/HPL2 Helper Scripts#Set-up|See below for download and set-up instructions.]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Contents=&lt;br /&gt;
The documentation and help is organised by file. '''''Lots of help, and full details of the new classes and functions, can be found on the following pages:'''''&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Utilities==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Debug|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Debug'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides more control and options for debug messages and logging.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/GameVars|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''GameVars'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Extends the functionality of the saved game global and local variable wrappers.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Lists|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Lists'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for linked list classes.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/LoadWatcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''LoadWatcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides an &amp;quot;OnLoad()&amp;quot; global function.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Math|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Math'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended maths functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/String|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''String'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended string functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Vectors|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Vectors'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for vector classes.&lt;br /&gt;
||&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;||&lt;br /&gt;
==Features==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Bobber|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Bobber'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for floating or hovering entities, without physics.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Fader|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Fader'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing global ambient sounds.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Glitcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Glitcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing entities that appear to glitch or flicker.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Slimer|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Slimer'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing large sequences of entity actions.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Spawner|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Spawner'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for spawning entities at specific map locations.&lt;br /&gt;
:&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&amp;amp;nbsp;&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
::&amp;amp;nbsp;&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Misc|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Miscellaneous'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Bits and pieces that don't fit anywhere else.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Set-up=&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First, download ''HPL2 Helper Scripts'' from the [https://steamcommunity.com/sharedfiles/filedetails/?id=3101276708 Steam Workshop page] or [https://www.moddb.com/mods/hpl2-helper-scripts ModDb page] and unzip it.&lt;br /&gt;
&lt;br /&gt;
If you get it on Steam Workshop, you'll find the actual folder in your Steam Workshop downloads.&lt;br /&gt;
&lt;br /&gt;
The current version is [[HPL2/HPL2_Helper_Scripts#Version_1.1.2C_03.2F02.2F24|1.1]].&lt;br /&gt;
&lt;br /&gt;
Once you have zipped the folder, there are three options for how you add it into your mod. '''If you are unsure, just go with option A'''.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option A: The full feature-set package===&lt;br /&gt;
::If you want to be able to use all the new functions and classes, go with option A.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_FullPackage.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_FullPackage.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option B: The utilities-only package===&lt;br /&gt;
::Choose option B if you want to have access to the functions and classes in the ''utilities'' category, but don't need the stuff in the ''features'' category.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_UtilitiesOnly.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_UtilitiesOnly.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option C: Pick-n-mix===&lt;br /&gt;
::Advanced modders might prefer to only adopt the specific script files they need. Go nuts! But also be aware of the #include dependencies in each script file, as many of them are interdependent. You might find it easiest to start with option A or B and then remove scripts later that you definitely haven't used. You're also fully allowed and encouraged to just use HPL2HelperScripts as a learning resource or even to just copy snippets here and there.&lt;br /&gt;
&lt;br /&gt;
=Licence and Credits=&lt;br /&gt;
You are free to use ''HPL2 Helper Scripts'' in whatever way you see fit, no rights reserved by Aetheric Games. (As long as you're not going against any licence terms between you and Frictional Games, of course!) Aetheric Games is mostly just one person, mrbehemo, me (hello), and this has been a ''stupid'' amount of work, so if you find it helpful then it would be very cool of you to give me a credit in your mod or custom story. You can list it as &amp;quot;HPL2&amp;amp;nbsp;Helper&amp;amp;nbsp;Scripts&amp;amp;nbsp;by&amp;amp;nbsp;Aetheric&amp;amp;nbsp;Games&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This script package would not have been possible without the work of the tireless and patient Luis Rodero of Frictional Games, and the ever present pillar of the community, Mudbill. &lt;br /&gt;
&lt;br /&gt;
=Support=&lt;br /&gt;
''HPL2 Helper Scripts'' is made by mrbehemo of Aetheric Games. If you need support, here's what to do:&lt;br /&gt;
#First be sure that you're familar with the official [[HPL2/Engine_Scripts|HPL2 scripting reference]] and the [[HPL2/ScriptReference|community scripting guide]].&lt;br /&gt;
#And second, be sure that you've read the relevant parts of this documentation, including the FAQ.&lt;br /&gt;
#And then if you're still stuck I'll be happy to hear from you and will help if I can. Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server].&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
Fervently Anticipated Questions. Nobody's asked anything yet... &lt;br /&gt;
* I've added one or more scripts to my project separately, but I'm getting errors. What should I check?&lt;br /&gt;
** The script files are very interdependent. Check the .hps files you've added - they will have #include directives near the top for every other script they rely on. Either make sure you've also added ''those'' into your project.&lt;br /&gt;
* What's &amp;quot;#include&amp;quot;? What's &amp;quot;OnUpdate()&amp;quot;?&lt;br /&gt;
** Those are new features added with the ATDD [[HPL2/1.5 Update|1.5 update]].&lt;br /&gt;
* I want to make something weird happen, like make 100 flying naked guys do a loop-de-loop around the player. How?&lt;br /&gt;
** Sounds fun and is probably do-able! Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server] if you want advice.&lt;br /&gt;
* Can I get the player's camera direction yet?&lt;br /&gt;
** No, sorry. I investigated multiple ways of doing that, as have many people over the years. There's just no reliable way of doing it in HPL2 without branching the source code.&lt;br /&gt;
* What's a uint and why have you used them everywhere?&lt;br /&gt;
** A &amp;quot;U-int&amp;quot; is an unsigned integer, that is, an integer that can only be positive. I think it's best to use uint in scenarios where negative numbers are nonsensical. Behind the scenes it minimises the the chance of conversion issues, and also minimises warnings in the error output.&lt;br /&gt;
* Why are all your function arguments passed by reference, and why is that not reflected in the docs?&lt;br /&gt;
** In Angelscript there's a tiny, tiny performance saving gained from passing arguments by reference (and by using const where possible). It's not enough of a saving for modders and gameplay scripters to bother with, but since I was writing hundreds of them, it was an easy thing to do. It's not reflected in the docs because most non-advanced modders don't know what &amp;quot;pass by reference&amp;quot; means, or need to know.&lt;br /&gt;
* I looked at your code and you did it all weird. Why did you do it weird?&lt;br /&gt;
** It's probably because of the version of Angelscript that is integrated into HPL2. It has some surprising versatility but also some surprising limitations.&lt;br /&gt;
* Why did you do any of this?&lt;br /&gt;
** I know, I know - HPL2 is old now, I should have done this for The Bunker or whatever. Actually, I was just tidying up The Trapdoor (ATDD mod) for a Steam release, and I got carried away with refactoring it... and then, half a million characters of script later, this had happened. Hope it's useful. If not, it was a good exercise for me. Maybe ''you'' would like to port these scripts to HPL3 as and where needed! Go ahead, just be sure to credit and it'd be cool to let me know.&lt;br /&gt;
&lt;br /&gt;
=Change Log=&lt;br /&gt;
It should be simple to upgrade existing projects to use the current version, but take note of the changes listed below. You may need to make some minor edits.&lt;br /&gt;
&lt;br /&gt;
==Version 1.1, 03/02/24==&lt;br /&gt;
* General&lt;br /&gt;
** Changed some more spammy debug messages in level 2 to level 3 in various classes.&lt;br /&gt;
** Fixed various sign mismatch warnings between ints and uints.&lt;br /&gt;
&lt;br /&gt;
* Debug&lt;br /&gt;
** Default log verbosity is now 2 instead of 3.&lt;br /&gt;
&lt;br /&gt;
* GameVars&lt;br /&gt;
** Added SetIntAsUint() method, which is just SetInt() with an explicit cast.&lt;br /&gt;
&lt;br /&gt;
* Lists&lt;br /&gt;
** New properties for all list types: DefaultValue, Capacity&lt;br /&gt;
** New methods for all list types: Fill(), Extend(), AddUnique(), ToString()&lt;br /&gt;
** Fixed silent exception that occured when Insert() was used with index 0.&lt;br /&gt;
** Fixed silent exception that occured when Pop() was used with a count of 0 or 1.&lt;br /&gt;
** Fixed behaviour of Find() and RemoveItem() in cListGeneric.&lt;br /&gt;
** Added '''==''' operator to cListBase for checking if two lists of the same type are equal.&lt;br /&gt;
** Added optional argument abExtend to Set() methods.&lt;br /&gt;
** Fixed issue with incorrectly overloading Pop(), by moving the generic Pop() from cListBase to its correct place in cListGeneric.&lt;br /&gt;
&lt;br /&gt;
* Math&lt;br /&gt;
** New method in cMath: DistToEntity()&lt;br /&gt;
** RandomVector3d() and RandomVector2d(), when using the vecNormal option or when no range is specified, now have a chance of returning a vector with negative axes, whereas previously they were always positive.&lt;br /&gt;
&lt;br /&gt;
* String&lt;br /&gt;
** New method in cString: NearlyEqual()&lt;br /&gt;
** SplitToList() and SplitToArray() now handle empty strings by returning an empty collection. (As to opposed to previously returning a collection of one empty string.)&lt;br /&gt;
** Added list behaviour to Str class.&lt;br /&gt;
&lt;br /&gt;
* Vectors&lt;br /&gt;
** New methods in cVector: DotProduct(), CrossProduct()&lt;br /&gt;
** New methods in cSpline: GetBezierHandle(), GetMinLength()&lt;br /&gt;
** Both cVector and cPoint now implement '''* / *= /=''' operators as ''per component'' multipliers, e.g. [2, 2, 2] * [1, 3, 0.5] = [2, 6, 1]&lt;br /&gt;
** If cVector * cVector was previously used where a dot product was the intended result, that should now be replaced by the DotProduct() method.&lt;br /&gt;
** Tweaked the bezier behaviour that uses a single control point to better approximate a quadratic bezier.&lt;br /&gt;
&lt;br /&gt;
* Fader&lt;br /&gt;
** New methods in cFader: PlayMusic(), StopMusic(), DuckStart(), DuckRestore()&lt;br /&gt;
** Group 0 now counts as &amp;quot;no group&amp;quot;.&lt;br /&gt;
** Added &amp;quot;Null&amp;quot; behaviour - Fader sounds initialised with a name containing &amp;quot;Null&amp;quot; will not be associated with a sound entity in the map, but they can be included in a group and have a play state as normal.&lt;br /&gt;
** Fader sounds can now be marked as StopOnMusic. If Fader.PlayMusic() and Fader.StopMusic() are used, then Fader sounds with StopOnMusic will fade out when music starts.&lt;br /&gt;
&lt;br /&gt;
* Glitcher&lt;br /&gt;
** Fixed the afChanceScale multiplier when adding glitches. (Was previously inverted).&lt;br /&gt;
** Slightly reduced the default max glitch frequency, for smoother fades.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6756</id>
		<title>HPL2/HPL2 Helper Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6756"/>
		<updated>2024-02-03T11:51:24Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added change log section, inc 1.1&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
=Introduction=&lt;br /&gt;
''HPL2 Helper Scripts'' by Aetheric Games is a package of .hps files containing script classes and functions that may be useful to HPL2 modders and custom story creators. It is compatible with ATDD version 1.5 and later.&lt;br /&gt;
&lt;br /&gt;
Would you like to...&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
...make 500 candles blow out in a big wave? ...make haunted objects hover in the air? ...spawn dozens of random debris objects throughout an area? ...make a particle system move along a spline? ...manage a list of quest objectives? ...compare the distances between entities? ...make puzzles based on position and rotation? ...store an array in a global game variable? ...seamlessly teleport the player into an ''almost'' identical room? ...make a statue that twitches when the player has low sanity?&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Well, this script package isn't going to magically do those things for you, but it gives you a ''lot'' of tools to help you do them yourself.&lt;br /&gt;
&lt;br /&gt;
The scripts are divided into two categories: ''utilities'' and ''features''. The ''utilities'' scripts include tools for general scripting, like new maths functions, or linked lists and vector classes. The ''features'' scripts are more specific solutions that make use of the utilities, such as a way to spawn entities at specific locations, script a large chain of events or to make entities twitch and flicker. Some modders might prefer to just adopt the ''utilities'' scripts. It's up to you!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''[[HPL2/HPL2 Helper Scripts#Set-up|See below for download and set-up instructions.]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Contents=&lt;br /&gt;
The documentation and help is organised by file. '''''Lots of help, and full details of the new classes and functions, can be found on the following pages:'''''&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Utilities==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Debug|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Debug'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides more control and options for debug messages and logging.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/GameVars|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''GameVars'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Extends the functionality of the saved game global and local variable wrappers.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Lists|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Lists'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for linked list classes.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/LoadWatcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''LoadWatcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides an &amp;quot;OnLoad()&amp;quot; global function.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Math|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Math'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended maths functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/String|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''String'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended string functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Vectors|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Vectors'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for vector classes.&lt;br /&gt;
||&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;||&lt;br /&gt;
==Features==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Bobber|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Bobber'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for floating or hovering entities, without physics.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Fader|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Fader'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing global ambient sounds.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Glitcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Glitcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing entities that appear to glitch or flicker.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Slimer|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Slimer'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing large sequences of entity actions.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Spawner|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Spawner'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for spawning entities at specific map locations.&lt;br /&gt;
:&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&amp;amp;nbsp;&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
::&amp;amp;nbsp;&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Misc|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Miscellaneous'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Bits and pieces that don't fit anywhere else.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Set-up=&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First, download ''HPL2 Helper Scripts'' from the [https://steamcommunity.com/sharedfiles/filedetails/?id=3101276708 Steam Workshop page] or [https://www.moddb.com/mods/hpl2-helper-scripts ModDb page] and unzip it.&lt;br /&gt;
&lt;br /&gt;
If you get it on Steam Workshop, you'll find the actual folder in your Steam Workshop downloads.&lt;br /&gt;
&lt;br /&gt;
Once you have zipped the folder, there are three options for how you add it into your mod. '''If you are unsure, just go with option A'''.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option A: The full feature-set package===&lt;br /&gt;
::If you want to be able to use all the new functions and classes, go with option A.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_FullPackage.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_FullPackage.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option B: The utilities-only package===&lt;br /&gt;
::Choose option B if you want to have access to the functions and classes in the ''utilities'' category, but don't need the stuff in the ''features'' category.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_UtilitiesOnly.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_UtilitiesOnly.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option C: Pick-n-mix===&lt;br /&gt;
::Advanced modders might prefer to only adopt the specific script files they need. Go nuts! But also be aware of the #include dependencies in each script file, as many of them are interdependent. You might find it easiest to start with option A or B and then remove scripts later that you definitely haven't used. You're also fully allowed and encouraged to just use HPL2HelperScripts as a learning resource or even to just copy snippets here and there.&lt;br /&gt;
&lt;br /&gt;
=Licence and Credits=&lt;br /&gt;
You are free to use ''HPL2 Helper Scripts'' in whatever way you see fit, no rights reserved by Aetheric Games. (As long as you're not going against any licence terms between you and Frictional Games, of course!) Aetheric Games is mostly just one person, mrbehemo, me (hello), and this has been a ''stupid'' amount of work, so if you find it helpful then it would be very cool of you to give me a credit in your mod or custom story. You can list it as &amp;quot;HPL2&amp;amp;nbsp;Helper&amp;amp;nbsp;Scripts&amp;amp;nbsp;by&amp;amp;nbsp;Aetheric&amp;amp;nbsp;Games&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This script package would not have been possible without the work of the tireless and patient Luis Rodero of Frictional Games, and the ever present pillar of the community, Mudbill. &lt;br /&gt;
&lt;br /&gt;
=Support=&lt;br /&gt;
''HPL2 Helper Scripts'' is made by mrbehemo of Aetheric Games. If you need support, here's what to do:&lt;br /&gt;
#First be sure that you're familar with the official [[HPL2/Engine_Scripts|HPL2 scripting reference]] and the [[HPL2/ScriptReference|community scripting guide]].&lt;br /&gt;
#And second, be sure that you've read the relevant parts of this documentation, including the FAQ.&lt;br /&gt;
#And then if you're still stuck I'll be happy to hear from you and will help if I can. Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server].&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
Fervently Anticipated Questions. Nobody's asked anything yet... &lt;br /&gt;
* I've added one or more scripts to my project separately, but I'm getting errors. What should I check?&lt;br /&gt;
** The script files are very interdependent. Check the .hps files you've added - they will have #include directives near the top for every other script they rely on. Either make sure you've also added ''those'' into your project.&lt;br /&gt;
* What's &amp;quot;#include&amp;quot;? What's &amp;quot;OnUpdate()&amp;quot;?&lt;br /&gt;
** Those are new features added with the ATDD [[HPL2/1.5 Update|1.5 update]].&lt;br /&gt;
* I want to make something weird happen, like make 100 flying naked guys do a loop-de-loop around the player. How?&lt;br /&gt;
** Sounds fun and is probably do-able! Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server] if you want advice.&lt;br /&gt;
* Can I get the player's camera direction yet?&lt;br /&gt;
** No, sorry. I investigated multiple ways of doing that, as have many people over the years. There's just no reliable way of doing it in HPL2 without branching the source code.&lt;br /&gt;
* What's a uint and why have you used them everywhere?&lt;br /&gt;
** A &amp;quot;U-int&amp;quot; is an unsigned integer, that is, an integer that can only be positive. I think it's best to use uint in scenarios where negative numbers are nonsensical. Behind the scenes it minimises the the chance of conversion issues, and also minimises warnings in the error output.&lt;br /&gt;
* Why are all your function arguments passed by reference, and why is that not reflected in the docs?&lt;br /&gt;
** In Angelscript there's a tiny, tiny performance saving gained from passing arguments by reference (and by using const where possible). It's not enough of a saving for modders and gameplay scripters to bother with, but since I was writing hundreds of them, it was an easy thing to do. It's not reflected in the docs because most non-advanced modders don't know what &amp;quot;pass by reference&amp;quot; means, or need to know.&lt;br /&gt;
* I looked at your code and you did it all weird. Why did you do it weird?&lt;br /&gt;
** It's probably because of the version of Angelscript that is integrated into HPL2. It has some surprising versatility but also some surprising limitations.&lt;br /&gt;
* Why did you do any of this?&lt;br /&gt;
** I know, I know - HPL2 is old now, I should have done this for The Bunker or whatever. Actually, I was just tidying up The Trapdoor (ATDD mod) for a Steam release, and I got carried away with refactoring it... and then, half a million characters of script later, this had happened. Hope it's useful. If not, it was a good exercise for me. Maybe ''you'' would like to port these scripts to HPL3 as and where needed! Go ahead, just be sure to credit and it'd be cool to let me know.&lt;br /&gt;
&lt;br /&gt;
=Change Log=&lt;br /&gt;
It should be simple to upgrade existing projects to use the current version, but take note of the changes listed below. You may need to make some minor edits.&lt;br /&gt;
&lt;br /&gt;
==Version 1.1, 03/02/24==&lt;br /&gt;
* General&lt;br /&gt;
** Changed some more spammy debug messages in level 2 to level 3 in various classes.&lt;br /&gt;
** Fixed various sign mismatch warnings between ints and uints.&lt;br /&gt;
&lt;br /&gt;
* Debug&lt;br /&gt;
** Default log verbosity is now 2 instead of 3.&lt;br /&gt;
&lt;br /&gt;
* GameVars&lt;br /&gt;
** Added SetIntAsUint() method, which is just SetInt() with an explicit cast.&lt;br /&gt;
&lt;br /&gt;
* Lists&lt;br /&gt;
** New properties for all list types: DefaultValue, Capacity&lt;br /&gt;
** New methods for all list types: Fill(), Extend(), AddUnique(), ToString()&lt;br /&gt;
** Fixed silent exception that occured when Insert() was used with index 0.&lt;br /&gt;
** Fixed silent exception that occured when Pop() was used with a count of 0 or 1.&lt;br /&gt;
** Fixed behaviour of Find() and RemoveItem() in cListGeneric.&lt;br /&gt;
** Added '''==''' operator to cListBase for checking if two lists of the same type are equal.&lt;br /&gt;
** Added optional argument abExtend to Set() methods.&lt;br /&gt;
** Fixed issue with incorrectly overloading Pop(), by moving the generic Pop() from cListBase to its correct place in cListGeneric.&lt;br /&gt;
&lt;br /&gt;
* Math&lt;br /&gt;
** New method in cMath: DistToEntity()&lt;br /&gt;
** RandomVector3d() and RandomVector2d(), when using the vecNormal option or when no range is specified, now have a chance of returning a vector with negative axes, whereas previously they were always positive.&lt;br /&gt;
&lt;br /&gt;
* String&lt;br /&gt;
** New method in cString: NearlyEqual()&lt;br /&gt;
** SplitToList() and SplitToArray() now handle empty strings by returning an empty collection. (As to opposed to previously returning a collection of one empty string.)&lt;br /&gt;
** Added list behaviour to Str class.&lt;br /&gt;
&lt;br /&gt;
* Vectors&lt;br /&gt;
** New methods in cVector: DotProduct(), CrossProduct()&lt;br /&gt;
** New methods in cSpline: GetBezierHandle(), GetMinLength()&lt;br /&gt;
** Both cVector and cPoint now implement '''* / *= /=''' operators as ''per component'' multipliers, e.g. [2, 2, 2] * [1, 3, 0.5] = [2, 6, 1]&lt;br /&gt;
** If cVector * cVector was previously used where a dot product was the intended result, that should now be replaced by the DotProduct() method.&lt;br /&gt;
** Tweaked the bezier behaviour that uses a single control point to better approximate a quadratic bezier.&lt;br /&gt;
&lt;br /&gt;
* Fader&lt;br /&gt;
** New methods in cFader: PlayMusic(), StopMusic(), DuckStart(), DuckRestore()&lt;br /&gt;
** Group 0 now counts as &amp;quot;no group&amp;quot;.&lt;br /&gt;
** Added &amp;quot;Null&amp;quot; behaviour - Fader sounds initialised with a name containing &amp;quot;Null&amp;quot; will not be associated with a sound entity in the map, but they can be included in a group and have a play state as normal.&lt;br /&gt;
** Fader sounds can now be marked as StopOnMusic. If Fader.PlayMusic() and Fader.StopMusic() are used, then Fader sounds with StopOnMusic will fade out when music starts.&lt;br /&gt;
&lt;br /&gt;
* Glitcher&lt;br /&gt;
** Fixed the afChanceScale multiplier when adding glitches. (Was previously inverted).&lt;br /&gt;
** Slightly reduced the default max glitch frequency, for smoother fades.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6696</id>
		<title>HPL2/HPL2 Helper Scripts/Lists</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6696"/>
		<updated>2024-01-06T12:02:20Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Lists.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;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_Lists.hps&amp;quot; adds support for linked list classes. For beginners or other people not familiar with classes, these are best thought of as new variable types. A linked list, or just &amp;quot;list&amp;quot;, is a type of collection that works similarly to an array. Both lists and arrays are ways of grouping multiple variables together under one name.&lt;br /&gt;
&lt;br /&gt;
There are three main advantages to using lists over arrays. The first is that it is more efficient (and more performant) to insert, remove or re-order items in the list than it would be with an array. The second is that lists can also take up less memory than arrays. The memory requirement of an array is defined by its maximum capacity, whereas the memory requirement of a list is only as much as its current content. And therefore the third advantage is that it is not necessary to know in advance how big a list needs to be - it expands automatically as items are added. (And of course, advanced users may note that there are exceptions when an array would be more efficient, but most users won't need to worry about this.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
Declare a list like any other variable, then use the methods below to work with it. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt myList;		// Declares a new cListInt, called myList, ready to collect integers.&lt;br /&gt;
myList.Add(68);			// Appends the first integer (68) to the list at index 0.&lt;br /&gt;
myList.Add(419);		// Appends the second integer (419) to the list at index 1.&lt;br /&gt;
myList.Get(0);			// Retrieves the integer at index 0.&lt;br /&gt;
myList.Set(1, 99);		// Overwrites the integer at index 1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Indices===&lt;br /&gt;
Like arrays, you can ''get'' the items in the list using an index operator, e.g. myList[0], myList[22], myList[LastIndex]. And like arrays, the index number is '''zero based'''. In a list or array of ten items, the first index is 0 and the last index is 9.&lt;br /&gt;
&lt;br /&gt;
Getting an item from a list by its index is equivalent to using the Get() method. However, ''unlike arrays'', this is '''read-only'''. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);		// OK&lt;br /&gt;
string myStringOne = myToDoList[1];				// OK&lt;br /&gt;
&lt;br /&gt;
myToDoList.Set(0, &amp;quot;Paint over the lines.&amp;quot;);		// OK&lt;br /&gt;
myToDoList[1] = &amp;quot;Cut the cheese.&amp;quot;;				// Not OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(This seems to be because the version of AngelScript used in HPL2 seems to only allow the index operator to ''get'' and not ''set''. If I'm wrong and you can make this work, let me know!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
&amp;quot;HelperScripts_Lists.hps&amp;quot; also defines cListNodeBase and several derived node classes for each type of list. The list classes all inherit from the base class cListBase, which defines some shared functionality and handles anything that doesn't depend on the type of the stored data.&lt;br /&gt;
&lt;br /&gt;
Additionally, cListGeneric is an extra list class intended for advanced users. It extends the cListBase class without defining an inner data type, to help with making custom node classes derived from cListNodeBase. Advanced users attempting this may find it helpful to take a look at the cListBase and cListGeneric definition, and to read up on how AngelScript uses object handles. Examples can be found in most of the ''features'' scripts, e.g. &amp;quot;HelperScripts_Slimer.hps&amp;quot;, which implements multiple custom node classes and nested lists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=List classes=&lt;br /&gt;
&lt;br /&gt;
Available list classes: &amp;lt;code&amp;gt;cListInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListPoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;List classes&amp;quot; section refers to all the list types unless otherwise stated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
Lists can be declared in the same way as other variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat listOfFloats;					// Declares a list of floats.&lt;br /&gt;
cListString listOfStrings;					// Declares a list of strings.&lt;br /&gt;
&lt;br /&gt;
myListOfFloats.Add(0.001f);					// Calling a method of the referred list.&lt;br /&gt;
int numStrings = myListOfStrings.Count;		// Accessing a property of the referred list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with capacity===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(uint aulMaxSize)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the list is initialised with a constructor, then a maximum capacity can be specified for the list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the list is declared without a specific capacity, then the default maximum capacity is assigned, which is 65535 (or 2^16 - 1).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat listOfFloatsDefault;&lt;br /&gt;
cListVector listOfVectorsDefault;&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfUpToFiveFloats = cListFloat(5);&lt;br /&gt;
cListVector listOfUpTo1000Vectors = cListVector(1000);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default 65535 (2^16-1) is the maximum capacity that can be indexed. Using this a or smaller arbitrary limit can help to catch runaway bugs. '''Advanced users''' may try changing the value of mulCountMax to use a smaller default maximum. Using a larger maximum will likely cause problems.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that arrays require as much memory as their full capacity even when empty, but lists are only ever as big as their content, so lowering the maximum size of the list does not help performance. But it might be useful in certain situations where a limit is required by design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with data===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(float[] afArray)&lt;br /&gt;
cListBase(cListBase aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Lists can be initialised with data by passing an array of values of the relevant type, or an existing list. The default capacity is used for the new list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the source is an array, the new list will contain copies of the array's contents. If the source is an existing list, then the new list will copy the ''link'' to the original items. Both the old and new lists will point to the same data, and changing one will change the other. To avoid this, see the [[HPL2/HPL2_Helper_Scripts/Lists#Copy.28.29|Copy()]] method.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListFloat myFirstList = cListFloat(myArray);			// Makes a new float list by copying items from the float array.&lt;br /&gt;
cListFloat mySecondList = myFirstList;					// Makes a new float list containing the same items as the other list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat(float afSingleFloat)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
All the derived list classes ('''except for cListGeneric and cListInt''') can be initialised with data by passing a single value of the relevant type, to become the first item in the list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat myList = cListFloat(1.2f);				// Makes a new float list with a single value.&lt;br /&gt;
myList.Add(2.3f);									// myList now contains: 1.2f, 2.3f&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
'''All list classes''' provide the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Count====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Count&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Count returns the current number of items in the list.&lt;br /&gt;
(The property Length and the method length() are provided for consistency with arrays, and are both equivalent to Count.)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat myList;&lt;br /&gt;
uint ulCountA = myList.Count;&lt;br /&gt;
myList.Add(99.99f);&lt;br /&gt;
uint ulCountB = myList.Count;&lt;br /&gt;
// ulCountA is 0. ulCountB is 1.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (listNumbers.Count &amp;lt; 6) listNumber.Add(42);&lt;br /&gt;
// The condition succeeds if the count is less than 6, and another number is added.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the last valid index, or -1 if the list is empty.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
uint ulA = myListOfStrings.LastIndex;&lt;br /&gt;
uint ulB = myListOfStrings.Count - 1;&lt;br /&gt;
// ulA and ulB are equal&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string sLatest = myListOfStrings[myListOfStrings.LastIndex];&lt;br /&gt;
// sLatest becomes whatever string was added to the list most recently.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsEmpty====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEmpty&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsEmpty returns true if the list is empty, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (myList.IsEmpty) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list contains no items.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsFull====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsFull&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsFull returns true if the list is full to its maximum capacity, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (!myList.IsFull) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list has space for another item.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Assignment====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase = cListBase&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The assignment operator (equals sign &amp;quot;=&amp;quot;) assigns a new set of data to the list, copied from another list. Note: the list contains handles to the data, not the data itself. So when a list is copied, ''both'' lists now refer to the same data, and any changes made to either will affect both.&lt;br /&gt;
&amp;lt;br&amp;gt;If the intent is to make a duplicate of the ''data'' rather than the list handles, then the Copy() method is recommended.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for assigning items to the list:&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(int alItem)&lt;br /&gt;
bool Add(float afItem)&lt;br /&gt;
bool Add(double adItem)&lt;br /&gt;
bool Add(bool abItem)&lt;br /&gt;
bool Add(string asItem)&lt;br /&gt;
bool Add(cVector avItem)&lt;br /&gt;
bool Add(cPoint avItem)&lt;br /&gt;
bool Add(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Creates a new item appended to the list. If the list is full or the item cannot be added, it returns false. If it was successfull appended, it returns true.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfFloats.Add(1.0f);&lt;br /&gt;
myListOfPoints.Add(cPoint(10, 15, 20));&lt;br /&gt;
// The new values are appended to the list.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!listNumbers.Add(-1.0f)) Debug.Message(1, &amp;quot;Error - could not add to list!&amp;quot;);&lt;br /&gt;
// The condition succeeds if Add failed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Set()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Set(uint aulIndex, int alItem)&lt;br /&gt;
bool Set(uint aulIndex, float afItem)&lt;br /&gt;
bool Set(uint aulIndex, double adItem)&lt;br /&gt;
bool Set(uint aulIndex, bool abItem)&lt;br /&gt;
bool Set(uint aulIndex, string asItem)&lt;br /&gt;
bool Set(uint aulIndex, cVector avItem)&lt;br /&gt;
bool Set(uint aulIndex, cPoint avItem)&lt;br /&gt;
bool Set(uint aulIndex, cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to an indexed item in the list, if it exists. If the list is shorter than the index or the item cannot be added, this returns false. If it was successfull set, it returns true.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be changed.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be assigned.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
myListOfBools.Set(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, replacing the previous one.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Insert()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Insert(uint aulIndex, int alItem)&lt;br /&gt;
bool Insert(uint aulIndex, float afItem)&lt;br /&gt;
bool Insert(uint aulIndex, double adItem)&lt;br /&gt;
bool Insert(uint aulIndex, bool abItem)&lt;br /&gt;
bool Insert(uint aulIndex, string asItem)&lt;br /&gt;
bool Insert(uint aulIndex, cVector avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cPoint avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Inserts a new item into the list at the given index. (The item previous at that index becomes the next one.) If the given index is not a valid place to insert an item, then then return value will be false. Otherwise the item is inserted and it returns true.&lt;br /&gt;
#''uint aulIndex'' - The index where the new item will be inserted.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be inserted.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfBools.Insert(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, displacing the previous one to index 8.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!myList.Insert(10, &amp;quot;hello&amp;quot;) myList.Add(&amp;quot;hello&amp;quot;);&lt;br /&gt;
// Attempts to insert the string at index 10, and if that fails the string is appended instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Concatenate()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Concatenate(cListBase aList)&lt;br /&gt;
bool Concatenate(int[] alArray)&lt;br /&gt;
bool Concatenate(float[] afArray)&lt;br /&gt;
bool Concatenate(double[] adArray)&lt;br /&gt;
bool Concatenate(bool[] abArray)&lt;br /&gt;
bool Concatenate(string[] asArray)&lt;br /&gt;
bool Concatenate(cVector[] avArray)&lt;br /&gt;
bool Concatenate(cPoint[] avArray)&lt;br /&gt;
bool Concatenate(cRotator[] avArray)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Takes either a second list or array of the same type and appends it to this one. It first checks to make sure there is enough capacity. Returns true if items were successfully added, or false if not.&lt;br /&gt;
&amp;lt;br&amp;gt;If an array is supplied, new list items are created to match them. If a list is suplied the items are '''not duplicated''' - both lists refer to the same items in memory, and changing them will change both lists.&lt;br /&gt;
#''cListBase aList (or any list type), or an array of int[], float[], double[], bool[], string[], cVector[], cPoint[] or cRotator[]'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
float[] arrayOfFloatsB = { 3.0f, 4.0f };&lt;br /&gt;
listOfFloatsA.Concatenate(arrayOfFloatsB);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 4.0f.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfFloatsB;&lt;br /&gt;
listOfFloatsB.Add(3.0f);&lt;br /&gt;
listOfFloatsB.Add(4.0f);&lt;br /&gt;
&lt;br /&gt;
listOfFloatsA.Concatenate(listOfFloatsB);&lt;br /&gt;
listOfFloatsA.Set(3, 99.9f);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 99.9f.&lt;br /&gt;
// listOfFloatsB now contains 3.0f, 99.9f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for retrieving items from the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Get()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Get(uint aulIndex)&lt;br /&gt;
float Get(uint aulIndex)&lt;br /&gt;
double Get(uint aulIndex)&lt;br /&gt;
bool Get(uint aulIndex)&lt;br /&gt;
string Get(uint aulIndex)&lt;br /&gt;
cVector Get(uint aulIndex)&lt;br /&gt;
cPoint Get(uint aulIndex)&lt;br /&gt;
cRotator Get(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, if it exists. If the item does not exist in the list, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;br&amp;gt;See GetIfValid() if you want to be sure the item exists. You can also use an index operator (e.g. myList[i]) to get list items.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);&lt;br /&gt;
string myStringLast = myToDoList.Get(myToDoList.LastIndex);&lt;br /&gt;
// myStringZero becomes the value from the start of the list.&lt;br /&gt;
// myStringLast becomes the value that happens to be at the end of the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIfValid()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GetIfValid(uint aulIndex, int &amp;amp;out alTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, float &amp;amp;out afTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, double &amp;amp;out adTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, bool &amp;amp;out abTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, string &amp;amp;out asTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cVector &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cPoint &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cRotator &amp;amp;out avTarget)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, as long as it is valid.&lt;br /&gt;
&amp;lt;br&amp;gt;The second parameter is an ''ouput'' parameter. If the item at the given index exists then '''the item is assigned to the Target &amp;amp;out parameter''', and the function returns true. If the item doesn't exist in the list, the function returns false.&lt;br /&gt;
&amp;lt;br&amp;gt;See Get() if you don't care about validation and just want to return the item.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
#''int alTarget, float afTarget, double adTarget, bool abTarget, string asTarget, cVector avTarget, cPoint avTarget, or cRotator avTarget'' - The variable, of the appropriate type, where the retrieved item will be '''stored'''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int retrievedInteger;&lt;br /&gt;
if(!myListOfInts.GetIfValid(3, retrievedInteger)) retrievedInteger = -1;&lt;br /&gt;
// retrievedInteger will be assigned the value retrieved from index 3 in the list, if it exists.&lt;br /&gt;
// If it doesn't exist, the condition will succeed and retrievedInteger with be assigned -1 instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetRandom()&lt;br /&gt;
float GetRandom()&lt;br /&gt;
double GetRandom()&lt;br /&gt;
bool GetRandom()&lt;br /&gt;
string GetRandom()&lt;br /&gt;
cVector GetRandom()&lt;br /&gt;
cPoint GetRandom()&lt;br /&gt;
cRotator GetRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list and returns it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pop()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Pop()&lt;br /&gt;
float Pop()&lt;br /&gt;
double Pop()&lt;br /&gt;
bool Pop()&lt;br /&gt;
string Pop()&lt;br /&gt;
cVector Pop()&lt;br /&gt;
cPoint Pop()&lt;br /&gt;
cRotator Pop()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the last item in the list, and removes that item. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lA = listNumbers.Pop();&lt;br /&gt;
int lB = listNumbers.Pop();&lt;br /&gt;
int lC = listNumbers.Pop();&lt;br /&gt;
// lA, lB, and lC have become 23, 16, and 15. myArray now contains only 4 and 8.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PopRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int PopRandom()&lt;br /&gt;
float PopRandom()&lt;br /&gt;
double PopRandom()&lt;br /&gt;
bool PopRandom()&lt;br /&gt;
string PopRandom()&lt;br /&gt;
cVector PopRandom()&lt;br /&gt;
cPoint PopRandom()&lt;br /&gt;
cRotator PopRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list, returns it and them removes it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors, and that value is no longer available in the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Copy()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt Copy(cListInt aList)&lt;br /&gt;
cListFloat Copy(cListFloat aList)&lt;br /&gt;
cListDouble Copy(cListDouble aList)&lt;br /&gt;
cListBool Copy(cListBool aList)&lt;br /&gt;
cListVector Copy(cListVector aList)&lt;br /&gt;
cListPoint Copy(cListPoint aList)&lt;br /&gt;
cListRotator Copy(cListRotator aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a new list that is a duplicate of this list. The items in the new list are new items. Changing either list will not affect the other.&lt;br /&gt;
#''cListBase aList (or any list type)'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Removing list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for removing items from the list: (See also: Pop() and PopRandom())&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAt(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and removes the given index.&lt;br /&gt;
Returns true if the index was valid and was removed, or false if not.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myList.RemoveAt(7);&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (myList.RemoveAt(7)) myList.Append(&amp;quot;something new&amp;quot;);&lt;br /&gt;
// If the removal was successful, then a new value is appended.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveItem(int alItem)&lt;br /&gt;
bool RemoveItem(float afItem)&lt;br /&gt;
bool RemoveItem(double adItem)&lt;br /&gt;
bool RemoveItem(bool abItem)&lt;br /&gt;
bool RemoveItem(string asItem)&lt;br /&gt;
bool RemoveItem(cVector avItem)&lt;br /&gt;
bool RemoveItem(cPoint avItem)&lt;br /&gt;
bool RemoveItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and removes the first matching item it finds. Returns true if the item was found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
myListOfBools.RemoveItem(false);&lt;br /&gt;
// The first instance of false in the list will be removed.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
int  lRemoved = 0;&lt;br /&gt;
int[] myArray = { 4, 8, 0, 15, 16, 0, 23, 0 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
while (listNumbers.Remove(0))&lt;br /&gt;
{&lt;br /&gt;
    lRemoved++;&lt;br /&gt;
	DoStuff();&lt;br /&gt;
}&lt;br /&gt;
// The Remove() call will repeat until it returns false, at which point the value of lRemoved will be 3.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAll()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAll(int alItem)&lt;br /&gt;
bool RemoveAll(float aItem)&lt;br /&gt;
bool RemoveAll(double aItem)&lt;br /&gt;
bool RemoveAll(bool aItem)&lt;br /&gt;
bool RemoveAll(string aItem)&lt;br /&gt;
bool RemoveAll(cVector aItem)&lt;br /&gt;
bool RemoveAll(cPoint aItem)&lt;br /&gt;
bool RemoveAll(cRotator aItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and removes the all matching items. Returns true if any items were found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
myListOfFloats.RemoveAll(0.0f);&lt;br /&gt;
// All the zeros will be removed from the list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Searching lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for searching for items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Find()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Find(int alItem)&lt;br /&gt;
int Find(float afItem)&lt;br /&gt;
int Find(double adItem)&lt;br /&gt;
int Find(bool abItem)&lt;br /&gt;
int Find(string asItem)&lt;br /&gt;
int Find(cVector avItem)&lt;br /&gt;
int Find(cPoint avItem)&lt;br /&gt;
int Find(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns the index of the first match. If the item is not found, -1 is returned instead.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
uint lIndexTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
uint lIndexFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// lIndexTwentyTwo becomes 1. lIndexFortyFour becomes -1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Contains()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Contains(int alItem)&lt;br /&gt;
bool Contains(float afItem)&lt;br /&gt;
bool Contains(double adItem)&lt;br /&gt;
bool Contains(bool abItem)&lt;br /&gt;
bool Contains(string asItem)&lt;br /&gt;
bool Contains(cVector avItem)&lt;br /&gt;
bool Contains(cPoint avItem)&lt;br /&gt;
bool Contains(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns true if found, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
bool bHasTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
bool bHasFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// bHasTwentyTwo becomes true. bHasFortyFour becomes false.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CountItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint CountItem(int alItem)&lt;br /&gt;
uint CountItem(float afItem)&lt;br /&gt;
uint CountItem(double adItem)&lt;br /&gt;
uint CountItem(bool abItem)&lt;br /&gt;
uint CountItem(string asItem)&lt;br /&gt;
uint CountItem(cVector avItem)&lt;br /&gt;
uint CountItem(cPoint avItem)&lt;br /&gt;
uint CountItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and returns the number of matches found.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myListOfStrings;&lt;br /&gt;
myListOfStrings.Add(&amp;quot;up&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;sideways&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
int lNumDown = myListOfStrings.CountItem(&amp;quot;down&amp;quot;);&lt;br /&gt;
int lNumForward = myListOfStrings.CountItem(&amp;quot;forward&amp;quot;);&lt;br /&gt;
// lNumDown becomes 2. lNumForward becomes 0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Numeric lists===&lt;br /&gt;
Some of the derived list classes dealing with numeric values provide the methods for arithmetic operations across the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Min()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Min()&lt;br /&gt;
float Min()&lt;br /&gt;
double Min()&lt;br /&gt;
bool Min()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns false if there is a false - like logical AND over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fSmallest = fRandomList.Min();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the smallest is assigned to fSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Max()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Max()&lt;br /&gt;
float Max()&lt;br /&gt;
double Max()&lt;br /&gt;
bool Max()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - like logical OR over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fLargest = fRandomList.Max();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the largest is assigned to fLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMin()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMin()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lSmallest = fRandomList.FindMin();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the smallest is assigned to lSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMax()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMax()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lLargest = fRandomList.FindMax();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the largest is assigned to lLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sum()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Sum()&lt;br /&gt;
float Sum()&lt;br /&gt;
double Sum()&lt;br /&gt;
bool Sum()&lt;br /&gt;
cVector Sum()&lt;br /&gt;
cPoint Sum()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the total of all the items in the list, added together. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - the same as logical OR. For vectors, this is equivalent to the combined path of each vector.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lTot = listNumbers.Sum();&lt;br /&gt;
// lTot becomes 108.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListPoint listGridSteps;&lt;br /&gt;
listGridSteps.Add(cPoint(1, 0));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(-1, 0));&lt;br /&gt;
&lt;br /&gt;
cPoint vFinalPos = listGridSteps.Sum()&lt;br /&gt;
// This example imagines a puzzle involving steps on a grid. Each step is stored in a list of points and the final position is the sum of the list. (0,2 in this case.)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Average()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Average()&lt;br /&gt;
float Average()&lt;br /&gt;
double Average()&lt;br /&gt;
bool Average()&lt;br /&gt;
cVector Average()&lt;br /&gt;
cPoint Average()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the mean average of all the items in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that for ints, the answer will be truncated. For bools, this basically returns true if there are more true items than false. For vectors this is like finding the &amp;quot;centre of balance&amp;quot; of some points.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lAvg = listNumbers.Average();&lt;br /&gt;
// lAvg becomes 18.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListVector listGruntPos;&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt1&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt2&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt3&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
SetEntityPosVec(&amp;quot;orb&amp;quot;, listGruntPos.Average());&lt;br /&gt;
// This example imagines an effect where an entity is positioned at the mid-point between 3 enemies.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Ordering lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for ordering items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Swap()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Swap(uint aulA, uint aulB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Swaps the places of two items in the array. Returns false if either of the indeces are invalid, or true if the swap went ahead.&lt;br /&gt;
#''uint aulA'' - The index of the first item to be swapped.&lt;br /&gt;
#''uint aulB'' - The index of the second item to be swapped.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Swap(0, 1);&lt;br /&gt;
myListOfInts.Swap(1, 2);&lt;br /&gt;
// After the two swaps, the list is in numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sort()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Sort(abDescending = false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Re-orders a list of numbers, to put them in numerical order, using bubble sort. Bubble sort is simple but inefficient, so sorting large lists very frequently will have a performance impact. cListInt, cListFloat, cListDouble, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For vectors, the list will be sorted by square length.&lt;br /&gt;
#''bool abDescending (optional, default = false)'' - If true, the items will be ordered highest-to-lowest, otherwise lowest-to-highest.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Sort();&lt;br /&gt;
// The list is now sorted into ascending numerical order.&lt;br /&gt;
myListOfInts.Sort(true);&lt;br /&gt;
// The list is now sorted into descending numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Shuffle()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Shuffle()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Changes the order of the list to a new, random order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
for (int i = 1; i &amp;lt;= 10; i++) myListOfInts.Add(i);&lt;br /&gt;
myListOfInts.Shuffle();&lt;br /&gt;
// The list now contains the numbers 1 to 10, in a random order with no repetition or missing numbers.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Converting lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for converting lists into other types of collections:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int[] ToArray()&lt;br /&gt;
float[] ToArray()&lt;br /&gt;
double[] ToArray()&lt;br /&gt;
string[] ToArray()&lt;br /&gt;
cVector[] ToArray()&lt;br /&gt;
cPoint[] ToArray()&lt;br /&gt;
cRotator[] ToArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes a new array, where each element in the array is a copy of an item from the list, and returns the array.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] ToStringArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes a new array, where each element in the array is a string version of each item in the list, and returns the array. (Uses the ToString() method of each node class.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a new string representing the whole list, by getting string versions of each item in the list and joining them. (Uses the ToString() method of each node class, and the Join() method of cString.) (Coming soon, this entry is a placeholder!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Node classes=&lt;br /&gt;
The node classes contain the actual items in the lists and provide ways to access the data or links between nodes. Generally, it is '''not recommended''' to work with these directly, but use the functions of the list classes instead. More '''advanced users''' can extend the cListNodeBase class, or any class, and use it with cListGeneric.&lt;br /&gt;
&lt;br /&gt;
Available node classes: &amp;lt;code&amp;gt;cListNodeInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodePoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Behaviours===&lt;br /&gt;
In the derived node classes, the default constructor creates a node with a default item, or an argument can be provided to set the initial value. For example, in the cListNodeInt class:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeInt() 					// Creates an int node with value 0.&lt;br /&gt;
cListNodeInt(int alItem)		// Creates an int node with value alItem.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Properties===&lt;br /&gt;
All dervied node classes have one public property, named Item:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Item&lt;br /&gt;
float Item&lt;br /&gt;
double Item&lt;br /&gt;
bool Item&lt;br /&gt;
string Item&lt;br /&gt;
cVector Item&lt;br /&gt;
cPoint Item&lt;br /&gt;
cRotator Item&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The property Item can get or set the data item in the node, using the appropriate type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNext(cListNodeBase@ ahNext)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a handle to the next node. To break the link, assign null or use ClearNext().&lt;br /&gt;
#''cListNodeBase@ ahNext'' - A handle to an instance of cListNodeBase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeBase@ GetNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ClearNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Resets the handle to the next node to null&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6695</id>
		<title>HPL2/HPL2 Helper Scripts/Lists</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6695"/>
		<updated>2024-01-06T12:00:13Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Lists.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;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_Lists.hps&amp;quot; adds support for linked list classes. For beginners or other people not familiar with classes, these are best thought of as new variable types. A linked list, or just &amp;quot;list&amp;quot;, is a type of collection that works similarly to an array. Both lists and arrays are ways of grouping multiple variables together under one name.&lt;br /&gt;
&lt;br /&gt;
There are three main advantages to using lists over arrays. The first is that it is more efficient (and more performant) to insert, remove or re-order items in the list than it would be with an array. The second is that lists can also take up less memory than arrays. The memory requirement of an array is defined by its maximum capacity, whereas the memory requirement of a list is only as much as its current content. And therefore the third advantage is that it is not necessary to know in advance how big a list needs to be - it expands automatically as items are added. (And of course, advanced users may note that there are exceptions when an array would be more efficient, but most users won't need to worry about this.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
Declare a list like any other variable, then use the methods below to work with it. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt myList;		// Declares a new cListInt, called myList, ready to collect integers.&lt;br /&gt;
myList.Add(68);			// Appends the first integer (68) to the list at index 0.&lt;br /&gt;
myList.Add(419);		// Appends the second integer (419) to the list at index 1.&lt;br /&gt;
myList.Get(0);			// Retrieves the integer at index 0.&lt;br /&gt;
myList.Set(1, 99);		// Overwrites the integer at index 1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Indices===&lt;br /&gt;
Like arrays, you can ''get'' the items in the list using an index operator, e.g. myList[0], myList[22], myList[LastIndex]. And like arrays, the index number is '''zero based'''. In a list or array of ten items, the first index is 0 and the last index is 9.&lt;br /&gt;
&lt;br /&gt;
Getting an item from a list by its index is equivalent to using the Get() method. However, ''unlike arrays'', this is '''read-only'''. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);		// OK&lt;br /&gt;
string myStringOne = myToDoList[1];				// OK&lt;br /&gt;
&lt;br /&gt;
myToDoList.Set(0, &amp;quot;Paint over the lines.&amp;quot;);		// OK&lt;br /&gt;
myToDoList[1] = &amp;quot;Cut the cheese.&amp;quot;;				// Not OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(This seems to be because the version of AngelScript used in HPL2 seems to only allow the index operator to ''get'' and not ''set''. If I'm wrong and you can make this work, let me know!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
&amp;quot;HelperScripts_Lists.hps&amp;quot; also defines cListNodeBase and several derived node classes for each type of list. The list classes all inherit from the base class cListBase, which defines some shared functionality and handles anything that doesn't depend on the type of the stored data.&lt;br /&gt;
&lt;br /&gt;
Additionally, cListGeneric is an extra list class intended for advanced users. It extends the cListBase class without defining an inner data type, to help with making custom node classes derived from cListNodeBase. Advanced users attempting this may find it helpful to take a look at the cListBase and cListGeneric definition, and to read up on how AngelScript uses object handles. Examples can be found in most of the ''features'' scripts, e.g. &amp;quot;HelperScripts_Slimer.hps&amp;quot;, which implements multiple custom node classes and nested lists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=List classes=&lt;br /&gt;
&lt;br /&gt;
Available list classes: &amp;lt;code&amp;gt;cListInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListPoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;List classes&amp;quot; section refers to all the list types unless otherwise stated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
Lists can be declared in the same way as other variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat listOfFloats;					// Declares a list of floats.&lt;br /&gt;
cListString listOfStrings;					// Declares a list of strings.&lt;br /&gt;
&lt;br /&gt;
myListOfFloats.Add(0.001f);					// Calling a method of the referred list.&lt;br /&gt;
int numStrings = myListOfStrings.Count;		// Accessing a property of the referred list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with capacity===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(uint aulMaxSize)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the list is initialised with a constructor, then a maximum capacity can be specified for the list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the list is declared without a specific capacity, then the default maximum capacity is assigned, which is 65535 (or 2^16 - 1).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat listOfFloatsDefault;&lt;br /&gt;
cListVector listOfVectorsDefault;&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfUpToFiveFloats = cListFloat(5);&lt;br /&gt;
cListVector listOfUpTo1000Vectors = cListVector(1000);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default 65535 (2^16-1) is the maximum capacity that can be indexed. Using this a or smaller arbitrary limit can help to catch runaway bugs. '''Advanced users''' may try changing the value of mulCountMax to use a smaller default maximum. Using a larger maximum will likely cause problems.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that arrays require as much memory as their full capacity even when empty, but lists are only ever as big as their content, so lowering the maximum size of the list does not help performance. But it might be useful in certain situations where a limit is required by design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with data===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(float[] afArray)&lt;br /&gt;
cListBase(cListBase aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Lists can be initialised with data by passing an array of values of the relevant type, or an existing list. The default capacity is used for the new list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the source is an array, the new list will contain copies of the array's contents. If the source is an existing list, then the new list will copy the ''link'' to the original items. Both the old and new lists will point to the same data, and changing one will change the other. To avoid this, see the [[HPL2/HPL2_Helper_Scripts/Lists#Copy.28.29|Copy()]] method.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListFloat myFirstList = cListFloat(myArray);			// Makes a new float list by copying items from the float array.&lt;br /&gt;
cListFloat mySecondList = myFirstList;					// Makes a new float list containing the same items as the other list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat(float afSingleFloat)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
All the derived list classes ('''except for cListGeneric and cListInt''') can be initialised with data by passing a single value of the relevant type, to become the first item in the list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat myList = cListFloat(1.2f);				// Makes a new float list with a single value.&lt;br /&gt;
myList.Add(2.3f);									// myList now contains: 1.2f, 2.3f&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
'''All list classes''' provide the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Count====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Count&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Count returns the current number of items in the list.&lt;br /&gt;
(The property Length and the method length() are provided for consistency with arrays, and are both equivalent to Count.)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat myList;&lt;br /&gt;
uint ulCountA = myList.Count;&lt;br /&gt;
myList.Add(99.99f);&lt;br /&gt;
uint ulCountB = myList.Count;&lt;br /&gt;
// ulCountA is 0. ulCountB is 1.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (listNumbers.Count &amp;lt; 6) listNumber.Add(42);&lt;br /&gt;
// The condition succeeds if the count is less than 6, and another number is added.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the last valid index, or -1 if the list is empty.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
uint ulA = myListOfStrings.LastIndex;&lt;br /&gt;
uint ulB = myListOfStrings.Count - 1;&lt;br /&gt;
// ulA and ulB are equal&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string sLatest = myListOfStrings[myListOfStrings.LastIndex];&lt;br /&gt;
// sLatest becomes whatever string was added to the list most recently.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsEmpty====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEmpty&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsEmpty returns true if the list is empty, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (myList.IsEmpty) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list contains no items.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsFull====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsFull&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsFull returns true if the list is full to its maximum capacity, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (!myList.IsFull) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list has space for another item.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Assignment====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase = cListBase&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The assignment operator (equals sign &amp;quot;=&amp;quot;) assigns a new set of data to the list, copied from another list. Note: the list contains handles to the data, not the data itself. So when a list is copied, ''both'' lists now refer to the same data, and any changes made to either will affect both.&lt;br /&gt;
&amp;lt;br&amp;gt;If the intent is to make a duplicate of the ''data'' rather than the list handles, then the Copy() method is recommended.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for assigning items to the list:&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(int alItem)&lt;br /&gt;
bool Add(float afItem)&lt;br /&gt;
bool Add(double adItem)&lt;br /&gt;
bool Add(bool abItem)&lt;br /&gt;
bool Add(string asItem)&lt;br /&gt;
bool Add(cVector avItem)&lt;br /&gt;
bool Add(cPoint avItem)&lt;br /&gt;
bool Add(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Creates a new item appended to the list. If the list is full or the item cannot be added, it returns false. If it was successfull appended, it returns true.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfFloats.Add(1.0f);&lt;br /&gt;
myListOfPoints.Add(cPoint(10, 15, 20));&lt;br /&gt;
// The new values are appended to the list.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!listNumbers.Add(-1.0f)) Debug.Message(1, &amp;quot;Error - could not add to list!&amp;quot;);&lt;br /&gt;
// The condition succeeds if Add failed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Set()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Set(uint aulIndex, int alItem)&lt;br /&gt;
bool Set(uint aulIndex, float afItem)&lt;br /&gt;
bool Set(uint aulIndex, double adItem)&lt;br /&gt;
bool Set(uint aulIndex, bool abItem)&lt;br /&gt;
bool Set(uint aulIndex, string asItem)&lt;br /&gt;
bool Set(uint aulIndex, cVector avItem)&lt;br /&gt;
bool Set(uint aulIndex, cPoint avItem)&lt;br /&gt;
bool Set(uint aulIndex, cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to an indexed item in the list, if it exists. If the list is shorter than the index or the item cannot be added, this returns false. If it was successfull set, it returns true.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be changed.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be assigned.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
myListOfBools.Set(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, replacing the previous one.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Insert()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Insert(uint aulIndex, int alItem)&lt;br /&gt;
bool Insert(uint aulIndex, float afItem)&lt;br /&gt;
bool Insert(uint aulIndex, double adItem)&lt;br /&gt;
bool Insert(uint aulIndex, bool abItem)&lt;br /&gt;
bool Insert(uint aulIndex, string asItem)&lt;br /&gt;
bool Insert(uint aulIndex, cVector avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cPoint avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Inserts a new item into the list at the given index. (The item previous at that index becomes the next one.) If the given index is not a valid place to insert an item, then then return value will be false. Otherwise the item is inserted and it returns true.&lt;br /&gt;
#''uint aulIndex'' - The index where the new item will be inserted.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be inserted.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfBools.Insert(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, displacing the previous one to index 8.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!myList.Insert(10, &amp;quot;hello&amp;quot;) myList.Add(&amp;quot;hello&amp;quot;);&lt;br /&gt;
// Attempts to insert the string at index 10, and if that fails the string is appended instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Concatenate()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Concatenate(cListBase aList)&lt;br /&gt;
bool Concatenate(int[] alArray)&lt;br /&gt;
bool Concatenate(float[] afArray)&lt;br /&gt;
bool Concatenate(double[] adArray)&lt;br /&gt;
bool Concatenate(bool[] abArray)&lt;br /&gt;
bool Concatenate(string[] asArray)&lt;br /&gt;
bool Concatenate(cVector[] avArray)&lt;br /&gt;
bool Concatenate(cPoint[] avArray)&lt;br /&gt;
bool Concatenate(cRotator[] avArray)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Takes either a second list or array of the same type and appends it to this one. It first checks to make sure there is enough capacity. Returns true if items were successfully added, or false if not.&lt;br /&gt;
&amp;lt;br&amp;gt;If an array is supplied, new list items are created to match them. If a list is suplied the items are '''not duplicated''' - both lists refer to the same items in memory, and changing them will change both lists.&lt;br /&gt;
#''cListBase aList (or any list type), or an array of int[], float[], double[], bool[], string[], cVector[], cPoint[] or cRotator[]'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
float[] arrayOfFloatsB = { 3.0f, 4.0f };&lt;br /&gt;
listOfFloatsA.Concatenate(arrayOfFloatsB);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 4.0f.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfFloatsB;&lt;br /&gt;
listOfFloatsB.Add(3.0f);&lt;br /&gt;
listOfFloatsB.Add(4.0f);&lt;br /&gt;
&lt;br /&gt;
listOfFloatsA.Concatenate(listOfFloatsB);&lt;br /&gt;
listOfFloatsA.Set(3, 99.9f);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 99.9f.&lt;br /&gt;
// listOfFloatsB now contains 3.0f, 99.9f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for retrieving items from the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Get()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Get(uint aulIndex)&lt;br /&gt;
float Get(uint aulIndex)&lt;br /&gt;
double Get(uint aulIndex)&lt;br /&gt;
bool Get(uint aulIndex)&lt;br /&gt;
string Get(uint aulIndex)&lt;br /&gt;
cVector Get(uint aulIndex)&lt;br /&gt;
cPoint Get(uint aulIndex)&lt;br /&gt;
cRotator Get(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, if it exists. If the item does not exist in the list, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;br&amp;gt;See GetIfValid() if you want to be sure the item exists. You can also use an index operator (e.g. myList[i]) to get list items.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);&lt;br /&gt;
string myStringLast = myToDoList.Get(myToDoList.LastIndex);&lt;br /&gt;
// myStringZero becomes the value from the start of the list.&lt;br /&gt;
// myStringLast becomes the value that happens to be at the end of the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIfValid()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GetIfValid(uint aulIndex, int &amp;amp;out alTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, float &amp;amp;out afTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, double &amp;amp;out adTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, bool &amp;amp;out abTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, string &amp;amp;out asTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cVector &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cPoint &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cRotator &amp;amp;out avTarget)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, as long as it is valid.&lt;br /&gt;
&amp;lt;br&amp;gt;The second parameter is an ''ouput'' parameter. If the item at the given index exists then '''the item is assigned to the Target &amp;amp;out parameter''', and the function returns true. If the item doesn't exist in the list, the function returns false.&lt;br /&gt;
&amp;lt;br&amp;gt;See Get() if you don't care about validation and just want to return the item.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
#''int alTarget, float afTarget, double adTarget, bool abTarget, string asTarget, cVector avTarget, cPoint avTarget, or cRotator avTarget'' - The variable, of the appropriate type, where the retrieved item will be '''stored'''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int retrievedInteger;&lt;br /&gt;
if(!myListOfInts.GetIfValid(3, retrievedInteger)) retrievedInteger = -1;&lt;br /&gt;
// retrievedInteger will be assigned the value retrieved from index 3 in the list, if it exists.&lt;br /&gt;
// If it doesn't exist, the condition will succeed and retrievedInteger with be assigned -1 instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetRandom()&lt;br /&gt;
float GetRandom()&lt;br /&gt;
double GetRandom()&lt;br /&gt;
bool GetRandom()&lt;br /&gt;
string GetRandom()&lt;br /&gt;
cVector GetRandom()&lt;br /&gt;
cPoint GetRandom()&lt;br /&gt;
cRotator GetRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list and returns it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pop()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Pop()&lt;br /&gt;
float Pop()&lt;br /&gt;
double Pop()&lt;br /&gt;
bool Pop()&lt;br /&gt;
string Pop()&lt;br /&gt;
cVector Pop()&lt;br /&gt;
cPoint Pop()&lt;br /&gt;
cRotator Pop()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the last item in the list, and removes that item. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lA = listNumbers.Pop();&lt;br /&gt;
int lB = listNumbers.Pop();&lt;br /&gt;
int lC = listNumbers.Pop();&lt;br /&gt;
// lA, lB, and lC have become 23, 16, and 15. myArray now contains only 4 and 8.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PopRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int PopRandom()&lt;br /&gt;
float PopRandom()&lt;br /&gt;
double PopRandom()&lt;br /&gt;
bool PopRandom()&lt;br /&gt;
string PopRandom()&lt;br /&gt;
cVector PopRandom()&lt;br /&gt;
cPoint PopRandom()&lt;br /&gt;
cRotator PopRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list, returns it and them removes it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors, and that value is no longer available in the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Copy()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt Copy(cListInt aList)&lt;br /&gt;
cListFloat Copy(cListFloat aList)&lt;br /&gt;
cListDouble Copy(cListDouble aList)&lt;br /&gt;
cListBool Copy(cListBool aList)&lt;br /&gt;
cListVector Copy(cListVector aList)&lt;br /&gt;
cListPoint Copy(cListPoint aList)&lt;br /&gt;
cListRotator Copy(cListRotator aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a new list that is a duplicate of this list. The items in the new list are new items. Changing either list will not affect the other.&lt;br /&gt;
#''cListBase aList (or any list type)'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Removing list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for removing items from the list: (See also: Pop() and PopRandom())&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAt(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and removes the given index.&lt;br /&gt;
Returns true if the index was valid and was removed, or false if not.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myList.RemoveAt(7);&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (myList.RemoveAt(7)) myList.Append(&amp;quot;something new&amp;quot;);&lt;br /&gt;
// If the removal was successful, then a new value is appended.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveItem(int alItem)&lt;br /&gt;
bool RemoveItem(float afItem)&lt;br /&gt;
bool RemoveItem(double adItem)&lt;br /&gt;
bool RemoveItem(bool abItem)&lt;br /&gt;
bool RemoveItem(string asItem)&lt;br /&gt;
bool RemoveItem(cVector avItem)&lt;br /&gt;
bool RemoveItem(cPoint avItem)&lt;br /&gt;
bool RemoveItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and removes the first matching item it finds. Returns true if the item was found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
myListOfBools.RemoveItem(false);&lt;br /&gt;
// The first instance of false in the list will be removed.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
int  lRemoved = 0;&lt;br /&gt;
int[] myArray = { 4, 8, 0, 15, 16, 0, 23, 0 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
while (listNumbers.Remove(0))&lt;br /&gt;
{&lt;br /&gt;
    lRemoved++;&lt;br /&gt;
	DoStuff();&lt;br /&gt;
}&lt;br /&gt;
// The Remove() call will repeat until it returns false, at which point the value of lRemoved will be 3.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAll()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAll(int alItem)&lt;br /&gt;
bool RemoveAll(float aItem)&lt;br /&gt;
bool RemoveAll(double aItem)&lt;br /&gt;
bool RemoveAll(bool aItem)&lt;br /&gt;
bool RemoveAll(string aItem)&lt;br /&gt;
bool RemoveAll(cVector aItem)&lt;br /&gt;
bool RemoveAll(cPoint aItem)&lt;br /&gt;
bool RemoveAll(cRotator aItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and removes the all matching items. Returns true if any items were found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
myListOfFloats.RemoveAll(0.0f);&lt;br /&gt;
// All the zeros will be removed from the list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Searching lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for searching for items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Find()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Find(int alItem)&lt;br /&gt;
int Find(float afItem)&lt;br /&gt;
int Find(double adItem)&lt;br /&gt;
int Find(bool abItem)&lt;br /&gt;
int Find(string asItem)&lt;br /&gt;
int Find(cVector avItem)&lt;br /&gt;
int Find(cPoint avItem)&lt;br /&gt;
int Find(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns the index of the first match. If the item is not found, -1 is returned instead.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
uint lIndexTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
uint lIndexFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// lIndexTwentyTwo becomes 1. lIndexFortyFour becomes -1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Contains()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Contains(int alItem)&lt;br /&gt;
bool Contains(float afItem)&lt;br /&gt;
bool Contains(double adItem)&lt;br /&gt;
bool Contains(bool abItem)&lt;br /&gt;
bool Contains(string asItem)&lt;br /&gt;
bool Contains(cVector avItem)&lt;br /&gt;
bool Contains(cPoint avItem)&lt;br /&gt;
bool Contains(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns true if found, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
bool bHasTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
bool bHasFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// bHasTwentyTwo becomes true. bHasFortyFour becomes false.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CountItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint CountItem(int alItem)&lt;br /&gt;
uint CountItem(float afItem)&lt;br /&gt;
uint CountItem(double adItem)&lt;br /&gt;
uint CountItem(bool abItem)&lt;br /&gt;
uint CountItem(string asItem)&lt;br /&gt;
uint CountItem(cVector avItem)&lt;br /&gt;
uint CountItem(cPoint avItem)&lt;br /&gt;
uint CountItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and returns the number of matches found.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myListOfStrings;&lt;br /&gt;
myListOfStrings.Add(&amp;quot;up&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;sideways&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
int lNumDown = myListOfStrings.CountItem(&amp;quot;down&amp;quot;);&lt;br /&gt;
int lNumForward = myListOfStrings.CountItem(&amp;quot;forward&amp;quot;);&lt;br /&gt;
// lNumDown becomes 2. lNumForward becomes 0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Numeric lists===&lt;br /&gt;
Some of the derived list classes dealing with numeric values provide the methods for arithmetic operations across the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Min()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Min()&lt;br /&gt;
float Min()&lt;br /&gt;
double Min()&lt;br /&gt;
bool Min()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns false if there is a false - like logical AND over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fSmallest = fRandomList.Min();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the smallest is assigned to fSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Max()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Max()&lt;br /&gt;
float Max()&lt;br /&gt;
double Max()&lt;br /&gt;
bool Max()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - like logical OR over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fLargest = fRandomList.Max();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the largest is assigned to fLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMin()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMin()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lSmallest = fRandomList.FindMin();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the smallest is assigned to lSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMax()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMax()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lLargest = fRandomList.FindMax();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the largest is assigned to lLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sum()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Sum()&lt;br /&gt;
float Sum()&lt;br /&gt;
double Sum()&lt;br /&gt;
bool Sum()&lt;br /&gt;
cVector Sum()&lt;br /&gt;
cPoint Sum()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the total of all the items in the list, added together. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - the same as logical OR. For vectors, this is equivalent to the combined path of each vector.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lTot = listNumbers.Sum();&lt;br /&gt;
// lTot becomes 108.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListPoint listGridSteps;&lt;br /&gt;
listGridSteps.Add(cPoint(1, 0));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(-1, 0));&lt;br /&gt;
&lt;br /&gt;
cPoint vFinalPos = listGridSteps.Sum()&lt;br /&gt;
// This example imagines a puzzle involving steps on a grid. Each step is stored in a list of points and the final position is the sum of the list. (0,2 in this case.)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Average()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Average()&lt;br /&gt;
float Average()&lt;br /&gt;
double Average()&lt;br /&gt;
bool Average()&lt;br /&gt;
cVector Average()&lt;br /&gt;
cPoint Average()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the mean average of all the items in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that for ints, the answer will be truncated. For bools, this basically returns true if there are more true items than false. For vectors this is like finding the &amp;quot;centre of balance&amp;quot; of some points.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lAvg = listNumbers.Average();&lt;br /&gt;
// lAvg becomes 18.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListVector listGruntPos;&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt1&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt2&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt3&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
SetEntityPosVec(&amp;quot;orb&amp;quot;, listGruntPos.Average());&lt;br /&gt;
// This example imagines an effect where an entity is positioned at the mid-point between 3 enemies.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Ordering lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for ordering items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Swap()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Swap(uint aulA, uint aulB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Swaps the places of two items in the array. Returns false if either of the indeces are invalid, or true if the swap went ahead.&lt;br /&gt;
#''uint aulA'' - The index of the first item to be swapped.&lt;br /&gt;
#''uint aulB'' - The index of the second item to be swapped.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Swap(0, 1);&lt;br /&gt;
myListOfInts.Swap(1, 2);&lt;br /&gt;
// After the two swaps, the list is in numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sort()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Sort(abDescending = false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Re-orders a list of numbers, to put them in numerical order, using bubble sort. Bubble sort is simple but inefficient, so sorting large lists very frequently will have a performance impact. cListInt, cListFloat, cListDouble, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For vectors, the list will be sorted by square length.&lt;br /&gt;
#''bool abDescending (optional, default = false)'' - If true, the items will be ordered highest-to-lowest, otherwise lowest-to-highest.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Sort();&lt;br /&gt;
// The list is now sorted into ascending numerical order.&lt;br /&gt;
myListOfInts.Sort(true);&lt;br /&gt;
// The list is now sorted into descending numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Shuffle()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Shuffle()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Changes the order of the list to a new, random order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
for (int i = 1; i &amp;lt;= 10; i++) myListOfInts.Add(i);&lt;br /&gt;
myListOfInts.Shuffle();&lt;br /&gt;
// The list now contains the numbers 1 to 10, in a random order with no repetition or missing numbers.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Converting lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for converting lists into other types of collections:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int[] ToArray()&lt;br /&gt;
float[] ToArray()&lt;br /&gt;
double[] ToArray()&lt;br /&gt;
string[] ToArray()&lt;br /&gt;
cVector[] ToArray()&lt;br /&gt;
cPoint[] ToArray()&lt;br /&gt;
cRotator[] ToArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes a new array, where each element in the array is a copy of an item from the list, and returns the array.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] ToStringArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes a new array, where each element in the array is a string version of each item in the list, and returns the array. (Uses the ToString() method of each node class.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes a new string representing the whole list, by joining string versions of each item in the list, and returns the string. (Uses the ToString() method of each node class, and the Join() method of cString.) (Coming soon, this entry is a placeholder!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Node classes=&lt;br /&gt;
The node classes contain the actual items in the lists and provide ways to access the data or links between nodes. Generally, it is '''not recommended''' to work with these directly, but use the functions of the list classes instead. More '''advanced users''' can extend the cListNodeBase class, or any class, and use it with cListGeneric.&lt;br /&gt;
&lt;br /&gt;
Available node classes: &amp;lt;code&amp;gt;cListNodeInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodePoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Behaviours===&lt;br /&gt;
In the derived node classes, the default constructor creates a node with a default item, or an argument can be provided to set the initial value. For example, in the cListNodeInt class:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeInt() 					// Creates an int node with value 0.&lt;br /&gt;
cListNodeInt(int alItem)		// Creates an int node with value alItem.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Properties===&lt;br /&gt;
All dervied node classes have one public property, named Item:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Item&lt;br /&gt;
float Item&lt;br /&gt;
double Item&lt;br /&gt;
bool Item&lt;br /&gt;
string Item&lt;br /&gt;
cVector Item&lt;br /&gt;
cPoint Item&lt;br /&gt;
cRotator Item&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The property Item can get or set the data item in the node, using the appropriate type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNext(cListNodeBase@ ahNext)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a handle to the next node. To break the link, assign null or use ClearNext().&lt;br /&gt;
#''cListNodeBase@ ahNext'' - A handle to an instance of cListNodeBase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeBase@ GetNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ClearNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Resets the handle to the next node to null&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:HPL2/Tutorials/CustomSounds&amp;diff=6694</id>
		<title>Hpl2:HPL2/Tutorials/CustomSounds</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:HPL2/Tutorials/CustomSounds&amp;diff=6694"/>
		<updated>2024-01-05T17:33:01Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Adding custom sounds =&lt;br /&gt;
== Preparing the sounds ==&lt;br /&gt;
&lt;br /&gt;
First you'll need a sound-editting program; [https://www.audacityteam.org/ Audacity] is a common choice - it is free and will suit most needs.&lt;br /&gt;
&lt;br /&gt;
The sounds need to be in '''.ogg ''' format. If your sound files are formatted as '''.MP3''', '''.WAV''' or anything else, you need to use one your audio editing software of choice to convert your sound file to an '''.ogg''' file format. In Audacity, you just need to drag the file into the program and then export as '''.ogg'''.&lt;br /&gt;
&lt;br /&gt;
{{tip|It is recommended to use mono files. Stereo should only be used for music and ambient tracks, because it will play directly at the player rather than play in 3D.}}&lt;br /&gt;
&lt;br /&gt;
If you only want to play this sound as music, you can skip the next few steps and jump right to the custom music section.&lt;br /&gt;
&lt;br /&gt;
== Managing sound files ==&lt;br /&gt;
&lt;br /&gt;
In your mod's (FC or CS, doesn't matter) folder, create a folder for sounds. It can be called however you want, but '''sounds''' would probably be the best.&lt;br /&gt;
&lt;br /&gt;
{{tip|If your mod has a lot of custom sounds, make sure to organise them into subfolders!}}&lt;br /&gt;
&lt;br /&gt;
Place the tutorial.ogg file in the created (sub)folder.&lt;br /&gt;
&lt;br /&gt;
== Creating the sound entity file ==&lt;br /&gt;
&lt;br /&gt;
The behaviour of the sound in the game is determined by a &amp;quot;sound entity&amp;quot; file. These files have a '''.snt''' extension.&lt;br /&gt;
&lt;br /&gt;
For the fastest workflow, copy an existing sound file that works similarly to how you want and change its name. Then alter the contents of that file rather than writing them from scratch. &lt;br /&gt;
&lt;br /&gt;
{{tip|If using Notepad++, right-click a .snt file and pick Notepad++ to edit the file.}}&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can do the following:&lt;br /&gt;
&lt;br /&gt;
Create a '''.txt''' file and name it what you want (same as the .ogg file is common), open it with any text editor you use.[[Notepad%2B%2B | Notepad++]] is recommended. When you finish editing the file, change the extension to the correct one. I named my file '''tutorial.snt'''.&lt;br /&gt;
&lt;br /&gt;
{{tip|Other extensions might work, but it is recommended to give sound files the .snt extension used by the main game. This will allow your sound to be placed in a level without scripting.}}&lt;br /&gt;
&lt;br /&gt;
In the file, you can edit quite a few things, and among them is..''Adding your sound-file into the script!'' And since my sound file is &amp;lt;u&amp;gt;'''door'''&amp;lt;/u&amp;gt;'''.ogg''', It shall go to the '''MAIN''' section. Random soundfiles will be covered later on.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;SOUNDENTITY&amp;gt;&lt;br /&gt;
 &amp;lt;SOUNDS&amp;gt;&lt;br /&gt;
   &amp;lt;Main&amp;gt;&lt;br /&gt;
      &amp;lt;Sound File=&amp;quot;door.ogg&amp;quot; /&amp;gt;&lt;br /&gt;
   	&amp;lt;/Main&amp;gt;&lt;br /&gt;
   &amp;lt;/SOUNDS&amp;gt;&lt;br /&gt;
   &amp;lt;PROPERTIES Volume=&amp;quot;5&amp;quot; MinDistance=&amp;quot;1&amp;quot; MaxDistance=&amp;quot;50&amp;quot; Random=&amp;quot;0&amp;quot; Interval=&amp;quot;0&amp;quot; FadeEnd=&amp;quot;False&amp;quot; FadeStart=&amp;quot;False&amp;quot; Stream=&amp;quot;False&amp;quot; Loop=&amp;quot;False&amp;quot; Use3D=&amp;quot;false&amp;quot; Blockable=&amp;quot;False&amp;quot; BlockVolumeMul=&amp;quot;0.7&amp;quot; Priority=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/SOUNDENTITY&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Format explanation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''SOUNDENTITY'''&amp;gt; is the start marker of the sound file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''SOUNDS'''&amp;gt; indicates the sound list&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''Main'''&amp;gt; is the list of sounds the file will play.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''Sound File'''=&amp;quot;''YourFileName''.ogg&amp;quot; /&amp;gt; is the way to add a file to the sound. Adding multiple files will play them randomly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''PROPERTIES'''&amp;gt; Are all the options you may use to decide how the sound will behave in-game.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
&lt;br /&gt;
* '''Volume''' is how loud the sound should play. '''Volume=1''' would make the sound play at the normal volume of the sound file. '''Volume=0.5''' would half as loud. '''Volume=2''' would amplify the sound to twice its normal volume.&lt;br /&gt;
&lt;br /&gt;
* '''MinDistance''' and '''MaxDistance''' are used for attenuation, which means how the sound fades out over distance. Within the '''MinDistance''' the sound will be at the full '''Volume''' level. As the player moves from '''MinDistance''' to '''MaxDistance''' away from the sound, the volume will fade towards silence. Outside of '''MaxDistance''' it does not play at all.&lt;br /&gt;
&lt;br /&gt;
* '''Loop''' should be set to '''&amp;quot;true&amp;quot;''' if the sound should loop.&lt;br /&gt;
&lt;br /&gt;
* '''Use3D''' should be set to '''&amp;quot;true&amp;quot;''' if the sound should originate from a point in the game world. Otherwise it will be all around the player and will not fade with distance.&lt;br /&gt;
&lt;br /&gt;
Well thats it! You now created your very own sound! Place it in the map with the Level Editor or use it with &amp;lt;code&amp;gt;PlaySoundAtEntity();&amp;lt;/code&amp;gt; in your level script (check [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] for details).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===More advanced .snt properties===&lt;br /&gt;
&lt;br /&gt;
* '''Loop''', '''Random''' and '''Interval''' are all used together to define whether and how the sound should loop. '''Loop=true''' will make the sound repeat. If '''Interval''' is 0 then the sound will loop continuously, but if '''Interval''' is set to a value &amp;gt; 0, then that becomes a delay inserted between the repeitions. If '''Random''' is set to a value &amp;gt; 0 and &amp;lt; 1, then it defines the random chance of the sound playing on that interval. If '''Random''' is &amp;lt;=0 or &amp;gt;=1, then the sound will always play every interval.&lt;br /&gt;
For example, an ambient background track that should play continuously with no gaps should have:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;Random=&amp;quot;1&amp;quot; Interval=&amp;quot;0&amp;quot; Loop=&amp;quot;true&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
A sound that should repeat periodically, with a 25% chance of playing again every 15 seconds would be defined like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;Random=&amp;quot;0.25&amp;quot; Interval=&amp;quot;15&amp;quot; Loop=&amp;quot;true&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Random''' does ''not'' affect the random variant sounds listed in the .snt file. Those each have an equal chance of playing, although the engine will try to stop them from playing twice in a row if possible.&lt;br /&gt;
&lt;br /&gt;
* '''Use3D''' causes the sound to originate from a point in space, and move between the left and right stereo channels, but it is also required for attenuation. If '''Use3D''' is false, then the sound will have no stereo separation but it will also not fade over distance. Only mono sounds can be used as 3D. Stereo sounds retain the the left/right channel in the sound file and always behave as '''Use3d=&amp;quot;false&amp;quot;'''.&lt;br /&gt;
&lt;br /&gt;
* '''Stream''' defines whether the sound can be preloaded. '''Stream=&amp;quot;false&amp;quot;''' is the normal behaviour for short sounds that are loaded into memory and played when needed. '''Stream=&amp;quot;true&amp;quot;''' makes the sound play from the disk. This is slower but saves memory, so should be used for large sound files that are played rarely.&lt;br /&gt;
&lt;br /&gt;
* '''FadeEnd''' and '''FadeStart''', if true, will cause looping sounds to fade in or out on their first or last repetition.&lt;br /&gt;
&lt;br /&gt;
* '''Blockable''', '''BlockVolumeMul''', and '''Priority''' do not seem to be implemented in the engine. ''('''Blockable''' and '''BlockVolumeMul''' may have been intended to define how the sounds are muffled by world geometry, and '''Priority''' may have been intended to be used when culling sounds. Although all three properties are read from the .snt file, they do not seem to be referenced in any other code.)'' {{confirm}}&lt;br /&gt;
&lt;br /&gt;
* '''&amp;lt;SOUNDS&amp;gt;''' categories: as well as '''&amp;lt;Main&amp;gt;''' the engine will also read lists of sounds from '''&amp;lt;Start&amp;gt;''' and '''&amp;lt;Stop&amp;gt;''' nodes. These may provide alternate sounds for the beginning and end of a loop. {{confirm}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Adding custom music==&lt;br /&gt;
&lt;br /&gt;
Custom music only needs to be a file in the '''.ogg''' format. It won't need an '''.snt''' file to be played with &amp;lt;code&amp;gt;PlayMusic();&amp;lt;/code&amp;gt; or at the credits, but you won't be able to use &amp;lt;code&amp;gt;PlaySoundAtEntity();&amp;lt;/code&amp;gt; with this file.&lt;br /&gt;
&lt;br /&gt;
Just like with sounds, it is good to create a folder for music in the mod's main folder, e.g. '''music'''. Put the '''.ogg''' file there.&lt;br /&gt;
&lt;br /&gt;
See [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] to learn how to use &amp;lt;code&amp;gt;PlayMusic();&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that only one music file can play at a time. For ambient sound, it is better to create a sound file (like described earlier). That way you can layer ambient sound with actual music when needed.&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:HPL2/Tutorials/CustomSounds&amp;diff=6693</id>
		<title>Hpl2:HPL2/Tutorials/CustomSounds</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:HPL2/Tutorials/CustomSounds&amp;diff=6693"/>
		<updated>2024-01-05T12:17:51Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Adding custom sounds =&lt;br /&gt;
== Preparing the sounds ==&lt;br /&gt;
&lt;br /&gt;
First you'll need a sound-editting program; [https://www.audacityteam.org/ Audacity] is a common choice - it is free and will suit most needs.&lt;br /&gt;
&lt;br /&gt;
The sounds need to be in '''.ogg ''' format. If your sound files are formatted as '''.MP3''', '''.WAV''' or anything else, you need to use one your audio editing software of choice to convert your sound file to an '''.ogg''' file format. In Audacity, you just need to drag the file into the program and then export as '''.ogg'''.&lt;br /&gt;
&lt;br /&gt;
{{tip|It is recommended to use mono files. Stereo should only be used for music and ambient tracks, because it will play directly at the player rather than play in 3D.}}&lt;br /&gt;
&lt;br /&gt;
If you only want to play this sound as music, you can skip the next few steps and jump right to the custom music section.&lt;br /&gt;
&lt;br /&gt;
== Managing sound files ==&lt;br /&gt;
&lt;br /&gt;
In your mod's (FC or CS, doesn't matter) folder, create a folder for sounds. It can be called however you want, but '''sounds''' would probably be the best.&lt;br /&gt;
&lt;br /&gt;
{{tip|If your mod has a lot of custom sounds, make sure to organise them into subfolders!}}&lt;br /&gt;
&lt;br /&gt;
Place the tutorial.ogg file in the created (sub)folder.&lt;br /&gt;
&lt;br /&gt;
== Creating the sound entity file ==&lt;br /&gt;
&lt;br /&gt;
The behaviour of the sound in the game is determined by a &amp;quot;sound entity&amp;quot; file. These files have a '''.snt''' extension.&lt;br /&gt;
&lt;br /&gt;
For the fastest workflow, copy an existing sound file that works similarly to how you want and change its name. Then alter the contents of that file rather than writing them from scratch. &lt;br /&gt;
&lt;br /&gt;
{{tip|If using Notepad++, right-click a .snt file and pick Notepad++ to edit the file.}}&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can do the following:&lt;br /&gt;
&lt;br /&gt;
Create a '''.txt''' file and name it what you want (same as the .ogg file is common), open it with any text editor you use.[[Notepad%2B%2B | Notepad++]] is recommended. When you finish editing the file, change the extension to the correct one. I named my file '''tutorial.snt'''.&lt;br /&gt;
&lt;br /&gt;
{{tip|Other extensions might work, but it is recommended to give sound files the .snt extension used by the main game. This will allow your sound to be placed in a level without scripting.}}&lt;br /&gt;
&lt;br /&gt;
In the file, you can edit quite a few things, and among them is..''Adding your sound-file into the script!'' And since my sound file is &amp;lt;u&amp;gt;'''door'''&amp;lt;/u&amp;gt;'''.ogg''', It shall go to the '''MAIN''' section. Random soundfiles will be covered later on.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;SOUNDENTITY&amp;gt;&lt;br /&gt;
 &amp;lt;SOUNDS&amp;gt;&lt;br /&gt;
   &amp;lt;Main&amp;gt;&lt;br /&gt;
      &amp;lt;Sound File=&amp;quot;door.ogg&amp;quot; /&amp;gt;&lt;br /&gt;
   	&amp;lt;/Main&amp;gt;&lt;br /&gt;
   &amp;lt;/SOUNDS&amp;gt;&lt;br /&gt;
   &amp;lt;PROPERTIES Volume=&amp;quot;5&amp;quot; MinDistance=&amp;quot;1&amp;quot; MaxDistance=&amp;quot;50&amp;quot; Random=&amp;quot;0&amp;quot; Interval=&amp;quot;0&amp;quot; FadeEnd=&amp;quot;False&amp;quot; FadeStart=&amp;quot;False&amp;quot; Stream=&amp;quot;False&amp;quot; Loop=&amp;quot;False&amp;quot; Use3D=&amp;quot;false&amp;quot; Blockable=&amp;quot;False&amp;quot; BlockVolumeMul=&amp;quot;0.7&amp;quot; Priority=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/SOUNDENTITY&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Format explanation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''SOUNDENTITY'''&amp;gt; is the start marker of the sound file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''SOUNDS'''&amp;gt; indicates the sound list&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''Main'''&amp;gt; is the list of sounds the file will play.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''Sound File'''=&amp;quot;''YourFileName''.ogg&amp;quot; /&amp;gt; is the way to add a file to the sound. Adding multiple files will play them randomly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''PROPERTIES'''&amp;gt; Are all the options you may use to decide how the sound will behave in-game.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
&lt;br /&gt;
* '''Volume''' is how loud the sound should play. '''Volume=1''' would make the sound play at the normal volume of the sound file. '''Volume=0.5''' would half as loud. '''Volume=2''' would amplify the sound to twice its normal volume.&lt;br /&gt;
&lt;br /&gt;
* '''MinDistance''' and '''MaxDistance''' are used for attenuation, which means how the sound fades out over distance. Within the '''MinDistance''' the sound will be at the full '''Volume''' level. As the player moves from '''MinDistance''' to '''MaxDistance''' away from the sound, the volume will fade towards silence. Outside of '''MaxDistance''' it does not play at all.&lt;br /&gt;
&lt;br /&gt;
* '''Loop''' should be set to '''&amp;quot;true&amp;quot;''' if the sound should loop.&lt;br /&gt;
&lt;br /&gt;
* '''Use3D''' should be set to '''&amp;quot;true&amp;quot;''' if the sound should originate from a point in the game world. Otherwise it will be all around the player and will not fade with distance.&lt;br /&gt;
&lt;br /&gt;
Well thats it! You now created your very own sound! Place it in the map with the Level Editor or use it with &amp;lt;code&amp;gt;PlaySoundAtEntity();&amp;lt;/code&amp;gt; in your level script (check [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] for details).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===More advanced .snt properties===&lt;br /&gt;
&lt;br /&gt;
* '''Loop''', '''Random''' and '''Interval''' are all used together to define whether and how the sound should loop. '''Loop=true''' will make the sound repeat. If '''Interval''' is 0 then the sound will loop continuously, but if '''Interval''' is set to a value &amp;gt; 0, then that becomes a delay inserted between the repeitions. If '''Random''' is set to a value &amp;gt; 0 and &amp;lt; 1, then it defines the random chance of the sound playing on that interval. If '''Random''' is &amp;lt;=0 or &amp;gt;=1, then the sound will always play every interval.&lt;br /&gt;
For example, an ambient background track that should play continuously with no gaps should have:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;Random=&amp;quot;1&amp;quot; Interval=&amp;quot;0&amp;quot; Loop=&amp;quot;true&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
A sound that should repeat periodically, with a 25% chance of playing again every 15 seconds would be defined like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;Random=&amp;quot;0.25&amp;quot; Interval=&amp;quot;15&amp;quot; Loop=&amp;quot;true&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Random''' does ''not'' affect the random variant sounds listed in the .snt file. Those each have an equal chance of playing, although the engine will try to stop them from playing twice in a row if possible.&lt;br /&gt;
&lt;br /&gt;
* '''Use3D''' causes the sound to originate from a point in space, and move between the left and right stereo channels, but it is also required for attenuation. If '''Use3D''' is false, then the sound will have no stereo separation but it will also not fade over distance. Only mono sounds can be used as 3D. Stereo sounds retain the the left/right channel in the sound file and always behave as '''Use3d=&amp;quot;false&amp;quot;'''.&lt;br /&gt;
&lt;br /&gt;
* '''Stream''' defines whether the sound can be preloaded. '''Stream=&amp;quot;false&amp;quot;''' is the normal behaviour for short sounds that are loaded into memory and played when needed. '''Stream=&amp;quot;true&amp;quot;''' makes the sound play from the disk. This is slower but saves memory, so should be used for large sound files that are played rarely.&lt;br /&gt;
&lt;br /&gt;
* '''FadeEnd''' and '''FadeStart''', if true, will cause looping sounds to fade in or out on their first or last repetition.&lt;br /&gt;
&lt;br /&gt;
* '''Blockable''' and '''BlockVolumeMul''' were probably intended to define how the sound can interact with world geometry, but they do not seem to be implemented in the engine.&lt;br /&gt;
&lt;br /&gt;
* '''Blockable''', '''BlockVolumeMul''', and '''Priority''' do not seem to be implemented in the engine. ''('''Blockable''' and '''BlockVolumeMul''' may have been intended to define how the sounds are muffled by world geometry, and '''Priority''' may have been intended to be used when culling sounds. Although all three properties are read from the .snt file, they do not seem to be referenced in any other code.)'' {{confirm}}&lt;br /&gt;
&lt;br /&gt;
* '''&amp;lt;SOUNDS&amp;gt;''' categories: as well as '''&amp;lt;Main&amp;gt;''' the engine will also read lists of sounds from '''&amp;lt;Start&amp;gt;''' and '''&amp;lt;Stop&amp;gt;''' nodes. These may provide alternate sounds for the beginning and end of a loop. {{confirm}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Adding custom music==&lt;br /&gt;
&lt;br /&gt;
Custom music only needs to be a file in the '''.ogg''' format. It won't need an '''.snt''' file to be played with &amp;lt;code&amp;gt;PlayMusic();&amp;lt;/code&amp;gt; or at the credits, but you won't be able to use &amp;lt;code&amp;gt;PlaySoundAtEntity();&amp;lt;/code&amp;gt; with this file.&lt;br /&gt;
&lt;br /&gt;
Just like with sounds, it is good to create a folder for music in the mod's main folder, e.g. '''music'''. Put the '''.ogg''' file there.&lt;br /&gt;
&lt;br /&gt;
See [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] to learn how to use &amp;lt;code&amp;gt;PlayMusic();&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that only one music file can play at a time. For ambient sound, it is better to create a sound file (like described earlier). That way you can layer ambient sound with actual music when needed.&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:HPL2/Tutorials/CustomSounds&amp;diff=6691</id>
		<title>Hpl2:HPL2/Tutorials/CustomSounds</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:HPL2/Tutorials/CustomSounds&amp;diff=6691"/>
		<updated>2024-01-05T12:14:43Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Mrbehemo moved page Hpl2:Tutorials:script:CustomSounds to Hpl2:HPL2/Tutorials/CustomSounds: Correct path format&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Adding custom sounds =&lt;br /&gt;
== Preparing the sounds ==&lt;br /&gt;
&lt;br /&gt;
First you'll need a sound-editting program; [https://www.audacityteam.org/ Audacity] is a common choice - it is free and will suit most needs.&lt;br /&gt;
&lt;br /&gt;
The sounds need to be in '''.ogg ''' format. If your sound files are formatted as '''.MP3''', '''.WAV''' or anything else, you need to use one your audio editing software of choice to convert your sound file to an '''.ogg''' file format. In Audacity, you just need to drag the file into the program and then export as '''.ogg'''.&lt;br /&gt;
&lt;br /&gt;
{{tip|It is recommended to use mono files. Stereo should only be used for music and ambient tracks, because it will play directly at the player rather than play in 3D.}}&lt;br /&gt;
&lt;br /&gt;
If you only want to play this sound as music, you can skip the next few steps and jump right to the custom music section.&lt;br /&gt;
&lt;br /&gt;
== Managing sound files ==&lt;br /&gt;
&lt;br /&gt;
In your mod's (FC or CS, doesn't matter) folder, create a folder for sounds. It can be called however you want, but '''sounds''' would probably be the best.&lt;br /&gt;
&lt;br /&gt;
{{tip|If your mod has a lot of custom sounds, make sure to organise them into subfolders!}}&lt;br /&gt;
&lt;br /&gt;
Place the tutorial.ogg file in the created (sub)folder.&lt;br /&gt;
&lt;br /&gt;
== Creating the sound entity file ==&lt;br /&gt;
&lt;br /&gt;
The behaviour of the sound in the game is determined by a &amp;quot;sound entity&amp;quot; file. These files have a '''.snt''' extension.&lt;br /&gt;
&lt;br /&gt;
For the fastest workflow, copy an existing sound file that works similarly to how you want and change its name. Then alter the contents of that file rather than writing them from scratch. &lt;br /&gt;
&lt;br /&gt;
{{tip|If using Notepad++, right-click a .snt file and pick Notepad++ to edit the file.}}&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can do the following:&lt;br /&gt;
&lt;br /&gt;
Create a '''.txt''' file and name it what you want (same as the .ogg file is common), open it with any text editor you use.[[Notepad%2B%2B | Notepad++]] is recommended. When you finish editing the file, change the extension to the correct one. I named my file '''tutorial.snt'''.&lt;br /&gt;
&lt;br /&gt;
{{tip|Other extensions might work, but it is recommended to give sound files the .snt extension used by the main game. This will allow your sound to be placed in a level without scripting.}}&lt;br /&gt;
&lt;br /&gt;
In the file, you can edit quite a few things, and among them is..''Adding your sound-file into the script!'' And since my sound file is &amp;lt;u&amp;gt;'''door'''&amp;lt;/u&amp;gt;'''.ogg''', It shall go to the '''MAIN''' section. Random soundfiles will be covered later on.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;SOUNDENTITY&amp;gt;&lt;br /&gt;
 &amp;lt;SOUNDS&amp;gt;&lt;br /&gt;
   &amp;lt;Main&amp;gt;&lt;br /&gt;
      &amp;lt;Sound File=&amp;quot;door.ogg&amp;quot; /&amp;gt;&lt;br /&gt;
   	&amp;lt;/Main&amp;gt;&lt;br /&gt;
   &amp;lt;/SOUNDS&amp;gt;&lt;br /&gt;
   &amp;lt;PROPERTIES Volume=&amp;quot;5&amp;quot; MinDistance=&amp;quot;1&amp;quot; MaxDistance=&amp;quot;50&amp;quot; Random=&amp;quot;0&amp;quot; Interval=&amp;quot;0&amp;quot; FadeEnd=&amp;quot;False&amp;quot; FadeStart=&amp;quot;False&amp;quot; Stream=&amp;quot;False&amp;quot; Loop=&amp;quot;False&amp;quot; Use3D=&amp;quot;false&amp;quot; Blockable=&amp;quot;False&amp;quot; BlockVolumeMul=&amp;quot;0.7&amp;quot; Priority=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/SOUNDENTITY&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Format explanation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''SOUNDENTITY'''&amp;gt; is the start marker of the sound file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''SOUNDS'''&amp;gt; indicates the sound list&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''Main'''&amp;gt; is the list of sounds the file will play.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''Sound File'''=&amp;quot;''YourFileName''.ogg&amp;quot; /&amp;gt; is the way to add a file to the sound. Adding multiple files will play them randomly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''PROPERTIES'''&amp;gt; Are all the options you may use to decide how the sound will behave in-game.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
&lt;br /&gt;
* '''Volume''' is how loud the sound should play. '''Volume=1''' would make the sound play at the normal volume of the sound file. '''Volume=0.5''' would half as loud. '''Volume=2''' would amplify the sound to twice its normal volume.&lt;br /&gt;
&lt;br /&gt;
* '''MinDistance''' and '''MaxDistance''' are used for attenuation, which means how the sound fades out over distance. Within the '''MinDistance''' the sound will be at the full '''Volume''' level. As the player moves from '''MinDistance''' to '''MaxDistance''' away from the sound, the volume will fade towards silence. Outside of '''MaxDistance''' it does not play at all.&lt;br /&gt;
&lt;br /&gt;
* '''Loop''' should be set to '''&amp;quot;true&amp;quot;''' if the sound should loop.&lt;br /&gt;
&lt;br /&gt;
* '''Use3D''' should be set to '''&amp;quot;true&amp;quot;''' if the sound should originate from a point in the game world. Otherwise it will be all around the player and will not fade with distance.&lt;br /&gt;
&lt;br /&gt;
Well thats it! You now created your very own sound! Place it in the map with the Level Editor or use it with &amp;lt;code&amp;gt;PlaySoundAtEntity();&amp;lt;/code&amp;gt; in your level script (check [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] for details).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===More advanced .snt properties===&lt;br /&gt;
&lt;br /&gt;
* '''Loop''', '''Random''' and '''Interval''' are all used together to define whether and how the sound should loop. '''Loop=true''' will make the sound repeat. If '''Interval''' is 0 then the sound will loop continuously, but if '''Interval''' is set to a value &amp;gt; 0, then that becomes a delay inserted between the repeitions. If '''Random''' is set to a value &amp;gt; 0 and &amp;lt; 1, then it defines the random chance of the sound playing on that interval. If '''Random''' is &amp;lt;=0 or &amp;gt;=1, then the sound will always play every interval.&lt;br /&gt;
For example, an ambient background track that should play continuously with no gaps should have:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;Random=&amp;quot;1&amp;quot; Interval=&amp;quot;0&amp;quot; Loop=&amp;quot;true&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
A sound that should repeat periodically, with a 25% chance of playing again every 15 seconds would be defined like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;Random=&amp;quot;0.25&amp;quot; Interval=&amp;quot;15&amp;quot; Loop=&amp;quot;true&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Random''' does 'not' affect the random variant sounds listed in the .snt file. Those each have an equal chance of playing, although the engine will try to stop them from playing twice in a row if possible.&lt;br /&gt;
&lt;br /&gt;
* '''Use3D''' causes the sound to originate from a point in space, and move between the left and right stereo channels, but it is also required for attenuation. If '''Use3D''' is false, then the sound will have no stereo separation but it will also not fade over distance. Only mono sounds can be used as 3D. Stereo sounds retain the the left/right channel in the sound file and always behave as '''Use3d=&amp;quot;false&amp;quot;'''.&lt;br /&gt;
&lt;br /&gt;
* '''Stream''' defines whether the sound can be preloaded. '''Stream=&amp;quot;false&amp;quot;''' is the normal behaviour for short sounds that are loaded into memory and played when needed. '''Stream=&amp;quot;true&amp;quot;''' makes the sound play from the disk. This is slower but saves memory, so should be used for large sound files that are played rarely.&lt;br /&gt;
&lt;br /&gt;
* '''FadeEnd''' and '''FadeStart''', if true, will cause looping sounds to fade in or out on their first or last repetition.&lt;br /&gt;
&lt;br /&gt;
* '''Blockable''' and '''BlockVolumeMul''' were probably intended to define how the sound can interact with world geometry, but they do not seem to be implemented in the engine.&lt;br /&gt;
&lt;br /&gt;
* '''Blockable''', '''BlockVolumeMul''', and '''Priority''' do not seem to be implemented in the engine. ''('''Blockable''' and '''BlockVolumeMul''' may have been intended to define how the sounds are muffled by world geometry, and '''Priority''' may have been intended to be used when culling sounds. Although all three properties are read from the .snt file, they do not seem to be referenced in any other code.)'' {{confirm}}&lt;br /&gt;
&lt;br /&gt;
* '''&amp;lt;SOUNDS&amp;gt;''' categories: as well as '''&amp;lt;Main&amp;gt;''' the engine will also read lists of sounds from '''&amp;lt;Start&amp;gt;''' and '''&amp;lt;Stop&amp;gt;''' nodes. These may provide alternate sounds for the beginning and end of a loop. {{confirm}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Adding custom music==&lt;br /&gt;
&lt;br /&gt;
Custom music only needs to be a file in the '''.ogg''' format. It won't need an '''.snt''' file to be played with &amp;lt;code&amp;gt;PlayMusic();&amp;lt;/code&amp;gt; or at the credits, but you won't be able to use &amp;lt;code&amp;gt;PlaySoundAtEntity();&amp;lt;/code&amp;gt; with this file.&lt;br /&gt;
&lt;br /&gt;
Just like with sounds, it is good to create a folder for music in the mod's main folder, e.g. '''music'''. Put the '''.ogg''' file there.&lt;br /&gt;
&lt;br /&gt;
See [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] to learn how to use &amp;lt;code&amp;gt;PlayMusic();&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that only one music file can play at a time. For ambient sound, it is better to create a sound file (like described earlier). That way you can layer ambient sound with actual music when needed.&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:CustomSounds&amp;diff=6692</id>
		<title>Hpl2:Tutorials:script:CustomSounds</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:CustomSounds&amp;diff=6692"/>
		<updated>2024-01-05T12:14:43Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Mrbehemo moved page Hpl2:Tutorials:script:CustomSounds to Hpl2:HPL2/Tutorials/CustomSounds: Correct path format&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Hpl2:HPL2/Tutorials/CustomSounds]]&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:HPL2/Tutorials/CustomSounds&amp;diff=6690</id>
		<title>Hpl2:HPL2/Tutorials/CustomSounds</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:HPL2/Tutorials/CustomSounds&amp;diff=6690"/>
		<updated>2024-01-05T12:13:04Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Improved .snt properties descriptions. Created a &amp;quot;basics&amp;quot; and &amp;quot;advanced&amp;quot; section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Adding custom sounds =&lt;br /&gt;
== Preparing the sounds ==&lt;br /&gt;
&lt;br /&gt;
First you'll need a sound-editting program; [https://www.audacityteam.org/ Audacity] is a common choice - it is free and will suit most needs.&lt;br /&gt;
&lt;br /&gt;
The sounds need to be in '''.ogg ''' format. If your sound files are formatted as '''.MP3''', '''.WAV''' or anything else, you need to use one your audio editing software of choice to convert your sound file to an '''.ogg''' file format. In Audacity, you just need to drag the file into the program and then export as '''.ogg'''.&lt;br /&gt;
&lt;br /&gt;
{{tip|It is recommended to use mono files. Stereo should only be used for music and ambient tracks, because it will play directly at the player rather than play in 3D.}}&lt;br /&gt;
&lt;br /&gt;
If you only want to play this sound as music, you can skip the next few steps and jump right to the custom music section.&lt;br /&gt;
&lt;br /&gt;
== Managing sound files ==&lt;br /&gt;
&lt;br /&gt;
In your mod's (FC or CS, doesn't matter) folder, create a folder for sounds. It can be called however you want, but '''sounds''' would probably be the best.&lt;br /&gt;
&lt;br /&gt;
{{tip|If your mod has a lot of custom sounds, make sure to organise them into subfolders!}}&lt;br /&gt;
&lt;br /&gt;
Place the tutorial.ogg file in the created (sub)folder.&lt;br /&gt;
&lt;br /&gt;
== Creating the sound entity file ==&lt;br /&gt;
&lt;br /&gt;
The behaviour of the sound in the game is determined by a &amp;quot;sound entity&amp;quot; file. These files have a '''.snt''' extension.&lt;br /&gt;
&lt;br /&gt;
For the fastest workflow, copy an existing sound file that works similarly to how you want and change its name. Then alter the contents of that file rather than writing them from scratch. &lt;br /&gt;
&lt;br /&gt;
{{tip|If using Notepad++, right-click a .snt file and pick Notepad++ to edit the file.}}&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can do the following:&lt;br /&gt;
&lt;br /&gt;
Create a '''.txt''' file and name it what you want (same as the .ogg file is common), open it with any text editor you use.[[Notepad%2B%2B | Notepad++]] is recommended. When you finish editing the file, change the extension to the correct one. I named my file '''tutorial.snt'''.&lt;br /&gt;
&lt;br /&gt;
{{tip|Other extensions might work, but it is recommended to give sound files the .snt extension used by the main game. This will allow your sound to be placed in a level without scripting.}}&lt;br /&gt;
&lt;br /&gt;
In the file, you can edit quite a few things, and among them is..''Adding your sound-file into the script!'' And since my sound file is &amp;lt;u&amp;gt;'''door'''&amp;lt;/u&amp;gt;'''.ogg''', It shall go to the '''MAIN''' section. Random soundfiles will be covered later on.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;SOUNDENTITY&amp;gt;&lt;br /&gt;
 &amp;lt;SOUNDS&amp;gt;&lt;br /&gt;
   &amp;lt;Main&amp;gt;&lt;br /&gt;
      &amp;lt;Sound File=&amp;quot;door.ogg&amp;quot; /&amp;gt;&lt;br /&gt;
   	&amp;lt;/Main&amp;gt;&lt;br /&gt;
   &amp;lt;/SOUNDS&amp;gt;&lt;br /&gt;
   &amp;lt;PROPERTIES Volume=&amp;quot;5&amp;quot; MinDistance=&amp;quot;1&amp;quot; MaxDistance=&amp;quot;50&amp;quot; Random=&amp;quot;0&amp;quot; Interval=&amp;quot;0&amp;quot; FadeEnd=&amp;quot;False&amp;quot; FadeStart=&amp;quot;False&amp;quot; Stream=&amp;quot;False&amp;quot; Loop=&amp;quot;False&amp;quot; Use3D=&amp;quot;false&amp;quot; Blockable=&amp;quot;False&amp;quot; BlockVolumeMul=&amp;quot;0.7&amp;quot; Priority=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/SOUNDENTITY&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Format explanation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''SOUNDENTITY'''&amp;gt; is the start marker of the sound file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''SOUNDS'''&amp;gt; indicates the sound list&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''Main'''&amp;gt; is the list of sounds the file will play.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''Sound File'''=&amp;quot;''YourFileName''.ogg&amp;quot; /&amp;gt; is the way to add a file to the sound. Adding multiple files will play them randomly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''PROPERTIES'''&amp;gt; Are all the options you may use to decide how the sound will behave in-game.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
&lt;br /&gt;
* '''Volume''' is how loud the sound should play. '''Volume=1''' would make the sound play at the normal volume of the sound file. '''Volume=0.5''' would half as loud. '''Volume=2''' would amplify the sound to twice its normal volume.&lt;br /&gt;
&lt;br /&gt;
* '''MinDistance''' and '''MaxDistance''' are used for attenuation, which means how the sound fades out over distance. Within the '''MinDistance''' the sound will be at the full '''Volume''' level. As the player moves from '''MinDistance''' to '''MaxDistance''' away from the sound, the volume will fade towards silence. Outside of '''MaxDistance''' it does not play at all.&lt;br /&gt;
&lt;br /&gt;
* '''Loop''' should be set to '''&amp;quot;true&amp;quot;''' if the sound should loop.&lt;br /&gt;
&lt;br /&gt;
* '''Use3D''' should be set to '''&amp;quot;true&amp;quot;''' if the sound should originate from a point in the game world. Otherwise it will be all around the player and will not fade with distance.&lt;br /&gt;
&lt;br /&gt;
Well thats it! You now created your very own sound! Place it in the map with the Level Editor or use it with &amp;lt;code&amp;gt;PlaySoundAtEntity();&amp;lt;/code&amp;gt; in your level script (check [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] for details).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===More advanced .snt properties===&lt;br /&gt;
&lt;br /&gt;
* '''Loop''', '''Random''' and '''Interval''' are all used together to define whether and how the sound should loop. '''Loop=true''' will make the sound repeat. If '''Interval''' is 0 then the sound will loop continuously, but if '''Interval''' is set to a value &amp;gt; 0, then that becomes a delay inserted between the repeitions. If '''Random''' is set to a value &amp;gt; 0 and &amp;lt; 1, then it defines the random chance of the sound playing on that interval. If '''Random''' is &amp;lt;=0 or &amp;gt;=1, then the sound will always play every interval.&lt;br /&gt;
For example, an ambient background track that should play continuously with no gaps should have:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;Random=&amp;quot;1&amp;quot; Interval=&amp;quot;0&amp;quot; Loop=&amp;quot;true&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
A sound that should repeat periodically, with a 25% chance of playing again every 15 seconds would be defined like this:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;Random=&amp;quot;0.25&amp;quot; Interval=&amp;quot;15&amp;quot; Loop=&amp;quot;true&amp;quot;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* '''Random''' does 'not' affect the random variant sounds listed in the .snt file. Those each have an equal chance of playing, although the engine will try to stop them from playing twice in a row if possible.&lt;br /&gt;
&lt;br /&gt;
* '''Use3D''' causes the sound to originate from a point in space, and move between the left and right stereo channels, but it is also required for attenuation. If '''Use3D''' is false, then the sound will have no stereo separation but it will also not fade over distance. Only mono sounds can be used as 3D. Stereo sounds retain the the left/right channel in the sound file and always behave as '''Use3d=&amp;quot;false&amp;quot;'''.&lt;br /&gt;
&lt;br /&gt;
* '''Stream''' defines whether the sound can be preloaded. '''Stream=&amp;quot;false&amp;quot;''' is the normal behaviour for short sounds that are loaded into memory and played when needed. '''Stream=&amp;quot;true&amp;quot;''' makes the sound play from the disk. This is slower but saves memory, so should be used for large sound files that are played rarely.&lt;br /&gt;
&lt;br /&gt;
* '''FadeEnd''' and '''FadeStart''', if true, will cause looping sounds to fade in or out on their first or last repetition.&lt;br /&gt;
&lt;br /&gt;
* '''Blockable''' and '''BlockVolumeMul''' were probably intended to define how the sound can interact with world geometry, but they do not seem to be implemented in the engine.&lt;br /&gt;
&lt;br /&gt;
* '''Blockable''', '''BlockVolumeMul''', and '''Priority''' do not seem to be implemented in the engine. ''('''Blockable''' and '''BlockVolumeMul''' may have been intended to define how the sounds are muffled by world geometry, and '''Priority''' may have been intended to be used when culling sounds. Although all three properties are read from the .snt file, they do not seem to be referenced in any other code.)'' {{confirm}}&lt;br /&gt;
&lt;br /&gt;
* '''&amp;lt;SOUNDS&amp;gt;''' categories: as well as '''&amp;lt;Main&amp;gt;''' the engine will also read lists of sounds from '''&amp;lt;Start&amp;gt;''' and '''&amp;lt;Stop&amp;gt;''' nodes. These may provide alternate sounds for the beginning and end of a loop. {{confirm}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Adding custom music==&lt;br /&gt;
&lt;br /&gt;
Custom music only needs to be a file in the '''.ogg''' format. It won't need an '''.snt''' file to be played with &amp;lt;code&amp;gt;PlayMusic();&amp;lt;/code&amp;gt; or at the credits, but you won't be able to use &amp;lt;code&amp;gt;PlaySoundAtEntity();&amp;lt;/code&amp;gt; with this file.&lt;br /&gt;
&lt;br /&gt;
Just like with sounds, it is good to create a folder for music in the mod's main folder, e.g. '''music'''. Put the '''.ogg''' file there.&lt;br /&gt;
&lt;br /&gt;
See [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] to learn how to use &amp;lt;code&amp;gt;PlayMusic();&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that only one music file can play at a time. For ambient sound, it is better to create a sound file (like described earlier). That way you can layer ambient sound with actual music when needed.&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:HPL2/Tutorials/CustomSounds&amp;diff=6689</id>
		<title>Hpl2:HPL2/Tutorials/CustomSounds</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:HPL2/Tutorials/CustomSounds&amp;diff=6689"/>
		<updated>2024-01-05T11:12:16Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Changed details of &amp;quot;Random&amp;quot; property.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Adding custom sounds =&lt;br /&gt;
== Preparing the sounds ==&lt;br /&gt;
&lt;br /&gt;
First you'll need a sound-editting program; [https://www.audacityteam.org/ Audacity] is a common choice - it is free and will suit most needs.&lt;br /&gt;
&lt;br /&gt;
The sounds need to be in '''.ogg ''' format. If your sound files are formatted as '''.MP3''', '''.WAV''' or anything else, you need to use one your audio editing software of choice to convert your sound file to an '''.ogg''' file format. In Audacity, you just need to drag the file into the program and then export as '''.ogg'''.&lt;br /&gt;
&lt;br /&gt;
{{tip|It is recommended to use mono files. Stereo should only be used for music and ambient tracks, because it will play directly at the player rather than play in 3D.}}&lt;br /&gt;
&lt;br /&gt;
If you only want to play this sound as music, you can skip the next few steps and jump right to the custom music section.&lt;br /&gt;
&lt;br /&gt;
== Managing sound files ==&lt;br /&gt;
&lt;br /&gt;
In your mod's (FC or CS, doesn't matter) folder, create a folder for sounds. It can be called however you want, but '''sounds''' would probably be the best.&lt;br /&gt;
&lt;br /&gt;
{{tip|If your mod has a lot of custom sounds, make sure to organise them into subfolders!}}&lt;br /&gt;
&lt;br /&gt;
Place the tutorial.ogg file in the created (sub)folder.&lt;br /&gt;
&lt;br /&gt;
== Creating the sound entity file ==&lt;br /&gt;
&lt;br /&gt;
The behaviour of the sound in the game is determined by a &amp;quot;sound entity&amp;quot; file. These files have a '''.snt''' extension.&lt;br /&gt;
&lt;br /&gt;
For the fastest workflow, copy an existing sound file that works similarly to how you want and change its name. Then alter the contents of that file rather than writing them from scratch. &lt;br /&gt;
&lt;br /&gt;
{{tip|If using Notepad++, right-click a .snt file and pick Notepad++ to edit the file.}}&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can do the following:&lt;br /&gt;
&lt;br /&gt;
Create a '''.txt''' file and name it what you want (same as the .ogg file is common), open it with any text editor you use.[[Notepad%2B%2B | Notepad++]] is recommended. When you finish editing the file, change the extension to the correct one. I named my file '''tutorial.snt'''.&lt;br /&gt;
&lt;br /&gt;
{{tip|Other extensions might work, but it is recommended to give sound files the .snt extension used by the main game. This will allow your sound to be placed in a level without scripting.}}&lt;br /&gt;
&lt;br /&gt;
In the file, you can edit quite a few things, and among them is..''Adding your sound-file into the script!'' And since my sound file is &amp;lt;u&amp;gt;'''door'''&amp;lt;/u&amp;gt;'''.ogg''', It shall go to the '''MAIN''' section. Random soundfiles will be covered later on.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;SOUNDENTITY&amp;gt;&lt;br /&gt;
 &amp;lt;SOUNDS&amp;gt;&lt;br /&gt;
   &amp;lt;Main&amp;gt;&lt;br /&gt;
      &amp;lt;Sound File=&amp;quot;door.ogg&amp;quot; /&amp;gt;&lt;br /&gt;
   	&amp;lt;/Main&amp;gt;&lt;br /&gt;
   &amp;lt;/SOUNDS&amp;gt;&lt;br /&gt;
   &amp;lt;PROPERTIES Volume=&amp;quot;5&amp;quot; MinDistance=&amp;quot;1&amp;quot; MaxDistance=&amp;quot;50&amp;quot; Random=&amp;quot;0&amp;quot; Interval=&amp;quot;0&amp;quot; FadeEnd=&amp;quot;False&amp;quot; FadeStart=&amp;quot;False&amp;quot; Stream=&amp;quot;False&amp;quot; Loop=&amp;quot;False&amp;quot; Use3D=&amp;quot;false&amp;quot; Blockable=&amp;quot;False&amp;quot; BlockVolumeMul=&amp;quot;0.7&amp;quot; Priority=&amp;quot;5&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/SOUNDENTITY&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Format explanation:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''SOUNDENTITY'''&amp;gt; is the start marker of the sound file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''SOUNDS'''&amp;gt; indicates the sound list&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''Main'''&amp;gt; is the list of sounds the file will play. It is unsure if other categories exist.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''Sound File'''=&amp;quot;''YourFileName''.ogg&amp;quot; /&amp;gt; is the way to add a file to the sound. Adding multiple files will play them randomly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;'''PROPERTIES'''&amp;gt; Are all the options you may use to decide how the sound will behave in-game. Most important ones are:&lt;br /&gt;
*'''MinDistance''' is what distance you have to be in to hear it, since 1 is the players exact size, You will hear the sound perfectly if you stand on it. The sound will be heard with less and less volume until getting further than the distance specified in '''MaxDistance'''.&lt;br /&gt;
*'''Random''' is used for looping sounds that have a random chance of repeating or not. Looping sounds with a Random value greater than 1 will always loop; 0.5 means they have a 50% chance of stopping. (This property is ''not'' connected to the list of random &amp;quot;.ogg&amp;quot; files - those all have an equal chance of playing, but the engine will try to stop them from being randomly selected multiple times in a row.)&lt;br /&gt;
*'''Loop=&amp;quot;False&amp;quot;''' - Make sure to change this to true if your sound should loop.&lt;br /&gt;
*'''Use3D=&amp;quot;false&amp;quot;''' - Setting this as true will make the sound fade if the player rotates right and left from the sound origin. Using false will only use the distance to fade the sound.{{confirm}}&lt;br /&gt;
{{warning|Stereo files will never work with this! The file needs to be mixed into a mono track to use this parameter. Also keep in minds stereo doesn't fade with distance.}}&lt;br /&gt;
&lt;br /&gt;
Well thats it! You now created your very own sound! Place it in the map with the Level Editor or use it with &amp;lt;code&amp;gt;PlaySoundAtEntity();&amp;lt;/code&amp;gt; in your level script (check [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] for details).&lt;br /&gt;
&lt;br /&gt;
= Adding custom music =&lt;br /&gt;
&lt;br /&gt;
Custom music only needs to be a file in the '''.ogg''' format. It won't need an '''.snt''' file to be played with &amp;lt;code&amp;gt;PlayMusic();&amp;lt;/code&amp;gt; or at the credits, but you won't be able to use &amp;lt;code&amp;gt;PlaySoundAtEntity();&amp;lt;/code&amp;gt; with this file.&lt;br /&gt;
&lt;br /&gt;
Just like with sounds, it is good to create a folder for music in the mod's main folder, e.g. '''music'''. Put the '''.ogg''' file there.&lt;br /&gt;
&lt;br /&gt;
See [http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Engine scripts] to learn how to use &amp;lt;code&amp;gt;PlayMusic();&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Keep in mind that only one music file can play at a time. For ambient sound, it is better to create a sound file (like described earlier). That way you can layer ambient sound with actual music when needed.&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6688</id>
		<title>HPL2/Tutorials/ShowScreenImage()</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6688"/>
		<updated>2024-01-04T17:27:42Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
ATDD version 1.5 added the ShowScreenImage() function, which was previously available in AAMFP. Some of the workings of this function are a little counter-intuitive, so the purpose of this page is to explain it a little. This is based off of the author's experiments in ATDD 1.5, so it's not definitive! It's also assumed that these notes apply to AAMFP in the same way, but that has not been tested.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Function=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen.&lt;br /&gt;
&lt;br /&gt;
# ''asImageName'' - The image file to render (.jpg, .png, .tga, .dds) (see [[HPL2/Tutorials/ShowScreenImage()#Size|Size]])&lt;br /&gt;
# ''afX'' - The X position of the image, relative to the centre of the screen (see [[HPL2/Tutorials/ShowScreenImage()#Placement|Placement]])&lt;br /&gt;
# ''afY'' - The Y position of the image, relative to the centre of the screen (see [[HPL2/Tutorials/ShowScreenImage()#Placement|Placement]])&lt;br /&gt;
# ''afScale'' - The size of the image in pixels, or original image size if negative (see [[HPL2/Tutorials/ShowScreenImage()#Size|Size]]) &lt;br /&gt;
# ''abUseRelativeCoordinates'' - If true, X and Y represent a fraction of the entire screen resoltion, otherwise they are pixel co-ordinates (see [[HPL2/Tutorials/ShowScreenImage()#Placement|Placement]])&lt;br /&gt;
# ''afDuration'' - The duration, in seconds, that the image is displayed for (see [[HPL2/Tutorials/ShowScreenImage()#Timing|Timing]])&lt;br /&gt;
# ''afFadeIn'' - The time, in seconds, to fade in the image (see [[HPL2/Tutorials/ShowScreenImage()#Timing|Timing]])&lt;br /&gt;
# ''afFadeOut'' - The time, in seconds, to fade out the image (see [[HPL2/Tutorials/ShowScreenImage()#Timing|Timing]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Size=&lt;br /&gt;
* Note that the ''afScale'' argument is ''not'' actually the scale of the image: it is the ''size in pixels''. This is not relative and does not take the screen resolution into account, so an image will appear bigger or smaller at lower or higher resolutions respectively.&lt;br /&gt;
* If the size is specified, the image will be rendered onscreen as a square quad, even if the image file is non square. So if the desired effect is to display a non-square image, it will need to be padded out with transparent pixels in order to make it render without distortion.&lt;br /&gt;
* If the size is given as -1 (or any number less than 0) then the actual pixel size and shape of the image file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Placement=&lt;br /&gt;
* The origin of the screen-space is the centre. This means that [0, 0] is the centre of the screen regardless of screen resolution, and regardless of ''abUseRelativeCoordinates''.&lt;br /&gt;
* The origin of the image-space is the top-left. This means that the co-ordinates define where the top-left corner of the image will go.&lt;br /&gt;
* If ''abUseRelativeCoordinates'' is ''false'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as actual pixels''.&lt;br /&gt;
* If ''abUseRelativeCoordinates'' is ''true'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as a fraction of the screen resolution width or height''.&lt;br /&gt;
* The relative co-ordinates still use the centre of the screen as the origin, so the top-left corner of the screen is [-0.5, -0.5] and the bottom-right corner is [0.5, 0.5]. Any relative co-ordinate greater than 0.5 will put the image outside of the screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Timing=&lt;br /&gt;
* The total time that the image will be displayed is ''afFadeIn'' + ''afDuration'' + ''afFadeOut''.&lt;br /&gt;
* ''afDuration'' counts from when the fade in is finished. ''afFadeOut'' counts from when ''afDuration'' is finished. &lt;br /&gt;
* Calling ShowScreenImage() again will replace the current image, regardless of duration or fade times.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
// Centred:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -150.0f, -150.0f, 300.0f, false, 3.0f, 0.0f, 0.0f);&lt;br /&gt;
// Size: 300 x 300 pixels&lt;br /&gt;
// Placement: centred on the screen (image-origin is placed image-size/2 from the screen-origin)&lt;br /&gt;
// Timing: 3 seconds, no fading&lt;br /&gt;
&lt;br /&gt;
// From top-left:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.45f, -0.45f, -1.0f, true, 2.0f, 1.0f, 2.0f);&lt;br /&gt;
// Size: original pixel size and shape of the image file&lt;br /&gt;
// Placement: near the top-left corner, with a 5% margin relative to the screen size&lt;br /&gt;
// Timing: 5 seconds, including fading&lt;br /&gt;
&lt;br /&gt;
// From top-centre:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.48f, 0.0f, 100.0f, true, 0.0f, 2.0f, 2.0f);&lt;br /&gt;
// Size: 100 x 100 pixels&lt;br /&gt;
// Placement: near the top-centre, with a 2% margin relative to the screen size&lt;br /&gt;
// Timing: 4 seconds, fading out immediately after fading in&lt;br /&gt;
&lt;br /&gt;
// Bottom-right - not reliable&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, 0.25f, 0.25f, 270.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a screen resolution of 1920 x 1080, this would fit neatly into the bottom-right 1/16 of the screen (1080 / 4 = 270).&lt;br /&gt;
// Unfortunately, if the resolution was lower, it would not fit on the screen. And if the resolution was higher, it would not reach the edges.&lt;br /&gt;
&lt;br /&gt;
// Full-screen kinda... top-left focussed&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.5f, -0.5f, 3840.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a 4k screen resolution of 3840 x 2160, this would fit the full screen.&lt;br /&gt;
// The centre of the image would be at the centre of the screen at 4k, but would move towards the bottom-right with lower resolutions.&lt;br /&gt;
// At lower resolutions the right and bottom of the image would be cropped. At higher resolutions it would not fill the screen.&lt;br /&gt;
&lt;br /&gt;
// Full-screen kinda... centre focussed&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.5f, -0.5f, 3840.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a 4k screen resolution of 3840 x 2160, this would fit the full screen.&lt;br /&gt;
// The centre of the image would stay on the centre of the screen, whatever the resolution.&lt;br /&gt;
// At lower resolutions all the edges would be cropped. At higher resolutions it would not fill the screen.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
There are lots of things you can do with ShowScreenImage() if you use it creatively!&lt;br /&gt;
&lt;br /&gt;
...But if you need to place an image relative the the right-hand edge or bottom of the screen, or relative to the screen resolution, it might be tricky, and might not be future-proof.&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6687</id>
		<title>HPL2/Tutorials/ShowScreenImage()</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6687"/>
		<updated>2024-01-04T17:26:53Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
ATDD version 1.5 added the ShowScreenImage() function, which was previously available in AAMFP. Some of the workings of this function are a little counter-intuitive, so the purpose of this page is to explain it a little. This is based off of the author's experiments in ATDD 1.5, so it's not definitive! It's also assumed that these notes apply to AAMFP in the same way, but that has not been tested.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Function=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen.&lt;br /&gt;
&lt;br /&gt;
# ''asImageName'' - The image file to render (.jpg, .png, .tga, .dds) (see [[HPL2/Tutorials/ShowScreenImage()#Size|Size]])&lt;br /&gt;
# ''afX'' - The X position of the image, relative to the centre of the screen (see [[HPL2/Tutorials/ShowScreenImage()#Placement|Placement]])&lt;br /&gt;
# ''afY'' - The Y position of the image, relative to the centre of the screen (see [[HPL2/Tutorials/ShowScreenImage()#Placement|Placement]])&lt;br /&gt;
# ''afScale'' - The size of the image in pixels, or original image size if negative (see [[HPL2/Tutorials/ShowScreenImage()#Size|Size]]) &lt;br /&gt;
# ''abUseRelativeCoordinates'' - If true, X and Y represent a fraction of the entire screen resoltion, otherwise they are pixel co-ordinates (see [[HPL2/Tutorials/ShowScreenImage()#Placement|Placement]])&lt;br /&gt;
# ''afDuration'' - The duration, in seconds, that the image is displayed for (see [[HPL2/Tutorials/ShowScreenImage()#Timing|Timing]])&lt;br /&gt;
# ''afFadeIn'' - The time, in seconds, to fade in the image (see [[HPL2/Tutorials/ShowScreenImage()#Timing|Timing]])&lt;br /&gt;
# ''afFadeOut'' - The time, in seconds, to fade out the image (see [[HPL2/Tutorials/ShowScreenImage()#Timing|Timing]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Size=&lt;br /&gt;
* Note that the ''afScale'' argument is ''not'' actually the scale of the image: it is the ''size in pixels''. This is not relative and does not take the screen resolution into account, so an image will appear bigger or smaller at lower or higher resolutions respectively.&lt;br /&gt;
* If the size is specified, the image will be rendered onscreen as a square quad, even if the image file is non square. So if the desired effect is to display a non-square image, it will need to be padded out with transparent pixels in order to make it render without distortion.&lt;br /&gt;
* If the size is given as -1 (or any number less than 0) then the actual pixel size and shape of the image file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Placement=&lt;br /&gt;
* The origin of the screen-space is the centre. This means that [0, 0] is the centre of the screen regardless of screen resolution, and regardless of ''abUseRelativeCoordinates''.&lt;br /&gt;
* The origin of the image-space is the top-left. This means that the co-ordinates define where the top-left corner of the image will go.&lt;br /&gt;
* If ''abUseRelativeCoordinates'' is ''false'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as actual pixels''.&lt;br /&gt;
* If ''abUseRelativeCoordinates'' is ''true'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as a fraction of the screen resolution width or height''.&lt;br /&gt;
* The relative co-ordinates still use the centre of the screen as the origin, so the top-left corner of the screen is [-0.5, -0.5] and the bottom-right corner is [0.5, 0.5]. Any relative co-ordinate greater than 0.5 will put the image outside of the screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Timing=&lt;br /&gt;
* The total time that the image will be displayed is ''afFadeIn'' + ''afDuration'' + ''afFadeOut''.&lt;br /&gt;
* ''afDuration'' counts from when the fade in is finished. ''afFadeOut'' counts from when ''afDuration'' is finished. &lt;br /&gt;
* Calling ShowScreenImage() again will replace the current image, regardless of duration or fade times.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
// Centred:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -150.0f, -150.0f, 300.0f, false, 3.0f, 0.0f, 0.0f);&lt;br /&gt;
// Size: 300 x 300 pixels&lt;br /&gt;
// Placement: centred on the screen (image-origin is placed image-size/2 from the screen-origin)&lt;br /&gt;
// Timing: 3 seconds, no fading&lt;br /&gt;
&lt;br /&gt;
// From top-left:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.45f, -0.45f, -1.0f, true, 2.0f, 1.0f, 2.0f);&lt;br /&gt;
// Size: original pixel size and shape of the image file&lt;br /&gt;
// Placement: near the top-left corner, with a 5% margin relative to the screen size&lt;br /&gt;
// Timing: 5 seconds, including fading&lt;br /&gt;
&lt;br /&gt;
// From top-centre:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.48f, 0.0f, 100.0f, true, 0.0f, 2.0f, 2.0f);&lt;br /&gt;
// Size: 100 x 100 pixels&lt;br /&gt;
// Placement: near the top-centre, with a 2% margin relative to the screen size&lt;br /&gt;
// Timing: 4 seconds, fading out immediately after fading in&lt;br /&gt;
&lt;br /&gt;
// Bottom-right - not reliable&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, 0.25f, 0.25f, 270.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a screen resolution of 1920 x 1080, this would fit neatly into the bottom-right 1/16 of the screen (1080 / 4 = 270).&lt;br /&gt;
// Unfortunately, if the resolution was lower, it would not fit on the screen. And if the resolution was higher, it would not reach the edges.&lt;br /&gt;
&lt;br /&gt;
// Full-screen kinda... top-left focussed&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.5f, -0.5f, 3840.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a 4k screen resolution of 3840 x 2160, this would fit the full screen.&lt;br /&gt;
// The centre of the image would be at the centre of the screen at 4k, but would move towards the bottom left with lower resolutions.&lt;br /&gt;
// At lower resolutions the right and bottom of the image would be cropped. At higher resolutions it would not fill the screen.&lt;br /&gt;
&lt;br /&gt;
// Full-screen kinda... centre focussed&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.5f, -0.5f, 3840.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a 4k screen resolution of 3840 x 2160, this would fit the full screen.&lt;br /&gt;
// The centre of the image would stay on the centre of the screen, whatever the resolution.&lt;br /&gt;
// At lower resolutions all the edges would be cropped. At higher resolutions it would not fill the screen.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
There are lots of things you can do with ShowScreenImage() if you use it creatively!&lt;br /&gt;
&lt;br /&gt;
...But if you need to place an image relative the the right-hand edge or bottom of the screen, or relative to the screen resolution, it might be tricky, and might not be future-proof.&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/AMFP/ScriptFunctions&amp;diff=6686</id>
		<title>HPL2/AMFP/ScriptFunctions</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/AMFP/ScriptFunctions&amp;diff=6686"/>
		<updated>2024-01-04T17:17:02Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added link to ShowScreenImage() tutorial&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Engine scripts ==&lt;br /&gt;
&lt;br /&gt;
A list of script functions available in A Machine For Pigs (that are not present in The Dark Descent). Many of TDD's scripts are available in AMFP, but not all. Some are replaced by ones listed below, and others are removed.&lt;br /&gt;
&lt;br /&gt;
{{note|'''NOTE:''' This page is partially incomplete. Some arguments for the functions listed here have unknown effects. If you wish to contribute, feel free to test them. It's also possible there are additional script functions not listed here that exist within the engine.}}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== General ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void CheckPoint(string@&amp;amp; asName, string@&amp;amp; asStartArea, string@&amp;amp; asFunction, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry, const bool abPlayerLimbo);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a check point where the player will respawn if they die. '''Callback syntax:'''&amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asName, int alCount)&amp;lt;/code&amp;gt;&lt;br /&gt;
This function replaces TDD's &amp;lt;code&amp;gt;CheckPoint()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# ''asName''  - The internal name of the callback&lt;br /&gt;
# ''asStartArea''  - The name of the PlayerStartArea to respawn at&lt;br /&gt;
# ''asFunction''  - The name of the callback function to run&lt;br /&gt;
# ''asTextCat''  - The name of the .lang file category (SEEMS UNUSED)&lt;br /&gt;
# ''asTextEntry''  - The name of the .lang file entry (SEEMS UNUSED)&lt;br /&gt;
# ''abPlayerLimbo''  - Whether to put the player into a state of &amp;quot;limbo&amp;quot; upon death. In limbo, the death occurs normally, but once the screen fades to black, it remains so until &amp;lt;code&amp;gt;ReleasePlayerFromLimbo()&amp;lt;/code&amp;gt;  is called. Player is still controllable during death.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ReleasePlayerFromLimbo();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Respawns the player if stuck in &amp;quot;limbo&amp;quot;. Limbo can be enabled with ''CheckPoint''. Limbo is the state between life and death. The player enters limbo upon dying but won't respawn until this function is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void PlayScriptedAnimation(string@&amp;amp; asEntity, string@&amp;amp; asAnimation, const bool abLoop);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an animation that has been added to an entity through the Model Editor. Similar to ''PlayEnemyAnimation''.&lt;br /&gt;
&lt;br /&gt;
# asEntity - Internal name of the entity&lt;br /&gt;
# asAnimation - The animation name inside the entity&lt;br /&gt;
# abLoop - Whether to loop the animation or play it only once&lt;br /&gt;
&lt;br /&gt;
=== Screen effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string@&amp;amp; asImageFile, int alX, int alY, const float afUnknown1, const bool abUnknown2, const float afDuration, const float afFadeInTime, const float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Shows a 2D image on the screen. Originally used for showing the intro logo during a sequence.&lt;br /&gt;
&lt;br /&gt;
May work similarly to the [[HPL2/Tutorials/ShowScreenImage()|ATTD 1.5 ShowScreenImage()]].&lt;br /&gt;
&lt;br /&gt;
# ''asImageFile''  - The image file to show. Does not have to be pow2 (although it gives a warning if not)&lt;br /&gt;
# ''alX -''  The X position of the top left corner, starting from the center of the screen. Use negative half of the width of the image to center it.&lt;br /&gt;
# ''alY -''  The Y position of the top left corner, starting from the center of the screen.&lt;br /&gt;
# ''afUnknown1''  - Unsure what this is. Any value 0 or greater results in the image not showing up, so use -1&lt;br /&gt;
# ''abUnknown2''  - Unsure what this is. If set to true, image does not display, so use false&lt;br /&gt;
# ''afDuration''  - How long, in seconds, the image displays. This does not include fade times&lt;br /&gt;
# ''afFadeInTime''  - How long, in seconds, the fade in spends&lt;br /&gt;
# ''afFadeOutTime''  - How long, in seconds, the fade out spends&lt;br /&gt;
&lt;br /&gt;
=== Journal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddHint(string&amp;amp; asNameAndTextEntry, string@&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a hint to the player's journal. &amp;lt;br /&amp;gt;This function replaces TDD's ''AddDiary''.&lt;br /&gt;
&lt;br /&gt;
# ''asNameAndTextEntry''  - The .lang text entry of the hint. The entry must be in category &amp;quot;Journal&amp;quot; and use the format Hint_MyHint_Name for the title and Hint_MyHint_Text for the body, where MyHint replaces the value you put in this argument.&lt;br /&gt;
# ''asImage''  - This argument does not seem to be used. Presumed to be for displaying an image but possibly removed functionality. All existing occurrences are empty.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetJournalDisabled(const bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the player's ability to open their journal.&lt;br /&gt;
&lt;br /&gt;
# ''abDisabled''  - True to disable, false to enable again&lt;br /&gt;
=== Player ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternFlickerActive(const bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/disables the flicker effect for the lantern's light.&lt;br /&gt;
&lt;br /&gt;
# ''abActive''  - True to flicker, false to not flicker&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerInfection(const float afAmount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the [[:hpl2:machine_for_pigs:infection|infection]] level for the player. Infection replaces sanity from TDD and acts similar, however it goes from 0-100 instead of 100-0. An infection level above approximately 20 will affect the player's ability to move. Infection level above 80 will kill the player. Infection slowly decreases over time, unless high enough. &amp;lt;br /&amp;gt;This function replaces TDD's ''SetPlayerSanity''.&lt;br /&gt;
&lt;br /&gt;
# ''afAmount''  - The level of infection to set&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddPlayerInfection(const float afAmount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds an amount of infection to the player's current amount. &amp;lt;br /&amp;gt;This function replaces TDD's ''AddPlayerSanity''.&lt;br /&gt;
&lt;br /&gt;
# afAmount - The amount to add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerInfection();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the amount of infection the player currently has. &amp;lt;br /&amp;gt;This function replaces TDD's ''GetPlayerSanity''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerPitchTo(const float afPitch, const float afDeaccelleration, const float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves the player's pitch (up and down rotation).&lt;br /&gt;
&lt;br /&gt;
# ''afPitch''  - The target pitch to move towards. 0 = straight forward. Clamped to range: -70 to +70.&lt;br /&gt;
# ''afDeaccelleration''  - The deaccelleration when nearing the target pitch. A low value makes a slow change.&lt;br /&gt;
# ''afSpeed''  - The speed of the movement. Speed is affected by deaccelleration.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerUsesDragFootsteps(const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets whether the player's footstep sounds are replaced with &amp;quot;drag&amp;quot; versions. Some surface materials do not have drag steps, and will therefore play no footstep sounds.&lt;br /&gt;
&lt;br /&gt;
# abX - Whether to use &amp;quot;drag&amp;quot; step sounds&lt;br /&gt;
&lt;br /&gt;
=== Entities ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPhysicsAutoDisable(string@&amp;amp; asEntity, const bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Does… something. Not immediately apparent. Is only used on chandeliers in the campaign.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The entity to affect&lt;br /&gt;
# ''abDisabled''  - Whether this effect auto disables or not&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLampFlickerActive(string@&amp;amp; asLamp, const bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables a flickering effect on a Lamp-type entity.&lt;br /&gt;
&lt;br /&gt;
# ''asLamp''  - The lamp entity&lt;br /&gt;
# ''abActive''  - Whether to enable flicker&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPhoneRinging(string@&amp;amp; asEntity);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables a PhoneBox-type entity to start ringing. A ringing phone box can be interacted with to play some audio files. After interacting, the phone will stop ringing.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The PhoneBox entity&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopPhoneRinging(string@&amp;amp; asEntity)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops a ringing PhoneBox-type entity.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The PhoneBox entity&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntityActive(string@&amp;amp; asEntity);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns whether an entity in the level is active or not.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The entity to check&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopPropAnimation(string@&amp;amp; asProp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops the animation currently playing on a prop. Animations can be started with ''PlayPropAnimation''.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The name of the entity/prop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropAnimationPosition(string@&amp;amp; asProp, const float afPosition);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Jumps to a specifc point in an animation. Generally used in conjunction with ''PlayPropAnimation''.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The entity that is being animated&lt;br /&gt;
# ''afPosition''  - The time within the animation, in seconds, to jump to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorOpenAmount(string@&amp;amp; asEntity, const float afOpenAmount, const float afTime, const bool abUnknown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the open amount for a swing door.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The SwingDoor entity&lt;br /&gt;
# ''afOpenAmount''  - The new amount state to set. Range: 0 - 1&lt;br /&gt;
# ''afTime''  - The time in seconds until the door has changed state&lt;br /&gt;
# ''abUnknown''  - Unsure what this does. If set to true, nothing happens (?), so use false.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeLampTo(string@&amp;amp; asEntity, const uint alR, const uint alG, const uint alB, const uint alA, int alRadius, const double afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades a Lamp-type entity's light to another color. This function uses integers for color values instead of floats, which is a little odd. Likewise, it uses a double floating point for the last argument instead of a regular one.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The lamp to change&lt;br /&gt;
# ''alR''  - Red value (appropriate values are 0 - 10)&lt;br /&gt;
# ''alG''  - Green value (appropriate values are 0 - 10)&lt;br /&gt;
# ''alB''  - Blue value (appropriate values are 0 - 10)&lt;br /&gt;
# ''alA''  - Alpha value (has no effect?)&lt;br /&gt;
# ''alRadius''  - The new radius to use (affects illumination strength)&lt;br /&gt;
# ''afTime''  - Time in seconds until the light properties have changed&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetButtonCanBeSwitchedOn(string@&amp;amp; asEntity, const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes whether a Button-type entity can be toggled.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The button entity&lt;br /&gt;
# ''abX''  - Whether it can be switched on&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateEntityAtArea(string@&amp;amp; asName, string@&amp;amp; asFile, string@&amp;amp; asArea, const bool abUnknown, const float afOffsetX, const float afOffsetY, const float afOffsetZ, const float afRotX, const float afRotY, const float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates an entity at an area with the specified offsets and rotation. &amp;lt;br /&amp;gt;This function replaces TDD's ''CreateEntityAtArea''.&lt;br /&gt;
&lt;br /&gt;
# ''asName''  - The internal name of the created entity&lt;br /&gt;
# ''asFile''  - The file for the entity (extension .ent)&lt;br /&gt;
# ''asArea''  - The area to create entity at&lt;br /&gt;
# ''abUnknown''  - Not sure. Only true is used in the campaign. Seemingly has no effect&lt;br /&gt;
# ''afOffsetX''  - The offset along the X axis in units&lt;br /&gt;
# ''afOffsetY''  - The offset along the Y axis in units&lt;br /&gt;
# ''afOffsetZ''  - The offset along the Z axis in units&lt;br /&gt;
# ''afRotX''  - The rotation on the X axis in degrees&lt;br /&gt;
# ''afRotY''  - The rotation on the Y axis in degrees&lt;br /&gt;
# ''afRotZ''  - The rotation on the Z axis in degrees&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToBone(string@&amp;amp; asProp, string@&amp;amp; asEntity, string@&amp;amp; asBone, const float afOffsetX, const float afOffsetY, const float afOffsetZ, const float afRotX, const float afRotY, const float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to a specific bone within another entity. You can inspect bones in the Model Editor. Note: Offsets and rotations are local to the bone and relative to its rotation.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The prop to attach&lt;br /&gt;
# ''asEntity''  - The entity that holds the bone to attach to&lt;br /&gt;
# ''asBone''  - The bone within the entity to attach to&lt;br /&gt;
# ''afOffsetX''  - Offset along the X axis&lt;br /&gt;
# ''afOffsetY''  - Offset along the Y axis&lt;br /&gt;
# ''afOffsetZ''  - Offset along the Z axis&lt;br /&gt;
# ''afRotX''  - Rotation along the X axis&lt;br /&gt;
# ''afRotY''  - Rotation along the Y axis&lt;br /&gt;
# ''afRotZ''  - Rotation along the Z axis&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DetachPropFromBone(string@&amp;amp; asProp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches an attached prop. Note: When detached, physics are not automatically enabled on the prop.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The attached prop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AttachAreaToProp(string@&amp;amp; asArea, string@&amp;amp; asProp, const float afUnknown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches an area to a prop, however testing has not yielded any useful results. Originally used to attach a liquid area to a movable water plane entity in the sewers map.&lt;br /&gt;
&lt;br /&gt;
# ''asArea''  - The area to attach&lt;br /&gt;
# ''asProp''  - The prop to attach area to&lt;br /&gt;
# ''alUnknown''  - Unknown float value&lt;br /&gt;
=== Sounds ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice2(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 2 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 2 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice3(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 3 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 3 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice4(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 4 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 4 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice5(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, string@&amp;amp; asTextEntry5, const float afStartTime5, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 5 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 5 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''asTextEntry5''  - The fifth .lang subtitle entry&lt;br /&gt;
# ''afStartTime5''  - The time to wait until the fifth subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice6(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, string@&amp;amp; asTextEntry5, const float afStartTime5, string@&amp;amp; asTextEntry6, const float afStartTime6, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 6 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 6 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''asTextEntry5''  - The fifth .lang subtitle entry&lt;br /&gt;
# ''afStartTime5''  - The time to wait until the fifth subtitle starts&lt;br /&gt;
# ''asTextEntry6''  - The sixth .lang subtitle entry&lt;br /&gt;
# ''afStartTime6''  - The time to wait until the sixth subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice7(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, string@&amp;amp; asTextEntry5, const float afStartTime5, string@&amp;amp; asTextEntry6, const float afStartTime6, string@&amp;amp; asTextEntry7, const float afStartTime7, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 7 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 7 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''asTextEntry5''  - The fifth .lang subtitle entry&lt;br /&gt;
# ''afStartTime5''  - The time to wait until the fifth subtitle starts&lt;br /&gt;
# ''asTextEntry6''  - The sixth .lang subtitle entry&lt;br /&gt;
# ''afStartTime6''  - The time to wait until the sixth subtitle starts&lt;br /&gt;
# ''asTextEntry7''  - The seventh .lang subtitle entry&lt;br /&gt;
# ''afStartTime7 ''- The time to wait until the seventh subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
=== Enemies ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEnemyPatrolNode(string@&amp;amp; asEnemy, string@&amp;amp; asPathNode, const float afWaitTime, string@&amp;amp; asAnimation, const bool abUnknown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a patrol node to the enemy's walking path. A path is restarted from the beginning when the final node is reached. Note: Inputting an invalid animation in asAnimation at the final node will make the enemy wait there indefinitely. &amp;lt;br /&amp;gt;This function replaces TDD's AddEnemyPatrolNode.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - The name of the enemy&lt;br /&gt;
# ''asPathNode''  - Internal name of path node&lt;br /&gt;
# ''afWaitTime''  - The time, in seconds, the enemy waits at this node before continuing. Note: A time of 0.0f does not seem to skip waiting, use 0.01f instead if you want the enemy to immediately continue to the next node.&lt;br /&gt;
# ''asAnimation''  - The animation to play on the enemy when they arrive at this path node. Animations can be found in the Model Editor. Leave empty to play no special animation (uses default Idle animation). Note: If the animation lasts longer than afWaitTime, the enemy waits until the animation is complete before continuing the path.&lt;br /&gt;
# ''abUnknown''  - Unknown variable. Only false is ever used in the campaign. If set to true, seems to affect how animations are played, however they seem to just stutter or loop.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyMoveType(string@&amp;amp; asEnemy, string@&amp;amp; asMoveType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes how an enemy moves.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - The name of the enemy&lt;br /&gt;
# ''asMoveType''  - The type to change to. Type can be &amp;quot;WalkBiped&amp;quot;, &amp;quot;RunBiped&amp;quot;, &amp;quot;ChargeBiped&amp;quot;, &amp;quot;Idle&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetManPigType(string@&amp;amp; asEnemy, string@&amp;amp; asType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the type for a ManPig enemy. It is unknown whether this function does anything or if it's just left over from an earlier state of the game. Only &amp;quot;Freddy&amp;quot; is used as the type, but supposedly it should also accept &amp;quot;Rod&amp;quot; and &amp;quot;Jane&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - The ManPig enemy.&lt;br /&gt;
# ''asType''  - The type to set. Type can be &amp;quot;Freddy&amp;quot;, &amp;quot;Rod&amp;quot;, &amp;quot;Jane&amp;quot;&lt;br /&gt;
The three types allegedly describe three different personality types for the AI, according to Peter Howell in [https://researchportal.port.ac.uk/portal/files/3364888/PeterHowell_PhD.pdf his PhD, section 7.4.4].&lt;br /&gt;
&lt;br /&gt;
Extract:&lt;br /&gt;
&lt;br /&gt;
''The initial design of the game’s enemy artificial intelligence system contained three unique sets of behavioural controls. There was only one visual enemy style, however every enemy agent in the game would be assigned one of three possible ‘personalities’, referred to in the game’s code as the ‘Rod’, ‘Jane’ and ‘Freddy’ personality types. These personalities each had a different set of behavioural rules, thus allowing enemy agents that may otherwise appear identical to behave very differently to one another.''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot; border=1&lt;br /&gt;
!Enemy Agent Personality Type !!Primary Behavioural Traits |&lt;br /&gt;
|-&lt;br /&gt;
| Rod  || – Will maintain a 'safe' distance to the player-character. &amp;lt;br /&amp;gt;– unable to do so, will approach player character, investigate them (by getting close and smelling them), before continuing its patrol. &lt;br /&gt;
|-&lt;br /&gt;
| Jane  || – Will maintain a ‘safe’ distance from player-character, whilst observing the player-character’s movements. &amp;lt;br /&amp;gt;– If unable to maintain ‘safe’ distance, will panic and flee. &amp;lt;br /&amp;gt;– If cornered and unable to flee, will attack and knock player-character to floor, then flee. &amp;lt;br /&amp;gt;– Will only attack and kill player-character as a last resort. &lt;br /&gt;
|-&lt;br /&gt;
| Freddy  || – Will actively hunt the player-character. &amp;lt;br /&amp;gt;– Will attack and kill them if given the opportunity. &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayEnemyAnimation(string@&amp;amp; asEnemy, string@&amp;amp; asAnimation, const bool abLoop, const float afDelay);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays a specific animation for an enemy.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy (asterisk is allowed)&lt;br /&gt;
# ''asAnimation''  - The name of an animation registered to the enemy&lt;br /&gt;
# ''abLoop''  - Whether the animation loops&lt;br /&gt;
# ''afDelay''  - Seems to affect how the animation plays out. A higher value makes the animation slower, although it seems to also skip some keyframes or perhaps merge them, making the animation look incorrect. Experiment to see what works based on the animation.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeEnemyPose(string@&amp;amp; asEnemy, string@&amp;amp; asPose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the pose for an enemy. Can be either &amp;quot;Biped&amp;quot; or &amp;quot;Quadruped&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
# ''asPose''  - The pose to change to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ForceEnemyWaitState(string@&amp;amp; asEnemy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the enemy's AI to change the state to &amp;quot;Wait&amp;quot; which makes the enemy wait for a short while before continuing its' normal actions. An enemy without patrol nodes defaults to the &amp;quot;Wait&amp;quot; state. Otherwise, if patrol nodes are added, the enemy will continue the path after waiting is done.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyBlind(string@&amp;amp; asEnemy, const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets whether the enemy can see the player if they are within visible range.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
# ''abX''  - Whether enemy is blind&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDeaf(string@&amp;amp; asEnemy, const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets whether the enemy can hear the player make sound if they are within audible range.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
# ''abX''  - Whether enemy is deaf&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetPlayerCanSeeEnemy(string@&amp;amp; asEnemy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns whether the enemy is within visible range of the player.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetEnemyPlayerDistance(string@&amp;amp; asEnemy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the distance (in HPL units) between the enemy and the player.&lt;br /&gt;
&lt;br /&gt;
# asEnemy - Internal name of the enemy&lt;br /&gt;
&lt;br /&gt;
=== Particles ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetParticleSystemActive(string@&amp;amp; asParticleSystem, const bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pauses a particle system in its current frame. The paused particle system remains frozen at this frame until reactivated or destroyed.&lt;br /&gt;
&lt;br /&gt;
# ''asParticleSystem''  - The name of the particle system&lt;br /&gt;
# ''abActive''  - False to pause, true to unpause&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DestroyParticleSystemInstantly(string@&amp;amp; asParticleSystem);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Destroys a particle system and any existing particles already emitted from it. Similar to ''DestroyParticleSystem'', except that one will not destroy the existing particles and rather let them live out their lives. This function will cut all particles' lives short.&lt;br /&gt;
&lt;br /&gt;
# ''asParticleSystem''  - The PS to destroy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/AMFP/ScriptFunctions&amp;diff=6685</id>
		<title>HPL2/AMFP/ScriptFunctions</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/AMFP/ScriptFunctions&amp;diff=6685"/>
		<updated>2024-01-04T17:15:27Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Undo revision 6684 by Mrbehemo (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Engine scripts ==&lt;br /&gt;
&lt;br /&gt;
A list of script functions available in A Machine For Pigs (that are not present in The Dark Descent). Many of TDD's scripts are available in AMFP, but not all. Some are replaced by ones listed below, and others are removed.&lt;br /&gt;
&lt;br /&gt;
{{note|'''NOTE:''' This page is partially incomplete. Some arguments for the functions listed here have unknown effects. If you wish to contribute, feel free to test them. It's also possible there are additional script functions not listed here that exist within the engine.}}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== General ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void CheckPoint(string@&amp;amp; asName, string@&amp;amp; asStartArea, string@&amp;amp; asFunction, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry, const bool abPlayerLimbo);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a check point where the player will respawn if they die. '''Callback syntax:'''&amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asName, int alCount)&amp;lt;/code&amp;gt;&lt;br /&gt;
This function replaces TDD's &amp;lt;code&amp;gt;CheckPoint()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# ''asName''  - The internal name of the callback&lt;br /&gt;
# ''asStartArea''  - The name of the PlayerStartArea to respawn at&lt;br /&gt;
# ''asFunction''  - The name of the callback function to run&lt;br /&gt;
# ''asTextCat''  - The name of the .lang file category (SEEMS UNUSED)&lt;br /&gt;
# ''asTextEntry''  - The name of the .lang file entry (SEEMS UNUSED)&lt;br /&gt;
# ''abPlayerLimbo''  - Whether to put the player into a state of &amp;quot;limbo&amp;quot; upon death. In limbo, the death occurs normally, but once the screen fades to black, it remains so until &amp;lt;code&amp;gt;ReleasePlayerFromLimbo()&amp;lt;/code&amp;gt;  is called. Player is still controllable during death.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ReleasePlayerFromLimbo();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Respawns the player if stuck in &amp;quot;limbo&amp;quot;. Limbo can be enabled with ''CheckPoint''. Limbo is the state between life and death. The player enters limbo upon dying but won't respawn until this function is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void PlayScriptedAnimation(string@&amp;amp; asEntity, string@&amp;amp; asAnimation, const bool abLoop);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an animation that has been added to an entity through the Model Editor. Similar to ''PlayEnemyAnimation''.&lt;br /&gt;
&lt;br /&gt;
# asEntity - Internal name of the entity&lt;br /&gt;
# asAnimation - The animation name inside the entity&lt;br /&gt;
# abLoop - Whether to loop the animation or play it only once&lt;br /&gt;
&lt;br /&gt;
=== Screen effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string@&amp;amp; asImageFile, int alX, int alY, const float afUnknown1, const bool abUnknown2, const float afDuration, const float afFadeInTime, const float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Shows a 2D image on the screen. Originally used for showing the intro logo during a sequence.&lt;br /&gt;
&lt;br /&gt;
# ''asImageFile''  - The image file to show. Does not have to be pow2 (although it gives a warning if not)&lt;br /&gt;
# ''alX -''  The X position of the top left corner, starting from the center of the screen. Use negative half of the width of the image to center it.&lt;br /&gt;
# ''alY -''  The Y position of the top left corner, starting from the center of the screen.&lt;br /&gt;
# ''afUnknown1''  - Unsure what this is. Any value 0 or greater results in the image not showing up, so use -1&lt;br /&gt;
# ''abUnknown2''  - Unsure what this is. If set to true, image does not display, so use false&lt;br /&gt;
# ''afDuration''  - How long, in seconds, the image displays. This does not include fade times&lt;br /&gt;
# ''afFadeInTime''  - How long, in seconds, the fade in spends&lt;br /&gt;
# ''afFadeOutTime''  - How long, in seconds, the fade out spends&lt;br /&gt;
=== Journal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddHint(string&amp;amp; asNameAndTextEntry, string@&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a hint to the player's journal. &amp;lt;br /&amp;gt;This function replaces TDD's ''AddDiary''.&lt;br /&gt;
&lt;br /&gt;
# ''asNameAndTextEntry''  - The .lang text entry of the hint. The entry must be in category &amp;quot;Journal&amp;quot; and use the format Hint_MyHint_Name for the title and Hint_MyHint_Text for the body, where MyHint replaces the value you put in this argument.&lt;br /&gt;
# ''asImage''  - This argument does not seem to be used. Presumed to be for displaying an image but possibly removed functionality. All existing occurrences are empty.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetJournalDisabled(const bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the player's ability to open their journal.&lt;br /&gt;
&lt;br /&gt;
# ''abDisabled''  - True to disable, false to enable again&lt;br /&gt;
=== Player ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternFlickerActive(const bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/disables the flicker effect for the lantern's light.&lt;br /&gt;
&lt;br /&gt;
# ''abActive''  - True to flicker, false to not flicker&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerInfection(const float afAmount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the [[:hpl2:machine_for_pigs:infection|infection]] level for the player. Infection replaces sanity from TDD and acts similar, however it goes from 0-100 instead of 100-0. An infection level above approximately 20 will affect the player's ability to move. Infection level above 80 will kill the player. Infection slowly decreases over time, unless high enough. &amp;lt;br /&amp;gt;This function replaces TDD's ''SetPlayerSanity''.&lt;br /&gt;
&lt;br /&gt;
# ''afAmount''  - The level of infection to set&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddPlayerInfection(const float afAmount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds an amount of infection to the player's current amount. &amp;lt;br /&amp;gt;This function replaces TDD's ''AddPlayerSanity''.&lt;br /&gt;
&lt;br /&gt;
# afAmount - The amount to add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerInfection();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the amount of infection the player currently has. &amp;lt;br /&amp;gt;This function replaces TDD's ''GetPlayerSanity''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerPitchTo(const float afPitch, const float afDeaccelleration, const float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves the player's pitch (up and down rotation).&lt;br /&gt;
&lt;br /&gt;
# ''afPitch''  - The target pitch to move towards. 0 = straight forward. Clamped to range: -70 to +70.&lt;br /&gt;
# ''afDeaccelleration''  - The deaccelleration when nearing the target pitch. A low value makes a slow change.&lt;br /&gt;
# ''afSpeed''  - The speed of the movement. Speed is affected by deaccelleration.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerUsesDragFootsteps(const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets whether the player's footstep sounds are replaced with &amp;quot;drag&amp;quot; versions. Some surface materials do not have drag steps, and will therefore play no footstep sounds.&lt;br /&gt;
&lt;br /&gt;
# abX - Whether to use &amp;quot;drag&amp;quot; step sounds&lt;br /&gt;
&lt;br /&gt;
=== Entities ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPhysicsAutoDisable(string@&amp;amp; asEntity, const bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Does… something. Not immediately apparent. Is only used on chandeliers in the campaign.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The entity to affect&lt;br /&gt;
# ''abDisabled''  - Whether this effect auto disables or not&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLampFlickerActive(string@&amp;amp; asLamp, const bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables a flickering effect on a Lamp-type entity.&lt;br /&gt;
&lt;br /&gt;
# ''asLamp''  - The lamp entity&lt;br /&gt;
# ''abActive''  - Whether to enable flicker&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPhoneRinging(string@&amp;amp; asEntity);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables a PhoneBox-type entity to start ringing. A ringing phone box can be interacted with to play some audio files. After interacting, the phone will stop ringing.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The PhoneBox entity&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopPhoneRinging(string@&amp;amp; asEntity)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops a ringing PhoneBox-type entity.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The PhoneBox entity&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntityActive(string@&amp;amp; asEntity);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns whether an entity in the level is active or not.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The entity to check&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopPropAnimation(string@&amp;amp; asProp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops the animation currently playing on a prop. Animations can be started with ''PlayPropAnimation''.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The name of the entity/prop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropAnimationPosition(string@&amp;amp; asProp, const float afPosition);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Jumps to a specifc point in an animation. Generally used in conjunction with ''PlayPropAnimation''.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The entity that is being animated&lt;br /&gt;
# ''afPosition''  - The time within the animation, in seconds, to jump to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorOpenAmount(string@&amp;amp; asEntity, const float afOpenAmount, const float afTime, const bool abUnknown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the open amount for a swing door.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The SwingDoor entity&lt;br /&gt;
# ''afOpenAmount''  - The new amount state to set. Range: 0 - 1&lt;br /&gt;
# ''afTime''  - The time in seconds until the door has changed state&lt;br /&gt;
# ''abUnknown''  - Unsure what this does. If set to true, nothing happens (?), so use false.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeLampTo(string@&amp;amp; asEntity, const uint alR, const uint alG, const uint alB, const uint alA, int alRadius, const double afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades a Lamp-type entity's light to another color. This function uses integers for color values instead of floats, which is a little odd. Likewise, it uses a double floating point for the last argument instead of a regular one.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The lamp to change&lt;br /&gt;
# ''alR''  - Red value (appropriate values are 0 - 10)&lt;br /&gt;
# ''alG''  - Green value (appropriate values are 0 - 10)&lt;br /&gt;
# ''alB''  - Blue value (appropriate values are 0 - 10)&lt;br /&gt;
# ''alA''  - Alpha value (has no effect?)&lt;br /&gt;
# ''alRadius''  - The new radius to use (affects illumination strength)&lt;br /&gt;
# ''afTime''  - Time in seconds until the light properties have changed&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetButtonCanBeSwitchedOn(string@&amp;amp; asEntity, const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes whether a Button-type entity can be toggled.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The button entity&lt;br /&gt;
# ''abX''  - Whether it can be switched on&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateEntityAtArea(string@&amp;amp; asName, string@&amp;amp; asFile, string@&amp;amp; asArea, const bool abUnknown, const float afOffsetX, const float afOffsetY, const float afOffsetZ, const float afRotX, const float afRotY, const float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates an entity at an area with the specified offsets and rotation. &amp;lt;br /&amp;gt;This function replaces TDD's ''CreateEntityAtArea''.&lt;br /&gt;
&lt;br /&gt;
# ''asName''  - The internal name of the created entity&lt;br /&gt;
# ''asFile''  - The file for the entity (extension .ent)&lt;br /&gt;
# ''asArea''  - The area to create entity at&lt;br /&gt;
# ''abUnknown''  - Not sure. Only true is used in the campaign. Seemingly has no effect&lt;br /&gt;
# ''afOffsetX''  - The offset along the X axis in units&lt;br /&gt;
# ''afOffsetY''  - The offset along the Y axis in units&lt;br /&gt;
# ''afOffsetZ''  - The offset along the Z axis in units&lt;br /&gt;
# ''afRotX''  - The rotation on the X axis in degrees&lt;br /&gt;
# ''afRotY''  - The rotation on the Y axis in degrees&lt;br /&gt;
# ''afRotZ''  - The rotation on the Z axis in degrees&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToBone(string@&amp;amp; asProp, string@&amp;amp; asEntity, string@&amp;amp; asBone, const float afOffsetX, const float afOffsetY, const float afOffsetZ, const float afRotX, const float afRotY, const float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to a specific bone within another entity. You can inspect bones in the Model Editor. Note: Offsets and rotations are local to the bone and relative to its rotation.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The prop to attach&lt;br /&gt;
# ''asEntity''  - The entity that holds the bone to attach to&lt;br /&gt;
# ''asBone''  - The bone within the entity to attach to&lt;br /&gt;
# ''afOffsetX''  - Offset along the X axis&lt;br /&gt;
# ''afOffsetY''  - Offset along the Y axis&lt;br /&gt;
# ''afOffsetZ''  - Offset along the Z axis&lt;br /&gt;
# ''afRotX''  - Rotation along the X axis&lt;br /&gt;
# ''afRotY''  - Rotation along the Y axis&lt;br /&gt;
# ''afRotZ''  - Rotation along the Z axis&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DetachPropFromBone(string@&amp;amp; asProp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches an attached prop. Note: When detached, physics are not automatically enabled on the prop.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The attached prop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AttachAreaToProp(string@&amp;amp; asArea, string@&amp;amp; asProp, const float afUnknown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches an area to a prop, however testing has not yielded any useful results. Originally used to attach a liquid area to a movable water plane entity in the sewers map.&lt;br /&gt;
&lt;br /&gt;
# ''asArea''  - The area to attach&lt;br /&gt;
# ''asProp''  - The prop to attach area to&lt;br /&gt;
# ''alUnknown''  - Unknown float value&lt;br /&gt;
=== Sounds ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice2(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 2 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 2 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice3(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 3 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 3 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice4(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 4 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 4 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice5(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, string@&amp;amp; asTextEntry5, const float afStartTime5, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 5 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 5 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''asTextEntry5''  - The fifth .lang subtitle entry&lt;br /&gt;
# ''afStartTime5''  - The time to wait until the fifth subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice6(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, string@&amp;amp; asTextEntry5, const float afStartTime5, string@&amp;amp; asTextEntry6, const float afStartTime6, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 6 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 6 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''asTextEntry5''  - The fifth .lang subtitle entry&lt;br /&gt;
# ''afStartTime5''  - The time to wait until the fifth subtitle starts&lt;br /&gt;
# ''asTextEntry6''  - The sixth .lang subtitle entry&lt;br /&gt;
# ''afStartTime6''  - The time to wait until the sixth subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice7(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, string@&amp;amp; asTextEntry5, const float afStartTime5, string@&amp;amp; asTextEntry6, const float afStartTime6, string@&amp;amp; asTextEntry7, const float afStartTime7, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 7 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 7 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''asTextEntry5''  - The fifth .lang subtitle entry&lt;br /&gt;
# ''afStartTime5''  - The time to wait until the fifth subtitle starts&lt;br /&gt;
# ''asTextEntry6''  - The sixth .lang subtitle entry&lt;br /&gt;
# ''afStartTime6''  - The time to wait until the sixth subtitle starts&lt;br /&gt;
# ''asTextEntry7''  - The seventh .lang subtitle entry&lt;br /&gt;
# ''afStartTime7 ''- The time to wait until the seventh subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
=== Enemies ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEnemyPatrolNode(string@&amp;amp; asEnemy, string@&amp;amp; asPathNode, const float afWaitTime, string@&amp;amp; asAnimation, const bool abUnknown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a patrol node to the enemy's walking path. A path is restarted from the beginning when the final node is reached. Note: Inputting an invalid animation in asAnimation at the final node will make the enemy wait there indefinitely. &amp;lt;br /&amp;gt;This function replaces TDD's AddEnemyPatrolNode.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - The name of the enemy&lt;br /&gt;
# ''asPathNode''  - Internal name of path node&lt;br /&gt;
# ''afWaitTime''  - The time, in seconds, the enemy waits at this node before continuing. Note: A time of 0.0f does not seem to skip waiting, use 0.01f instead if you want the enemy to immediately continue to the next node.&lt;br /&gt;
# ''asAnimation''  - The animation to play on the enemy when they arrive at this path node. Animations can be found in the Model Editor. Leave empty to play no special animation (uses default Idle animation). Note: If the animation lasts longer than afWaitTime, the enemy waits until the animation is complete before continuing the path.&lt;br /&gt;
# ''abUnknown''  - Unknown variable. Only false is ever used in the campaign. If set to true, seems to affect how animations are played, however they seem to just stutter or loop.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyMoveType(string@&amp;amp; asEnemy, string@&amp;amp; asMoveType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes how an enemy moves.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - The name of the enemy&lt;br /&gt;
# ''asMoveType''  - The type to change to. Type can be &amp;quot;WalkBiped&amp;quot;, &amp;quot;RunBiped&amp;quot;, &amp;quot;ChargeBiped&amp;quot;, &amp;quot;Idle&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetManPigType(string@&amp;amp; asEnemy, string@&amp;amp; asType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the type for a ManPig enemy. It is unknown whether this function does anything or if it's just left over from an earlier state of the game. Only &amp;quot;Freddy&amp;quot; is used as the type, but supposedly it should also accept &amp;quot;Rod&amp;quot; and &amp;quot;Jane&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - The ManPig enemy.&lt;br /&gt;
# ''asType''  - The type to set. Type can be &amp;quot;Freddy&amp;quot;, &amp;quot;Rod&amp;quot;, &amp;quot;Jane&amp;quot;&lt;br /&gt;
The three types allegedly describe three different personality types for the AI, according to Peter Howell in [https://researchportal.port.ac.uk/portal/files/3364888/PeterHowell_PhD.pdf his PhD, section 7.4.4].&lt;br /&gt;
&lt;br /&gt;
Extract:&lt;br /&gt;
&lt;br /&gt;
''The initial design of the game’s enemy artificial intelligence system contained three unique sets of behavioural controls. There was only one visual enemy style, however every enemy agent in the game would be assigned one of three possible ‘personalities’, referred to in the game’s code as the ‘Rod’, ‘Jane’ and ‘Freddy’ personality types. These personalities each had a different set of behavioural rules, thus allowing enemy agents that may otherwise appear identical to behave very differently to one another.''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot; border=1&lt;br /&gt;
!Enemy Agent Personality Type !!Primary Behavioural Traits |&lt;br /&gt;
|-&lt;br /&gt;
| Rod  || – Will maintain a 'safe' distance to the player-character. &amp;lt;br /&amp;gt;– unable to do so, will approach player character, investigate them (by getting close and smelling them), before continuing its patrol. &lt;br /&gt;
|-&lt;br /&gt;
| Jane  || – Will maintain a ‘safe’ distance from player-character, whilst observing the player-character’s movements. &amp;lt;br /&amp;gt;– If unable to maintain ‘safe’ distance, will panic and flee. &amp;lt;br /&amp;gt;– If cornered and unable to flee, will attack and knock player-character to floor, then flee. &amp;lt;br /&amp;gt;– Will only attack and kill player-character as a last resort. &lt;br /&gt;
|-&lt;br /&gt;
| Freddy  || – Will actively hunt the player-character. &amp;lt;br /&amp;gt;– Will attack and kill them if given the opportunity. &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayEnemyAnimation(string@&amp;amp; asEnemy, string@&amp;amp; asAnimation, const bool abLoop, const float afDelay);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays a specific animation for an enemy.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy (asterisk is allowed)&lt;br /&gt;
# ''asAnimation''  - The name of an animation registered to the enemy&lt;br /&gt;
# ''abLoop''  - Whether the animation loops&lt;br /&gt;
# ''afDelay''  - Seems to affect how the animation plays out. A higher value makes the animation slower, although it seems to also skip some keyframes or perhaps merge them, making the animation look incorrect. Experiment to see what works based on the animation.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeEnemyPose(string@&amp;amp; asEnemy, string@&amp;amp; asPose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the pose for an enemy. Can be either &amp;quot;Biped&amp;quot; or &amp;quot;Quadruped&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
# ''asPose''  - The pose to change to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ForceEnemyWaitState(string@&amp;amp; asEnemy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the enemy's AI to change the state to &amp;quot;Wait&amp;quot; which makes the enemy wait for a short while before continuing its' normal actions. An enemy without patrol nodes defaults to the &amp;quot;Wait&amp;quot; state. Otherwise, if patrol nodes are added, the enemy will continue the path after waiting is done.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyBlind(string@&amp;amp; asEnemy, const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets whether the enemy can see the player if they are within visible range.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
# ''abX''  - Whether enemy is blind&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDeaf(string@&amp;amp; asEnemy, const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets whether the enemy can hear the player make sound if they are within audible range.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
# ''abX''  - Whether enemy is deaf&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetPlayerCanSeeEnemy(string@&amp;amp; asEnemy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns whether the enemy is within visible range of the player.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetEnemyPlayerDistance(string@&amp;amp; asEnemy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the distance (in HPL units) between the enemy and the player.&lt;br /&gt;
&lt;br /&gt;
# asEnemy - Internal name of the enemy&lt;br /&gt;
&lt;br /&gt;
=== Particles ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetParticleSystemActive(string@&amp;amp; asParticleSystem, const bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pauses a particle system in its current frame. The paused particle system remains frozen at this frame until reactivated or destroyed.&lt;br /&gt;
&lt;br /&gt;
# ''asParticleSystem''  - The name of the particle system&lt;br /&gt;
# ''abActive''  - False to pause, true to unpause&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DestroyParticleSystemInstantly(string@&amp;amp; asParticleSystem);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Destroys a particle system and any existing particles already emitted from it. Similar to ''DestroyParticleSystem'', except that one will not destroy the existing particles and rather let them live out their lives. This function will cut all particles' lives short.&lt;br /&gt;
&lt;br /&gt;
# ''asParticleSystem''  - The PS to destroy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/AMFP/ScriptFunctions&amp;diff=6684</id>
		<title>HPL2/AMFP/ScriptFunctions</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/AMFP/ScriptFunctions&amp;diff=6684"/>
		<updated>2024-01-04T17:14:50Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Edited notes for ShowScreenImage() and added a link to tutorial.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Engine scripts ==&lt;br /&gt;
&lt;br /&gt;
A list of script functions available in A Machine For Pigs (that are not present in The Dark Descent). Many of TDD's scripts are available in AMFP, but not all. Some are replaced by ones listed below, and others are removed.&lt;br /&gt;
&lt;br /&gt;
{{note|'''NOTE:''' This page is partially incomplete. Some arguments for the functions listed here have unknown effects. If you wish to contribute, feel free to test them. It's also possible there are additional script functions not listed here that exist within the engine.}}&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
=== General ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void CheckPoint(string@&amp;amp; asName, string@&amp;amp; asStartArea, string@&amp;amp; asFunction, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry, const bool abPlayerLimbo);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a check point where the player will respawn if they die. '''Callback syntax:'''&amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asName, int alCount)&amp;lt;/code&amp;gt;&lt;br /&gt;
This function replaces TDD's &amp;lt;code&amp;gt;CheckPoint()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
# ''asName''  - The internal name of the callback&lt;br /&gt;
# ''asStartArea''  - The name of the PlayerStartArea to respawn at&lt;br /&gt;
# ''asFunction''  - The name of the callback function to run&lt;br /&gt;
# ''asTextCat''  - The name of the .lang file category (SEEMS UNUSED)&lt;br /&gt;
# ''asTextEntry''  - The name of the .lang file entry (SEEMS UNUSED)&lt;br /&gt;
# ''abPlayerLimbo''  - Whether to put the player into a state of &amp;quot;limbo&amp;quot; upon death. In limbo, the death occurs normally, but once the screen fades to black, it remains so until &amp;lt;code&amp;gt;ReleasePlayerFromLimbo()&amp;lt;/code&amp;gt;  is called. Player is still controllable during death.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ReleasePlayerFromLimbo();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Respawns the player if stuck in &amp;quot;limbo&amp;quot;. Limbo can be enabled with ''CheckPoint''. Limbo is the state between life and death. The player enters limbo upon dying but won't respawn until this function is called.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void PlayScriptedAnimation(string@&amp;amp; asEntity, string@&amp;amp; asAnimation, const bool abLoop);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an animation that has been added to an entity through the Model Editor. Similar to ''PlayEnemyAnimation''.&lt;br /&gt;
&lt;br /&gt;
# asEntity - Internal name of the entity&lt;br /&gt;
# asAnimation - The animation name inside the entity&lt;br /&gt;
# abLoop - Whether to loop the animation or play it only once&lt;br /&gt;
&lt;br /&gt;
=== Screen effects ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string@&amp;amp; asImageFile, int alX, int alY, const float afUnknown1, const bool abUnknown2, const float afDuration, const float afFadeInTime, const float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Shows a 2D image on the screen. Originally used for showing the intro logo during a sequence.&lt;br /&gt;
See [[HPL2/Tutorials/ShowScreenImage()|ShowScreenImage()]] in the ATTD tutorials section for more information.&lt;br /&gt;
&lt;br /&gt;
# ''asImageName'' - The image file to render (.jpg, .png, .tga, .dds)&lt;br /&gt;
# ''afX'' - The X position of the image&lt;br /&gt;
# ''afY'' - The Y position of the image&lt;br /&gt;
# ''afScale'' - The size of the image in pixels (not scale), or original image size if negative&lt;br /&gt;
# ''abUseRelativeCoordinates'' - Whether X and Y are relative to the screen resoltion, or pixel co-ordinates if not&lt;br /&gt;
# ''afDuration'' - The duration that the image is displayed for&lt;br /&gt;
# ''afFadeIn'' - The time, in seconds, to fade in the image&lt;br /&gt;
# ''afFadeOut'' - The time, in seconds, to fade out the image&lt;br /&gt;
&lt;br /&gt;
=== Journal ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddHint(string&amp;amp; asNameAndTextEntry, string@&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a hint to the player's journal. &amp;lt;br /&amp;gt;This function replaces TDD's ''AddDiary''.&lt;br /&gt;
&lt;br /&gt;
# ''asNameAndTextEntry''  - The .lang text entry of the hint. The entry must be in category &amp;quot;Journal&amp;quot; and use the format Hint_MyHint_Name for the title and Hint_MyHint_Text for the body, where MyHint replaces the value you put in this argument.&lt;br /&gt;
# ''asImage''  - This argument does not seem to be used. Presumed to be for displaying an image but possibly removed functionality. All existing occurrences are empty.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetJournalDisabled(const bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the player's ability to open their journal.&lt;br /&gt;
&lt;br /&gt;
# ''abDisabled''  - True to disable, false to enable again&lt;br /&gt;
=== Player ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternFlickerActive(const bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/disables the flicker effect for the lantern's light.&lt;br /&gt;
&lt;br /&gt;
# ''abActive''  - True to flicker, false to not flicker&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerInfection(const float afAmount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the [[:hpl2:machine_for_pigs:infection|infection]] level for the player. Infection replaces sanity from TDD and acts similar, however it goes from 0-100 instead of 100-0. An infection level above approximately 20 will affect the player's ability to move. Infection level above 80 will kill the player. Infection slowly decreases over time, unless high enough. &amp;lt;br /&amp;gt;This function replaces TDD's ''SetPlayerSanity''.&lt;br /&gt;
&lt;br /&gt;
# ''afAmount''  - The level of infection to set&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddPlayerInfection(const float afAmount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds an amount of infection to the player's current amount. &amp;lt;br /&amp;gt;This function replaces TDD's ''AddPlayerSanity''.&lt;br /&gt;
&lt;br /&gt;
# afAmount - The amount to add&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerInfection();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the amount of infection the player currently has. &amp;lt;br /&amp;gt;This function replaces TDD's ''GetPlayerSanity''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerPitchTo(const float afPitch, const float afDeaccelleration, const float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves the player's pitch (up and down rotation).&lt;br /&gt;
&lt;br /&gt;
# ''afPitch''  - The target pitch to move towards. 0 = straight forward. Clamped to range: -70 to +70.&lt;br /&gt;
# ''afDeaccelleration''  - The deaccelleration when nearing the target pitch. A low value makes a slow change.&lt;br /&gt;
# ''afSpeed''  - The speed of the movement. Speed is affected by deaccelleration.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerUsesDragFootsteps(const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets whether the player's footstep sounds are replaced with &amp;quot;drag&amp;quot; versions. Some surface materials do not have drag steps, and will therefore play no footstep sounds.&lt;br /&gt;
&lt;br /&gt;
# abX - Whether to use &amp;quot;drag&amp;quot; step sounds&lt;br /&gt;
&lt;br /&gt;
=== Entities ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPhysicsAutoDisable(string@&amp;amp; asEntity, const bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Does… something. Not immediately apparent. Is only used on chandeliers in the campaign.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The entity to affect&lt;br /&gt;
# ''abDisabled''  - Whether this effect auto disables or not&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLampFlickerActive(string@&amp;amp; asLamp, const bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables a flickering effect on a Lamp-type entity.&lt;br /&gt;
&lt;br /&gt;
# ''asLamp''  - The lamp entity&lt;br /&gt;
# ''abActive''  - Whether to enable flicker&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPhoneRinging(string@&amp;amp; asEntity);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables a PhoneBox-type entity to start ringing. A ringing phone box can be interacted with to play some audio files. After interacting, the phone will stop ringing.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The PhoneBox entity&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopPhoneRinging(string@&amp;amp; asEntity)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops a ringing PhoneBox-type entity.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The PhoneBox entity&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntityActive(string@&amp;amp; asEntity);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns whether an entity in the level is active or not.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The entity to check&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopPropAnimation(string@&amp;amp; asProp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops the animation currently playing on a prop. Animations can be started with ''PlayPropAnimation''.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The name of the entity/prop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropAnimationPosition(string@&amp;amp; asProp, const float afPosition);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Jumps to a specifc point in an animation. Generally used in conjunction with ''PlayPropAnimation''.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The entity that is being animated&lt;br /&gt;
# ''afPosition''  - The time within the animation, in seconds, to jump to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorOpenAmount(string@&amp;amp; asEntity, const float afOpenAmount, const float afTime, const bool abUnknown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the open amount for a swing door.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The SwingDoor entity&lt;br /&gt;
# ''afOpenAmount''  - The new amount state to set. Range: 0 - 1&lt;br /&gt;
# ''afTime''  - The time in seconds until the door has changed state&lt;br /&gt;
# ''abUnknown''  - Unsure what this does. If set to true, nothing happens (?), so use false.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeLampTo(string@&amp;amp; asEntity, const uint alR, const uint alG, const uint alB, const uint alA, int alRadius, const double afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades a Lamp-type entity's light to another color. This function uses integers for color values instead of floats, which is a little odd. Likewise, it uses a double floating point for the last argument instead of a regular one.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The lamp to change&lt;br /&gt;
# ''alR''  - Red value (appropriate values are 0 - 10)&lt;br /&gt;
# ''alG''  - Green value (appropriate values are 0 - 10)&lt;br /&gt;
# ''alB''  - Blue value (appropriate values are 0 - 10)&lt;br /&gt;
# ''alA''  - Alpha value (has no effect?)&lt;br /&gt;
# ''alRadius''  - The new radius to use (affects illumination strength)&lt;br /&gt;
# ''afTime''  - Time in seconds until the light properties have changed&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetButtonCanBeSwitchedOn(string@&amp;amp; asEntity, const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes whether a Button-type entity can be toggled.&lt;br /&gt;
&lt;br /&gt;
# ''asEntity''  - The button entity&lt;br /&gt;
# ''abX''  - Whether it can be switched on&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateEntityAtArea(string@&amp;amp; asName, string@&amp;amp; asFile, string@&amp;amp; asArea, const bool abUnknown, const float afOffsetX, const float afOffsetY, const float afOffsetZ, const float afRotX, const float afRotY, const float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates an entity at an area with the specified offsets and rotation. &amp;lt;br /&amp;gt;This function replaces TDD's ''CreateEntityAtArea''.&lt;br /&gt;
&lt;br /&gt;
# ''asName''  - The internal name of the created entity&lt;br /&gt;
# ''asFile''  - The file for the entity (extension .ent)&lt;br /&gt;
# ''asArea''  - The area to create entity at&lt;br /&gt;
# ''abUnknown''  - Not sure. Only true is used in the campaign. Seemingly has no effect&lt;br /&gt;
# ''afOffsetX''  - The offset along the X axis in units&lt;br /&gt;
# ''afOffsetY''  - The offset along the Y axis in units&lt;br /&gt;
# ''afOffsetZ''  - The offset along the Z axis in units&lt;br /&gt;
# ''afRotX''  - The rotation on the X axis in degrees&lt;br /&gt;
# ''afRotY''  - The rotation on the Y axis in degrees&lt;br /&gt;
# ''afRotZ''  - The rotation on the Z axis in degrees&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToBone(string@&amp;amp; asProp, string@&amp;amp; asEntity, string@&amp;amp; asBone, const float afOffsetX, const float afOffsetY, const float afOffsetZ, const float afRotX, const float afRotY, const float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to a specific bone within another entity. You can inspect bones in the Model Editor. Note: Offsets and rotations are local to the bone and relative to its rotation.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The prop to attach&lt;br /&gt;
# ''asEntity''  - The entity that holds the bone to attach to&lt;br /&gt;
# ''asBone''  - The bone within the entity to attach to&lt;br /&gt;
# ''afOffsetX''  - Offset along the X axis&lt;br /&gt;
# ''afOffsetY''  - Offset along the Y axis&lt;br /&gt;
# ''afOffsetZ''  - Offset along the Z axis&lt;br /&gt;
# ''afRotX''  - Rotation along the X axis&lt;br /&gt;
# ''afRotY''  - Rotation along the Y axis&lt;br /&gt;
# ''afRotZ''  - Rotation along the Z axis&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DetachPropFromBone(string@&amp;amp; asProp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches an attached prop. Note: When detached, physics are not automatically enabled on the prop.&lt;br /&gt;
&lt;br /&gt;
# ''asProp''  - The attached prop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AttachAreaToProp(string@&amp;amp; asArea, string@&amp;amp; asProp, const float afUnknown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches an area to a prop, however testing has not yielded any useful results. Originally used to attach a liquid area to a movable water plane entity in the sewers map.&lt;br /&gt;
&lt;br /&gt;
# ''asArea''  - The area to attach&lt;br /&gt;
# ''asProp''  - The prop to attach area to&lt;br /&gt;
# ''alUnknown''  - Unknown float value&lt;br /&gt;
=== Sounds ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice2(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 2 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 2 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice3(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 3 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 3 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice4(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 4 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 4 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice5(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, string@&amp;amp; asTextEntry5, const float afStartTime5, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 5 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 5 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''asTextEntry5''  - The fifth .lang subtitle entry&lt;br /&gt;
# ''afStartTime5''  - The time to wait until the fifth subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice6(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, string@&amp;amp; asTextEntry5, const float afStartTime5, string@&amp;amp; asTextEntry6, const float afStartTime6, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 6 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 6 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''asTextEntry5''  - The fifth .lang subtitle entry&lt;br /&gt;
# ''afStartTime5''  - The time to wait until the fifth subtitle starts&lt;br /&gt;
# ''asTextEntry6''  - The sixth .lang subtitle entry&lt;br /&gt;
# ''afStartTime6''  - The time to wait until the sixth subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice7(string@&amp;amp; asVoiceFile, string@&amp;amp; asEffectFile, string@&amp;amp; asTextCat, string@&amp;amp; asTextEntry1, const float afStartTime1, string@&amp;amp; asTextEntry2, const float afStartTime2, string@&amp;amp; asTextEntry3, const float afStartTime3, string@&amp;amp; asTextEntry4, const float afStartTime4, string@&amp;amp; asTextEntry5, const float afStartTime5, string@&amp;amp; asTextEntry6, const float afStartTime6, string@&amp;amp; asTextEntry7, const float afStartTime7, const bool abUsePosition, string@&amp;amp; asPosEntity, const float afMinDistance, const float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays an audio file with 7 consecutive subtitles.&lt;br /&gt;
&lt;br /&gt;
# ''asVoiceFile''  - The entire voice file to play (intended to include 7 sections)&lt;br /&gt;
# ''asEffectFile''  - The background effect file to play during voices. Leave empty for no extra effect&lt;br /&gt;
# ''asTextCat''  - The .lang text category for the subtitles&lt;br /&gt;
# ''asTextEntry1''  - The first .lang subtitle entry&lt;br /&gt;
# ''afStartTime1''  - The time to wait until the first subtitle starts&lt;br /&gt;
# ''asTextEntry2''  - The second .lang subtitle entry&lt;br /&gt;
# ''afStartTime2''  - The time to wait until the second subtitle starts&lt;br /&gt;
# ''asTextEntry3''  - The third .lang subtitle entry&lt;br /&gt;
# ''afStartTime3''  - The time to wait until the third subtitle starts&lt;br /&gt;
# ''asTextEntry4''  - The fourth .lang subtitle entry&lt;br /&gt;
# ''afStartTime4''  - The time to wait until the fourth subtitle starts&lt;br /&gt;
# ''asTextEntry5''  - The fifth .lang subtitle entry&lt;br /&gt;
# ''afStartTime5''  - The time to wait until the fifth subtitle starts&lt;br /&gt;
# ''asTextEntry6''  - The sixth .lang subtitle entry&lt;br /&gt;
# ''afStartTime6''  - The time to wait until the sixth subtitle starts&lt;br /&gt;
# ''asTextEntry7''  - The seventh .lang subtitle entry&lt;br /&gt;
# ''afStartTime7 ''- The time to wait until the seventh subtitle starts&lt;br /&gt;
# ''abUsePosition''  - Whether to use 3D to play the sound from an entity&lt;br /&gt;
# ''asPosEntity''  - The entity to play the sound from. If empty, plays from player&lt;br /&gt;
# ''afMinDistance''  - The minimum distance required between the player and the entity in order to hear the audio&lt;br /&gt;
# ''afMaxDistance''  - The maximum distance allowed between the player and the entity in order to hear the audio&lt;br /&gt;
=== Enemies ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEnemyPatrolNode(string@&amp;amp; asEnemy, string@&amp;amp; asPathNode, const float afWaitTime, string@&amp;amp; asAnimation, const bool abUnknown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a patrol node to the enemy's walking path. A path is restarted from the beginning when the final node is reached. Note: Inputting an invalid animation in asAnimation at the final node will make the enemy wait there indefinitely. &amp;lt;br /&amp;gt;This function replaces TDD's AddEnemyPatrolNode.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - The name of the enemy&lt;br /&gt;
# ''asPathNode''  - Internal name of path node&lt;br /&gt;
# ''afWaitTime''  - The time, in seconds, the enemy waits at this node before continuing. Note: A time of 0.0f does not seem to skip waiting, use 0.01f instead if you want the enemy to immediately continue to the next node.&lt;br /&gt;
# ''asAnimation''  - The animation to play on the enemy when they arrive at this path node. Animations can be found in the Model Editor. Leave empty to play no special animation (uses default Idle animation). Note: If the animation lasts longer than afWaitTime, the enemy waits until the animation is complete before continuing the path.&lt;br /&gt;
# ''abUnknown''  - Unknown variable. Only false is ever used in the campaign. If set to true, seems to affect how animations are played, however they seem to just stutter or loop.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyMoveType(string@&amp;amp; asEnemy, string@&amp;amp; asMoveType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes how an enemy moves.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - The name of the enemy&lt;br /&gt;
# ''asMoveType''  - The type to change to. Type can be &amp;quot;WalkBiped&amp;quot;, &amp;quot;RunBiped&amp;quot;, &amp;quot;ChargeBiped&amp;quot;, &amp;quot;Idle&amp;quot;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetManPigType(string@&amp;amp; asEnemy, string@&amp;amp; asType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the type for a ManPig enemy. It is unknown whether this function does anything or if it's just left over from an earlier state of the game. Only &amp;quot;Freddy&amp;quot; is used as the type, but supposedly it should also accept &amp;quot;Rod&amp;quot; and &amp;quot;Jane&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - The ManPig enemy.&lt;br /&gt;
# ''asType''  - The type to set. Type can be &amp;quot;Freddy&amp;quot;, &amp;quot;Rod&amp;quot;, &amp;quot;Jane&amp;quot;&lt;br /&gt;
The three types allegedly describe three different personality types for the AI, according to Peter Howell in [https://researchportal.port.ac.uk/portal/files/3364888/PeterHowell_PhD.pdf his PhD, section 7.4.4].&lt;br /&gt;
&lt;br /&gt;
Extract:&lt;br /&gt;
&lt;br /&gt;
''The initial design of the game’s enemy artificial intelligence system contained three unique sets of behavioural controls. There was only one visual enemy style, however every enemy agent in the game would be assigned one of three possible ‘personalities’, referred to in the game’s code as the ‘Rod’, ‘Jane’ and ‘Freddy’ personality types. These personalities each had a different set of behavioural rules, thus allowing enemy agents that may otherwise appear identical to behave very differently to one another.''&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot; border=1&lt;br /&gt;
!Enemy Agent Personality Type !!Primary Behavioural Traits |&lt;br /&gt;
|-&lt;br /&gt;
| Rod  || – Will maintain a 'safe' distance to the player-character. &amp;lt;br /&amp;gt;– unable to do so, will approach player character, investigate them (by getting close and smelling them), before continuing its patrol. &lt;br /&gt;
|-&lt;br /&gt;
| Jane  || – Will maintain a ‘safe’ distance from player-character, whilst observing the player-character’s movements. &amp;lt;br /&amp;gt;– If unable to maintain ‘safe’ distance, will panic and flee. &amp;lt;br /&amp;gt;– If cornered and unable to flee, will attack and knock player-character to floor, then flee. &amp;lt;br /&amp;gt;– Will only attack and kill player-character as a last resort. &lt;br /&gt;
|-&lt;br /&gt;
| Freddy  || – Will actively hunt the player-character. &amp;lt;br /&amp;gt;– Will attack and kill them if given the opportunity. &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayEnemyAnimation(string@&amp;amp; asEnemy, string@&amp;amp; asAnimation, const bool abLoop, const float afDelay);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays a specific animation for an enemy.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy (asterisk is allowed)&lt;br /&gt;
# ''asAnimation''  - The name of an animation registered to the enemy&lt;br /&gt;
# ''abLoop''  - Whether the animation loops&lt;br /&gt;
# ''afDelay''  - Seems to affect how the animation plays out. A higher value makes the animation slower, although it seems to also skip some keyframes or perhaps merge them, making the animation look incorrect. Experiment to see what works based on the animation.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeEnemyPose(string@&amp;amp; asEnemy, string@&amp;amp; asPose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the pose for an enemy. Can be either &amp;quot;Biped&amp;quot; or &amp;quot;Quadruped&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
# ''asPose''  - The pose to change to&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ForceEnemyWaitState(string@&amp;amp; asEnemy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the enemy's AI to change the state to &amp;quot;Wait&amp;quot; which makes the enemy wait for a short while before continuing its' normal actions. An enemy without patrol nodes defaults to the &amp;quot;Wait&amp;quot; state. Otherwise, if patrol nodes are added, the enemy will continue the path after waiting is done.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyBlind(string@&amp;amp; asEnemy, const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets whether the enemy can see the player if they are within visible range.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
# ''abX''  - Whether enemy is blind&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDeaf(string@&amp;amp; asEnemy, const bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets whether the enemy can hear the player make sound if they are within audible range.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
# ''abX''  - Whether enemy is deaf&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetPlayerCanSeeEnemy(string@&amp;amp; asEnemy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns whether the enemy is within visible range of the player.&lt;br /&gt;
&lt;br /&gt;
# ''asEnemy''  - Internal name of the enemy&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetEnemyPlayerDistance(string@&amp;amp; asEnemy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the distance (in HPL units) between the enemy and the player.&lt;br /&gt;
&lt;br /&gt;
# asEnemy - Internal name of the enemy&lt;br /&gt;
&lt;br /&gt;
=== Particles ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetParticleSystemActive(string@&amp;amp; asParticleSystem, const bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pauses a particle system in its current frame. The paused particle system remains frozen at this frame until reactivated or destroyed.&lt;br /&gt;
&lt;br /&gt;
# ''asParticleSystem''  - The name of the particle system&lt;br /&gt;
# ''abActive''  - False to pause, true to unpause&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DestroyParticleSystemInstantly(string@&amp;amp; asParticleSystem);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Destroys a particle system and any existing particles already emitted from it. Similar to ''DestroyParticleSystem'', except that one will not destroy the existing particles and rather let them live out their lives. This function will cut all particles' lives short.&lt;br /&gt;
&lt;br /&gt;
# ''asParticleSystem''  - The PS to destroy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Engine_Scripts&amp;diff=6683</id>
		<title>HPL2/Engine Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Engine_Scripts&amp;diff=6683"/>
		<updated>2024-01-04T17:14:16Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
&lt;br /&gt;
This page documents all scripts available in Amnesia: The Dark Descent.&lt;br /&gt;
&lt;br /&gt;
{{note|'''Note''': Some of the functions require the Amnesia 1.3 or 1.5 update. Steam and other online store copies should be automatically updated. Other copies can get 1.3 [http://www.frictionalgames.com/forum/thread-24334.html here].}}&lt;br /&gt;
&lt;br /&gt;
== Directives ==&lt;br /&gt;
&lt;br /&gt;
First off, &amp;lt;code&amp;gt;#include &amp;quot;file.hps&amp;quot;&amp;lt;/code&amp;gt; can be used to programmatically merge together multiple separate files to make organizing scripts easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
==Engine scripts==&lt;br /&gt;
===Main===&lt;br /&gt;
&lt;br /&gt;
The following functions are the main hps functions that the HPL2 engine looks to run on certain events - similar to the C++ int main() function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void OnStart();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs when the map is loaded for the first time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnEnter();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs whenever the player enters a map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnLeave();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs when the player leaves a map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnGameStart();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function is found in the global.hps file and the inventory.hps file, and is run when the game is first started by the player (ie via &amp;quot;Start New Game&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnUpdate(float afStep);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
This function is executed for every game update or &amp;quot;tick&amp;quot;. Can be used for rapid-firing updates instead of looping timers. Keep in mind that this can affect game performance if not used with care.&lt;br /&gt;
&lt;br /&gt;
#''afStep''- time elapsed since the last frame. Multiply speeds, distances etc. by this argument to avoid framerate dependence issues (for example: if you move something in this function with constant speed, it will move faster on computers which run the game with high FPS and slower on computers with low FPS).&lt;br /&gt;
&lt;br /&gt;
===General===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float RandFloat(float afMin, float afMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generates a random float.&lt;br /&gt;
&lt;br /&gt;
#''afMin ''- minimum value&lt;br /&gt;
#''afMax ''- maximum value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
int RandInt(int alMin, int alMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generates a random int. Note: the maximum value is ''inclusive''  - the RandInt() function may return this value.&lt;br /&gt;
&lt;br /&gt;
#''alMin ''- minimum value&lt;br /&gt;
#''alMax ''- maximum value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool StringContains(string&amp;amp; asString, string&amp;amp; asSubString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a string contains the specified string. &amp;lt;br /&amp;gt;Example: searching for &amp;quot;hello&amp;quot; in &amp;quot;hello world&amp;quot; would return '''true'''.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string to check&lt;br /&gt;
#''asSubString ''- the string to search for&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string&amp;amp; StringSub(string&amp;amp; asString, int alStart, int alCount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the substring in a string. &amp;lt;br /&amp;gt;Example: in the string &amp;quot;frictional games rocks&amp;quot;, using 4 as ''alStart''  and 6 as ''alCount''  would return '''&amp;quot;tional&amp;quot;'''.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string&lt;br /&gt;
#''alStart ''- start position in the string&lt;br /&gt;
#''alCount ''- amount of characters&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
int StringToInt(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns an integer converted from a string, else returns 0.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float StringToFloat(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns a float converted from a string, else returns 0.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool StringToBool(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns a boolean converted from a string, else returns false.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&lt;br /&gt;
===Mathematical Operations===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathSin(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the sine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathCos(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the cosine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathTan(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the tangent of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAsin(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc sine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAcos(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc cosine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAtan(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc tangent of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAtan2(float afX, float afY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Calculates and returns the arc tangent of the specified values.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - First value to operate.&lt;br /&gt;
#''afY''  - Second value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathSqrt(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the square root of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathPow(float afBase, float afExp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the value of afBase raised to the power of afExp.&lt;br /&gt;
&lt;br /&gt;
#''afBase''  - The base value.&lt;br /&gt;
#''afExp''  - Value to calculate the base with.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathMin(float afA, float afB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the lowest value.&lt;br /&gt;
&lt;br /&gt;
#''afA''  - First value.&lt;br /&gt;
#''afB''  - Second value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathMax(float afA, float afB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the highest value.&lt;br /&gt;
&lt;br /&gt;
#''afA''  - First value.&lt;br /&gt;
#''afB''  - Second value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathClamp(float afX, float afMin, float afMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns afX clamped between afMin and afMax. If afX &amp;lt; afMin, returns afMin, and if afX &amp;gt; afMax, returns afMax.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - The value to clamp.&lt;br /&gt;
#''afMin''  - The minimum value to clamp afX with.&lt;br /&gt;
#''afMax''  - The maximum value to clamp afX with.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAbs(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the absolute value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Print(string&amp;amp; asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints a string to the log file (''hpl.log'').&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddDebugMessage(string&amp;amp; asString, bool abCheckForDuplicates);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints a string to the debug console.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string to print&lt;br /&gt;
#''abCheckForDuplicates ''- if true, the string won't be printed more than once on screen until it disappears&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ProgLog(string&amp;amp; asLevel, string&amp;amp; asMessage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints an entry to the ProgLog (progression log). &amp;lt;br /&amp;gt;ProgLog is a file created in Documents/Amnesia/main (or an FC folder if one is being used). It logs certain events, such us opening the menu or picking up the lantern, as well as the player's state (Health, Sanity, Oil, Tinderboxes, Coins), for the purpose of documenting a tester's playstyle. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;This function allows to log custom messages.The messages in the ProgLog file are sorted by time elapsed since a map was loaded.&lt;br /&gt;
&lt;br /&gt;
ProgLog has to be enabled for a player profile in ''user_settings.cfg''  before it starts working.&lt;br /&gt;
&lt;br /&gt;
#''asLevel ''- can be &amp;quot;Low&amp;quot;, &amp;quot;Medium&amp;quot; or &amp;quot;High&amp;quot;. It's a tag which appears in each log entry, for event prioritising.&lt;br /&gt;
#''asMessage ''- The custom message to be printed to the log.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool ScriptDebugOn();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the debug mode is enabled. &amp;lt;br /&amp;gt;See [[HPL2/Development_Environment|&amp;quot;Setting up Development Environment&amp;quot;]] to setup debug mode on your own computer.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
{{warning|Regular variables (int, float, etc.) are '''not''' saved by the game. Using them in important parts of yor script will break it upon loading a game save. In HPL, those variables should only be used for disposable counters, like spawning objects in a &amp;quot;for&amp;quot; loop. For variables which need to be saved, use the wrappers as described below.}}&lt;br /&gt;
&lt;br /&gt;
====Local====&lt;br /&gt;
&lt;br /&gt;
Local variables can be used throughout the same script file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
void AddLocalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
int GetLocalVarInt(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
void AddLocalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
float GetLocalVarFloat(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarString(string&amp;amp; asName, const string&amp;amp; asVal);&lt;br /&gt;
void AddLocalVarString(string&amp;amp; asName, string&amp;amp; asVal);&lt;br /&gt;
string&amp;amp; GetLocalVarString(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Global====&lt;br /&gt;
&lt;br /&gt;
Global variables can be used throughout several maps and can be accessed by several script files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
void AddGlobalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
int GetGlobalVarInt(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
void AddGlobalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
float GetGlobalVarFloat(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarString(string&amp;amp; asName, const string&amp;amp; asVal);&lt;br /&gt;
void AddGlobalVarString(string&amp;amp; asName, string&amp;amp; asVal);&lt;br /&gt;
string&amp;amp; GetGlobalVarString(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Particle Systems===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PreloadParticleSystem(string&amp;amp; asPSFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Preloads a particle system.&lt;br /&gt;
&lt;br /&gt;
#''asPSFile''  - The particle system file to load. Extension: .ps&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateParticleSystemAtEntity(string&amp;amp; asPSName, string&amp;amp; asPSFile, string&amp;amp; asEntity, bool abSavePS);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a particle system on an entity.&lt;br /&gt;
&lt;br /&gt;
#''asPSName ''- internal name&lt;br /&gt;
#''asPSFile ''- the particle system to use + extension .ps&lt;br /&gt;
#''asEntity ''- the entity to create the particle system at&lt;br /&gt;
#''abSavePS ''- determines whether a particle system should &amp;quot;remember&amp;quot; its shown/hidden state, so that this state can be restored when the player revisits the level&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateParticleSystemAtEntityExt(string&amp;amp; asPSName, string&amp;amp; asPSFile, string&amp;amp; asEntity, bool abSavePS,&lt;br /&gt;
float afR, float afG, float afB, float afA, bool abFadeAtDistance, float afFadeMinEnd, float afFadeMinStart,&lt;br /&gt;
float afFadeMaxStart, float afFadeMaxEnd);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a particle system on an entity, extended method with more options.&lt;br /&gt;
&lt;br /&gt;
#''asPSName ''- internal name&lt;br /&gt;
#''asPSFile ''- the particle system to use + extension .ps&lt;br /&gt;
#''asEntity ''- the entity to create the particle system at&lt;br /&gt;
#''abSavePS ''- determines whether a particle system should &amp;quot;remember&amp;quot; its shown/hidden state, so that this state can be restored when the player revisits the level&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
#''abFadeAtDistance ''- determines whether a particle system fades from a certain distance on&lt;br /&gt;
#''afFadeMinEnd ''- minimum distance at which the particle system stops fading&lt;br /&gt;
#''afFadeMinStart ''- minimum distance at which the particle system starts fading&lt;br /&gt;
#''afFadeMaxStart ''- maximum distance at which the particle system starts fading&lt;br /&gt;
#''afFadeMaxEnd ''- maximum distance at which the particle system stops fading&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DestroyParticleSystem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Destroys a particle system.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - The internal name of the particle system&lt;br /&gt;
&lt;br /&gt;
===Sounds &amp;amp; Music===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PreloadSound(string&amp;amp; asSoundFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Preloads a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundFile''  - The sound file to load. Extension: .snt&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlaySoundAtEntity(string&amp;amp; asSoundName, string&amp;amp; asSoundFile, string&amp;amp; asEntity, float afFadeTime, bool abSaveSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a sound on an entity.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''asSoundFile ''- the sound to use + extension .snt&lt;br /&gt;
#''asEntity ''- the entity to create the sound at, can be &amp;quot;Player&amp;quot;&lt;br /&gt;
#''afFadeTime ''- time in seconds the sound needs to fade. Avoids enemies hearing the sound if afFadeTime is at least 0.1f&lt;br /&gt;
#''abSaveSound ''- if ''true'', a looping sound will &amp;quot;remember&amp;quot; its playback state (currently playing/stopped), and that state will be restored the next time the level is entered. If ''true'', the sound is never attached to the entity! Note that saving should only be used on ''looping sounds''!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeInSound(string&amp;amp; asSoundName, float afFadeTime, bool abPlayStart);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades in a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''afFadeTime ''- time in seconds&lt;br /&gt;
#''abPlayStart ''- ?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopSound(string&amp;amp; asSoundName, float afFadeTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades out a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''afFadeTime ''- time in seconds, use 0 to immediatly stop the sound&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayMusic(string&amp;amp; asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays music.&lt;br /&gt;
&lt;br /&gt;
#''asMusicFile ''- the music to play + extension .ogg&lt;br /&gt;
#''abLoop ''- determines whether a music track should loop&lt;br /&gt;
#''afVolume ''- volume of the music&lt;br /&gt;
#''afFadeTime ''- time in seconds until music reaches full volume&lt;br /&gt;
#''alPrio ''- priority of the music. Note that only the music with the highest priority can be heard! 0 - lowest, 1 - higher, etc.&lt;br /&gt;
#''abResume''  - if ''true'', playback will be continued from where the track stopped after the call to StopMusic(); if ''false'', the track will be restarted.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopMusic(float afFadeTime, int alPrio);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops music.&lt;br /&gt;
&lt;br /&gt;
#''afFadeTime ''- time in seconds until music stops&lt;br /&gt;
#''alPrio ''- the priority of the music that should stop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeGlobalSoundVolume(float afDestVolume, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Influences the global sound volume, that means everything you can hear '''from the world'''. This does not affect music of GUI sounds.&lt;br /&gt;
&lt;br /&gt;
#''afDestVolume ''- desired volume&lt;br /&gt;
#''afTime ''- time in seconds until volume reaches desired volume&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeGlobalSoundSpeed(float afDestSpeed, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Influences the global sound speed.&lt;br /&gt;
&lt;br /&gt;
#''afDestSpeed ''- desired speed&lt;br /&gt;
#''afTime ''- time in seconds until volume reaches desired speed&lt;br /&gt;
&lt;br /&gt;
===Lights===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLightVisible(string&amp;amp; asLightName, bool abVisible);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/disables lights.&lt;br /&gt;
&lt;br /&gt;
#''asLightName ''- internal name&lt;br /&gt;
#''abVisible ''- determines the state of the light&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeLightTo(string&amp;amp; asLightName, float afR, float afG, float afB, float afA, float afRadius, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the properties of a light.&lt;br /&gt;
&lt;br /&gt;
#''asLightName ''- internal name&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
#''afRadius ''- radius of the light. -1 means keeping the radius&lt;br /&gt;
#''afTime ''- time in seconds until change is done&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLightFlickerActive(string&amp;amp; asLightName, bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates flickering on a light.&lt;br /&gt;
&lt;br /&gt;
#''asLightName''  - The internal light name&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&lt;br /&gt;
==Game scripts==&lt;br /&gt;
&lt;br /&gt;
===General===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartCredits(string&amp;amp; asMusic, bool abLoopMusic, string&amp;amp; asTextCat, string&amp;amp; asTextEntry, int alEndNum);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the end credits screen.&lt;br /&gt;
&lt;br /&gt;
#''asMusic ''- the music to play (including .ogg)&lt;br /&gt;
#''abLoopMusic ''- determines whether the music should loop&lt;br /&gt;
#''asTextCat ''- the category to be used in the .lang file&lt;br /&gt;
#''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
#''alEndNum ''- Amnesia has 3 different endings and displays a code at the bottom. Determines which code is displayed. 0-2 will display codes, any other integer will not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartDemoEnd();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the end images that are used in the demo, images are named &amp;quot;demo_end01.jpg&amp;quot;, increase the number for each image you want to use. (NEEDS VERIFICATION)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AutoSave();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the game to the auto save.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CheckPoint (string&amp;amp; asName, string&amp;amp; asStartPos, string&amp;amp; asCallback, string&amp;amp; asDeathHintCat, string&amp;amp; asDeathHintEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets a checkpoint at which the player will respawn in case he dies. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asName, int alCount)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;Count is 0 on the first checkpoint load!&lt;br /&gt;
&lt;br /&gt;
#''asName ''- the internal name&lt;br /&gt;
#''asStartPos ''- the name of the StartPos in the editor&lt;br /&gt;
#''asCallback ''- the function to call when the player dies/respawns&lt;br /&gt;
#''asDeathHintCat ''- the category of the death hint message to be used in the .lang file&lt;br /&gt;
#''asDeathHintEntry ''- the entry in the .lang file&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeMap(string&amp;amp; asMapName, string&amp;amp; asStartPos, string&amp;amp; asStartSound, string&amp;amp; asEndSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Immediatly loads another map.&lt;br /&gt;
&lt;br /&gt;
#''asMapName ''- the file to load&lt;br /&gt;
#''asStartPos ''- the name of the StartPos on the next map&lt;br /&gt;
#''asStartSound ''- the sound that is played when the change starts&lt;br /&gt;
#''asEndSound ''- the sound that is played when the new map is loaded&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ClearSavedMaps();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clears the &amp;quot;history&amp;quot; of the save, useful to do when you know the player will not be able to go back anymore. Makes the next save much smaller in size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateDataCache();&lt;br /&gt;
void DestroyDataCache();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This caches all current textures and models and they are not released until destroy is called. If there is already cached data it is destroyed.&lt;br /&gt;
Create caches to enable faster loading when going back to a map. Destroy the cache if you know the player won't go back to that map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetMapDisplayNameEntry(string&amp;amp; asNameEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the map name shown in save file names. If none is set NULL is assumed.&lt;br /&gt;
&lt;br /&gt;
#''asNameEntry ''- the entry to display, category must be &amp;quot;Levels&amp;quot;!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the skybox.&lt;br /&gt;
&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxTexture(string&amp;amp; asTexture);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the texture of the skybox.&lt;br /&gt;
&lt;br /&gt;
#''asTexture''  - The texture file to set. Extension: .dds&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxColor(float afR, float afG, float afB, float afA);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the solid color of the skybox rather than a texture.&lt;br /&gt;
&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the global fog.&lt;br /&gt;
&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogColor(float afR, float afG, float afB, float afA);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the color to use for the global fog.&lt;br /&gt;
&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogProperties(float afStart, float afEnd, float afFalloffExp, bool abCulling);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the properties for the global fog.&lt;br /&gt;
&lt;br /&gt;
#''afStart ''- how many meters from the camera should the fog begin&lt;br /&gt;
#''afEnd ''- how many meters from the camera should the fog reach full thickness&lt;br /&gt;
#''afFalloffExp ''- the amount by which the thinkness increases&lt;br /&gt;
#''abCulling ''- whether occlusion culling is active for the fog; this prevents objects behind the fog from being loaded&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetupLoadScreen(string&amp;amp;asTextCat, string&amp;amp;asTextEntry, int alRandomNum, string&amp;amp;asImageFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which loading screen will be shown when changing maps.&lt;br /&gt;
&lt;br /&gt;
#''asTextCat ''- the category of the loading text in the .lang file to be shown on the loading screen&lt;br /&gt;
#''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
#''alRandomNum ''- if greater 1, then it will randomize between 1 and alRandom for each LoadScreen giving entry the suffix XX (eg 01). If &amp;lt; =1 then no suffix is added&lt;br /&gt;
#''asImageFile ''- the image to be shown (optional)&lt;br /&gt;
&lt;br /&gt;
===Game Timer===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddTimer(string&amp;amp; asName, float afTime, string&amp;amp; asFunction);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a timer which calls a function when it expires. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asTimer)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#''asName ''- the name of the timer&lt;br /&gt;
#''afTime ''- time in seconds&lt;br /&gt;
#''asFunction ''- the function to call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveTimer(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes a timer, no matter how much time is left.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - the internal name of the timer.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetTimerTimeLeft(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the time left on a timer.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - the internal name of the timer.&lt;br /&gt;
&lt;br /&gt;
===Screen Effects===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeOut(float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to black.&lt;br /&gt;
&lt;br /&gt;
''afTime ''- time in seconds until the screen is completly black&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeIn(float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen back to normal.&lt;br /&gt;
&lt;br /&gt;
''afTime ''- time in seconds until the screen back to normal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeImageTrailTo(float afAmount, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applies the image trail effect to the screen.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeSepiaColorTo(float afAmount, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the screen go dark red.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeRadialBlurTo(float afSize, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applies radial blur effects to the screen.&lt;br /&gt;
&lt;br /&gt;
''afSize ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetRadialBlurStartDist(float afStartDist);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines at which distance the radial blur effects appear.&lt;br /&gt;
&lt;br /&gt;
''afStartDist ''- the distance at which the effect starts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartEffectFlash(float afFadeIn, float afWhite, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to white.&lt;br /&gt;
&lt;br /&gt;
''afFadeIn ''- time in seconds until screen is white &amp;lt;br /&amp;gt;''afWhite ''- determines to which percentage the screen fades to white (1.0 = completly white) &amp;lt;br /&amp;gt;''afFadeOut ''- time in seconds until screen is back to normal again&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartEffectEmotionFlash(string&amp;amp; asTextCat, string&amp;amp; asTextEntry, string&amp;amp; asSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to white and shows a text message.&lt;br /&gt;
&lt;br /&gt;
''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the text entry in the .lang file &amp;lt;br /&amp;gt;''asSound ''- the sound to play while fading&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice(string&amp;amp; asVoiceFile, string&amp;amp; asEffectFile, string&amp;amp; asTextCat, string&amp;amp; asTextEntry,&lt;br /&gt;
bool abUsePosition, string&amp;amp; asPosEntity, float afMinDistance, float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This adds a voice and an effect to be played. It is okay to call this many times in order to play many voices in a row. The EffectVoiceOverCallback is not called until ALL voices have finished.&lt;br /&gt;
&lt;br /&gt;
''asVoiceFile ''- the voice to play &amp;lt;br /&amp;gt;''asEffectFile ''- the effect to play &amp;lt;br /&amp;gt;''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the text entry in the .lang file &amp;lt;br /&amp;gt;''abUsePosition ''- plays using 3D from the entity, or without 3D &amp;lt;br /&amp;gt;''asPosEntity ''- the entity at which the effect appears &amp;lt;br /&amp;gt;''afMinDistance ''- minimum distance to see the effect &amp;lt;br /&amp;gt;''afMaxDistance ''- maximum distance to see the effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopAllEffectVoices(float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops all voices and calls the EffectVoiceOverCallback.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEffectVoiceActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether EffectVoices are still active.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEffectVoiceOverCallback(string&amp;amp; asFunc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the function to be called when the EffectVoices are finished. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetFlashbackIsActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a flashback is still in effect.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPlayerSpawnPS(string&amp;amp; asSPSFile);&lt;br /&gt;
void StopPlayerSpawnPS();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuously spawn regular particle systems (''.ps'') around the player. Particles created by this script carry over from map to map. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;''asSPSFile''  - the ''.sps''  file to use. Exemplary ''.sps''  files are located in the ''/misc''  folder in the main game directory. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;Custom ''.sps''  files can be created by hand in a text editor (see existing ones and mimic how those are written). &amp;lt;br /&amp;gt;Since ''StopPlayerSpawnPS()''  doesn't seem to work, to stop an SPS you must create an ''.sps''  file with an empty particle field field and override the old SPS by calling ''StartPlayerSpawnPS''  again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayGuiSound(string&amp;amp; asSoundFile, float afVolume);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays a sound, not using 3D.&lt;br /&gt;
&lt;br /&gt;
''asSoundFile ''- the sound to play (extension is .snt) &amp;lt;br /&amp;gt;''afVolume ''- the volume of the sound&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartScreenShake(float afAmount, float afTime, float afFadeInTime, float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Shakes the screen.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity of the shake &amp;lt;br /&amp;gt;''afTime ''- duration of the shake &amp;lt;br /&amp;gt;''afFadeInTime ''- time in seconds until full intensity is reached &amp;lt;br /&amp;gt;''afFadeOutTime ''- time until screen is back to normal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInDarknessEffectsActive(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables the sanity drain and night vision effects while in the darkness.&lt;br /&gt;
&lt;br /&gt;
''bool abX''  - Enable/disable effects.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen. See [[HPL2/Tutorials/ShowScreenImage()|ShowScreenImage()]] in the tutorials section for more information.&lt;br /&gt;
&lt;br /&gt;
# ''asImageName'' - The image file to render (.jpg, .png, .tga, .dds)&lt;br /&gt;
# ''afX'' - The X position of the image&lt;br /&gt;
# ''afY'' - The Y position of the image&lt;br /&gt;
# ''afScale'' - The size of the image in pixels (not scale), or original image size if negative&lt;br /&gt;
# ''abUseRelativeCoordinates'' - Whether X and Y are relative to the screen resoltion, or pixel co-ordinates if not&lt;br /&gt;
# ''afDuration'' - The duration that the image is displayed for&lt;br /&gt;
# ''afFadeIn'' - The time, in seconds, to fade in the image&lt;br /&gt;
# ''afFadeOut'' - The time, in seconds, to fade out the image&lt;br /&gt;
&lt;br /&gt;
===Insanity===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInsanitySetEnabled(string&amp;amp; asSet, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which InsanitySets are enabled.&lt;br /&gt;
&lt;br /&gt;
''asSet ''- the set &amp;lt;br /&amp;gt;''abX ''- enabled or not&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartInsanityEvent(string &amp;amp;in asEventName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Starts a specified insanity event.&lt;br /&gt;
&lt;br /&gt;
''asEventName ''- Insanity event to play.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartRandomInsanityEvent();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts a random insanity event from the available sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopCurrentInsanityEvent();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Stops the currently playing insanity event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void InsanityEventIsActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether an insanity event is currently in effect… Or so it was supposed to be, but as it doesn't return a value, we can never know [http://wiki.frictionalgames.com/lib/images/smileys/icon_smile.gif?nolink&amp;amp;15x15]&lt;br /&gt;
&lt;br /&gt;
===Player===&lt;br /&gt;
&lt;br /&gt;
Note that the player's maximum health and sanity is 100.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enabled/Disable player controlled movement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangePlayerStateToNormal();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets certain effects back to normal. It can for example make the player drop an item.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerCrouching(bool abCrouch);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the player to crouch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pushes the player into a certain direction. Note that you need values above ~2000 to see any effects.&lt;br /&gt;
&lt;br /&gt;
''afX ''- amount along the X-axis &amp;lt;br /&amp;gt;''afY ''- amount along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- amount along the Z-axis &amp;lt;br /&amp;gt;''abUseLocalCoords ''- If true, axes are based on where the player is facing, not the world.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowPlayerCrossHairIcons(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the icons when a player has something in focus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerSanity(float afSanity);&lt;br /&gt;
void AddPlayerSanity(float afSanity);&lt;br /&gt;
float GetPlayerSanity();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the sanity of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerHealth(float afHealth);&lt;br /&gt;
void AddPlayerHealth(float afHealth);&lt;br /&gt;
float GetPlayerHealth();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the health of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerLampOil(float afOil);&lt;br /&gt;
void AddPlayerLampOil(float afOil);&lt;br /&gt;
float GetPlayerLampOil();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the lamp oil of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerSpeed();&lt;br /&gt;
float GetPlayerYSpeed();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the current speed of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSanityDrainDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables sanity drain from darkness, monsters, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveSanityBoost();&lt;br /&gt;
void GiveSanityBoostSmall();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Boosts the player's sanity by a fixed amount.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveSanityDamage(float afAmount, bool abUseEffect);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduces the sanity of the player.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount of sanity damage done &amp;lt;br /&amp;gt;''abUseEffect ''- determines whether an effect is played when the sanity damage is dealt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GivePlayerDamage(float afAmount, string&amp;amp; asType, bool abSpinHead, bool abLethal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduces the health of the player.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount of damage done to health &amp;lt;br /&amp;gt;''asType ''- plays a certain effect on the screen when the damage is dealt (BloodSplat, Claws or Slash) &amp;lt;br /&amp;gt;''abSpinHead ''- changes the camera view when damage is dealt &amp;lt;br /&amp;gt;''abLethal ''- set to true if player can die from given damage&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerFOVMulTo(float afX, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the field of view of the player. A shorter FOV will create a zoom effect.&lt;br /&gt;
&lt;br /&gt;
''afX ''- multiplier of default FOV (1 is default) &amp;lt;br /&amp;gt;''afSpeed ''- the speed of change between FOV's&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerAspectMulTo(float afX, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the aspect ratio of the player. Basically stretches or narrows the screen horizontally.&lt;br /&gt;
&lt;br /&gt;
''afX ''- multiplier of default aspect (default is 1) &amp;lt;br /&amp;gt;''afSpeed ''- the speed of change between FOV's&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerRollTo(float afX, float afSpeedMul, float afMaxSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rotates the position of the camera on the player's body.&lt;br /&gt;
&lt;br /&gt;
''afX ''- angle of rotation of head, positive being counter-clockwise &amp;lt;br /&amp;gt;''afSpeedMul ''- speed (possibly acceleration) multiplier of the rotation (default 1, which is really slow) &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed of rotation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void MovePlayerHeadPos(float afX, float afY, float afZ, float afSpeed, float afSlowDownDist);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the position of the camera on the player's body.&lt;br /&gt;
&lt;br /&gt;
''afX ''- amount along the X-axis &amp;lt;br /&amp;gt;''afY ''- amount along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- amount along the Z-axis &amp;lt;br /&amp;gt;''afSpeed ''- speed at which the change happens &amp;lt;br /&amp;gt;''afSlowDownDist ''- distance at which to start slowing down (prevents the head from abruptly stopping)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPlayerLookAt(string&amp;amp; asEntityName, float afSpeedMul, float afMaxSpeed, string&amp;amp; asAtTargetCallback);&lt;br /&gt;
void StopPlayerLookAt();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the player to look at a certain entity until StopPlayerLookAt is used.&lt;br /&gt;
&lt;br /&gt;
''asEntityName ''- the entity to look at &amp;lt;br /&amp;gt;''afSpeedMul ''- how fast should the player look at the entity &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed allowed &amp;lt;br /&amp;gt;''asAtTargetCallback ''- function to call when player looks at target&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerMoveSpeedMul(float afMul);&lt;br /&gt;
void SetPlayerRunSpeedMul(float afMul);&lt;br /&gt;
void SetPlayerLookSpeedMul(float afMul);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the player's move/run/look speed. Default is 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerJumpForceMul(float afMul);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Changes the player's jump multiplier. Higher values = higher jumps. Default is 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerJumpDisabled(bool abX);&lt;br /&gt;
void SetPlayerCrouchDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the player's ability to jump/crouch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportPlayer(string&amp;amp; asStartPosName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instantly teleports the player to the target StartPos.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternActive(bool abX, bool abUseEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the player use his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetLanternActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the player currently uses his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the player's ability to use his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternLitCallback(string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the function to call when the player uses his lantern. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;MyFunc(bool abLit)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetMessage(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a message on the screen.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTime ''- determines how long the message is displayed. If time is &amp;lt; =0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetDeathHint(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the message that appears when the player dies.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DisableDeathStartSound();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the death sound when the player dies. This must be called directly before player is killed! The variable as soon as player dies too.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
void MovePlayerForward(float afAmount)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;REQUIRES THE 1.2 PATCH: JUSTINE&amp;quot; Moves the player forward. It needs to be called in a timer that updates 60 times / second.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerFallDamageDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables the player's ability to take fall damage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerPos(float afX, float afY, float afZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Sets the player's position within the level.&lt;br /&gt;
&lt;br /&gt;
''afX''  - X co-ordinate position. &amp;lt;br /&amp;gt;''afY''  - Y co-ordinate position. &amp;lt;br /&amp;gt;''afZ''  - Z co-ordinate position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerPosX();&lt;br /&gt;
float GetPlayerPosY();&lt;br /&gt;
float GetPlayerPosZ();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the player's position within the level on the specified axis.&lt;br /&gt;
&lt;br /&gt;
===Journal===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddNote(string&amp;amp; asNameAndTextEntry, string&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a note to the player's journal.&lt;br /&gt;
&lt;br /&gt;
''asNameAndTextEntry ''- entries in the .lang file. Must end with _Name and _Text and be in category &amp;quot;Journal&amp;quot;! &amp;lt;br /&amp;gt;''asImage ''- the background image to be used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddDiary(string&amp;amp; asNameAndTextEntry, string&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a diary to the player's journal.&lt;br /&gt;
&lt;br /&gt;
''asNameAndTextEntry ''- entries in the .lang file. Must end with _NameX and _TextY whereas X and Y are numbers of the parts (_Name1: first diary, _Text1: first page) and be in category &amp;quot;Journal&amp;quot;! &amp;lt;br /&amp;gt;''asImage ''- the background image to be used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ReturnOpenJournal(bool abOpenJournal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Only called in the pickup diary callback! If true the journal displays the entry else not.&lt;br /&gt;
&lt;br /&gt;
===Quests===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddQuest(string&amp;amp; asName, string&amp;amp; asNameAndTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a quest to the player's journal under mementos.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name to be used &amp;lt;br /&amp;gt;''asNameAndTextEntry ''- entry in the .lang file. Must start with &amp;quot;Quest_&amp;lt;texthere&amp;gt;_Text”, and be in category “Journal”!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CompleteQuest(string&amp;amp; asName, string&amp;amp; asNameAndTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Completes a quest.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name of the quest &amp;lt;br /&amp;gt;''asNameAndTextEntry ''- entry in the .lang file. Must start with &amp;quot; Quest_&amp;lt;texthere&amp;gt;_Text ”, and be in category “Journal”!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool QuestIsCompleted(string&amp;amp; asName);&lt;br /&gt;
bool QuestIsAdded(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a quest is completed/added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetNumberOfQuestsInMap(int alNumberOfQuests);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the number of quests in the map.&lt;br /&gt;
&lt;br /&gt;
''alNumberOfQuests ''- Amount of Quests&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveHint(string&amp;amp; asName, string&amp;amp; asMessageCat, string&amp;amp; asMessageEntry, float afTimeShown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a hint on the player's screen.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name &amp;lt;br /&amp;gt;''asMessageCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asMessageEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTimeShown ''- time in seconds until the message disappears. If time is &amp;lt;= 0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void BlockHint(string&amp;amp; asName);&lt;br /&gt;
void UnBlockHint(string&amp;amp; asName);&lt;br /&gt;
void RemoveHint(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Blocking a hint prevents it from being shown. Blocked hints are included in savefiles, so they should persist between levels.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Removing&amp;quot; a hint actually removes it from the list of already given hints, thus allowing it to show up again.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name. Basic game hints use the same name as their respective lang entries, with the exception of &amp;quot;numbered&amp;quot; hints. For example, &amp;lt;code&amp;gt;EntityGrab&amp;lt;/code&amp;gt; blocks the &amp;lt;code&amp;gt;EntityGrab01&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;EntityGrab02&amp;lt;/code&amp;gt; entries.&lt;br /&gt;
&lt;br /&gt;
===Inventory===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ExitInventory();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exits the inventory by force.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInventoryDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the player's ability to open his inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInventoryMessage(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a message at the bottom of the inventory screen.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTime ''- time in seconds until the message disappears. If life time is &amp;lt;= 0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveItem(string&amp;amp; asName, string&amp;amp; asType, string&amp;amp; asSubTypeName, string&amp;amp; asImageName, float afAmount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds an item to the inventory of the player. Note that the item does not have to exist as entity in the world to be able to do this.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asType ''- item type to give, Available types are: &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Puzzle&lt;br /&gt;
*Lantern&lt;br /&gt;
*Health&lt;br /&gt;
*Sanity&lt;br /&gt;
*LampOil&lt;br /&gt;
*Tinderbox&lt;br /&gt;
&lt;br /&gt;
''asSubTypeName ''- item name for .lang file &amp;lt;br /&amp;gt;''asImageName ''- the image which will appear in inventory. For example: &amp;lt;code&amp;gt;void GiveItem(&amp;quot;chemical_container_full_1&amp;quot;, &amp;quot;Puzzle&amp;quot;, &amp;quot;chemical_container_full&amp;quot;, &amp;quot;chemical_container_full.tga&amp;quot;, 1);&amp;lt;/code&amp;gt; will use the image from &amp;lt;code&amp;gt;graphics/item/chemical_container_full.tga&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount the item gives, - For example: Oil potions will fill the oil meter by this amount, Health potions will heal by this amount, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveItem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an item from the player's inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool HasItem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the player has an item in his inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveItemFromFile(string&amp;amp; asName, string&amp;amp; asFileName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a single item to the player's inventory. This is meant to be used for debug mostly as it creates the actual item and then destroys it.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asFileName ''- item to give + extension (.ent)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddCombineCallback(string&amp;amp; asName, string&amp;amp; asItemA, string&amp;amp; asItemB, string&amp;amp; asFunction, bool abAutoRemove);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to combine items in his inventory. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asItemA, string &amp;amp;in asItemB)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name for the callback &amp;lt;br /&amp;gt;''asItemA ''- internal name of first item &amp;lt;br /&amp;gt;''asItemB ''- internal name of second item &amp;lt;br /&amp;gt;''asFunction ''- the function to call &amp;lt;br /&amp;gt;''abAutoRemove ''- determines whether the callback should be removed when the items are combined&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveCombineCallback(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes a combine callback. &amp;lt;br /&amp;gt;''asName''  - the internal name of the callback to be removed (as specified in AddCombineCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddUseItemCallback(string&amp;amp; asName, string&amp;amp; asItem, string&amp;amp; asEntity, string&amp;amp; asFunction, bool abAutoDestroy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to use items on the world. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asItem, string &amp;amp;in asEntity)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asItem ''- internal name of the item &amp;lt;br /&amp;gt;''asEntity ''- entity to be able to use the item on &amp;lt;br /&amp;gt;''asFunction ''- function to call &amp;lt;br /&amp;gt;''abAutoDestroy ''- determines whether the item is destroyed when used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveUseItemCallback(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an item callback.&lt;br /&gt;
&lt;br /&gt;
===Entities===&lt;br /&gt;
&lt;br /&gt;
====General====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityActive(string&amp;amp; asName, bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates an entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityVisible(string &amp;amp;in asName, bool abVisible);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates an entity's visual mesh. The collision body remains.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity. &amp;lt;br /&amp;gt;''abActive''  - Activate/deactivate mesh.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntityExists(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether an entity exists.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityCustomFocusCrossHair(string&amp;amp; asName, string&amp;amp; asCrossHair);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the crosshair that is used when focusing an entity.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCrossHair ''- desired crosshair, can be: Default (uses default), Grab, Push, Ignite, Pick, LevelDoor, Ladder&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void CreateEntityAtArea(string&amp;amp; asEntityName, string&amp;amp; asEntityFile, string&amp;amp; asAreaName, bool abFullGameSave);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates an entity at an area. When creating an enemy though, it cannot chase properly along PathNodes(using for example ShowEnemyPlayerPosition).&lt;br /&gt;
&lt;br /&gt;
''asEntityName ''- internal name &amp;lt;br /&amp;gt;''asEntityFile ''- entity to be used extension .ent &amp;lt;br /&amp;gt;''asAreaName ''- the area to create the entity at &amp;lt;br /&amp;gt;''abFullGameSave ''- determines whether an entity &amp;quot;remembers&amp;quot; its state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ReplaceEntity(string &amp;amp;in asName, string &amp;amp;in asBodyName, string &amp;amp;in asNewEntityName, string &amp;amp;in asNewEntityFile, bool abFullGameSave);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Removes an entity and places a new one in its place.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to replace. &amp;lt;br /&amp;gt;''asBodyName''  - Name of the body of the entity to place the new entity at. If empty the first body is used (might be buggy, recommended to name a body anyway). &amp;lt;br /&amp;gt;''asNewEntityName''  - Name of the new entity. &amp;lt;br /&amp;gt;''asNewEntityFile''  - Name of the new entity file. Extension .ent. &amp;lt;br /&amp;gt;''abFullGameSave''  - Whether ALL properties of this entity should be saved throughout levels.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlaceEntityAtEntity(string &amp;amp;in asName, string &amp;amp;in asTargetEntity, string &amp;amp;in asTargetBodyName, bool abUseRotation);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Places an entity at the position of another entity. Does not work for enemies, use TeleportEnemyToEntity instead.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to place. &amp;lt;br /&amp;gt;''asTargetEntity''  - Name of the other entity to place the first entity at. &amp;lt;br /&amp;gt;''asTargetBodyName''  - Name of the body of the entity to place the first entity at. If empty the first body is used (might be buggy, recommended to name a body anyway). &amp;lt;br /&amp;gt;''abUseRotation''  - Whether the entity should be rotated like the target entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPos(string &amp;amp;in asName, float afX, float afY, float afZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Moves an entity to a position in the level.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to move. &amp;lt;br /&amp;gt;''afX''  - X co-ordinate position. &amp;lt;br /&amp;gt;''afY''  - Y co-ordinate position. &amp;lt;br /&amp;gt;''afZ''  - Z co-ordinate position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
float GetEntityPosX(string &amp;amp;in asName);&lt;br /&gt;
float GetEntityPosY(string &amp;amp;in asName);&lt;br /&gt;
float GetEntityPosZ(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns an entity's position in the level on the specified axis.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPlayerLookAtCallback(string&amp;amp; asName, string&amp;amp; asCallback, bool abRemoveWhenLookedAt);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player looks at a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: 1 = looking, -1 = not looking&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCallback ''- function to call &amp;lt;br /&amp;gt;''abRemoveWhenLookedAt ''- determines whether the callback should be removed when the player looked at the entity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPlayerInteractCallback(string&amp;amp; asName, string&amp;amp; asCallback, bool abRemoveOnInteraction);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player interacts with a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCallback ''- function to call &amp;lt;br /&amp;gt;''abRemoveOnInteraction ''- determines whether the callback should be removed when the player interacts with the entity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityCallbackFunc(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player interacts with a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, string &amp;amp;in type)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;Type depends on entity type and includes: &amp;quot;OnPickup&amp;quot;, &amp;quot;Break&amp;quot;, &amp;quot;OnIgnite&amp;quot;, etc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityConnectionStateChangeCallback(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A callback called when ever the connection state changes (button being switched on, lever switched, etc). &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void Func(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: -1 = off, 0 = between, 1 = on&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityInteractionDisabled(string&amp;amp; asName, bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disallows interaction with an entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void BreakJoint (string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Breaks a joint. Do not use this on joints in SwingDoors, Levers, Wheels, etc. where the joint is part of an interaction. That will make the game crash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void AddEntityCollideCallback(string&amp;amp; asParentName, string&amp;amp; asChildName, string&amp;amp; asFunction, bool abDeleteOnCollide, int alStates);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when two entites collide. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: 1 = enter, -1 = leave&lt;br /&gt;
&lt;br /&gt;
''asParentName ''- internal name of main object &amp;lt;br /&amp;gt;''asChildName ''- internal name of object that collides with main object (asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) NOT supported!) &amp;lt;br /&amp;gt;''asFunction ''- function to call &amp;lt;br /&amp;gt;''abDeleteOnCollide ''- determines whether the callback after it was called &amp;lt;br /&amp;gt;''alStates ''- 1 = only enter, -1 = only leave, 0 = both&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveEntityCollideCallback(string&amp;amp; asParentName, string&amp;amp; asChildName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an EntityCollideCallback. Asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) not supported in ''asChildName''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntitiesCollide(string&amp;amp; asEntityA, string&amp;amp; asEntityB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether two entites collide. This function does NOT support asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) or &amp;quot;Player&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetBodyMass(string &amp;amp;in asName, float afMass);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Sets the mass of an entity's body.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the body of an entity. The body name of an entity is EntityName_BodyName. &amp;lt;br /&amp;gt;''afMass''  - The mass to set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
float GetBodyMass(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Gets the mass of an entity's body.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the body of an entity. The body name of an entity is EntityName_BodyName. &amp;lt;br /&amp;gt;''afMass''  - The mass to get.&lt;br /&gt;
&lt;br /&gt;
====Props====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropEffectActive(string&amp;amp; asName, bool abActive, bool abFadeAndPlaySounds);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Can be used on coal to give it the black color it should have.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropActiveAndFade(string&amp;amp; asName, bool abActive, float afFadeTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates a prop.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''abActive ''- nothing to add &amp;lt;br /&amp;gt;''afFadeTime ''- time in seconds until prop fully fades&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropStaticPhysics(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates the physics of a prop. Setting as true will make entities static in midair.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetPropIsInteractedWith(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a prop is interacted with.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void RotatePropToSpeed(string&amp;amp; asName, float afAcc, float afGoalSpeed, float afAxisX, float afAxisY, float afAxisZ, bool abResetSpeed, string&amp;amp; asOffsetArea);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rotates the prop up to a set speed.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afAcc ''- acceleration &amp;lt;br /&amp;gt;''afGoalSpeed ''- desired speed &amp;lt;br /&amp;gt;''afAxisX ''- rotation around X axis &amp;lt;br /&amp;gt;''afAxisY ''- rotation around Y axis &amp;lt;br /&amp;gt;''afAxisZ ''- rotation around Z axis &amp;lt;br /&amp;gt;''abResetSpeed ''- determines whether the speed is resetted after goal speed is reached &amp;lt;br /&amp;gt;''asOffsetArea ''- the area to rotate around, if empty, then the center of the body is used Note: The entity you want to rotate MUST be a &amp;quot;StaticObject&amp;quot; entity!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void StopPropMovement(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops all movement of a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddAttachedPropToProp(string&amp;amp; asPropName, string&amp;amp; asAttachName, string&amp;amp; asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to another prop.&lt;br /&gt;
&lt;br /&gt;
a''sPropName''- the prop to attach another prop at &amp;lt;br /&amp;gt;''asAttachName ''- internal name of the prop that gets attached &amp;lt;br /&amp;gt;''asAttachFile ''- the prop that gets attached extension .ent &amp;lt;br /&amp;gt;''afPosX ''- X position of the attach from the prop &amp;lt;br /&amp;gt;''afPosY ''- Y position of the attach from the prop &amp;lt;br /&amp;gt;''afPosZ ''- Z position of the attach from the prop &amp;lt;br /&amp;gt;''afRotX ''- rotation around X axis of the attach &amp;lt;br /&amp;gt;''afRotY ''- rotation around Y axis of the attach &amp;lt;br /&amp;gt;''afRotZ ''- rotation around ZX axis of the attach Note: for the purposes of &amp;quot;AddEntityCollideCallback&amp;quot;, attached props will not call the callback function if they collide with a &amp;quot;static_object&amp;quot; or a &amp;quot;StaticProp&amp;quot; entity type!&lt;br /&gt;
&lt;br /&gt;
{{bug|''afRotZ '' is used for both the ZX rotation and the Z position of the attached prop. Unwanted rotation can be avoided by using: &amp;lt;br /&amp;gt;''AddAttachedPropToProp(asPropName, asAttachName, asAttachFile, afPosX, afPosY, '''0''', afPosZ, '''90.0f''', afPosZ)''}}&lt;br /&gt;
&lt;br /&gt;
{{bug|Attaching a breakable prop to a physically active prop, and then breaking the attached prop, will cause the game to crash, should the parent object be moved or reset.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToProp(string&amp;amp; asPropName, string&amp;amp; asAttachName, string&amp;amp; asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to another prop. Fixed version of AddAttachedPropToProp.&lt;br /&gt;
&lt;br /&gt;
''asPropName ''- the prop to attach another prop at &amp;lt;br /&amp;gt;''asAttachName ''- internal name of the prop that gets attached &amp;lt;br /&amp;gt;''asAttachFile ''- the prop that gets attached extension .ent &amp;lt;br /&amp;gt;''afPosX ''- X position of the attach from the prop &amp;lt;br /&amp;gt;''afPosY ''- Y position of the attach from the prop &amp;lt;br /&amp;gt;''afPosZ ''- Z position of the attach from the prop &amp;lt;br /&amp;gt;''afRotX ''- rotation around X axis of the attach &amp;lt;br /&amp;gt;''afRotY ''- rotation around Y axis of the attach &amp;lt;br /&amp;gt;''afRotZ ''- rotation around ZX axis of the attach Note: for the purposes of &amp;quot;AddEntityCollideCallback&amp;quot;, attached props will not call the callback function if they collide with a &amp;quot;static_object&amp;quot; or a &amp;quot;StaticProp&amp;quot; entity type!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveAttachedPropFromProp(string&amp;amp; asPropName, string&amp;amp; asAttachName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches a prop from a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropHealth(string&amp;amp; asName, float afHealth);&lt;br /&gt;
void AddPropHealth(string&amp;amp; asName, float afHealth);&lt;br /&gt;
float GetPropHealth(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the health of a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ResetProp(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Resets a prop's state to the original one when the map was loaded.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void PlayPropAnimation(string&amp;amp; asProp, string&amp;amp; asAnimation, float afFadeTime, bool abLoop, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the prop play an animation and calls a function. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asProp)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asProp ''- internal name of the prop &amp;lt;br /&amp;gt;''asAnimation ''- animation to play &amp;lt;br /&amp;gt;''afFadeTime ''- ? &amp;lt;br /&amp;gt;''abLoop ''- determines whether the animation loops &amp;lt;br /&amp;gt;''asCallback ''- function to call&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddPropForce(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddPropImpulse(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddBodyForce(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddBodyImpulse(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These functions push objects. Note that rather high values are needed when applying ''forces''  (on the order of ~100 (weak) to ~10000 (strong)), but not impulses (values less than 10 can be appropriate). Forces are external influences, and will have different effect depending on the mass of the object they are being applied to; impulses disregard mass, and can cause objects to break, as if hit. A &amp;quot;Body&amp;quot; is a physics-related helper object, to which a force or an impulse can be applied. Entities can consist of several bodies, interconnected in various ways (you can create/examine bodies in the model editor).&lt;br /&gt;
&lt;br /&gt;
''asName ''- the object to push; for bodies, use this format: &amp;quot;''entityName''_''bodyName''&amp;quot; &amp;lt;br /&amp;gt;''afX ''- magnitude along the X-axis &amp;lt;br /&amp;gt;''afY ''- magnitude along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- magnitude along the Z-axis &amp;lt;br /&amp;gt;''asCoordSystem ''- determines which coordinate system is used, usually &amp;quot;world&amp;quot; All of these functions are ''additive''  - when called consecutively, for each call, the vectors defined by (afX, afY, afZ) will be added together, and a resultant force/impulse will be calculated ''before''  any physics simulation is applied to the target object.&lt;br /&gt;
&lt;br /&gt;
====Connections====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void InteractConnectPropWithRope(string&amp;amp; asName, string&amp;amp; asPropName, string&amp;amp; asRopeName, bool abInteractOnly, float afSpeedMul, float afToMinSpeed, float afToMaxSpeed, bool abInvert, int alStatesUsed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connects a prop with the movement of a rope (ie. turn wheel to move rope).&lt;br /&gt;
&lt;br /&gt;
''asName ''- connection name &amp;lt;br /&amp;gt;''asPropName ''- name of prop &amp;lt;br /&amp;gt;''asRopeName ''- name of rope &amp;lt;br /&amp;gt;''abInteractOnly ''- ? &amp;lt;br /&amp;gt;''afSpeedMul ''- speed multiplier of how quickly the rope moves &amp;lt;br /&amp;gt;''afToMinSpeed ''- the slowest the rope will move when moving the prop &amp;lt;br /&amp;gt;''afToMaxSpeed ''- the fastest the rope will move when moving the prop &amp;lt;br /&amp;gt;''abInvert ''- whether to invert the direction the rope moves &amp;lt;br /&amp;gt;''alStatesUsed ''- which states of the prop can interact with the rope?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void InteractConnectPropWithMoveObject(string&amp;amp; asName, string&amp;amp; asPropName, string&amp;amp; asMoveObjectName, bool abInteractOnly, bool abInvert, int alStatesUsed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This one should only be used if there must be an exact correspondance to prope &amp;quot;amount&amp;quot; and the moveobject open amount. It is best used for Wheel-door connections!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ConnectEntities(string&amp;amp; asName, string&amp;amp; asMainEntity, string&amp;amp; asConnectEntity, bool abInvertStateSent, int alStatesUsed, string&amp;amp; asCallbackFunc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asConnectionName, string &amp;amp;in asMainEntity, string &amp;amp;in asConnectEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;State is what is sent to connection entity and will be inverted if abInvertStateSent = true!&lt;br /&gt;
&lt;br /&gt;
====Lamps====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLampLit(string&amp;amp; asName, bool abLit, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(Un)lits a lamp.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Name of the lamp &amp;lt;br /&amp;gt;''abLit ''- Set true if you want the lamp to be lit, set to false if you want the lamp to be unlit &amp;lt;br /&amp;gt;''abEffects ''- If you want to have the lamp fade in/out when it gets (un)lit&lt;br /&gt;
&lt;br /&gt;
====Doors====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorLocked(string&amp;amp; asName, bool abLocked, bool abEffects);&lt;br /&gt;
void SetSwingDoorClosed(string&amp;amp; asName, bool abClosed, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Locks/closes a swing door.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GetSwingDoorLocked(string&amp;amp; asName);&lt;br /&gt;
bool GetSwingDoorClosed(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a swing door is locked/closed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorDisableAutoClose(string&amp;amp; asName, bool abDisableAutoClose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deactivates the &amp;quot;auto-close&amp;quot; when a door is nearly closed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetSwingDoorState(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns an integer depending on how far the door is opened. &amp;lt;br /&amp;gt;-1 = angle is close to 0°, 1 = angle is 70% or higher of max, 0 = inbetween -1 and 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLocked(string&amp;amp; asName, bool abLocked);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Locks a level door. Note that level doors are NOT swing doors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLockedSound(string&amp;amp; asName, string&amp;amp; asSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which sound is played when interacting with a locked level door.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLockedText(string&amp;amp; asName, string&amp;amp; asTextCat, string&amp;amp; asTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a message when interacting with a locked level door.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMoveObjectState(string&amp;amp; asName, float afState);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves an object to a certain state.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afState ''- state of the object, 0 = closed, 1 = open, values inbetween (and above, for example, the bridge_metal_vert) are valid too!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMoveObjectStateExt(string&amp;amp; asName, float afState, float afAcc, float afMaxSpeed, float afSlowdownDist, bool abResetSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves an object to a certain state, extended method.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afState ''- state of the object, 0 = closed, 1 = open, values inbetween are valid too! &amp;lt;br /&amp;gt;''afAcc ''- acceleration &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed &amp;lt;br /&amp;gt;''afSlowdownDist ''- Distance to the target state before decceleration occurs. &amp;lt;br /&amp;gt;''abResetSpeed ''- Set to True if the prop's speed should be reset before performing the movement, else the prop will accelerate from it's current speed to afMaxSpeed.&lt;br /&gt;
&lt;br /&gt;
====Levers, wheels and buttons====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropObjectStuckState(string&amp;amp; asName, int alState);&lt;br /&gt;
void SetWheelStuckState(string&amp;amp; asName, int alState, bool abEffects);&lt;br /&gt;
void SetLeverStuckState(string&amp;amp; asName, int alState, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes a prop&amp;lt;nowiki&amp;gt;\&amp;lt;/nowiki&amp;gt;wheel&amp;lt;nowiki&amp;gt;\&amp;lt;/nowiki&amp;gt;lever stuck in a certain state.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''alState ''- 0 = not stuck, 1 = at max, -1 = at min &amp;lt;br /&amp;gt;''abEffects ''- use effects&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetWheelAngle(string&amp;amp; asName, float afAngle, bool abAutoMove);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves a wheel to a certain angle.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afAngle ''- angle &amp;lt;br /&amp;gt;''abAutoMove ''- determines whether the wheel should move on its own&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetWheelInteractionDisablesStuck(string&amp;amp; asName, bool abX);&lt;br /&gt;
void SetLeverInteractionDisablesStuck(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to make a wheel/lever unstuck when interacted with.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetLeverState(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the state of the lever. &amp;lt;br /&amp;gt;0 = not stuck, 1 = at max, -1 = at min&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMultiSliderStuckState(string&amp;amp; asName, int alStuckState, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes a MultiSlider stuck in a certain state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMultiSliderCallback(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when state changes. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetButtonSwitchedOn(string&amp;amp; asName, bool abSwitchedOn, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Sticky areas====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetAllowStickyAreaAttachment(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows entites to stick to a StickyArea.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToStickyArea(string&amp;amp; asAreaName, string&amp;amp; asProp);&lt;br /&gt;
void AttachBodyToStickyArea(string&amp;amp; asAreaName, string&amp;amp; asBody);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop/body to a StickyArea.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void DetachFromStickyArea(string&amp;amp; asAreaName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches everything from a StickyArea.&lt;br /&gt;
&lt;br /&gt;
====Enemies====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNPCAwake(string&amp;amp; asName, bool abAwake, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates the npc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNPCFollowPlayer(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets an NPC's head to follow the player's movement's.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDisabled(string&amp;amp; asName, bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables an enemy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyIsHallucination(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes an enemy a hallucination. Hallucinations fade to smoke when they get near the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void FadeEnemyToSmoke(string&amp;amp; asName, bool abPlaySound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instantly fades an enemy to smoke.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ShowEnemyPlayerPosition(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the enemy run to the player, no matter where he is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AlertEnemyOfPlayerPresence(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Gives the specified enemy the player's current position and makes it search the area.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDisableTriggers(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables or disables enemy triggers. If disabled, enemy will not react to player or attack.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddEnemyPatrolNode(string&amp;amp; asName, string&amp;amp; asNodeName, float afWaitTime, string&amp;amp; asAnimation);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a patrol node to the enemy's path.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name of the enemy &amp;lt;br /&amp;gt;''asNodeName ''- path node &amp;lt;br /&amp;gt;''afWaitTime ''- time in seconds that the enemy waits at the path node before continuing &amp;lt;br /&amp;gt;''asAnimation ''- the animation the enemy uses when reaching the path node&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearEnemyPatrolNodes(string&amp;amp; asEnemyName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clears the current path of patrol nodes of the enemy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemySanityDecreaseActive(string &amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether an enemy activates the player's sanity drain when stared at.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX ''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportEnemyToNode(string &amp;amp;in asEnemyName, string &amp;amp;in asNodeName, bool abChangeY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Teleports an enemy to a specific PathNode.&lt;br /&gt;
&lt;br /&gt;
''asEnemyName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asNodeName ''- Internal name of the node to teleport to &amp;lt;br /&amp;gt;''abChangeY ''- Whether the Y position of the node will be used when teleporting the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportEnemyToEntity(string &amp;amp;in asEnemyName, string &amp;amp;in asTargetEntity, string &amp;amp;in asTargetBody, bool abChangeY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Teleports an enemy to a specific entity.&lt;br /&gt;
&lt;br /&gt;
''asEnemyName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asTargetEntity ''- Internal name of the entity to teleport to &amp;lt;br /&amp;gt;''asTargetBody''- Internal name of the entity's body name to teleport to. If empty, the first body will be used (might be unstable, recommended to input a body anyway) &amp;lt;br /&amp;gt;''abChangeY ''- Whether the Y position of the node will be used when teleporting the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeManPigPose(string&amp;amp;in asName, string&amp;amp;in asPoseType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Changes the pose a specified ManPig.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asPoseType''- Name of the ManPig pose to use. Can be &amp;quot;Biped&amp;quot; or &amp;quot;Quadruped&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigFadeDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should fade the player's view in and out.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigSoundDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should play the proximity sounds.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigEasyEscapeDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should be easier to escape from when hunted.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ForceTeslaPigSighting(string&amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Forces a TeslaPig to be visible for a short time.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
string&amp;amp; GetEnemyStateName(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the name of the state a specified enemy is current in. States can be Hunt, Search, Patrol, Wait, Alert, Investigate, Track and BreakDoor.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6681</id>
		<title>HPL2/Tutorials/ShowScreenImage()</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6681"/>
		<updated>2024-01-04T17:11:23Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
ATDD version 1.5 added the ShowScreenImage() function, which was previously available in AAMFP. Some of the workings of this function are a little counter-intuitive, so the purpose of this page is to explain it a little. This is based off of the author's experiments in ATDD 1.5, so it's not definitive! It's also assumed that these notes apply to AAMFP in the same way, but that has not been tested.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Function=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen.&lt;br /&gt;
&lt;br /&gt;
# ''asImageName'' - The image file to render (.jpg, .png, .tga, .dds) (see Size)&lt;br /&gt;
# ''afX'' - The X position of the image (see Placement)&lt;br /&gt;
# ''afY'' - The Y position of the image (see Placement)&lt;br /&gt;
# ''afScale'' - The size of the image in pixels, or original image size if negative (see Size) &lt;br /&gt;
# ''abUseRelativeCoordinates'' - If true, X and Y represent a fraction of the entire screen resoltion, otherwise they are pixel co-ordinates (see Placement)&lt;br /&gt;
# ''afDuration'' - The duration, in seconds, that the image is displayed for (see Timing)&lt;br /&gt;
# ''afFadeIn'' - The time, in seconds, to fade in the image (see Timing)&lt;br /&gt;
# ''afFadeOut'' - The time, in seconds, to fade out the image (see Timing)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Size=&lt;br /&gt;
* Note that the ''afScale'' argument is ''not'' actually the scale of the image: it is the ''size in pixels''. This is not relative and does not take the screen resolution into account, so an image will appear bigger or smaller at lower or higher resolutions respectively.&lt;br /&gt;
* If the size is specified, the image will be rendered onscreen as a square quad, even if the image file is non square. So if the desired effect is to display a non-square image, it will need to be padded out with transparent pixels in order to make it render without distortion.&lt;br /&gt;
* If the size is given as -1 (or any number less than 0) then the actual pixel size and shape of the image file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Placement=&lt;br /&gt;
* The origin of the screen-space is the centre. This means that [0, 0] is the centre of the screen regardless of screen resolution, and regardless of ''abUseRelativeCoordinates''.&lt;br /&gt;
* The origin of the image-space is the top-left. This means that the co-ordinates define where the top-left corner of the image will go.&lt;br /&gt;
* If ''abUseRelativeCoordinates'' is ''false'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as actual pixels''.&lt;br /&gt;
* If ''abUseRelativeCoordinates'' is ''true'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as a fraction of the screen resolution width or height''.&lt;br /&gt;
* The relative co-ordinates still use the centre of the screen as the origin, so the top-left corner of the screen is [-0.5, -0.5] and the bottom-right corner is [0.5, 0.5]. Any relative co-ordinate greater than 0.5 will put the image outside of the screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Timing=&lt;br /&gt;
* The total time that the image will be displayed is ''afFadeIn'' + ''afDuration'' + ''afFadeOut''.&lt;br /&gt;
* ''afDuration'' counts from when the fade in is finished. ''afFadeOut'' counts from when ''afDuration'' is finished. &lt;br /&gt;
* Calling ShowScreenImage() again will replace the current image, regardless of duration or fade times.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
// Centred:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -150.0f, -150.0f, 300.0f, false, 3.0f, 0.0f, 0.0f);&lt;br /&gt;
// Size: 300 x 300 pixels&lt;br /&gt;
// Placement: centred on the screen (image-origin is placed image-size/2 from the screen-origin)&lt;br /&gt;
// Timing: 3 seconds, no fading&lt;br /&gt;
&lt;br /&gt;
// From top-left:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.45f, -0.45f, -1.0f, true, 2.0f, 1.0f, 2.0f);&lt;br /&gt;
// Size: original pixel size and shape of the image file&lt;br /&gt;
// Placement: near the top-left corner, with a 5% margin relative to the screen size&lt;br /&gt;
// Timing: 5 seconds, including fading&lt;br /&gt;
&lt;br /&gt;
// From top-centre:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.48f, 0.0f, 100.0f, true, 0.0f, 2.0f, 2.0f);&lt;br /&gt;
// Size: 100 x 100 pixels&lt;br /&gt;
// Placement: near the top-centre, with a 2% margin relative to the screen size&lt;br /&gt;
// Timing: 4 seconds, fading out immediately after fading in&lt;br /&gt;
&lt;br /&gt;
// Bottom-right - not reliable&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, 0.25f, 0.25f, 270.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a screen resolution of 1920 x 1080, this would fit neatly into the bottom-right 1/16 of the screen (1080 / 4 = 270).&lt;br /&gt;
// Unfortunately, if the resolution was lower, it would not fit on the screen. And if the resolution was higher, it would not reach the edges.&lt;br /&gt;
&lt;br /&gt;
// Full-screen kinda... top-left focussed&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.5f, -0.5f, 3840.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a 4k screen resolution of 3840 x 2160, this would fit the full screen.&lt;br /&gt;
// The centre of the image would be at the centre of the screen at 4k, but would move towards the bottom left with lower resolutions.&lt;br /&gt;
// At lower resolutions the right and bottom of the image would be cropped. At higher resolutions it would not fill the screen.&lt;br /&gt;
&lt;br /&gt;
// Full-screen kinda... centre focussed&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.5f, -0.5f, 3840.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a 4k screen resolution of 3840 x 2160, this would fit the full screen.&lt;br /&gt;
// The centre of the image would stay on the centre of the screen, whatever the resolution.&lt;br /&gt;
// At lower resolutions all the edges would be cropped. At higher resolutions it would not fill the screen.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
There are lots of things you can do with ShowScreenImage() if you use it creatively!&lt;br /&gt;
&lt;br /&gt;
...But if you need to place an image relative the the right-hand edge or bottom of the screen, or relative to the screen resolution, it might be tricky, and might not be future-proof.&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Engine_Scripts&amp;diff=6682</id>
		<title>HPL2/Engine Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Engine_Scripts&amp;diff=6682"/>
		<updated>2024-01-04T17:11:05Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
&lt;br /&gt;
This page documents all scripts available in Amnesia: The Dark Descent.&lt;br /&gt;
&lt;br /&gt;
{{note|'''Note''': Some of the functions require the Amnesia 1.3 or 1.5 update. Steam and other online store copies should be automatically updated. Other copies can get 1.3 [http://www.frictionalgames.com/forum/thread-24334.html here].}}&lt;br /&gt;
&lt;br /&gt;
== Directives ==&lt;br /&gt;
&lt;br /&gt;
First off, &amp;lt;code&amp;gt;#include &amp;quot;file.hps&amp;quot;&amp;lt;/code&amp;gt; can be used to programmatically merge together multiple separate files to make organizing scripts easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
==Engine scripts==&lt;br /&gt;
===Main===&lt;br /&gt;
&lt;br /&gt;
The following functions are the main hps functions that the HPL2 engine looks to run on certain events - similar to the C++ int main() function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void OnStart();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs when the map is loaded for the first time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnEnter();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs whenever the player enters a map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnLeave();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs when the player leaves a map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnGameStart();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function is found in the global.hps file and the inventory.hps file, and is run when the game is first started by the player (ie via &amp;quot;Start New Game&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnUpdate(float afStep);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
This function is executed for every game update or &amp;quot;tick&amp;quot;. Can be used for rapid-firing updates instead of looping timers. Keep in mind that this can affect game performance if not used with care.&lt;br /&gt;
&lt;br /&gt;
#''afStep''- time elapsed since the last frame. Multiply speeds, distances etc. by this argument to avoid framerate dependence issues (for example: if you move something in this function with constant speed, it will move faster on computers which run the game with high FPS and slower on computers with low FPS).&lt;br /&gt;
&lt;br /&gt;
===General===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float RandFloat(float afMin, float afMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generates a random float.&lt;br /&gt;
&lt;br /&gt;
#''afMin ''- minimum value&lt;br /&gt;
#''afMax ''- maximum value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
int RandInt(int alMin, int alMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generates a random int. Note: the maximum value is ''inclusive''  - the RandInt() function may return this value.&lt;br /&gt;
&lt;br /&gt;
#''alMin ''- minimum value&lt;br /&gt;
#''alMax ''- maximum value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool StringContains(string&amp;amp; asString, string&amp;amp; asSubString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a string contains the specified string. &amp;lt;br /&amp;gt;Example: searching for &amp;quot;hello&amp;quot; in &amp;quot;hello world&amp;quot; would return '''true'''.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string to check&lt;br /&gt;
#''asSubString ''- the string to search for&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string&amp;amp; StringSub(string&amp;amp; asString, int alStart, int alCount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the substring in a string. &amp;lt;br /&amp;gt;Example: in the string &amp;quot;frictional games rocks&amp;quot;, using 4 as ''alStart''  and 6 as ''alCount''  would return '''&amp;quot;tional&amp;quot;'''.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string&lt;br /&gt;
#''alStart ''- start position in the string&lt;br /&gt;
#''alCount ''- amount of characters&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
int StringToInt(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns an integer converted from a string, else returns 0.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float StringToFloat(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns a float converted from a string, else returns 0.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool StringToBool(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns a boolean converted from a string, else returns false.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&lt;br /&gt;
===Mathematical Operations===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathSin(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the sine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathCos(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the cosine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathTan(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the tangent of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAsin(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc sine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAcos(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc cosine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAtan(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc tangent of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAtan2(float afX, float afY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Calculates and returns the arc tangent of the specified values.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - First value to operate.&lt;br /&gt;
#''afY''  - Second value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathSqrt(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the square root of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathPow(float afBase, float afExp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the value of afBase raised to the power of afExp.&lt;br /&gt;
&lt;br /&gt;
#''afBase''  - The base value.&lt;br /&gt;
#''afExp''  - Value to calculate the base with.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathMin(float afA, float afB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the lowest value.&lt;br /&gt;
&lt;br /&gt;
#''afA''  - First value.&lt;br /&gt;
#''afB''  - Second value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathMax(float afA, float afB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the highest value.&lt;br /&gt;
&lt;br /&gt;
#''afA''  - First value.&lt;br /&gt;
#''afB''  - Second value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathClamp(float afX, float afMin, float afMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns afX clamped between afMin and afMax. If afX &amp;lt; afMin, returns afMin, and if afX &amp;gt; afMax, returns afMax.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - The value to clamp.&lt;br /&gt;
#''afMin''  - The minimum value to clamp afX with.&lt;br /&gt;
#''afMax''  - The maximum value to clamp afX with.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAbs(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the absolute value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Print(string&amp;amp; asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints a string to the log file (''hpl.log'').&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddDebugMessage(string&amp;amp; asString, bool abCheckForDuplicates);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints a string to the debug console.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string to print&lt;br /&gt;
#''abCheckForDuplicates ''- if true, the string won't be printed more than once on screen until it disappears&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ProgLog(string&amp;amp; asLevel, string&amp;amp; asMessage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints an entry to the ProgLog (progression log). &amp;lt;br /&amp;gt;ProgLog is a file created in Documents/Amnesia/main (or an FC folder if one is being used). It logs certain events, such us opening the menu or picking up the lantern, as well as the player's state (Health, Sanity, Oil, Tinderboxes, Coins), for the purpose of documenting a tester's playstyle. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;This function allows to log custom messages.The messages in the ProgLog file are sorted by time elapsed since a map was loaded.&lt;br /&gt;
&lt;br /&gt;
ProgLog has to be enabled for a player profile in ''user_settings.cfg''  before it starts working.&lt;br /&gt;
&lt;br /&gt;
#''asLevel ''- can be &amp;quot;Low&amp;quot;, &amp;quot;Medium&amp;quot; or &amp;quot;High&amp;quot;. It's a tag which appears in each log entry, for event prioritising.&lt;br /&gt;
#''asMessage ''- The custom message to be printed to the log.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool ScriptDebugOn();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the debug mode is enabled. &amp;lt;br /&amp;gt;See [[HPL2/Development_Environment|&amp;quot;Setting up Development Environment&amp;quot;]] to setup debug mode on your own computer.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
{{warning|Regular variables (int, float, etc.) are '''not''' saved by the game. Using them in important parts of yor script will break it upon loading a game save. In HPL, those variables should only be used for disposable counters, like spawning objects in a &amp;quot;for&amp;quot; loop. For variables which need to be saved, use the wrappers as described below.}}&lt;br /&gt;
&lt;br /&gt;
====Local====&lt;br /&gt;
&lt;br /&gt;
Local variables can be used throughout the same script file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
void AddLocalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
int GetLocalVarInt(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
void AddLocalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
float GetLocalVarFloat(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarString(string&amp;amp; asName, const string&amp;amp; asVal);&lt;br /&gt;
void AddLocalVarString(string&amp;amp; asName, string&amp;amp; asVal);&lt;br /&gt;
string&amp;amp; GetLocalVarString(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Global====&lt;br /&gt;
&lt;br /&gt;
Global variables can be used throughout several maps and can be accessed by several script files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
void AddGlobalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
int GetGlobalVarInt(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
void AddGlobalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
float GetGlobalVarFloat(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarString(string&amp;amp; asName, const string&amp;amp; asVal);&lt;br /&gt;
void AddGlobalVarString(string&amp;amp; asName, string&amp;amp; asVal);&lt;br /&gt;
string&amp;amp; GetGlobalVarString(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Particle Systems===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PreloadParticleSystem(string&amp;amp; asPSFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Preloads a particle system.&lt;br /&gt;
&lt;br /&gt;
#''asPSFile''  - The particle system file to load. Extension: .ps&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateParticleSystemAtEntity(string&amp;amp; asPSName, string&amp;amp; asPSFile, string&amp;amp; asEntity, bool abSavePS);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a particle system on an entity.&lt;br /&gt;
&lt;br /&gt;
#''asPSName ''- internal name&lt;br /&gt;
#''asPSFile ''- the particle system to use + extension .ps&lt;br /&gt;
#''asEntity ''- the entity to create the particle system at&lt;br /&gt;
#''abSavePS ''- determines whether a particle system should &amp;quot;remember&amp;quot; its shown/hidden state, so that this state can be restored when the player revisits the level&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateParticleSystemAtEntityExt(string&amp;amp; asPSName, string&amp;amp; asPSFile, string&amp;amp; asEntity, bool abSavePS,&lt;br /&gt;
float afR, float afG, float afB, float afA, bool abFadeAtDistance, float afFadeMinEnd, float afFadeMinStart,&lt;br /&gt;
float afFadeMaxStart, float afFadeMaxEnd);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a particle system on an entity, extended method with more options.&lt;br /&gt;
&lt;br /&gt;
#''asPSName ''- internal name&lt;br /&gt;
#''asPSFile ''- the particle system to use + extension .ps&lt;br /&gt;
#''asEntity ''- the entity to create the particle system at&lt;br /&gt;
#''abSavePS ''- determines whether a particle system should &amp;quot;remember&amp;quot; its shown/hidden state, so that this state can be restored when the player revisits the level&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
#''abFadeAtDistance ''- determines whether a particle system fades from a certain distance on&lt;br /&gt;
#''afFadeMinEnd ''- minimum distance at which the particle system stops fading&lt;br /&gt;
#''afFadeMinStart ''- minimum distance at which the particle system starts fading&lt;br /&gt;
#''afFadeMaxStart ''- maximum distance at which the particle system starts fading&lt;br /&gt;
#''afFadeMaxEnd ''- maximum distance at which the particle system stops fading&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DestroyParticleSystem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Destroys a particle system.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - The internal name of the particle system&lt;br /&gt;
&lt;br /&gt;
===Sounds &amp;amp; Music===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PreloadSound(string&amp;amp; asSoundFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Preloads a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundFile''  - The sound file to load. Extension: .snt&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlaySoundAtEntity(string&amp;amp; asSoundName, string&amp;amp; asSoundFile, string&amp;amp; asEntity, float afFadeTime, bool abSaveSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a sound on an entity.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''asSoundFile ''- the sound to use + extension .snt&lt;br /&gt;
#''asEntity ''- the entity to create the sound at, can be &amp;quot;Player&amp;quot;&lt;br /&gt;
#''afFadeTime ''- time in seconds the sound needs to fade. Avoids enemies hearing the sound if afFadeTime is at least 0.1f&lt;br /&gt;
#''abSaveSound ''- if ''true'', a looping sound will &amp;quot;remember&amp;quot; its playback state (currently playing/stopped), and that state will be restored the next time the level is entered. If ''true'', the sound is never attached to the entity! Note that saving should only be used on ''looping sounds''!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeInSound(string&amp;amp; asSoundName, float afFadeTime, bool abPlayStart);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades in a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''afFadeTime ''- time in seconds&lt;br /&gt;
#''abPlayStart ''- ?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopSound(string&amp;amp; asSoundName, float afFadeTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades out a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''afFadeTime ''- time in seconds, use 0 to immediatly stop the sound&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayMusic(string&amp;amp; asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays music.&lt;br /&gt;
&lt;br /&gt;
#''asMusicFile ''- the music to play + extension .ogg&lt;br /&gt;
#''abLoop ''- determines whether a music track should loop&lt;br /&gt;
#''afVolume ''- volume of the music&lt;br /&gt;
#''afFadeTime ''- time in seconds until music reaches full volume&lt;br /&gt;
#''alPrio ''- priority of the music. Note that only the music with the highest priority can be heard! 0 - lowest, 1 - higher, etc.&lt;br /&gt;
#''abResume''  - if ''true'', playback will be continued from where the track stopped after the call to StopMusic(); if ''false'', the track will be restarted.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopMusic(float afFadeTime, int alPrio);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops music.&lt;br /&gt;
&lt;br /&gt;
#''afFadeTime ''- time in seconds until music stops&lt;br /&gt;
#''alPrio ''- the priority of the music that should stop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeGlobalSoundVolume(float afDestVolume, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Influences the global sound volume, that means everything you can hear '''from the world'''. This does not affect music of GUI sounds.&lt;br /&gt;
&lt;br /&gt;
#''afDestVolume ''- desired volume&lt;br /&gt;
#''afTime ''- time in seconds until volume reaches desired volume&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeGlobalSoundSpeed(float afDestSpeed, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Influences the global sound speed.&lt;br /&gt;
&lt;br /&gt;
#''afDestSpeed ''- desired speed&lt;br /&gt;
#''afTime ''- time in seconds until volume reaches desired speed&lt;br /&gt;
&lt;br /&gt;
===Lights===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLightVisible(string&amp;amp; asLightName, bool abVisible);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/disables lights.&lt;br /&gt;
&lt;br /&gt;
#''asLightName ''- internal name&lt;br /&gt;
#''abVisible ''- determines the state of the light&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeLightTo(string&amp;amp; asLightName, float afR, float afG, float afB, float afA, float afRadius, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the properties of a light.&lt;br /&gt;
&lt;br /&gt;
#''asLightName ''- internal name&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
#''afRadius ''- radius of the light. -1 means keeping the radius&lt;br /&gt;
#''afTime ''- time in seconds until change is done&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLightFlickerActive(string&amp;amp; asLightName, bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates flickering on a light.&lt;br /&gt;
&lt;br /&gt;
#''asLightName''  - The internal light name&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&lt;br /&gt;
==Game scripts==&lt;br /&gt;
&lt;br /&gt;
===General===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartCredits(string&amp;amp; asMusic, bool abLoopMusic, string&amp;amp; asTextCat, string&amp;amp; asTextEntry, int alEndNum);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the end credits screen.&lt;br /&gt;
&lt;br /&gt;
#''asMusic ''- the music to play (including .ogg)&lt;br /&gt;
#''abLoopMusic ''- determines whether the music should loop&lt;br /&gt;
#''asTextCat ''- the category to be used in the .lang file&lt;br /&gt;
#''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
#''alEndNum ''- Amnesia has 3 different endings and displays a code at the bottom. Determines which code is displayed. 0-2 will display codes, any other integer will not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartDemoEnd();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the end images that are used in the demo, images are named &amp;quot;demo_end01.jpg&amp;quot;, increase the number for each image you want to use. (NEEDS VERIFICATION)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AutoSave();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the game to the auto save.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CheckPoint (string&amp;amp; asName, string&amp;amp; asStartPos, string&amp;amp; asCallback, string&amp;amp; asDeathHintCat, string&amp;amp; asDeathHintEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets a checkpoint at which the player will respawn in case he dies. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asName, int alCount)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;Count is 0 on the first checkpoint load!&lt;br /&gt;
&lt;br /&gt;
#''asName ''- the internal name&lt;br /&gt;
#''asStartPos ''- the name of the StartPos in the editor&lt;br /&gt;
#''asCallback ''- the function to call when the player dies/respawns&lt;br /&gt;
#''asDeathHintCat ''- the category of the death hint message to be used in the .lang file&lt;br /&gt;
#''asDeathHintEntry ''- the entry in the .lang file&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeMap(string&amp;amp; asMapName, string&amp;amp; asStartPos, string&amp;amp; asStartSound, string&amp;amp; asEndSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Immediatly loads another map.&lt;br /&gt;
&lt;br /&gt;
#''asMapName ''- the file to load&lt;br /&gt;
#''asStartPos ''- the name of the StartPos on the next map&lt;br /&gt;
#''asStartSound ''- the sound that is played when the change starts&lt;br /&gt;
#''asEndSound ''- the sound that is played when the new map is loaded&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ClearSavedMaps();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clears the &amp;quot;history&amp;quot; of the save, useful to do when you know the player will not be able to go back anymore. Makes the next save much smaller in size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateDataCache();&lt;br /&gt;
void DestroyDataCache();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This caches all current textures and models and they are not released until destroy is called. If there is already cached data it is destroyed.&lt;br /&gt;
Create caches to enable faster loading when going back to a map. Destroy the cache if you know the player won't go back to that map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetMapDisplayNameEntry(string&amp;amp; asNameEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the map name shown in save file names. If none is set NULL is assumed.&lt;br /&gt;
&lt;br /&gt;
#''asNameEntry ''- the entry to display, category must be &amp;quot;Levels&amp;quot;!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the skybox.&lt;br /&gt;
&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxTexture(string&amp;amp; asTexture);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the texture of the skybox.&lt;br /&gt;
&lt;br /&gt;
#''asTexture''  - The texture file to set. Extension: .dds&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxColor(float afR, float afG, float afB, float afA);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the solid color of the skybox rather than a texture.&lt;br /&gt;
&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the global fog.&lt;br /&gt;
&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogColor(float afR, float afG, float afB, float afA);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the color to use for the global fog.&lt;br /&gt;
&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogProperties(float afStart, float afEnd, float afFalloffExp, bool abCulling);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the properties for the global fog.&lt;br /&gt;
&lt;br /&gt;
#''afStart ''- how many meters from the camera should the fog begin&lt;br /&gt;
#''afEnd ''- how many meters from the camera should the fog reach full thickness&lt;br /&gt;
#''afFalloffExp ''- the amount by which the thinkness increases&lt;br /&gt;
#''abCulling ''- whether occlusion culling is active for the fog; this prevents objects behind the fog from being loaded&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetupLoadScreen(string&amp;amp;asTextCat, string&amp;amp;asTextEntry, int alRandomNum, string&amp;amp;asImageFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which loading screen will be shown when changing maps.&lt;br /&gt;
&lt;br /&gt;
#''asTextCat ''- the category of the loading text in the .lang file to be shown on the loading screen&lt;br /&gt;
#''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
#''alRandomNum ''- if greater 1, then it will randomize between 1 and alRandom for each LoadScreen giving entry the suffix XX (eg 01). If &amp;lt; =1 then no suffix is added&lt;br /&gt;
#''asImageFile ''- the image to be shown (optional)&lt;br /&gt;
&lt;br /&gt;
===Game Timer===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddTimer(string&amp;amp; asName, float afTime, string&amp;amp; asFunction);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a timer which calls a function when it expires. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asTimer)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#''asName ''- the name of the timer&lt;br /&gt;
#''afTime ''- time in seconds&lt;br /&gt;
#''asFunction ''- the function to call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveTimer(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes a timer, no matter how much time is left.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - the internal name of the timer.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetTimerTimeLeft(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the time left on a timer.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - the internal name of the timer.&lt;br /&gt;
&lt;br /&gt;
===Screen Effects===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeOut(float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to black.&lt;br /&gt;
&lt;br /&gt;
''afTime ''- time in seconds until the screen is completly black&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeIn(float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen back to normal.&lt;br /&gt;
&lt;br /&gt;
''afTime ''- time in seconds until the screen back to normal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeImageTrailTo(float afAmount, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applies the image trail effect to the screen.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeSepiaColorTo(float afAmount, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the screen go dark red.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeRadialBlurTo(float afSize, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applies radial blur effects to the screen.&lt;br /&gt;
&lt;br /&gt;
''afSize ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetRadialBlurStartDist(float afStartDist);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines at which distance the radial blur effects appear.&lt;br /&gt;
&lt;br /&gt;
''afStartDist ''- the distance at which the effect starts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartEffectFlash(float afFadeIn, float afWhite, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to white.&lt;br /&gt;
&lt;br /&gt;
''afFadeIn ''- time in seconds until screen is white &amp;lt;br /&amp;gt;''afWhite ''- determines to which percentage the screen fades to white (1.0 = completly white) &amp;lt;br /&amp;gt;''afFadeOut ''- time in seconds until screen is back to normal again&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartEffectEmotionFlash(string&amp;amp; asTextCat, string&amp;amp; asTextEntry, string&amp;amp; asSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to white and shows a text message.&lt;br /&gt;
&lt;br /&gt;
''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the text entry in the .lang file &amp;lt;br /&amp;gt;''asSound ''- the sound to play while fading&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice(string&amp;amp; asVoiceFile, string&amp;amp; asEffectFile, string&amp;amp; asTextCat, string&amp;amp; asTextEntry,&lt;br /&gt;
bool abUsePosition, string&amp;amp; asPosEntity, float afMinDistance, float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This adds a voice and an effect to be played. It is okay to call this many times in order to play many voices in a row. The EffectVoiceOverCallback is not called until ALL voices have finished.&lt;br /&gt;
&lt;br /&gt;
''asVoiceFile ''- the voice to play &amp;lt;br /&amp;gt;''asEffectFile ''- the effect to play &amp;lt;br /&amp;gt;''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the text entry in the .lang file &amp;lt;br /&amp;gt;''abUsePosition ''- plays using 3D from the entity, or without 3D &amp;lt;br /&amp;gt;''asPosEntity ''- the entity at which the effect appears &amp;lt;br /&amp;gt;''afMinDistance ''- minimum distance to see the effect &amp;lt;br /&amp;gt;''afMaxDistance ''- maximum distance to see the effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopAllEffectVoices(float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops all voices and calls the EffectVoiceOverCallback.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEffectVoiceActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether EffectVoices are still active.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEffectVoiceOverCallback(string&amp;amp; asFunc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the function to be called when the EffectVoices are finished. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetFlashbackIsActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a flashback is still in effect.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPlayerSpawnPS(string&amp;amp; asSPSFile);&lt;br /&gt;
void StopPlayerSpawnPS();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuously spawn regular particle systems (''.ps'') around the player. Particles created by this script carry over from map to map. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;''asSPSFile''  - the ''.sps''  file to use. Exemplary ''.sps''  files are located in the ''/misc''  folder in the main game directory. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;Custom ''.sps''  files can be created by hand in a text editor (see existing ones and mimic how those are written). &amp;lt;br /&amp;gt;Since ''StopPlayerSpawnPS()''  doesn't seem to work, to stop an SPS you must create an ''.sps''  file with an empty particle field field and override the old SPS by calling ''StartPlayerSpawnPS''  again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayGuiSound(string&amp;amp; asSoundFile, float afVolume);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays a sound, not using 3D.&lt;br /&gt;
&lt;br /&gt;
''asSoundFile ''- the sound to play (extension is .snt) &amp;lt;br /&amp;gt;''afVolume ''- the volume of the sound&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartScreenShake(float afAmount, float afTime, float afFadeInTime, float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Shakes the screen.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity of the shake &amp;lt;br /&amp;gt;''afTime ''- duration of the shake &amp;lt;br /&amp;gt;''afFadeInTime ''- time in seconds until full intensity is reached &amp;lt;br /&amp;gt;''afFadeOutTime ''- time until screen is back to normal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInDarknessEffectsActive(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables the sanity drain and night vision effects while in the darkness.&lt;br /&gt;
&lt;br /&gt;
''bool abX''  - Enable/disable effects.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen. See [[HPL2/Tutorials/ShowScreenImage()|ShowScreenImage()]] in the tutorials section for more information.&lt;br /&gt;
&lt;br /&gt;
''asImageName'' - The image file to render (.jpg, .png, .tga, .dds)&lt;br /&gt;
&lt;br /&gt;
''afX'' - The X position of the image&lt;br /&gt;
&lt;br /&gt;
''afY'' - The Y position of the image&lt;br /&gt;
&lt;br /&gt;
''afScale'' - The size of the image in pixels (not scale), or original image size if negative&lt;br /&gt;
&lt;br /&gt;
''abUseRelativeCoordinates'' - Whether X and Y are relative to the screen resoltion, or pixel co-ordinates if not&lt;br /&gt;
&lt;br /&gt;
''afDuration'' - The duration that the image is displayed for&lt;br /&gt;
&lt;br /&gt;
''afFadeIn'' - The time, in seconds, to fade in the image&lt;br /&gt;
&lt;br /&gt;
''afFadeOut'' - The time, in seconds, to fade out the image&lt;br /&gt;
&lt;br /&gt;
===Insanity===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInsanitySetEnabled(string&amp;amp; asSet, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which InsanitySets are enabled.&lt;br /&gt;
&lt;br /&gt;
''asSet ''- the set &amp;lt;br /&amp;gt;''abX ''- enabled or not&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartInsanityEvent(string &amp;amp;in asEventName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Starts a specified insanity event.&lt;br /&gt;
&lt;br /&gt;
''asEventName ''- Insanity event to play.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartRandomInsanityEvent();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts a random insanity event from the available sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopCurrentInsanityEvent();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Stops the currently playing insanity event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void InsanityEventIsActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether an insanity event is currently in effect… Or so it was supposed to be, but as it doesn't return a value, we can never know [http://wiki.frictionalgames.com/lib/images/smileys/icon_smile.gif?nolink&amp;amp;15x15]&lt;br /&gt;
&lt;br /&gt;
===Player===&lt;br /&gt;
&lt;br /&gt;
Note that the player's maximum health and sanity is 100.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enabled/Disable player controlled movement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangePlayerStateToNormal();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets certain effects back to normal. It can for example make the player drop an item.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerCrouching(bool abCrouch);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the player to crouch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pushes the player into a certain direction. Note that you need values above ~2000 to see any effects.&lt;br /&gt;
&lt;br /&gt;
''afX ''- amount along the X-axis &amp;lt;br /&amp;gt;''afY ''- amount along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- amount along the Z-axis &amp;lt;br /&amp;gt;''abUseLocalCoords ''- If true, axes are based on where the player is facing, not the world.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowPlayerCrossHairIcons(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the icons when a player has something in focus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerSanity(float afSanity);&lt;br /&gt;
void AddPlayerSanity(float afSanity);&lt;br /&gt;
float GetPlayerSanity();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the sanity of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerHealth(float afHealth);&lt;br /&gt;
void AddPlayerHealth(float afHealth);&lt;br /&gt;
float GetPlayerHealth();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the health of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerLampOil(float afOil);&lt;br /&gt;
void AddPlayerLampOil(float afOil);&lt;br /&gt;
float GetPlayerLampOil();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the lamp oil of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerSpeed();&lt;br /&gt;
float GetPlayerYSpeed();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the current speed of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSanityDrainDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables sanity drain from darkness, monsters, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveSanityBoost();&lt;br /&gt;
void GiveSanityBoostSmall();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Boosts the player's sanity by a fixed amount.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveSanityDamage(float afAmount, bool abUseEffect);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduces the sanity of the player.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount of sanity damage done &amp;lt;br /&amp;gt;''abUseEffect ''- determines whether an effect is played when the sanity damage is dealt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GivePlayerDamage(float afAmount, string&amp;amp; asType, bool abSpinHead, bool abLethal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduces the health of the player.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount of damage done to health &amp;lt;br /&amp;gt;''asType ''- plays a certain effect on the screen when the damage is dealt (BloodSplat, Claws or Slash) &amp;lt;br /&amp;gt;''abSpinHead ''- changes the camera view when damage is dealt &amp;lt;br /&amp;gt;''abLethal ''- set to true if player can die from given damage&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerFOVMulTo(float afX, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the field of view of the player. A shorter FOV will create a zoom effect.&lt;br /&gt;
&lt;br /&gt;
''afX ''- multiplier of default FOV (1 is default) &amp;lt;br /&amp;gt;''afSpeed ''- the speed of change between FOV's&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerAspectMulTo(float afX, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the aspect ratio of the player. Basically stretches or narrows the screen horizontally.&lt;br /&gt;
&lt;br /&gt;
''afX ''- multiplier of default aspect (default is 1) &amp;lt;br /&amp;gt;''afSpeed ''- the speed of change between FOV's&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerRollTo(float afX, float afSpeedMul, float afMaxSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rotates the position of the camera on the player's body.&lt;br /&gt;
&lt;br /&gt;
''afX ''- angle of rotation of head, positive being counter-clockwise &amp;lt;br /&amp;gt;''afSpeedMul ''- speed (possibly acceleration) multiplier of the rotation (default 1, which is really slow) &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed of rotation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void MovePlayerHeadPos(float afX, float afY, float afZ, float afSpeed, float afSlowDownDist);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the position of the camera on the player's body.&lt;br /&gt;
&lt;br /&gt;
''afX ''- amount along the X-axis &amp;lt;br /&amp;gt;''afY ''- amount along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- amount along the Z-axis &amp;lt;br /&amp;gt;''afSpeed ''- speed at which the change happens &amp;lt;br /&amp;gt;''afSlowDownDist ''- distance at which to start slowing down (prevents the head from abruptly stopping)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPlayerLookAt(string&amp;amp; asEntityName, float afSpeedMul, float afMaxSpeed, string&amp;amp; asAtTargetCallback);&lt;br /&gt;
void StopPlayerLookAt();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the player to look at a certain entity until StopPlayerLookAt is used.&lt;br /&gt;
&lt;br /&gt;
''asEntityName ''- the entity to look at &amp;lt;br /&amp;gt;''afSpeedMul ''- how fast should the player look at the entity &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed allowed &amp;lt;br /&amp;gt;''asAtTargetCallback ''- function to call when player looks at target&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerMoveSpeedMul(float afMul);&lt;br /&gt;
void SetPlayerRunSpeedMul(float afMul);&lt;br /&gt;
void SetPlayerLookSpeedMul(float afMul);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the player's move/run/look speed. Default is 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerJumpForceMul(float afMul);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Changes the player's jump multiplier. Higher values = higher jumps. Default is 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerJumpDisabled(bool abX);&lt;br /&gt;
void SetPlayerCrouchDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the player's ability to jump/crouch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportPlayer(string&amp;amp; asStartPosName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instantly teleports the player to the target StartPos.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternActive(bool abX, bool abUseEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the player use his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetLanternActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the player currently uses his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the player's ability to use his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternLitCallback(string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the function to call when the player uses his lantern. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;MyFunc(bool abLit)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetMessage(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a message on the screen.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTime ''- determines how long the message is displayed. If time is &amp;lt; =0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetDeathHint(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the message that appears when the player dies.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DisableDeathStartSound();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the death sound when the player dies. This must be called directly before player is killed! The variable as soon as player dies too.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
void MovePlayerForward(float afAmount)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;REQUIRES THE 1.2 PATCH: JUSTINE&amp;quot; Moves the player forward. It needs to be called in a timer that updates 60 times / second.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerFallDamageDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables the player's ability to take fall damage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerPos(float afX, float afY, float afZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Sets the player's position within the level.&lt;br /&gt;
&lt;br /&gt;
''afX''  - X co-ordinate position. &amp;lt;br /&amp;gt;''afY''  - Y co-ordinate position. &amp;lt;br /&amp;gt;''afZ''  - Z co-ordinate position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerPosX();&lt;br /&gt;
float GetPlayerPosY();&lt;br /&gt;
float GetPlayerPosZ();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the player's position within the level on the specified axis.&lt;br /&gt;
&lt;br /&gt;
===Journal===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddNote(string&amp;amp; asNameAndTextEntry, string&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a note to the player's journal.&lt;br /&gt;
&lt;br /&gt;
''asNameAndTextEntry ''- entries in the .lang file. Must end with _Name and _Text and be in category &amp;quot;Journal&amp;quot;! &amp;lt;br /&amp;gt;''asImage ''- the background image to be used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddDiary(string&amp;amp; asNameAndTextEntry, string&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a diary to the player's journal.&lt;br /&gt;
&lt;br /&gt;
''asNameAndTextEntry ''- entries in the .lang file. Must end with _NameX and _TextY whereas X and Y are numbers of the parts (_Name1: first diary, _Text1: first page) and be in category &amp;quot;Journal&amp;quot;! &amp;lt;br /&amp;gt;''asImage ''- the background image to be used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ReturnOpenJournal(bool abOpenJournal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Only called in the pickup diary callback! If true the journal displays the entry else not.&lt;br /&gt;
&lt;br /&gt;
===Quests===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddQuest(string&amp;amp; asName, string&amp;amp; asNameAndTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a quest to the player's journal under mementos.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name to be used &amp;lt;br /&amp;gt;''asNameAndTextEntry ''- entry in the .lang file. Must start with &amp;quot;Quest_&amp;lt;texthere&amp;gt;_Text”, and be in category “Journal”!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CompleteQuest(string&amp;amp; asName, string&amp;amp; asNameAndTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Completes a quest.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name of the quest &amp;lt;br /&amp;gt;''asNameAndTextEntry ''- entry in the .lang file. Must start with &amp;quot; Quest_&amp;lt;texthere&amp;gt;_Text ”, and be in category “Journal”!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool QuestIsCompleted(string&amp;amp; asName);&lt;br /&gt;
bool QuestIsAdded(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a quest is completed/added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetNumberOfQuestsInMap(int alNumberOfQuests);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the number of quests in the map.&lt;br /&gt;
&lt;br /&gt;
''alNumberOfQuests ''- Amount of Quests&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveHint(string&amp;amp; asName, string&amp;amp; asMessageCat, string&amp;amp; asMessageEntry, float afTimeShown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a hint on the player's screen.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name &amp;lt;br /&amp;gt;''asMessageCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asMessageEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTimeShown ''- time in seconds until the message disappears. If time is &amp;lt;= 0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void BlockHint(string&amp;amp; asName);&lt;br /&gt;
void UnBlockHint(string&amp;amp; asName);&lt;br /&gt;
void RemoveHint(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Blocking a hint prevents it from being shown. Blocked hints are included in savefiles, so they should persist between levels.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Removing&amp;quot; a hint actually removes it from the list of already given hints, thus allowing it to show up again.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name. Basic game hints use the same name as their respective lang entries, with the exception of &amp;quot;numbered&amp;quot; hints. For example, &amp;lt;code&amp;gt;EntityGrab&amp;lt;/code&amp;gt; blocks the &amp;lt;code&amp;gt;EntityGrab01&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;EntityGrab02&amp;lt;/code&amp;gt; entries.&lt;br /&gt;
&lt;br /&gt;
===Inventory===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ExitInventory();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exits the inventory by force.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInventoryDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the player's ability to open his inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInventoryMessage(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a message at the bottom of the inventory screen.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTime ''- time in seconds until the message disappears. If life time is &amp;lt;= 0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveItem(string&amp;amp; asName, string&amp;amp; asType, string&amp;amp; asSubTypeName, string&amp;amp; asImageName, float afAmount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds an item to the inventory of the player. Note that the item does not have to exist as entity in the world to be able to do this.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asType ''- item type to give, Available types are: &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Puzzle&lt;br /&gt;
*Lantern&lt;br /&gt;
*Health&lt;br /&gt;
*Sanity&lt;br /&gt;
*LampOil&lt;br /&gt;
*Tinderbox&lt;br /&gt;
&lt;br /&gt;
''asSubTypeName ''- item name for .lang file &amp;lt;br /&amp;gt;''asImageName ''- the image which will appear in inventory. For example: &amp;lt;code&amp;gt;void GiveItem(&amp;quot;chemical_container_full_1&amp;quot;, &amp;quot;Puzzle&amp;quot;, &amp;quot;chemical_container_full&amp;quot;, &amp;quot;chemical_container_full.tga&amp;quot;, 1);&amp;lt;/code&amp;gt; will use the image from &amp;lt;code&amp;gt;graphics/item/chemical_container_full.tga&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount the item gives, - For example: Oil potions will fill the oil meter by this amount, Health potions will heal by this amount, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveItem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an item from the player's inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool HasItem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the player has an item in his inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveItemFromFile(string&amp;amp; asName, string&amp;amp; asFileName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a single item to the player's inventory. This is meant to be used for debug mostly as it creates the actual item and then destroys it.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asFileName ''- item to give + extension (.ent)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddCombineCallback(string&amp;amp; asName, string&amp;amp; asItemA, string&amp;amp; asItemB, string&amp;amp; asFunction, bool abAutoRemove);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to combine items in his inventory. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asItemA, string &amp;amp;in asItemB)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name for the callback &amp;lt;br /&amp;gt;''asItemA ''- internal name of first item &amp;lt;br /&amp;gt;''asItemB ''- internal name of second item &amp;lt;br /&amp;gt;''asFunction ''- the function to call &amp;lt;br /&amp;gt;''abAutoRemove ''- determines whether the callback should be removed when the items are combined&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveCombineCallback(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes a combine callback. &amp;lt;br /&amp;gt;''asName''  - the internal name of the callback to be removed (as specified in AddCombineCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddUseItemCallback(string&amp;amp; asName, string&amp;amp; asItem, string&amp;amp; asEntity, string&amp;amp; asFunction, bool abAutoDestroy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to use items on the world. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asItem, string &amp;amp;in asEntity)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asItem ''- internal name of the item &amp;lt;br /&amp;gt;''asEntity ''- entity to be able to use the item on &amp;lt;br /&amp;gt;''asFunction ''- function to call &amp;lt;br /&amp;gt;''abAutoDestroy ''- determines whether the item is destroyed when used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveUseItemCallback(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an item callback.&lt;br /&gt;
&lt;br /&gt;
===Entities===&lt;br /&gt;
&lt;br /&gt;
====General====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityActive(string&amp;amp; asName, bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates an entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityVisible(string &amp;amp;in asName, bool abVisible);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates an entity's visual mesh. The collision body remains.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity. &amp;lt;br /&amp;gt;''abActive''  - Activate/deactivate mesh.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntityExists(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether an entity exists.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityCustomFocusCrossHair(string&amp;amp; asName, string&amp;amp; asCrossHair);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the crosshair that is used when focusing an entity.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCrossHair ''- desired crosshair, can be: Default (uses default), Grab, Push, Ignite, Pick, LevelDoor, Ladder&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void CreateEntityAtArea(string&amp;amp; asEntityName, string&amp;amp; asEntityFile, string&amp;amp; asAreaName, bool abFullGameSave);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates an entity at an area. When creating an enemy though, it cannot chase properly along PathNodes(using for example ShowEnemyPlayerPosition).&lt;br /&gt;
&lt;br /&gt;
''asEntityName ''- internal name &amp;lt;br /&amp;gt;''asEntityFile ''- entity to be used extension .ent &amp;lt;br /&amp;gt;''asAreaName ''- the area to create the entity at &amp;lt;br /&amp;gt;''abFullGameSave ''- determines whether an entity &amp;quot;remembers&amp;quot; its state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ReplaceEntity(string &amp;amp;in asName, string &amp;amp;in asBodyName, string &amp;amp;in asNewEntityName, string &amp;amp;in asNewEntityFile, bool abFullGameSave);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Removes an entity and places a new one in its place.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to replace. &amp;lt;br /&amp;gt;''asBodyName''  - Name of the body of the entity to place the new entity at. If empty the first body is used (might be buggy, recommended to name a body anyway). &amp;lt;br /&amp;gt;''asNewEntityName''  - Name of the new entity. &amp;lt;br /&amp;gt;''asNewEntityFile''  - Name of the new entity file. Extension .ent. &amp;lt;br /&amp;gt;''abFullGameSave''  - Whether ALL properties of this entity should be saved throughout levels.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlaceEntityAtEntity(string &amp;amp;in asName, string &amp;amp;in asTargetEntity, string &amp;amp;in asTargetBodyName, bool abUseRotation);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Places an entity at the position of another entity. Does not work for enemies, use TeleportEnemyToEntity instead.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to place. &amp;lt;br /&amp;gt;''asTargetEntity''  - Name of the other entity to place the first entity at. &amp;lt;br /&amp;gt;''asTargetBodyName''  - Name of the body of the entity to place the first entity at. If empty the first body is used (might be buggy, recommended to name a body anyway). &amp;lt;br /&amp;gt;''abUseRotation''  - Whether the entity should be rotated like the target entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPos(string &amp;amp;in asName, float afX, float afY, float afZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Moves an entity to a position in the level.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to move. &amp;lt;br /&amp;gt;''afX''  - X co-ordinate position. &amp;lt;br /&amp;gt;''afY''  - Y co-ordinate position. &amp;lt;br /&amp;gt;''afZ''  - Z co-ordinate position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
float GetEntityPosX(string &amp;amp;in asName);&lt;br /&gt;
float GetEntityPosY(string &amp;amp;in asName);&lt;br /&gt;
float GetEntityPosZ(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns an entity's position in the level on the specified axis.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPlayerLookAtCallback(string&amp;amp; asName, string&amp;amp; asCallback, bool abRemoveWhenLookedAt);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player looks at a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: 1 = looking, -1 = not looking&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCallback ''- function to call &amp;lt;br /&amp;gt;''abRemoveWhenLookedAt ''- determines whether the callback should be removed when the player looked at the entity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPlayerInteractCallback(string&amp;amp; asName, string&amp;amp; asCallback, bool abRemoveOnInteraction);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player interacts with a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCallback ''- function to call &amp;lt;br /&amp;gt;''abRemoveOnInteraction ''- determines whether the callback should be removed when the player interacts with the entity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityCallbackFunc(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player interacts with a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, string &amp;amp;in type)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;Type depends on entity type and includes: &amp;quot;OnPickup&amp;quot;, &amp;quot;Break&amp;quot;, &amp;quot;OnIgnite&amp;quot;, etc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityConnectionStateChangeCallback(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A callback called when ever the connection state changes (button being switched on, lever switched, etc). &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void Func(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: -1 = off, 0 = between, 1 = on&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityInteractionDisabled(string&amp;amp; asName, bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disallows interaction with an entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void BreakJoint (string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Breaks a joint. Do not use this on joints in SwingDoors, Levers, Wheels, etc. where the joint is part of an interaction. That will make the game crash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void AddEntityCollideCallback(string&amp;amp; asParentName, string&amp;amp; asChildName, string&amp;amp; asFunction, bool abDeleteOnCollide, int alStates);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when two entites collide. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: 1 = enter, -1 = leave&lt;br /&gt;
&lt;br /&gt;
''asParentName ''- internal name of main object &amp;lt;br /&amp;gt;''asChildName ''- internal name of object that collides with main object (asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) NOT supported!) &amp;lt;br /&amp;gt;''asFunction ''- function to call &amp;lt;br /&amp;gt;''abDeleteOnCollide ''- determines whether the callback after it was called &amp;lt;br /&amp;gt;''alStates ''- 1 = only enter, -1 = only leave, 0 = both&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveEntityCollideCallback(string&amp;amp; asParentName, string&amp;amp; asChildName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an EntityCollideCallback. Asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) not supported in ''asChildName''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntitiesCollide(string&amp;amp; asEntityA, string&amp;amp; asEntityB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether two entites collide. This function does NOT support asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) or &amp;quot;Player&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetBodyMass(string &amp;amp;in asName, float afMass);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Sets the mass of an entity's body.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the body of an entity. The body name of an entity is EntityName_BodyName. &amp;lt;br /&amp;gt;''afMass''  - The mass to set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
float GetBodyMass(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Gets the mass of an entity's body.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the body of an entity. The body name of an entity is EntityName_BodyName. &amp;lt;br /&amp;gt;''afMass''  - The mass to get.&lt;br /&gt;
&lt;br /&gt;
====Props====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropEffectActive(string&amp;amp; asName, bool abActive, bool abFadeAndPlaySounds);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Can be used on coal to give it the black color it should have.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropActiveAndFade(string&amp;amp; asName, bool abActive, float afFadeTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates a prop.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''abActive ''- nothing to add &amp;lt;br /&amp;gt;''afFadeTime ''- time in seconds until prop fully fades&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropStaticPhysics(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates the physics of a prop. Setting as true will make entities static in midair.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetPropIsInteractedWith(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a prop is interacted with.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void RotatePropToSpeed(string&amp;amp; asName, float afAcc, float afGoalSpeed, float afAxisX, float afAxisY, float afAxisZ, bool abResetSpeed, string&amp;amp; asOffsetArea);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rotates the prop up to a set speed.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afAcc ''- acceleration &amp;lt;br /&amp;gt;''afGoalSpeed ''- desired speed &amp;lt;br /&amp;gt;''afAxisX ''- rotation around X axis &amp;lt;br /&amp;gt;''afAxisY ''- rotation around Y axis &amp;lt;br /&amp;gt;''afAxisZ ''- rotation around Z axis &amp;lt;br /&amp;gt;''abResetSpeed ''- determines whether the speed is resetted after goal speed is reached &amp;lt;br /&amp;gt;''asOffsetArea ''- the area to rotate around, if empty, then the center of the body is used Note: The entity you want to rotate MUST be a &amp;quot;StaticObject&amp;quot; entity!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void StopPropMovement(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops all movement of a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddAttachedPropToProp(string&amp;amp; asPropName, string&amp;amp; asAttachName, string&amp;amp; asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to another prop.&lt;br /&gt;
&lt;br /&gt;
a''sPropName''- the prop to attach another prop at &amp;lt;br /&amp;gt;''asAttachName ''- internal name of the prop that gets attached &amp;lt;br /&amp;gt;''asAttachFile ''- the prop that gets attached extension .ent &amp;lt;br /&amp;gt;''afPosX ''- X position of the attach from the prop &amp;lt;br /&amp;gt;''afPosY ''- Y position of the attach from the prop &amp;lt;br /&amp;gt;''afPosZ ''- Z position of the attach from the prop &amp;lt;br /&amp;gt;''afRotX ''- rotation around X axis of the attach &amp;lt;br /&amp;gt;''afRotY ''- rotation around Y axis of the attach &amp;lt;br /&amp;gt;''afRotZ ''- rotation around ZX axis of the attach Note: for the purposes of &amp;quot;AddEntityCollideCallback&amp;quot;, attached props will not call the callback function if they collide with a &amp;quot;static_object&amp;quot; or a &amp;quot;StaticProp&amp;quot; entity type!&lt;br /&gt;
&lt;br /&gt;
{{bug|''afRotZ '' is used for both the ZX rotation and the Z position of the attached prop. Unwanted rotation can be avoided by using: &amp;lt;br /&amp;gt;''AddAttachedPropToProp(asPropName, asAttachName, asAttachFile, afPosX, afPosY, '''0''', afPosZ, '''90.0f''', afPosZ)''}}&lt;br /&gt;
&lt;br /&gt;
{{bug|Attaching a breakable prop to a physically active prop, and then breaking the attached prop, will cause the game to crash, should the parent object be moved or reset.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToProp(string&amp;amp; asPropName, string&amp;amp; asAttachName, string&amp;amp; asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to another prop. Fixed version of AddAttachedPropToProp.&lt;br /&gt;
&lt;br /&gt;
''asPropName ''- the prop to attach another prop at &amp;lt;br /&amp;gt;''asAttachName ''- internal name of the prop that gets attached &amp;lt;br /&amp;gt;''asAttachFile ''- the prop that gets attached extension .ent &amp;lt;br /&amp;gt;''afPosX ''- X position of the attach from the prop &amp;lt;br /&amp;gt;''afPosY ''- Y position of the attach from the prop &amp;lt;br /&amp;gt;''afPosZ ''- Z position of the attach from the prop &amp;lt;br /&amp;gt;''afRotX ''- rotation around X axis of the attach &amp;lt;br /&amp;gt;''afRotY ''- rotation around Y axis of the attach &amp;lt;br /&amp;gt;''afRotZ ''- rotation around ZX axis of the attach Note: for the purposes of &amp;quot;AddEntityCollideCallback&amp;quot;, attached props will not call the callback function if they collide with a &amp;quot;static_object&amp;quot; or a &amp;quot;StaticProp&amp;quot; entity type!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveAttachedPropFromProp(string&amp;amp; asPropName, string&amp;amp; asAttachName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches a prop from a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropHealth(string&amp;amp; asName, float afHealth);&lt;br /&gt;
void AddPropHealth(string&amp;amp; asName, float afHealth);&lt;br /&gt;
float GetPropHealth(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the health of a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ResetProp(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Resets a prop's state to the original one when the map was loaded.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void PlayPropAnimation(string&amp;amp; asProp, string&amp;amp; asAnimation, float afFadeTime, bool abLoop, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the prop play an animation and calls a function. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asProp)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asProp ''- internal name of the prop &amp;lt;br /&amp;gt;''asAnimation ''- animation to play &amp;lt;br /&amp;gt;''afFadeTime ''- ? &amp;lt;br /&amp;gt;''abLoop ''- determines whether the animation loops &amp;lt;br /&amp;gt;''asCallback ''- function to call&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddPropForce(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddPropImpulse(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddBodyForce(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddBodyImpulse(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These functions push objects. Note that rather high values are needed when applying ''forces''  (on the order of ~100 (weak) to ~10000 (strong)), but not impulses (values less than 10 can be appropriate). Forces are external influences, and will have different effect depending on the mass of the object they are being applied to; impulses disregard mass, and can cause objects to break, as if hit. A &amp;quot;Body&amp;quot; is a physics-related helper object, to which a force or an impulse can be applied. Entities can consist of several bodies, interconnected in various ways (you can create/examine bodies in the model editor).&lt;br /&gt;
&lt;br /&gt;
''asName ''- the object to push; for bodies, use this format: &amp;quot;''entityName''_''bodyName''&amp;quot; &amp;lt;br /&amp;gt;''afX ''- magnitude along the X-axis &amp;lt;br /&amp;gt;''afY ''- magnitude along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- magnitude along the Z-axis &amp;lt;br /&amp;gt;''asCoordSystem ''- determines which coordinate system is used, usually &amp;quot;world&amp;quot; All of these functions are ''additive''  - when called consecutively, for each call, the vectors defined by (afX, afY, afZ) will be added together, and a resultant force/impulse will be calculated ''before''  any physics simulation is applied to the target object.&lt;br /&gt;
&lt;br /&gt;
====Connections====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void InteractConnectPropWithRope(string&amp;amp; asName, string&amp;amp; asPropName, string&amp;amp; asRopeName, bool abInteractOnly, float afSpeedMul, float afToMinSpeed, float afToMaxSpeed, bool abInvert, int alStatesUsed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connects a prop with the movement of a rope (ie. turn wheel to move rope).&lt;br /&gt;
&lt;br /&gt;
''asName ''- connection name &amp;lt;br /&amp;gt;''asPropName ''- name of prop &amp;lt;br /&amp;gt;''asRopeName ''- name of rope &amp;lt;br /&amp;gt;''abInteractOnly ''- ? &amp;lt;br /&amp;gt;''afSpeedMul ''- speed multiplier of how quickly the rope moves &amp;lt;br /&amp;gt;''afToMinSpeed ''- the slowest the rope will move when moving the prop &amp;lt;br /&amp;gt;''afToMaxSpeed ''- the fastest the rope will move when moving the prop &amp;lt;br /&amp;gt;''abInvert ''- whether to invert the direction the rope moves &amp;lt;br /&amp;gt;''alStatesUsed ''- which states of the prop can interact with the rope?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void InteractConnectPropWithMoveObject(string&amp;amp; asName, string&amp;amp; asPropName, string&amp;amp; asMoveObjectName, bool abInteractOnly, bool abInvert, int alStatesUsed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This one should only be used if there must be an exact correspondance to prope &amp;quot;amount&amp;quot; and the moveobject open amount. It is best used for Wheel-door connections!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ConnectEntities(string&amp;amp; asName, string&amp;amp; asMainEntity, string&amp;amp; asConnectEntity, bool abInvertStateSent, int alStatesUsed, string&amp;amp; asCallbackFunc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asConnectionName, string &amp;amp;in asMainEntity, string &amp;amp;in asConnectEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;State is what is sent to connection entity and will be inverted if abInvertStateSent = true!&lt;br /&gt;
&lt;br /&gt;
====Lamps====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLampLit(string&amp;amp; asName, bool abLit, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(Un)lits a lamp.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Name of the lamp &amp;lt;br /&amp;gt;''abLit ''- Set true if you want the lamp to be lit, set to false if you want the lamp to be unlit &amp;lt;br /&amp;gt;''abEffects ''- If you want to have the lamp fade in/out when it gets (un)lit&lt;br /&gt;
&lt;br /&gt;
====Doors====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorLocked(string&amp;amp; asName, bool abLocked, bool abEffects);&lt;br /&gt;
void SetSwingDoorClosed(string&amp;amp; asName, bool abClosed, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Locks/closes a swing door.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GetSwingDoorLocked(string&amp;amp; asName);&lt;br /&gt;
bool GetSwingDoorClosed(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a swing door is locked/closed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorDisableAutoClose(string&amp;amp; asName, bool abDisableAutoClose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deactivates the &amp;quot;auto-close&amp;quot; when a door is nearly closed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetSwingDoorState(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns an integer depending on how far the door is opened. &amp;lt;br /&amp;gt;-1 = angle is close to 0°, 1 = angle is 70% or higher of max, 0 = inbetween -1 and 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLocked(string&amp;amp; asName, bool abLocked);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Locks a level door. Note that level doors are NOT swing doors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLockedSound(string&amp;amp; asName, string&amp;amp; asSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which sound is played when interacting with a locked level door.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLockedText(string&amp;amp; asName, string&amp;amp; asTextCat, string&amp;amp; asTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a message when interacting with a locked level door.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMoveObjectState(string&amp;amp; asName, float afState);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves an object to a certain state.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afState ''- state of the object, 0 = closed, 1 = open, values inbetween (and above, for example, the bridge_metal_vert) are valid too!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMoveObjectStateExt(string&amp;amp; asName, float afState, float afAcc, float afMaxSpeed, float afSlowdownDist, bool abResetSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves an object to a certain state, extended method.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afState ''- state of the object, 0 = closed, 1 = open, values inbetween are valid too! &amp;lt;br /&amp;gt;''afAcc ''- acceleration &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed &amp;lt;br /&amp;gt;''afSlowdownDist ''- Distance to the target state before decceleration occurs. &amp;lt;br /&amp;gt;''abResetSpeed ''- Set to True if the prop's speed should be reset before performing the movement, else the prop will accelerate from it's current speed to afMaxSpeed.&lt;br /&gt;
&lt;br /&gt;
====Levers, wheels and buttons====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropObjectStuckState(string&amp;amp; asName, int alState);&lt;br /&gt;
void SetWheelStuckState(string&amp;amp; asName, int alState, bool abEffects);&lt;br /&gt;
void SetLeverStuckState(string&amp;amp; asName, int alState, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes a prop&amp;lt;nowiki&amp;gt;\&amp;lt;/nowiki&amp;gt;wheel&amp;lt;nowiki&amp;gt;\&amp;lt;/nowiki&amp;gt;lever stuck in a certain state.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''alState ''- 0 = not stuck, 1 = at max, -1 = at min &amp;lt;br /&amp;gt;''abEffects ''- use effects&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetWheelAngle(string&amp;amp; asName, float afAngle, bool abAutoMove);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves a wheel to a certain angle.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afAngle ''- angle &amp;lt;br /&amp;gt;''abAutoMove ''- determines whether the wheel should move on its own&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetWheelInteractionDisablesStuck(string&amp;amp; asName, bool abX);&lt;br /&gt;
void SetLeverInteractionDisablesStuck(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to make a wheel/lever unstuck when interacted with.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetLeverState(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the state of the lever. &amp;lt;br /&amp;gt;0 = not stuck, 1 = at max, -1 = at min&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMultiSliderStuckState(string&amp;amp; asName, int alStuckState, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes a MultiSlider stuck in a certain state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMultiSliderCallback(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when state changes. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetButtonSwitchedOn(string&amp;amp; asName, bool abSwitchedOn, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Sticky areas====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetAllowStickyAreaAttachment(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows entites to stick to a StickyArea.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToStickyArea(string&amp;amp; asAreaName, string&amp;amp; asProp);&lt;br /&gt;
void AttachBodyToStickyArea(string&amp;amp; asAreaName, string&amp;amp; asBody);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop/body to a StickyArea.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void DetachFromStickyArea(string&amp;amp; asAreaName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches everything from a StickyArea.&lt;br /&gt;
&lt;br /&gt;
====Enemies====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNPCAwake(string&amp;amp; asName, bool abAwake, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates the npc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNPCFollowPlayer(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets an NPC's head to follow the player's movement's.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDisabled(string&amp;amp; asName, bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables an enemy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyIsHallucination(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes an enemy a hallucination. Hallucinations fade to smoke when they get near the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void FadeEnemyToSmoke(string&amp;amp; asName, bool abPlaySound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instantly fades an enemy to smoke.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ShowEnemyPlayerPosition(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the enemy run to the player, no matter where he is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AlertEnemyOfPlayerPresence(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Gives the specified enemy the player's current position and makes it search the area.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDisableTriggers(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables or disables enemy triggers. If disabled, enemy will not react to player or attack.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddEnemyPatrolNode(string&amp;amp; asName, string&amp;amp; asNodeName, float afWaitTime, string&amp;amp; asAnimation);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a patrol node to the enemy's path.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name of the enemy &amp;lt;br /&amp;gt;''asNodeName ''- path node &amp;lt;br /&amp;gt;''afWaitTime ''- time in seconds that the enemy waits at the path node before continuing &amp;lt;br /&amp;gt;''asAnimation ''- the animation the enemy uses when reaching the path node&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearEnemyPatrolNodes(string&amp;amp; asEnemyName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clears the current path of patrol nodes of the enemy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemySanityDecreaseActive(string &amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether an enemy activates the player's sanity drain when stared at.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX ''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportEnemyToNode(string &amp;amp;in asEnemyName, string &amp;amp;in asNodeName, bool abChangeY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Teleports an enemy to a specific PathNode.&lt;br /&gt;
&lt;br /&gt;
''asEnemyName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asNodeName ''- Internal name of the node to teleport to &amp;lt;br /&amp;gt;''abChangeY ''- Whether the Y position of the node will be used when teleporting the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportEnemyToEntity(string &amp;amp;in asEnemyName, string &amp;amp;in asTargetEntity, string &amp;amp;in asTargetBody, bool abChangeY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Teleports an enemy to a specific entity.&lt;br /&gt;
&lt;br /&gt;
''asEnemyName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asTargetEntity ''- Internal name of the entity to teleport to &amp;lt;br /&amp;gt;''asTargetBody''- Internal name of the entity's body name to teleport to. If empty, the first body will be used (might be unstable, recommended to input a body anyway) &amp;lt;br /&amp;gt;''abChangeY ''- Whether the Y position of the node will be used when teleporting the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeManPigPose(string&amp;amp;in asName, string&amp;amp;in asPoseType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Changes the pose a specified ManPig.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asPoseType''- Name of the ManPig pose to use. Can be &amp;quot;Biped&amp;quot; or &amp;quot;Quadruped&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigFadeDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should fade the player's view in and out.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigSoundDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should play the proximity sounds.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigEasyEscapeDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should be easier to escape from when hunted.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ForceTeslaPigSighting(string&amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Forces a TeslaPig to be visible for a short time.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
string&amp;amp; GetEnemyStateName(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the name of the state a specified enemy is current in. States can be Hunt, Search, Patrol, Wait, Alert, Investigate, Track and BreakDoor.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6680</id>
		<title>HPL2/Tutorials/ShowScreenImage()</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6680"/>
		<updated>2024-01-04T17:10:09Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added -1 size option.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
ATDD version 1.5 added the ShowScreenImage() function, which was previously available in AAMFP. Some of the workings of this function are a little counter-intuitive, so the purpose of this page is to explain it a little. This is based off of the author's experiments in ATDD 1.5, so it's not definitive! It's also assumed that these notes apply to AAMFP in the same way, but that has not been tested.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Function=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen.&lt;br /&gt;
&lt;br /&gt;
# ''asImageName'' - The image file to render (.jpg, .png, .tga, .dds) (see Size)&lt;br /&gt;
# ''afX'' - The X position of the image (see Placement)&lt;br /&gt;
# ''afY'' - The Y position of the image (see Placement)&lt;br /&gt;
# ''afScale'' - The size of the image in pixels (see Size) &lt;br /&gt;
# ''abUseRelativeCoordinates'' - If true, X and Y represent a fraction of the entire screen resoltion, otherwise they are pixel co-ordinates (see Placement)&lt;br /&gt;
# ''afDuration'' - The duration, in seconds, that the image is displayed for (see Timing)&lt;br /&gt;
# ''afFadeIn'' - The time, in seconds, to fade in the image (see Timing)&lt;br /&gt;
# ''afFadeOut'' - The time, in seconds, to fade out the image (see Timing)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Size=&lt;br /&gt;
* Note that the ''afScale'' argument is ''not'' actually the scale of the image: it is the ''size in pixels''. This is not relative and does not take the screen resolution into account, so an image will appear bigger or smaller at lower or higher resolutions respectively.&lt;br /&gt;
* If the size is specified, the image will be rendered onscreen as a square quad, even if the image file is non square. So if the desired effect is to display a non-square image, it will need to be padded out with transparent pixels in order to make it render without distortion.&lt;br /&gt;
* If the size is given as -1 (or any number less than 0) then the actual pixel size and shape of the image file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Placement=&lt;br /&gt;
* The origin of the screen-space is the centre. This means that [0, 0] is the centre of the screen regardless of screen resolution, and regardless of ''abUseRelativeCoordinates''.&lt;br /&gt;
* The origin of the image-space is the top-left. This means that the co-ordinates define where the top-left corner of the image will go.&lt;br /&gt;
* If ''abUseRelativeCoordinates'' is ''false'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as actual pixels''.&lt;br /&gt;
* If ''abUseRelativeCoordinates'' is ''true'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as a fraction of the screen resolution width or height''.&lt;br /&gt;
* The relative co-ordinates still use the centre of the screen as the origin, so the top-left corner of the screen is [-0.5, -0.5] and the bottom-right corner is [0.5, 0.5]. Any relative co-ordinate greater than 0.5 will put the image outside of the screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Timing=&lt;br /&gt;
* The total time that the image will be displayed is ''afFadeIn'' + ''afDuration'' + ''afFadeOut''.&lt;br /&gt;
* ''afDuration'' counts from when the fade in is finished. ''afFadeOut'' counts from when ''afDuration'' is finished. &lt;br /&gt;
* Calling ShowScreenImage() again will replace the current image, regardless of duration or fade times.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
// Centred:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -150.0f, -150.0f, 300.0f, false, 3.0f, 0.0f, 0.0f);&lt;br /&gt;
// Size: 300 x 300 pixels&lt;br /&gt;
// Placement: centred on the screen (image-origin is placed image-size/2 from the screen-origin)&lt;br /&gt;
// Timing: 3 seconds, no fading&lt;br /&gt;
&lt;br /&gt;
// From top-left:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.45f, -0.45f, -1.0f, true, 2.0f, 1.0f, 2.0f);&lt;br /&gt;
// Size: original pixel size and shape of the image file&lt;br /&gt;
// Placement: near the top-left corner, with a 5% margin relative to the screen size&lt;br /&gt;
// Timing: 5 seconds, including fading&lt;br /&gt;
&lt;br /&gt;
// From top-centre:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.48f, 0.0f, 100.0f, true, 0.0f, 2.0f, 2.0f);&lt;br /&gt;
// Size: 100 x 100 pixels&lt;br /&gt;
// Placement: near the top-centre, with a 2% margin relative to the screen size&lt;br /&gt;
// Timing: 4 seconds, fading out immediately after fading in&lt;br /&gt;
&lt;br /&gt;
// Bottom-right - not reliable&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, 0.25f, 0.25f, 270.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a screen resolution of 1920 x 1080, this would fit neatly into the bottom-right 1/16 of the screen (1080 / 4 = 270).&lt;br /&gt;
// Unfortunately, if the resolution was lower, it would not fit on the screen. And if the resolution was higher, it would not reach the edges.&lt;br /&gt;
&lt;br /&gt;
// Full-screen kinda... top-left focussed&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.5f, -0.5f, 3840.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a 4k screen resolution of 3840 x 2160, this would fit the full screen.&lt;br /&gt;
// The centre of the image would be at the centre of the screen at 4k, but would move towards the bottom left with lower resolutions.&lt;br /&gt;
// At lower resolutions the right and bottom of the image would be cropped. At higher resolutions it would not fill the screen.&lt;br /&gt;
&lt;br /&gt;
// Full-screen kinda... centre focussed&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.5f, -0.5f, 3840.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a 4k screen resolution of 3840 x 2160, this would fit the full screen.&lt;br /&gt;
// The centre of the image would stay on the centre of the screen, whatever the resolution.&lt;br /&gt;
// At lower resolutions all the edges would be cropped. At higher resolutions it would not fill the screen.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
There are lots of things you can do with ShowScreenImage() if you use it creatively!&lt;br /&gt;
&lt;br /&gt;
...But if you need to place an image relative the the right-hand edge or bottom of the screen, or relative to the screen resolution, it might be tricky, and might not be future-proof.&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Engine_Scripts&amp;diff=6679</id>
		<title>HPL2/Engine Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Engine_Scripts&amp;diff=6679"/>
		<updated>2024-01-04T17:03:17Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
&lt;br /&gt;
This page documents all scripts available in Amnesia: The Dark Descent.&lt;br /&gt;
&lt;br /&gt;
{{note|'''Note''': Some of the functions require the Amnesia 1.3 or 1.5 update. Steam and other online store copies should be automatically updated. Other copies can get 1.3 [http://www.frictionalgames.com/forum/thread-24334.html here].}}&lt;br /&gt;
&lt;br /&gt;
== Directives ==&lt;br /&gt;
&lt;br /&gt;
First off, &amp;lt;code&amp;gt;#include &amp;quot;file.hps&amp;quot;&amp;lt;/code&amp;gt; can be used to programmatically merge together multiple separate files to make organizing scripts easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
==Engine scripts==&lt;br /&gt;
===Main===&lt;br /&gt;
&lt;br /&gt;
The following functions are the main hps functions that the HPL2 engine looks to run on certain events - similar to the C++ int main() function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void OnStart();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs when the map is loaded for the first time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnEnter();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs whenever the player enters a map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnLeave();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs when the player leaves a map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnGameStart();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function is found in the global.hps file and the inventory.hps file, and is run when the game is first started by the player (ie via &amp;quot;Start New Game&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnUpdate(float afStep);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
This function is executed for every game update or &amp;quot;tick&amp;quot;. Can be used for rapid-firing updates instead of looping timers. Keep in mind that this can affect game performance if not used with care.&lt;br /&gt;
&lt;br /&gt;
#''afStep''- time elapsed since the last frame. Multiply speeds, distances etc. by this argument to avoid framerate dependence issues (for example: if you move something in this function with constant speed, it will move faster on computers which run the game with high FPS and slower on computers with low FPS).&lt;br /&gt;
&lt;br /&gt;
===General===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float RandFloat(float afMin, float afMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generates a random float.&lt;br /&gt;
&lt;br /&gt;
#''afMin ''- minimum value&lt;br /&gt;
#''afMax ''- maximum value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
int RandInt(int alMin, int alMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generates a random int. Note: the maximum value is ''inclusive''  - the RandInt() function may return this value.&lt;br /&gt;
&lt;br /&gt;
#''alMin ''- minimum value&lt;br /&gt;
#''alMax ''- maximum value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool StringContains(string&amp;amp; asString, string&amp;amp; asSubString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a string contains the specified string. &amp;lt;br /&amp;gt;Example: searching for &amp;quot;hello&amp;quot; in &amp;quot;hello world&amp;quot; would return '''true'''.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string to check&lt;br /&gt;
#''asSubString ''- the string to search for&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string&amp;amp; StringSub(string&amp;amp; asString, int alStart, int alCount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the substring in a string. &amp;lt;br /&amp;gt;Example: in the string &amp;quot;frictional games rocks&amp;quot;, using 4 as ''alStart''  and 6 as ''alCount''  would return '''&amp;quot;tional&amp;quot;'''.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string&lt;br /&gt;
#''alStart ''- start position in the string&lt;br /&gt;
#''alCount ''- amount of characters&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
int StringToInt(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns an integer converted from a string, else returns 0.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float StringToFloat(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns a float converted from a string, else returns 0.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool StringToBool(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns a boolean converted from a string, else returns false.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&lt;br /&gt;
===Mathematical Operations===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathSin(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the sine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathCos(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the cosine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathTan(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the tangent of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAsin(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc sine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAcos(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc cosine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAtan(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc tangent of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAtan2(float afX, float afY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Calculates and returns the arc tangent of the specified values.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - First value to operate.&lt;br /&gt;
#''afY''  - Second value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathSqrt(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the square root of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathPow(float afBase, float afExp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the value of afBase raised to the power of afExp.&lt;br /&gt;
&lt;br /&gt;
#''afBase''  - The base value.&lt;br /&gt;
#''afExp''  - Value to calculate the base with.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathMin(float afA, float afB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the lowest value.&lt;br /&gt;
&lt;br /&gt;
#''afA''  - First value.&lt;br /&gt;
#''afB''  - Second value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathMax(float afA, float afB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the highest value.&lt;br /&gt;
&lt;br /&gt;
#''afA''  - First value.&lt;br /&gt;
#''afB''  - Second value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathClamp(float afX, float afMin, float afMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns afX clamped between afMin and afMax. If afX &amp;lt; afMin, returns afMin, and if afX &amp;gt; afMax, returns afMax.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - The value to clamp.&lt;br /&gt;
#''afMin''  - The minimum value to clamp afX with.&lt;br /&gt;
#''afMax''  - The maximum value to clamp afX with.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAbs(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the absolute value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Print(string&amp;amp; asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints a string to the log file (''hpl.log'').&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddDebugMessage(string&amp;amp; asString, bool abCheckForDuplicates);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints a string to the debug console.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string to print&lt;br /&gt;
#''abCheckForDuplicates ''- if true, the string won't be printed more than once on screen until it disappears&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ProgLog(string&amp;amp; asLevel, string&amp;amp; asMessage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints an entry to the ProgLog (progression log). &amp;lt;br /&amp;gt;ProgLog is a file created in Documents/Amnesia/main (or an FC folder if one is being used). It logs certain events, such us opening the menu or picking up the lantern, as well as the player's state (Health, Sanity, Oil, Tinderboxes, Coins), for the purpose of documenting a tester's playstyle. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;This function allows to log custom messages.The messages in the ProgLog file are sorted by time elapsed since a map was loaded.&lt;br /&gt;
&lt;br /&gt;
ProgLog has to be enabled for a player profile in ''user_settings.cfg''  before it starts working.&lt;br /&gt;
&lt;br /&gt;
#''asLevel ''- can be &amp;quot;Low&amp;quot;, &amp;quot;Medium&amp;quot; or &amp;quot;High&amp;quot;. It's a tag which appears in each log entry, for event prioritising.&lt;br /&gt;
#''asMessage ''- The custom message to be printed to the log.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool ScriptDebugOn();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the debug mode is enabled. &amp;lt;br /&amp;gt;See [[HPL2/Development_Environment|&amp;quot;Setting up Development Environment&amp;quot;]] to setup debug mode on your own computer.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
{{warning|Regular variables (int, float, etc.) are '''not''' saved by the game. Using them in important parts of yor script will break it upon loading a game save. In HPL, those variables should only be used for disposable counters, like spawning objects in a &amp;quot;for&amp;quot; loop. For variables which need to be saved, use the wrappers as described below.}}&lt;br /&gt;
&lt;br /&gt;
====Local====&lt;br /&gt;
&lt;br /&gt;
Local variables can be used throughout the same script file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
void AddLocalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
int GetLocalVarInt(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
void AddLocalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
float GetLocalVarFloat(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarString(string&amp;amp; asName, const string&amp;amp; asVal);&lt;br /&gt;
void AddLocalVarString(string&amp;amp; asName, string&amp;amp; asVal);&lt;br /&gt;
string&amp;amp; GetLocalVarString(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Global====&lt;br /&gt;
&lt;br /&gt;
Global variables can be used throughout several maps and can be accessed by several script files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
void AddGlobalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
int GetGlobalVarInt(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
void AddGlobalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
float GetGlobalVarFloat(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarString(string&amp;amp; asName, const string&amp;amp; asVal);&lt;br /&gt;
void AddGlobalVarString(string&amp;amp; asName, string&amp;amp; asVal);&lt;br /&gt;
string&amp;amp; GetGlobalVarString(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Particle Systems===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PreloadParticleSystem(string&amp;amp; asPSFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Preloads a particle system.&lt;br /&gt;
&lt;br /&gt;
#''asPSFile''  - The particle system file to load. Extension: .ps&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateParticleSystemAtEntity(string&amp;amp; asPSName, string&amp;amp; asPSFile, string&amp;amp; asEntity, bool abSavePS);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a particle system on an entity.&lt;br /&gt;
&lt;br /&gt;
#''asPSName ''- internal name&lt;br /&gt;
#''asPSFile ''- the particle system to use + extension .ps&lt;br /&gt;
#''asEntity ''- the entity to create the particle system at&lt;br /&gt;
#''abSavePS ''- determines whether a particle system should &amp;quot;remember&amp;quot; its shown/hidden state, so that this state can be restored when the player revisits the level&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateParticleSystemAtEntityExt(string&amp;amp; asPSName, string&amp;amp; asPSFile, string&amp;amp; asEntity, bool abSavePS,&lt;br /&gt;
float afR, float afG, float afB, float afA, bool abFadeAtDistance, float afFadeMinEnd, float afFadeMinStart,&lt;br /&gt;
float afFadeMaxStart, float afFadeMaxEnd);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a particle system on an entity, extended method with more options.&lt;br /&gt;
&lt;br /&gt;
#''asPSName ''- internal name&lt;br /&gt;
#''asPSFile ''- the particle system to use + extension .ps&lt;br /&gt;
#''asEntity ''- the entity to create the particle system at&lt;br /&gt;
#''abSavePS ''- determines whether a particle system should &amp;quot;remember&amp;quot; its shown/hidden state, so that this state can be restored when the player revisits the level&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
#''abFadeAtDistance ''- determines whether a particle system fades from a certain distance on&lt;br /&gt;
#''afFadeMinEnd ''- minimum distance at which the particle system stops fading&lt;br /&gt;
#''afFadeMinStart ''- minimum distance at which the particle system starts fading&lt;br /&gt;
#''afFadeMaxStart ''- maximum distance at which the particle system starts fading&lt;br /&gt;
#''afFadeMaxEnd ''- maximum distance at which the particle system stops fading&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DestroyParticleSystem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Destroys a particle system.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - The internal name of the particle system&lt;br /&gt;
&lt;br /&gt;
===Sounds &amp;amp; Music===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PreloadSound(string&amp;amp; asSoundFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Preloads a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundFile''  - The sound file to load. Extension: .snt&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlaySoundAtEntity(string&amp;amp; asSoundName, string&amp;amp; asSoundFile, string&amp;amp; asEntity, float afFadeTime, bool abSaveSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a sound on an entity.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''asSoundFile ''- the sound to use + extension .snt&lt;br /&gt;
#''asEntity ''- the entity to create the sound at, can be &amp;quot;Player&amp;quot;&lt;br /&gt;
#''afFadeTime ''- time in seconds the sound needs to fade. Avoids enemies hearing the sound if afFadeTime is at least 0.1f&lt;br /&gt;
#''abSaveSound ''- if ''true'', a looping sound will &amp;quot;remember&amp;quot; its playback state (currently playing/stopped), and that state will be restored the next time the level is entered. If ''true'', the sound is never attached to the entity! Note that saving should only be used on ''looping sounds''!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeInSound(string&amp;amp; asSoundName, float afFadeTime, bool abPlayStart);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades in a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''afFadeTime ''- time in seconds&lt;br /&gt;
#''abPlayStart ''- ?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopSound(string&amp;amp; asSoundName, float afFadeTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades out a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''afFadeTime ''- time in seconds, use 0 to immediatly stop the sound&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayMusic(string&amp;amp; asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays music.&lt;br /&gt;
&lt;br /&gt;
#''asMusicFile ''- the music to play + extension .ogg&lt;br /&gt;
#''abLoop ''- determines whether a music track should loop&lt;br /&gt;
#''afVolume ''- volume of the music&lt;br /&gt;
#''afFadeTime ''- time in seconds until music reaches full volume&lt;br /&gt;
#''alPrio ''- priority of the music. Note that only the music with the highest priority can be heard! 0 - lowest, 1 - higher, etc.&lt;br /&gt;
#''abResume''  - if ''true'', playback will be continued from where the track stopped after the call to StopMusic(); if ''false'', the track will be restarted.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopMusic(float afFadeTime, int alPrio);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops music.&lt;br /&gt;
&lt;br /&gt;
#''afFadeTime ''- time in seconds until music stops&lt;br /&gt;
#''alPrio ''- the priority of the music that should stop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeGlobalSoundVolume(float afDestVolume, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Influences the global sound volume, that means everything you can hear '''from the world'''. This does not affect music of GUI sounds.&lt;br /&gt;
&lt;br /&gt;
#''afDestVolume ''- desired volume&lt;br /&gt;
#''afTime ''- time in seconds until volume reaches desired volume&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeGlobalSoundSpeed(float afDestSpeed, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Influences the global sound speed.&lt;br /&gt;
&lt;br /&gt;
#''afDestSpeed ''- desired speed&lt;br /&gt;
#''afTime ''- time in seconds until volume reaches desired speed&lt;br /&gt;
&lt;br /&gt;
===Lights===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLightVisible(string&amp;amp; asLightName, bool abVisible);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/disables lights.&lt;br /&gt;
&lt;br /&gt;
#''asLightName ''- internal name&lt;br /&gt;
#''abVisible ''- determines the state of the light&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeLightTo(string&amp;amp; asLightName, float afR, float afG, float afB, float afA, float afRadius, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the properties of a light.&lt;br /&gt;
&lt;br /&gt;
#''asLightName ''- internal name&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
#''afRadius ''- radius of the light. -1 means keeping the radius&lt;br /&gt;
#''afTime ''- time in seconds until change is done&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLightFlickerActive(string&amp;amp; asLightName, bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates flickering on a light.&lt;br /&gt;
&lt;br /&gt;
#''asLightName''  - The internal light name&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&lt;br /&gt;
==Game scripts==&lt;br /&gt;
&lt;br /&gt;
===General===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartCredits(string&amp;amp; asMusic, bool abLoopMusic, string&amp;amp; asTextCat, string&amp;amp; asTextEntry, int alEndNum);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the end credits screen.&lt;br /&gt;
&lt;br /&gt;
#''asMusic ''- the music to play (including .ogg)&lt;br /&gt;
#''abLoopMusic ''- determines whether the music should loop&lt;br /&gt;
#''asTextCat ''- the category to be used in the .lang file&lt;br /&gt;
#''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
#''alEndNum ''- Amnesia has 3 different endings and displays a code at the bottom. Determines which code is displayed. 0-2 will display codes, any other integer will not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartDemoEnd();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the end images that are used in the demo, images are named &amp;quot;demo_end01.jpg&amp;quot;, increase the number for each image you want to use. (NEEDS VERIFICATION)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AutoSave();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the game to the auto save.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CheckPoint (string&amp;amp; asName, string&amp;amp; asStartPos, string&amp;amp; asCallback, string&amp;amp; asDeathHintCat, string&amp;amp; asDeathHintEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets a checkpoint at which the player will respawn in case he dies. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asName, int alCount)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;Count is 0 on the first checkpoint load!&lt;br /&gt;
&lt;br /&gt;
#''asName ''- the internal name&lt;br /&gt;
#''asStartPos ''- the name of the StartPos in the editor&lt;br /&gt;
#''asCallback ''- the function to call when the player dies/respawns&lt;br /&gt;
#''asDeathHintCat ''- the category of the death hint message to be used in the .lang file&lt;br /&gt;
#''asDeathHintEntry ''- the entry in the .lang file&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeMap(string&amp;amp; asMapName, string&amp;amp; asStartPos, string&amp;amp; asStartSound, string&amp;amp; asEndSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Immediatly loads another map.&lt;br /&gt;
&lt;br /&gt;
#''asMapName ''- the file to load&lt;br /&gt;
#''asStartPos ''- the name of the StartPos on the next map&lt;br /&gt;
#''asStartSound ''- the sound that is played when the change starts&lt;br /&gt;
#''asEndSound ''- the sound that is played when the new map is loaded&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ClearSavedMaps();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clears the &amp;quot;history&amp;quot; of the save, useful to do when you know the player will not be able to go back anymore. Makes the next save much smaller in size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateDataCache();&lt;br /&gt;
void DestroyDataCache();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This caches all current textures and models and they are not released until destroy is called. If there is already cached data it is destroyed.&lt;br /&gt;
Create caches to enable faster loading when going back to a map. Destroy the cache if you know the player won't go back to that map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetMapDisplayNameEntry(string&amp;amp; asNameEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the map name shown in save file names. If none is set NULL is assumed.&lt;br /&gt;
&lt;br /&gt;
#''asNameEntry ''- the entry to display, category must be &amp;quot;Levels&amp;quot;!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the skybox.&lt;br /&gt;
&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxTexture(string&amp;amp; asTexture);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the texture of the skybox.&lt;br /&gt;
&lt;br /&gt;
#''asTexture''  - The texture file to set. Extension: .dds&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxColor(float afR, float afG, float afB, float afA);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the solid color of the skybox rather than a texture.&lt;br /&gt;
&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the global fog.&lt;br /&gt;
&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogColor(float afR, float afG, float afB, float afA);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the color to use for the global fog.&lt;br /&gt;
&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogProperties(float afStart, float afEnd, float afFalloffExp, bool abCulling);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the properties for the global fog.&lt;br /&gt;
&lt;br /&gt;
#''afStart ''- how many meters from the camera should the fog begin&lt;br /&gt;
#''afEnd ''- how many meters from the camera should the fog reach full thickness&lt;br /&gt;
#''afFalloffExp ''- the amount by which the thinkness increases&lt;br /&gt;
#''abCulling ''- whether occlusion culling is active for the fog; this prevents objects behind the fog from being loaded&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetupLoadScreen(string&amp;amp;asTextCat, string&amp;amp;asTextEntry, int alRandomNum, string&amp;amp;asImageFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which loading screen will be shown when changing maps.&lt;br /&gt;
&lt;br /&gt;
#''asTextCat ''- the category of the loading text in the .lang file to be shown on the loading screen&lt;br /&gt;
#''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
#''alRandomNum ''- if greater 1, then it will randomize between 1 and alRandom for each LoadScreen giving entry the suffix XX (eg 01). If &amp;lt; =1 then no suffix is added&lt;br /&gt;
#''asImageFile ''- the image to be shown (optional)&lt;br /&gt;
&lt;br /&gt;
===Game Timer===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddTimer(string&amp;amp; asName, float afTime, string&amp;amp; asFunction);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a timer which calls a function when it expires. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asTimer)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#''asName ''- the name of the timer&lt;br /&gt;
#''afTime ''- time in seconds&lt;br /&gt;
#''asFunction ''- the function to call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveTimer(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes a timer, no matter how much time is left.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - the internal name of the timer.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetTimerTimeLeft(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the time left on a timer.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - the internal name of the timer.&lt;br /&gt;
&lt;br /&gt;
===Screen Effects===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeOut(float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to black.&lt;br /&gt;
&lt;br /&gt;
''afTime ''- time in seconds until the screen is completly black&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeIn(float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen back to normal.&lt;br /&gt;
&lt;br /&gt;
''afTime ''- time in seconds until the screen back to normal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeImageTrailTo(float afAmount, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applies the image trail effect to the screen.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeSepiaColorTo(float afAmount, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the screen go dark red.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeRadialBlurTo(float afSize, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applies radial blur effects to the screen.&lt;br /&gt;
&lt;br /&gt;
''afSize ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetRadialBlurStartDist(float afStartDist);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines at which distance the radial blur effects appear.&lt;br /&gt;
&lt;br /&gt;
''afStartDist ''- the distance at which the effect starts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartEffectFlash(float afFadeIn, float afWhite, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to white.&lt;br /&gt;
&lt;br /&gt;
''afFadeIn ''- time in seconds until screen is white &amp;lt;br /&amp;gt;''afWhite ''- determines to which percentage the screen fades to white (1.0 = completly white) &amp;lt;br /&amp;gt;''afFadeOut ''- time in seconds until screen is back to normal again&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartEffectEmotionFlash(string&amp;amp; asTextCat, string&amp;amp; asTextEntry, string&amp;amp; asSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to white and shows a text message.&lt;br /&gt;
&lt;br /&gt;
''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the text entry in the .lang file &amp;lt;br /&amp;gt;''asSound ''- the sound to play while fading&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice(string&amp;amp; asVoiceFile, string&amp;amp; asEffectFile, string&amp;amp; asTextCat, string&amp;amp; asTextEntry,&lt;br /&gt;
bool abUsePosition, string&amp;amp; asPosEntity, float afMinDistance, float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This adds a voice and an effect to be played. It is okay to call this many times in order to play many voices in a row. The EffectVoiceOverCallback is not called until ALL voices have finished.&lt;br /&gt;
&lt;br /&gt;
''asVoiceFile ''- the voice to play &amp;lt;br /&amp;gt;''asEffectFile ''- the effect to play &amp;lt;br /&amp;gt;''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the text entry in the .lang file &amp;lt;br /&amp;gt;''abUsePosition ''- plays using 3D from the entity, or without 3D &amp;lt;br /&amp;gt;''asPosEntity ''- the entity at which the effect appears &amp;lt;br /&amp;gt;''afMinDistance ''- minimum distance to see the effect &amp;lt;br /&amp;gt;''afMaxDistance ''- maximum distance to see the effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopAllEffectVoices(float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops all voices and calls the EffectVoiceOverCallback.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEffectVoiceActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether EffectVoices are still active.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEffectVoiceOverCallback(string&amp;amp; asFunc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the function to be called when the EffectVoices are finished. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetFlashbackIsActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a flashback is still in effect.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPlayerSpawnPS(string&amp;amp; asSPSFile);&lt;br /&gt;
void StopPlayerSpawnPS();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuously spawn regular particle systems (''.ps'') around the player. Particles created by this script carry over from map to map. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;''asSPSFile''  - the ''.sps''  file to use. Exemplary ''.sps''  files are located in the ''/misc''  folder in the main game directory. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;Custom ''.sps''  files can be created by hand in a text editor (see existing ones and mimic how those are written). &amp;lt;br /&amp;gt;Since ''StopPlayerSpawnPS()''  doesn't seem to work, to stop an SPS you must create an ''.sps''  file with an empty particle field field and override the old SPS by calling ''StartPlayerSpawnPS''  again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayGuiSound(string&amp;amp; asSoundFile, float afVolume);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays a sound, not using 3D.&lt;br /&gt;
&lt;br /&gt;
''asSoundFile ''- the sound to play (extension is .snt) &amp;lt;br /&amp;gt;''afVolume ''- the volume of the sound&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartScreenShake(float afAmount, float afTime, float afFadeInTime, float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Shakes the screen.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity of the shake &amp;lt;br /&amp;gt;''afTime ''- duration of the shake &amp;lt;br /&amp;gt;''afFadeInTime ''- time in seconds until full intensity is reached &amp;lt;br /&amp;gt;''afFadeOutTime ''- time until screen is back to normal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInDarknessEffectsActive(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables the sanity drain and night vision effects while in the darkness.&lt;br /&gt;
&lt;br /&gt;
''bool abX''  - Enable/disable effects.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen. See [[HPL2/Tutorials/ShowScreenImage()|ShowScreenImage()]] in the tutorials section for more information.&lt;br /&gt;
&lt;br /&gt;
''asImageName'' - The image file to render (.jpg, .png, .tga, .dds)&lt;br /&gt;
&lt;br /&gt;
''afX'' - The X position of the image&lt;br /&gt;
&lt;br /&gt;
''afY'' - The Y position of the image&lt;br /&gt;
&lt;br /&gt;
''afScale'' - The size of the image in pixels (not scale)&lt;br /&gt;
&lt;br /&gt;
''abUseRelativeCoordinates'' - Whether X and Y are relative to the screen resoltion, or pixel co-ordinates if not&lt;br /&gt;
&lt;br /&gt;
''afDuration'' - The duration that the image is displayed for&lt;br /&gt;
&lt;br /&gt;
''afFadeIn'' - The time, in seconds, to fade in the image&lt;br /&gt;
&lt;br /&gt;
''afFadeOut'' - The time, in seconds, to fade out the image&lt;br /&gt;
&lt;br /&gt;
===Insanity===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInsanitySetEnabled(string&amp;amp; asSet, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which InsanitySets are enabled.&lt;br /&gt;
&lt;br /&gt;
''asSet ''- the set &amp;lt;br /&amp;gt;''abX ''- enabled or not&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartInsanityEvent(string &amp;amp;in asEventName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Starts a specified insanity event.&lt;br /&gt;
&lt;br /&gt;
''asEventName ''- Insanity event to play.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartRandomInsanityEvent();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts a random insanity event from the available sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopCurrentInsanityEvent();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Stops the currently playing insanity event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void InsanityEventIsActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether an insanity event is currently in effect… Or so it was supposed to be, but as it doesn't return a value, we can never know [http://wiki.frictionalgames.com/lib/images/smileys/icon_smile.gif?nolink&amp;amp;15x15]&lt;br /&gt;
&lt;br /&gt;
===Player===&lt;br /&gt;
&lt;br /&gt;
Note that the player's maximum health and sanity is 100.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enabled/Disable player controlled movement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangePlayerStateToNormal();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets certain effects back to normal. It can for example make the player drop an item.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerCrouching(bool abCrouch);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the player to crouch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pushes the player into a certain direction. Note that you need values above ~2000 to see any effects.&lt;br /&gt;
&lt;br /&gt;
''afX ''- amount along the X-axis &amp;lt;br /&amp;gt;''afY ''- amount along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- amount along the Z-axis &amp;lt;br /&amp;gt;''abUseLocalCoords ''- If true, axes are based on where the player is facing, not the world.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowPlayerCrossHairIcons(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the icons when a player has something in focus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerSanity(float afSanity);&lt;br /&gt;
void AddPlayerSanity(float afSanity);&lt;br /&gt;
float GetPlayerSanity();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the sanity of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerHealth(float afHealth);&lt;br /&gt;
void AddPlayerHealth(float afHealth);&lt;br /&gt;
float GetPlayerHealth();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the health of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerLampOil(float afOil);&lt;br /&gt;
void AddPlayerLampOil(float afOil);&lt;br /&gt;
float GetPlayerLampOil();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the lamp oil of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerSpeed();&lt;br /&gt;
float GetPlayerYSpeed();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the current speed of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSanityDrainDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables sanity drain from darkness, monsters, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveSanityBoost();&lt;br /&gt;
void GiveSanityBoostSmall();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Boosts the player's sanity by a fixed amount.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveSanityDamage(float afAmount, bool abUseEffect);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduces the sanity of the player.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount of sanity damage done &amp;lt;br /&amp;gt;''abUseEffect ''- determines whether an effect is played when the sanity damage is dealt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GivePlayerDamage(float afAmount, string&amp;amp; asType, bool abSpinHead, bool abLethal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduces the health of the player.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount of damage done to health &amp;lt;br /&amp;gt;''asType ''- plays a certain effect on the screen when the damage is dealt (BloodSplat, Claws or Slash) &amp;lt;br /&amp;gt;''abSpinHead ''- changes the camera view when damage is dealt &amp;lt;br /&amp;gt;''abLethal ''- set to true if player can die from given damage&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerFOVMulTo(float afX, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the field of view of the player. A shorter FOV will create a zoom effect.&lt;br /&gt;
&lt;br /&gt;
''afX ''- multiplier of default FOV (1 is default) &amp;lt;br /&amp;gt;''afSpeed ''- the speed of change between FOV's&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerAspectMulTo(float afX, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the aspect ratio of the player. Basically stretches or narrows the screen horizontally.&lt;br /&gt;
&lt;br /&gt;
''afX ''- multiplier of default aspect (default is 1) &amp;lt;br /&amp;gt;''afSpeed ''- the speed of change between FOV's&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerRollTo(float afX, float afSpeedMul, float afMaxSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rotates the position of the camera on the player's body.&lt;br /&gt;
&lt;br /&gt;
''afX ''- angle of rotation of head, positive being counter-clockwise &amp;lt;br /&amp;gt;''afSpeedMul ''- speed (possibly acceleration) multiplier of the rotation (default 1, which is really slow) &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed of rotation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void MovePlayerHeadPos(float afX, float afY, float afZ, float afSpeed, float afSlowDownDist);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the position of the camera on the player's body.&lt;br /&gt;
&lt;br /&gt;
''afX ''- amount along the X-axis &amp;lt;br /&amp;gt;''afY ''- amount along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- amount along the Z-axis &amp;lt;br /&amp;gt;''afSpeed ''- speed at which the change happens &amp;lt;br /&amp;gt;''afSlowDownDist ''- distance at which to start slowing down (prevents the head from abruptly stopping)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPlayerLookAt(string&amp;amp; asEntityName, float afSpeedMul, float afMaxSpeed, string&amp;amp; asAtTargetCallback);&lt;br /&gt;
void StopPlayerLookAt();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the player to look at a certain entity until StopPlayerLookAt is used.&lt;br /&gt;
&lt;br /&gt;
''asEntityName ''- the entity to look at &amp;lt;br /&amp;gt;''afSpeedMul ''- how fast should the player look at the entity &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed allowed &amp;lt;br /&amp;gt;''asAtTargetCallback ''- function to call when player looks at target&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerMoveSpeedMul(float afMul);&lt;br /&gt;
void SetPlayerRunSpeedMul(float afMul);&lt;br /&gt;
void SetPlayerLookSpeedMul(float afMul);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the player's move/run/look speed. Default is 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerJumpForceMul(float afMul);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Changes the player's jump multiplier. Higher values = higher jumps. Default is 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerJumpDisabled(bool abX);&lt;br /&gt;
void SetPlayerCrouchDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the player's ability to jump/crouch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportPlayer(string&amp;amp; asStartPosName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instantly teleports the player to the target StartPos.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternActive(bool abX, bool abUseEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the player use his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetLanternActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the player currently uses his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the player's ability to use his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternLitCallback(string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the function to call when the player uses his lantern. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;MyFunc(bool abLit)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetMessage(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a message on the screen.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTime ''- determines how long the message is displayed. If time is &amp;lt; =0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetDeathHint(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the message that appears when the player dies.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DisableDeathStartSound();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the death sound when the player dies. This must be called directly before player is killed! The variable as soon as player dies too.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
void MovePlayerForward(float afAmount)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;REQUIRES THE 1.2 PATCH: JUSTINE&amp;quot; Moves the player forward. It needs to be called in a timer that updates 60 times / second.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerFallDamageDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables the player's ability to take fall damage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerPos(float afX, float afY, float afZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Sets the player's position within the level.&lt;br /&gt;
&lt;br /&gt;
''afX''  - X co-ordinate position. &amp;lt;br /&amp;gt;''afY''  - Y co-ordinate position. &amp;lt;br /&amp;gt;''afZ''  - Z co-ordinate position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerPosX();&lt;br /&gt;
float GetPlayerPosY();&lt;br /&gt;
float GetPlayerPosZ();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the player's position within the level on the specified axis.&lt;br /&gt;
&lt;br /&gt;
===Journal===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddNote(string&amp;amp; asNameAndTextEntry, string&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a note to the player's journal.&lt;br /&gt;
&lt;br /&gt;
''asNameAndTextEntry ''- entries in the .lang file. Must end with _Name and _Text and be in category &amp;quot;Journal&amp;quot;! &amp;lt;br /&amp;gt;''asImage ''- the background image to be used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddDiary(string&amp;amp; asNameAndTextEntry, string&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a diary to the player's journal.&lt;br /&gt;
&lt;br /&gt;
''asNameAndTextEntry ''- entries in the .lang file. Must end with _NameX and _TextY whereas X and Y are numbers of the parts (_Name1: first diary, _Text1: first page) and be in category &amp;quot;Journal&amp;quot;! &amp;lt;br /&amp;gt;''asImage ''- the background image to be used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ReturnOpenJournal(bool abOpenJournal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Only called in the pickup diary callback! If true the journal displays the entry else not.&lt;br /&gt;
&lt;br /&gt;
===Quests===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddQuest(string&amp;amp; asName, string&amp;amp; asNameAndTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a quest to the player's journal under mementos.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name to be used &amp;lt;br /&amp;gt;''asNameAndTextEntry ''- entry in the .lang file. Must start with &amp;quot;Quest_&amp;lt;texthere&amp;gt;_Text”, and be in category “Journal”!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CompleteQuest(string&amp;amp; asName, string&amp;amp; asNameAndTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Completes a quest.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name of the quest &amp;lt;br /&amp;gt;''asNameAndTextEntry ''- entry in the .lang file. Must start with &amp;quot; Quest_&amp;lt;texthere&amp;gt;_Text ”, and be in category “Journal”!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool QuestIsCompleted(string&amp;amp; asName);&lt;br /&gt;
bool QuestIsAdded(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a quest is completed/added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetNumberOfQuestsInMap(int alNumberOfQuests);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the number of quests in the map.&lt;br /&gt;
&lt;br /&gt;
''alNumberOfQuests ''- Amount of Quests&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveHint(string&amp;amp; asName, string&amp;amp; asMessageCat, string&amp;amp; asMessageEntry, float afTimeShown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a hint on the player's screen.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name &amp;lt;br /&amp;gt;''asMessageCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asMessageEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTimeShown ''- time in seconds until the message disappears. If time is &amp;lt;= 0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void BlockHint(string&amp;amp; asName);&lt;br /&gt;
void UnBlockHint(string&amp;amp; asName);&lt;br /&gt;
void RemoveHint(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Blocking a hint prevents it from being shown. Blocked hints are included in savefiles, so they should persist between levels.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Removing&amp;quot; a hint actually removes it from the list of already given hints, thus allowing it to show up again.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name. Basic game hints use the same name as their respective lang entries, with the exception of &amp;quot;numbered&amp;quot; hints. For example, &amp;lt;code&amp;gt;EntityGrab&amp;lt;/code&amp;gt; blocks the &amp;lt;code&amp;gt;EntityGrab01&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;EntityGrab02&amp;lt;/code&amp;gt; entries.&lt;br /&gt;
&lt;br /&gt;
===Inventory===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ExitInventory();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exits the inventory by force.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInventoryDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the player's ability to open his inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInventoryMessage(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a message at the bottom of the inventory screen.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTime ''- time in seconds until the message disappears. If life time is &amp;lt;= 0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveItem(string&amp;amp; asName, string&amp;amp; asType, string&amp;amp; asSubTypeName, string&amp;amp; asImageName, float afAmount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds an item to the inventory of the player. Note that the item does not have to exist as entity in the world to be able to do this.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asType ''- item type to give, Available types are: &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Puzzle&lt;br /&gt;
*Lantern&lt;br /&gt;
*Health&lt;br /&gt;
*Sanity&lt;br /&gt;
*LampOil&lt;br /&gt;
*Tinderbox&lt;br /&gt;
&lt;br /&gt;
''asSubTypeName ''- item name for .lang file &amp;lt;br /&amp;gt;''asImageName ''- the image which will appear in inventory. For example: &amp;lt;code&amp;gt;void GiveItem(&amp;quot;chemical_container_full_1&amp;quot;, &amp;quot;Puzzle&amp;quot;, &amp;quot;chemical_container_full&amp;quot;, &amp;quot;chemical_container_full.tga&amp;quot;, 1);&amp;lt;/code&amp;gt; will use the image from &amp;lt;code&amp;gt;graphics/item/chemical_container_full.tga&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount the item gives, - For example: Oil potions will fill the oil meter by this amount, Health potions will heal by this amount, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveItem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an item from the player's inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool HasItem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the player has an item in his inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveItemFromFile(string&amp;amp; asName, string&amp;amp; asFileName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a single item to the player's inventory. This is meant to be used for debug mostly as it creates the actual item and then destroys it.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asFileName ''- item to give + extension (.ent)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddCombineCallback(string&amp;amp; asName, string&amp;amp; asItemA, string&amp;amp; asItemB, string&amp;amp; asFunction, bool abAutoRemove);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to combine items in his inventory. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asItemA, string &amp;amp;in asItemB)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name for the callback &amp;lt;br /&amp;gt;''asItemA ''- internal name of first item &amp;lt;br /&amp;gt;''asItemB ''- internal name of second item &amp;lt;br /&amp;gt;''asFunction ''- the function to call &amp;lt;br /&amp;gt;''abAutoRemove ''- determines whether the callback should be removed when the items are combined&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveCombineCallback(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes a combine callback. &amp;lt;br /&amp;gt;''asName''  - the internal name of the callback to be removed (as specified in AddCombineCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddUseItemCallback(string&amp;amp; asName, string&amp;amp; asItem, string&amp;amp; asEntity, string&amp;amp; asFunction, bool abAutoDestroy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to use items on the world. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asItem, string &amp;amp;in asEntity)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asItem ''- internal name of the item &amp;lt;br /&amp;gt;''asEntity ''- entity to be able to use the item on &amp;lt;br /&amp;gt;''asFunction ''- function to call &amp;lt;br /&amp;gt;''abAutoDestroy ''- determines whether the item is destroyed when used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveUseItemCallback(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an item callback.&lt;br /&gt;
&lt;br /&gt;
===Entities===&lt;br /&gt;
&lt;br /&gt;
====General====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityActive(string&amp;amp; asName, bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates an entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityVisible(string &amp;amp;in asName, bool abVisible);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates an entity's visual mesh. The collision body remains.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity. &amp;lt;br /&amp;gt;''abActive''  - Activate/deactivate mesh.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntityExists(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether an entity exists.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityCustomFocusCrossHair(string&amp;amp; asName, string&amp;amp; asCrossHair);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the crosshair that is used when focusing an entity.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCrossHair ''- desired crosshair, can be: Default (uses default), Grab, Push, Ignite, Pick, LevelDoor, Ladder&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void CreateEntityAtArea(string&amp;amp; asEntityName, string&amp;amp; asEntityFile, string&amp;amp; asAreaName, bool abFullGameSave);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates an entity at an area. When creating an enemy though, it cannot chase properly along PathNodes(using for example ShowEnemyPlayerPosition).&lt;br /&gt;
&lt;br /&gt;
''asEntityName ''- internal name &amp;lt;br /&amp;gt;''asEntityFile ''- entity to be used extension .ent &amp;lt;br /&amp;gt;''asAreaName ''- the area to create the entity at &amp;lt;br /&amp;gt;''abFullGameSave ''- determines whether an entity &amp;quot;remembers&amp;quot; its state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ReplaceEntity(string &amp;amp;in asName, string &amp;amp;in asBodyName, string &amp;amp;in asNewEntityName, string &amp;amp;in asNewEntityFile, bool abFullGameSave);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Removes an entity and places a new one in its place.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to replace. &amp;lt;br /&amp;gt;''asBodyName''  - Name of the body of the entity to place the new entity at. If empty the first body is used (might be buggy, recommended to name a body anyway). &amp;lt;br /&amp;gt;''asNewEntityName''  - Name of the new entity. &amp;lt;br /&amp;gt;''asNewEntityFile''  - Name of the new entity file. Extension .ent. &amp;lt;br /&amp;gt;''abFullGameSave''  - Whether ALL properties of this entity should be saved throughout levels.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlaceEntityAtEntity(string &amp;amp;in asName, string &amp;amp;in asTargetEntity, string &amp;amp;in asTargetBodyName, bool abUseRotation);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Places an entity at the position of another entity. Does not work for enemies, use TeleportEnemyToEntity instead.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to place. &amp;lt;br /&amp;gt;''asTargetEntity''  - Name of the other entity to place the first entity at. &amp;lt;br /&amp;gt;''asTargetBodyName''  - Name of the body of the entity to place the first entity at. If empty the first body is used (might be buggy, recommended to name a body anyway). &amp;lt;br /&amp;gt;''abUseRotation''  - Whether the entity should be rotated like the target entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPos(string &amp;amp;in asName, float afX, float afY, float afZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Moves an entity to a position in the level.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to move. &amp;lt;br /&amp;gt;''afX''  - X co-ordinate position. &amp;lt;br /&amp;gt;''afY''  - Y co-ordinate position. &amp;lt;br /&amp;gt;''afZ''  - Z co-ordinate position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
float GetEntityPosX(string &amp;amp;in asName);&lt;br /&gt;
float GetEntityPosY(string &amp;amp;in asName);&lt;br /&gt;
float GetEntityPosZ(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns an entity's position in the level on the specified axis.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPlayerLookAtCallback(string&amp;amp; asName, string&amp;amp; asCallback, bool abRemoveWhenLookedAt);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player looks at a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: 1 = looking, -1 = not looking&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCallback ''- function to call &amp;lt;br /&amp;gt;''abRemoveWhenLookedAt ''- determines whether the callback should be removed when the player looked at the entity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPlayerInteractCallback(string&amp;amp; asName, string&amp;amp; asCallback, bool abRemoveOnInteraction);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player interacts with a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCallback ''- function to call &amp;lt;br /&amp;gt;''abRemoveOnInteraction ''- determines whether the callback should be removed when the player interacts with the entity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityCallbackFunc(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player interacts with a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, string &amp;amp;in type)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;Type depends on entity type and includes: &amp;quot;OnPickup&amp;quot;, &amp;quot;Break&amp;quot;, &amp;quot;OnIgnite&amp;quot;, etc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityConnectionStateChangeCallback(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A callback called when ever the connection state changes (button being switched on, lever switched, etc). &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void Func(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: -1 = off, 0 = between, 1 = on&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityInteractionDisabled(string&amp;amp; asName, bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disallows interaction with an entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void BreakJoint (string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Breaks a joint. Do not use this on joints in SwingDoors, Levers, Wheels, etc. where the joint is part of an interaction. That will make the game crash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void AddEntityCollideCallback(string&amp;amp; asParentName, string&amp;amp; asChildName, string&amp;amp; asFunction, bool abDeleteOnCollide, int alStates);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when two entites collide. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: 1 = enter, -1 = leave&lt;br /&gt;
&lt;br /&gt;
''asParentName ''- internal name of main object &amp;lt;br /&amp;gt;''asChildName ''- internal name of object that collides with main object (asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) NOT supported!) &amp;lt;br /&amp;gt;''asFunction ''- function to call &amp;lt;br /&amp;gt;''abDeleteOnCollide ''- determines whether the callback after it was called &amp;lt;br /&amp;gt;''alStates ''- 1 = only enter, -1 = only leave, 0 = both&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveEntityCollideCallback(string&amp;amp; asParentName, string&amp;amp; asChildName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an EntityCollideCallback. Asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) not supported in ''asChildName''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntitiesCollide(string&amp;amp; asEntityA, string&amp;amp; asEntityB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether two entites collide. This function does NOT support asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) or &amp;quot;Player&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetBodyMass(string &amp;amp;in asName, float afMass);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Sets the mass of an entity's body.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the body of an entity. The body name of an entity is EntityName_BodyName. &amp;lt;br /&amp;gt;''afMass''  - The mass to set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
float GetBodyMass(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Gets the mass of an entity's body.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the body of an entity. The body name of an entity is EntityName_BodyName. &amp;lt;br /&amp;gt;''afMass''  - The mass to get.&lt;br /&gt;
&lt;br /&gt;
====Props====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropEffectActive(string&amp;amp; asName, bool abActive, bool abFadeAndPlaySounds);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Can be used on coal to give it the black color it should have.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropActiveAndFade(string&amp;amp; asName, bool abActive, float afFadeTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates a prop.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''abActive ''- nothing to add &amp;lt;br /&amp;gt;''afFadeTime ''- time in seconds until prop fully fades&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropStaticPhysics(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates the physics of a prop. Setting as true will make entities static in midair.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetPropIsInteractedWith(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a prop is interacted with.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void RotatePropToSpeed(string&amp;amp; asName, float afAcc, float afGoalSpeed, float afAxisX, float afAxisY, float afAxisZ, bool abResetSpeed, string&amp;amp; asOffsetArea);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rotates the prop up to a set speed.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afAcc ''- acceleration &amp;lt;br /&amp;gt;''afGoalSpeed ''- desired speed &amp;lt;br /&amp;gt;''afAxisX ''- rotation around X axis &amp;lt;br /&amp;gt;''afAxisY ''- rotation around Y axis &amp;lt;br /&amp;gt;''afAxisZ ''- rotation around Z axis &amp;lt;br /&amp;gt;''abResetSpeed ''- determines whether the speed is resetted after goal speed is reached &amp;lt;br /&amp;gt;''asOffsetArea ''- the area to rotate around, if empty, then the center of the body is used Note: The entity you want to rotate MUST be a &amp;quot;StaticObject&amp;quot; entity!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void StopPropMovement(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops all movement of a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddAttachedPropToProp(string&amp;amp; asPropName, string&amp;amp; asAttachName, string&amp;amp; asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to another prop.&lt;br /&gt;
&lt;br /&gt;
a''sPropName''- the prop to attach another prop at &amp;lt;br /&amp;gt;''asAttachName ''- internal name of the prop that gets attached &amp;lt;br /&amp;gt;''asAttachFile ''- the prop that gets attached extension .ent &amp;lt;br /&amp;gt;''afPosX ''- X position of the attach from the prop &amp;lt;br /&amp;gt;''afPosY ''- Y position of the attach from the prop &amp;lt;br /&amp;gt;''afPosZ ''- Z position of the attach from the prop &amp;lt;br /&amp;gt;''afRotX ''- rotation around X axis of the attach &amp;lt;br /&amp;gt;''afRotY ''- rotation around Y axis of the attach &amp;lt;br /&amp;gt;''afRotZ ''- rotation around ZX axis of the attach Note: for the purposes of &amp;quot;AddEntityCollideCallback&amp;quot;, attached props will not call the callback function if they collide with a &amp;quot;static_object&amp;quot; or a &amp;quot;StaticProp&amp;quot; entity type!&lt;br /&gt;
&lt;br /&gt;
{{bug|''afRotZ '' is used for both the ZX rotation and the Z position of the attached prop. Unwanted rotation can be avoided by using: &amp;lt;br /&amp;gt;''AddAttachedPropToProp(asPropName, asAttachName, asAttachFile, afPosX, afPosY, '''0''', afPosZ, '''90.0f''', afPosZ)''}}&lt;br /&gt;
&lt;br /&gt;
{{bug|Attaching a breakable prop to a physically active prop, and then breaking the attached prop, will cause the game to crash, should the parent object be moved or reset.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToProp(string&amp;amp; asPropName, string&amp;amp; asAttachName, string&amp;amp; asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to another prop. Fixed version of AddAttachedPropToProp.&lt;br /&gt;
&lt;br /&gt;
''asPropName ''- the prop to attach another prop at &amp;lt;br /&amp;gt;''asAttachName ''- internal name of the prop that gets attached &amp;lt;br /&amp;gt;''asAttachFile ''- the prop that gets attached extension .ent &amp;lt;br /&amp;gt;''afPosX ''- X position of the attach from the prop &amp;lt;br /&amp;gt;''afPosY ''- Y position of the attach from the prop &amp;lt;br /&amp;gt;''afPosZ ''- Z position of the attach from the prop &amp;lt;br /&amp;gt;''afRotX ''- rotation around X axis of the attach &amp;lt;br /&amp;gt;''afRotY ''- rotation around Y axis of the attach &amp;lt;br /&amp;gt;''afRotZ ''- rotation around ZX axis of the attach Note: for the purposes of &amp;quot;AddEntityCollideCallback&amp;quot;, attached props will not call the callback function if they collide with a &amp;quot;static_object&amp;quot; or a &amp;quot;StaticProp&amp;quot; entity type!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveAttachedPropFromProp(string&amp;amp; asPropName, string&amp;amp; asAttachName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches a prop from a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropHealth(string&amp;amp; asName, float afHealth);&lt;br /&gt;
void AddPropHealth(string&amp;amp; asName, float afHealth);&lt;br /&gt;
float GetPropHealth(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the health of a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ResetProp(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Resets a prop's state to the original one when the map was loaded.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void PlayPropAnimation(string&amp;amp; asProp, string&amp;amp; asAnimation, float afFadeTime, bool abLoop, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the prop play an animation and calls a function. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asProp)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asProp ''- internal name of the prop &amp;lt;br /&amp;gt;''asAnimation ''- animation to play &amp;lt;br /&amp;gt;''afFadeTime ''- ? &amp;lt;br /&amp;gt;''abLoop ''- determines whether the animation loops &amp;lt;br /&amp;gt;''asCallback ''- function to call&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddPropForce(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddPropImpulse(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddBodyForce(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddBodyImpulse(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These functions push objects. Note that rather high values are needed when applying ''forces''  (on the order of ~100 (weak) to ~10000 (strong)), but not impulses (values less than 10 can be appropriate). Forces are external influences, and will have different effect depending on the mass of the object they are being applied to; impulses disregard mass, and can cause objects to break, as if hit. A &amp;quot;Body&amp;quot; is a physics-related helper object, to which a force or an impulse can be applied. Entities can consist of several bodies, interconnected in various ways (you can create/examine bodies in the model editor).&lt;br /&gt;
&lt;br /&gt;
''asName ''- the object to push; for bodies, use this format: &amp;quot;''entityName''_''bodyName''&amp;quot; &amp;lt;br /&amp;gt;''afX ''- magnitude along the X-axis &amp;lt;br /&amp;gt;''afY ''- magnitude along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- magnitude along the Z-axis &amp;lt;br /&amp;gt;''asCoordSystem ''- determines which coordinate system is used, usually &amp;quot;world&amp;quot; All of these functions are ''additive''  - when called consecutively, for each call, the vectors defined by (afX, afY, afZ) will be added together, and a resultant force/impulse will be calculated ''before''  any physics simulation is applied to the target object.&lt;br /&gt;
&lt;br /&gt;
====Connections====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void InteractConnectPropWithRope(string&amp;amp; asName, string&amp;amp; asPropName, string&amp;amp; asRopeName, bool abInteractOnly, float afSpeedMul, float afToMinSpeed, float afToMaxSpeed, bool abInvert, int alStatesUsed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connects a prop with the movement of a rope (ie. turn wheel to move rope).&lt;br /&gt;
&lt;br /&gt;
''asName ''- connection name &amp;lt;br /&amp;gt;''asPropName ''- name of prop &amp;lt;br /&amp;gt;''asRopeName ''- name of rope &amp;lt;br /&amp;gt;''abInteractOnly ''- ? &amp;lt;br /&amp;gt;''afSpeedMul ''- speed multiplier of how quickly the rope moves &amp;lt;br /&amp;gt;''afToMinSpeed ''- the slowest the rope will move when moving the prop &amp;lt;br /&amp;gt;''afToMaxSpeed ''- the fastest the rope will move when moving the prop &amp;lt;br /&amp;gt;''abInvert ''- whether to invert the direction the rope moves &amp;lt;br /&amp;gt;''alStatesUsed ''- which states of the prop can interact with the rope?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void InteractConnectPropWithMoveObject(string&amp;amp; asName, string&amp;amp; asPropName, string&amp;amp; asMoveObjectName, bool abInteractOnly, bool abInvert, int alStatesUsed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This one should only be used if there must be an exact correspondance to prope &amp;quot;amount&amp;quot; and the moveobject open amount. It is best used for Wheel-door connections!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ConnectEntities(string&amp;amp; asName, string&amp;amp; asMainEntity, string&amp;amp; asConnectEntity, bool abInvertStateSent, int alStatesUsed, string&amp;amp; asCallbackFunc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asConnectionName, string &amp;amp;in asMainEntity, string &amp;amp;in asConnectEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;State is what is sent to connection entity and will be inverted if abInvertStateSent = true!&lt;br /&gt;
&lt;br /&gt;
====Lamps====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLampLit(string&amp;amp; asName, bool abLit, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(Un)lits a lamp.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Name of the lamp &amp;lt;br /&amp;gt;''abLit ''- Set true if you want the lamp to be lit, set to false if you want the lamp to be unlit &amp;lt;br /&amp;gt;''abEffects ''- If you want to have the lamp fade in/out when it gets (un)lit&lt;br /&gt;
&lt;br /&gt;
====Doors====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorLocked(string&amp;amp; asName, bool abLocked, bool abEffects);&lt;br /&gt;
void SetSwingDoorClosed(string&amp;amp; asName, bool abClosed, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Locks/closes a swing door.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GetSwingDoorLocked(string&amp;amp; asName);&lt;br /&gt;
bool GetSwingDoorClosed(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a swing door is locked/closed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorDisableAutoClose(string&amp;amp; asName, bool abDisableAutoClose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deactivates the &amp;quot;auto-close&amp;quot; when a door is nearly closed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetSwingDoorState(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns an integer depending on how far the door is opened. &amp;lt;br /&amp;gt;-1 = angle is close to 0°, 1 = angle is 70% or higher of max, 0 = inbetween -1 and 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLocked(string&amp;amp; asName, bool abLocked);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Locks a level door. Note that level doors are NOT swing doors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLockedSound(string&amp;amp; asName, string&amp;amp; asSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which sound is played when interacting with a locked level door.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLockedText(string&amp;amp; asName, string&amp;amp; asTextCat, string&amp;amp; asTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a message when interacting with a locked level door.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMoveObjectState(string&amp;amp; asName, float afState);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves an object to a certain state.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afState ''- state of the object, 0 = closed, 1 = open, values inbetween (and above, for example, the bridge_metal_vert) are valid too!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMoveObjectStateExt(string&amp;amp; asName, float afState, float afAcc, float afMaxSpeed, float afSlowdownDist, bool abResetSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves an object to a certain state, extended method.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afState ''- state of the object, 0 = closed, 1 = open, values inbetween are valid too! &amp;lt;br /&amp;gt;''afAcc ''- acceleration &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed &amp;lt;br /&amp;gt;''afSlowdownDist ''- Distance to the target state before decceleration occurs. &amp;lt;br /&amp;gt;''abResetSpeed ''- Set to True if the prop's speed should be reset before performing the movement, else the prop will accelerate from it's current speed to afMaxSpeed.&lt;br /&gt;
&lt;br /&gt;
====Levers, wheels and buttons====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropObjectStuckState(string&amp;amp; asName, int alState);&lt;br /&gt;
void SetWheelStuckState(string&amp;amp; asName, int alState, bool abEffects);&lt;br /&gt;
void SetLeverStuckState(string&amp;amp; asName, int alState, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes a prop&amp;lt;nowiki&amp;gt;\&amp;lt;/nowiki&amp;gt;wheel&amp;lt;nowiki&amp;gt;\&amp;lt;/nowiki&amp;gt;lever stuck in a certain state.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''alState ''- 0 = not stuck, 1 = at max, -1 = at min &amp;lt;br /&amp;gt;''abEffects ''- use effects&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetWheelAngle(string&amp;amp; asName, float afAngle, bool abAutoMove);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves a wheel to a certain angle.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afAngle ''- angle &amp;lt;br /&amp;gt;''abAutoMove ''- determines whether the wheel should move on its own&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetWheelInteractionDisablesStuck(string&amp;amp; asName, bool abX);&lt;br /&gt;
void SetLeverInteractionDisablesStuck(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to make a wheel/lever unstuck when interacted with.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetLeverState(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the state of the lever. &amp;lt;br /&amp;gt;0 = not stuck, 1 = at max, -1 = at min&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMultiSliderStuckState(string&amp;amp; asName, int alStuckState, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes a MultiSlider stuck in a certain state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMultiSliderCallback(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when state changes. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetButtonSwitchedOn(string&amp;amp; asName, bool abSwitchedOn, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Sticky areas====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetAllowStickyAreaAttachment(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows entites to stick to a StickyArea.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToStickyArea(string&amp;amp; asAreaName, string&amp;amp; asProp);&lt;br /&gt;
void AttachBodyToStickyArea(string&amp;amp; asAreaName, string&amp;amp; asBody);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop/body to a StickyArea.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void DetachFromStickyArea(string&amp;amp; asAreaName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches everything from a StickyArea.&lt;br /&gt;
&lt;br /&gt;
====Enemies====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNPCAwake(string&amp;amp; asName, bool abAwake, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates the npc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNPCFollowPlayer(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets an NPC's head to follow the player's movement's.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDisabled(string&amp;amp; asName, bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables an enemy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyIsHallucination(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes an enemy a hallucination. Hallucinations fade to smoke when they get near the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void FadeEnemyToSmoke(string&amp;amp; asName, bool abPlaySound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instantly fades an enemy to smoke.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ShowEnemyPlayerPosition(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the enemy run to the player, no matter where he is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AlertEnemyOfPlayerPresence(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Gives the specified enemy the player's current position and makes it search the area.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDisableTriggers(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables or disables enemy triggers. If disabled, enemy will not react to player or attack.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddEnemyPatrolNode(string&amp;amp; asName, string&amp;amp; asNodeName, float afWaitTime, string&amp;amp; asAnimation);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a patrol node to the enemy's path.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name of the enemy &amp;lt;br /&amp;gt;''asNodeName ''- path node &amp;lt;br /&amp;gt;''afWaitTime ''- time in seconds that the enemy waits at the path node before continuing &amp;lt;br /&amp;gt;''asAnimation ''- the animation the enemy uses when reaching the path node&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearEnemyPatrolNodes(string&amp;amp; asEnemyName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clears the current path of patrol nodes of the enemy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemySanityDecreaseActive(string &amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether an enemy activates the player's sanity drain when stared at.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX ''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportEnemyToNode(string &amp;amp;in asEnemyName, string &amp;amp;in asNodeName, bool abChangeY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Teleports an enemy to a specific PathNode.&lt;br /&gt;
&lt;br /&gt;
''asEnemyName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asNodeName ''- Internal name of the node to teleport to &amp;lt;br /&amp;gt;''abChangeY ''- Whether the Y position of the node will be used when teleporting the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportEnemyToEntity(string &amp;amp;in asEnemyName, string &amp;amp;in asTargetEntity, string &amp;amp;in asTargetBody, bool abChangeY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Teleports an enemy to a specific entity.&lt;br /&gt;
&lt;br /&gt;
''asEnemyName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asTargetEntity ''- Internal name of the entity to teleport to &amp;lt;br /&amp;gt;''asTargetBody''- Internal name of the entity's body name to teleport to. If empty, the first body will be used (might be unstable, recommended to input a body anyway) &amp;lt;br /&amp;gt;''abChangeY ''- Whether the Y position of the node will be used when teleporting the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeManPigPose(string&amp;amp;in asName, string&amp;amp;in asPoseType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Changes the pose a specified ManPig.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asPoseType''- Name of the ManPig pose to use. Can be &amp;quot;Biped&amp;quot; or &amp;quot;Quadruped&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigFadeDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should fade the player's view in and out.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigSoundDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should play the proximity sounds.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigEasyEscapeDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should be easier to escape from when hunted.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ForceTeslaPigSighting(string&amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Forces a TeslaPig to be visible for a short time.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
string&amp;amp; GetEnemyStateName(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the name of the state a specified enemy is current in. States can be Hunt, Search, Patrol, Wait, Alert, Investigate, Track and BreakDoor.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Engine_Scripts&amp;diff=6678</id>
		<title>HPL2/Engine Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Engine_Scripts&amp;diff=6678"/>
		<updated>2024-01-04T17:02:36Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Edited notes for ShowScreenImage() and added a link to tutorial.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
&lt;br /&gt;
This page documents all scripts available in Amnesia: The Dark Descent.&lt;br /&gt;
&lt;br /&gt;
{{note|'''Note''': Some of the functions require the Amnesia 1.3 or 1.5 update. Steam and other online store copies should be automatically updated. Other copies can get 1.3 [http://www.frictionalgames.com/forum/thread-24334.html here].}}&lt;br /&gt;
&lt;br /&gt;
== Directives ==&lt;br /&gt;
&lt;br /&gt;
First off, &amp;lt;code&amp;gt;#include &amp;quot;file.hps&amp;quot;&amp;lt;/code&amp;gt; can be used to programmatically merge together multiple separate files to make organizing scripts easier.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
==Engine scripts==&lt;br /&gt;
===Main===&lt;br /&gt;
&lt;br /&gt;
The following functions are the main hps functions that the HPL2 engine looks to run on certain events - similar to the C++ int main() function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void OnStart();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs when the map is loaded for the first time.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnEnter();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs whenever the player enters a map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnLeave();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function that runs when the player leaves a map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnGameStart();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function is found in the global.hps file and the inventory.hps file, and is run when the game is first started by the player (ie via &amp;quot;Start New Game&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void OnUpdate(float afStep);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
This function is executed for every game update or &amp;quot;tick&amp;quot;. Can be used for rapid-firing updates instead of looping timers. Keep in mind that this can affect game performance if not used with care.&lt;br /&gt;
&lt;br /&gt;
#''afStep''- time elapsed since the last frame. Multiply speeds, distances etc. by this argument to avoid framerate dependence issues (for example: if you move something in this function with constant speed, it will move faster on computers which run the game with high FPS and slower on computers with low FPS).&lt;br /&gt;
&lt;br /&gt;
===General===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float RandFloat(float afMin, float afMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generates a random float.&lt;br /&gt;
&lt;br /&gt;
#''afMin ''- minimum value&lt;br /&gt;
#''afMax ''- maximum value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
int RandInt(int alMin, int alMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Generates a random int. Note: the maximum value is ''inclusive''  - the RandInt() function may return this value.&lt;br /&gt;
&lt;br /&gt;
#''alMin ''- minimum value&lt;br /&gt;
#''alMax ''- maximum value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool StringContains(string&amp;amp; asString, string&amp;amp; asSubString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a string contains the specified string. &amp;lt;br /&amp;gt;Example: searching for &amp;quot;hello&amp;quot; in &amp;quot;hello world&amp;quot; would return '''true'''.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string to check&lt;br /&gt;
#''asSubString ''- the string to search for&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string&amp;amp; StringSub(string&amp;amp; asString, int alStart, int alCount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the substring in a string. &amp;lt;br /&amp;gt;Example: in the string &amp;quot;frictional games rocks&amp;quot;, using 4 as ''alStart''  and 6 as ''alCount''  would return '''&amp;quot;tional&amp;quot;'''.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string&lt;br /&gt;
#''alStart ''- start position in the string&lt;br /&gt;
#''alCount ''- amount of characters&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
int StringToInt(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns an integer converted from a string, else returns 0.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float StringToFloat(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns a float converted from a string, else returns 0.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool StringToBool(string&amp;amp;in asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
If possible, returns a boolean converted from a string, else returns false.&lt;br /&gt;
&lt;br /&gt;
#''asString''  - String to convert.&lt;br /&gt;
&lt;br /&gt;
===Mathematical Operations===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathSin(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the sine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathCos(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the cosine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathTan(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the tangent of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAsin(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc sine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAcos(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc cosine of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAtan(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the arc tangent of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAtan2(float afX, float afY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Calculates and returns the arc tangent of the specified values.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - First value to operate.&lt;br /&gt;
#''afY''  - Second value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathSqrt(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the square root of the specified value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathPow(float afBase, float afExp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the value of afBase raised to the power of afExp.&lt;br /&gt;
&lt;br /&gt;
#''afBase''  - The base value.&lt;br /&gt;
#''afExp''  - Value to calculate the base with.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathMin(float afA, float afB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the lowest value.&lt;br /&gt;
&lt;br /&gt;
#''afA''  - First value.&lt;br /&gt;
#''afB''  - Second value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathMax(float afA, float afB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the highest value.&lt;br /&gt;
&lt;br /&gt;
#''afA''  - First value.&lt;br /&gt;
#''afB''  - Second value.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathClamp(float afX, float afMin, float afMax);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns afX clamped between afMin and afMax. If afX &amp;lt; afMin, returns afMin, and if afX &amp;gt; afMax, returns afMax.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - The value to clamp.&lt;br /&gt;
#''afMin''  - The minimum value to clamp afX with.&lt;br /&gt;
#''afMax''  - The maximum value to clamp afX with.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float MathAbs(float afX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the absolute value.&lt;br /&gt;
&lt;br /&gt;
#''afX''  - Value to operate.&lt;br /&gt;
&lt;br /&gt;
===Debugging===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Print(string&amp;amp; asString);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints a string to the log file (''hpl.log'').&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddDebugMessage(string&amp;amp; asString, bool abCheckForDuplicates);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints a string to the debug console.&lt;br /&gt;
&lt;br /&gt;
#''asString ''- the string to print&lt;br /&gt;
#''abCheckForDuplicates ''- if true, the string won't be printed more than once on screen until it disappears&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ProgLog(string&amp;amp; asLevel, string&amp;amp; asMessage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prints an entry to the ProgLog (progression log). &amp;lt;br /&amp;gt;ProgLog is a file created in Documents/Amnesia/main (or an FC folder if one is being used). It logs certain events, such us opening the menu or picking up the lantern, as well as the player's state (Health, Sanity, Oil, Tinderboxes, Coins), for the purpose of documenting a tester's playstyle. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;This function allows to log custom messages.The messages in the ProgLog file are sorted by time elapsed since a map was loaded.&lt;br /&gt;
&lt;br /&gt;
ProgLog has to be enabled for a player profile in ''user_settings.cfg''  before it starts working.&lt;br /&gt;
&lt;br /&gt;
#''asLevel ''- can be &amp;quot;Low&amp;quot;, &amp;quot;Medium&amp;quot; or &amp;quot;High&amp;quot;. It's a tag which appears in each log entry, for event prioritising.&lt;br /&gt;
#''asMessage ''- The custom message to be printed to the log.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool ScriptDebugOn();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the debug mode is enabled. &amp;lt;br /&amp;gt;See [[HPL2/Development_Environment|&amp;quot;Setting up Development Environment&amp;quot;]] to setup debug mode on your own computer.&lt;br /&gt;
&lt;br /&gt;
===Variables===&lt;br /&gt;
{{warning|Regular variables (int, float, etc.) are '''not''' saved by the game. Using them in important parts of yor script will break it upon loading a game save. In HPL, those variables should only be used for disposable counters, like spawning objects in a &amp;quot;for&amp;quot; loop. For variables which need to be saved, use the wrappers as described below.}}&lt;br /&gt;
&lt;br /&gt;
====Local====&lt;br /&gt;
&lt;br /&gt;
Local variables can be used throughout the same script file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
void AddLocalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
int GetLocalVarInt(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
void AddLocalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
float GetLocalVarFloat(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLocalVarString(string&amp;amp; asName, const string&amp;amp; asVal);&lt;br /&gt;
void AddLocalVarString(string&amp;amp; asName, string&amp;amp; asVal);&lt;br /&gt;
string&amp;amp; GetLocalVarString(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Global====&lt;br /&gt;
&lt;br /&gt;
Global variables can be used throughout several maps and can be accessed by several script files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
void AddGlobalVarInt(string&amp;amp; asName, int alVal);&lt;br /&gt;
int GetGlobalVarInt(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
void AddGlobalVarFloat(string&amp;amp; asName, float afVal);&lt;br /&gt;
float GetGlobalVarFloat(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetGlobalVarString(string&amp;amp; asName, const string&amp;amp; asVal);&lt;br /&gt;
void AddGlobalVarString(string&amp;amp; asName, string&amp;amp; asVal);&lt;br /&gt;
string&amp;amp; GetGlobalVarString(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Particle Systems===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PreloadParticleSystem(string&amp;amp; asPSFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Preloads a particle system.&lt;br /&gt;
&lt;br /&gt;
#''asPSFile''  - The particle system file to load. Extension: .ps&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateParticleSystemAtEntity(string&amp;amp; asPSName, string&amp;amp; asPSFile, string&amp;amp; asEntity, bool abSavePS);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a particle system on an entity.&lt;br /&gt;
&lt;br /&gt;
#''asPSName ''- internal name&lt;br /&gt;
#''asPSFile ''- the particle system to use + extension .ps&lt;br /&gt;
#''asEntity ''- the entity to create the particle system at&lt;br /&gt;
#''abSavePS ''- determines whether a particle system should &amp;quot;remember&amp;quot; its shown/hidden state, so that this state can be restored when the player revisits the level&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateParticleSystemAtEntityExt(string&amp;amp; asPSName, string&amp;amp; asPSFile, string&amp;amp; asEntity, bool abSavePS,&lt;br /&gt;
float afR, float afG, float afB, float afA, bool abFadeAtDistance, float afFadeMinEnd, float afFadeMinStart,&lt;br /&gt;
float afFadeMaxStart, float afFadeMaxEnd);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a particle system on an entity, extended method with more options.&lt;br /&gt;
&lt;br /&gt;
#''asPSName ''- internal name&lt;br /&gt;
#''asPSFile ''- the particle system to use + extension .ps&lt;br /&gt;
#''asEntity ''- the entity to create the particle system at&lt;br /&gt;
#''abSavePS ''- determines whether a particle system should &amp;quot;remember&amp;quot; its shown/hidden state, so that this state can be restored when the player revisits the level&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
#''abFadeAtDistance ''- determines whether a particle system fades from a certain distance on&lt;br /&gt;
#''afFadeMinEnd ''- minimum distance at which the particle system stops fading&lt;br /&gt;
#''afFadeMinStart ''- minimum distance at which the particle system starts fading&lt;br /&gt;
#''afFadeMaxStart ''- maximum distance at which the particle system starts fading&lt;br /&gt;
#''afFadeMaxEnd ''- maximum distance at which the particle system stops fading&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DestroyParticleSystem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Destroys a particle system.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - The internal name of the particle system&lt;br /&gt;
&lt;br /&gt;
===Sounds &amp;amp; Music===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PreloadSound(string&amp;amp; asSoundFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Preloads a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundFile''  - The sound file to load. Extension: .snt&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlaySoundAtEntity(string&amp;amp; asSoundName, string&amp;amp; asSoundFile, string&amp;amp; asEntity, float afFadeTime, bool abSaveSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a sound on an entity.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''asSoundFile ''- the sound to use + extension .snt&lt;br /&gt;
#''asEntity ''- the entity to create the sound at, can be &amp;quot;Player&amp;quot;&lt;br /&gt;
#''afFadeTime ''- time in seconds the sound needs to fade. Avoids enemies hearing the sound if afFadeTime is at least 0.1f&lt;br /&gt;
#''abSaveSound ''- if ''true'', a looping sound will &amp;quot;remember&amp;quot; its playback state (currently playing/stopped), and that state will be restored the next time the level is entered. If ''true'', the sound is never attached to the entity! Note that saving should only be used on ''looping sounds''!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeInSound(string&amp;amp; asSoundName, float afFadeTime, bool abPlayStart);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades in a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''afFadeTime ''- time in seconds&lt;br /&gt;
#''abPlayStart ''- ?&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopSound(string&amp;amp; asSoundName, float afFadeTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades out a sound.&lt;br /&gt;
&lt;br /&gt;
#''asSoundName ''- internal name&lt;br /&gt;
#''afFadeTime ''- time in seconds, use 0 to immediatly stop the sound&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayMusic(string&amp;amp; asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays music.&lt;br /&gt;
&lt;br /&gt;
#''asMusicFile ''- the music to play + extension .ogg&lt;br /&gt;
#''abLoop ''- determines whether a music track should loop&lt;br /&gt;
#''afVolume ''- volume of the music&lt;br /&gt;
#''afFadeTime ''- time in seconds until music reaches full volume&lt;br /&gt;
#''alPrio ''- priority of the music. Note that only the music with the highest priority can be heard! 0 - lowest, 1 - higher, etc.&lt;br /&gt;
#''abResume''  - if ''true'', playback will be continued from where the track stopped after the call to StopMusic(); if ''false'', the track will be restarted.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopMusic(float afFadeTime, int alPrio);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops music.&lt;br /&gt;
&lt;br /&gt;
#''afFadeTime ''- time in seconds until music stops&lt;br /&gt;
#''alPrio ''- the priority of the music that should stop&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeGlobalSoundVolume(float afDestVolume, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Influences the global sound volume, that means everything you can hear '''from the world'''. This does not affect music of GUI sounds.&lt;br /&gt;
&lt;br /&gt;
#''afDestVolume ''- desired volume&lt;br /&gt;
#''afTime ''- time in seconds until volume reaches desired volume&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeGlobalSoundSpeed(float afDestSpeed, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Influences the global sound speed.&lt;br /&gt;
&lt;br /&gt;
#''afDestSpeed ''- desired speed&lt;br /&gt;
#''afTime ''- time in seconds until volume reaches desired speed&lt;br /&gt;
&lt;br /&gt;
===Lights===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLightVisible(string&amp;amp; asLightName, bool abVisible);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/disables lights.&lt;br /&gt;
&lt;br /&gt;
#''asLightName ''- internal name&lt;br /&gt;
#''abVisible ''- determines the state of the light&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeLightTo(string&amp;amp; asLightName, float afR, float afG, float afB, float afA, float afRadius, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the properties of a light.&lt;br /&gt;
&lt;br /&gt;
#''asLightName ''- internal name&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
#''afRadius ''- radius of the light. -1 means keeping the radius&lt;br /&gt;
#''afTime ''- time in seconds until change is done&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLightFlickerActive(string&amp;amp; asLightName, bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates flickering on a light.&lt;br /&gt;
&lt;br /&gt;
#''asLightName''  - The internal light name&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&lt;br /&gt;
==Game scripts==&lt;br /&gt;
&lt;br /&gt;
===General===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartCredits(string&amp;amp; asMusic, bool abLoopMusic, string&amp;amp; asTextCat, string&amp;amp; asTextEntry, int alEndNum);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the end credits screen.&lt;br /&gt;
&lt;br /&gt;
#''asMusic ''- the music to play (including .ogg)&lt;br /&gt;
#''abLoopMusic ''- determines whether the music should loop&lt;br /&gt;
#''asTextCat ''- the category to be used in the .lang file&lt;br /&gt;
#''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
#''alEndNum ''- Amnesia has 3 different endings and displays a code at the bottom. Determines which code is displayed. 0-2 will display codes, any other integer will not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartDemoEnd();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the end images that are used in the demo, images are named &amp;quot;demo_end01.jpg&amp;quot;, increase the number for each image you want to use. (NEEDS VERIFICATION)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AutoSave();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the game to the auto save.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CheckPoint (string&amp;amp; asName, string&amp;amp; asStartPos, string&amp;amp; asCallback, string&amp;amp; asDeathHintCat, string&amp;amp; asDeathHintEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets a checkpoint at which the player will respawn in case he dies. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asName, int alCount)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;Count is 0 on the first checkpoint load!&lt;br /&gt;
&lt;br /&gt;
#''asName ''- the internal name&lt;br /&gt;
#''asStartPos ''- the name of the StartPos in the editor&lt;br /&gt;
#''asCallback ''- the function to call when the player dies/respawns&lt;br /&gt;
#''asDeathHintCat ''- the category of the death hint message to be used in the .lang file&lt;br /&gt;
#''asDeathHintEntry ''- the entry in the .lang file&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeMap(string&amp;amp; asMapName, string&amp;amp; asStartPos, string&amp;amp; asStartSound, string&amp;amp; asEndSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Immediatly loads another map.&lt;br /&gt;
&lt;br /&gt;
#''asMapName ''- the file to load&lt;br /&gt;
#''asStartPos ''- the name of the StartPos on the next map&lt;br /&gt;
#''asStartSound ''- the sound that is played when the change starts&lt;br /&gt;
#''asEndSound ''- the sound that is played when the new map is loaded&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ClearSavedMaps();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clears the &amp;quot;history&amp;quot; of the save, useful to do when you know the player will not be able to go back anymore. Makes the next save much smaller in size.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CreateDataCache();&lt;br /&gt;
void DestroyDataCache();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This caches all current textures and models and they are not released until destroy is called. If there is already cached data it is destroyed.&lt;br /&gt;
Create caches to enable faster loading when going back to a map. Destroy the cache if you know the player won't go back to that map.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetMapDisplayNameEntry(string&amp;amp; asNameEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the map name shown in save file names. If none is set NULL is assumed.&lt;br /&gt;
&lt;br /&gt;
#''asNameEntry ''- the entry to display, category must be &amp;quot;Levels&amp;quot;!&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the skybox.&lt;br /&gt;
&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxTexture(string&amp;amp; asTexture);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the texture of the skybox.&lt;br /&gt;
&lt;br /&gt;
#''asTexture''  - The texture file to set. Extension: .dds&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSkyBoxColor(float afR, float afG, float afB, float afA);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the solid color of the skybox rather than a texture.&lt;br /&gt;
&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the global fog.&lt;br /&gt;
&lt;br /&gt;
#''abActive''  - true = active, false = inactive&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogColor(float afR, float afG, float afB, float afA);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the color to use for the global fog.&lt;br /&gt;
&lt;br /&gt;
#''afR ''- red value&lt;br /&gt;
#''afG ''- green value&lt;br /&gt;
#''afB ''- blue value&lt;br /&gt;
#''afA ''- alpha value&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetFogProperties(float afStart, float afEnd, float afFalloffExp, bool abCulling);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the properties for the global fog.&lt;br /&gt;
&lt;br /&gt;
#''afStart ''- how many meters from the camera should the fog begin&lt;br /&gt;
#''afEnd ''- how many meters from the camera should the fog reach full thickness&lt;br /&gt;
#''afFalloffExp ''- the amount by which the thinkness increases&lt;br /&gt;
#''abCulling ''- whether occlusion culling is active for the fog; this prevents objects behind the fog from being loaded&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetupLoadScreen(string&amp;amp;asTextCat, string&amp;amp;asTextEntry, int alRandomNum, string&amp;amp;asImageFile);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which loading screen will be shown when changing maps.&lt;br /&gt;
&lt;br /&gt;
#''asTextCat ''- the category of the loading text in the .lang file to be shown on the loading screen&lt;br /&gt;
#''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
#''alRandomNum ''- if greater 1, then it will randomize between 1 and alRandom for each LoadScreen giving entry the suffix XX (eg 01). If &amp;lt; =1 then no suffix is added&lt;br /&gt;
#''asImageFile ''- the image to be shown (optional)&lt;br /&gt;
&lt;br /&gt;
===Game Timer===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddTimer(string&amp;amp; asName, float afTime, string&amp;amp; asFunction);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates a timer which calls a function when it expires. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asTimer)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#''asName ''- the name of the timer&lt;br /&gt;
#''afTime ''- time in seconds&lt;br /&gt;
#''asFunction ''- the function to call&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveTimer(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes a timer, no matter how much time is left.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - the internal name of the timer.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetTimerTimeLeft(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the time left on a timer.&lt;br /&gt;
&lt;br /&gt;
#''asName''  - the internal name of the timer.&lt;br /&gt;
&lt;br /&gt;
===Screen Effects===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeOut(float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to black.&lt;br /&gt;
&lt;br /&gt;
''afTime ''- time in seconds until the screen is completly black&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeIn(float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen back to normal.&lt;br /&gt;
&lt;br /&gt;
''afTime ''- time in seconds until the screen back to normal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeImageTrailTo(float afAmount, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applies the image trail effect to the screen.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeSepiaColorTo(float afAmount, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the screen go dark red.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadeRadialBlurTo(float afSize, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Applies radial blur effects to the screen.&lt;br /&gt;
&lt;br /&gt;
''afSize ''- intensity (default: 0) &amp;lt;br /&amp;gt;''afSpeed ''- time in seconds until full effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetRadialBlurStartDist(float afStartDist);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines at which distance the radial blur effects appear.&lt;br /&gt;
&lt;br /&gt;
''afStartDist ''- the distance at which the effect starts&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartEffectFlash(float afFadeIn, float afWhite, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to white.&lt;br /&gt;
&lt;br /&gt;
''afFadeIn ''- time in seconds until screen is white &amp;lt;br /&amp;gt;''afWhite ''- determines to which percentage the screen fades to white (1.0 = completly white) &amp;lt;br /&amp;gt;''afFadeOut ''- time in seconds until screen is back to normal again&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartEffectEmotionFlash(string&amp;amp; asTextCat, string&amp;amp; asTextEntry, string&amp;amp; asSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Fades the screen to white and shows a text message.&lt;br /&gt;
&lt;br /&gt;
''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the text entry in the .lang file &amp;lt;br /&amp;gt;''asSound ''- the sound to play while fading&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddEffectVoice(string&amp;amp; asVoiceFile, string&amp;amp; asEffectFile, string&amp;amp; asTextCat, string&amp;amp; asTextEntry,&lt;br /&gt;
bool abUsePosition, string&amp;amp; asPosEntity, float afMinDistance, float afMaxDistance);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This adds a voice and an effect to be played. It is okay to call this many times in order to play many voices in a row. The EffectVoiceOverCallback is not called until ALL voices have finished.&lt;br /&gt;
&lt;br /&gt;
''asVoiceFile ''- the voice to play &amp;lt;br /&amp;gt;''asEffectFile ''- the effect to play &amp;lt;br /&amp;gt;''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the text entry in the .lang file &amp;lt;br /&amp;gt;''abUsePosition ''- plays using 3D from the entity, or without 3D &amp;lt;br /&amp;gt;''asPosEntity ''- the entity at which the effect appears &amp;lt;br /&amp;gt;''afMinDistance ''- minimum distance to see the effect &amp;lt;br /&amp;gt;''afMaxDistance ''- maximum distance to see the effect&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopAllEffectVoices(float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops all voices and calls the EffectVoiceOverCallback.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEffectVoiceActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether EffectVoices are still active.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetEffectVoiceOverCallback(string&amp;amp; asFunc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the function to be called when the EffectVoices are finished. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetFlashbackIsActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a flashback is still in effect.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPlayerSpawnPS(string&amp;amp; asSPSFile);&lt;br /&gt;
void StopPlayerSpawnPS();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuously spawn regular particle systems (''.ps'') around the player. Particles created by this script carry over from map to map. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;''asSPSFile''  - the ''.sps''  file to use. Exemplary ''.sps''  files are located in the ''/misc''  folder in the main game directory. &amp;lt;br /&amp;gt; &amp;lt;br /&amp;gt;Custom ''.sps''  files can be created by hand in a text editor (see existing ones and mimic how those are written). &amp;lt;br /&amp;gt;Since ''StopPlayerSpawnPS()''  doesn't seem to work, to stop an SPS you must create an ''.sps''  file with an empty particle field field and override the old SPS by calling ''StartPlayerSpawnPS''  again.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlayGuiSound(string&amp;amp; asSoundFile, float afVolume);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plays a sound, not using 3D.&lt;br /&gt;
&lt;br /&gt;
''asSoundFile ''- the sound to play (extension is .snt) &amp;lt;br /&amp;gt;''afVolume ''- the volume of the sound&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartScreenShake(float afAmount, float afTime, float afFadeInTime, float afFadeOutTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Shakes the screen.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- intensity of the shake &amp;lt;br /&amp;gt;''afTime ''- duration of the shake &amp;lt;br /&amp;gt;''afFadeInTime ''- time in seconds until full intensity is reached &amp;lt;br /&amp;gt;''afFadeOutTime ''- time until screen is back to normal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInDarknessEffectsActive(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables the sanity drain and night vision effects while in the darkness.&lt;br /&gt;
&lt;br /&gt;
''bool abX''  - Enable/disable effects.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.5}}&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen.&lt;br /&gt;
&lt;br /&gt;
''asImageName'' - The image file to render (.jpg, .png, .tga, .dds)&lt;br /&gt;
&lt;br /&gt;
''afX'' - The X position of the image&lt;br /&gt;
&lt;br /&gt;
''afY'' - The Y position of the image&lt;br /&gt;
&lt;br /&gt;
''afScale'' - The size of the image in pixels (not scale)&lt;br /&gt;
&lt;br /&gt;
''abUseRelativeCoordinates'' - Whether X and Y are relative to the screen resoltion, or pixel co-ordinates if not&lt;br /&gt;
&lt;br /&gt;
''afDuration'' - The duration that the image is displayed for&lt;br /&gt;
&lt;br /&gt;
''afFadeIn'' - The time, in seconds, to fade in the image&lt;br /&gt;
&lt;br /&gt;
''afFadeOut'' - The time, in seconds, to fade out the image&lt;br /&gt;
&lt;br /&gt;
See [[HPL2/Tutorials/ShowScreenImage()|ShowScreenImage()]] in the tutorials section for more information.&lt;br /&gt;
&lt;br /&gt;
===Insanity===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInsanitySetEnabled(string&amp;amp; asSet, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which InsanitySets are enabled.&lt;br /&gt;
&lt;br /&gt;
''asSet ''- the set &amp;lt;br /&amp;gt;''abX ''- enabled or not&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartInsanityEvent(string &amp;amp;in asEventName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Starts a specified insanity event.&lt;br /&gt;
&lt;br /&gt;
''asEventName ''- Insanity event to play.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartRandomInsanityEvent();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts a random insanity event from the available sets.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StopCurrentInsanityEvent();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Stops the currently playing insanity event.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void InsanityEventIsActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether an insanity event is currently in effect… Or so it was supposed to be, but as it doesn't return a value, we can never know [http://wiki.frictionalgames.com/lib/images/smileys/icon_smile.gif?nolink&amp;amp;15x15]&lt;br /&gt;
&lt;br /&gt;
===Player===&lt;br /&gt;
&lt;br /&gt;
Note that the player's maximum health and sanity is 100.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerActive(bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enabled/Disable player controlled movement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ChangePlayerStateToNormal();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets certain effects back to normal. It can for example make the player drop an item.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerCrouching(bool abCrouch);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the player to crouch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddPlayerBodyForce(float afX, float afY, float afZ, bool abUseLocalCoords);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Pushes the player into a certain direction. Note that you need values above ~2000 to see any effects.&lt;br /&gt;
&lt;br /&gt;
''afX ''- amount along the X-axis &amp;lt;br /&amp;gt;''afY ''- amount along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- amount along the Z-axis &amp;lt;br /&amp;gt;''abUseLocalCoords ''- If true, axes are based on where the player is facing, not the world.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowPlayerCrossHairIcons(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the icons when a player has something in focus.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerSanity(float afSanity);&lt;br /&gt;
void AddPlayerSanity(float afSanity);&lt;br /&gt;
float GetPlayerSanity();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the sanity of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerHealth(float afHealth);&lt;br /&gt;
void AddPlayerHealth(float afHealth);&lt;br /&gt;
float GetPlayerHealth();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the health of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerLampOil(float afOil);&lt;br /&gt;
void AddPlayerLampOil(float afOil);&lt;br /&gt;
float GetPlayerLampOil();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the lamp oil of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerSpeed();&lt;br /&gt;
float GetPlayerYSpeed();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the current speed of the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetSanityDrainDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables sanity drain from darkness, monsters, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveSanityBoost();&lt;br /&gt;
void GiveSanityBoostSmall();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Boosts the player's sanity by a fixed amount.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveSanityDamage(float afAmount, bool abUseEffect);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduces the sanity of the player.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount of sanity damage done &amp;lt;br /&amp;gt;''abUseEffect ''- determines whether an effect is played when the sanity damage is dealt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GivePlayerDamage(float afAmount, string&amp;amp; asType, bool abSpinHead, bool abLethal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reduces the health of the player.&lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount of damage done to health &amp;lt;br /&amp;gt;''asType ''- plays a certain effect on the screen when the damage is dealt (BloodSplat, Claws or Slash) &amp;lt;br /&amp;gt;''abSpinHead ''- changes the camera view when damage is dealt &amp;lt;br /&amp;gt;''abLethal ''- set to true if player can die from given damage&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerFOVMulTo(float afX, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the field of view of the player. A shorter FOV will create a zoom effect.&lt;br /&gt;
&lt;br /&gt;
''afX ''- multiplier of default FOV (1 is default) &amp;lt;br /&amp;gt;''afSpeed ''- the speed of change between FOV's&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerAspectMulTo(float afX, float afSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the aspect ratio of the player. Basically stretches or narrows the screen horizontally.&lt;br /&gt;
&lt;br /&gt;
''afX ''- multiplier of default aspect (default is 1) &amp;lt;br /&amp;gt;''afSpeed ''- the speed of change between FOV's&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void FadePlayerRollTo(float afX, float afSpeedMul, float afMaxSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rotates the position of the camera on the player's body.&lt;br /&gt;
&lt;br /&gt;
''afX ''- angle of rotation of head, positive being counter-clockwise &amp;lt;br /&amp;gt;''afSpeedMul ''- speed (possibly acceleration) multiplier of the rotation (default 1, which is really slow) &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed of rotation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void MovePlayerHeadPos(float afX, float afY, float afZ, float afSpeed, float afSlowDownDist);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the position of the camera on the player's body.&lt;br /&gt;
&lt;br /&gt;
''afX ''- amount along the X-axis &amp;lt;br /&amp;gt;''afY ''- amount along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- amount along the Z-axis &amp;lt;br /&amp;gt;''afSpeed ''- speed at which the change happens &amp;lt;br /&amp;gt;''afSlowDownDist ''- distance at which to start slowing down (prevents the head from abruptly stopping)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void StartPlayerLookAt(string&amp;amp; asEntityName, float afSpeedMul, float afMaxSpeed, string&amp;amp; asAtTargetCallback);&lt;br /&gt;
void StopPlayerLookAt();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Forces the player to look at a certain entity until StopPlayerLookAt is used.&lt;br /&gt;
&lt;br /&gt;
''asEntityName ''- the entity to look at &amp;lt;br /&amp;gt;''afSpeedMul ''- how fast should the player look at the entity &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed allowed &amp;lt;br /&amp;gt;''asAtTargetCallback ''- function to call when player looks at target&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerMoveSpeedMul(float afMul);&lt;br /&gt;
void SetPlayerRunSpeedMul(float afMul);&lt;br /&gt;
void SetPlayerLookSpeedMul(float afMul);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the player's move/run/look speed. Default is 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerJumpForceMul(float afMul);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Changes the player's jump multiplier. Higher values = higher jumps. Default is 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerJumpDisabled(bool abX);&lt;br /&gt;
void SetPlayerCrouchDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the player's ability to jump/crouch.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportPlayer(string&amp;amp; asStartPosName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instantly teleports the player to the target StartPos.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternActive(bool abX, bool abUseEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the player use his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool GetLanternActive();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the player currently uses his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables/Disables the player's ability to use his lantern.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetLanternLitCallback(string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the function to call when the player uses his lantern. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;MyFunc(bool abLit)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetMessage(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a message on the screen.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTime ''- determines how long the message is displayed. If time is &amp;lt; =0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetDeathHint(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the message that appears when the player dies.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void DisableDeathStartSound();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the death sound when the player dies. This must be called directly before player is killed! The variable as soon as player dies too.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;&amp;quot;&amp;gt;&lt;br /&gt;
void MovePlayerForward(float afAmount)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;REQUIRES THE 1.2 PATCH: JUSTINE&amp;quot; Moves the player forward. It needs to be called in a timer that updates 60 times / second.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerFallDamageDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables the player's ability to take fall damage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetPlayerPos(float afX, float afY, float afZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Sets the player's position within the level.&lt;br /&gt;
&lt;br /&gt;
''afX''  - X co-ordinate position. &amp;lt;br /&amp;gt;''afY''  - Y co-ordinate position. &amp;lt;br /&amp;gt;''afZ''  - Z co-ordinate position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float GetPlayerPosX();&lt;br /&gt;
float GetPlayerPosY();&lt;br /&gt;
float GetPlayerPosZ();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the player's position within the level on the specified axis.&lt;br /&gt;
&lt;br /&gt;
===Journal===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddNote(string&amp;amp; asNameAndTextEntry, string&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a note to the player's journal.&lt;br /&gt;
&lt;br /&gt;
''asNameAndTextEntry ''- entries in the .lang file. Must end with _Name and _Text and be in category &amp;quot;Journal&amp;quot;! &amp;lt;br /&amp;gt;''asImage ''- the background image to be used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddDiary(string&amp;amp; asNameAndTextEntry, string&amp;amp; asImage);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a diary to the player's journal.&lt;br /&gt;
&lt;br /&gt;
''asNameAndTextEntry ''- entries in the .lang file. Must end with _NameX and _TextY whereas X and Y are numbers of the parts (_Name1: first diary, _Text1: first page) and be in category &amp;quot;Journal&amp;quot;! &amp;lt;br /&amp;gt;''asImage ''- the background image to be used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ReturnOpenJournal(bool abOpenJournal);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Only called in the pickup diary callback! If true the journal displays the entry else not.&lt;br /&gt;
&lt;br /&gt;
===Quests===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddQuest(string&amp;amp; asName, string&amp;amp; asNameAndTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a quest to the player's journal under mementos.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name to be used &amp;lt;br /&amp;gt;''asNameAndTextEntry ''- entry in the .lang file. Must start with &amp;quot;Quest_&amp;lt;texthere&amp;gt;_Text”, and be in category “Journal”!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void CompleteQuest(string&amp;amp; asName, string&amp;amp; asNameAndTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Completes a quest.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name of the quest &amp;lt;br /&amp;gt;''asNameAndTextEntry ''- entry in the .lang file. Must start with &amp;quot; Quest_&amp;lt;texthere&amp;gt;_Text ”, and be in category “Journal”!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool QuestIsCompleted(string&amp;amp; asName);&lt;br /&gt;
bool QuestIsAdded(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a quest is completed/added.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetNumberOfQuestsInMap(int alNumberOfQuests);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets the number of quests in the map.&lt;br /&gt;
&lt;br /&gt;
''alNumberOfQuests ''- Amount of Quests&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveHint(string&amp;amp; asName, string&amp;amp; asMessageCat, string&amp;amp; asMessageEntry, float afTimeShown);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a hint on the player's screen.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name &amp;lt;br /&amp;gt;''asMessageCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asMessageEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTimeShown ''- time in seconds until the message disappears. If time is &amp;lt;= 0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void BlockHint(string&amp;amp; asName);&lt;br /&gt;
void UnBlockHint(string&amp;amp; asName);&lt;br /&gt;
void RemoveHint(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Blocking a hint prevents it from being shown. Blocked hints are included in savefiles, so they should persist between levels.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Removing&amp;quot; a hint actually removes it from the list of already given hints, thus allowing it to show up again.&lt;br /&gt;
&lt;br /&gt;
''asName ''- the internal name. Basic game hints use the same name as their respective lang entries, with the exception of &amp;quot;numbered&amp;quot; hints. For example, &amp;lt;code&amp;gt;EntityGrab&amp;lt;/code&amp;gt; blocks the &amp;lt;code&amp;gt;EntityGrab01&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;EntityGrab02&amp;lt;/code&amp;gt; entries.&lt;br /&gt;
&lt;br /&gt;
===Inventory===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ExitInventory();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exits the inventory by force.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInventoryDisabled(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables the player's ability to open his inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void SetInventoryMessage(string&amp;amp; asTextCategory, string&amp;amp; asTextEntry, float afTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a message at the bottom of the inventory screen.&lt;br /&gt;
&lt;br /&gt;
''asTextCategory ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file &amp;lt;br /&amp;gt;''afTime ''- time in seconds until the message disappears. If life time is &amp;lt;= 0 then the life time is calculated based on string length.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveItem(string&amp;amp; asName, string&amp;amp; asType, string&amp;amp; asSubTypeName, string&amp;amp; asImageName, float afAmount);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds an item to the inventory of the player. Note that the item does not have to exist as entity in the world to be able to do this.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asType ''- item type to give, Available types are: &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Puzzle&lt;br /&gt;
*Lantern&lt;br /&gt;
*Health&lt;br /&gt;
*Sanity&lt;br /&gt;
*LampOil&lt;br /&gt;
*Tinderbox&lt;br /&gt;
&lt;br /&gt;
''asSubTypeName ''- item name for .lang file &amp;lt;br /&amp;gt;''asImageName ''- the image which will appear in inventory. For example: &amp;lt;code&amp;gt;void GiveItem(&amp;quot;chemical_container_full_1&amp;quot;, &amp;quot;Puzzle&amp;quot;, &amp;quot;chemical_container_full&amp;quot;, &amp;quot;chemical_container_full.tga&amp;quot;, 1);&amp;lt;/code&amp;gt; will use the image from &amp;lt;code&amp;gt;graphics/item/chemical_container_full.tga&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
''afAmount ''- amount the item gives, - For example: Oil potions will fill the oil meter by this amount, Health potions will heal by this amount, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveItem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an item from the player's inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
bool HasItem(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether the player has an item in his inventory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void GiveItemFromFile(string&amp;amp; asName, string&amp;amp; asFileName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a single item to the player's inventory. This is meant to be used for debug mostly as it creates the actual item and then destroys it.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asFileName ''- item to give + extension (.ent)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddCombineCallback(string&amp;amp; asName, string&amp;amp; asItemA, string&amp;amp; asItemB, string&amp;amp; asFunction, bool abAutoRemove);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to combine items in his inventory. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asItemA, string &amp;amp;in asItemB)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name for the callback &amp;lt;br /&amp;gt;''asItemA ''- internal name of first item &amp;lt;br /&amp;gt;''asItemB ''- internal name of second item &amp;lt;br /&amp;gt;''asFunction ''- the function to call &amp;lt;br /&amp;gt;''abAutoRemove ''- determines whether the callback should be removed when the items are combined&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveCombineCallback(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes a combine callback. &amp;lt;br /&amp;gt;''asName''  - the internal name of the callback to be removed (as specified in AddCombineCallback)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void AddUseItemCallback(string&amp;amp; asName, string&amp;amp; asItem, string&amp;amp; asEntity, string&amp;amp; asFunction, bool abAutoDestroy);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to use items on the world. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asItem, string &amp;amp;in asEntity)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asItem ''- internal name of the item &amp;lt;br /&amp;gt;''asEntity ''- entity to be able to use the item on &amp;lt;br /&amp;gt;''asFunction ''- function to call &amp;lt;br /&amp;gt;''abAutoDestroy ''- determines whether the item is destroyed when used&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveUseItemCallback(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an item callback.&lt;br /&gt;
&lt;br /&gt;
===Entities===&lt;br /&gt;
&lt;br /&gt;
====General====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityActive(string&amp;amp; asName, bool abActive);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates an entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityVisible(string &amp;amp;in asName, bool abVisible);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates an entity's visual mesh. The collision body remains.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity. &amp;lt;br /&amp;gt;''abActive''  - Activate/deactivate mesh.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntityExists(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether an entity exists.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityCustomFocusCrossHair(string&amp;amp; asName, string&amp;amp; asCrossHair);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes the crosshair that is used when focusing an entity.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCrossHair ''- desired crosshair, can be: Default (uses default), Grab, Push, Ignite, Pick, LevelDoor, Ladder&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void CreateEntityAtArea(string&amp;amp; asEntityName, string&amp;amp; asEntityFile, string&amp;amp; asAreaName, bool abFullGameSave);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Creates an entity at an area. When creating an enemy though, it cannot chase properly along PathNodes(using for example ShowEnemyPlayerPosition).&lt;br /&gt;
&lt;br /&gt;
''asEntityName ''- internal name &amp;lt;br /&amp;gt;''asEntityFile ''- entity to be used extension .ent &amp;lt;br /&amp;gt;''asAreaName ''- the area to create the entity at &amp;lt;br /&amp;gt;''abFullGameSave ''- determines whether an entity &amp;quot;remembers&amp;quot; its state&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ReplaceEntity(string &amp;amp;in asName, string &amp;amp;in asBodyName, string &amp;amp;in asNewEntityName, string &amp;amp;in asNewEntityFile, bool abFullGameSave);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Removes an entity and places a new one in its place.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to replace. &amp;lt;br /&amp;gt;''asBodyName''  - Name of the body of the entity to place the new entity at. If empty the first body is used (might be buggy, recommended to name a body anyway). &amp;lt;br /&amp;gt;''asNewEntityName''  - Name of the new entity. &amp;lt;br /&amp;gt;''asNewEntityFile''  - Name of the new entity file. Extension .ent. &amp;lt;br /&amp;gt;''abFullGameSave''  - Whether ALL properties of this entity should be saved throughout levels.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void PlaceEntityAtEntity(string &amp;amp;in asName, string &amp;amp;in asTargetEntity, string &amp;amp;in asTargetBodyName, bool abUseRotation);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Places an entity at the position of another entity. Does not work for enemies, use TeleportEnemyToEntity instead.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to place. &amp;lt;br /&amp;gt;''asTargetEntity''  - Name of the other entity to place the first entity at. &amp;lt;br /&amp;gt;''asTargetBodyName''  - Name of the body of the entity to place the first entity at. If empty the first body is used (might be buggy, recommended to name a body anyway). &amp;lt;br /&amp;gt;''abUseRotation''  - Whether the entity should be rotated like the target entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPos(string &amp;amp;in asName, float afX, float afY, float afZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Moves an entity to a position in the level.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity to move. &amp;lt;br /&amp;gt;''afX''  - X co-ordinate position. &amp;lt;br /&amp;gt;''afY''  - Y co-ordinate position. &amp;lt;br /&amp;gt;''afZ''  - Z co-ordinate position.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
float GetEntityPosX(string &amp;amp;in asName);&lt;br /&gt;
float GetEntityPosY(string &amp;amp;in asName);&lt;br /&gt;
float GetEntityPosZ(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns an entity's position in the level on the specified axis.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPlayerLookAtCallback(string&amp;amp; asName, string&amp;amp; asCallback, bool abRemoveWhenLookedAt);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player looks at a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: 1 = looking, -1 = not looking&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCallback ''- function to call &amp;lt;br /&amp;gt;''abRemoveWhenLookedAt ''- determines whether the callback should be removed when the player looked at the entity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityPlayerInteractCallback(string&amp;amp; asName, string&amp;amp; asCallback, bool abRemoveOnInteraction);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player interacts with a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asCallback ''- function to call &amp;lt;br /&amp;gt;''abRemoveOnInteraction ''- determines whether the callback should be removed when the player interacts with the entity&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityCallbackFunc(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when the player interacts with a certain entity. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, string &amp;amp;in type)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;Type depends on entity type and includes: &amp;quot;OnPickup&amp;quot;, &amp;quot;Break&amp;quot;, &amp;quot;OnIgnite&amp;quot;, etc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityConnectionStateChangeCallback(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A callback called when ever the connection state changes (button being switched on, lever switched, etc). &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void Func(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: -1 = off, 0 = between, 1 = on&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetEntityInteractionDisabled(string&amp;amp; asName, bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disallows interaction with an entity.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void BreakJoint (string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Breaks a joint. Do not use this on joints in SwingDoors, Levers, Wheels, etc. where the joint is part of an interaction. That will make the game crash.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void AddEntityCollideCallback(string&amp;amp; asParentName, string&amp;amp; asChildName, string&amp;amp; asFunction, bool abDeleteOnCollide, int alStates);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when two entites collide. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asParent, string &amp;amp;in asChild, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;alState: 1 = enter, -1 = leave&lt;br /&gt;
&lt;br /&gt;
''asParentName ''- internal name of main object &amp;lt;br /&amp;gt;''asChildName ''- internal name of object that collides with main object (asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) NOT supported!) &amp;lt;br /&amp;gt;''asFunction ''- function to call &amp;lt;br /&amp;gt;''abDeleteOnCollide ''- determines whether the callback after it was called &amp;lt;br /&amp;gt;''alStates ''- 1 = only enter, -1 = only leave, 0 = both&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveEntityCollideCallback(string&amp;amp; asParentName, string&amp;amp; asChildName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Removes an EntityCollideCallback. Asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) not supported in ''asChildName''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetEntitiesCollide(string&amp;amp; asEntityA, string&amp;amp; asEntityB);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether two entites collide. This function does NOT support asterix (&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;) or &amp;quot;Player&amp;quot;!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetBodyMass(string &amp;amp;in asName, float afMass);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Sets the mass of an entity's body.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the body of an entity. The body name of an entity is EntityName_BodyName. &amp;lt;br /&amp;gt;''afMass''  - The mass to set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
float GetBodyMass(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Gets the mass of an entity's body.&lt;br /&gt;
&lt;br /&gt;
''asName''  - Name of the body of an entity. The body name of an entity is EntityName_BodyName. &amp;lt;br /&amp;gt;''afMass''  - The mass to get.&lt;br /&gt;
&lt;br /&gt;
====Props====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropEffectActive(string&amp;amp; asName, bool abActive, bool abFadeAndPlaySounds);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Can be used on coal to give it the black color it should have.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropActiveAndFade(string&amp;amp; asName, bool abActive, float afFadeTime);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates a prop.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''abActive ''- nothing to add &amp;lt;br /&amp;gt;''afFadeTime ''- time in seconds until prop fully fades&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropStaticPhysics(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates/deactivates the physics of a prop. Setting as true will make entities static in midair.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
bool GetPropIsInteractedWith(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a prop is interacted with.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void RotatePropToSpeed(string&amp;amp; asName, float afAcc, float afGoalSpeed, float afAxisX, float afAxisY, float afAxisZ, bool abResetSpeed, string&amp;amp; asOffsetArea);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Rotates the prop up to a set speed.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afAcc ''- acceleration &amp;lt;br /&amp;gt;''afGoalSpeed ''- desired speed &amp;lt;br /&amp;gt;''afAxisX ''- rotation around X axis &amp;lt;br /&amp;gt;''afAxisY ''- rotation around Y axis &amp;lt;br /&amp;gt;''afAxisZ ''- rotation around Z axis &amp;lt;br /&amp;gt;''abResetSpeed ''- determines whether the speed is resetted after goal speed is reached &amp;lt;br /&amp;gt;''asOffsetArea ''- the area to rotate around, if empty, then the center of the body is used Note: The entity you want to rotate MUST be a &amp;quot;StaticObject&amp;quot; entity!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void StopPropMovement(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Stops all movement of a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddAttachedPropToProp(string&amp;amp; asPropName, string&amp;amp; asAttachName, string&amp;amp; asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to another prop.&lt;br /&gt;
&lt;br /&gt;
a''sPropName''- the prop to attach another prop at &amp;lt;br /&amp;gt;''asAttachName ''- internal name of the prop that gets attached &amp;lt;br /&amp;gt;''asAttachFile ''- the prop that gets attached extension .ent &amp;lt;br /&amp;gt;''afPosX ''- X position of the attach from the prop &amp;lt;br /&amp;gt;''afPosY ''- Y position of the attach from the prop &amp;lt;br /&amp;gt;''afPosZ ''- Z position of the attach from the prop &amp;lt;br /&amp;gt;''afRotX ''- rotation around X axis of the attach &amp;lt;br /&amp;gt;''afRotY ''- rotation around Y axis of the attach &amp;lt;br /&amp;gt;''afRotZ ''- rotation around ZX axis of the attach Note: for the purposes of &amp;quot;AddEntityCollideCallback&amp;quot;, attached props will not call the callback function if they collide with a &amp;quot;static_object&amp;quot; or a &amp;quot;StaticProp&amp;quot; entity type!&lt;br /&gt;
&lt;br /&gt;
{{bug|''afRotZ '' is used for both the ZX rotation and the Z position of the attached prop. Unwanted rotation can be avoided by using: &amp;lt;br /&amp;gt;''AddAttachedPropToProp(asPropName, asAttachName, asAttachFile, afPosX, afPosY, '''0''', afPosZ, '''90.0f''', afPosZ)''}}&lt;br /&gt;
&lt;br /&gt;
{{bug|Attaching a breakable prop to a physically active prop, and then breaking the attached prop, will cause the game to crash, should the parent object be moved or reset.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToProp(string&amp;amp; asPropName, string&amp;amp; asAttachName, string&amp;amp; asAttachFile, float afPosX, float afPosY, float afPosZ, float afRotX, float afRotY, float afRotZ);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Attaches a prop to another prop. Fixed version of AddAttachedPropToProp.&lt;br /&gt;
&lt;br /&gt;
''asPropName ''- the prop to attach another prop at &amp;lt;br /&amp;gt;''asAttachName ''- internal name of the prop that gets attached &amp;lt;br /&amp;gt;''asAttachFile ''- the prop that gets attached extension .ent &amp;lt;br /&amp;gt;''afPosX ''- X position of the attach from the prop &amp;lt;br /&amp;gt;''afPosY ''- Y position of the attach from the prop &amp;lt;br /&amp;gt;''afPosZ ''- Z position of the attach from the prop &amp;lt;br /&amp;gt;''afRotX ''- rotation around X axis of the attach &amp;lt;br /&amp;gt;''afRotY ''- rotation around Y axis of the attach &amp;lt;br /&amp;gt;''afRotZ ''- rotation around ZX axis of the attach Note: for the purposes of &amp;quot;AddEntityCollideCallback&amp;quot;, attached props will not call the callback function if they collide with a &amp;quot;static_object&amp;quot; or a &amp;quot;StaticProp&amp;quot; entity type!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void RemoveAttachedPropFromProp(string&amp;amp; asPropName, string&amp;amp; asAttachName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches a prop from a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropHealth(string&amp;amp; asName, float afHealth);&lt;br /&gt;
void AddPropHealth(string&amp;amp; asName, float afHealth);&lt;br /&gt;
float GetPropHealth(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Modifies/returns the health of a prop.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ResetProp(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Resets a prop's state to the original one when the map was loaded.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void PlayPropAnimation(string&amp;amp; asProp, string&amp;amp; asAnimation, float afFadeTime, bool abLoop, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the prop play an animation and calls a function. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asProp)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''asProp ''- internal name of the prop &amp;lt;br /&amp;gt;''asAnimation ''- animation to play &amp;lt;br /&amp;gt;''afFadeTime ''- ? &amp;lt;br /&amp;gt;''abLoop ''- determines whether the animation loops &amp;lt;br /&amp;gt;''asCallback ''- function to call&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddPropForce(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddPropImpulse(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddBodyForce(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
void AddBodyImpulse(string&amp;amp; asName, float afX, float afY, float afZ, string&amp;amp; asCoordSystem);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These functions push objects. Note that rather high values are needed when applying ''forces''  (on the order of ~100 (weak) to ~10000 (strong)), but not impulses (values less than 10 can be appropriate). Forces are external influences, and will have different effect depending on the mass of the object they are being applied to; impulses disregard mass, and can cause objects to break, as if hit. A &amp;quot;Body&amp;quot; is a physics-related helper object, to which a force or an impulse can be applied. Entities can consist of several bodies, interconnected in various ways (you can create/examine bodies in the model editor).&lt;br /&gt;
&lt;br /&gt;
''asName ''- the object to push; for bodies, use this format: &amp;quot;''entityName''_''bodyName''&amp;quot; &amp;lt;br /&amp;gt;''afX ''- magnitude along the X-axis &amp;lt;br /&amp;gt;''afY ''- magnitude along the Y-axis &amp;lt;br /&amp;gt;''afZ ''- magnitude along the Z-axis &amp;lt;br /&amp;gt;''asCoordSystem ''- determines which coordinate system is used, usually &amp;quot;world&amp;quot; All of these functions are ''additive''  - when called consecutively, for each call, the vectors defined by (afX, afY, afZ) will be added together, and a resultant force/impulse will be calculated ''before''  any physics simulation is applied to the target object.&lt;br /&gt;
&lt;br /&gt;
====Connections====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void InteractConnectPropWithRope(string&amp;amp; asName, string&amp;amp; asPropName, string&amp;amp; asRopeName, bool abInteractOnly, float afSpeedMul, float afToMinSpeed, float afToMaxSpeed, bool abInvert, int alStatesUsed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Connects a prop with the movement of a rope (ie. turn wheel to move rope).&lt;br /&gt;
&lt;br /&gt;
''asName ''- connection name &amp;lt;br /&amp;gt;''asPropName ''- name of prop &amp;lt;br /&amp;gt;''asRopeName ''- name of rope &amp;lt;br /&amp;gt;''abInteractOnly ''- ? &amp;lt;br /&amp;gt;''afSpeedMul ''- speed multiplier of how quickly the rope moves &amp;lt;br /&amp;gt;''afToMinSpeed ''- the slowest the rope will move when moving the prop &amp;lt;br /&amp;gt;''afToMaxSpeed ''- the fastest the rope will move when moving the prop &amp;lt;br /&amp;gt;''abInvert ''- whether to invert the direction the rope moves &amp;lt;br /&amp;gt;''alStatesUsed ''- which states of the prop can interact with the rope?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void InteractConnectPropWithMoveObject(string&amp;amp; asName, string&amp;amp; asPropName, string&amp;amp; asMoveObjectName, bool abInteractOnly, bool abInvert, int alStatesUsed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This one should only be used if there must be an exact correspondance to prope &amp;quot;amount&amp;quot; and the moveobject open amount. It is best used for Wheel-door connections!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ConnectEntities(string&amp;amp; asName, string&amp;amp; asMainEntity, string&amp;amp; asConnectEntity, bool abInvertStateSent, int alStatesUsed, string&amp;amp; asCallbackFunc);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asConnectionName, string &amp;amp;in asMainEntity, string &amp;amp;in asConnectEntity, int alState)&amp;lt;/code&amp;gt;  &amp;lt;br /&amp;gt;State is what is sent to connection entity and will be inverted if abInvertStateSent = true!&lt;br /&gt;
&lt;br /&gt;
====Lamps====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLampLit(string&amp;amp; asName, bool abLit, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(Un)lits a lamp.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Name of the lamp &amp;lt;br /&amp;gt;''abLit ''- Set true if you want the lamp to be lit, set to false if you want the lamp to be unlit &amp;lt;br /&amp;gt;''abEffects ''- If you want to have the lamp fade in/out when it gets (un)lit&lt;br /&gt;
&lt;br /&gt;
====Doors====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorLocked(string&amp;amp; asName, bool abLocked, bool abEffects);&lt;br /&gt;
void SetSwingDoorClosed(string&amp;amp; asName, bool abClosed, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Locks/closes a swing door.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GetSwingDoorLocked(string&amp;amp; asName);&lt;br /&gt;
bool GetSwingDoorClosed(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Checks whether a swing door is locked/closed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetSwingDoorDisableAutoClose(string&amp;amp; asName, bool abDisableAutoClose);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deactivates the &amp;quot;auto-close&amp;quot; when a door is nearly closed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetSwingDoorState(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns an integer depending on how far the door is opened. &amp;lt;br /&amp;gt;-1 = angle is close to 0°, 1 = angle is 70% or higher of max, 0 = inbetween -1 and 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLocked(string&amp;amp; asName, bool abLocked);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Locks a level door. Note that level doors are NOT swing doors.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLockedSound(string&amp;amp; asName, string&amp;amp; asSound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Determines which sound is played when interacting with a locked level door.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetLevelDoorLockedText(string&amp;amp; asName, string&amp;amp; asTextCat, string&amp;amp; asTextEntry);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays a message when interacting with a locked level door.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''asTextCat ''- the category in the .lang file &amp;lt;br /&amp;gt;''asTextEntry ''- the entry in the .lang file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMoveObjectState(string&amp;amp; asName, float afState);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves an object to a certain state.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afState ''- state of the object, 0 = closed, 1 = open, values inbetween (and above, for example, the bridge_metal_vert) are valid too!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMoveObjectStateExt(string&amp;amp; asName, float afState, float afAcc, float afMaxSpeed, float afSlowdownDist, bool abResetSpeed);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves an object to a certain state, extended method.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afState ''- state of the object, 0 = closed, 1 = open, values inbetween are valid too! &amp;lt;br /&amp;gt;''afAcc ''- acceleration &amp;lt;br /&amp;gt;''afMaxSpeed ''- maximum speed &amp;lt;br /&amp;gt;''afSlowdownDist ''- Distance to the target state before decceleration occurs. &amp;lt;br /&amp;gt;''abResetSpeed ''- Set to True if the prop's speed should be reset before performing the movement, else the prop will accelerate from it's current speed to afMaxSpeed.&lt;br /&gt;
&lt;br /&gt;
====Levers, wheels and buttons====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetPropObjectStuckState(string&amp;amp; asName, int alState);&lt;br /&gt;
void SetWheelStuckState(string&amp;amp; asName, int alState, bool abEffects);&lt;br /&gt;
void SetLeverStuckState(string&amp;amp; asName, int alState, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes a prop&amp;lt;nowiki&amp;gt;\&amp;lt;/nowiki&amp;gt;wheel&amp;lt;nowiki&amp;gt;\&amp;lt;/nowiki&amp;gt;lever stuck in a certain state.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''alState ''- 0 = not stuck, 1 = at max, -1 = at min &amp;lt;br /&amp;gt;''abEffects ''- use effects&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetWheelAngle(string&amp;amp; asName, float afAngle, bool abAutoMove);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Moves a wheel to a certain angle.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name &amp;lt;br /&amp;gt;''afAngle ''- angle &amp;lt;br /&amp;gt;''abAutoMove ''- determines whether the wheel should move on its own&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetWheelInteractionDisablesStuck(string&amp;amp; asName, bool abX);&lt;br /&gt;
void SetLeverInteractionDisablesStuck(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows the player to make a wheel/lever unstuck when interacted with.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetLeverState(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns the state of the lever. &amp;lt;br /&amp;gt;0 = not stuck, 1 = at max, -1 = at min&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMultiSliderStuckState(string&amp;amp; asName, int alStuckState, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes a MultiSlider stuck in a certain state.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetMultiSliderCallback(string&amp;amp; asName, string&amp;amp; asCallback);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Calls a function when state changes. &amp;lt;br /&amp;gt;Callback syntax: &amp;lt;code&amp;gt;void MyFunc(string &amp;amp;in asEntity, int alState)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetButtonSwitchedOn(string&amp;amp; asName, bool abSwitchedOn, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Sticky areas====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetAllowStickyAreaAttachment(bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Allows entites to stick to a StickyArea.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AttachPropToStickyArea(string&amp;amp; asAreaName, string&amp;amp; asProp);&lt;br /&gt;
void AttachBodyToStickyArea(string&amp;amp; asAreaName, string&amp;amp; asBody);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Attaches a prop/body to a StickyArea.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void DetachFromStickyArea(string&amp;amp; asAreaName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Detaches everything from a StickyArea.&lt;br /&gt;
&lt;br /&gt;
====Enemies====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNPCAwake(string&amp;amp; asName, bool abAwake, bool abEffects);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Activates the npc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNPCFollowPlayer(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sets an NPC's head to follow the player's movement's.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDisabled(string&amp;amp; asName, bool abDisabled);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Disables an enemy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyIsHallucination(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes an enemy a hallucination. Hallucinations fade to smoke when they get near the player.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void FadeEnemyToSmoke(string&amp;amp; asName, bool abPlaySound);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Instantly fades an enemy to smoke.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ShowEnemyPlayerPosition(string&amp;amp; asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Makes the enemy run to the player, no matter where he is.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AlertEnemyOfPlayerPresence(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Gives the specified enemy the player's current position and makes it search the area.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemyDisableTriggers(string&amp;amp; asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enables or disables enemy triggers. If disabled, enemy will not react to player or attack.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void AddEnemyPatrolNode(string&amp;amp; asName, string&amp;amp; asNodeName, float afWaitTime, string&amp;amp; asAnimation);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Adds a patrol node to the enemy's path.&lt;br /&gt;
&lt;br /&gt;
''asName ''- internal name of the enemy &amp;lt;br /&amp;gt;''asNodeName ''- path node &amp;lt;br /&amp;gt;''afWaitTime ''- time in seconds that the enemy waits at the path node before continuing &amp;lt;br /&amp;gt;''asAnimation ''- the animation the enemy uses when reaching the path node&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearEnemyPatrolNodes(string&amp;amp; asEnemyName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Clears the current path of patrol nodes of the enemy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetEnemySanityDecreaseActive(string &amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether an enemy activates the player's sanity drain when stared at.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX ''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportEnemyToNode(string &amp;amp;in asEnemyName, string &amp;amp;in asNodeName, bool abChangeY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Teleports an enemy to a specific PathNode.&lt;br /&gt;
&lt;br /&gt;
''asEnemyName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asNodeName ''- Internal name of the node to teleport to &amp;lt;br /&amp;gt;''abChangeY ''- Whether the Y position of the node will be used when teleporting the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void TeleportEnemyToEntity(string &amp;amp;in asEnemyName, string &amp;amp;in asTargetEntity, string &amp;amp;in asTargetBody, bool abChangeY);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Teleports an enemy to a specific entity.&lt;br /&gt;
&lt;br /&gt;
''asEnemyName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asTargetEntity ''- Internal name of the entity to teleport to &amp;lt;br /&amp;gt;''asTargetBody''- Internal name of the entity's body name to teleport to. If empty, the first body will be used (might be unstable, recommended to input a body anyway) &amp;lt;br /&amp;gt;''abChangeY ''- Whether the Y position of the node will be used when teleporting the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ChangeManPigPose(string&amp;amp;in asName, string&amp;amp;in asPoseType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Changes the pose a specified ManPig.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''asPoseType''- Name of the ManPig pose to use. Can be &amp;quot;Biped&amp;quot; or &amp;quot;Quadruped&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigFadeDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should fade the player's view in and out.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigSoundDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should play the proximity sounds.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void SetTeslaPigEasyEscapeDisabled(string&amp;amp;in asName, bool abX);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Enables/disables whether a specified TeslaPig should be easier to escape from when hunted.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy &amp;lt;br /&amp;gt;''abX''- Enabled/disabled&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
void ForceTeslaPigSighting(string&amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Forces a TeslaPig to be visible for a short time.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
string&amp;amp; GetEnemyStateName(string &amp;amp;in asName);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{ReqVer|1.3}}&lt;br /&gt;
&lt;br /&gt;
Returns the name of the state a specified enemy is current in. States can be Hunt, Search, Patrol, Wait, Alert, Investigate, Track and BreakDoor.&lt;br /&gt;
&lt;br /&gt;
''asName ''- Internal name of the enemy&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Tutorials&amp;diff=6677</id>
		<title>HPL2/Tutorials</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Tutorials&amp;diff=6677"/>
		<updated>2024-01-04T16:58:59Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added link to ShowScreenImage()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Text tutorials=&lt;br /&gt;
&lt;br /&gt;
This page lists a large amount of tutorials, most of which are community-made. Feel free to check them out and see if they can teach you something. If you've made a tutorial and wish to add it to this page, you can do so by editing it to the right. Just try to keep to the same format as the rest of the page.&lt;br /&gt;
&lt;br /&gt;
{{tip|If you can't find a tutorial for what you need, make sure to check the [[HPL2/Tools#Editors|Editor documentation]] and [[HPL2/TDD#Documentation|Engine documentation]].  An example of this would be the Particle Editor.}}&lt;br /&gt;
&lt;br /&gt;
==Level Editor==&lt;br /&gt;
&lt;br /&gt;
* [[:hpl2:tutorials:level_editor:tutorial_1|Tutorial 1]] - The minimum required to get a level that can load.&lt;br /&gt;
* [[:hpl2:tutorials:level_editor:tutorial_2|Tutorial 2]] - Placement of lights and advanced setup of lights.&lt;br /&gt;
* [[:hpl2:tutorials:level_editor:tutorial_3|Tutorial 3]] - How to make an outdoor environment. There's a [[Hpl2:Tutorials:level_editor:outdoors|newer version of i]]t available.&lt;br /&gt;
* [[:hpl2:tutorials:level_editor:tutorial_4|Tutorial 4]] - Explains how to make water.&lt;br /&gt;
* [[:hpl2:tutorials:level_editor:tutorial_5|Tutorial 5]] - Prop dimensions and detailing your map.&lt;br /&gt;
*[[Hpl2:Tutorials:level editor:tutorial 6|Tutorial 6]] - ???????&lt;br /&gt;
*[[HPL2/Tutorials/Skyboxes|Tutorial 7]] - Making skyboxes for HPL2&lt;br /&gt;
*[[HPL2/Tutorials/Level Design]] - Using all of the basic techniques to achieve good effects&lt;br /&gt;
* [[:hpl2:tutorials:level_editor:level_editor_101|Level Editor 101]] - All the basics and some more advanced techniques.&lt;br /&gt;
&lt;br /&gt;
==Model Editor==&lt;br /&gt;
&lt;br /&gt;
* [[:hpl2:tutorials:model_editor:tutorial_1|Basic tutorial]] - The minimum required to load a model as an entity with collision and game properties.&lt;br /&gt;
* [[:hpl2:tutorials:model_editor:tutorial_2|Creating Ragdoll Entities]] - How to create full physics-based entities.&lt;br /&gt;
* [[:hpl2:tutorials:model_editor:static_objects_jenniferorange|Making Items Static]] - How to change an items' properties to static.&lt;br /&gt;
* [[HPL2/Tutorials/Coin_chests | Coin chests]] - How to create chests that can be only opened with coins.&lt;br /&gt;
&lt;br /&gt;
==Material Editor==&lt;br /&gt;
&lt;br /&gt;
* [[:hpl2:tutorials:material_editor:tutorial_1|Tutorial 1]] - Basic materials and their properties.&lt;br /&gt;
* [[Hpl2:Tutorials:material editor:creating mirrors|Creating mirrors]] - make reflective surfaces using water materials&lt;br /&gt;
&lt;br /&gt;
==Game files==&lt;br /&gt;
* [[:hpl2:tutorials:script:CustomSounds|How to create Custom Sounds]] - Teaches how to create custom sounds for your custom story.&lt;br /&gt;
* [[:hpl2:tutorials:script:howtomakenotes|How to Create Notes and Journal Entries]] - Explains how to make journal entries and place them in a map&lt;br /&gt;
* [[HPL2/Tutorials/Porting MFP Assets|Porting MFP Assets]] - explains how to copy assets from MFP to TDD and avoid issues&lt;br /&gt;
* [[HPL2/Tutorials/Convert HDRI to skyboxes|Convert HDRI to skyboxes]]&lt;br /&gt;
&lt;br /&gt;
==Scripting tutorials==&lt;br /&gt;
General basics:&lt;br /&gt;
&lt;br /&gt;
*[[HPL2/Tutorials/Scripts/Debugging|Make your set-up comfortable for scripting]]&lt;br /&gt;
* [[:hpl2:tutorials:script:entihscript_beginner|Newbie's Guide to Scripting]] - A tutorial for those new to scripting, focusing on syntax and a few helpful hints - ''By 'Entih''&lt;br /&gt;
* [[:hpl2:tutorials:script:tutorial_1|Tutorial 1]] - Using a tutorial level, with some objects to make basic scripts.&lt;br /&gt;
* [[:hpl2:tutorials:scripting:messages_jenniferorange|Activating/Using Message Pop-Ups]] - Explains how to activate a message to appear when walking into a script area.&lt;br /&gt;
* [[:hpl2:tutorials:scripting:triggering_monsters_on_entities|Triggering monsters on entities]] - Explains how to trigger an event after picking up an item.&lt;br /&gt;
&lt;br /&gt;
Door-related script tutorials:&lt;br /&gt;
&lt;br /&gt;
* [[:hpl2:tutorials:script:scripting_by_xtron_-_item_that_unlocks_a_door|Item That Unlocks a Door]] - How to make an item that unlocks a certain door.&lt;br /&gt;
* [[:hpl2:tutorials:script:buttons_that_open_a_door|Buttons that open door]]s - Explains how to make buttons that open doors.&lt;br /&gt;
* [[:hpl2:tutorials:script:events|Scary door events]] - Explains how to make scary door events.&lt;br /&gt;
* [[:hpl2:tutorials:scripting:crowbartutorialjenniferorange|Using A Crowbar On A Door]] - Explains how to script a crowbar to blow open a door.&lt;br /&gt;
* [[:hpl2:tutorials:script:adding_messages_to_locked_doors|Adding Messages To Locked Doors]] - Explains how to display a message when a player tries to open a locked door.&lt;br /&gt;
&lt;br /&gt;
Useful coding practices:&lt;br /&gt;
&lt;br /&gt;
* [[:hpl2:tutorials:script:forloop|The &amp;quot;For&amp;quot; loop]] - Explains how and when to use the &amp;quot;for&amp;quot; loop.&lt;br /&gt;
* [[:hpl2:tutorials:script:advancedtimers|Advanced Timers]] - Explains how to use multiple timers in one function.&lt;br /&gt;
* [[:hpl2:tutorials:script:localandglobalvariables|Local and Global Variables]] - Explains what they are and how to use them correctly.&lt;br /&gt;
* [[:hpl2:tutorials:script:sequences|Scripting Sequences]] - Explains how to build simple and easy to use cutscenes, or sequences for your mod.&lt;br /&gt;
&lt;br /&gt;
Forces and impulses:&lt;br /&gt;
&lt;br /&gt;
* [[:hpl2:tutorials:script:force|Impulse and forces]] - Explains how to use force and impulse.&lt;br /&gt;
* [[:hpl2:tutorials:script:pushdoorsopen|Push doors open using force]] - Explains how to use Force to open doors and entities.&lt;br /&gt;
* [[Hpl2:Tutorials:level_editor:dynamic_curtains|Dynamic curtains]] - Using force to simulate wind&lt;br /&gt;
* [[:hpl2:tutorials:script:disable_gravity_tutorial|&amp;quot;Disable&amp;quot; gravity and make objects float]] - Make entities seem to float using timer functions and forces &lt;br /&gt;
&lt;br /&gt;
Other:&lt;br /&gt;
&lt;br /&gt;
* [[:hpl2:tutorials:script:monsterpathnodes|Monster Path Nodes]] - Explains how to set up a monster's path and how to trigger it.&lt;br /&gt;
* [[:hpl2:tutorials:script:levers_and_secretshelfs|Levers and secret bookshelves]] - Explains how to make a lever that opens a bookshelf.&lt;br /&gt;
* [[:hpl2:tutorials:scripting:scaresbyjenniferorange|Scares]] - Explains in as much detail as possible the multiple scares you can use without having to bring out the monsters.&lt;br /&gt;
* [[:hpl2:tutorials:level_editor:combininghammerchipperjenniferorange|Combining The Hammer And Chipper]] - Explains how to combine your hammer and chipper in your inventory.&lt;br /&gt;
* [[:hpl2:tutorials:scripting:checkpoints_using_scriptarea_s|Checkpoints using Areas]] - Explains how to make a checkpoint using Areas.&lt;br /&gt;
* [[:hpl2:tutorials:script:tutorialsformainmenu|How to create your own Main Menu Backgrounds!]] - The usability of Amnesia's .cfg files and its Editors&lt;br /&gt;
* [[HPL2/Tutorials/ShowScreenImage()|ShowScreenImage()]] - Some notes about the ShowScreenImage() function new to ATTD in version 1.5 (and also AAMFP).&lt;br /&gt;
&lt;br /&gt;
==Modeling==&lt;br /&gt;
&lt;br /&gt;
* [[:hpl2:tutorials:modeling:tutorialoutsource|Modeling tutorial]] - Initially written for outsourcers.&lt;br /&gt;
&lt;br /&gt;
=Video tutorials=&lt;br /&gt;
Sublists:&lt;br /&gt;
*[https://www.youtube.com/playlist?list=PLIYfl4qBRihBjRpmQL-izQ4xdAtLblU36 Large playlist of video tutorials for beginners and intermediate developers] - ''By Mudbill''&lt;br /&gt;
*[[Hpl2:Tutorials:script:elventutorials|Elven's tutorials]]&lt;br /&gt;
&lt;br /&gt;
==By Simpanra==&lt;br /&gt;
* [http://www.youtube.com/watch?v=CklTIT2W4g4 How To Make Level Door]&lt;br /&gt;
* [http://www.youtube.com/watch?v=ABI7NUqkXW0 How To Get a Key To Unlock a Door]&lt;br /&gt;
* [http://www.youtube.com/watch?v=v4WudNebX08 How To Make Water]&lt;br /&gt;
* [http://www.youtube.com/watch?v=ESISPLDbMWM How To Make a Custom Story Background]&lt;br /&gt;
* [http://www.youtube.com/watch?v=RmIKTH9YRqk How To Make a Functional and Interactable Ladder]&lt;br /&gt;
* [http://www.youtube.com/watch?v=riFwThqQ68k How To Name and Describe Keys]&lt;br /&gt;
* [http://www.youtube.com/watch?v=M5x_taEkP8s Simple Script Function]&lt;br /&gt;
==By Khyrpa==&lt;br /&gt;
* [http://www.youtube.com/watch?v=1R2F2eVmJ5k Building and Lighting in The Level Editor]&lt;br /&gt;
* [http://www.youtube.com/watch?v=d2ShkLEgGNk Lighting in Level Editor]&lt;br /&gt;
* [http://www.youtube.com/watch?v=u8EhP59tmjA Billboards]&lt;br /&gt;
* [http://www.youtube.com/watch?v=LKxzoAIK8jA Advanced Candle Light Connecting]&lt;br /&gt;
* [http://www.youtube.com/watch?v=xIDCoEZ581Q Wind Scare (Part 1)]&lt;br /&gt;
* [http://www.youtube.com/watch?v=Kj-NFkIGafI Wind Scare (Part 2)]&lt;br /&gt;
==By MulleDK19==&lt;br /&gt;
* [http://amnesia.treesoft.dk/tutorials/Tutorial1.wmv Make a key unlock a specific door]&lt;br /&gt;
* [http://amnesia.treesoft.dk/tutorials/Tutorial2.wmv How to create and use Areas or Triggers]&lt;br /&gt;
* [http://amnesia.treesoft.dk/tutorials/EditorTutorial1.wmv Using the Level Editor (Part 1)]&lt;br /&gt;
* [http://amnesia.treesoft.dk/tutorials/EditorTutorial2.wmv Using the Level Editor (Part 2)]&lt;br /&gt;
* [http://amnesia.treesoft.dk/tutorials/EditorTutorial3.wmv Using the Level Editor (Part 3)]&lt;br /&gt;
==By others==&lt;br /&gt;
* [http://www.youtube.com/watch?v=0grr7uipnk0 How To Create a Custom Story] - ''By TheVegaNVega''&lt;br /&gt;
* [http://www.youtube.com/watch?v=uGCTwQQSZ0A How To Make Journal Entries/Notes] - ''By RussMoney''&lt;br /&gt;
* [http://www.youtube.com/watch?v=WfgFEG4TSCE How To Make Journal Entries/Mementos] - ''By RussMoney''&lt;br /&gt;
* [http://www.youtube.com/watch?v=puIfVx0lslA How To Convert a Custom Story To a Full Conversion] - ''By RussMoney''&lt;br /&gt;
* [http://www.youtube.com/watch?v=9uKBYVEyw1s How to convert cube map images to DDS format in the GIMP] - ''By YourComputer''&lt;br /&gt;
* [http://www.youtube.com/playlist?list=PLD326789BC99530C8 From Noob to Pro: Amnesia Custom Story Creation Series] - ''By YourComputer''&lt;br /&gt;
* [http://www.youtube.com/watch?v=EnCAbgTY6d8 Adding Voice to your Diaries] - ''By triadtimes''&lt;br /&gt;
* [http://www.youtube.com/watch?v=vQEdIAZw5gM&amp;amp;feature=plcp&amp;amp;context=C4347014VDvjVQa1PpcFNKLAyG_d-p_QR49e20E_Wo08wpqmVkJz0= How to create a custom main menu background] - ''By CTCommunity''&lt;br /&gt;
* [http://youtu.be/Crx5Qd7AgJ0 Using Prop Force: How Do I Know Which Coordinate To Put My Value In?] - ''By JenniferOrange''&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6676</id>
		<title>HPL2/Tutorials/ShowScreenImage()</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6676"/>
		<updated>2024-01-04T16:54:32Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Added examples and conclusion.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
ATDD version 1.5 added the ShowScreenImage() function, which was previously available in AAMFP. Some of the workings of this function are a little counter-intuitive, so the purpose of this page is to explain it a little. This is based off of the author's experiments in ATDD 1.5, so it's not definitive! It's also assumed that these notes apply to AAMFP in the same way, but that has not been tested.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Function=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen.&lt;br /&gt;
&lt;br /&gt;
# ''asImageName'' - The image file to render (.jpg, .png, .tga, .dds) (see Size)&lt;br /&gt;
# ''afX'' - The X position of the image (see Placement)&lt;br /&gt;
# ''afY'' - The Y position of the image (see Placement)&lt;br /&gt;
# ''afScale'' - The size of the image in pixels (see Size) &lt;br /&gt;
# ''abUseRelativeCoordinates'' - If true, X and Y represent a fraction of the entire screen resoltion, otherwise they are pixel co-ordinates (see Placement)&lt;br /&gt;
# ''afDuration'' - The duration, in seconds, that the image is displayed for (see Timing)&lt;br /&gt;
# ''afFadeIn'' - The time, in seconds, to fade in the image (see Timing)&lt;br /&gt;
# ''afFadeOut'' - The time, in seconds, to fade out the image (see Timing)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Size=&lt;br /&gt;
* Note that the ''afScale'' argument is ''not'' actually the scale of the image: it is the ''size in pixels''. This is not relative and does not take the screen resolution into account, so an image will appear bigger or smaller at lower or higher resolutions respectively.&lt;br /&gt;
* The image will be rendered onscreen as a square quad, even if the image file is non square. So if the desired effect is to display a non-square image, it will need to be padded out with transparent pixels in order to make it render without distortion.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Placement=&lt;br /&gt;
* The origin of the screen-space is the centre. This means that [0, 0] is the centre of the screen regardless of screen resolution, and regardless of ''abUseRelativeCoordinates''.&lt;br /&gt;
* The origin of the image-space is the top-left. This means that the co-ordinates define where the top-left corner of the image will go.&lt;br /&gt;
* If ''abUseRelativeCoordinates'' is ''false'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as actual pixels''.&lt;br /&gt;
* If ''abUseRelativeCoordinates'' is ''true'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as a fraction of the screen resolution width or height''.&lt;br /&gt;
* The relative co-ordinates still use the centre of the screen as the origin, so the top-left corner of the screen is [-0.5, -0.5] and the bottom-right corner is [0.5, 0.5]. Any relative co-ordinate greater than 0.5 will put the image outside of the screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Timing=&lt;br /&gt;
* The total time that the image will be displayed is ''afFadeIn'' + ''afDuration'' + ''afFadeOut''.&lt;br /&gt;
* ''afDuration'' counts from when the fade in is finished. ''afFadeOut'' counts from when ''afDuration'' is finished. &lt;br /&gt;
* Calling ShowScreenImage() again will replace the current image, regardless of duration or fade times.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Examples=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
// Centred:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -150.0f, -150.0f, 300.0f, false, 3.0f, 0.0f, 0.0f);&lt;br /&gt;
// Size: 300 x 300 pixels&lt;br /&gt;
// Placement: centred on the screen (image-origin is placed image-size/2 from the screen-origin)&lt;br /&gt;
// Timing: 3 seconds, no fading&lt;br /&gt;
&lt;br /&gt;
// From top-left:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.45f, -0.45f, 100.0f, true, 2.0f, 1.0f, 2.0f);&lt;br /&gt;
// Size: 100 x 100 pixels&lt;br /&gt;
// Placement: near the top-left corner, with a 5% margin relative to the screen size&lt;br /&gt;
// Timing: 5 seconds, including fading&lt;br /&gt;
&lt;br /&gt;
// From top-centre:&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.48f, 0.0f, 100.0f, true, 0.0f, 2.0f, 2.0f);&lt;br /&gt;
// Size: 100 x 100 pixels&lt;br /&gt;
// Placement: near the top-centre, with a 2% margin relative to the screen size&lt;br /&gt;
// Timing: 4 seconds, fading out immediately after fading in&lt;br /&gt;
&lt;br /&gt;
// Bottom-right - not reliable&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, 0.25f, 0.25f, 270.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a screen resolution of 1920 x 1080, this would fit neatly into the bottom-right 1/16 of the screen (1080 / 4 = 270).&lt;br /&gt;
// Unfortunately, if the resolution was lower, it would not fit on the screen. And if the resolution was higher, it would not reach the edges.&lt;br /&gt;
&lt;br /&gt;
// Full-screen kinda... top-left focussed&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.5f, -0.5f, 3840.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a 4k screen resolution of 3840 x 2160, this would fit the full screen.&lt;br /&gt;
// The centre of the image would be at the centre of the screen at 4k, but would move towards the bottom left with lower resolutions.&lt;br /&gt;
// At lower resolutions the right and bottom of the image would be cropped. At higher resolutions it would not fill the screen.&lt;br /&gt;
&lt;br /&gt;
// Full-screen kinda... centre focussed&lt;br /&gt;
ShowScreenImage(&amp;quot;image.dds&amp;quot;, -0.5f, -0.5f, 3840.0f, true, 1.0f, 1.0f, 1.0f);&lt;br /&gt;
// With a 4k screen resolution of 3840 x 2160, this would fit the full screen.&lt;br /&gt;
// The centre of the image would stay on the centre of the screen, whatever the resolution.&lt;br /&gt;
// At lower resolutions all the edges would be cropped. At higher resolutions it would not fill the screen.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Conclusion=&lt;br /&gt;
There are lots of things you can do with ShowScreenImage() if you use it creatively...&lt;br /&gt;
&lt;br /&gt;
If you need to place an image relative the the right-hand edge or bottom of the screen, or relative to the screen resolution, it might be tricky, and might not be future-proof.&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6674</id>
		<title>HPL2/Tutorials/ShowScreenImage()</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6674"/>
		<updated>2024-01-04T15:05:26Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Mrbehemo moved page ShowScreenImage() to HPL2/Tutorials/ShowScreenImage()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
ATDD version 1.5 added the ShowScreenImage() function, which was previously available in AAMFP. Some of the workings of this function are a little counter-intuitive, so the purpose of this page is to explain it a little. This is based off of the author's experiments in ATDD 1.5, so it's not definitive! It's also assumed that these notes apply to AAMFP in the same way, but that has not been tested.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Function=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen.&lt;br /&gt;
&lt;br /&gt;
# ''asImageName'' - The image file to render (.jpg, .png, .tga, .dds) (see Size)&lt;br /&gt;
# ''afX'' - The X position of the image (see Placement)&lt;br /&gt;
# ''afY'' - The Y position of the image (see Placement)&lt;br /&gt;
# ''afScale'' - The size of the image in pixels (see Size) &lt;br /&gt;
# ''abUseRelativeCoordinates'' - If true, X and Y represent a fraction of the entire screen resoltion, otherwise they are pixel co-ordinates (see Placement)&lt;br /&gt;
# ''afDuration'' - The duration, in seconds, that the image is displayed for (see Timing)&lt;br /&gt;
# ''afFadeIn'' - The time, in seconds, to fade in the image (see Timing)&lt;br /&gt;
# ''afFadeOut'' - The time, in seconds, to fade out the image (see Timing)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Size=&lt;br /&gt;
Note that the ''afScale'' argument is ''not'' actually the scale of the image: it is the ''size in pixels''. This is not relative and does not take the screen resolution into account, so an image will appear bigger or smaller at lower or higher resolutions respectively.&lt;br /&gt;
The image will be rendered onscreen as a square quad, even if the image file is non square. So if the desired effect is to display a non-square image, it will need to be padded out with transparent pixels in order to make it render without distortion.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Placement=&lt;br /&gt;
The origin of the screen-space is the centre. This means that [0,0] is the centre of the screen regardless of screen resolution, and regardless of ''abUseRelativeCoordinates''.&lt;br /&gt;
The origin of the image-space is the top-left. This means that the co-ordinates define where the top-left corner of the image will go.&lt;br /&gt;
If ''abUseRelativeCoordinates'' is ''false'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as actual pixels''.&lt;br /&gt;
If ''abUseRelativeCoordinates'' is ''true'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as a fraction of the screen resolution width or height''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Timing=&lt;br /&gt;
The total time that the image will be displayed is ''afFadeIn'' + ''afDuration'' + ''afFadeOut''.&lt;br /&gt;
''afDuration'' counts from when the fade in is finished. ''afFadeOut'' counts from when ''afDuration'' is finished. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Uses=&lt;br /&gt;
WIP - examples to follow&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=ShowScreenImage()&amp;diff=6675</id>
		<title>ShowScreenImage()</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=ShowScreenImage()&amp;diff=6675"/>
		<updated>2024-01-04T15:05:26Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Mrbehemo moved page ShowScreenImage() to HPL2/Tutorials/ShowScreenImage()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[HPL2/Tutorials/ShowScreenImage()]]&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6673</id>
		<title>HPL2/Tutorials/ShowScreenImage()</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/Tutorials/ShowScreenImage()&amp;diff=6673"/>
		<updated>2024-01-04T15:04:41Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: Notes about using the ShowScreenImage() function in ATTD 1.5 and AAMFP.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
ATDD version 1.5 added the ShowScreenImage() function, which was previously available in AAMFP. Some of the workings of this function are a little counter-intuitive, so the purpose of this page is to explain it a little. This is based off of the author's experiments in ATDD 1.5, so it's not definitive! It's also assumed that these notes apply to AAMFP in the same way, but that has not been tested.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Function=&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
void ShowScreenImage(string &amp;amp;in asImageName, float afX, float afY, float afScale, bool abUseRelativeCoordinates, float afDuration, float afFadeIn, float afFadeOut);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Displays an image file directly onto the screen.&lt;br /&gt;
&lt;br /&gt;
# ''asImageName'' - The image file to render (.jpg, .png, .tga, .dds) (see Size)&lt;br /&gt;
# ''afX'' - The X position of the image (see Placement)&lt;br /&gt;
# ''afY'' - The Y position of the image (see Placement)&lt;br /&gt;
# ''afScale'' - The size of the image in pixels (see Size) &lt;br /&gt;
# ''abUseRelativeCoordinates'' - If true, X and Y represent a fraction of the entire screen resoltion, otherwise they are pixel co-ordinates (see Placement)&lt;br /&gt;
# ''afDuration'' - The duration, in seconds, that the image is displayed for (see Timing)&lt;br /&gt;
# ''afFadeIn'' - The time, in seconds, to fade in the image (see Timing)&lt;br /&gt;
# ''afFadeOut'' - The time, in seconds, to fade out the image (see Timing)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Size=&lt;br /&gt;
Note that the ''afScale'' argument is ''not'' actually the scale of the image: it is the ''size in pixels''. This is not relative and does not take the screen resolution into account, so an image will appear bigger or smaller at lower or higher resolutions respectively.&lt;br /&gt;
The image will be rendered onscreen as a square quad, even if the image file is non square. So if the desired effect is to display a non-square image, it will need to be padded out with transparent pixels in order to make it render without distortion.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Placement=&lt;br /&gt;
The origin of the screen-space is the centre. This means that [0,0] is the centre of the screen regardless of screen resolution, and regardless of ''abUseRelativeCoordinates''.&lt;br /&gt;
The origin of the image-space is the top-left. This means that the co-ordinates define where the top-left corner of the image will go.&lt;br /&gt;
If ''abUseRelativeCoordinates'' is ''false'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as actual pixels''.&lt;br /&gt;
If ''abUseRelativeCoordinates'' is ''true'', then X and Y represent the co-ordinates of the top-left corner of the image, relative to the centre of the screen, ''expressed as a fraction of the screen resolution width or height''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Timing=&lt;br /&gt;
The total time that the image will be displayed is ''afFadeIn'' + ''afDuration'' + ''afFadeOut''.&lt;br /&gt;
''afDuration'' counts from when the fade in is finished. ''afFadeOut'' counts from when ''afDuration'' is finished. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Uses=&lt;br /&gt;
WIP - examples to follow&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6636</id>
		<title>HPL2/HPL2 Helper Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6636"/>
		<updated>2023-12-24T14:12:10Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
=Introduction=&lt;br /&gt;
''HPL2 Helper Scripts'' by Aetheric Games is a package of .hps files containing script classes and functions that may be useful to HPL2 modders and custom story creators. It is compatible with ATDD version 1.5 and later.&lt;br /&gt;
&lt;br /&gt;
Would you like to...&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
...make 500 candles blow out in a big wave? ...make haunted objects hover in the air? ...spawn dozens of random debris objects throughout an area? ...make a particle system move along a spline? ...manage a list of quest objectives? ...compare the distances between entities? ...make puzzles based on position and rotation? ...store an array in a global game variable? ...seamlessly teleport the player into an ''almost'' identical room? ...make a statue that twitches when the player has low sanity?&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Well, this script package isn't going to magically do those things for you, but it gives you a ''lot'' of tools to help you do them yourself.&lt;br /&gt;
&lt;br /&gt;
The scripts are divided into two categories: ''utilities'' and ''features''. The ''utilities'' scripts include tools for general scripting, like new maths functions, or linked lists and vector classes. The ''features'' scripts are more specific solutions that make use of the utilities, such as a way to spawn entities at specific locations, script a large chain of events or to make entities twitch and flicker. Some modders might prefer to just adopt the ''utilities'' scripts. It's up to you!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''[[HPL2/HPL2 Helper Scripts#Set-up|See below for download and set-up instructions.]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Contents=&lt;br /&gt;
The documentation and help is organised by file. '''''Lots of help, and full details of the new classes and functions, can be found on the following pages:'''''&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Utilities==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Debug|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Debug'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides more control and options for debug messages and logging.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/GameVars|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''GameVars'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Extends the functionality of the saved game global and local variable wrappers.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Lists|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Lists'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for linked list classes.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/LoadWatcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''LoadWatcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides an &amp;quot;OnLoad()&amp;quot; global function.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Math|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Math'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended maths functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/String|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''String'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended string functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Vectors|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Vectors'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for vector classes.&lt;br /&gt;
||&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;||&lt;br /&gt;
==Features==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Bobber|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Bobber'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for floating or hovering entities, without physics.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Fader|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Fader'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing global ambient sounds.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Glitcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Glitcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing entities that appear to glitch or flicker.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Slimer|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Slimer'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing large sequences of entity actions.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Spawner|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Spawner'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for spawning entities at specific map locations.&lt;br /&gt;
:&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&amp;amp;nbsp;&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
::&amp;amp;nbsp;&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Misc|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Miscellaneous'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Bits and pieces that don't fit anywhere else.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Set-up=&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First, download ''HPL2 Helper Scripts'' from the [https://steamcommunity.com/sharedfiles/filedetails/?id=3101276708 Steam Workshop page] or [https://www.moddb.com/mods/hpl2-helper-scripts ModDb page] and unzip it.&lt;br /&gt;
&lt;br /&gt;
If you get it on Steam Workshop, you'll find the actual folder in your Steam Workshop downloads.&lt;br /&gt;
&lt;br /&gt;
Once you have zipped the folder, there are three options for how you add it into your mod. '''If you are unsure, just go with option A'''.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option A: The full feature-set package===&lt;br /&gt;
::If you want to be able to use all the new functions and classes, go with option A.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_FullPackage.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_FullPackage.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option B: The utilities-only package===&lt;br /&gt;
::Choose option B if you want to have access to the functions and classes in the ''utilities'' category, but don't need the stuff in the ''features'' category.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_UtilitiesOnly.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_UtilitiesOnly.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option C: Pick-n-mix===&lt;br /&gt;
::Advanced modders might prefer to only adopt the specific script files they need. Go nuts! But also be aware of the #include dependencies in each script file, as many of them are interdependent. You might find it easiest to start with option A or B and then remove scripts later that you definitely haven't used. You're also fully allowed and encouraged to just use HPL2HelperScripts as a learning resource or even to just copy snippets here and there.&lt;br /&gt;
&lt;br /&gt;
=Licence and Credits=&lt;br /&gt;
You are free to use ''HPL2 Helper Scripts'' in whatever way you see fit, no rights reserved by Aetheric Games. (As long as you're not going against any licence terms between you and Frictional Games, of course!) Aetheric Games is mostly just one person, mrbehemo, me (hello), and this has been a ''stupid'' amount of work, so if you find it helpful then it would be very cool of you to give me a credit in your mod or custom story. You can list it as &amp;quot;HPL2&amp;amp;nbsp;Helper&amp;amp;nbsp;Scripts&amp;amp;nbsp;by&amp;amp;nbsp;Aetheric&amp;amp;nbsp;Games&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This script package would not have been possible without the work of the tireless and patient Luis Rodero of Frictional Games, and the ever present pillar of the community, Mudbill. &lt;br /&gt;
&lt;br /&gt;
=Support=&lt;br /&gt;
''HPL2 Helper Scripts'' is made by mrbehemo of Aetheric Games. If you need support, here's what to do:&lt;br /&gt;
#First be sure that you're familar with the official [[HPL2/Engine_Scripts|HPL2 scripting reference]] and the [[HPL2/ScriptReference|community scripting guide]].&lt;br /&gt;
#And second, be sure that you've read the relevant parts of this documentation, including the FAQ.&lt;br /&gt;
#And then if you're still stuck I'll be happy to hear from you and will help if I can. Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server].&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
Fervently Anticipated Questions. Nobody's asked anything yet... &lt;br /&gt;
* I've added one or more scripts to my project separately, but I'm getting errors. What should I check?&lt;br /&gt;
** The script files are very interdependent. Check the .hps files you've added - they will have #include directives near the top for every other script they rely on. Either make sure you've also added ''those'' into your project.&lt;br /&gt;
* What's &amp;quot;#include&amp;quot;? What's &amp;quot;OnUpdate()&amp;quot;?&lt;br /&gt;
** Those are new features added with the ATDD [[HPL2/1.5 Update|1.5 update]].&lt;br /&gt;
* I want to make something weird happen, like make 100 flying naked guys do a loop-de-loop around the player. How?&lt;br /&gt;
** Sounds fun and is probably do-able! Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server] if you want advice.&lt;br /&gt;
* Can I get the player's camera direction yet?&lt;br /&gt;
** No, sorry. I investigated multiple ways of doing that, as have many people over the years. There's just no reliable way of doing it in HPL2 without branching the source code.&lt;br /&gt;
* What's a uint and why have you used them everywhere?&lt;br /&gt;
** A &amp;quot;U-int&amp;quot; is an unsigned integer, that is, an integer that can only be positive. I think it's best to use uint in scenarios where negative numbers are nonsensical. Behind the scenes it minimises the the chance of conversion issues, and also minimises warnings in the error output.&lt;br /&gt;
* Why are all your function arguments passed by reference, and why is that not reflected in the docs?&lt;br /&gt;
** In Angelscript there's a tiny, tiny performance saving gained from passing arguments by reference (and by using const where possible). It's not enough of a saving for modders and gameplay scripters to bother with, but since I was writing hundreds of them, it was an easy thing to do. It's not reflected in the docs because most non-advanced modders don't know what &amp;quot;pass by reference&amp;quot; means, or need to know.&lt;br /&gt;
* I looked at your code and you did it all weird. Why did you do it weird?&lt;br /&gt;
** It's probably because of the version of Angelscript that is integrated into HPL2. It has some surprising versatility but also some surprising limitations.&lt;br /&gt;
* Why did you do any of this?&lt;br /&gt;
** I know, I know - HPL2 is old now, I should have done this for The Bunker or whatever. Actually, I was just tidying up The Trapdoor (ATDD mod) for a Steam release, and I got carried away with refactoring it... and then, half a million characters of script later, this had happened. Hope it's useful. If not, it was a good exercise for me. Maybe ''you'' would like to port these scripts to HPL3 as and where needed! Go ahead, just be sure to credit and it'd be cool to let me know.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6635</id>
		<title>HPL2/HPL2 Helper Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6635"/>
		<updated>2023-12-24T14:11:51Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
=Introduction=&lt;br /&gt;
''HPL2 Helper Scripts'' by Aetheric Games is a package of .hps files containing script classes and functions that may be useful to HPL2 modders and custom story creators. It is compatible with ATDD version 1.5 and later.&lt;br /&gt;
&lt;br /&gt;
Would you like to...&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
...make 500 candles blow out in a big wave? ...make haunted objects hover in the air? ...spawn dozens of random debris objects throughout an area? ...make a particle system move along a spline? ...manage a list of quest objectives? ...compare the distances between entities? ...make puzzles based on position and rotation? ...store an array in a global game variable? ...seamlessly teleport the player into an ''almost'' identical room? ...make a statue that twitches when the player has low sanity?&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Well, this script package isn't going to magically do those things for you, but it gives you a ''lot'' of tools to help you do them yourself.&lt;br /&gt;
&lt;br /&gt;
The scripts are divided into two categories: ''utilities'' and ''features''. The ''utilities'' scripts include tools for general scripting, like new maths functions, or linked lists and vector classes. The ''features'' scripts are more specific solutions that make use of the utilities, such as a way to spawn entities at specific locations, script a large chain of events or to make entities twitch and flicker. Some modders might prefer to just adopt the ''utilities'' scripts. It's up to you!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''[[HPL2/HPL2 Helper Scripts#Set-up|See below for download and set-up instructions.]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Contents=&lt;br /&gt;
The documentation and help is organised by file. '''''The majority of help, and full details of the new classes and functions, can be found on the following pages:'''''&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Utilities==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Debug|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Debug'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides more control and options for debug messages and logging.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/GameVars|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''GameVars'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Extends the functionality of the saved game global and local variable wrappers.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Lists|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Lists'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for linked list classes.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/LoadWatcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''LoadWatcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides an &amp;quot;OnLoad()&amp;quot; global function.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Math|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Math'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended maths functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/String|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''String'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended string functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Vectors|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Vectors'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for vector classes.&lt;br /&gt;
||&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;||&lt;br /&gt;
==Features==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Bobber|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Bobber'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for floating or hovering entities, without physics.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Fader|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Fader'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing global ambient sounds.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Glitcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Glitcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing entities that appear to glitch or flicker.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Slimer|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Slimer'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing large sequences of entity actions.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Spawner|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Spawner'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for spawning entities at specific map locations.&lt;br /&gt;
:&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&amp;amp;nbsp;&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
::&amp;amp;nbsp;&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Misc|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Miscellaneous'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Bits and pieces that don't fit anywhere else.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Set-up=&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First, download ''HPL2 Helper Scripts'' from the [https://steamcommunity.com/sharedfiles/filedetails/?id=3101276708 Steam Workshop page] or [https://www.moddb.com/mods/hpl2-helper-scripts ModDb page] and unzip it.&lt;br /&gt;
&lt;br /&gt;
If you get it on Steam Workshop, you'll find the actual folder in your Steam Workshop downloads.&lt;br /&gt;
&lt;br /&gt;
Once you have zipped the folder, there are three options for how you add it into your mod. '''If you are unsure, just go with option A'''.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option A: The full feature-set package===&lt;br /&gt;
::If you want to be able to use all the new functions and classes, go with option A.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_FullPackage.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_FullPackage.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option B: The utilities-only package===&lt;br /&gt;
::Choose option B if you want to have access to the functions and classes in the ''utilities'' category, but don't need the stuff in the ''features'' category.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_UtilitiesOnly.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_UtilitiesOnly.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option C: Pick-n-mix===&lt;br /&gt;
::Advanced modders might prefer to only adopt the specific script files they need. Go nuts! But also be aware of the #include dependencies in each script file, as many of them are interdependent. You might find it easiest to start with option A or B and then remove scripts later that you definitely haven't used. You're also fully allowed and encouraged to just use HPL2HelperScripts as a learning resource or even to just copy snippets here and there.&lt;br /&gt;
&lt;br /&gt;
=Licence and Credits=&lt;br /&gt;
You are free to use ''HPL2 Helper Scripts'' in whatever way you see fit, no rights reserved by Aetheric Games. (As long as you're not going against any licence terms between you and Frictional Games, of course!) Aetheric Games is mostly just one person, mrbehemo, me (hello), and this has been a ''stupid'' amount of work, so if you find it helpful then it would be very cool of you to give me a credit in your mod or custom story. You can list it as &amp;quot;HPL2&amp;amp;nbsp;Helper&amp;amp;nbsp;Scripts&amp;amp;nbsp;by&amp;amp;nbsp;Aetheric&amp;amp;nbsp;Games&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This script package would not have been possible without the work of the tireless and patient Luis Rodero of Frictional Games, and the ever present pillar of the community, Mudbill. &lt;br /&gt;
&lt;br /&gt;
=Support=&lt;br /&gt;
''HPL2 Helper Scripts'' is made by mrbehemo of Aetheric Games. If you need support, here's what to do:&lt;br /&gt;
#First be sure that you're familar with the official [[HPL2/Engine_Scripts|HPL2 scripting reference]] and the [[HPL2/ScriptReference|community scripting guide]].&lt;br /&gt;
#And second, be sure that you've read the relevant parts of this documentation, including the FAQ.&lt;br /&gt;
#And then if you're still stuck I'll be happy to hear from you and will help if I can. Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server].&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
Fervently Anticipated Questions. Nobody's asked anything yet... &lt;br /&gt;
* I've added one or more scripts to my project separately, but I'm getting errors. What should I check?&lt;br /&gt;
** The script files are very interdependent. Check the .hps files you've added - they will have #include directives near the top for every other script they rely on. Either make sure you've also added ''those'' into your project.&lt;br /&gt;
* What's &amp;quot;#include&amp;quot;? What's &amp;quot;OnUpdate()&amp;quot;?&lt;br /&gt;
** Those are new features added with the ATDD [[HPL2/1.5 Update|1.5 update]].&lt;br /&gt;
* I want to make something weird happen, like make 100 flying naked guys do a loop-de-loop around the player. How?&lt;br /&gt;
** Sounds fun and is probably do-able! Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server] if you want advice.&lt;br /&gt;
* Can I get the player's camera direction yet?&lt;br /&gt;
** No, sorry. I investigated multiple ways of doing that, as have many people over the years. There's just no reliable way of doing it in HPL2 without branching the source code.&lt;br /&gt;
* What's a uint and why have you used them everywhere?&lt;br /&gt;
** A &amp;quot;U-int&amp;quot; is an unsigned integer, that is, an integer that can only be positive. I think it's best to use uint in scenarios where negative numbers are nonsensical. Behind the scenes it minimises the the chance of conversion issues, and also minimises warnings in the error output.&lt;br /&gt;
* Why are all your function arguments passed by reference, and why is that not reflected in the docs?&lt;br /&gt;
** In Angelscript there's a tiny, tiny performance saving gained from passing arguments by reference (and by using const where possible). It's not enough of a saving for modders and gameplay scripters to bother with, but since I was writing hundreds of them, it was an easy thing to do. It's not reflected in the docs because most non-advanced modders don't know what &amp;quot;pass by reference&amp;quot; means, or need to know.&lt;br /&gt;
* I looked at your code and you did it all weird. Why did you do it weird?&lt;br /&gt;
** It's probably because of the version of Angelscript that is integrated into HPL2. It has some surprising versatility but also some surprising limitations.&lt;br /&gt;
* Why did you do any of this?&lt;br /&gt;
** I know, I know - HPL2 is old now, I should have done this for The Bunker or whatever. Actually, I was just tidying up The Trapdoor (ATDD mod) for a Steam release, and I got carried away with refactoring it... and then, half a million characters of script later, this had happened. Hope it's useful. If not, it was a good exercise for me. Maybe ''you'' would like to port these scripts to HPL3 as and where needed! Go ahead, just be sure to credit and it'd be cool to let me know.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6634</id>
		<title>HPL2/HPL2 Helper Scripts</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts&amp;diff=6634"/>
		<updated>2023-12-24T14:11:29Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
=Introduction=&lt;br /&gt;
''HPL2 Helper Scripts'' by Aetheric Games is a package of .hps files containing script classes and functions that may be useful to HPL2 modders and custom story creators. It is compatible with ATDD version 1.5 and later.&lt;br /&gt;
&lt;br /&gt;
Would you like to...&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&amp;lt;small&amp;gt;&lt;br /&gt;
...make 500 candles blow out in a big wave? ...make haunted objects hover in the air? ...spawn dozens of random debris objects throughout an area? ...make a particle system move along a spline? ...manage a list of quest objectives? ...compare the distances between entities? ...make puzzles based on position and rotation? ...store an array in a global game variable? ...seamlessly teleport the player into an ''almost'' identical room? ...make a statue that twitches when the player has low sanity?&lt;br /&gt;
&amp;lt;/small&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
Well, this script package isn't going to magically do those things for you, but it gives you a ''lot'' of tools to help you do them yourself.&lt;br /&gt;
&lt;br /&gt;
The scripts are divided into two categories: ''utilities'' and ''features''. The ''utilities'' scripts include tools for general scripting, like new maths functions, or linked lists and vector classes. The ''features'' scripts are more specific solutions that make use of the utilities, such as a way to spawn entities at specific locations, script a large chain of events or to make entities twitch and flicker. Some modders might prefer to just adopt the ''utilities'' scripts. It's up to you!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;big&amp;gt;'''[[HPL2/HPL2 Helper Scripts#Set-up|See below for download and set-up instructions.]]'''&amp;lt;/big&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Contents=&lt;br /&gt;
The documentation and help is organised by file. '''The majority of help, and full details of the new classes and functions, can be found on the following pages:'''&lt;br /&gt;
{|&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
==Utilities==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Debug|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Debug'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides more control and options for debug messages and logging.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/GameVars|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''GameVars'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Extends the functionality of the saved game global and local variable wrappers.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Lists|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Lists'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for linked list classes.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/LoadWatcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''LoadWatcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides an &amp;quot;OnLoad()&amp;quot; global function.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Math|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Math'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended maths functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/String|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''String'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Provides extended string functionality.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Vectors|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Vectors'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Adds support for vector classes.&lt;br /&gt;
||&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;&amp;amp;nbsp;||&lt;br /&gt;
==Features==&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Bobber|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Bobber'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for floating or hovering entities, without physics.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Fader|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Fader'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing global ambient sounds.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Glitcher|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Glitcher'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing entities that appear to glitch or flicker.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Slimer|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Slimer'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for managing large sequences of entity actions.&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Spawner|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Spawner'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Implements a class for spawning entities at specific map locations.&lt;br /&gt;
:&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;&amp;amp;nbsp;&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;&lt;br /&gt;
::&amp;amp;nbsp;&lt;br /&gt;
:* [[HPL2/HPL2 Helper Scripts/Misc|&amp;lt;big&amp;gt;&amp;lt;big&amp;gt;'''Miscellaneous'''&amp;lt;/big&amp;gt;&amp;lt;/big&amp;gt;]]&lt;br /&gt;
::Bits and pieces that don't fit anywhere else.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=Set-up=&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
{{ReqVer|1.5}}&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
First, download ''HPL2 Helper Scripts'' from the [https://steamcommunity.com/sharedfiles/filedetails/?id=3101276708 Steam Workshop page] or [https://www.moddb.com/mods/hpl2-helper-scripts ModDb page] and unzip it.&lt;br /&gt;
&lt;br /&gt;
If you get it on Steam Workshop, you'll find the actual folder in your Steam Workshop downloads.&lt;br /&gt;
&lt;br /&gt;
Once you have zipped the folder, there are three options for how you add it into your mod. '''If you are unsure, just go with option A'''.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option A: The full feature-set package===&lt;br /&gt;
::If you want to be able to use all the new functions and classes, go with option A.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_FullPackage.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_FullPackage.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option B: The utilities-only package===&lt;br /&gt;
::Choose option B if you want to have access to the functions and classes in the ''utilities'' category, but don't need the stuff in the ''features'' category.&lt;br /&gt;
::#Copy the folder &amp;lt;code&amp;gt;HPL2HelperScripts&amp;lt;/code&amp;gt; into your &amp;lt;code&amp;gt;maps&amp;lt;/code&amp;gt; folder.&lt;br /&gt;
::#Include &amp;lt;code&amp;gt;HelperScripts_UtilitiesOnly.hps&amp;lt;/code&amp;gt; in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file using the &amp;lt;code&amp;gt;#include&amp;lt;/code&amp;gt; directive.&lt;br /&gt;
::#Add &amp;lt;code&amp;gt;HelperScriptsUpdate(afStep)&amp;lt;/code&amp;gt; to your main &amp;lt;code&amp;gt;OnUpdate()&amp;lt;/code&amp;gt; function in your level's &amp;lt;code&amp;gt;.hps&amp;lt;/code&amp;gt; script file.&lt;br /&gt;
::For example, in &amp;lt;code&amp;gt;myLevel.hps&amp;lt;/code&amp;gt;:&lt;br /&gt;
::&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;HelperScripts_UtilitiesOnly.hps&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void OnUpdate(float afStep)&lt;br /&gt;
{&lt;br /&gt;
    HelperScriptsUpdate(afStep);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Option C: Pick-n-mix===&lt;br /&gt;
::Advanced modders might prefer to only adopt the specific script files they need. Go nuts! But also be aware of the #include dependencies in each script file, as many of them are interdependent. You might find it easiest to start with option A or B and then remove scripts later that you definitely haven't used. You're also fully allowed and encouraged to just use HPL2HelperScripts as a learning resource or even to just copy snippets here and there.&lt;br /&gt;
&lt;br /&gt;
=Licence and Credits=&lt;br /&gt;
You are free to use ''HPL2 Helper Scripts'' in whatever way you see fit, no rights reserved by Aetheric Games. (As long as you're not going against any licence terms between you and Frictional Games, of course!) Aetheric Games is mostly just one person, mrbehemo, me (hello), and this has been a ''stupid'' amount of work, so if you find it helpful then it would be very cool of you to give me a credit in your mod or custom story. You can list it as &amp;quot;HPL2&amp;amp;nbsp;Helper&amp;amp;nbsp;Scripts&amp;amp;nbsp;by&amp;amp;nbsp;Aetheric&amp;amp;nbsp;Games&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
This script package would not have been possible without the work of the tireless and patient Luis Rodero of Frictional Games, and the ever present pillar of the community, Mudbill. &lt;br /&gt;
&lt;br /&gt;
=Support=&lt;br /&gt;
''HPL2 Helper Scripts'' is made by mrbehemo of Aetheric Games. If you need support, here's what to do:&lt;br /&gt;
#First be sure that you're familar with the official [[HPL2/Engine_Scripts|HPL2 scripting reference]] and the [[HPL2/ScriptReference|community scripting guide]].&lt;br /&gt;
#And second, be sure that you've read the relevant parts of this documentation, including the FAQ.&lt;br /&gt;
#And then if you're still stuck I'll be happy to hear from you and will help if I can. Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server].&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
Fervently Anticipated Questions. Nobody's asked anything yet... &lt;br /&gt;
* I've added one or more scripts to my project separately, but I'm getting errors. What should I check?&lt;br /&gt;
** The script files are very interdependent. Check the .hps files you've added - they will have #include directives near the top for every other script they rely on. Either make sure you've also added ''those'' into your project.&lt;br /&gt;
* What's &amp;quot;#include&amp;quot;? What's &amp;quot;OnUpdate()&amp;quot;?&lt;br /&gt;
** Those are new features added with the ATDD [[HPL2/1.5 Update|1.5 update]].&lt;br /&gt;
* I want to make something weird happen, like make 100 flying naked guys do a loop-de-loop around the player. How?&lt;br /&gt;
** Sounds fun and is probably do-able! Come and find me on [https://discord.com/invite/frictionalgames the Frictional Discord server] if you want advice.&lt;br /&gt;
* Can I get the player's camera direction yet?&lt;br /&gt;
** No, sorry. I investigated multiple ways of doing that, as have many people over the years. There's just no reliable way of doing it in HPL2 without branching the source code.&lt;br /&gt;
* What's a uint and why have you used them everywhere?&lt;br /&gt;
** A &amp;quot;U-int&amp;quot; is an unsigned integer, that is, an integer that can only be positive. I think it's best to use uint in scenarios where negative numbers are nonsensical. Behind the scenes it minimises the the chance of conversion issues, and also minimises warnings in the error output.&lt;br /&gt;
* Why are all your function arguments passed by reference, and why is that not reflected in the docs?&lt;br /&gt;
** In Angelscript there's a tiny, tiny performance saving gained from passing arguments by reference (and by using const where possible). It's not enough of a saving for modders and gameplay scripters to bother with, but since I was writing hundreds of them, it was an easy thing to do. It's not reflected in the docs because most non-advanced modders don't know what &amp;quot;pass by reference&amp;quot; means, or need to know.&lt;br /&gt;
* I looked at your code and you did it all weird. Why did you do it weird?&lt;br /&gt;
** It's probably because of the version of Angelscript that is integrated into HPL2. It has some surprising versatility but also some surprising limitations.&lt;br /&gt;
* Why did you do any of this?&lt;br /&gt;
** I know, I know - HPL2 is old now, I should have done this for The Bunker or whatever. Actually, I was just tidying up The Trapdoor (ATDD mod) for a Steam release, and I got carried away with refactoring it... and then, half a million characters of script later, this had happened. Hope it's useful. If not, it was a good exercise for me. Maybe ''you'' would like to port these scripts to HPL3 as and where needed! Go ahead, just be sure to credit and it'd be cool to let me know.&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6633</id>
		<title>HPL2/HPL2 Helper Scripts/Lists</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6633"/>
		<updated>2023-12-23T19:04:59Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Lists.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;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_Lists.hps&amp;quot; adds support for linked list classes. For beginners or other people not familiar with classes, these are best thought of as new variable types. A linked list, or just &amp;quot;list&amp;quot;, is a type of collection that works similarly to an array. Both lists and arrays are ways of grouping multiple variables together under one name.&lt;br /&gt;
&lt;br /&gt;
There are three main advantages to using lists over arrays. The first is that it is more efficient (and more performant) to insert, remove or re-order items in the list than it would be with an array. The second is that lists can also take up less memory than arrays. The memory requirement of an array is defined by its maximum capacity, whereas the memory requirement of a list is only as much as its current content. And therefore the third advantage is that it is not necessary to know in advance how big a list needs to be - it expands automatically as items are added. (And of course, advanced users may note that there are exceptions when an array would be more efficient, but most users won't need to worry about this.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
Declare a list like any other variable, then use the methods below to work with it. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt myList;		// Declares a new cListInt, called myList, ready to collect integers.&lt;br /&gt;
myList.Add(68);			// Appends the first integer (68) to the list at index 0.&lt;br /&gt;
myList.Add(419);		// Appends the second integer (419) to the list at index 1.&lt;br /&gt;
myList.Get(0);			// Retrieves the integer at index 0.&lt;br /&gt;
myList.Set(1, 99);		// Overwrites the integer at index 1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Indices===&lt;br /&gt;
Like arrays, you can ''get'' the items in the list using an index operator, e.g. myList[0], myList[22], myList[LastIndex]. And like arrays, the index number is '''zero based'''. In a list or array of ten items, the first index is 0 and the last index is 9.&lt;br /&gt;
&lt;br /&gt;
Getting an item from a list by its index is equivalent to using the Get() method. However, ''unlike arrays'', this is '''read-only'''. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);		// OK&lt;br /&gt;
string myStringOne = myToDoList[1];				// OK&lt;br /&gt;
&lt;br /&gt;
myToDoList.Set(0, &amp;quot;Paint over the lines.&amp;quot;);		// OK&lt;br /&gt;
myToDoList[1] = &amp;quot;Cut the cheese.&amp;quot;;				// Not OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(This seems to be because the version of AngelScript used in HPL2 seems to only allow the index operator to ''get'' and not ''set''. If I'm wrong and you can make this work, let me know!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
&amp;quot;HelperScripts_Lists.hps&amp;quot; also defines cListNodeBase and several derived node classes for each type of list. The list classes all inherit from the base class cListBase, which defines some shared functionality and handles anything that doesn't depend on the type of the stored data.&lt;br /&gt;
&lt;br /&gt;
Additionally, cListGeneric is an extra list class intended for advanced users. It extends the cListBase class without defining an inner data type, to help with making custom node classes derived from cListNodeBase. Advanced users attempting this may find it helpful to take a look at the cListBase and cListGeneric definition, and to read up on how AngelScript uses object handles. Examples can be found in most of the ''features'' scripts, e.g. &amp;quot;HelperScripts_Slimer.hps&amp;quot;, which implements multiple custom node classes and nested lists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=List classes=&lt;br /&gt;
&lt;br /&gt;
Available list classes: &amp;lt;code&amp;gt;cListInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListPoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;List classes&amp;quot; section refers to all the list types unless otherwise stated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
Lists can be declared in the same way as other variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat listOfFloats;					// Declares a list of floats.&lt;br /&gt;
cListString listOfStrings;					// Declares a list of strings.&lt;br /&gt;
&lt;br /&gt;
myListOfFloats.Add(0.001f);					// Calling a method of the referred list.&lt;br /&gt;
int numStrings = myListOfStrings.Count;		// Accessing a property of the referred list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with capacity===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(uint aulMaxSize)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the list is initialised with a constructor, then a maximum capacity can be specified for the list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the list is declared without a specific capacity, then the default maximum capacity is assigned, which is 65535 (or 2^16 - 1).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat listOfFloatsDefault;&lt;br /&gt;
cListVector listOfVectorsDefault;&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfUpToFiveFloats = cListFloat(5);&lt;br /&gt;
cListVector listOfUpTo1000Vectors = cListVector(1000);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default 65535 (2^16-1) is the maximum capacity that can be indexed. Using this a or smaller arbitrary limit can help to catch runaway bugs. '''Advanced users''' may try changing the value of mulCountMax to use a smaller default maximum. Using a larger maximum will likely cause problems.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that arrays require as much memory as their full capacity even when empty, but lists are only ever as big as their content, so lowering the maximum size of the list does not help performance. But it might be useful in certain situations where a limit is required by design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with data===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(float[] afArray)&lt;br /&gt;
cListBase(cListBase aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Lists can be initialised with data by passing an array of values of the relevant type, or an existing list. The default capacity is used for the new list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the source is an array, the new list will contain copies of the array's contents. If the source is an existing list, then the new list will copy the ''link'' to the original items. Both the old and new lists will point to the same data, and changing one will change the other. To avoid this, see the [[HPL2/HPL2_Helper_Scripts/Lists#Copy.28.29|Copy()]] method.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListFloat myFirstList = cListFloat(myArray);			// Makes a new float list by copying items from the float array.&lt;br /&gt;
cListFloat mySecondList = myFirstList;					// Makes a new float list containing the same items as the other list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat(float afSingleFloat)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
All the derived list classes ('''except for cListGeneric and cListInt''') can be initialised with data by passing a single value of the relevant type, to become the first item in the list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat myList = cListFloat(1.2f);				// Makes a new float list with a single value.&lt;br /&gt;
myList.Add(2.3f);									// myList now contains: 1.2f, 2.3f&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
'''All list classes''' provide the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Count====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Count&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Count returns the current number of items in the list.&lt;br /&gt;
(The property Length and the method length() are provided for consistency with arrays, and are both equivalent to Count.)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat myList;&lt;br /&gt;
uint ulCountA = myList.Count;&lt;br /&gt;
myList.Add(99.99f);&lt;br /&gt;
uint ulCountB = myList.Count;&lt;br /&gt;
// ulCountA is 0. ulCountB is 1.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (listNumbers.Count &amp;lt; 6) listNumber.Add(42);&lt;br /&gt;
// The condition succeeds if the count is less than 6, and another number is added.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the last valid index, or -1 if the list is empty.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
uint ulA = myListOfStrings.LastIndex;&lt;br /&gt;
uint ulB = myListOfStrings.Count - 1;&lt;br /&gt;
// ulA and ulB are equal&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string sLatest = myListOfStrings[myListOfStrings.LastIndex];&lt;br /&gt;
// sLatest becomes whatever string was added to the list most recently.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsEmpty====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEmpty&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsEmpty returns true if the list is empty, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (myList.IsEmpty) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list contains no items.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsFull====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsFull&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsFull returns true if the list is full to its maximum capacity, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (!myList.IsFull) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list has space for another item.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Assignment====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase = cListBase&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The assignment operator (equals sign &amp;quot;=&amp;quot;) assigns a new set of data to the list, copied from another list. Note: the list contains handles to the data, not the data itself. So when a list is copied, ''both'' lists now refer to the same data, and any changes made to either will affect both.&lt;br /&gt;
&amp;lt;br&amp;gt;If the intent is to make a duplicate of the ''data'' rather than the list handles, then the Copy() method is recommended.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for assigning items to the list:&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(int alItem)&lt;br /&gt;
bool Add(float afItem)&lt;br /&gt;
bool Add(double adItem)&lt;br /&gt;
bool Add(bool abItem)&lt;br /&gt;
bool Add(string asItem)&lt;br /&gt;
bool Add(cVector avItem)&lt;br /&gt;
bool Add(cPoint avItem)&lt;br /&gt;
bool Add(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Creates a new item appended to the list. If the list is full or the item cannot be added, it returns false. If it was successfull appended, it returns true.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfFloats.Add(1.0f);&lt;br /&gt;
myListOfPoints.Add(cPoint(10, 15, 20));&lt;br /&gt;
// The new values are appended to the list.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!listNumbers.Add(-1.0f)) Debug.Message(1, &amp;quot;Error - could not add to list!&amp;quot;);&lt;br /&gt;
// The condition succeeds if Add failed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Set()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Set(uint aulIndex, int alItem)&lt;br /&gt;
bool Set(uint aulIndex, float afItem)&lt;br /&gt;
bool Set(uint aulIndex, double adItem)&lt;br /&gt;
bool Set(uint aulIndex, bool abItem)&lt;br /&gt;
bool Set(uint aulIndex, string asItem)&lt;br /&gt;
bool Set(uint aulIndex, cVector avItem)&lt;br /&gt;
bool Set(uint aulIndex, cPoint avItem)&lt;br /&gt;
bool Set(uint aulIndex, cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to an indexed item in the list, if it exists. If the list is shorter than the index or the item cannot be added, this returns false. If it was successfull set, it returns true.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be changed.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be assigned.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
myListOfBools.Set(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, replacing the previous one.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Insert()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Insert(uint aulIndex, int alItem)&lt;br /&gt;
bool Insert(uint aulIndex, float afItem)&lt;br /&gt;
bool Insert(uint aulIndex, double adItem)&lt;br /&gt;
bool Insert(uint aulIndex, bool abItem)&lt;br /&gt;
bool Insert(uint aulIndex, string asItem)&lt;br /&gt;
bool Insert(uint aulIndex, cVector avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cPoint avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Inserts a new item into the list at the given index. (The item previous at that index becomes the next one.) If the given index is not a valid place to insert an item, then then return value will be false. Otherwise the item is inserted and it returns true.&lt;br /&gt;
#''uint aulIndex'' - The index where the new item will be inserted.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be inserted.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfBools.Insert(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, displacing the previous one to index 8.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!myList.Insert(10, &amp;quot;hello&amp;quot;) myList.Add(&amp;quot;hello&amp;quot;);&lt;br /&gt;
// Attempts to insert the string at index 10, and if that fails the string is appended instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Concatenate()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Concatenate(cListBase aList)&lt;br /&gt;
bool Concatenate(int[] alArray)&lt;br /&gt;
bool Concatenate(float[] afArray)&lt;br /&gt;
bool Concatenate(double[] adArray)&lt;br /&gt;
bool Concatenate(bool[] abArray)&lt;br /&gt;
bool Concatenate(string[] asArray)&lt;br /&gt;
bool Concatenate(cVector[] avArray)&lt;br /&gt;
bool Concatenate(cPoint[] avArray)&lt;br /&gt;
bool Concatenate(cRotator[] avArray)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Takes either a second list or array of the same type and appends it to this one. It first checks to make sure there is enough capacity. Returns true if items were successfully added, or false if not.&lt;br /&gt;
&amp;lt;br&amp;gt;If an array is supplied, new list items are created to match them. If a list is suplied the items are '''not duplicated''' - both lists refer to the same items in memory, and changing them will change both lists.&lt;br /&gt;
#''cListBase aList (or any list type), or an array of int[], float[], double[], bool[], string[], cVector[], cPoint[] or cRotator[]'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
float[] arrayOfFloatsB = { 3.0f, 4.0f };&lt;br /&gt;
listOfFloatsA.Concatenate(arrayOfFloatsB);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 4.0f.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfFloatsB;&lt;br /&gt;
listOfFloatsB.Add(3.0f);&lt;br /&gt;
listOfFloatsB.Add(4.0f);&lt;br /&gt;
&lt;br /&gt;
listOfFloatsA.Concatenate(listOfFloatsB);&lt;br /&gt;
listOfFloatsA.Set(3, 99.9f);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 99.9f.&lt;br /&gt;
// listOfFloatsB now contains 3.0f, 99.9f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for retrieving items from the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Get()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Get(uint aulIndex)&lt;br /&gt;
float Get(uint aulIndex)&lt;br /&gt;
double Get(uint aulIndex)&lt;br /&gt;
bool Get(uint aulIndex)&lt;br /&gt;
string Get(uint aulIndex)&lt;br /&gt;
cVector Get(uint aulIndex)&lt;br /&gt;
cPoint Get(uint aulIndex)&lt;br /&gt;
cRotator Get(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, if it exists. If the item does not exist in the list, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;br&amp;gt;See GetIfValid() if you want to be sure the item exists. You can also use an index operator (e.g. myList[i]) to get list items.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);&lt;br /&gt;
string myStringLast = myToDoList.Get(myToDoList.LastIndex);&lt;br /&gt;
// myStringZero becomes the value from the start of the list.&lt;br /&gt;
// myStringLast becomes the value that happens to be at the end of the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIfValid()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GetIfValid(uint aulIndex, int &amp;amp;out alTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, float &amp;amp;out afTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, double &amp;amp;out adTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, bool &amp;amp;out abTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, string &amp;amp;out asTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cVector &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cPoint &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cRotator &amp;amp;out avTarget)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, as long as it is valid.&lt;br /&gt;
&amp;lt;br&amp;gt;The second parameter is an ''ouput'' parameter. If the item at the given index exists then '''the item is assigned to the Target &amp;amp;out parameter''', and the function returns true. If the item doesn't exist in the list, the function returns false.&lt;br /&gt;
&amp;lt;br&amp;gt;See Get() if you don't care about validation and just want to return the item.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
#''int alTarget, float afTarget, double adTarget, bool abTarget, string asTarget, cVector avTarget, cPoint avTarget, or cRotator avTarget'' - The variable, of the appropriate type, where the retrieved item will be '''stored'''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int retrievedInteger;&lt;br /&gt;
if(!myListOfInts.GetIfValid(3, retrievedInteger)) retrievedInteger = -1;&lt;br /&gt;
// retrievedInteger will be assigned the value retrieved from index 3 in the list, if it exists.&lt;br /&gt;
// If it doesn't exist, the condition will succeed and retrievedInteger with be assigned -1 instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetRandom()&lt;br /&gt;
float GetRandom()&lt;br /&gt;
double GetRandom()&lt;br /&gt;
bool GetRandom()&lt;br /&gt;
string GetRandom()&lt;br /&gt;
cVector GetRandom()&lt;br /&gt;
cPoint GetRandom()&lt;br /&gt;
cRotator GetRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list and returns it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pop()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Pop()&lt;br /&gt;
float Pop()&lt;br /&gt;
double Pop()&lt;br /&gt;
bool Pop()&lt;br /&gt;
string Pop()&lt;br /&gt;
cVector Pop()&lt;br /&gt;
cPoint Pop()&lt;br /&gt;
cRotator Pop()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the last item in the list, and removes that item. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lA = listNumbers.Pop();&lt;br /&gt;
int lB = listNumbers.Pop();&lt;br /&gt;
int lC = listNumbers.Pop();&lt;br /&gt;
// lA, lB, and lC have become 23, 16, and 15. myArray now contains only 4 and 8.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PopRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int PopRandom()&lt;br /&gt;
float PopRandom()&lt;br /&gt;
double PopRandom()&lt;br /&gt;
bool PopRandom()&lt;br /&gt;
string PopRandom()&lt;br /&gt;
cVector PopRandom()&lt;br /&gt;
cPoint PopRandom()&lt;br /&gt;
cRotator PopRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list, returns it and them removes it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors, and that value is no longer available in the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Copy()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt Copy(cListInt aList)&lt;br /&gt;
cListFloat Copy(cListFloat aList)&lt;br /&gt;
cListDouble Copy(cListDouble aList)&lt;br /&gt;
cListBool Copy(cListBool aList)&lt;br /&gt;
cListVector Copy(cListVector aList)&lt;br /&gt;
cListPoint Copy(cListPoint aList)&lt;br /&gt;
cListRotator Copy(cListRotator aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a new list that is a duplicate of this list. The items in the new list are new items. Changing either list will not affect the other.&lt;br /&gt;
#''cListBase aList (or any list type)'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Removing list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for removing items from the list: (See also: Pop() and PopRandom())&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAt(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and removes the given index.&lt;br /&gt;
Returns true if the index was valid and was removed, or false if not.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myList.RemoveAt(7);&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (myList.RemoveAt(7)) myList.Append(&amp;quot;something new&amp;quot;);&lt;br /&gt;
// If the removal was successful, then a new value is appended.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveItem(int alItem)&lt;br /&gt;
bool RemoveItem(float afItem)&lt;br /&gt;
bool RemoveItem(double adItem)&lt;br /&gt;
bool RemoveItem(bool abItem)&lt;br /&gt;
bool RemoveItem(string asItem)&lt;br /&gt;
bool RemoveItem(cVector avItem)&lt;br /&gt;
bool RemoveItem(cPoint avItem)&lt;br /&gt;
bool RemoveItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and removes the first matching item it finds. Returns true if the item was found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
myListOfBools.RemoveItem(false);&lt;br /&gt;
// The first instance of false in the list will be removed.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
int  lRemoved = 0;&lt;br /&gt;
int[] myArray = { 4, 8, 0, 15, 16, 0, 23, 0 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
while (listNumbers.Remove(0))&lt;br /&gt;
{&lt;br /&gt;
    lRemoved++;&lt;br /&gt;
	DoStuff();&lt;br /&gt;
}&lt;br /&gt;
// The Remove() call will repeat until it returns false, at which point the value of lRemoved will be 3.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAll()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAll(int alItem)&lt;br /&gt;
bool RemoveAll(float aItem)&lt;br /&gt;
bool RemoveAll(double aItem)&lt;br /&gt;
bool RemoveAll(bool aItem)&lt;br /&gt;
bool RemoveAll(string aItem)&lt;br /&gt;
bool RemoveAll(cVector aItem)&lt;br /&gt;
bool RemoveAll(cPoint aItem)&lt;br /&gt;
bool RemoveAll(cRotator aItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and removes the all matching items. Returns true if any items were found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
myListOfFloats.RemoveAll(0.0f);&lt;br /&gt;
// All the zeros will be removed from the list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Searching lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for searching for items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Find()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Find(int alItem)&lt;br /&gt;
int Find(float afItem)&lt;br /&gt;
int Find(double adItem)&lt;br /&gt;
int Find(bool abItem)&lt;br /&gt;
int Find(string asItem)&lt;br /&gt;
int Find(cVector avItem)&lt;br /&gt;
int Find(cPoint avItem)&lt;br /&gt;
int Find(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns the index of the first match. If the item is not found, -1 is returned instead.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
uint lIndexTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
uint lIndexFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// lIndexTwentyTwo becomes 1. lIndexFortyFour becomes -1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Contains()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Contains(int alItem)&lt;br /&gt;
bool Contains(float afItem)&lt;br /&gt;
bool Contains(double adItem)&lt;br /&gt;
bool Contains(bool abItem)&lt;br /&gt;
bool Contains(string asItem)&lt;br /&gt;
bool Contains(cVector avItem)&lt;br /&gt;
bool Contains(cPoint avItem)&lt;br /&gt;
bool Contains(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns true if found, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
bool bHasTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
bool bHasFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// bHasTwentyTwo becomes true. bHasFortyFour becomes false.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CountItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint CountItem(int alItem)&lt;br /&gt;
uint CountItem(float afItem)&lt;br /&gt;
uint CountItem(double adItem)&lt;br /&gt;
uint CountItem(bool abItem)&lt;br /&gt;
uint CountItem(string asItem)&lt;br /&gt;
uint CountItem(cVector avItem)&lt;br /&gt;
uint CountItem(cPoint avItem)&lt;br /&gt;
uint CountItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and returns the number of matches found.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myListOfStrings;&lt;br /&gt;
myListOfStrings.Add(&amp;quot;up&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;sideways&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
int lNumDown = myListOfStrings.CountItem(&amp;quot;down&amp;quot;);&lt;br /&gt;
int lNumForward = myListOfStrings.CountItem(&amp;quot;forward&amp;quot;);&lt;br /&gt;
// lNumDown becomes 2. lNumForward becomes 0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Numeric lists===&lt;br /&gt;
Some of the derived list classes dealing with numeric values provide the methods for arithmetic operations across the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Min()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Min()&lt;br /&gt;
float Min()&lt;br /&gt;
double Min()&lt;br /&gt;
bool Min()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns false if there is a false - like logical AND over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fSmallest = fRandomList.Min();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the smallest is assigned to fSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Max()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Max()&lt;br /&gt;
float Max()&lt;br /&gt;
double Max()&lt;br /&gt;
bool Max()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - like logical OR over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fLargest = fRandomList.Max();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the largest is assigned to fLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMin()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMin()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lSmallest = fRandomList.FindMin();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the smallest is assigned to lSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMax()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMax()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lLargest = fRandomList.FindMax();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the largest is assigned to lLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sum()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Sum()&lt;br /&gt;
float Sum()&lt;br /&gt;
double Sum()&lt;br /&gt;
bool Sum()&lt;br /&gt;
cVector Sum()&lt;br /&gt;
cPoint Sum()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the total of all the items in the list, added together. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - the same as logical OR. For vectors, this is equivalent to the combined path of each vector.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lTot = listNumbers.Sum();&lt;br /&gt;
// lTot becomes 108.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListPoint listGridSteps;&lt;br /&gt;
listGridSteps.Add(cPoint(1, 0));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(-1, 0));&lt;br /&gt;
&lt;br /&gt;
cPoint vFinalPos = listGridSteps.Sum()&lt;br /&gt;
// This example imagines a puzzle involving steps on a grid. Each step is stored in a list of points and the final position is the sum of the list. (0,2 in this case.)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Average()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Average()&lt;br /&gt;
float Average()&lt;br /&gt;
double Average()&lt;br /&gt;
bool Average()&lt;br /&gt;
cVector Average()&lt;br /&gt;
cPoint Average()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the mean average of all the items in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that for ints, the answer will be truncated. For bools, this basically returns true if there are more true items than false. For vectors this is like finding the &amp;quot;centre of balance&amp;quot; of some points.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lAvg = listNumbers.Average();&lt;br /&gt;
// lAvg becomes 18.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListVector listGruntPos;&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt1&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt2&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt3&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
SetEntityPosVec(&amp;quot;orb&amp;quot;, listGruntPos.Average());&lt;br /&gt;
// This example imagines an effect where an entity is positioned at the mid-point between 3 enemies.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Ordering lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for ordering items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Swap()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Swap(uint aulA, uint aulB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Swaps the places of two items in the array. Returns false if either of the indeces are invalid, or true if the swap went ahead.&lt;br /&gt;
#''uint aulA'' - The index of the first item to be swapped.&lt;br /&gt;
#''uint aulB'' - The index of the second item to be swapped.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Swap(0, 1);&lt;br /&gt;
myListOfInts.Swap(1, 2);&lt;br /&gt;
// After the two swaps, the list is in numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sort()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Sort(abDescending = false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Re-orders a list of numbers, to put them in numerical order, using bubble sort. Bubble sort is simple but inefficient, so sorting large lists very frequently will have a performance impact. cListInt, cListFloat, cListDouble, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For vectors, the list will be sorted by square length.&lt;br /&gt;
#''bool abDescending (optional, default = false)'' - If true, the items will be ordered highest-to-lowest, otherwise lowest-to-highest.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Sort();&lt;br /&gt;
// The list is now sorted into ascending numerical order.&lt;br /&gt;
myListOfInts.Sort(true);&lt;br /&gt;
// The list is now sorted into descending numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Shuffle()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Shuffle()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Changes the order of the list to a new, random order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
for (int i = 1; i &amp;lt;= 10; i++) myListOfInts.Add(i);&lt;br /&gt;
myListOfInts.Shuffle();&lt;br /&gt;
// The list now contains the numbers 1 to 10, in a random order with no repetition or missing numbers.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Arrays from lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for transforming lists into arrays:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int[] ToArray()&lt;br /&gt;
float[] ToArray()&lt;br /&gt;
double[] ToArray()&lt;br /&gt;
string[] ToArray()&lt;br /&gt;
cVector[] ToArray()&lt;br /&gt;
cPoint[] ToArray()&lt;br /&gt;
cRotator[] ToArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes an new array, where each element in the array is a copy of an item from the list, and returns the array.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] ToArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes an new array, where each element in the array is a string version of each item in the list, and returns the array. (Uses the ToString() method of each node class.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Node classes=&lt;br /&gt;
The node classes contain the actual items in the lists and provide ways to access the data or links between nodes. Generally, it is '''not recommended''' to work with these directly, but use the functions of the list classes instead. More '''advanced users''' can extend the cListNodeBase class, or any class, and use it with cListGeneric.&lt;br /&gt;
&lt;br /&gt;
Available node classes: &amp;lt;code&amp;gt;cListNodeInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodePoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Behaviours===&lt;br /&gt;
In the derived node classes, the default constructor creates a node with a default item, or an argument can be provided to set the initial value. For example, in the cListNodeInt class:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeInt() 					// Creates an int node with value 0.&lt;br /&gt;
cListNodeInt(int alItem)		// Creates an int node with value alItem.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Properties===&lt;br /&gt;
All dervied node classes have one public property, named Item:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Item&lt;br /&gt;
float Item&lt;br /&gt;
double Item&lt;br /&gt;
bool Item&lt;br /&gt;
string Item&lt;br /&gt;
cVector Item&lt;br /&gt;
cPoint Item&lt;br /&gt;
cRotator Item&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The property Item can get or set the data item in the node, using the appropriate type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNext(cListNodeBase@ ahNext)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a handle to the next node. To break the link, assign null or use ClearNext().&lt;br /&gt;
#''cListNodeBase@ ahNext'' - A handle to an instance of cListNodeBase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeBase@ GetNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ClearNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Resets the handle to the next node to null&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6632</id>
		<title>HPL2/HPL2 Helper Scripts/Lists</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Lists&amp;diff=6632"/>
		<updated>2023-12-23T18:57:06Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Lists.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;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_Lists.hps&amp;quot; adds support for linked list classes. For beginners or other people not familiar with classes, these are best thought of as new variable types.&lt;br /&gt;
&lt;br /&gt;
A linked list, or just &amp;quot;list&amp;quot;, is a type of collection that works similarly to an array. Both lists and arrays are ways of grouping multiple variables together under one name. The advantages to using lists over arrays is that it is programmatically easier (and more performant) to insert, remove or re-order items in the list than it would be with an array.&lt;br /&gt;
&lt;br /&gt;
Lists can also take up less memory than arrays. The memory requirement of an array is defined by its maximum capacity, whereas the memory requirement of a list is only as much as its current content. It is not necessary to know in advance how big a list needs to be - it expands automatically as items are added.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===The basics===&lt;br /&gt;
Declare a list like any other variable, then use the methods below to work with it. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt myList;		// Declares a new cListInt, called myList, ready to collect integers.&lt;br /&gt;
myList.Add(68);			// Appends the first integer (68) to the list at index 0.&lt;br /&gt;
myList.Add(419);		// Appends the second integer (419) to the list at index 1.&lt;br /&gt;
myList.Get(0);			// Retrieves the integer at index 0.&lt;br /&gt;
myList.Set(1, 99);		// Overwrites the integer at index 1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Indices===&lt;br /&gt;
Like arrays, you can ''get'' the items in the list using an index operator, e.g. myList[0], myList[22], myList[LastIndex]. And like arrays, the index number is '''zero based'''. In a list or array of ten items, the first index is 0 and the last index is 9.&lt;br /&gt;
&lt;br /&gt;
Getting an item from a list by its index is equivalent to using the Get() method. However, ''unlike arrays'', this is '''read-only'''. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);		// OK&lt;br /&gt;
string myStringOne = myToDoList[1];				// OK&lt;br /&gt;
&lt;br /&gt;
myToDoList.Set(0, &amp;quot;Paint over the lines.&amp;quot;);		// OK&lt;br /&gt;
myToDoList[1] = &amp;quot;Cut the cheese.&amp;quot;;				// Not OK&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(This seems to be because the version of AngelScript used in HPL2 seems to only allow the index operator to ''get'' and not ''set''. If I'm wrong and you can make this work, let me know!)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
&amp;quot;HelperScripts_Lists.hps&amp;quot; also defines cListNodeBase and several derived node classes for each type of list. The list classes all inherit from the base class cListBase, which defines some shared functionality and handles anything that doesn't depend on the type of the stored data.&lt;br /&gt;
&lt;br /&gt;
Additionally, cListGeneric is an extra list class intended for advanced users. It extends the cListBase class without defining an inner data type, to help with making custom node classes derived from cListNodeBase. Advanced users attempting this may find it helpful to take a look at the cListBase and cListGeneric definition, and to read up on how AngelScript uses object handles. Examples can be found in most of the ''features'' scripts, e.g. &amp;quot;HelperScripts_Slimer.hps&amp;quot;, which implements multiple custom node classes and nested lists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=List classes=&lt;br /&gt;
&lt;br /&gt;
Available list classes: &amp;lt;code&amp;gt;cListInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListPoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;List classes&amp;quot; section refers to all the list types unless otherwise stated.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
Lists can be declared in the same way as other variables:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat listOfFloats;					// Declares a list of floats.&lt;br /&gt;
cListString listOfStrings;					// Declares a list of strings.&lt;br /&gt;
&lt;br /&gt;
myListOfFloats.Add(0.001f);					// Calling a method of the referred list.&lt;br /&gt;
int numStrings = myListOfStrings.Count;		// Accessing a property of the referred list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with capacity===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(uint aulMaxSize)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the list is initialised with a constructor, then a maximum capacity can be specified for the list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the list is declared without a specific capacity, then the default maximum capacity is assigned, which is 65535 (or 2^16 - 1).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat listOfFloatsDefault;&lt;br /&gt;
cListVector listOfVectorsDefault;&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfUpToFiveFloats = cListFloat(5);&lt;br /&gt;
cListVector listOfUpTo1000Vectors = cListVector(1000);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default 65535 (2^16-1) is the maximum capacity that can be indexed. Using this a or smaller arbitrary limit can help to catch runaway bugs. '''Advanced users''' may try changing the value of mulCountMax to use a smaller default maximum. Using a larger maximum will likely cause problems.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that arrays require as much memory as their full capacity even when empty, but lists are only ever as big as their content, so lowering the maximum size of the list does not help performance. But it might be useful in certain situations where a limit is required by design.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Constructor with data===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase(float[] afArray)&lt;br /&gt;
cListBase(cListBase aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Lists can be initialised with data by passing an array of values of the relevant type, or an existing list. The default capacity is used for the new list.&lt;br /&gt;
&amp;lt;br&amp;gt;If the source is an array, the new list will contain copies of the array's contents. If the source is an existing list, then the new list will copy the ''link'' to the original items. Both the old and new lists will point to the same data, and changing one will change the other. To avoid this, see the [[HPL2/HPL2_Helper_Scripts/Lists#Copy.28.29|Copy()]] method.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
float[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListFloat myFirstList = cListFloat(myArray);			// Makes a new float list by copying items from the float array.&lt;br /&gt;
cListFloat mySecondList = myFirstList;					// Makes a new float list containing the same items as the other list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListFloat(float afSingleFloat)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
All the derived list classes ('''except for cListGeneric and cListInt''') can be initialised with data by passing a single value of the relevant type, to become the first item in the list.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat myList = cListFloat(1.2f);				// Makes a new float list with a single value.&lt;br /&gt;
myList.Add(2.3f);									// myList now contains: 1.2f, 2.3f&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
'''All list classes''' provide the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Count====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Count&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property Count returns the current number of items in the list.&lt;br /&gt;
(The property Length and the method length() are provided for consistency with arrays, and are both equivalent to Count.)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat myList;&lt;br /&gt;
uint ulCountA = myList.Count;&lt;br /&gt;
myList.Add(99.99f);&lt;br /&gt;
uint ulCountB = myList.Count;&lt;br /&gt;
// ulCountA is 0. ulCountB is 1.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (listNumbers.Count &amp;lt; 6) listNumber.Add(42);&lt;br /&gt;
// The condition succeeds if the count is less than 6, and another number is added.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====LastIndex====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint LastIndex&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only integer property LastIndex returns the last valid index, or -1 if the list is empty.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
uint ulA = myListOfStrings.LastIndex;&lt;br /&gt;
uint ulB = myListOfStrings.Count - 1;&lt;br /&gt;
// ulA and ulB are equal&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string sLatest = myListOfStrings[myListOfStrings.LastIndex];&lt;br /&gt;
// sLatest becomes whatever string was added to the list most recently.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsEmpty====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEmpty&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsEmpty returns true if the list is empty, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (myList.IsEmpty) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list contains no items.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IsFull====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsFull&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The read-only boolean property IsFull returns true if the list is full to its maximum capacity, or false if not.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (!myList.IsFull) myList.Add(1);&lt;br /&gt;
// The condition succeeds if the list has space for another item.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Operators==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Assignment====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListBase = cListBase&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The assignment operator (equals sign &amp;quot;=&amp;quot;) assigns a new set of data to the list, copied from another list. Note: the list contains handles to the data, not the data itself. So when a list is copied, ''both'' lists now refer to the same data, and any changes made to either will affect both.&lt;br /&gt;
&amp;lt;br&amp;gt;If the intent is to make a duplicate of the ''data'' rather than the list handles, then the Copy() method is recommended.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Setting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for assigning items to the list:&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(int alItem)&lt;br /&gt;
bool Add(float afItem)&lt;br /&gt;
bool Add(double adItem)&lt;br /&gt;
bool Add(bool abItem)&lt;br /&gt;
bool Add(string asItem)&lt;br /&gt;
bool Add(cVector avItem)&lt;br /&gt;
bool Add(cPoint avItem)&lt;br /&gt;
bool Add(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Creates a new item appended to the list. If the list is full or the item cannot be added, it returns false. If it was successfull appended, it returns true.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfFloats.Add(1.0f);&lt;br /&gt;
myListOfPoints.Add(cPoint(10, 15, 20));&lt;br /&gt;
// The new values are appended to the list.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!listNumbers.Add(-1.0f)) Debug.Message(1, &amp;quot;Error - could not add to list!&amp;quot;);&lt;br /&gt;
// The condition succeeds if Add failed.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Set()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Set(uint aulIndex, int alItem)&lt;br /&gt;
bool Set(uint aulIndex, float afItem)&lt;br /&gt;
bool Set(uint aulIndex, double adItem)&lt;br /&gt;
bool Set(uint aulIndex, bool abItem)&lt;br /&gt;
bool Set(uint aulIndex, string asItem)&lt;br /&gt;
bool Set(uint aulIndex, cVector avItem)&lt;br /&gt;
bool Set(uint aulIndex, cPoint avItem)&lt;br /&gt;
bool Set(uint aulIndex, cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a new value to an indexed item in the list, if it exists. If the list is shorter than the index or the item cannot be added, this returns false. If it was successfull set, it returns true.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be changed.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be assigned.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
myListOfBools.Set(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, replacing the previous one.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Insert()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Insert(uint aulIndex, int alItem)&lt;br /&gt;
bool Insert(uint aulIndex, float afItem)&lt;br /&gt;
bool Insert(uint aulIndex, double adItem)&lt;br /&gt;
bool Insert(uint aulIndex, bool abItem)&lt;br /&gt;
bool Insert(uint aulIndex, string asItem)&lt;br /&gt;
bool Insert(uint aulIndex, cVector avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cPoint avItem)&lt;br /&gt;
bool Insert(uint aulIndex, cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Inserts a new item into the list at the given index. (The item previous at that index becomes the next one.) If the given index is not a valid place to insert an item, then then return value will be false. Otherwise the item is inserted and it returns true.&lt;br /&gt;
#''uint aulIndex'' - The index where the new item will be inserted.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be inserted.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myListOfBools.Insert(7, false);&lt;br /&gt;
// The bool at index 7 in the list becomes false, displacing the previous one to index 8.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (!myList.Insert(10, &amp;quot;hello&amp;quot;) myList.Add(&amp;quot;hello&amp;quot;);&lt;br /&gt;
// Attempts to insert the string at index 10, and if that fails the string is appended instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Concatenate()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Concatenate(cListBase aList)&lt;br /&gt;
bool Concatenate(int[] alArray)&lt;br /&gt;
bool Concatenate(float[] afArray)&lt;br /&gt;
bool Concatenate(double[] adArray)&lt;br /&gt;
bool Concatenate(bool[] abArray)&lt;br /&gt;
bool Concatenate(string[] asArray)&lt;br /&gt;
bool Concatenate(cVector[] avArray)&lt;br /&gt;
bool Concatenate(cPoint[] avArray)&lt;br /&gt;
bool Concatenate(cRotator[] avArray)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Takes either a second list or array of the same type and appends it to this one. It first checks to make sure there is enough capacity. Returns true if items were successfully added, or false if not.&lt;br /&gt;
&amp;lt;br&amp;gt;If an array is supplied, new list items are created to match them. If a list is suplied the items are '''not duplicated''' - both lists refer to the same items in memory, and changing them will change both lists.&lt;br /&gt;
#''cListBase aList (or any list type), or an array of int[], float[], double[], bool[], string[], cVector[], cPoint[] or cRotator[]'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
float[] arrayOfFloatsB = { 3.0f, 4.0f };&lt;br /&gt;
listOfFloatsA.Concatenate(arrayOfFloatsB);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 4.0f.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListFloat listOfFloatsA;&lt;br /&gt;
listOfFloatsA.Add(1.0f);&lt;br /&gt;
listOfFloatsA.Add(2.0f);&lt;br /&gt;
&lt;br /&gt;
cListFloat listOfFloatsB;&lt;br /&gt;
listOfFloatsB.Add(3.0f);&lt;br /&gt;
listOfFloatsB.Add(4.0f);&lt;br /&gt;
&lt;br /&gt;
listOfFloatsA.Concatenate(listOfFloatsB);&lt;br /&gt;
listOfFloatsA.Set(3, 99.9f);&lt;br /&gt;
// listOfFloatsA now contains 1.0f, 2.0f, 3.0f, 99.9f.&lt;br /&gt;
// listOfFloatsB now contains 3.0f, 99.9f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Getting list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for retrieving items from the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Get()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Get(uint aulIndex)&lt;br /&gt;
float Get(uint aulIndex)&lt;br /&gt;
double Get(uint aulIndex)&lt;br /&gt;
bool Get(uint aulIndex)&lt;br /&gt;
string Get(uint aulIndex)&lt;br /&gt;
cVector Get(uint aulIndex)&lt;br /&gt;
cPoint Get(uint aulIndex)&lt;br /&gt;
cRotator Get(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, if it exists. If the item does not exist in the list, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;br&amp;gt;See GetIfValid() if you want to be sure the item exists. You can also use an index operator (e.g. myList[i]) to get list items.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myToDoList;&lt;br /&gt;
myToDoList.Add(&amp;quot;Paint the lines.&amp;quot;);&lt;br /&gt;
myToDoList.Add(&amp;quot;Cut the man.&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
string myStringZero = myToDoList.Get(0);&lt;br /&gt;
string myStringLast = myToDoList.Get(myToDoList.LastIndex);&lt;br /&gt;
// myStringZero becomes the value from the start of the list.&lt;br /&gt;
// myStringLast becomes the value that happens to be at the end of the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetIfValid()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool GetIfValid(uint aulIndex, int &amp;amp;out alTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, float &amp;amp;out afTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, double &amp;amp;out adTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, bool &amp;amp;out abTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, string &amp;amp;out asTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cVector &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cPoint &amp;amp;out avTarget)&lt;br /&gt;
bool GetIfValid(uint aulIndex, cRotator &amp;amp;out avTarget)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and retrieves an item from the given index, as long as it is valid.&lt;br /&gt;
&amp;lt;br&amp;gt;The second parameter is an ''ouput'' parameter. If the item at the given index exists then '''the item is assigned to the Target &amp;amp;out parameter''', and the function returns true. If the item doesn't exist in the list, the function returns false.&lt;br /&gt;
&amp;lt;br&amp;gt;See Get() if you don't care about validation and just want to return the item.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be retrieved.&lt;br /&gt;
#''int alTarget, float afTarget, double adTarget, bool abTarget, string asTarget, cVector avTarget, cPoint avTarget, or cRotator avTarget'' - The variable, of the appropriate type, where the retrieved item will be '''stored'''.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int retrievedInteger;&lt;br /&gt;
if(!myListOfInts.GetIfValid(3, retrievedInteger)) retrievedInteger = -1;&lt;br /&gt;
// retrievedInteger will be assigned the value retrieved from index 3 in the list, if it exists.&lt;br /&gt;
// If it doesn't exist, the condition will succeed and retrievedInteger with be assigned -1 instead.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int GetRandom()&lt;br /&gt;
float GetRandom()&lt;br /&gt;
double GetRandom()&lt;br /&gt;
bool GetRandom()&lt;br /&gt;
string GetRandom()&lt;br /&gt;
cVector GetRandom()&lt;br /&gt;
cPoint GetRandom()&lt;br /&gt;
cRotator GetRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list and returns it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Pop()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Pop()&lt;br /&gt;
float Pop()&lt;br /&gt;
double Pop()&lt;br /&gt;
bool Pop()&lt;br /&gt;
string Pop()&lt;br /&gt;
cVector Pop()&lt;br /&gt;
cPoint Pop()&lt;br /&gt;
cRotator Pop()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the last item in the list, and removes that item. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lA = listNumbers.Pop();&lt;br /&gt;
int lB = listNumbers.Pop();&lt;br /&gt;
int lC = listNumbers.Pop();&lt;br /&gt;
// lA, lB, and lC have become 23, 16, and 15. myArray now contains only 4 and 8.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====PopRandom()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int PopRandom()&lt;br /&gt;
float PopRandom()&lt;br /&gt;
double PopRandom()&lt;br /&gt;
bool PopRandom()&lt;br /&gt;
string PopRandom()&lt;br /&gt;
cVector PopRandom()&lt;br /&gt;
cPoint PopRandom()&lt;br /&gt;
cRotator PopRandom()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Randomly selects an item from the list, returns it and them removes it. If the list is empty, a default value will be returned instead, e.g. -1 or an empty string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sRandomColor = listOfColors.GetRandom();&lt;br /&gt;
// The string sRandomColor is assigned a random value from listOfColors, and that value is no longer available in the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Copy()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListInt Copy(cListInt aList)&lt;br /&gt;
cListFloat Copy(cListFloat aList)&lt;br /&gt;
cListDouble Copy(cListDouble aList)&lt;br /&gt;
cListBool Copy(cListBool aList)&lt;br /&gt;
cListVector Copy(cListVector aList)&lt;br /&gt;
cListPoint Copy(cListPoint aList)&lt;br /&gt;
cListRotator Copy(cListRotator aList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a new list that is a duplicate of this list. The items in the new list are new items. Changing either list will not affect the other.&lt;br /&gt;
#''cListBase aList (or any list type)'' - The items to be added.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listA;&lt;br /&gt;
listA.Add(&amp;quot;one&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;two&amp;quot;);&lt;br /&gt;
listA.Add(&amp;quot;three&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
cListString listB = listA;&lt;br /&gt;
&lt;br /&gt;
cListString listC;&lt;br /&gt;
listC = listA.Copy();&lt;br /&gt;
&lt;br /&gt;
listA.Set(2, &amp;quot;banana&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
// listA and listB both lists refer to the same 3 strings, and the final content of both listA and listB is: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;banana&amp;quot;.&lt;br /&gt;
// listC was made as a copy, so it was not affected when listA[2] was changed. listC still has: &amp;quot;one&amp;quot;, &amp;quot;two&amp;quot;, &amp;quot;three&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Removing list items===&lt;br /&gt;
cListBase and its derived classes provide the following methods for removing items from the list: (See also: Pop() and PopRandom())&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAt(uint aulIndex)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Traverses the list and removes the given index.&lt;br /&gt;
Returns true if the index was valid and was removed, or false if not.&lt;br /&gt;
#''uint aulIndex'' - The index of the item to be removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
myList.RemoveAt(7);&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (myList.RemoveAt(7)) myList.Append(&amp;quot;something new&amp;quot;);&lt;br /&gt;
// If the removal was successful, then a new value is appended.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveItem(int alItem)&lt;br /&gt;
bool RemoveItem(float afItem)&lt;br /&gt;
bool RemoveItem(double adItem)&lt;br /&gt;
bool RemoveItem(bool abItem)&lt;br /&gt;
bool RemoveItem(string asItem)&lt;br /&gt;
bool RemoveItem(cVector avItem)&lt;br /&gt;
bool RemoveItem(cPoint avItem)&lt;br /&gt;
bool RemoveItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and removes the first matching item it finds. Returns true if the item was found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
myListOfBools.RemoveItem(false);&lt;br /&gt;
// The first instance of false in the list will be removed.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
int  lRemoved = 0;&lt;br /&gt;
int[] myArray = { 4, 8, 0, 15, 16, 0, 23, 0 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
while (listNumbers.Remove(0))&lt;br /&gt;
{&lt;br /&gt;
    lRemoved++;&lt;br /&gt;
	DoStuff();&lt;br /&gt;
}&lt;br /&gt;
// The Remove() call will repeat until it returns false, at which point the value of lRemoved will be 3.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====RemoveAll()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool RemoveAll(int alItem)&lt;br /&gt;
bool RemoveAll(float aItem)&lt;br /&gt;
bool RemoveAll(double aItem)&lt;br /&gt;
bool RemoveAll(bool aItem)&lt;br /&gt;
bool RemoveAll(string aItem)&lt;br /&gt;
bool RemoveAll(cVector aItem)&lt;br /&gt;
bool RemoveAll(cPoint aItem)&lt;br /&gt;
bool RemoveAll(cRotator aItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and removes the all matching items. Returns true if any items were found and removed, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for and removed.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
myListOfFloats.RemoveAll(0.0f);&lt;br /&gt;
// All the zeros will be removed from the list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Searching lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for searching for items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Find()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Find(int alItem)&lt;br /&gt;
int Find(float afItem)&lt;br /&gt;
int Find(double adItem)&lt;br /&gt;
int Find(bool abItem)&lt;br /&gt;
int Find(string asItem)&lt;br /&gt;
int Find(cVector avItem)&lt;br /&gt;
int Find(cPoint avItem)&lt;br /&gt;
int Find(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns the index of the first match. If the item is not found, -1 is returned instead.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
uint lIndexTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
uint lIndexFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// lIndexTwentyTwo becomes 1. lIndexFortyFour becomes -1.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Contains()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Contains(int alItem)&lt;br /&gt;
bool Contains(float afItem)&lt;br /&gt;
bool Contains(double adItem)&lt;br /&gt;
bool Contains(bool abItem)&lt;br /&gt;
bool Contains(string asItem)&lt;br /&gt;
bool Contains(cVector avItem)&lt;br /&gt;
bool Contains(cPoint avItem)&lt;br /&gt;
bool Contains(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for a matching item and returns true if found, or false if not.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
&lt;br /&gt;
bool bHasTwentyTwo = myListOfInts.Find(22);&lt;br /&gt;
bool bHasFortyFour = myListOfInts.Find(44);&lt;br /&gt;
// bHasTwentyTwo becomes true. bHasFortyFour becomes false.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CountItem()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint CountItem(int alItem)&lt;br /&gt;
uint CountItem(float afItem)&lt;br /&gt;
uint CountItem(double adItem)&lt;br /&gt;
uint CountItem(bool abItem)&lt;br /&gt;
uint CountItem(string asItem)&lt;br /&gt;
uint CountItem(cVector avItem)&lt;br /&gt;
uint CountItem(cPoint avItem)&lt;br /&gt;
uint CountItem(cRotator avItem)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches the list for matching items and returns the number of matches found.&lt;br /&gt;
#''int alItem, float afItem, double adItem, bool abItem, string asItem, cVector avItem, cPoint avItem, or cRotator avItem'' - The item, of the appropriate type, to be searched for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myListOfStrings;&lt;br /&gt;
myListOfStrings.Add(&amp;quot;up&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;sideways&amp;quot;);&lt;br /&gt;
myListOfStrings.Add(&amp;quot;down&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
int lNumDown = myListOfStrings.CountItem(&amp;quot;down&amp;quot;);&lt;br /&gt;
int lNumForward = myListOfStrings.CountItem(&amp;quot;forward&amp;quot;);&lt;br /&gt;
// lNumDown becomes 2. lNumForward becomes 0.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Numeric lists===&lt;br /&gt;
Some of the derived list classes dealing with numeric values provide the methods for arithmetic operations across the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Min()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Min()&lt;br /&gt;
float Min()&lt;br /&gt;
double Min()&lt;br /&gt;
bool Min()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns false if there is a false - like logical AND over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fSmallest = fRandomList.Min();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the smallest is assigned to fSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Max()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Max()&lt;br /&gt;
float Max()&lt;br /&gt;
double Max()&lt;br /&gt;
bool Max()&lt;br /&gt;
cVector Min()&lt;br /&gt;
cPoint Min()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - like logical OR over the list. For vectors and points, this evaluates and compares each square length.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
float fLargest = fRandomList.Max();&lt;br /&gt;
// fRandomList is assigned ten random floats, and whichever is the largest is assigned to fLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMin()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMin()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the lowest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lSmallest = fRandomList.FindMin();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the smallest is assigned to lSmallest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====FindMax()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint FindMax()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the first index of the item with the highest value in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListFloat fRandomList;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 10; i++) fRandomList.Add(Math.RandomFloat());&lt;br /&gt;
int lLargest = fRandomList.FindMax();&lt;br /&gt;
// fRandomList is assigned ten random floats, and the index of the largest is assigned to lLargest.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sum()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Sum()&lt;br /&gt;
float Sum()&lt;br /&gt;
double Sum()&lt;br /&gt;
bool Sum()&lt;br /&gt;
cVector Sum()&lt;br /&gt;
cPoint Sum()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the total of all the items in the list, added together. cListInt, cListFloat, cListDouble, cListBool, cListVector, and cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For bools, this is returns true if there is a true - the same as logical OR. For vectors, this is equivalent to the combined path of each vector.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lTot = listNumbers.Sum();&lt;br /&gt;
// lTot becomes 108.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListPoint listGridSteps;&lt;br /&gt;
listGridSteps.Add(cPoint(1, 0));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(0, 1));&lt;br /&gt;
listGridSteps.Add(cPoint(-1, 0));&lt;br /&gt;
&lt;br /&gt;
cPoint vFinalPos = listGridSteps.Sum()&lt;br /&gt;
// This example imagines a puzzle involving steps on a grid. Each step is stored in a list of points and the final position is the sum of the list. (0,2 in this case.)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Average()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Average()&lt;br /&gt;
float Average()&lt;br /&gt;
double Average()&lt;br /&gt;
bool Average()&lt;br /&gt;
cVector Average()&lt;br /&gt;
cPoint Average()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the mean average of all the items in the list. cListInt, cListFloat, cListDouble, cListBool, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;Note that for ints, the answer will be truncated. For bools, this basically returns true if there are more true items than false. For vectors this is like finding the &amp;quot;centre of balance&amp;quot; of some points.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//Example 1:&lt;br /&gt;
int[] myArray = { 4, 8, 15, 16, 23, 42 };&lt;br /&gt;
cListInt listNumbers = cListInt(myArray);&lt;br /&gt;
int lAvg = listNumbers.Average();&lt;br /&gt;
// lAvg becomes 18.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListVector listGruntPos;&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt1&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt2&amp;quot;));&lt;br /&gt;
listGruntPos.Add(GetEntityPosVec(&amp;quot;grunt3&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
SetEntityPosVec(&amp;quot;orb&amp;quot;, listGruntPos.Average());&lt;br /&gt;
// This example imagines an effect where an entity is positioned at the mid-point between 3 enemies.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Ordering lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for ordering items in the list:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Swap()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Swap(uint aulA, uint aulB)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Swaps the places of two items in the array. Returns false if either of the indeces are invalid, or true if the swap went ahead.&lt;br /&gt;
#''uint aulA'' - The index of the first item to be swapped.&lt;br /&gt;
#''uint aulB'' - The index of the second item to be swapped.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Swap(0, 1);&lt;br /&gt;
myListOfInts.Swap(1, 2);&lt;br /&gt;
// After the two swaps, the list is in numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sort()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Sort(abDescending = false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Re-orders a list of numbers, to put them in numerical order, using bubble sort. Bubble sort is simple but inefficient, so sorting large lists very frequently will have a performance impact. cListInt, cListFloat, cListDouble, cListVector, cListPoint only.&lt;br /&gt;
&amp;lt;br&amp;gt;For vectors, the list will be sorted by square length.&lt;br /&gt;
#''bool abDescending (optional, default = false)'' - If true, the items will be ordered highest-to-lowest, otherwise lowest-to-highest.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
myListOfInts.Add(33);&lt;br /&gt;
myListOfInts.Add(11);&lt;br /&gt;
myListOfInts.Add(22);&lt;br /&gt;
myListOfInts.Add(44);&lt;br /&gt;
myListOfInts.Sort();&lt;br /&gt;
// The list is now sorted into ascending numerical order.&lt;br /&gt;
myListOfInts.Sort(true);&lt;br /&gt;
// The list is now sorted into descending numerical order.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Shuffle()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void Shuffle()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Changes the order of the list to a new, random order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListInt myListOfInts;&lt;br /&gt;
for (int i = 1; i &amp;lt;= 10; i++) myListOfInts.Add(i);&lt;br /&gt;
myListOfInts.Shuffle();&lt;br /&gt;
// The list now contains the numbers 1 to 10, in a random order with no repetition or missing numbers.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Arrays from lists===&lt;br /&gt;
cListBase and its derived classes provide the following methods for transforming lists into arrays:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int[] ToArray()&lt;br /&gt;
float[] ToArray()&lt;br /&gt;
double[] ToArray()&lt;br /&gt;
string[] ToArray()&lt;br /&gt;
cVector[] ToArray()&lt;br /&gt;
cPoint[] ToArray()&lt;br /&gt;
cRotator[] ToArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes an new array, where each element in the array is a copy of an item from the list, and returns the array.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToStringArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] ToArray()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Makes an new array, where each element in the array is a string version of each item in the list, and returns the array. (Uses the ToString() method of each node class.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Node classes=&lt;br /&gt;
The node classes contain the actual items in the lists and provide ways to access the data or links between nodes. Generally, it is '''not recommended''' to work with these directly, but use the functions of the list classes instead. More '''advanced users''' can extend the cListNodeBase class, or any class, and use it with cListGeneric.&lt;br /&gt;
&lt;br /&gt;
Available node classes: &amp;lt;code&amp;gt;cListNodeInt&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeFloat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeDouble&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeBool&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeString&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodeVector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListNodePoint&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;cListRotator&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Behaviours===&lt;br /&gt;
In the derived node classes, the default constructor creates a node with a default item, or an argument can be provided to set the initial value. For example, in the cListNodeInt class:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeInt() 					// Creates an int node with value 0.&lt;br /&gt;
cListNodeInt(int alItem)		// Creates an int node with value alItem.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Properties===&lt;br /&gt;
All dervied node classes have one public property, named Item:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Item====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Item&lt;br /&gt;
float Item&lt;br /&gt;
double Item&lt;br /&gt;
bool Item&lt;br /&gt;
string Item&lt;br /&gt;
cVector Item&lt;br /&gt;
cPoint Item&lt;br /&gt;
cRotator Item&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The property Item can get or set the data item in the node, using the appropriate type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Methods===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetNext(cListNodeBase@ ahNext)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assigns a handle to the next node. To break the link, assign null or use ClearNext().&lt;br /&gt;
#''cListNodeBase@ ahNext'' - A handle to an instance of cListNodeBase.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====GetNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListNodeBase@ GetNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ClearNext()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void ClearNext()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the handle to the next node. If there isn't one, it will return null.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Resets the handle to the next node to null&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/String&amp;diff=6631</id>
		<title>HPL2/HPL2 Helper Scripts/String</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/String&amp;diff=6631"/>
		<updated>2023-12-22T23:40:53Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_String.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;
=Summary=&lt;br /&gt;
&lt;br /&gt;
The script file &amp;quot;HelperScripts_String.hps&amp;quot; provides some extended maths functionality for modders. The new String class contains additional string functions, including replacement, sequence generation and more.&lt;br /&gt;
&lt;br /&gt;
Despite the name, this is not a string class itself, and does not contain text or replace the &amp;quot;string&amp;quot; type. String should be used similarly to Math, as a library of functions. For example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string welcomeText = &amp;quot;I bid you welcome to my cabinet of perturbation.&amp;quot;;&lt;br /&gt;
string cabinetType = &amp;quot;liquor&amp;quot;;&lt;br /&gt;
welcomeText = String.ReplaceAll(welcomeText, &amp;quot;perturbation&amp;quot;, cabinetType);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;HelperScripts_String.hps&amp;quot; also defines the Str class. The Str class is intended to provide something like a template parameter, or a loosely typed variable, for string formatting.&lt;br /&gt;
&lt;br /&gt;
=String=&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
&amp;quot;HelperScripts_String.hps&amp;quot; script declares an object called '''String''', of the new script class cString. To access its methods, just use &amp;quot;String.&amp;quot; followed by the function call. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
String.Replace(&amp;quot;catfish&amp;quot;, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
String has no public properties. &lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
&lt;br /&gt;
===Length===&lt;br /&gt;
String provides the following methods for working with string sizes:&lt;br /&gt;
&lt;br /&gt;
====IsEmpty()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool IsEmpty(string asString, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if the string is empty (&amp;quot;&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), only the length of the string will be considered. With any other trim option, whitespace and control characters will be not be counted. E.g. &amp;quot; &amp;quot; would count as empty if a trim option other than trimNone was used.&lt;br /&gt;
#''string asString'' - The string to check if empty.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd or trimAll. (Optional, default = trimNone)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
bool bA = String.IsEmpty(&amp;quot; &amp;quot;);&lt;br /&gt;
bool bB = String.IsEmpty(&amp;quot; &amp;quot;, trimAll);&lt;br /&gt;
// bA is assigned false. bB is assigned true, as the empty space is not counted.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Length()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint Length(string asString, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the number of characters in the string.&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), only the length of the string will be considered. This is the same as asString.length(). With any other trim option, whitespace and control characters will be not be counted. E.g. &amp;quot; &amp;quot; would count as empty if a trim option other than trimNone was used.&lt;br /&gt;
#''string asString'' - The string to check the length of.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimNone)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
int lA = String.Length(&amp;quot; words words words   &amp;quot;);&lt;br /&gt;
int lB = String.Length(&amp;quot; words words words   &amp;quot;, trimEnd);&lt;br /&gt;
int lC = String.Length(&amp;quot; words words words   &amp;quot;, trimAll);&lt;br /&gt;
// lA becomes 21, lB becomes 18 and lC becomes 17.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
while (sSleepy.Length() &amp;lt; 20) sSleepy += &amp;quot;z&amp;quot;;&lt;br /&gt;
// The while loop continues until the string is at least 20 characters long.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Trim()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Trim(string &amp;amp;in asString, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Removes whitespace and control characters from the beginning and end of a string. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
&amp;lt;br&amp;gt; aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, the string will not be trimmed. With trimStart, whitespace and control characters will be removed from the start of the string. With trimEnd, whitespace and control characters will be removed from the end of the string. With trimAll (default), whitespace and control characters will be removed from both ends of the string.&lt;br /&gt;
#''string asString'' - The string to trim.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sSpooky = &amp;quot;  sppoooky  &amp;quot;;&lt;br /&gt;
sSpooky = String.Trim(aSpooky, trimStart);&lt;br /&gt;
// The initial spaces have been removed. sSpooky now equals &amp;quot;sppoooky  &amp;quot;.&lt;br /&gt;
sSpooky = String.Trim(aSpooky);&lt;br /&gt;
// Now the trailing spaces have been removed too. sSpooky now equals &amp;quot;spoooky&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Parsing===&lt;br /&gt;
String provides the following methods for parsing strings:&lt;br /&gt;
&lt;br /&gt;
====ToInt()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int ToInt(string asString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If possible, returns an integer converted from a string, else returns 0. This is the same as the normal global function StringToInt(), but is included here for consistency.&lt;br /&gt;
&lt;br /&gt;
====ToFloat()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
float ToFloat(string asString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If possible, returns a float converted from a string, else returns 0.0f. This is the same as the normal global function StringToFloat(), but is included here for consistency.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToBool()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool ToBool(string asString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If possible, returns a boolean converted from a string, else returns false. This is the same as the normal global function StringToBool(), but is included here for consistency.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Characters===&lt;br /&gt;
String provides the following miscellaneous methods for working with character codes:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CharToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string CharToString(uint8 auiChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an ASCII character code, this returns a string containing that single character. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''uint8 auiChar'' - An ASCII character code to be converted to a string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sSymbols = String.CharToString(126) + String.CharToString(64) + String.CharToString(63);&lt;br /&gt;
// sSymbols now says &amp;quot;~@?&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StringToChar()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint8 StringToChar(string asSingleChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a single character string, this returns that character as an ASCII code. If the string is empty then 0 is returned (null character). If the string is longer than one character, the rest are ignored. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''string asSingleChar'' - A string containing a character to be converted to a character code.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
uint8 uiCharacter = String.StringToChar(sSomeText);&lt;br /&gt;
if (uiCharacter &amp;gt;= 48 &amp;amp;&amp;amp; ul8Character &amp;lt;= 57) DoStuff();&lt;br /&gt;
// The condition succeeds if the first character of sSomeText is a numeric digit (ASCII codes 48-57).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====CharArrayToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string CharArrayToString(uint8[] ausCharArray, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given an array of ASCII codes, this returns those character joined into a string. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), any whitespace or control characters in the array will be included. With trimStart, any whitespace or control characters at the start of the array will be excluded. With trimEnd, any whitespace or control characters at the end of the array will be excluded. With trimAll, any whitespace or control characters at either end of the array will be excluded.&lt;br /&gt;
#''uint8[] ausCharArray'' - An array of ASCII character codes (unsigned 8bit ints), to be joined.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimNone)&lt;br /&gt;
See StringToCharArray() for an example.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StringToCharArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
uint8[] StringToCharArray(string asString, enumStringTrim aTrimOption = trimNone)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string, this splits the string and returns it as an array of ASCII codes. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone (default), any whitespace or control characters in the string will be included. With trimStart, any whitespace or control characters at the start of the string will be excluded. With trimEnd, any whitespace or control characters at the end of the string will be excluded. With trimAll, any whitespace or control characters at either end of the string will be excluded.&lt;br /&gt;
#''string asString'' - A string to be split.&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimNone)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string Rot13(string asInput)&lt;br /&gt;
{&lt;br /&gt;
	uint8[] chars = String.StringToCharArray(asInput, trimAll);&lt;br /&gt;
	for (uint i = 0; i &amp;lt; chars.length(); i++)&lt;br /&gt;
	{&lt;br /&gt;
		if (chars[i] &amp;gt;= 65 &amp;amp;&amp;amp; chars[i] &amp;lt;= 90 || chars[i] &amp;gt;= 141 &amp;amp;&amp;amp; chars[i] &amp;lt;= 172)&lt;br /&gt;
		{&lt;br /&gt;
			chars[i] += 13;&lt;br /&gt;
			if (chars[i] &amp;gt; 90 &amp;amp;&amp;amp; chars[i] &amp;lt; 141 || chars[i] &amp;gt; 172) &lt;br /&gt;
			{&lt;br /&gt;
				chars[i] -= 26;&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
	return String.CharArrayToString(chars );&lt;br /&gt;
}&lt;br /&gt;
// This example is a whole Rot13 function. The string arg asInput is broken into an array of chars. Any char that is a upper or lower case alphabet letter is moved 13 characters. Then the char array is made back into a string and returned.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Case===&lt;br /&gt;
String provides the following methods for changing the case of a string:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToUpper()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToUpper(string asString)&lt;br /&gt;
uint8 ToUpper(uint8 auiChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string or a character code, this returns the character(s) as upper case. If any character is a lower case letter, it will be swapped for upper case. Otherwise they are unchanged. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''string asString, uint8 auiChar'' - A string or a single character code to be changed to upper case.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sUpper = String.ToUpper(&amp;quot;Dark Descent&amp;quot;);&lt;br /&gt;
// sUpper is assigned &amp;quot;DARK DESCENT&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
if (String.ToUpper(sSomeTextA) == String.ToUpper(sSomeTextB))&lt;br /&gt;
// The condition succeeds if sSomeTextA and sSomeTextB are equal, regardless of their capitalisation.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToLower()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToLower(string asString)&lt;br /&gt;
uint8 ToLower(uint8 auiChar)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string or a character code, this returns the character(s) as lower case. If any character is a upper case letter, it will be swapped for lower case. Otherwise they are unchanged. (Only works with ASCII, not full Unicode.)&lt;br /&gt;
#''string asString, uint8 auiChar'' - A string or a single character code to be changed to lower case.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sLower = String.ToLower(&amp;quot;Dark Descent&amp;quot;);&lt;br /&gt;
// sLower is assigned &amp;quot;dark descent&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Searching===&lt;br /&gt;
String provides the following methods for changing the case of a string:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Contains()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool Contains(string asString, string asSubString)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns true if asSubString can be found in asString. This is the same as the normal global function StringContains(), but is included in String for consistency.&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asSubString'' - The string to search for.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
if (String.Contains(sCurrentObjective, &amp;quot;thalers&amp;quot;);&lt;br /&gt;
// The condition succeeds if the string sCurrentObjective contains the substring &amp;quot;thalers&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Find()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
int Find(string asString, string asSubString, enumStringCase aCaseOption = caseSensitive, enumStringDirection aDirOption = dirFromStart)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches for a substring within a string, and the returns the index of the first character of the first instance of the substring.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aDirOption can be omitted, or optionally can be either dirFromStart, or dirFromEnd. With dirFromStart (default), the string is searched from the left, and the index returned is the first instance. With dirFromEnd, the string is searched from the right, and the index returned is the last instance.&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asSubString'' - The string to search for.&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringDirection aDirOption'' - dirFromStart or dirFromEnd. (Optional, default = dirFromStart)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
int lA = String.Find(&amp;quot;Grunt&amp;quot;, &amp;quot;run&amp;quot;);&lt;br /&gt;
int lB = String.Find(&amp;quot;Agrippa&amp;quot;, &amp;quot;RIP&amp;quot;, caseInsensitive);&lt;br /&gt;
int lC = String.Find(&amp;quot;Herbert&amp;quot;, &amp;quot;er&amp;quot;);&lt;br /&gt;
int lD = String.Find(&amp;quot;Herbert&amp;quot;, &amp;quot;er&amp;quot;, dirFromEnd);&lt;br /&gt;
// lA is assigned 1. lB is assigned 2.&lt;br /&gt;
// lC is assigned 1, but searching from the end lD is assigned 4.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Substrings===&lt;br /&gt;
String provides the following methods for working with parts of strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Sub()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Sub(string asString, uint aulStart, uint aulCount)&lt;br /&gt;
string Sub(string asString, uint aulStart)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns part of a string. This is the same as the normal global function StringSub(), except that aulCount can be omitted. If aulCount is specified, the substring returned starts at aulStart and proceeds for aulCount characters. If aulCount is omitted then the substring starts at aulStart and proceeds to the end of the original string.&lt;br /&gt;
#''string asString'' - The string to get the substring from.&lt;br /&gt;
#''uint aulStart'' - The index of the character that is the start of the substring.&lt;br /&gt;
#''uint aulCount'' - The number of characters in the substring. (Optional, default = the remaining length of the string)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sA = String.Sub(&amp;quot;grunt&amp;quot;, 1, 3);&lt;br /&gt;
string sB = String.Sub(&amp;quot;grunt&amp;quot;, 1);&lt;br /&gt;
// sA is assigned &amp;quot;run&amp;quot;. sB is assigned &amp;quot;runt&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Replace()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Replace(string asString, string asFind, string asReplace, enumStringCase aCaseOption = caseSensitive, enumStringDirection aDirOption = dirFromStart)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches through a string and if it finds an instance of a given substring, it replaces it with another. Replace() replaces the first instance found. To replace all instances, consider ReplaceAll().&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt; aDirOption can be omitted, or optionally can be either dirFromStart, or dirFromEnd. With dirFromStart (default), the string is searched from the left, and the index returned is the first instance. With dirFromEnd, the string is searched from the right, and the index returned is the last instance.&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asFind'' - The string to search for.&lt;br /&gt;
#''asReplace'' - The string that will replace asFind if it is found.&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringDirection aDirOption'' - dirFromStart or dirFromEnd. (Optional, default = dirFromStart)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sMyStringA = &amp;quot;catfish catfood&amp;quot;;&lt;br /&gt;
string sMyStringB = String.Replace(sMyStringA, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;);&lt;br /&gt;
string sMyStringC = String.Replace(sMyStringA, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;, dirFromEnd);&lt;br /&gt;
// sMyStringB becomes &amp;quot;dogfish catfood&amp;quot;. sMyStringC becomes &amp;quot;catfish dogfood&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ReplaceAll()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ReplaceAll(string asString, string asFind, string asReplace, enumStringCase aCaseOption = caseSensitive)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Searches through a string and replaces all instances of a substring with another. To avoid an infinite loop, asReplace can't contain a match to asFind it would. Consider using Replace() instead.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
#''string asString'' - The string to search within.&lt;br /&gt;
#''string asFind'' - The string to search for.&lt;br /&gt;
#''asReplace'' - The string that will replace asFind if it is found.&lt;br /&gt;
#''aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
string sMyStringA = &amp;quot;catfish catfood&amp;quot;;&lt;br /&gt;
string sMyStringB = String.ReplaceAll(sMyStringA, &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;);&lt;br /&gt;
// sMyStringB becomes &amp;quot;dogfish dogfood&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Format()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Format(string asString, Str[] argArray)&lt;br /&gt;
string Format(string asString, Str arg0, Str arg1, ... Str arg7)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
A minimal version of the string formatting methods found in other languages. It doesn't provide number formating options, but it does allow an arbirtrary number of variables to be inserted into a string, regardless of data type, using the Str class. The Str class is just a container for a variable that can be turned into a string. In other languages we might use a template or a loosely typed variable. This is the method used by the cDebug class.&lt;br /&gt;
&amp;lt;br&amp;gt;Format() returns a string in which tokens like &amp;quot;{i}&amp;quot; have been replaced, where i is the index of the additional arguments, starting from zero. If an argument is supplied but the text doesn't contain a corresponding token, then the argument won't be included. If the text contains a token but not corresponding argument is supplied, then the token will remain in the output text.&lt;br /&gt;
&amp;lt;br&amp;gt;Up to eight individual Str arguments can be provides, or an array of Str. (Unfortunately, anonymous arrays as arguments are not supported, so the array must be declared.)&lt;br /&gt;
#''string asString'' - A template string containing tokens (&amp;quot;{i}&amp;quot;) to be replaced by the other arguments.&lt;br /&gt;
#''argArray or arg0'' - An array of Str instances, or a single Str instance, to replace tokens in the string.&lt;br /&gt;
#''arg1 - arg7'' - If not using an array, an additional 7 single Str arguments can be optionally given.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sNewString = String.Format(&amp;quot;I got {0} problems but this script ain't {1}.&amp;quot;, Str(99), Str(&amp;quot;one&amp;quot;));&lt;br /&gt;
// sNewString is assigned &amp;quot;I got 99 problems but this script ain't one.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
Str[] myArray = { Str(&amp;quot;Daniel&amp;quot;), Str(&amp;quot;London&amp;quot;), Str(&amp;quot;Mayfair&amp;quot;) };&lt;br /&gt;
string myOutput = String.Format(&amp;quot;My name is {0}, I live in {1} at... at... {2}...&amp;quot;, myArray);&lt;br /&gt;
// myOutput becomes &amp;quot;My name is Daniel, I live in London at... at... Mayfair...&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Arrays and lists===&lt;br /&gt;
String provides the following methods for splitting and joining collections of strings:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Join()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string Join(string[] asStringArray, string asSeparator = &amp;quot;&amp;quot;, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
string Join(cListBase asGenericList, string asSeparator = &amp;quot;&amp;quot;, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a collection of strings, this returns them joined into a single string. The collection can be a string array (string[]), a list of strings (cListString), or any type other type of list. (The ToStringArray() method of the cListBase class is used, which in turn calls the ToString() method of each node. For most list classes this will return valid strings, but if the instanced list is itself cListBase or cListGeneric, empty strings will be returned.)&lt;br /&gt;
&amp;lt;br&amp;gt;Optionally, a separator string can be included, which will be inserted between each item. If omitted, asSeparator defaults to &amp;quot;&amp;quot; - i.e., no separator. Example uses could be &amp;quot; &amp;quot; or &amp;quot;_&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, the strings in the array will not be trimmed. With trimStart, whitespace will be removed from the start of the strings before they are joined. With trimEnd, whitespace will be removed from the end of the strings before they are joined. With trimAll (default), whiltespace will be removed from both ends of the strings before they are joined. Additionally any empty strings will be ignored unless trimNone is used.&lt;br /&gt;
#''string[] asStringArray, cListString asListString'' - An array of strings, a list of strings, or any other list type that can output strings, to be joined.&lt;br /&gt;
#''stromg asSeparator'' - A substring to insert between each joined string. (Optional, default = &amp;quot;&amp;quot;)&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
float[] fNumbers = { 2.33f, 3.44f, 4.55f, 5.66f };&lt;br /&gt;
string sNumberText = String.Join(fNumbers, &amp;quot; &amp;gt;&amp;gt; &amp;quot;);&lt;br /&gt;
// sNumberText will read &amp;quot;2.33 &amp;gt;&amp;gt; 3.44 &amp;gt;&amp;gt; 4.55 &amp;gt;&amp;gt; 5.66&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
cListString sJumble = String.Join(String.SplitToList(&amp;quot;The Inner Sanctum, my most precious chamber, Daniel.&amp;quot;).Shuffle(), &amp;quot; &amp;quot;);&lt;br /&gt;
// sJumble becomes the words of the string, in a random order. First the string is split into a list of strings, the list's Shuffle() method is called, and the result is passed to Join().&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SplitToList()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
cListString SplitToList(string asString, string asDelimiter = &amp;quot; &amp;quot;, enumStringCase aCaseOption = caseSensitive, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string and a substring to use as a delimiter, this returns the string split up into a list of substrings. If the delimiter is omitted then it defaults to &amp;quot; &amp;quot; - a single space, so the returned list contains the individual words in the string.&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the substring must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, strings in the resulting list will not be trimmed. With trimStart, whitespace will be removed from the start of the strings in the resulting list. With trimEnd, whitespace will be removed from the end of the strings in the resulting list. With trimAll (default), whiltespace will be removed from both ends of the strings in the resulting array. Additionally any empty strings will be ignored unless trimNone is used.&lt;br /&gt;
#''string asString'' - A string to be split into a list.&lt;br /&gt;
#''string asDelimiter'' - A substring to search for in asString, for the boundary of each split. (Optional, default = &amp;quot; &amp;quot;)&lt;br /&gt;
#''enumStringCase aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''enumStringTrim aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString myListA = String.SplitToList(&amp;quot;cat_dog_catfish_dogfish&amp;quot;, &amp;quot;_&amp;quot;);&lt;br /&gt;
cListString myListB = String.SplitToList(&amp;quot;cat_dog_catfish_dogfish&amp;quot;, &amp;quot;_Dog&amp;quot;);&lt;br /&gt;
cListString myListC = String.SplitToList(&amp;quot;cat_dog_catfish_dogfish&amp;quot;, &amp;quot;_Dog&amp;quot;, caseInsensitive);&lt;br /&gt;
// myListA is created with the items &amp;quot;cat&amp;quot;, &amp;quot;dog&amp;quot;, &amp;quot;catfish&amp;quot; and &amp;quot;dogfish&amp;quot;.&lt;br /&gt;
// myListB is created with the no items, as the delimiter is not found with the defaul caseSensitive option.&lt;br /&gt;
// myListC is created with the items &amp;quot;cat&amp;quot;, &amp;quot;_catfish&amp;quot; and &amp;quot;fish&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SplitToArray()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] SplitToArray(string asString, string asDelimiter = &amp;quot; &amp;quot;, enumStringCase aCaseOption = caseSensitive, enumStringTrim aTrimOption = trimAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Given a string and a substring to use as a delimiter, this returns the string split up into an array of substrings. If the delimiter is omitted then it defaults to &amp;quot; &amp;quot; - a single space, so the returned array contains the individual words in the string. Consider also: SplitToList().&lt;br /&gt;
&amp;lt;br&amp;gt;aCaseOption can be omitted, or optionally can be either caseSensitive, or caseInsensitive. With caseSensitive (default), the delimiter must match exactly, including the case. With caseInsensitive, the capitalisation does not matter. (E.g. &amp;quot;Foobar&amp;quot; matches with &amp;quot;fooBar&amp;quot;).&lt;br /&gt;
&amp;lt;br&amp;gt;aTrimOption can be omitted, or optionally can be either trimNone, trimStart, trimEnd or trimAll. With trimNone, strings in the resulting array will not be trimmed. With trimStart, whitespace will be removed from the start of the strings in the resulting array. With trimEnd, whitespace will be removed from the end of the strings in the resulting array. With trimAll (default), whiltespace will be removed from both ends of the strings in the resulting array. Additionally any empty strings will be ignored unless trimNone is used.&lt;br /&gt;
&amp;lt;br&amp;gt;(The max length of the array is 256, but advanced users could edit that if needed.)&lt;br /&gt;
#''string asString'' - A string to be split into an array.&lt;br /&gt;
#''asDelimiter'' - A substring to search for in asString, for the boundary of each split. (Optional, default = &amp;quot; &amp;quot;)&lt;br /&gt;
#''aCaseOption'' - caseSensitive or caseInsensitive. (Optional, default = caseSensitive)&lt;br /&gt;
#''aTrimOption'' - trimNone, trimStart, trimEnd, or trimAll. (Optional, default = trimAll)&lt;br /&gt;
For an example, see SplitToList()&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Sequences===&lt;br /&gt;
String provides the following methods for working with numbered string sequences:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====StringRange()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string[] StringRange(string asPrefix, uint alRangeFirst, uint alRangeLast, string asSuffix)&lt;br /&gt;
string[] StringRange(string asPrefix, string asRangeFirst, string asRangeLast, string asSuffix)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns an array of strings where each string in the array is made up of a prefix, followed by an iterator from given range, and then a suffix. The prefix and/or suffix can be &amp;quot;&amp;quot;.&lt;br /&gt;
&amp;lt;br&amp;gt;Accepts the iterator range as either integers or characters, expressed as an inclusive min and inclusive max. Any integers or any ASCII characters could be used, as long as the min/first is less than the max/last.&lt;br /&gt;
#''string asPrefix'' - A string to add at the start of the output strings.&lt;br /&gt;
#''int alRangeFirst, string asRangeFirst'' - An integer or a single character string for the start of the iteration. (inclusive).&lt;br /&gt;
#''int alRangeLast, string asRangeLast'' - An integer or a single character string for the end of the interation (inclusive).&lt;br /&gt;
#''string asSuffix'' - A string to add at the end of the output strings.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string[] sDoorNames = String.StringRange(&amp;quot;door&amp;quot;, 2, 5);&lt;br /&gt;
for (uint i = 0; i &amp;lt; sDoorNames.length(); i++) SetSwingDoorLocked(sDoorNames, true, true);&lt;br /&gt;
// Creates an array of strings containing &amp;quot;door2&amp;quot;, &amp;quot;door3&amp;quot;, &amp;quot;door4&amp;quot; and &amp;quot;door5&amp;quot;, and passes each of them to SetSwingDoorLocked().&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string[] sStuffAndJunk = StringRange(&amp;quot;stuff_&amp;quot;, &amp;quot;A&amp;quot;, &amp;quot;C&amp;quot;, &amp;quot;_andJunk&amp;quot;);&lt;br /&gt;
// sStuffAndJunk is assigned with the strings &amp;quot;stuff_A_andJunk&amp;quot;, &amp;quot;stuff_B_andJunk&amp;quot; and &amp;quot;stuff_C_andJunk&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====IntToStringFixedDigits()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string IntToStringFixedDigits(uint aulNumber, uint8 auiDigits, enumLimitType aLimitOption = limitClamped)&lt;br /&gt;
string IntToStringFixedDigits(int alNumber, uint8 auiDigits, enumLimitType aLimitOption = limitClamped)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns a string representing an unsigned or positive int, with the specified number of characters, adding leading zeros if needed. aulNumber is the number to convert. auiDigits is the number of digits. E.g. 42 as 3 digits returns the string &amp;quot;042&amp;quot;. auiDigits is an unsigned 8-bit int (0-255), because the max uint is only 10 digits. (Hey, if you want to try any make a string that's 2^32 followed by 245 zeros, that's none of my business!)&lt;br /&gt;
&amp;lt;br&amp;gt;aLimitOption is optional and can be omitted, or it can be limitFree, limitClamped or limitWrapped. With limitFree, the number is not clamped, so auiDigits is a minimum. E.g. 1 as 2 digits returns &amp;quot;01&amp;quot; but 123 as 2 digits returns &amp;quot;123&amp;quot;. With limitClamped (default), the number will be clamped within the range of the digits. E.g. 123 as 2 digits returns &amp;quot;99&amp;quot;. With limitWrapped, the number will be modulated. E.g. 123 as 2 digits returns &amp;quot;23&amp;quot;.&lt;br /&gt;
#''uint aulNumber, int alNumber' - An unsigned integer to be respresented in the string. If the supplied int is signed and less than zero, it will be treated as zero.&lt;br /&gt;
#''uint8 auiDigits'' - The min number of digits to include in the string.&lt;br /&gt;
#''enumLimitType aLimitOption'' - Can be limitFree, limitClamped or limitWrapped. (Optional, default = limitClamped)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
string sNum = String.IntToStringFixedDigits(1188, 4, limitWrapped);&lt;br /&gt;
// sNum becomes &amp;quot;0088&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
for (uint i = 1; i &amp;lt;= 12; i++) SetSwingDoorLocked(&amp;quot;door_&amp;quot; + String.IntToStringFixedDigits(i, 3), true, true);&lt;br /&gt;
// This example imagines that the level has 12 doors named in the style &amp;quot;door_001&amp;quot;, &amp;quot;door_002&amp;quot;, ... &amp;quot;door_009&amp;quot;, &amp;quot;door_010&amp;quot;, &amp;quot;door_011&amp;quot;, &amp;quot;door_012&amp;quot;.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Str class=&lt;br /&gt;
The Str class is used in the String.Format() and Debug.Message() methods.&lt;br /&gt;
&amp;lt;br&amp;gt;It's purpose is to provide something like a template parameter, or a loosely typed variable, for string formatting. The main goal is just to let modders pass values for string formatting without requiring hundreds of overloads. It's definitely clunkier in debug mode, but outside of debug mode it's more efficient.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
The Str constructors can be passed a reference to a single string, int, uint, float, double, bool, cVector, cRotator, cPoint, cBezier, or cSpline.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Str(3)&lt;br /&gt;
Str(myInt)&lt;br /&gt;
Str(myVector)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
Str has no public properties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
The only method is the ToString() function:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====ToString()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string ToString()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Returns the stored variable as a string.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Debug.Message(3, &amp;quot;Created new rotator {0} for puzzle #{1}.&amp;quot;, Str(myRotator), Str(myInt));&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
SetLevelDoorLockedText(&amp;quot;BigDoor&amp;quot;, &amp;quot;BigDoorMessages&amp;quot;, String.Format(&amp;quot;Door_Zone{0}_Type{1}&amp;quot;, Str(doorZone), Str(doorType)));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
__FORCETOC__&lt;/div&gt;</summary>
		<author><name>Mrbehemo</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Spawner&amp;diff=6630</id>
		<title>HPL2/HPL2 Helper Scripts/Spawner</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Spawner&amp;diff=6630"/>
		<updated>2023-12-22T23:28:04Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Spawner.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 cSpawner provides methods for spawning entities and particle systems at specific vector positions.&lt;br /&gt;
&lt;br /&gt;
===Spawn area===&lt;br /&gt;
The normal global functions provided by HPL2 only allow scripts to place objects at an existing Script Area. Spawner makes use of this and teleports the objects into the desired position afterwards.&lt;br /&gt;
&lt;br /&gt;
There are three options for using Spawner, regarding a Spawn Area:&lt;br /&gt;
# Simply add a Script Area to the level named &amp;quot;SpawnArea&amp;quot;, anywhere, any size.&lt;br /&gt;
# Tell Spawner to use a Script Area that already exists in the map, anywhere, any size, regardless of any other purpose.&lt;br /&gt;
# Tell Spawner to use multiple Script Areas placed in the map especially. This is only useful for semi-random rotation.&lt;br /&gt;
&lt;br /&gt;
The default named Area is &amp;quot;SpawnArea&amp;quot; - you can change this using the SpawnArea property in script.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Spawner.SpawnArea = &amp;quot;SomeOtherArea&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Whatever it is called, there must be designated Script Area in the map, ''somewhere'', whose name matches SpawnArea. It doesn't matter what size it is or where it is located, as long as it exists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Spawning with shapes===&lt;br /&gt;
As well as spawning enties at specific positions, Spawner can also spawn entities randomly within a box or sphere shape, or spread evenly along a curve. It can also spawn particle systems at specific places or on a curve.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Spawning with rotation===&lt;br /&gt;
It isn't possible to set the world rotation of an entity through script alone. However, spawned items will match the rotation of the whatever Script Area they were spawned at.&lt;br /&gt;
&lt;br /&gt;
The SpawnArea propery allows one specific area to be set, but the [[HPL2/HPL2_Helper_Scripts/Spawner#SetSpawnArea.28.29|SetSpawnArea()]] ''method'' will accept an array or list of area names. When more than one Spawn Area is set, each spawned item will choose a different one at random. Having multiple Spawn Areas has no advantage other than having multiple sources for rotation.&lt;br /&gt;
&lt;br /&gt;
For example, if the desired outcome is to spawn many debris objects with random-ish rotations, multiple Script Areas should be created in the level and given specific names and different rotations. It doesn't matter what size or location they are, only their rotation matters. In script, they should all be assigned with [[HPL2/HPL2_Helper_Scripts/Spawner#SetSpawnArea.28.29|SetSpawnArea()]], and then each spawned item will take on the rotation of one of the areas at random.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Particles &amp;amp; temporary entities===&lt;br /&gt;
In order to spawn particle systems, Spawner spawns a &amp;quot;temp entity&amp;quot; - an invisible entity that the particle system is attached to. The number of temp entities is limited (256 by default) and when the full number is reached, older ones will be recycled.&lt;br /&gt;
&lt;br /&gt;
If Spawner is used to create entities without specifying a name for them, they will be treated like temp entities too.&lt;br /&gt;
&lt;br /&gt;
The entity file used for temp entities is called &amp;quot;SpawnerTemp.ent&amp;quot; and is located in the &amp;quot;&amp;quot;HPL2HelperScripts&amp;quot; folders. This can be changed using the TempEntityFile property, if required for some reason.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Save data===&lt;br /&gt;
Spawner does not save any data of its own. By default, entities created by Spawner will be saved along with the save game and Spawner will have no need to remember them on the next play session. The SaveEntities property can be used to change this behaviour at run-time. Its default is true.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent1&amp;quot;, &amp;quot;spookyChair.ent&amp;quot;, cVector(0.0f, 0.0f, 0.0f));		// This new entity will save by *default*.&lt;br /&gt;
Spawner.SaveEntities = false;		&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent2&amp;quot;, &amp;quot;spookyTable.ent&amp;quot;, cVector(2.0f, 0.0f, 0.0f));		// This new entity will *not* save, specifically.&lt;br /&gt;
Spawner.SaveEntities = true;		&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent3&amp;quot;, &amp;quot;spookyCrate.ent&amp;quot;, cVector(4.0f, 0.0f, 0.0f));		// This new entity *will* save, specifically.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
'''Advanced users''' may wish to examine &amp;quot;HelperScripts_Spawner.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 the default names for entities and the maximum number of temp entities allowed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Spawner=&lt;br /&gt;
Spawner is the name of the object that manages spawning entities at specific map locations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
&amp;quot;HelperScripts_Spawner.hps&amp;quot; declares an object called '''Spawner''', of the new script class cSpawner. To access its methods, just use &amp;quot;Spawner.&amp;quot; followed by the function call. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;bigThing&amp;quot;, &amp;quot;bigThing.ent&amp;quot;, cVector(1.1f, 2.2f, 3.3f));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
Spawner provides the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SaveEntities====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string SaveEntities&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The bool property SaveEntities can be used to specify whether entities and particle systems spawned by Spawner will be saved as part of the save game. (Default = true)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent1&amp;quot;, &amp;quot;spookyChair.ent&amp;quot;, cVector(0.0f, 0.0f, 0.0f));		// This new entity will save by default.&lt;br /&gt;
Spawner.SaveEntities = false;		&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent2&amp;quot;, &amp;quot;spookyTable.ent&amp;quot;, cVector(2.0f, 0.0f, 0.0f));		// This new entity will ''not'' save, specifically.&lt;br /&gt;
Spawner.SaveEntities = true;		&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent3&amp;quot;, &amp;quot;spookyCrate.ent&amp;quot;, cVector(4.0f, 0.0f, 0.0f));		// This new entity ''will'' save, specifically.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnArea====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string SpawnArea&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string property SpawnArea can get or set the named Script Area used for spawning entities. (Default = &amp;quot;SpawnArea&amp;quot;)&lt;br /&gt;
&amp;lt;br&amp;gt;(The advantage of using the SpawnArea property is that it can just be set to any Script Area that happens to exist in the map.)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.SpawnArea = &amp;quot;LibraryEntranceTriggerB&amp;quot;;&lt;br /&gt;
// Spawner will use the Script Area named &amp;quot;LibraryEntranceTriggerB&amp;quot; instead of the default name.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====TempEntityBaseName====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string TempEntityBaseName&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string property TempEntityBaseName can get or set the prefix used when naming temp entities. (Default = &amp;quot;SpawnerTemp&amp;quot;)&lt;br /&gt;
&amp;lt;br&amp;gt;If TempEntityBaseName is &amp;quot;SpawnerTemp&amp;quot; then temp entities will have names like &amp;quot;SpawnerTemp_0&amp;quot;, &amp;quot;SpawnerTemp_1&amp;quot;, etc..&lt;br /&gt;
&amp;lt;br&amp;gt;Note: This can only be changed before Spawner has actually spawned any temp entities, otherwise it would not be able to update or recycle them.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.TempEntityBaseName = &amp;quot;MySpecialEntityName&amp;quot;;&lt;br /&gt;
// Spawner will now create temporary entities with names like &amp;quot;MySpecialEntityName_0&amp;quot;, &amp;quot;MySpecialEntityName_1&amp;quot;, etc..&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====TempEntityFile====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string TempEntityFile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string property TempEntityFile can get or set the .ent file used for spawning temporary entities for particle systems. (Default = &amp;quot;SpawnerTemp.ent&amp;quot;)&lt;br /&gt;
&amp;lt;br&amp;gt;The only reason to change TempEntityFile is if there is a specific entity that should be used instead.&lt;br /&gt;
&amp;lt;br&amp;gt;Note: This can only be changed before Spawner has actually spawned any temp entities, otherwise it would not be able to update or recycle them.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.TempEntityFile = &amp;quot;CustomTempEnt.ent&amp;quot;;&lt;br /&gt;
// Spawner will attempt to spawn temp entities from the file &amp;quot;CustomTempEnt.ent&amp;quot; instead of the default file.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
Spawner provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Spawning entities===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnEntityAtPos()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnEntityAtPos(string asNewEntityName, string asEntityFile, cVector avPosition)&lt;br /&gt;
bool SpawnEntityAtPos(string asNewEntityName, cListString@ ahEntityFileList, cVector avPosition)&lt;br /&gt;
bool SpawnEntityAtPos(string asNewEntityName, string[] asEntityFileArray, cVector avPosition)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns an entity at a specific vector position. If an entity with that name already exists, it will be recycled. That is, it will be teleported into the new position. SpawnEntityAtPos returns true if the entity was recycled, or false if a new entity was created.&lt;br /&gt;
&amp;lt;br&amp;gt;The .ent file can be given as a specific string, e.g. &amp;quot;orb.ent&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ent file that spawns will be chosen at random from the list or array.&lt;br /&gt;
#''string asNewEntityName'' - The name that the new entity will be given. Should either be unique, or an existing entity will be recycled instead.&lt;br /&gt;
#''string asEntityFile, cListString@ ahEntityFileList, string[] asEntityFileArray'' - A string, an array of strings, or a list of strings containing one or more .ent files.&lt;br /&gt;
#''cVector avPosition'' - A 3d vector position in the map to spawn the entity.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;AcmeAnvil&amp;quot;, &amp;quot;anvil.ent&amp;quot;, Math.GetPlayerPosVec() + cVector(0.0f, 3.0f, 0.0f));&lt;br /&gt;
// An entity of the type &amp;quot;anvil.ent&amp;quot; spawns 3m above the player's location.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnEntitiesInBox()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnEntitiesInBox(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string asEntityFile, uint aulQty, cVector avBoxMin, cVector avBoxMax)&lt;br /&gt;
bool SpawnEntitiesInBox(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, cListString ahEntityFileList, uint aulQty, cVector avBoxMin, cVector avBoxMax)&lt;br /&gt;
bool SpawnEntitiesInBox(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string[] asEntityFileArray, uint aulQty, cVector avBoxMin, cVector avBoxMax)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns a quantity of entities a random positions within a box shape defined by a pair of vectors (similar to the box shaped starting position in the particle editor). If the box is sized zero in one dimension then that is effectively a rectangle, so this can also be used spawn objects on a plane.&lt;br /&gt;
&amp;lt;br&amp;gt;The .ent file can be given as a specific string, e.g. &amp;quot;orb.ent&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ent file that spawns will be chosen at random from the list or array.&lt;br /&gt;
&amp;lt;br&amp;gt;If asEntityBaseName is given, it will be used to name the new entities. E.g. if asEntityBaseName = &amp;quot;box&amp;quot;, then new entities will be named like &amp;quot;box_0&amp;quot;, &amp;quot;box_1&amp;quot; etc.. If asEntityBaseName is omitted, then temp entity names will be used instead. If an entity with that name already exists, it will be recycled, that is it will be teleported into the new position. If the script needs to refer to the entities by name later, use asEntityBaseName to give them specific names.&lt;br /&gt;
&amp;lt;br&amp;gt;SpawnEntitiesInBox returns true if any entities were recycled, or false if all the entities are newly created.&lt;br /&gt;
#''string asEntityBaseName'' - The name to use for the new entities, which will be appended with &amp;quot;_0&amp;quot;, &amp;quot;_1&amp;quot; etc. (Optional, default = &amp;quot;SpawnerTemp&amp;quot;) &lt;br /&gt;
#''string asEntityFile, cListString@ ahEntityFileList, string[] asEntityFileArray'' - A string, an array of strings, or a list of strings containing one or more .ent files.&lt;br /&gt;
#''uint aulQty'' -  The number of entities to spawn in the box.&lt;br /&gt;
#''cVector avBoxMin'' - The minimum extent of the box.&lt;br /&gt;
#''cVector avBoxMax'' -  The maximum extent of the box.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listJunkProps;&lt;br /&gt;
listJunkProps.Add(&amp;quot;wooden_board02.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;tongs.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;hammer.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;chisel.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;basket.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;flask01.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;dungeon_small01.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;brick.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;brick.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;brick.ent&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
Spawner.SpawnEntitiesInBox(&amp;quot;Junk_A&amp;quot;, listJunkProps, 24, cVector(10.0f, 0.25f, 15.0f), cVector(15.0f, 0.25f, 20.0f));&lt;br /&gt;
// 24 random junk items are selected from the list and spawned in a square, with names &amp;quot;Junk_A_0&amp;quot; to &amp;quot;Junk_A_23&amp;quot;.&lt;br /&gt;
// Note that &amp;quot;brick.ent&amp;quot; is three times more likely to spawn than the others.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnEntitiesInSphere()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnEntitiesInSphere(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string asEntityFile, uint aulQty, cVector avOrigin, float afRadius) &lt;br /&gt;
bool SpawnEntitiesInSphere(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, cListString ahEntityFileList, uint aulQty, cVector avOrigin, float afRadius) &lt;br /&gt;
bool SpawnEntitiesInSphere(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string[] asEntityFileArray, uint aulQty, cVector avOrigin, float afRadius) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns a quantity of entities a random positions within a sphere shape defined by a centre vector and a radius.&lt;br /&gt;
&amp;lt;br&amp;gt;The .ent file can be given as a specific string, e.g. &amp;quot;orb.ent&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ent file that spawns will be chosen at random from the list or array.&lt;br /&gt;
&amp;lt;br&amp;gt; If asEntityBaseName is given, it will be used to name the new entities. E.g. if asEntityBaseName = &amp;quot;box&amp;quot;, then new entities will be named like &amp;quot;box_0&amp;quot;, &amp;quot;box_1&amp;quot; etc.. If asEntityBaseName is omitted, then temp entity names will be used instead. If an entity with that name already exists, it will be recycled, that is it will be teleported into the new position. If you need to know the names of the entities to refer to them later, use asEntityBaseName.&lt;br /&gt;
&amp;lt;br&amp;gt;SpawnEntitiesInSphere returns true if any entities were recycled, or false if all the entities are newly created.&lt;br /&gt;
#''string asEntityBaseName'' - The name to use for the new entities, which will be appended with &amp;quot;_0&amp;quot;, &amp;quot;_1&amp;quot; etc. (Optional, default = &amp;quot;SpawnerTemp&amp;quot;) &lt;br /&gt;
#''string asEntityFile, cListString@ ahEntityFileList, string[] asEntityFileArray'' - A string, an array of strings, or a list of strings containing one or more .ent files.&lt;br /&gt;
#''uint aulQty'' - The number of entities to spawn in the sphere.&lt;br /&gt;
#''cVector avOrigin'' - The centre of the sphere.&lt;br /&gt;
#''cVector afRadius'' - The radius of the sphere.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.SpawnEntitiesInSphere(&amp;quot;MegaOrb&amp;quot;, &amp;quot;orb.ent&amp;quot;, 1000, Math.GetPlayerPosVec(), 4.0f);&lt;br /&gt;
SetPlayerSanity(0.0f);&lt;br /&gt;
// One thousand orbs have spawned around the player, placing them at the centre of an 8m wide MegaOrb. The player had no chance to remain sane in such circumstances.&lt;br /&gt;
// Note: if no string was given for asEntityBaseName, then the number of entities spawned would be limited to the temp entity max (default = 256).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnEntitiesOnSpline()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnEntitiesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string asEntityFile, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
bool SpawnEntitiesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, cListString ahEntityFileList, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
bool SpawnEntitiesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string[] asEntityFileArray, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns a quantity of entites evenly spaced along a spline.&lt;br /&gt;
&amp;lt;br&amp;gt;The .ent file can be given as a specific string, e.g. &amp;quot;orb.ent&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ent file that spawns will be chosen at random from the list or array.&lt;br /&gt;
&amp;lt;br&amp;gt;If asEntityBaseName is given, it will be used to name the new entities. E.g. if asEntityBaseName = &amp;quot;box&amp;quot;, then new entities will be named like &amp;quot;box_0&amp;quot;, &amp;quot;box_1&amp;quot; etc.. If asEntityBaseName is omitted, then temp entity names will be used instead. If an entity with that name already exists, it will be recycled, that is it will be teleported into the new position. If the names of the entities are needed to refer to them later or update their position, use asEntityBaseName.&lt;br /&gt;
&amp;lt;br&amp;gt;SpawnEntitiesOnSpline returns true if any entities were recycled, or false if all the entities are newly created.&lt;br /&gt;
&amp;lt;br&amp;gt;afPhase is optional. It can be used to adjust the spread of the entities on the curve with a number between 0.0f and 1.0f, or it can be omitted. If it is omitted, or less than zero, then the default spacing will be used.&lt;br /&gt;
&amp;lt;br&amp;gt;The default spacing is the &amp;quot;full spread&amp;quot; - that is to say the first entity will be spawned at the start of the curve, the last entity at the very end, and all the others evenly in between.&lt;br /&gt;
&amp;lt;br&amp;gt;However, if value between 0.0f and 1.0f is used for afPhase, then the entities will be spawned within their own division of the curve, with the phase 0.0f - 1.0f specifying how far through that division it will appear.&lt;br /&gt;
&amp;lt;br&amp;gt;The following diagram illustrates the phase option:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
  |1----2----3----4|	&amp;lt;- default spacing: no phase, full spread.&lt;br /&gt;
  |1---2---3---4---|	&amp;lt;- phase = 0.0f, each object at the start of its division.&lt;br /&gt;
  |-1---2---3---4--|	&amp;lt;- phase = 0.25f, each object 1/4 of the way through its division.&lt;br /&gt;
  |--1---2---3---4-|	&amp;lt;- phase = 0.5f, each object 1/2 of the way through its division.&lt;br /&gt;
  |---1---2---3---4|	&amp;lt;- phase = 0.75f, each object 3/4 of the way through its division.&lt;br /&gt;
  |1---2---3---4---|	&amp;lt;- phase = 1.0f is the same as phase = 0.0f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;To update the position of the spawned entities without respawning them, for example if the spline or phase has changed, see UpdateEntitiesOnSpline().&lt;br /&gt;
&amp;lt;br&amp;gt;You can easily use SpawnEntitiesOnSpline() with a single Bezier or a straight line between two points, depending on how you construct your spline. See the examples, or see cSpline and cBezier classes for more information.&lt;br /&gt;
#''string asEntityBaseName'' - The name to use for the new entities, which will be appended with &amp;quot;_0&amp;quot;, &amp;quot;_1&amp;quot; etc. (Optional, default = &amp;quot;SpawnerTemp&amp;quot;)&lt;br /&gt;
#''string asEntityFile, cListString@ ahEntityFileList, string[] asEntityFileArray'' - A string, an array of strings, or a list of strings containing one or more .ent files.&lt;br /&gt;
#''uint aulQty'' - The number of entities to be placed on the spline.&lt;br /&gt;
#''cSpline@ ahSpline'' - A spline to place entities on.&lt;br /&gt;
#''float afPhase'' - An adjustment to the spread of the entities, 0.0f - 1.0f, or -1.0f for full spread. (Optional, default = -1.0f)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(&amp;quot;WigglyPathChair&amp;quot;, &amp;quot;chair.ent&amp;quot;, 10, vBigWigglyPath);&lt;br /&gt;
// 10x chair.ent have been spawned on the existing spline curve vBigWigglyPath.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
SpawnEntitiesOnSpline(&amp;quot;rock.ent&amp;quot;, 16, cSpline(cVector(2.0f, 2.0f, 10.0f), cVector(4.0f, 2.0f, 10.0f));&lt;br /&gt;
// 16x rock.ent have been spawned in a line shape.&lt;br /&gt;
// The line is formed from a new cSpline defined by two cVectors.&lt;br /&gt;
// The entities were not named, so temp entity names have been used. This means that they cannot be updated and may be recycled.&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
cSpline vFloatyRockArch = cSpline(cVector(2.0f, 0.0f, 10.0f), cVector(2.0f, 3.0f, 10.0f), cVector(4.0f, 3.0f, 10.0f), cVector(4.0f, 0.0f, 10.0f));&lt;br /&gt;
&lt;br /&gt;
cListString listRockTypes;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 5; i++) listRockTypes.Add(&amp;quot;rock_&amp;quot; + i + &amp;quot;.ent&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(&amp;quot;FloatyRockArchEnt&amp;quot;, listRockTypes, 16, vFloatyRockArch);&lt;br /&gt;
// 16x rocks have been spawned in an arch shape.&lt;br /&gt;
// The arch is formed from a new cSpline defined by four cVectors, making a cubic bezier.&lt;br /&gt;
// Each rock entity was selected at random from one of five created in the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Spawning particles===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnParticlesAtPos()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnParticlesAtPos(string asNewPSName, string asPSFile, cVector avPosition)&lt;br /&gt;
bool SpawnParticlesAtPos(string asNewPSName, cListString@ ahPSFileList, cVector avPosition)&lt;br /&gt;
bool SpawnParticlesAtPos(string asNewPSName, string[] asPSFileArray, cVector avPosition)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns a particle system at a specific vector position. &lt;br /&gt;
&amp;lt;br&amp;gt;The .ps file can be given as a specific string, e.g. &amp;quot;ps_bubbles.ps&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ps file that spawns will be chosen at random from the list or array.&lt;br /&gt;
&amp;lt;br&amp;gt;In order to place a particle system at an arbitrary location, a temp entity is used, using the msTempEntNameBase. If the maximum number of temp entities already exist, one will be recycled in the new position. SpawnParticlesAtPos returns true if the temp entity was recycled, or false if a new entity was created.&lt;br /&gt;
&amp;lt;br&amp;gt;If a particle system already exists with the given name, then it will be destroyed and replaced.&lt;br /&gt;
#''string asNewPSName'' - The name that the new particle system will be given. Should either be unique, or an existing system will be recycled instead.&lt;br /&gt;
#''string asPSFile, cListString@ ahPSFileList, string[] asPSFileArray'' - A string, an array of strings, or a list of strings containing one or more .ps files.&lt;br /&gt;
#''cVector avPosition'' - A 3d vector position in the map to spawn the entity.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Spawner.SpawnParticlesAtPos(&amp;quot;FloatyFlame&amp;quot;, &amp;quot;ps_fire_candle.ps&amp;quot;, cVector(23.0f, 2.25f, 14.5f));&lt;br /&gt;
// A candle flame will be spawned at the given vector position, using a temp entity.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string[] arrayFlameTypes = { &amp;quot;ps_fire_candle.ps&amp;quot;, &amp;quot;ps_fire_candle_red.ps&amp;quot;, &amp;quot;ps_fire_candle_blue.ps&amp;quot; };&lt;br /&gt;
&lt;br /&gt;
Spawner.SpawnParticlesAtPos(&amp;quot;FloatyFlame&amp;quot;, listFlameTypes, cVector(23.0f, 2.25f, 14.5f));&lt;br /&gt;
// A candle flame will be spawned at the given vector position, using a temp entity.&lt;br /&gt;
// The .ps file will be selected at random from the array.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnParticlesOnSpline()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnParticlesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string asPSFile, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
bool SpawnParticlesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, cListString ahPSFileList, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
bool SpawnParticlesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string[] ahPSFileArray, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns a quantity of particle systems evenly spaced along a spline. The ahSpline argument should refer to an existing cSpline variable if the positions of the particles should need to be updated later. See the examples, or see cSpline for further information on creating splines. To update the position of the spawned entities without respawning them, for example if the spline or phase has changed, see UpdateEntitiesOnSpline(). This will also move the particle systems.&lt;br /&gt;
&amp;lt;br&amp;gt;The .ps file can be given as a specific string, e.g. &amp;quot;ps_bubbles.ps&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ps file that spawns will be chosen at random from the list or array.&lt;br /&gt;
&amp;lt;br&amp;gt;In order to place a particle system at an arbitrary location, a temp entity is used, using the default temp entity name. If the maximum number of temp entities already exist, some will be recycled in the new position on the spline. SpawnParticlesOnSpline returns true if any temp entities were recycled, or false if only new entities were used created.&lt;br /&gt;
&amp;lt;br&amp;gt;If a specific name is given using the asEntityBaseName argument, then it will be used instead. E.g. if asEntityBaseName = &amp;quot;box&amp;quot;, then new entities will be named like &amp;quot;box_0&amp;quot;, &amp;quot;box_1&amp;quot; etc.. If the names of the temp entities are needed to refer to them later, for example to update the particles on the spline, use a specific string for asEntityBaseName. SpawnParticlesOnSpline returns true is any entities were recycled, or false if all the entities are newly created.&lt;br /&gt;
&amp;lt;br&amp;gt;afPhase is optional. It can be used to adjust the spread of the entities on the curve with a number between 0.0f and 1.0f, or it can be omitted. If it is omitted or if it is given as any number less than zero, then the default spacing will be used. The default spacing  is the &amp;quot;full spread&amp;quot; - that is to say the first entity will be spawned at the start of the curve, the last at the end, and all the others evenly in between. However, if value between 0.0f and 1.0f is used for afPhase, then the entities will be spawned within their own division of the curve, with the phase 0.0f - 1.0f specifying how far through that division it will appear.&lt;br /&gt;
&amp;lt;br&amp;gt;The following diagram illustrates the phase option:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
  |1----2----3----4|	&amp;lt;- default spacing: no phase, full spread.&lt;br /&gt;
  |1---2---3---4---|	&amp;lt;- phase = 0.0f, each object at the start of its division.&lt;br /&gt;
  |-1---2---3---4--|	&amp;lt;- phase = 0.25f, each object 1/4 of the way through its division.&lt;br /&gt;
  |--1---2---3---4-|	&amp;lt;- phase = 0.5f, each object 1/2 of the way through its division.&lt;br /&gt;
  |---1---2---3---4|	&amp;lt;- phase = 0.75f, each object 3/4 of the way through its division.&lt;br /&gt;
  |1---2---3---4---|	&amp;lt;- phase = 1.0f is the same as phase = 0.0f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;If a particle system already exists with the given name, then it will be destroyed and replaced.&lt;br /&gt;
#''string asEntityBaseName'' - The name to use for the new entities, which will be appended with &amp;quot;_0&amp;quot;, &amp;quot;_1&amp;quot; etc. (Optional, default = &amp;quot;SpawnerTemp&amp;quot;)&lt;br /&gt;
#''string asPSFile, cListString@ ahPSFileList, string[] asPSFileArray'' - A string, an array of strings, or a list of strings containing one or more .ps files.&lt;br /&gt;
#''uint aulQty'' - The number of entities to be placed on the spline.&lt;br /&gt;
#''cSpline@ ahSpline'' - A spline to place entities on.&lt;br /&gt;
#''float afPhase'' - An adjustment to the spread of the entities, 0.0f - 1.0f, or -1.0f for full spread. (Optional, default = -1.0f)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(&amp;quot;WigglyPathFlame&amp;quot;, &amp;quot;ps_fire_candle.ps&amp;quot;, 10, vBigWigglyPath);&lt;br /&gt;
// 10x ps_fire_candle.ps have been spawned on the existing spline curve vBigWigglyPath.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(&amp;quot;ps_fire_candle.ps&amp;quot;, 16, cSpline(cVector(2.0f, 2.0f, 10.0f), cVector(4.0f, 2.0f, 10.0f)));&lt;br /&gt;
// 16x flames have been spawned in a line shape.&lt;br /&gt;
// The line is formed from a new anonymous cSpline defined by two cVectors.&lt;br /&gt;
// The temp entities have not been named, so they cannot be updated and may be recycled.&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
cSpline vFloatyFlameArch = cSpline(cVector(2.0f, 0.0f, 10.0f), cVector(2.0f, 3.0f, 10.0f), cVector(4.0f, 3.0f, 10.0f), cVector(4.0f, 0.0f, 10.0f));&lt;br /&gt;
&lt;br /&gt;
cListString listFlameTypes;&lt;br /&gt;
listFlameTypes.Add(&amp;quot;ps_fire_candle.ps&amp;quot;);&lt;br /&gt;
listFlameTypes.Add(&amp;quot;ps_fire_candle_red.ps&amp;quot;);&lt;br /&gt;
listFlameTypes.Add(&amp;quot;ps_fire_candle_blue.ps&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(&amp;quot;FloatyFlame&amp;quot;, listFlameTypes, 16, vFloatyFlameArch, 0.5f);&lt;br /&gt;
// 16x flames have been spawned in an arch shape, where each sits halfway through own 16th division (phase = 0.5f).&lt;br /&gt;
// The arch shape is provided by an existing named cSpline, defined by four cVectors, making a cubic bezier.&lt;br /&gt;
// Each particle system was selected at random from one of three .ps files.&lt;br /&gt;
// Since the cSpline and the carrier entities have been named (&amp;quot;FloatyFlame_0&amp;quot;, &amp;quot;FloatyFlame_1&amp;quot; etc.) they can be referred to and updated later.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Movement and rotation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetSpawnArea()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetSpawnArea(string asSpawnArea)&lt;br /&gt;
void SetSpawnArea(string[] asSpawnAreaArray)&lt;br /&gt;
void SetSpawnArea(cListString asSpawnAreaList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The simplest way to allocate a specific Spawn Area is with the SpawnArea property. (&amp;lt;code&amp;gt;Spawner.SpawnArea = &amp;quot;someArea&amp;quot;;&amp;lt;/code&amp;gt;)&lt;br /&gt;
&amp;lt;br&amp;gt;However, the SetSpawnArea() method can also be used to specify multiple Script Areas with an array or list. If multiple Script Areas are specified then one of them will be selected at random for each item spawned.&lt;br /&gt;
&amp;lt;br&amp;gt;This has only one advantage: spawned items take on the rotation of their Spawn Area.&lt;br /&gt;
&amp;lt;br&amp;gt;If the desired outcome is to [[HPL2/HPL2_Helper_Scripts/Spawner#Spawning_with_rotation|spawn objects with random rotation]], the only way to achieve this through script to create a handful of Areas with various rotations, assign them all the SetSpawnArea(), and then each spawned item will take on the rotation of one of the areas.&lt;br /&gt;
#''string asSpawnArea, string[] asSpawnAreaArray, cListString, asSpawnAreaList'' - One or more names to be designated as the spawn area.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Spawner.SetSpawnArea(&amp;quot;MyScriptArea&amp;quot;);&lt;br /&gt;
Spawner.SpawnEntitiesInBox(&amp;quot;Hammer&amp;quot;, &amp;quot;hammer.ent&amp;quot;, 24, cVector(10.0f, 0.25f, 15.0f), cVector(15.0f, 0.25f, 20.0f));&lt;br /&gt;
// 24x hammer.ent will be spawned in the defined bos.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string[] sAreas = { &amp;quot;MyScriptArea1&amp;quot;, &amp;quot;MyScriptArea2&amp;quot;, &amp;quot;MyScriptArea3&amp;quot;, &amp;quot;MyScriptArea4&amp;quot; };&lt;br /&gt;
Spawner.SetSpawnArea(sAreas);&lt;br /&gt;
Spawner.SpawnEntitiesInBox(&amp;quot;Hammer&amp;quot;, &amp;quot;hammer.ent&amp;quot;, 24, cVector(10.0f, 0.25f, 15.0f), cVector(15.0f, 0.25f, 20.0f));&lt;br /&gt;
// 24x hammer.ent will be spawned in the defined box, each with the rotation copied from one of the 4 script areas.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====UpdateEntitiesOnSpline()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool UpdateEntitiesOnSpline(string asEntityBaseName, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If SpawnEntitiesOnSpline() or SpawnParticlesOnSpline() has been used with a specific asEntityBaseName, and if the spline position has changed or a new phase value is desired, then UpdateEntitiesOnSpline() can be used to update the entities' or particles' positions, without recycling or further spawning.&lt;br /&gt;
&amp;lt;br&amp;gt;UpdateEntitiesOnSpline returns false if any of the expected entities do not exist, or true if the were all found and updated successfully.&lt;br /&gt;
&amp;lt;br&amp;gt;If a unique asEntityBaseName was not used, this may have enexpected results.&lt;br /&gt;
#''string asEntityBaseName'' - The base name used to previously spawn items on the spline.&lt;br /&gt;
#''uint aulQty'' - The number of items that were previously spawned in the spline.&lt;br /&gt;
#''cSpline ahSpline'' - A reference to an existing spline.&lt;br /&gt;
#''float afPhase'' - An adjustment to the spread of the entities, 0.0f - 1.0f, or -1.0f for full spread. (Optional, default = -1.0f)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(vBigWigglyPath, 10, &amp;quot;chair.ent&amp;quot;, &amp;quot;WigglyPathChair&amp;quot;);&lt;br /&gt;
// 10x chair.ent have been spawned on the curve vBigWigglyPath.&lt;br /&gt;
// ...some time later... vBigWigglyPath has been updated with new vectors:&lt;br /&gt;
Spawner.UpdateEntitiesOnSpline(vBigWigglyPath, 10, &amp;quot;WigglyPathChair&amp;quot;);&lt;br /&gt;
// The 10 entities have adjusted to the new curve vectors.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
OnEnter()&lt;br /&gt;
{&lt;br /&gt;
	float fWigglyPathPhase = 0.0f;&lt;br /&gt;
	Spawner.SpawnEntitiesOnSpline(vBigWigglyPath, 1, &amp;quot;chair.ent&amp;quot;, &amp;quot;WigglyPathChair&amp;quot;, fWigglyPathPhase);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OnUpdate(float asStep)&lt;br /&gt;
{&lt;br /&gt;
	fWigglyPathPhase = Math.Wrap(fWigglyPathPhase + afStep / 5.0f);&lt;br /&gt;
	Spawner.UpdateEntitiesOnSpline(vBigWigglyPath, 1, &amp;quot;WigglyPathChair&amp;quot;, fWigglyPathPhase);&lt;br /&gt;
}&lt;br /&gt;
// In this example, a single chair.ent is spawned on a curve name vBigWigglyPath when the level is first entered.&lt;br /&gt;
// fWigglyPathPhase updates between 0.0f and 1.0f over the course of 5 seconds (see Math.Wrap()) and UpdateEntitiesOnSpline() applies the new phase.&lt;br /&gt;
// The result is that the chair continuous moves along the curve vBigWigglyPath every 5 seconds, then loops back to the start.&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>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Spawner&amp;diff=6629</id>
		<title>HPL2/HPL2 Helper Scripts/Spawner</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=HPL2/HPL2_Helper_Scripts/Spawner&amp;diff=6629"/>
		<updated>2023-12-22T23:21:34Z</updated>

		<summary type="html">&lt;p&gt;Mrbehemo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TocRight}}&lt;br /&gt;
This page documents &amp;quot;HelperScripts_Spawner.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 cSpawner provides methods for spawning entities and particle systems at specific vector positions.&lt;br /&gt;
&lt;br /&gt;
===Spawn area===&lt;br /&gt;
The normal global functions provided by HPL2 only allow scripts to place objects at an existing Script Area. Spawner makes use of this and teleports the objects into the desired position afterwards.&lt;br /&gt;
&lt;br /&gt;
There are three options for using Spawner, regarding a Spawn Area:&lt;br /&gt;
# Simply add a Script Area to the level named &amp;quot;SpawnArea&amp;quot;, anywhere, any size.&lt;br /&gt;
# Tell Spawner to use a Script Area that already exists in the map, anywhere, any size, regardless of any other purpose.&lt;br /&gt;
# Tell Spawner to use multiple Script Areas placed in the map especially. This is only useful for semi-random rotation.&lt;br /&gt;
&lt;br /&gt;
The default named Area is &amp;quot;SpawnArea&amp;quot; - you can change this using the SpawnArea property in script.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Spawner.SpawnArea = &amp;quot;SomeOtherArea&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Whatever it is called, there must be designated Script Area in the map, ''somewhere'', whose name matches SpawnArea. It doesn't matter what size it is or where it is located, as long as it exists.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Spawning with shapes===&lt;br /&gt;
As well as spawning enties at specific positions, Spawner can also spawn entities randomly within a box or sphere shape, or spread evenly along a curve. It can also spawn particle systems at specific places or on a curve.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Spawning with rotation===&lt;br /&gt;
It isn't possible to set the world rotation of an entity through script alone. However, spawned items will match the rotation of the whatever Script Area they were spawned at.&lt;br /&gt;
&lt;br /&gt;
The SpawnArea propery allows one specific area to be set, but the [[HPL2/HPL2_Helper_Scripts/Spawner#SetSpawnArea.28.29|SetSpawnArea()]] ''method'' will accept an array or list of area names. When more than one Spawn Area is set, each spawned item will choose a different one at random. Having multiple Spawn Areas has no advantage other than having multiple sources for rotation.&lt;br /&gt;
&lt;br /&gt;
For example, if the desired outcome is to spawn many debris objects with random-ish rotations, multiple Script Areas should be created in the level and given specific names and different rotations. It doesn't matter what size or location they are, only their rotation matters. In script, they should all be assigned with [[HPL2/HPL2_Helper_Scripts/Spawner#SetSpawnArea.28.29|SetSpawnArea()]], and then each spawned item will take on the rotation of one of the areas at random.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Particles &amp;amp; temporary entities===&lt;br /&gt;
In order to spawn particle systems, Spawner spawns a &amp;quot;temp entity&amp;quot; - an invisible entity that the particle system is attached to. The number of temp entities is limited (256 by default) and when the full number is reached, older ones will be recycled.&lt;br /&gt;
&lt;br /&gt;
If Spawner is used to create entities without specifying a name for them, they will be treated like temp entities too.&lt;br /&gt;
&lt;br /&gt;
The entity file used for temp entities is called &amp;quot;SpawnerTemp.ent&amp;quot; and is located in the &amp;quot;&amp;quot;HPL2HelperScripts&amp;quot; folders. This can be changed using the TempEntityFile property, if required for some reason.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Save data===&lt;br /&gt;
Spawner does not save any data of its own. By default, entities created by Spawner will be saved along with the save game and Spawner will have no need to remember them on the next play session. The SaveEntities property can be used to change this behaviour at run-time. Its default is true.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent1&amp;quot;, &amp;quot;spookyChair.ent&amp;quot;, cVector(0.0f, 0.0f, 0.0f));		// This new entity will save by *default*.&lt;br /&gt;
Spawner.SaveEntities = false;		&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent2&amp;quot;, &amp;quot;spookyTable.ent&amp;quot;, cVector(2.0f, 0.0f, 0.0f));		// This new entity will *not* save, specifically.&lt;br /&gt;
Spawner.SaveEntities = true;		&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent3&amp;quot;, &amp;quot;spookyCrate.ent&amp;quot;, cVector(4.0f, 0.0f, 0.0f));		// This new entity *will* save, specifically.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Advanced info===&lt;br /&gt;
'''Advanced users''' may wish to examine &amp;quot;HelperScripts_Spawner.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 the default names for entities and the maximum number of temp entities allowed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Spawner=&lt;br /&gt;
Spawner is the name of the object that manages spawning entities at specific map locations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Behaviours==&lt;br /&gt;
&amp;quot;HelperScripts_Spawner.hps&amp;quot; declares an object called '''Spawner''', of the new script class cSpawner. To access its methods, just use &amp;quot;Spawner.&amp;quot; followed by the function call. E.g.:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;bigThing&amp;quot;, &amp;quot;bigThing.ent&amp;quot;, cVector(1.1f, 2.2f, 3.3f));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Properties==&lt;br /&gt;
Spawner provides the following properties:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SaveEntities====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string SaveEntities&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The bool property SaveEntities can be used to specify whether entities and particle systems spawned by Spawner will be saved as part of the save game. (Default = true)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent1&amp;quot;, &amp;quot;spookyChair.ent&amp;quot;, cVector(0.0f, 0.0f, 0.0f));		// This new entity will save by default.&lt;br /&gt;
Spawner.SaveEntities = false;		&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent2&amp;quot;, &amp;quot;spookyTable.ent&amp;quot;, cVector(2.0f, 0.0f, 0.0f));		// This new entity will ''not'' save, specifically.&lt;br /&gt;
Spawner.SaveEntities = true;		&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;ent3&amp;quot;, &amp;quot;spookyCrate.ent&amp;quot;, cVector(4.0f, 0.0f, 0.0f));		// This new entity ''will'' save, specifically.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnArea====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string SpawnArea&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string property SpawnArea can get or set the named Script Area used for spawning entities. (Default = &amp;quot;SpawnArea&amp;quot;)&lt;br /&gt;
&amp;lt;br&amp;gt;(The advantage of using the SpawnArea property is that it can just be set to any Script Area that happens to exist in the map.)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.SpawnArea = &amp;quot;LibraryEntranceTriggerB&amp;quot;;&lt;br /&gt;
// Spawner will use the Script Area named &amp;quot;LibraryEntranceTriggerB&amp;quot; instead of the default name.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====TempEntityBaseName====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string TempEntityBaseName&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string property TempEntityBaseName can get or set the prefix used when naming temp entities. (Default = &amp;quot;SpawnerTemp&amp;quot;)&lt;br /&gt;
&amp;lt;br&amp;gt;If TempEntityBaseName is &amp;quot;SpawnerTemp&amp;quot; then temp entities will have names like &amp;quot;SpawnerTemp_0&amp;quot;, &amp;quot;SpawnerTemp_1&amp;quot;, etc..&lt;br /&gt;
&amp;lt;br&amp;gt;Note: This can only be changed before Spawner has actually spawned any temp entities, otherwise it would not be able to update or recycle them.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.TempEntityBaseName = &amp;quot;MySpecialEntityName&amp;quot;;&lt;br /&gt;
// Spawner will now create temporary entities with names like &amp;quot;MySpecialEntityName_0&amp;quot;, &amp;quot;MySpecialEntityName_1&amp;quot;, etc..&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====TempEntityFile====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
string TempEntityFile&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string property TempEntityFile can get or set the .ent file used for spawning temporary entities for particle systems. (Default = &amp;quot;SpawnerTemp.ent&amp;quot;)&lt;br /&gt;
&amp;lt;br&amp;gt;The only reason to change TempEntityFile is if there is a specific entity that should be used instead.&lt;br /&gt;
&amp;lt;br&amp;gt;Note: This can only be changed before Spawner has actually spawned any temp entities, otherwise it would not be able to update or recycle them.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.TempEntityFile = &amp;quot;CustomTempEnt.ent&amp;quot;;&lt;br /&gt;
// Spawner will attempt to spawn temp entities from the file &amp;quot;CustomTempEnt.ent&amp;quot; instead of the default file.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Methods==&lt;br /&gt;
Spawner provides the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Spawning entities===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnEntityAtPos()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnEntityAtPos(string asNewEntityName, string asEntityFile, cVector avPosition)&lt;br /&gt;
bool SpawnEntityAtPos(string asNewEntityName, cListString@ ahEntityFileList, cVector avPosition)&lt;br /&gt;
bool SpawnEntityAtPos(string asNewEntityName, string[] asEntityFileArray, cVector avPosition)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns an entity at a specific vector position. If an entity with that name already exists, it will be recycled. That is, it will be teleported into the new position. SpawnEntityAtPos returns true if the entity was recycled, or false if a new entity was created.&lt;br /&gt;
&amp;lt;br&amp;gt;The .ent file can be given as a specific string, e.g. &amp;quot;orb.ent&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ent file that spawns will be chosen at random from the list or array.&lt;br /&gt;
#''string asNewEntityName'' - The name that the new entity will be given. Should either be unique, or an existing entity will be recycled instead.&lt;br /&gt;
#''string asEntityFile, cListString@ ahEntityFileList, string[] asEntityFileArray'' - A string, an array of strings, or a list of strings containing one or more .ent files.&lt;br /&gt;
#''cVector avPosition'' - A 3d vector position in the map to spawn the entity.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.SpawnEntityAtPos(&amp;quot;AcmeAnvil&amp;quot;, &amp;quot;anvil.ent&amp;quot;, Math.GetPlayerPosVec() + cVector(0.0f, 3.0f, 0.0f))&lt;br /&gt;
// An entity of the type &amp;quot;anvil.ent&amp;quot; spawns 3m above the player's location.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnEntitiesInBox()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnEntitiesInBox(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string asEntityFile, uint aulQty, cVector avBoxMin, cVector avBoxMax)&lt;br /&gt;
bool SpawnEntitiesInBox(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, cListString ahEntityFileList, uint aulQty, cVector avBoxMin, cVector avBoxMax)&lt;br /&gt;
bool SpawnEntitiesInBox(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string[] asEntityFileArray, uint aulQty, cVector avBoxMin, cVector avBoxMax)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns a quantity of entities a random positions within a box shape defined by a pair of vectors (similar to the box shaped starting position in the particle editor). If the box is sized zero in one dimension then that is effectively a rectangle, so this can also be used spawn objects on a plane.&lt;br /&gt;
&amp;lt;br&amp;gt;The .ent file can be given as a specific string, e.g. &amp;quot;orb.ent&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ent file that spawns will be chosen at random from the list or array.&lt;br /&gt;
&amp;lt;br&amp;gt;If asEntityBaseName is given, it will be used to name the new entities. E.g. if asEntityBaseName = &amp;quot;box&amp;quot;, then new entities will be named like &amp;quot;box_0&amp;quot;, &amp;quot;box_1&amp;quot; etc.. If asEntityBaseName is omitted, then temp entity names will be used instead. If an entity with that name already exists, it will be recycled, that is it will be teleported into the new position. If the script needs to refer to the entities by name later, use asEntityBaseName to give them specific names.&lt;br /&gt;
&amp;lt;br&amp;gt;SpawnEntitiesInBox returns true if any entities were recycled, or false if all the entities are newly created.&lt;br /&gt;
#''string asEntityBaseName'' - The name to use for the new entities, which will be appended with &amp;quot;_0&amp;quot;, &amp;quot;_1&amp;quot; etc. (Optional, default = &amp;quot;SpawnerTemp&amp;quot;) &lt;br /&gt;
#''string asEntityFile, cListString@ ahEntityFileList, string[] asEntityFileArray'' - A string, an array of strings, or a list of strings containing one or more .ent files.&lt;br /&gt;
#''uint aulQty'' -  The number of entities to spawn in the box.&lt;br /&gt;
#''cVector avBoxMin'' - The minimum extent of the box.&lt;br /&gt;
#''cVector avBoxMax'' -  The maximum extent of the box.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
cListString listJunkProps;&lt;br /&gt;
listJunkProps.Add(&amp;quot;wooden_board02.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;tongs.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;hammer.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;chisel.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;basket.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;flask01.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;dungeon_small01.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;brick.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;brick.ent&amp;quot;);&lt;br /&gt;
listJunkProps.Add(&amp;quot;brick.ent&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
Spawner.SpawnEntitiesInBox(&amp;quot;Junk_A&amp;quot;, listJunkProps, 24, cVector(10.0f, 0.25f, 15.0f), cVector(15.0f, 0.25f, 20.0f));&lt;br /&gt;
// 24 random junk items are selected from the list and spawned in a square, with names &amp;quot;Junk_A_0&amp;quot; to &amp;quot;Junk_A_23&amp;quot;.&lt;br /&gt;
// Note that &amp;quot;brick.ent&amp;quot; is three times more likely to spawn than the others.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnEntitiesInSphere()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnEntitiesInSphere(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string asEntityFile, uint aulQty, cVector avOrigin, float afRadius) &lt;br /&gt;
bool SpawnEntitiesInSphere(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, cListString ahEntityFileList, uint aulQty, cVector avOrigin, float afRadius) &lt;br /&gt;
bool SpawnEntitiesInSphere(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string[] asEntityFileArray, uint aulQty, cVector avOrigin, float afRadius) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns a quantity of entities a random positions within a sphere shape defined by a centre vector and a radius.&lt;br /&gt;
&amp;lt;br&amp;gt;The .ent file can be given as a specific string, e.g. &amp;quot;orb.ent&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ent file that spawns will be chosen at random from the list or array.&lt;br /&gt;
&amp;lt;br&amp;gt; If asEntityBaseName is given, it will be used to name the new entities. E.g. if asEntityBaseName = &amp;quot;box&amp;quot;, then new entities will be named like &amp;quot;box_0&amp;quot;, &amp;quot;box_1&amp;quot; etc.. If asEntityBaseName is omitted, then temp entity names will be used instead. If an entity with that name already exists, it will be recycled, that is it will be teleported into the new position. If you need to know the names of the entities to refer to them later, use asEntityBaseName.&lt;br /&gt;
&amp;lt;br&amp;gt;SpawnEntitiesInSphere returns true if any entities were recycled, or false if all the entities are newly created.&lt;br /&gt;
#''string asEntityBaseName'' - The name to use for the new entities, which will be appended with &amp;quot;_0&amp;quot;, &amp;quot;_1&amp;quot; etc. (Optional, default = &amp;quot;SpawnerTemp&amp;quot;) &lt;br /&gt;
#''string asEntityFile, cListString@ ahEntityFileList, string[] asEntityFileArray'' - A string, an array of strings, or a list of strings containing one or more .ent files.&lt;br /&gt;
#''uint aulQty'' - The number of entities to spawn in the sphere.&lt;br /&gt;
#''cVector avOrigin'' - The centre of the sphere.&lt;br /&gt;
#''cVector afRadius'' - The radius of the sphere.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example:&lt;br /&gt;
Spawner.SpawnEntitiesInSphere(&amp;quot;MegaOrb&amp;quot;, &amp;quot;orb.ent&amp;quot;, 1000, Math.GetPlayerPosVec(), 4.0f);&lt;br /&gt;
SetPlayerSanity(0.0f);&lt;br /&gt;
// One thousand orbs have spawned around the player, placing them at the centre of an 8m wide MegaOrb. The player had no chance to remain sane in such circumstances.&lt;br /&gt;
// Note: if no string was given for asEntityBaseName, then the number of entities spawned would be limited to the temp entity max (default = 256).&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnEntitiesOnSpline()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnEntitiesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string asEntityFile, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
bool SpawnEntitiesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, cListString ahEntityFileList, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
bool SpawnEntitiesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string[] asEntityFileArray, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns a quantity of entites evenly spaced along a spline.&lt;br /&gt;
&amp;lt;br&amp;gt;The .ent file can be given as a specific string, e.g. &amp;quot;orb.ent&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ent file that spawns will be chosen at random from the list or array.&lt;br /&gt;
&amp;lt;br&amp;gt;If asEntityBaseName is given, it will be used to name the new entities. E.g. if asEntityBaseName = &amp;quot;box&amp;quot;, then new entities will be named like &amp;quot;box_0&amp;quot;, &amp;quot;box_1&amp;quot; etc.. If asEntityBaseName is omitted, then temp entity names will be used instead. If an entity with that name already exists, it will be recycled, that is it will be teleported into the new position. If the names of the entities are needed to refer to them later or update their position, use asEntityBaseName.&lt;br /&gt;
&amp;lt;br&amp;gt;SpawnEntitiesOnSpline returns true if any entities were recycled, or false if all the entities are newly created.&lt;br /&gt;
&amp;lt;br&amp;gt;afPhase is optional. It can be used to adjust the spread of the entities on the curve with a number between 0.0f and 1.0f, or it can be omitted. If it is omitted, or less than zero, then the default spacing will be used.&lt;br /&gt;
&amp;lt;br&amp;gt;The default spacing is the &amp;quot;full spread&amp;quot; - that is to say the first entity will be spawned at the start of the curve, the last entity at the very end, and all the others evenly in between.&lt;br /&gt;
&amp;lt;br&amp;gt;However, if value between 0.0f and 1.0f is used for afPhase, then the entities will be spawned within their own division of the curve, with the phase 0.0f - 1.0f specifying how far through that division it will appear.&lt;br /&gt;
&amp;lt;br&amp;gt;The following diagram illustrates the phase option:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
  |1----2----3----4|	&amp;lt;- default spacing: no phase, full spread.&lt;br /&gt;
  |1---2---3---4---|	&amp;lt;- phase = 0.0f, each object at the start of its division.&lt;br /&gt;
  |-1---2---3---4--|	&amp;lt;- phase = 0.25f, each object 1/4 of the way through its division.&lt;br /&gt;
  |--1---2---3---4-|	&amp;lt;- phase = 0.5f, each object 1/2 of the way through its division.&lt;br /&gt;
  |---1---2---3---4|	&amp;lt;- phase = 0.75f, each object 3/4 of the way through its division.&lt;br /&gt;
  |1---2---3---4---|	&amp;lt;- phase = 1.0f is the same as phase = 0.0f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;To update the position of the spawned entities without respawning them, for example if the spline or phase has changed, see UpdateEntitiesOnSpline().&lt;br /&gt;
&amp;lt;br&amp;gt;You can easily use SpawnEntitiesOnSpline() with a single Bezier or a straight line between two points, depending on how you construct your spline. See the examples, or see cSpline and cBezier classes for more information.&lt;br /&gt;
#''string asEntityBaseName'' - The name to use for the new entities, which will be appended with &amp;quot;_0&amp;quot;, &amp;quot;_1&amp;quot; etc. (Optional, default = &amp;quot;SpawnerTemp&amp;quot;)&lt;br /&gt;
#''string asEntityFile, cListString@ ahEntityFileList, string[] asEntityFileArray'' - A string, an array of strings, or a list of strings containing one or more .ent files.&lt;br /&gt;
#''uint aulQty'' - The number of entities to be placed on the spline.&lt;br /&gt;
#''cSpline@ ahSpline'' - A spline to place entities on.&lt;br /&gt;
#''float afPhase'' - An adjustment to the spread of the entities, 0.0f - 1.0f, or -1.0f for full spread. (Optional, default = -1.0f)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(&amp;quot;WigglyPathChair&amp;quot;, &amp;quot;chair.ent&amp;quot;, 10, vBigWigglyPath);&lt;br /&gt;
// 10x chair.ent have been spawned on the existing spline curve vBigWigglyPath.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
SpawnEntitiesOnSpline(&amp;quot;rock.ent&amp;quot;, 16, cSpline(cVector(2.0f, 2.0f, 10.0f), cVector(4.0f, 2.0f, 10.0f));&lt;br /&gt;
// 16x rock.ent have been spawned in a line shape.&lt;br /&gt;
// The line is formed from a new cSpline defined by two cVectors.&lt;br /&gt;
// The entities were not named, so temp entity names have been used. This means that they cannot be updated and may be recycled.&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
cSpline vFloatyRockArch = cSpline(cVector(2.0f, 0.0f, 10.0f), cVector(2.0f, 3.0f, 10.0f), cVector(4.0f, 3.0f, 10.0f), cVector(4.0f, 0.0f, 10.0f));&lt;br /&gt;
&lt;br /&gt;
cListString listRockTypes;&lt;br /&gt;
for (uint i = 0; i &amp;lt; 5; i++) listRockTypes.Add(&amp;quot;rock_&amp;quot; + i + &amp;quot;.ent&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(&amp;quot;FloatyRockArchEnt&amp;quot;, listRockTypes, 16, vFloatyRockArch);&lt;br /&gt;
// 16x rocks have been spawned in an arch shape.&lt;br /&gt;
// The arch is formed from a new cSpline defined by four cVectors, making a cubic bezier.&lt;br /&gt;
// Each rock entity was selected at random from one of five created in the list.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Spawning particles===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnParticlesAtPos()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnParticlesAtPos(string asNewPSName, string asPSFile, cVector avPosition)&lt;br /&gt;
bool SpawnParticlesAtPos(string asNewPSName, cListString@ ahPSFileList, cVector avPosition)&lt;br /&gt;
bool SpawnParticlesAtPos(string asNewPSName, string[] asPSFileArray, cVector avPosition)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns a particle system at a specific vector position. &lt;br /&gt;
&amp;lt;br&amp;gt;The .ps file can be given as a specific string, e.g. &amp;quot;ps_bubbles.ps&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ps file that spawns will be chosen at random from the list or array.&lt;br /&gt;
&amp;lt;br&amp;gt;In order to place a particle system at an arbitrary location, a temp entity is used, using the msTempEntNameBase. If the maximum number of temp entities already exist, one will be recycled in the new position. SpawnParticlesAtPos returns true if the temp entity was recycled, or false if a new entity was created.&lt;br /&gt;
&amp;lt;br&amp;gt;If a particle system already exists with the given name, then it will be destroyed and replaced.&lt;br /&gt;
#''string asNewPSName'' - The name that the new particle system will be given. Should either be unique, or an existing system will be recycled instead.&lt;br /&gt;
#''string asPSFile, cListString@ ahPSFileList, string[] asPSFileArray'' - A string, an array of strings, or a list of strings containing one or more .ps files.&lt;br /&gt;
#''cVector avPosition'' - A 3d vector position in the map to spawn the entity.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Spawner.SpawnParticlesAtPos(&amp;quot;FloatyFlame&amp;quot;, &amp;quot;ps_fire_candle.ps&amp;quot;, cVector(23.0f, 2.25f, 14.5f));&lt;br /&gt;
// A candle flame will be spawned at the given vector position, using a temp entity.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string[] arrayFlameTypes = { &amp;quot;ps_fire_candle.ps&amp;quot;, &amp;quot;ps_fire_candle_red.ps&amp;quot;, &amp;quot;ps_fire_candle_blue.ps&amp;quot; };&lt;br /&gt;
&lt;br /&gt;
Spawner.SpawnParticlesAtPos(&amp;quot;FloatyFlame&amp;quot;, listFlameTypes, cVector(23.0f, 2.25f, 14.5f));&lt;br /&gt;
// A candle flame will be spawned at the given vector position, using a temp entity.&lt;br /&gt;
// The .ps file will be selected at random from the array.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SpawnParticlesOnSpline()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool SpawnParticlesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string asPSFile, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
bool SpawnParticlesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, cListString ahPSFileList, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
bool SpawnParticlesOnSpline(string asEntityBaseName = &amp;quot;SpawnerTemp&amp;quot;, string[] ahPSFileArray, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Spawns a quantity of particle systems evenly spaced along a spline. The ahSpline argument should refer to an existing cSpline variable if the positions of the particles should need to be updated later. See the examples, or see cSpline for further information on creating splines. To update the position of the spawned entities without respawning them, for example if the spline or phase has changed, see UpdateEntitiesOnSpline(). This will also move the particle systems.&lt;br /&gt;
&amp;lt;br&amp;gt;The .ps file can be given as a specific string, e.g. &amp;quot;ps_bubbles.ps&amp;quot;, or it can be a list or array or strings. If a list or array is given, the .ps file that spawns will be chosen at random from the list or array.&lt;br /&gt;
&amp;lt;br&amp;gt;In order to place a particle system at an arbitrary location, a temp entity is used, using the default temp entity name. If the maximum number of temp entities already exist, some will be recycled in the new position on the spline. SpawnParticlesOnSpline returns true if any temp entities were recycled, or false if only new entities were used created.&lt;br /&gt;
&amp;lt;br&amp;gt;If a specific name is given using the asEntityBaseName argument, then it will be used instead. E.g. if asEntityBaseName = &amp;quot;box&amp;quot;, then new entities will be named like &amp;quot;box_0&amp;quot;, &amp;quot;box_1&amp;quot; etc.. If the names of the temp entities are needed to refer to them later, for example to update the particles on the spline, use a specific string for asEntityBaseName. SpawnParticlesOnSpline returns true is any entities were recycled, or false if all the entities are newly created.&lt;br /&gt;
&amp;lt;br&amp;gt;afPhase is optional. It can be used to adjust the spread of the entities on the curve with a number between 0.0f and 1.0f, or it can be omitted. If it is omitted or if it is given as any number less than zero, then the default spacing will be used. The default spacing  is the &amp;quot;full spread&amp;quot; - that is to say the first entity will be spawned at the start of the curve, the last at the end, and all the others evenly in between. However, if value between 0.0f and 1.0f is used for afPhase, then the entities will be spawned within their own division of the curve, with the phase 0.0f - 1.0f specifying how far through that division it will appear.&lt;br /&gt;
&amp;lt;br&amp;gt;The following diagram illustrates the phase option:&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
  |1----2----3----4|	&amp;lt;- default spacing: no phase, full spread.&lt;br /&gt;
  |1---2---3---4---|	&amp;lt;- phase = 0.0f, each object at the start of its division.&lt;br /&gt;
  |-1---2---3---4--|	&amp;lt;- phase = 0.25f, each object 1/4 of the way through its division.&lt;br /&gt;
  |--1---2---3---4-|	&amp;lt;- phase = 0.5f, each object 1/2 of the way through its division.&lt;br /&gt;
  |---1---2---3---4|	&amp;lt;- phase = 0.75f, each object 3/4 of the way through its division.&lt;br /&gt;
  |1---2---3---4---|	&amp;lt;- phase = 1.0f is the same as phase = 0.0f.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;If a particle system already exists with the given name, then it will be destroyed and replaced.&lt;br /&gt;
#''string asEntityBaseName'' - The name to use for the new entities, which will be appended with &amp;quot;_0&amp;quot;, &amp;quot;_1&amp;quot; etc. (Optional, default = &amp;quot;SpawnerTemp&amp;quot;)&lt;br /&gt;
#''string asPSFile, cListString@ ahPSFileList, string[] asPSFileArray'' - A string, an array of strings, or a list of strings containing one or more .ps files.&lt;br /&gt;
#''uint aulQty'' - The number of entities to be placed on the spline.&lt;br /&gt;
#''cSpline@ ahSpline'' - A spline to place entities on.&lt;br /&gt;
#''float afPhase'' - An adjustment to the spread of the entities, 0.0f - 1.0f, or -1.0f for full spread. (Optional, default = -1.0f)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(&amp;quot;WigglyPathFlame&amp;quot;, &amp;quot;ps_fire_candle.ps&amp;quot;, 10, vBigWigglyPath);&lt;br /&gt;
// 10x ps_fire_candle.ps have been spawned on the existing spline curve vBigWigglyPath.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(&amp;quot;ps_fire_candle.ps&amp;quot;, 16, cSpline(cVector(2.0f, 2.0f, 10.0f), cVector(4.0f, 2.0f, 10.0f)));&lt;br /&gt;
// 16x flames have been spawned in a line shape.&lt;br /&gt;
// The line is formed from a new anonymous cSpline defined by two cVectors.&lt;br /&gt;
// The temp entities have not been named, so they cannot be updated and may be recycled.&lt;br /&gt;
&lt;br /&gt;
// Example 3:&lt;br /&gt;
cSpline vFloatyFlameArch = cSpline(cVector(2.0f, 0.0f, 10.0f), cVector(2.0f, 3.0f, 10.0f), cVector(4.0f, 3.0f, 10.0f), cVector(4.0f, 0.0f, 10.0f));&lt;br /&gt;
&lt;br /&gt;
cListString listFlameTypes;&lt;br /&gt;
listFlameTypes.Add(&amp;quot;ps_fire_candle.ps&amp;quot;);&lt;br /&gt;
listFlameTypes.Add(&amp;quot;ps_fire_candle_red.ps&amp;quot;);&lt;br /&gt;
listFlameTypes.Add(&amp;quot;ps_fire_candle_blue.ps&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(&amp;quot;FloatyFlame&amp;quot;, listFlameTypes, 16, vFloatyFlameArch, 0.5f);&lt;br /&gt;
// 16x flames have been spawned in an arch shape, where each sits halfway through own 16th division (phase = 0.5f).&lt;br /&gt;
// The arch shape is provided by an existing named cSpline, defined by four cVectors, making a cubic bezier.&lt;br /&gt;
// Each particle system was selected at random from one of three .ps files.&lt;br /&gt;
// Since the cSpline and the carrier entities have been named (&amp;quot;FloatyFlame_0&amp;quot;, &amp;quot;FloatyFlame_1&amp;quot; etc.) they can be referred to and updated later.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Movement and rotation===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====SetSpawnArea()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
void SetSpawnArea(string asSpawnArea)&lt;br /&gt;
void SetSpawnArea(string[] asSpawnAreaArray)&lt;br /&gt;
void SetSpawnArea(cListString asSpawnAreaList)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The simplest way to allocate a specific Spawn Area is with the SpawnArea property. (&amp;lt;code&amp;gt;Spawner.SpawnArea = &amp;quot;someArea&amp;quot;;&amp;lt;/code&amp;gt;)&lt;br /&gt;
&amp;lt;br&amp;gt;However, the SetSpawnArea() method can also be used to specify multiple Script Areas with an array or list. If multiple Script Areas are specified then one of them will be selected at random for each item spawned.&lt;br /&gt;
&amp;lt;br&amp;gt;This has only one advantage: spawned items take on the rotation of their Spawn Area.&lt;br /&gt;
&amp;lt;br&amp;gt;If the desired outcome is to [[HPL2/HPL2_Helper_Scripts/Spawner#Spawning_with_rotation|spawn objects with random rotation]], the only way to achieve this through script to create a handful of Areas with various rotations, assign them all the SetSpawnArea(), and then each spawned item will take on the rotation of one of the areas.&lt;br /&gt;
#''string asSpawnArea, string[] asSpawnAreaArray, cListString, asSpawnAreaList'' - One or more names to be designated as the spawn area.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Spawner.SetSpawnArea(&amp;quot;MyScriptArea&amp;quot;);&lt;br /&gt;
Spawner.SpawnEntitiesInBox(&amp;quot;Hammer&amp;quot;, &amp;quot;hammer.ent&amp;quot;, 24, cVector(10.0f, 0.25f, 15.0f), cVector(15.0f, 0.25f, 20.0f));&lt;br /&gt;
// 24x hammer.ent will be spawned in the defined bos.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
string[] sAreas = { &amp;quot;MyScriptArea1&amp;quot;, &amp;quot;MyScriptArea2&amp;quot;, &amp;quot;MyScriptArea3&amp;quot;, &amp;quot;MyScriptArea4&amp;quot; };&lt;br /&gt;
Spawner.SetSpawnArea(sAreas);&lt;br /&gt;
Spawner.SpawnEntitiesInBox(&amp;quot;Hammer&amp;quot;, &amp;quot;hammer.ent&amp;quot;, 24, cVector(10.0f, 0.25f, 15.0f), cVector(15.0f, 0.25f, 20.0f));&lt;br /&gt;
// 24x hammer.ent will be spawned in the defined box, each with the rotation copied from one of the 4 script areas.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====UpdateEntitiesOnSpline()====&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
bool UpdateEntitiesOnSpline(string asEntityBaseName, uint aulQty, cSpline ahSpline, float afPhase = -1.0f)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
If SpawnEntitiesOnSpline() or SpawnParticlesOnSpline() has been used with a specific asEntityBaseName, and if the spline position has changed or a new phase value is desired, then UpdateEntitiesOnSpline() can be used to update the entities' or particles' positions, without recycling or further spawning.&lt;br /&gt;
&amp;lt;br&amp;gt;UpdateEntitiesOnSpline returns false if any of the expected entities do not exist, or true if the were all found and updated successfully.&lt;br /&gt;
&amp;lt;br&amp;gt;If a unique asEntityBaseName was not used, this may have enexpected results.&lt;br /&gt;
#''string asEntityBaseName'' - The base name used to previously spawn items on the spline.&lt;br /&gt;
#''uint aulQty'' - The number of items that were previously spawned in the spline.&lt;br /&gt;
#''cSpline ahSpline'' - A reference to an existing spline.&lt;br /&gt;
#''float afPhase'' - An adjustment to the spread of the entities, 0.0f - 1.0f, or -1.0f for full spread. (Optional, default = -1.0f)&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
// Example 1:&lt;br /&gt;
Spawner.SpawnEntitiesOnSpline(vBigWigglyPath, 10, &amp;quot;chair.ent&amp;quot;, &amp;quot;WigglyPathChair&amp;quot;);&lt;br /&gt;
// 10x chair.ent have been spawned on the curve vBigWigglyPath.&lt;br /&gt;
// ...some time later... vBigWigglyPath has been updated with new vectors:&lt;br /&gt;
Spawner.UpdateEntitiesOnSpline(vBigWigglyPath, 10, &amp;quot;WigglyPathChair&amp;quot;);&lt;br /&gt;
// The 10 entities have adjusted to the new curve vectors.&lt;br /&gt;
&lt;br /&gt;
// Example 2:&lt;br /&gt;
OnEnter()&lt;br /&gt;
{&lt;br /&gt;
	float fWigglyPathPhase = 0.0f;&lt;br /&gt;
	Spawner.SpawnEntitiesOnSpline(vBigWigglyPath, 1, &amp;quot;chair.ent&amp;quot;, &amp;quot;WigglyPathChair&amp;quot;, fWigglyPathPhase);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
OnUpdate(float asStep)&lt;br /&gt;
{&lt;br /&gt;
	fWigglyPathPhase = Math.Wrap(fWigglyPathPhase + afStep / 5.0f);&lt;br /&gt;
	Spawner.UpdateEntitiesOnSpline(vBigWigglyPath, 1, &amp;quot;WigglyPathChair&amp;quot;, fWigglyPathPhase);&lt;br /&gt;
}&lt;br /&gt;
// In this example, a single chair.ent is spawned on a curve name vBigWigglyPath when the level is first entered.&lt;br /&gt;
// fWigglyPathPhase updates between 0.0f and 1.0f over the course of 5 seconds (see Math.Wrap()) and UpdateEntitiesOnSpline() applies the new phase.&lt;br /&gt;
// The result is that the chair continuous moves along the curve vBigWigglyPath every 5 seconds, then loops back to the start.&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>