code/__DEFINES/maths.dm

SIGN | Gets the sign of x, returns -1 if negative, 0 if 0, 1 if positive |
---|---|
LPFILTER | Low-pass filter a value to smooth out high frequent peaks. This can be thought of as a moving average filter as well. delta_time is how many seconds since we last ran this command. RC is the filter constant, high RC means more smoothing See https://en.wikipedia.org/wiki/Low-pass_filter#Simple_infinite_impulse_response_filter for the maths |
TOBITSHIFT | Gets shift x that would be required the bitflag (1<<x) |
DT_PROB_RATE | Converts a probability/second chance to probability/delta_time chance
For example, if you want an event to happen with a 10% per second chance, but your proc only runs every 5 seconds, do if(prob(100*DT_PROB_RATE(0.1, 5))) |
DT_PROB | Like DT_PROB_RATE but easier to use, simply put if(DT_PROB(10, 5)) |
Define Details
DT_PROB
Like DT_PROB_RATE but easier to use, simply put if(DT_PROB(10, 5))
DT_PROB_RATE
Converts a probability/second chance to probability/delta_time chance
For example, if you want an event to happen with a 10% per second chance, but your proc only runs every 5 seconds, do if(prob(100*DT_PROB_RATE(0.1, 5)))
LPFILTER
Low-pass filter a value to smooth out high frequent peaks. This can be thought of as a moving average filter as well. delta_time is how many seconds since we last ran this command. RC is the filter constant, high RC means more smoothing See https://en.wikipedia.org/wiki/Low-pass_filter#Simple_infinite_impulse_response_filter for the maths
SIGN
Gets the sign of x, returns -1 if negative, 0 if 0, 1 if positive
TOBITSHIFT
Gets shift x that would be required the bitflag (1<<x)