-
Notifications
You must be signed in to change notification settings - Fork 12
Math
Half-Life has a very limited number of entities to do math operations. They're game_counter
and game_counter_set
. These entities are very limited by themselves, and Featureful SDK provides more powerful ways to do math operations.
All entities have a calculable value associated with them - the concept borrowed from Spirit of Half-Life, where it's called Calc Ratio (see also: Locus system). While most entities have a constant zero value as Calc Ratio, there're few entities that actually implement this concept in Featureful SDK:
-
game_counter
- the Calc Ratio is the current counter value. Note thatgame_counter
holds integer values only. -
env_global
- since each global has an integer number associated with them in Featureful SDK, theenv_global
can be used to access this number. - Monsters. For them Calc Ratio is the health / max health fraction (the the number in [0..1] range).
- Wall rechargers (health and armor). For them Calc Ratio is the juice left / max juice capacity fraction (the the number in [0..1] range).
-
calc_ratio
- Calc Ratio is calculated based on Calc Ratio of another entity. -
calc_eval_number
- see calc_eval_number. -
game_number
- Calc Ratio is a stored floating point value. -
player_calc_ratio
- report some player related values like current health, armor and ammo.
Locus Ratio (or LR
for short) is a type of entity parameter. In FGD file they're marked with [LR]
suffix. LR
parameter can be either a constant number or a name of another entity. In the latter case the Calc Ratio result of another entity will be used as a number.
The entity that have LR
parameters can behave differently depending on their values.
Some examples of entities having LR
parameters:
-
trigger_push
- can have a speed factor calculable from another entity. -
env_shooter
- can have a speed factor calculable from another entity. -
calc_ratio
- calculates its own Calc Ratio depending onLR
parameter. - Vector related calc entities (e.g.
calc_subvelocity
) haveLR
parameter for factor. -
calc_eval_number
- see calc_eval_number. -
trigger_compare
- when triggered, compares calculated values of twoLR
parameters and fire the targets accordingly to result.
This entity calculates a result of binary operation on two LR
parameters.
calc_eval_number
can act as LR
parameter of another entity by itself. In this case the result of operation is used as Calc Ratio. The calc_eval_number
entity can be used as one of operands for another calc_eval_number
entity, allowing to do calculations on more than two operands.
When calc_eval_number
is triggered by something else it can store the result of operation in other entity (see below).
There're few entities that can act as value storage for the result of calc_eval_number
.
-
game_counter
- the stored value will be cast to integer. The counter may fire its target and reset if it hit the limit. -
game_number
- the stored value will be preserved as is. This entity just stores the value and it's expected to be accessed by other entities. -
env_global
withModify/Set value
trigger mode. The value will be cast to integer.