/tg/ Station 13 - Modules - TypesDefine Details

# code/__DEFINES/maths.dm SIGN Gets the sign of x, returns -1 if negative, 0 if 0, 1 if positive 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 Gets shift x that would be required the bitflag (1<

## Define Details

### #define DT_PROB (prob_per_second_percent, delta_time) Like DT_PROB_RATE but easier to use, simply put `if(DT_PROB(10, 5))`

### #define DT_PROB_RATE (prob_per_second, delta_time) 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)))`

### #define LPFILTER (memory, signal, delta_time, RC) 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

### #define SIGN (x) Gets the sign of x, returns -1 if negative, 0 if 0, 1 if positive

### #define TOBITSHIFT (bit) Gets shift x that would be required the bitflag (1<<x)