Infection Handler

From Frictional Wiki
< HPL3‎ | SOMA‎ | Scripting
Revision as of 14:13, 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 Infection Handler draws growing infection trees at screen borders. Border indices select top, bottom, left or right, and ClearTrees removes the generated trees.

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_modules.hps"

Infection_CreateBorderTree

Creates an infection tree at a border of the screen

Parameter Meaning
alBorder The border of the screen where it randomly appears 0=top, 1= bottom, 2=left, 3=right
afOffset How much outside of the screen the tree start is offset
avSize The size of the start tree segment.
afSpeed The speed at which the tree grows.

In maps/02_06_theta_tunnels_old/02_06_theta_tunnels.hps, SOMA calls Infection_CreateBorderTree as follows.

Infection_CreateBorderTree(1, 30, cVector2f(14,35), 3.0f);
Parameter Value in this stock call
alBorder 1
afOffset 30
avSize cVector2f(14,35)
afSpeed 3.0f

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

Infection_ClearTrees

Clears all created trees.

In script/modules/PlayerEnergyHandler.hps, SOMA calls Infection_ClearTrees as follows.

Infection_ClearTrees();

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

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