Implement powersink surge (#2452)

Implements suggestion https://forums.aurorastation.org/viewtopic.php?f=21&p=78011 in the following fashion:

Powersinks explode ~18 minutes after being placed on normal SMES setup. Obviously more input from engineering will make this process go faster.
Upon reaching their capacity, they will now cause a larger area power surge. The surge will smash all lights belonging to APCs within close to moderate proximity, and call EMP act on all connected powernet items that are within range (severity depending on distance). All of those items have a small chance to cause a minor explosion as well, primarily because EMP act is fucking whimpy.
This commit is contained in:
skull132
2017-05-27 12:25:47 +03:00
committed by GitHub
parent ad5c986093
commit 547e78d93c
5 changed files with 105 additions and 43 deletions

View File

@@ -1,6 +1,3 @@
// Macro functions.
#define RAND_F(LOW, HIGH) (rand()*(HIGH-LOW) + LOW)
// min is inclusive, max is exclusive
/proc/Wrap(val, min, max)
var/d = max - min
@@ -124,24 +121,14 @@
return sqrt(squaredNorm(x, y))
/proc/IsPowerOfTwo(var/val)
return (val & (val-1)) == 0
return (val & (val-1)) == 0
/proc/RoundUpToPowerOfTwo(var/val)
return 2 ** -round(-log(2,val))
//"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(world.tick_usage-starting_tickusage))
//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 ( rollovercheck_last_timeofday != world.timeofday ? update_midnight_rollover() : midnight_rollovers )
return 2 ** -round(-log(2,val))
//Returns the cube root of the input number
/proc/cubert(var/num, var/iterations = 10)
. = num
for (var/i = 0, i < iterations, i++)
. = (1/3) * (num/(.**2)+2*.)
. = num
for (var/i = 0, i < iterations, i++)
. = (1/3) * (num/(.**2)+2*.)