Agents
The SOMA script declarations for this interface reference are in script/interfaces/Agent_Interface.hps.
The iScrAgent base exposes the native cLuxAgent as mBaseObj and through GetBase. Agent behavior can use separate movement, pathfinding, sound and head-tracking components; the AI helper calls the relevant component on a named entity.
Contents
Before you start
- Open the map script inside your own mod. Keep its generated includes,
cScrMap : iScrMapclass and callback structure. See Add your first script if you have not edited a map script yet. - Add the helper include shown below alongside the script’s other includes.
- Read the stock example before copying its calls: named entities, voice subjects, materials and callbacks must belong to the map or resources you are using.
Follow the stock example
#include "helpers/helper_ai.hps"
Agent_SetSensesActive
Set if the agent should have its senses (hearing/vision/etc) enabled. Usually implemented on a specific basis.
| Parameter | Meaning |
|---|---|
asAgentName |
name of the agent. Wildcard supported. |
abX |
If the senses should be active. |
In maps/chapter01/01_04_transport_station/01_04_transport_station.hps, SOMA calls Agent_SetSensesActive as follows.
Agent_SetSensesActive(asTimer, true);
| Parameter | Value in this stock call |
|---|---|
asAgentName |
asTimer
|
abX |
true
|
This is an excerpt from that stock script; its referenced names and variables belong to that script.
Pathfinder_MoveToNode
Moves an entity containing a Pathfinder component to a node. The entity message eLuxEntityMessage_EndOfPath is broadcasted when complete.
| Parameter | Meaning |
|---|---|
asEntityName |
name of the entity with the pathfinder. |
asNodeName |
name of the node to move to. |
asCallbackFunc |
The name of callback called when end is reach. Syntax: void Func(const tString& in asEntityName, bool abReachedEnd) |
afUpdateFreq |
The number of times per second that the path will be updated. O or below means never update. |
abExactStopAtEnd |
If the goal node should be hit exactly. |
asResultCallbackFunc |
The name of callback called when the pathfinding has been performed. Syntax: void Func(bool abSuccesful) |
Check your change
Save the script and restart the map in development mode with F5. If the script fails, open F1 and use Show Error List or Show HPL Log. See the development loop for the launch and debugging steps.