mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2025-12-31 04:31:41 +00:00
* Make the cache room * adds alien cache machine * adds the cache properly * adds multitile component * adds terminal building and reward selection procs * adds laser receptacle file * Refactors ptl targetting code * more work on the ptl terminal * change file name to laser_terminal * changes area to powered makes laser terminal work properly * makes a new pickweight function because the old one is bad * Update alien_cache.dm * Update canister.dm * Update alien_cache.dm * adds a template of the ruin * adds some spawners to the reward pool * adjusts agent b amount * adjustments to loot table and changes to spawner comments * new placeholder sprite for the cache * randomizes reward spawn location and makes a PTL terminal sprite * updates alien cache sprite and examine proc * Adds overlays to the cache to indicate the current progress * fixes mob capsule spawner and laser terminal * Adds animations to PTL terminal * new box part of the sprite for the PTL terminal. Adds glow * fixes untargetting the PTL terminal and adds a little light overlay to the receiving dish * changes PTL terminal id generation slightly * adds simon says. incomplete * Update paradise.dme * simon says works now * adds more rhythms * Adds success and failure sounds * Makes the ptl terminal board printable * Update secure_alien_airlock.dm * undo changes to preferences.dm * undefs things * removes identical to parent vars * Update alien_cache_random_spawners.dm * replaces animation end loop flag so open dream CI doesn't give errors * changes centre platform colour and adds a fan to the entrance * more pads more sounds * better sprites * remove old sprite * adds the cache to example config * makes it not always spawn * Update simon_says_32x32.dmi * adds some flavor to the ruin * Update alien_cache_site.dmm * adds a signal to the ruin
263 lines
8.9 KiB
Plaintext
263 lines
8.9 KiB
Plaintext
#define NUM_E 2.71828183
|
|
#define PI 3.1415
|
|
#define SQRT_2 1.41421356237
|
|
#define INFINITY 1e31 //closer than enough
|
|
|
|
#define SHORT_REAL_LIMIT 16777216
|
|
|
|
//"fancy" math for calculating time in ms from tick_usage percentage and the length of ticks
|
|
//percent_of_tick_used * (ticklag * 100(to convert to ms)) / 100(percent ratio)
|
|
//collapsed to percent_of_tick_used * tick_lag
|
|
#define TICK_DELTA_TO_MS(percent_of_tick_used) ((percent_of_tick_used) * world.tick_lag)
|
|
#define TICK_USAGE_TO_MS(starting_tickusage) (TICK_DELTA_TO_MS(TICK_USAGE_REAL - starting_tickusage))
|
|
|
|
#define PERCENT(val) (round((val)*100, 0.1))
|
|
#define CLAMP01(x) (clamp(x, 0, 1))
|
|
|
|
//time of day but automatically adjusts to the server going into the next day within the same round.
|
|
//for when you need a reliable time number that doesn't depend on byond time.
|
|
#define REALTIMEOFDAY (world.timeofday + (MIDNIGHT_ROLLOVER * MIDNIGHT_ROLLOVER_CHECK))
|
|
#define MIDNIGHT_ROLLOVER_CHECK ( GLOB.rollovercheck_last_timeofday != world.timeofday ? update_midnight_rollover() : GLOB.midnight_rollovers )
|
|
|
|
#define SIMPLE_SIGN(X) ((X) < 0 ? -1 : 1)
|
|
|
|
#define SIGN(x) ( (x)!=0 ? (x) / abs(x) : 0 )
|
|
|
|
#define CEILING(x, y) ( -round(-(x) / (y)) * (y) )
|
|
|
|
// round() acts like floor(x, 1) by default but can't handle other values
|
|
#define FLOOR(x, y) ( round((x) / (y)) * (y) )
|
|
|
|
#define ROUND_UP(x) ( -round(-(x)))
|
|
|
|
// Similar to clamp but the bottom rolls around to the top and vice versa. min is inclusive, max is exclusive
|
|
#define WRAP(val, min, max) clamp(( min == max ? min : (val) - (round(((val) - (min))/((max) - (min))) * ((max) - (min))) ),min,max)
|
|
|
|
// Real modulus that handles decimals
|
|
#define MODULUS(x, y) ( (x) - (y) * round((x) / (y)) )
|
|
|
|
// Cotangent
|
|
#define COT(x) (1 / tan(x))
|
|
|
|
// Secant
|
|
#define SEC(x) (1 / cos(x))
|
|
|
|
// Cosecant
|
|
#define CSC(x) (1 / sin(x))
|
|
|
|
#define ATAN2(x, y) ( !(x) && !(y) ? 0 : (y) >= 0 ? arccos((x) / sqrt((x)*(x) + (y)*(y))) : -arccos((x) / sqrt((x)*(x) + (y)*(y))) )
|
|
|
|
#define HYPOTENUSE(Ax, Ay, Bx, By) (sqrt(((Ax) - (Bx))**2 + ((Ay) - (By))**2))
|
|
|
|
// Greatest Common Divisor - Euclid's algorithm
|
|
/proc/Gcd(a, b)
|
|
return b ? Gcd(b, (a) % (b)) : a
|
|
|
|
// Least Common Multiple
|
|
#define Lcm(a, b) (abs(a) / Gcd(a, b) * abs(b))
|
|
|
|
#define INVERSE(x) ( 1/(x) )
|
|
|
|
// Used for calculating the radioactive strength falloff
|
|
#define INVERSE_SQUARE(initial_strength,cur_distance,initial_distance) ( (initial_strength)*((initial_distance)**2/(cur_distance)**2) )
|
|
|
|
#define ISABOUTEQUAL(a, b, deviation) (deviation ? abs((a) - (b)) <= deviation : abs((a) - (b)) <= 0.1)
|
|
|
|
#define ISEVEN(x) (!((x) & 1))
|
|
|
|
#define ISODD(x) ((x) & 1)
|
|
|
|
// Returns true if val is from min to max, inclusive.
|
|
#define ISINRANGE(val, min, max) (min <= val && val <= max)
|
|
|
|
// Same as above, exclusive.
|
|
#define ISINRANGE_EX(val, min, max) (min < val && val < max)
|
|
|
|
#define ISINTEGER(x) (round(x) == x)
|
|
|
|
#define ISMULTIPLE(x, y) ((x) % (y) == 0)
|
|
|
|
// Performs a linear interpolation between a and b.
|
|
// Note that amount=0 returns a, amount=1 returns b, and
|
|
// amount=0.5 returns the mean of a and b.
|
|
#define LERP(a, b, amount) ( amount ? ((a) + ((b) - (a)) * (amount)) : a )
|
|
|
|
// Returns the nth root of x.
|
|
#define ROOT(n, x) ((x) ** (1 / (n)))
|
|
|
|
// The quadratic formula. Returns a list with the solutions, or an empty list
|
|
// if they are imaginary.
|
|
/proc/SolveQuadratic(a, b, c)
|
|
ASSERT(a)
|
|
. = list()
|
|
var/d = b*b - 4 * a * c
|
|
var/bottom = 2 * a
|
|
if(d < 0)
|
|
return
|
|
var/root = sqrt(d)
|
|
. += (-b + root) / bottom
|
|
if(!d)
|
|
return
|
|
. += (-b - root) / bottom
|
|
|
|
#define TODEGREES(radians) ((radians) * 57.2957795)
|
|
|
|
#define TORADIANS(degrees) ((degrees) * 0.0174532925)
|
|
|
|
// Will filter out extra rotations and negative rotations
|
|
// E.g: 540 becomes 180. -180 becomes 180.
|
|
#define SIMPLIFY_DEGREES(degrees) (MODULUS((degrees), 360))
|
|
|
|
#define GET_ANGLE_OF_INCIDENCE(face, input) (MODULUS((face) - (input), 360))
|
|
|
|
//Finds the shortest angle that angle A has to change to get to angle B. Aka, whether to move clock or counterclockwise.
|
|
/proc/closer_angle_difference(a, b)
|
|
if(!isnum(a) || !isnum(b))
|
|
return
|
|
a = SIMPLIFY_DEGREES(a)
|
|
b = SIMPLIFY_DEGREES(b)
|
|
var/inc = b - a
|
|
if(inc < 0)
|
|
inc += 360
|
|
var/dec = a - b
|
|
if(dec < 0)
|
|
dec += 360
|
|
. = inc > dec? -dec : inc
|
|
|
|
//A logarithm that converts an integer to a number scaled between 0 and 1.
|
|
//Currently, this is used for hydroponics-produce sprite transforming, but could be useful for other transform functions.
|
|
#define TRANSFORM_USING_VARIABLE(input, max) ( sin((90*(input))/(max))**2 )
|
|
|
|
/// 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 SPT_PROB_RATE(prob_per_second, seconds_per_tick) (1 - (1 - (prob_per_second)) ** (seconds_per_tick))
|
|
|
|
/// Like SPT_PROB_RATE but easier to use, simply put `if(SPT_PROB(10, 5))`
|
|
#define SPT_PROB(prob_per_second_percent, seconds_per_tick) (prob(100*SPT_PROB_RATE((prob_per_second_percent)/100, (seconds_per_tick))))
|
|
|
|
//converts a uniform distributed random number into a normal distributed one
|
|
//since this method produces two random numbers, one is saved for subsequent calls
|
|
//(making the cost negligble for every second call)
|
|
//This will return +/- decimals, situated about mean with standard deviation stddev
|
|
//68% chance that the number is within 1stddev
|
|
//95% chance that the number is within 2stddev
|
|
//98% chance that the number is within 3stddev...etc
|
|
#define ACCURACY 10000
|
|
/proc/gaussian(mean, stddev)
|
|
var/static/gaussian_next
|
|
var/R1;var/R2;var/working
|
|
if(gaussian_next != null)
|
|
R1 = gaussian_next
|
|
gaussian_next = null
|
|
else
|
|
do
|
|
R1 = rand(-ACCURACY,ACCURACY)/ACCURACY
|
|
R2 = rand(-ACCURACY,ACCURACY)/ACCURACY
|
|
working = R1*R1 + R2*R2
|
|
while(working >= 1 || working==0)
|
|
working = sqrt(-2 * log(working) / working)
|
|
R1 *= working
|
|
gaussian_next = R2 * working
|
|
return (mean + stddev * R1)
|
|
#undef ACCURACY
|
|
|
|
/proc/get_turf_in_angle(angle, turf/starting, increments)
|
|
var/pixel_x = 0
|
|
var/pixel_y = 0
|
|
for(var/i in 1 to increments)
|
|
pixel_x += sin(angle)+16*sin(angle)*2
|
|
pixel_y += cos(angle)+16*cos(angle)*2
|
|
var/new_x = starting.x
|
|
var/new_y = starting.y
|
|
while(pixel_x > 16)
|
|
pixel_x -= 32
|
|
new_x++
|
|
while(pixel_x < -16)
|
|
pixel_x += 32
|
|
new_x--
|
|
while(pixel_y > 16)
|
|
pixel_y -= 32
|
|
new_y++
|
|
while(pixel_y < -16)
|
|
pixel_y += 32
|
|
new_y--
|
|
new_x = clamp(new_x, 0, world.maxx)
|
|
new_y = clamp(new_y, 0, world.maxy)
|
|
return locate(new_x, new_y, starting.z)
|
|
|
|
// Returns a list where [1] is all x values and [2] is all y values that overlap between the given pair of rectangles
|
|
/proc/get_overlap(x1, y1, x2, y2, x3, y3, x4, y4)
|
|
var/list/region_x1 = list()
|
|
var/list/region_y1 = list()
|
|
var/list/region_x2 = list()
|
|
var/list/region_y2 = list()
|
|
|
|
// These loops create loops filled with x/y values that the boundaries inhabit
|
|
// ex: list(5, 6, 7, 8, 9)
|
|
for(var/i in min(x1, x2) to max(x1, x2))
|
|
region_x1["[i]"] = TRUE
|
|
for(var/i in min(y1, y2) to max(y1, y2))
|
|
region_y1["[i]"] = TRUE
|
|
for(var/i in min(x3, x4) to max(x3, x4))
|
|
region_x2["[i]"] = TRUE
|
|
for(var/i in min(y3, y4) to max(y3, y4))
|
|
region_y2["[i]"] = TRUE
|
|
|
|
return list(region_x1 & region_x2, region_y1 & region_y2)
|
|
|
|
#define EXP_DISTRIBUTION(desired_mean) ( -(1/(1/desired_mean)) * log(rand(1, 1000) * 0.001) )
|
|
|
|
#define LORENTZ_DISTRIBUTION(x, s) ( s*tan(TODEGREES(PI*(rand()-0.5))) + x )
|
|
#define LORENTZ_CUMULATIVE_DISTRIBUTION(x, y, s) ( (1/PI)*TORADIANS(arctan((x-y)/s)) + 1/2 )
|
|
#define RULE_OF_THREE(a, b, x) ((a*x)/b)
|
|
|
|
/// Returns probability based on deviation from the mean(m) and sigma(s)
|
|
#define normal_distribution(x, m, s) ((1 / ((2 * PI * s**2)**0.5)) * NUM_E ** -(((x - m) ** 2) / (2 * s ** 2)))
|
|
|
|
// )
|
|
|
|
/proc/RaiseToPower(num, power)
|
|
if(!power)
|
|
return 1
|
|
return (power-- > 1 ? num * RaiseToPower(num, power) : num)
|
|
|
|
// oof, what a mouthful
|
|
// Used in status_procs' "adjust" to let them modify a status effect by a given
|
|
// amount, without inadverdently increasing it in the wrong direction
|
|
/proc/directional_bounded_sum(orig_val, modifier, bound_lower, bound_upper)
|
|
var/new_val = orig_val + modifier
|
|
if(modifier > 0)
|
|
if(new_val > bound_upper)
|
|
new_val = max(orig_val, bound_upper)
|
|
else if(modifier < 0)
|
|
if(new_val < bound_lower)
|
|
new_val = min(orig_val, bound_lower)
|
|
return new_val
|
|
|
|
// sqrt, but if you give it a negative number, you get 0 instead of a runtime
|
|
/proc/sqrtor0(num)
|
|
if(num < 0)
|
|
return 0
|
|
return sqrt(num)
|
|
|
|
/proc/round_down(num)
|
|
if(round(num) != num)
|
|
return round(num--)
|
|
else
|
|
return num
|
|
|
|
/// Checks if a number is an integer, or a float
|
|
#define IS_INT(x) (x == round(x))
|
|
|
|
// Gives you the percent of two inputs
|
|
#define PERCENT_OF(val1, val2) (val1 * (val2 / 100))
|
|
|
|
///Returns an integer given a hex input, supports negative values "-ff". Skips preceding invalid characters.
|
|
#define hex2num(X) text2num(X, 16)
|
|
|
|
/// Returns the hex value of a decimal number. len == length of returned string.
|
|
#define num2hex(X, len) uppertext(num2text(X, len, 16))
|
|
|
|
/// Tests if the value is in the given range.
|
|
#define IS_IN_BOUNDS(val, lower, upper) ((val) >= (lower) && (val) <= (upper))
|