code/__DEFINES/maths.dm
SIGN | Gets the sign of x, returns -1 if negative, 0 if 0, 1 if positive |
---|---|
WRAP_UP | Increments a value and wraps it if it exceeds some value. Can be used to circularly iterate through a list through idx = WRAP_UP(idx, length_of_list) . |
TOBITSHIFT | Gets shift x that would be required the bitflag (1<<x) |
REVERSE_ANGLE | Reverse an angle. 45 -> 225, 0 -> 180, etc |
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)) |
DIAMOND_AREA | The number of cells in a taxicab circle (rasterized diamond) of radius X. |
MAPCLAMP | See above, but clamps the resulting value between omin and omax |
Define Details
DIAMOND_AREA
The number of cells in a taxicab circle (rasterized diamond) of radius X.
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)))
MAPCLAMP
See above, but clamps the resulting value between omin and omax
REVERSE_ANGLE
Reverse an angle. 45 -> 225, 0 -> 180, etc
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)
WRAP_UP
Increments a value and wraps it if it exceeds some value. Can be used to circularly iterate through a list through idx = WRAP_UP(idx, length_of_list)
.