Skip to main content

Locus systemFeaturefulSpirit of Half-Life

A locus key can hold the name of another entity instead of a fixed value, and the game asks that entity for the value each time it needs one, so a position, direction or number can follow a player, a monster or a calculation while the map runs. See the Locus guide for small setups you can build step by step.

The Object Properties window of an env_explosion: the key Position [LP] (blank = here) is set to overhead, the name of a calc_position

An env_explosion whose Position key names a calc_position

Value types​

The FGD marks each locus key with a tag at the end of its editor name, which tells you what kind of value the key takes:

TagWhat the key takesA fixed valueA random value
[LP]A position, which is a point in the world, given as its X Y Z map coordinates128 0 640 0 0 .. 64 64 0
[LV]A vector, which is a direction and an amount, such as a speed or an offset, and not a place0 0 50-10 -10 0 .. 10 10 0
[LR]A number5 or -2.51..3

A position and a vector both have three numbers, but they mean different things: the position 0 0 50 is the point 50 units above the map's point 0 0 0, and the vector 0 0 50 means "50 units up" from any starting point.

The game looks at the first character of the value: a digit or a minus sign makes it a fixed value, and anything else makes it the name of an entity. The game reads .5 as the name of an entity, so you must write 0.5 instead.

A random value gives a new random value each time the game reads the key. In a number range, each side can also be the name of an entity, such as 1..maxhits. Spaces around the .. are fine, so 1 .. 3 works too.

Some keys hold the name of an entity instead of a value, and the FGD marks them [LE], for locus entity. In these keys you can use the special names below, such as !activator, to name the entity.

Entity names in a locus key​

Special names​

These names stand for the activator, which is the entity that started the chain of triggers:

NameWhat it stands for
!activator or *locusThe activator, such as the player who pressed the button, the entity that touched a trigger or the entity a trigger_entity_iterator works on
*playerThe activator, but only when it is a player, and otherwise the key gives no value

If a key's FGD default is *locus, it is also *locus when you leave it empty. !caller, which other keys use for the entity that fired this one, doesn't work in locus keys.

What an entity gives​

What an entity gives depends on the kind of entity and on the type of value the key asks for:

The entityAsked for a positionAsked for a vectorAsked for a number
A monster or a playerIts positionIts velocityIts health divided by its maximum health, so a player with 50 of their 100 health gives 0.5, and a dead one gives 0
A game_numberIts positionIts velocity, which is 0 0 0The number it holds
A game_counterIts positionIts velocity, which is 0 0 0Its count
An env_globalIts positionIts velocity, which is 0 0 0The value of its global state, and no value while the game has no state of that name
A locus_variableThe position it recordedThe vector it recordedThe number it recorded
A calc_ entity or a player_calc_ratioWhat it works out, if it works out that typeWhat it works out, if it works out that typeWhat it works out, if it works out that type
Any other entityIts positionIts velocity0

A calc_ entity that works out a different type gives what any other entity gives: its own position, its velocity of 0 0 0, or the number 0. The value doesn't fail, so this mistake is hard to spot. See Calculation entities for the type each one works out.

When a value fails​

A value fails when the key names an entity that doesn't exist, when *player names no player, or when a calc_ entity can't work out its value, such as after a division by zero or with a result that is too large. If a value fails, the entity that asked does nothing that time. With developer 1 set in the console, the console shows a line such as env_explosion "boom" has bad or missing [LP] value "spot".

Calculation entities​

The calc_ entities work out a value from other values each time a key reads them. Their own keys are locus keys too, so you can chain them, with each one working on the answer of the one before. See the calc_ entities guide for how to build chains.

EntityWhat it givesWhat it works the value out from
calc_positionA positionA point on an entity, such as its origin, eyes, top, center, bottom, an attachment, a random point in its box or the point monsters aim at, plus an offset
calc_subvelocityA vectorAn entity's velocity, the direction it faces or the direction a player looks
calc_velocity_pathA vectorThe way from one position to another, which a wall can cut short
calc_velocity_polarA vectorAnother vector, turned by angles and scaled
calc_vecfromnumsA vector or a positionThree numbers, one each for X, Y and Z
calc_numfromvecA numberOne part of a vector, such as its X, its length, its pitch or its yaw
calc_ratioA numberAnother number, changed with a function such as 1−X, X² or the sine, an offset, a factor, a minimum and a maximum
calc_eval_numberA number, and a vector if you set Report as vectorTwo or three numbers that it adds, subtracts, multiplies or divides, or the remainder, the smallest or the largest
player_calc_ratioA numberThe health, armor, ammo or speed of the player who is the activator

The whole chain is worked out again each time a key reads it, and nothing is stored on the way. To keep a value, use one of these entities:

EntityWhat it keeps
locus_variableA position, a vector and a number, which it records each time you trigger it
game_numberA number, where On and Toggle add 1, Off subtracts 1 and Set gives it a new value, such as the result of a calc_eval_number

If calc_ entities refer to each other in a loop, or a chain has more than 16 calc_ entities one after the other, the value fails. With developer 1 set in the console, the console then shows Locus: calc entities refer to each other in a loop (more than 32 levels); value ignored.

Keys that take locus values​

Most entities work out their locus keys when you trigger them, for the activator of that trigger, and entities that react to a touch work them out for the entity that touches them.

EntityKeysWorked out for
env_explosionPosition [LP]The activator
env_shooter, gibshooterPosition [LP], Direction and speed [LV], Gib Velocity [LR]The activator
env_bloodInitial position [LP], Direction [LV]The activator
env_decalPosition [LP], Spray direction [LV]The activator
env_funnel, env_quakefx, env_shake, env_shockwave, env_soundmarkPosition [LP]The activator
env_warpballWarp position [LP]The activator
env_dlight, env_elightPosition [LP] [LE]The activator
env_renderFX Amount factor [LR]The activator
func_breakable_effectAt position [LP]The activator
monstermakerSpawn position [LP], Face position [LP]The activator
scripted_sentenceSearch origin [LP]The activator
trigger_sensorSource Position [LP]The activator
trigger_compareBase value [LR], Compare value [LR]The activator
trigger_motion, motion_managerPosition, Angles, Velocity and Facing, as their mode keys sayThe activator
trigger_changevalueNew value, with a locus value typeThe activator
locus_variablePosition to record [LP], Vector to record [LV], Number to record [LR]The activator
locus_beamStart at, End atThe activator
trigger_pushSpeed factor [LR], Push direction [LV]Each entity that touches it
trigger_jumpJump target [LP]Each entity that touches it

Second names​

Maps made with Spirit of Half-Life 1.8 may use older class names for five of the calc_ entities, and SBO accepts those names too, loading such a map as if it had the entity in the first column. The editor only offers the names in the first column:

ClassName in Spirit of Half-Life 1.8 maps
calc_positioncalc_posfroment
calc_ratiocalc_numfromnum
calc_subvelocitycalc_vecfroment
calc_velocity_pathcalc_vecfrompos
calc_velocity_polarcalc_vecfromvec

Changes since 1.38​

  • The locus keys, the calc_ entities, locus_variable, locus_beam, game_number and trigger_compare are new

See also​