Critter

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting
Revision as of 14:19, 2 October 2026 by TiMan (talk | contribs) (Add a sourced SOMA guide with explanations and stock-script examples.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


The SOMA script declarations for this interface reference are in script/interfaces/Critter_Interface.hps.

The iScrCritter base exposes the native cLuxCritter as mBaseObj and through GetBase. The AI helper provides critter-group and extra-escape-target operations; the extra-escape helper is documented as implemented for FishSmall.

Before you start

  1. Open the map script inside your own mod. Keep its generated includes, cScrMap : iScrMap class and callback structure. See Add your first script if you have not edited a map script yet.
  2. Add the helper include shown below alongside the script’s other includes.
  3. 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"

Critter_SetGroupEntity

Sets the entity the critter should flock around

Parameter Meaning
asCritter name of the Critter. Wildcard supported.
asGroupEntity The name of the group entity.

In maps/chapter02/02_02_ms_curie_inside/02_02_ms_curie_inside.hps, SOMA calls Critter_SetGroupEntity as follows.

Critter_SetGroupEntity(asChild, "LockerFishTarget_2");
Parameter Value in this stock call
asCritter asChild
asGroupEntity "LockerFishTarget_2"

This is an excerpt from that stock script; its referenced names and variables belong to that script.

Critter_AddExtraEscapeEntity

Adds an entity that the critter should try to avoid the same way it does with the player. (Only implemented in FishSmall right now)

Parameter Meaning
asCritter name of the Critter. Wildcard supported.
asEscapeEntity The name of the entity to escape from

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.

See also