calc_ratio

A calc_ratio works out a number from another number and hands the result to the entity that asks for it. It can
change the number with a function such as 1 minus the number, the square or the sine, then add an offset, multiply it
and keep it inside a range.
Triggering it does nothing. Instead, you put its name in a key that takes a number, marked [LR] in the editor, and
each time that key needs a number, the calc_ratio works it out again at that moment. See the Locus
guide for more details and some setups.
Attributes
targetnameSets the name you put in another entity's number key so it reads this one. See Common keys.
targetSets the number to start from, a locus number, so it can be a number such as 5, a range such as 1..10 for a random number in it, or the name of an entity that gives a number. With *locus or !activator, it is the number of the entity that started the chain of triggers, which for a player or a monster is their health divided by their maximum health.
If you leave this key empty, it works like *locus.
*locusimpulsePicks a function that changes the number before the offset and the scale factor. The angles of the trigonometry functions are in degrees, and a result that isn't a number, such as 1 divided by 0 or the square root of a negative number, gives no number.The 13 choices
None (0)netnameAdds a locus number to the result after the transformation.
messageMultiplies the result by a locus number, after the transformation and the offset.
noiseSets the lowest result, a locus number. If outside range sets what happens to a result below it.
noise1Sets the highest result, a locus number. If outside range sets what happens to a result above it.
fragsSets what happens to a result outside Min and Max, when you set both of them. With only one of them set, a result past it always becomes that limit.
- Pick nearest value (0) - The result becomes the limit it went past
- Wrap around (1) - The result comes back in at the other end, so with Min 0 and Max 10, 12 becomes 2
- Bounce back (2) - The result bounces back off the limit it went past, so with Min 0 and Max 10, 12 becomes 8
Pick nearest value (0)base_cast_modeTurns the starting number into a whole number before the transformation.
- No cast (0) - The number stays as it is
- Round (1) - Rounds to the nearest whole number, so 2.5 becomes 3
- Floor (2) - Rounds down, so 2.7 becomes 2 and -2.3 becomes -3
- Ceil (3) - Rounds up, so 2.3 becomes 3
- Trunc (4) - Cuts off the part after the point, so 2.7 becomes 2 and -2.7 becomes -2
No cast (0)result_cast_modeTurns the result into a whole number at the end, after Min and Max.
- No cast (0) - The number stays as it is
- Round (1) - Rounds to the nearest whole number, so 2.5 becomes 3
- Floor (2) - Rounds down, so 2.7 becomes 2 and -2.3 becomes -3
- Ceil (3) - Rounds up, so 2.3 becomes 3
- Trunc (4) - Cuts off the part after the point, so 2.7 becomes 2 and -2.7 becomes -2
No cast (0)Notes
- A key that takes a position or a vector doesn't get the number. It gets the position of the
calc_ratioitself or a vector of 0 0 0, so usecalc_vecfromnumsto turn numbers into a vector - If any number it needs is missing, the
calc_ratiogives no number, so the entity that asked does nothing that time - Maps made with Spirit of Half-Life 1.8 may call this entity
calc_numfromnum, and SBO accepts that name too - You can change Min and Max with
trigger_changevalueortrigger_copyvaluewhile the map runs. See Changing keys
See also
- Locus guide - how entities pass positions and numbers to each other
- calc_ entities guide - setups that chain
calc_entities calc_eval_number- works out a number from two or three numberscalc_numfromvec- takes a number out of a vector, such as its lengthplayer_calc_ratio- gives a number about a player- Locus system - every locus rule, and the keys that take a number
Changes since 1.38
calc_ratiois new in SBO 2.0.0

