Files
Paradise/code/__DEFINES/_math.html
T

3 lines
5.2 KiB
HTML

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><base href="../../"><link rel="stylesheet" href="dmdoc.css"><title>code/__DEFINES/_math.dm - Space Station 13</title></head><body><header><a href="index.html">Space Station 13</a> - <a href="index.html#modules">Modules</a> - <a href="index.html#types">Types</a><a href="code/__DEFINES/_math.html#define">Define Details</a></header><main><h1>code/__DEFINES/_math.dm <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/__DEFINES/_math.dm"><img src="git.png" width="16" height="16" title="code/__DEFINES/_math.dm"></a></h1><table class="summary" cellspacing="0"><tr><th><a href="code/__DEFINES/_math.html#define/SPT_PROB_RATE">SPT_PROB_RATE</a></th><td>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 <code>if(prob(100*SPT_PROB_RATE(0.1, 5)))</code></td></tr><tr><th><a href="code/__DEFINES/_math.html#define/SPT_PROB">SPT_PROB</a></th><td>Like SPT_PROB_RATE but easier to use, simply put <code>if(SPT_PROB(10, 5))</code></td></tr><tr><th><a href="code/__DEFINES/_math.html#define/normal_distribution">normal_distribution</a></th><td>Returns probability based on deviation from the mean(m) and sigma(s)</td></tr><tr><th><a href="code/__DEFINES/_math.html#define/IS_INT">IS_INT</a></th><td>Checks if a number is an integer, or a float</td></tr><tr><th><a href="code/__DEFINES/_math.html#define/hex2num">hex2num</a></th><td>Returns an integer given a hex input, supports negative values &quot;-ff&quot;. Skips preceding invalid characters.</td></tr><tr><th><a href="code/__DEFINES/_math.html#define/num2hex">num2hex</a></th><td>Returns the hex value of a decimal number. len == length of returned string.</td></tr><tr><th><a href="code/__DEFINES/_math.html#define/IS_IN_BOUNDS">IS_IN_BOUNDS</a></th><td>Tests if the value is in the given range.</td></tr></table><h2 id="define">Define Details</h2><h3 id="define/IS_INT"><aside class="declaration">#define </aside>IS_INT<aside>(x)</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/__DEFINES/_math.dm#L250"><img src="git.png" width="16" height="16" title="code/__DEFINES/_math.dm 250"></a></h3><p>Checks if a number is an integer, or a float</p><h3 id="define/IS_IN_BOUNDS"><aside class="declaration">#define </aside>IS_IN_BOUNDS<aside>(val, lower, upper)</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/__DEFINES/_math.dm#L262"><img src="git.png" width="16" height="16" title="code/__DEFINES/_math.dm 262"></a></h3><p>Tests if the value is in the given range.</p><h3 id="define/SPT_PROB"><aside class="declaration">#define </aside>SPT_PROB<aside>(prob_per_second_percent, seconds_per_tick)</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/__DEFINES/_math.dm#L136"><img src="git.png" width="16" height="16" title="code/__DEFINES/_math.dm 136"></a></h3><p>Like SPT_PROB_RATE but easier to use, simply put <code>if(SPT_PROB(10, 5))</code></p><h3 id="define/SPT_PROB_RATE"><aside class="declaration">#define </aside>SPT_PROB_RATE<aside>(prob_per_second, seconds_per_tick)</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/__DEFINES/_math.dm#L133"><img src="git.png" width="16" height="16" title="code/__DEFINES/_math.dm 133"></a></h3><p>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 <code>if(prob(100*SPT_PROB_RATE(0.1, 5)))</code></p><h3 id="define/hex2num"><aside class="declaration">#define </aside>hex2num<aside>(X)</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/__DEFINES/_math.dm#L256"><img src="git.png" width="16" height="16" title="code/__DEFINES/_math.dm 256"></a></h3><p>Returns an integer given a hex input, supports negative values &quot;-ff&quot;. Skips preceding invalid characters.</p><h3 id="define/normal_distribution"><aside class="declaration">#define </aside>normal_distribution<aside>(x, m, s)</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/__DEFINES/_math.dm#L215"><img src="git.png" width="16" height="16" title="code/__DEFINES/_math.dm 215"></a></h3><p>Returns probability based on deviation from the mean(m) and sigma(s)</p><h3 id="define/num2hex"><aside class="declaration">#define </aside>num2hex<aside>(X, len)</aside> <a href="https://github.com/ParadiseSS13/Paradise/blob/8a8a00a2a9bec485351e5f219982b7315d3504fa/code/__DEFINES/_math.dm#L259"><img src="git.png" width="16" height="16" title="code/__DEFINES/_math.dm 259"></a></h3><p>Returns the hex value of a decimal number. len == length of returned string.</p></main><footer>paradise.dme <a href="https://github.com/ParadiseSS13/Paradise/tree/8a8a00a2a9bec485351e5f219982b7315d3504fa">8a8a00a</a> (master) — <a href="https://github.com/SpaceManiac/SpacemanDMM/blob/master/crates/dmdoc/README.md">dmdoc 1.11.0</a></footer></body></html>