Shiptest 13 - Modules - TypesDefine Details

# code/__DEFINES/maths.dm

DIGITS Returns the number of digits in a number. Only works on whole numbers. This is marginally faster than string interpolation -> length Gets shift x that would be required the bitflag (1<

## Define Details

### #define DIGITS (x)

Returns the number of digits in a number. Only works on whole numbers. This is marginally faster than string interpolation -> length

### #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 FORCE_BOOLEAN (x)

Make sure something is a boolean TRUE/FALSE 1/0 value, since things like bitfield & bitflag doesn't always give 1s and 0s.

### #define LOGISTIC_FUNCTION (L, k, x, x_0)

A function that exponentially approaches a maximum value of L k is the rate at which is approaches L, x_0 is the point where the function = 0

### #define MANHATTAN_DISTANCE (a, b)

Taxicab distance--gets you the actual time it takes to get from one turf to another due to how we calculate diagonal movement

### #define SPT_PROB (prob_per_second_percent, seconds_per_tick)

Like SPT_PROB_RATE but easier to use, simply put `if(SPT_PROB(10, 5))`

### #define SPT_PROB_RATE (prob_per_second, seconds_per_tick)

Converts a probability/second chance to probability/seconds_per_tick 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*SPT_PROB_RATE(0.1, 5)))`

### #define TILES_TO_PIXELS (tiles)

Gives the number of pixels in an orthogonal line of tiles.

### #define TOBITSHIFT (bit)

Gets shift x that would be required the bitflag (1<<x) We need the round because log has floating-point inaccuracy, and if we undershoot at all on list indexing we'll get the wrong index.