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

		<summary type="html">&lt;p&gt;Add a sourced SOMA guide with explanations and stock-script examples.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{shortPageTitle}}&lt;br /&gt;
&lt;br /&gt;
The Ai helper file in SOMA is &amp;lt;code&amp;gt;script/helpers/helper_ai.hps&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
AI helpers call entity components for movement, pathfinding, senses, voices and head tracking. Pathfinder_MoveToNode requires an entity with a Pathfinder component and broadcasts EndOfPath when its path completes.&lt;br /&gt;
&lt;br /&gt;
== Before you start ==&lt;br /&gt;
# Open the map script inside your own mod. Keep its generated includes, &amp;lt;code&amp;gt;cScrMap : iScrMap&amp;lt;/code&amp;gt; class and callback structure. See [[HPL3/SOMA/Getting Started/Add Your First Script|Add your first script]] if you have not edited a map script yet.&lt;br /&gt;
# Add the helper include shown below alongside the script’s other includes.&lt;br /&gt;
# Read the stock example before copying its calls: named entities, voice subjects, materials and callbacks must belong to the map or resources you are using.&lt;br /&gt;
&lt;br /&gt;
== Follow the stock example ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;helpers/helper_ai.hps&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pathfinder_MoveToNode ===&lt;br /&gt;
Moves an entity containing a Pathfinder component to a node.  The entity message eLuxEntityMessage_EndOfPath is broadcasted when complete.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asEntityName&amp;lt;/code&amp;gt; || name of the entity with the pathfinder.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asNodeName&amp;lt;/code&amp;gt; || name of the node to move to.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asCallbackFunc&amp;lt;/code&amp;gt; || The name of callback called when end is reach. Syntax: void Func(const tString&amp;amp; in asEntityName, bool abReachedEnd)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afUpdateFreq&amp;lt;/code&amp;gt; || The number of times per second that the path will be updated. O or below means never update.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;abExactStopAtEnd&amp;lt;/code&amp;gt; || If the goal node should be hit exactly.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asResultCallbackFunc&amp;lt;/code&amp;gt; || The name of callback called when the pathfinding has been performed. Syntax: void Func(bool abSuccesful)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;maps/chapter04/04_02_tau_inside/04_02_tau_inside.hps&amp;lt;/code&amp;gt;, SOMA calls &amp;lt;code&amp;gt;Pathfinder_MoveToNode&amp;lt;/code&amp;gt; as follows.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Pathfinder_MoveToNode(&amp;quot;Leviathan&amp;quot;, &amp;quot;LeviathanTarget&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Value in this stock call&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asEntityName&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;amp;quot;Leviathan&amp;amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asNodeName&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;amp;quot;LeviathanTarget&amp;amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an excerpt from that stock script; its referenced names and variables belong to that script.&lt;br /&gt;
&lt;br /&gt;
=== Pathfinder_Track_Add ===&lt;br /&gt;
Adds a track node to be followed.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asEntityName&amp;lt;/code&amp;gt; || name of the entity with the pathfinder.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asNodeName&amp;lt;/code&amp;gt; || Name of the path node to be added.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afMinWaitTime&amp;lt;/code&amp;gt; || minimum time before the entity moves to the next node.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afMaxWaitTime&amp;lt;/code&amp;gt; || maximum time before the entity moves to the next node. If &amp;lt;0, then the value will be same as afMinWaitTime&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asAnimName&amp;lt;/code&amp;gt; || animation played when at node, per entity.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;abLoopAnim&amp;lt;/code&amp;gt; || if the animtion should be looped, per entity.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;maps/chapter04/04_01_tau_outside/04_01_tau_outside.hps&amp;lt;/code&amp;gt;, SOMA calls &amp;lt;code&amp;gt;Pathfinder_Track_Add&amp;lt;/code&amp;gt; as follows.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
Pathfinder_Track_Add(&amp;quot;LightBot&amp;quot;,&amp;quot;LightNode_&amp;quot;+i);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Value in this stock call&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asEntityName&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;amp;quot;LightBot&amp;amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asNodeName&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;&amp;amp;quot;LightNode_&amp;amp;quot;+i&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
This is an excerpt from that stock script; its referenced names and variables belong to that script.&lt;br /&gt;
&lt;br /&gt;
=== Pathfinder_Track_Start ===&lt;br /&gt;
Starts a track&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Parameter !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asEntityName&amp;lt;/code&amp;gt; || name of the entity with the pathfinder.&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;abLoop&amp;lt;/code&amp;gt; || if the path should loop&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;afUpdateFreq&amp;lt;/code&amp;gt; || the frequency at which the path is recculated&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;asEndOfTrackCallback&amp;lt;/code&amp;gt; || Callback called when path is over. Syntax: void MyFunc(const tString&amp;amp; in asEntityName)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Check your change ==&lt;br /&gt;
Save the script and restart the map in development mode with &amp;lt;code&amp;gt;F5&amp;lt;/code&amp;gt;. If the script fails, open &amp;lt;code&amp;gt;F1&amp;lt;/code&amp;gt; and use '''Show Error List''' or '''Show HPL Log'''. See [[HPL3/SOMA/Getting Started/Test Debug and Continue|the development loop]] for the launch and debugging steps.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[HPL3/SOMA/Scripting|SOMA scripting]]&lt;br /&gt;
* [[HPL3/SOMA/Scripting/Scripting Api|SOMA scripting API]]&lt;br /&gt;
&lt;br /&gt;
[[Category:English]]&lt;/div&gt;</summary>
		<author><name>TiMan</name></author>
		
	</entry>
</feed>