mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 02:34:00 +00:00
Makes math helpers defines for performance
This commit is contained in:
@@ -1,18 +1,228 @@
|
||||
// Credits to Nickr5 for the useful procs I've taken from his library resource.
|
||||
// This file is quadruple wrapped for your pleasure
|
||||
// (
|
||||
|
||||
#define NUM_E 2.71828183
|
||||
|
||||
#define M_PI (3.14159265)
|
||||
#define INFINITY (1.#INF) //closer then 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-starting_tickusage))
|
||||
#define TICK_USAGE_TO_MS(starting_tickusage) (TICK_DELTA_TO_MS(world.tick_usage - 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 ( rollovercheck_last_timeofday != world.timeofday ? update_midnight_rollover() : midnight_rollovers )
|
||||
|
||||
#define SHORT_REAL_LIMIT 16777216 // 2^24 - Maximum integer that can be exactly represented in a float (BYOND num var)
|
||||
#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) )
|
||||
// Check if a BYOND dir var is a cardinal direction (power of two)
|
||||
|
||||
#define CLAMP(CLVALUE,CLMIN,CLMAX) ( max( (CLMIN), min((CLVALUE), (CLMAX)) ) )
|
||||
|
||||
// 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) ( min == max ? min : (val) - (round(((val) - (min))/((max) - (min))) * ((max) - (min))) )
|
||||
|
||||
// Real modulus that handles decimals
|
||||
#define MODULUS(x, y) ( (x) - (y) * round((x) / (y)) )
|
||||
|
||||
// Tangent
|
||||
#define TAN(x) (sin(x) / cos(x))
|
||||
|
||||
// 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))) )
|
||||
|
||||
// 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 IS_CARDINAL(x) ((x & (x - 1)) == 0)
|
||||
|
||||
#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 % 2 == 0)
|
||||
|
||||
#define ISODD(x) (x % 2 != 0)
|
||||
|
||||
// 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)))
|
||||
|
||||
/proc/Mean(...)
|
||||
var/sum = 0
|
||||
for(var/val in args)
|
||||
sum += val
|
||||
return sum / args.len
|
||||
|
||||
// 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
|
||||
// Return if the roots are imaginary.
|
||||
if(d < 0)
|
||||
return
|
||||
var/root = sqrt(d)
|
||||
. += (-b + root) / bottom
|
||||
// If discriminant == 0, there would be two roots at the same position.
|
||||
if(!d)
|
||||
return
|
||||
. += (-b - root) / bottom
|
||||
|
||||
// 180 / Pi ~ 57.2957795
|
||||
#define TODEGREES(radians) ((radians) * 57.2957795)
|
||||
|
||||
// Pi / 180 ~ 0.0174532925
|
||||
#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 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 RAND_F(LOW, HIGH) (rand()*(HIGH-LOW) + LOW)
|
||||
|
||||
#define SQUARE(x) (x*x)
|
||||
|
||||
//Vector Algebra
|
||||
#define SQUAREDNORM(x, y) (x*x+y*y)
|
||||
#define NORM(x, y) (sqrt(SQUAREDNORM(x,y)))
|
||||
#define ISPOWEROFTWO(x) ((x & (x - 1)) == 0)
|
||||
#define ROUNDUPTOPOWEROFTWO(x) (2 ** -round(-log(2,x)))
|
||||
|
||||
#define DEFAULT(a, b) (a? a : b)
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
// Math constants.
|
||||
#define M_PI 3.14159265
|
||||
|
||||
#define R_IDEAL_GAS_EQUATION 8.31 // kPa*L/(K*mol).
|
||||
#define ONE_ATMOSPHERE 101.325 // kPa.
|
||||
#define IDEAL_GAS_ENTROPY_CONSTANT 1164 // (mol^3 * s^3) / (kg^3 * L).
|
||||
|
||||
#define T0C 273.15 // 0.0 degrees celcius
|
||||
#define T20C 293.15 // 20.0 degrees celcius
|
||||
#define TCMB 2.7 // -270.3 degrees celcius
|
||||
#define TN60C 213.15 // -60 degrees celcius
|
||||
|
||||
// Radiation constants.
|
||||
#define STEFAN_BOLTZMANN_CONSTANT 5.6704e-8 // W/(m^2*K^4).
|
||||
#define COSMIC_RADIATION_TEMPERATURE 3.15 // K.
|
||||
@@ -15,18 +18,7 @@
|
||||
#define RADIATOR_EXPOSED_SURFACE_AREA_RATIO 0.04 // (3 cm + 100 cm * sin(3deg))/(2*(3+100 cm)). Unitless ratio.
|
||||
#define HUMAN_EXPOSED_SURFACE_AREA 5.2 //m^2, surface area of 1.7m (H) x 0.46m (D) cylinder
|
||||
|
||||
#define T0C 273.15 // 0.0 degrees celcius
|
||||
#define T20C 293.15 // 20.0 degrees celcius
|
||||
#define TCMB 2.7 // -270.3 degrees celcius
|
||||
#define TN60C 213.15 // -60 degrees celcius
|
||||
|
||||
#define CLAMP01(x) max(0, min(1, x))
|
||||
#define QUANTIZE(variable) (round(variable,0.0001))
|
||||
|
||||
#define INFINITY 1.#INF
|
||||
|
||||
#define TICKS_IN_DAY 24*60*60*10
|
||||
#define TICKS_IN_SECOND 10
|
||||
|
||||
#define SIMPLE_SIGN(X) ((X) < 0 ? -1 : 1)
|
||||
#define SIGN(X) ((X) ? SIMPLE_SIGN(X) : 0)
|
||||
#define TICKS_IN_DAY (TICKS_IN_SECOND * 60 * 60 * 24)
|
||||
#define TICKS_IN_SECOND (world.fps)
|
||||
@@ -1,131 +0,0 @@
|
||||
// Macro functions.
|
||||
#define RAND_F(LOW, HIGH) (rand()*(HIGH-LOW) + LOW)
|
||||
#define ceil(x) (-round(-(x)))
|
||||
|
||||
// min is inclusive, max is exclusive
|
||||
/proc/Wrap(val, min, max)
|
||||
var/d = max - min
|
||||
var/t = Floor((val - min) / d)
|
||||
return val - (t * d)
|
||||
|
||||
/proc/Default(a, b)
|
||||
return a ? a : b
|
||||
|
||||
// Trigonometric functions.
|
||||
/proc/Tan(x)
|
||||
return sin(x) / cos(x)
|
||||
|
||||
/proc/Csc(x)
|
||||
return 1 / sin(x)
|
||||
|
||||
/proc/Sec(x)
|
||||
return 1 / cos(x)
|
||||
|
||||
/proc/Cot(x)
|
||||
return 1 / Tan(x)
|
||||
|
||||
/proc/Atan2(x, y)
|
||||
if(!x && !y) return 0
|
||||
var/a = arccos(x / sqrt(x*x + y*y))
|
||||
return y >= 0 ? a : -a
|
||||
|
||||
/proc/Floor(x)
|
||||
return round(x)
|
||||
|
||||
/proc/Ceiling(x)
|
||||
return -round(-x)
|
||||
|
||||
// Greatest Common Divisor: Euclid's algorithm.
|
||||
/proc/Gcd(a, b)
|
||||
while (1)
|
||||
if (!b) return a
|
||||
a %= b
|
||||
if (!a) return b
|
||||
b %= a
|
||||
|
||||
// Least Common Multiple. The formula is a consequence of: a*b = LCM*GCD.
|
||||
/proc/Lcm(a, b)
|
||||
return abs(a) * abs(b) / Gcd(a, b)
|
||||
|
||||
// Useful in the cases when x is a large expression, e.g. x = 3a/2 + b^2 + Function(c)
|
||||
/proc/Square(x)
|
||||
return x*x
|
||||
|
||||
/proc/Inverse(x)
|
||||
return 1 / x
|
||||
|
||||
// Condition checks.
|
||||
/proc/IsAboutEqual(a, b, delta = 0.1)
|
||||
return abs(a - b) <= delta
|
||||
|
||||
// Returns true if val is from min to max, inclusive.
|
||||
/proc/IsInRange(val, min, max)
|
||||
return (val >= min) && (val <= max)
|
||||
|
||||
/proc/IsInteger(x)
|
||||
return Floor(x) == x
|
||||
|
||||
/proc/IsMultiple(x, y)
|
||||
return x % y == 0
|
||||
|
||||
/proc/IsEven(x)
|
||||
return !(x & 0x1)
|
||||
|
||||
/proc/IsOdd(x)
|
||||
return (x & 0x1)
|
||||
|
||||
// Performs a linear interpolation between a and b.
|
||||
// Note: weight=0 returns a, weight=1 returns b, and weight=0.5 returns the mean of a and b.
|
||||
/proc/Interpolate(a, b, weight = 0.5)
|
||||
return a + (b - a) * weight // Equivalent to: a*(1 - weight) + b*weight
|
||||
|
||||
/proc/Mean(...)
|
||||
var/sum = 0
|
||||
for(var/val in args)
|
||||
sum += val
|
||||
return sum / args.len
|
||||
|
||||
// Returns the nth root of x.
|
||||
/proc/Root(n, x)
|
||||
return 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/discriminant = b*b - 4*a*c
|
||||
var/bottom = 2*a
|
||||
|
||||
// Return if the roots are imaginary.
|
||||
if(discriminant < 0)
|
||||
return
|
||||
|
||||
var/root = sqrt(discriminant)
|
||||
. += (-b + root) / bottom
|
||||
|
||||
// If discriminant == 0, there would be two roots at the same position.
|
||||
if(discriminant != 0)
|
||||
. += (-b - root) / bottom
|
||||
|
||||
/proc/ToDegrees(radians)
|
||||
// 180 / Pi ~ 57.2957795
|
||||
return radians * 57.2957795
|
||||
|
||||
/proc/ToRadians(degrees)
|
||||
// Pi / 180 ~ 0.0174532925
|
||||
return degrees * 0.0174532925
|
||||
|
||||
// Vector algebra.
|
||||
/proc/squaredNorm(x, y)
|
||||
return x*x + y*y
|
||||
|
||||
/proc/norm(x, y)
|
||||
return sqrt(squaredNorm(x, y))
|
||||
|
||||
/proc/IsPowerOfTwo(var/val)
|
||||
return (val & (val-1)) == 0
|
||||
|
||||
/proc/RoundUpToPowerOfTwo(var/val)
|
||||
return 2 ** -round(-log(2,val))
|
||||
@@ -78,13 +78,13 @@ return_location()
|
||||
return
|
||||
|
||||
// calculate the angle
|
||||
angle = Atan2(dx, dy) + angle_offset
|
||||
angle = ATAN2(dx, dy) + angle_offset
|
||||
|
||||
// and some rounding to stop the increments jumping whole turfs - because byond favours certain angles
|
||||
if(angle > -135 && angle < 45)
|
||||
angle = Ceiling(angle)
|
||||
angle = CEILING(angle, 1)
|
||||
else
|
||||
angle = Floor(angle)
|
||||
angle = FLOOR(angle, 1)
|
||||
|
||||
// calculate the offset per increment step
|
||||
if(abs(angle) in list(0, 45, 90, 135, 180)) // check if the angle is a cardinal
|
||||
@@ -93,11 +93,11 @@ return_location()
|
||||
if(abs(angle) in list(45, 90, 135))
|
||||
offset_y = sign(dy)
|
||||
else if(abs(dy) > abs(dx))
|
||||
offset_x = Cot(abs(angle)) // otherwise set the offsets
|
||||
offset_x = COT(abs(angle)) // otherwise set the offsets
|
||||
offset_y = sign(dy)
|
||||
else
|
||||
offset_x = sign(dx)
|
||||
offset_y = Tan(angle)
|
||||
offset_y = TAN(angle)
|
||||
if(dx < 0)
|
||||
offset_y = -offset_y
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@ var/global/image/appearance_bro = new() // Temporarily super-global because of B
|
||||
* Adds specific overlay(s) to the atom.
|
||||
* It is designed so any of the types allowed to be added to /atom/overlays can be added here too. More details below.
|
||||
*
|
||||
* @param overlays The overlay(s) to add. These may be
|
||||
* @param overlays The overlay(s) to add. These may be
|
||||
* - A string: In which case it is treated as an icon_state of the atom's icon.
|
||||
* - An icon: It is treated as an icon.
|
||||
* - An atom: Its own overlays are compiled and then it's appearance is added. (Meaning its current apperance is frozen).
|
||||
@@ -205,7 +205,7 @@ var/global/image/appearance_bro = new() // Temporarily super-global because of B
|
||||
/**
|
||||
* Copy the overlays from another atom, either replacing all of ours or appending to our existing overlays.
|
||||
* Note: This copies only the normal overlays, not the "priority" overlays.
|
||||
*
|
||||
*
|
||||
* @param other The atom to copy overlays from.
|
||||
* @param cut_old If true, all of our overlays will be *replaced* by the other's. If other is null, that means cutting all ours.
|
||||
*/
|
||||
|
||||
@@ -102,11 +102,11 @@
|
||||
//Position the effect so the beam is one continous line
|
||||
var/a
|
||||
if(abs(Pixel_x)>32)
|
||||
a = Pixel_x > 0 ? round(Pixel_x/32) : Ceiling(Pixel_x/32)
|
||||
a = Pixel_x > 0 ? round(Pixel_x/32) : CEILING(Pixel_x/32, 1)
|
||||
X.x += a
|
||||
Pixel_x %= 32
|
||||
if(abs(Pixel_y)>32)
|
||||
a = Pixel_y > 0 ? round(Pixel_y/32) : Ceiling(Pixel_y/32)
|
||||
a = Pixel_y > 0 ? round(Pixel_y/32) : CEILING(Pixel_y/32, 1)
|
||||
X.y += a
|
||||
Pixel_y %= 32
|
||||
|
||||
|
||||
@@ -287,7 +287,7 @@
|
||||
|
||||
/obj/machinery/organ_printer/robot/dismantle()
|
||||
if(stored_matter >= matter_amount_per_sheet)
|
||||
new /obj/item/stack/material/steel(get_turf(src), Floor(stored_matter/matter_amount_per_sheet))
|
||||
new /obj/item/stack/material/steel(get_turf(src), FLOOR(stored_matter/matter_amount_per_sheet, 1))
|
||||
return ..()
|
||||
|
||||
/obj/machinery/organ_printer/robot/print_organ(var/choice)
|
||||
@@ -305,7 +305,7 @@
|
||||
return
|
||||
var/obj/item/stack/S = W
|
||||
var/space_left = max_stored_matter - stored_matter
|
||||
var/sheets_to_take = min(S.amount, Floor(space_left/matter_amount_per_sheet))
|
||||
var/sheets_to_take = min(S.amount, FLOOR(space_left/matter_amount_per_sheet, 1))
|
||||
if(sheets_to_take <= 0)
|
||||
to_chat(user, "<span class='warning'>\The [src] is too full.</span>")
|
||||
return
|
||||
|
||||
@@ -194,7 +194,7 @@
|
||||
occupant.adjustCloneLoss(-2 * heal_rate)
|
||||
|
||||
//Premature clones may have brain damage.
|
||||
occupant.adjustBrainLoss(-(ceil(0.5*heal_rate)))
|
||||
occupant.adjustBrainLoss(-(CEILING(0.5*heal_rate, 1)))
|
||||
|
||||
//So clones don't die of oxyloss in a running pod.
|
||||
if(occupant.reagents.get_reagent_amount("inaprovaline") < 30)
|
||||
|
||||
@@ -151,7 +151,7 @@
|
||||
return
|
||||
|
||||
else if(istype(C, /obj/item/stack/material) && C.get_material_name() == "plasteel") // Repairing.
|
||||
var/amt = Ceiling((maxhealth - health)/150)
|
||||
var/amt = CEILING((maxhealth - health)/150, 1)
|
||||
if(!amt)
|
||||
to_chat(user, "<span class='notice'>\The [src] is already fully repaired.</span>")
|
||||
return
|
||||
|
||||
@@ -130,9 +130,9 @@
|
||||
|
||||
var/offset = 0
|
||||
var/points = round((radius * 2 * M_PI) / arcLength)
|
||||
var/angle = round(ToDegrees(arcLength / radius), 1)
|
||||
var/angle = round(TODEGREES(arcLength / radius), 1)
|
||||
|
||||
if(!IsInteger(radius))
|
||||
if(!ISINTEGER(radius))
|
||||
offset = 45 //degrees
|
||||
|
||||
for(var/j = 0, j < points, j++)
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
else
|
||||
new_overlays += "[initial(icon_state)]-powered"
|
||||
|
||||
var/ratio = Ceiling(bcell.percent()/25) * 25
|
||||
var/ratio = CEILING(bcell.percent()/25, 1) * 25
|
||||
new_overlays += "[initial(icon_state)]-charge[ratio]"
|
||||
else
|
||||
new_overlays += "[initial(icon_state)]-nocell"
|
||||
|
||||
@@ -101,6 +101,6 @@
|
||||
usr << "<span class='notice'>You are not adding enough telecrystals to fuel \the [src].</span>"
|
||||
return
|
||||
uses += T.amount/2 //Gives 5 uses per 10 TC
|
||||
uses = ceil(uses) //Ensures no decimal uses nonsense, rounds up to be nice
|
||||
uses = CEILING(uses, 1) //Ensures no decimal uses nonsense, rounds up to be nice
|
||||
usr << "<span class='notice'>You add \the [O] to \the [src]. Increasing the uses of \the [src] to [uses].</span>"
|
||||
qdel(O)
|
||||
@@ -1,3 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
#define WELDER_FUEL_BURN_INTERVAL 13
|
||||
/*
|
||||
* Welding Tool
|
||||
@@ -610,3 +611,609 @@
|
||||
toolspeed = 0.5
|
||||
|
||||
#undef WELDER_FUEL_BURN_INTERVAL
|
||||
=======
|
||||
#define WELDER_FUEL_BURN_INTERVAL 13
|
||||
/*
|
||||
* Welding Tool
|
||||
*/
|
||||
/obj/item/weapon/weldingtool
|
||||
name = "\improper welding tool"
|
||||
icon = 'icons/obj/tools.dmi'
|
||||
icon_state = "welder"
|
||||
item_state = "welder"
|
||||
flags = CONDUCT
|
||||
slot_flags = SLOT_BELT
|
||||
|
||||
//Amount of OUCH when it's thrown
|
||||
force = 3.0
|
||||
throwforce = 5.0
|
||||
throw_speed = 1
|
||||
throw_range = 5
|
||||
w_class = ITEMSIZE_SMALL
|
||||
|
||||
//Cost to make in the autolathe
|
||||
matter = list(DEFAULT_WALL_MATERIAL = 70, "glass" = 30)
|
||||
|
||||
//R&D tech level
|
||||
origin_tech = list(TECH_ENGINEERING = 1)
|
||||
|
||||
//Welding tool specific stuff
|
||||
var/welding = 0 //Whether or not the welding tool is off(0), on(1) or currently welding(2)
|
||||
var/status = 1 //Whether the welder is secured or unsecured (able to attach rods to it to make a flamethrower)
|
||||
var/max_fuel = 20 //The max amount of fuel the welder can hold
|
||||
|
||||
var/acti_sound = 'sound/items/welderactivate.ogg'
|
||||
var/deac_sound = 'sound/items/welderdeactivate.ogg'
|
||||
usesound = 'sound/items/Welder2.ogg'
|
||||
var/change_icons = TRUE
|
||||
var/flame_intensity = 2 //how powerful the emitted light is when used.
|
||||
var/flame_color = "#FF9933" // What color the welder light emits when its on. Default is an orange-ish color.
|
||||
var/eye_safety_modifier = 0 // Increasing this will make less eye protection needed to stop eye damage. IE at 1, sunglasses will fully protect.
|
||||
var/burned_fuel_for = 0 // Keeps track of how long the welder's been on, used to gradually empty the welder if left one, without RNG.
|
||||
var/always_process = FALSE // If true, keeps the welder on the process list even if it's off. Used for when it needs to regenerate fuel.
|
||||
toolspeed = 1
|
||||
|
||||
/obj/item/weapon/weldingtool/New()
|
||||
// var/random_fuel = min(rand(10,20),max_fuel)
|
||||
var/datum/reagents/R = new/datum/reagents(max_fuel)
|
||||
reagents = R
|
||||
R.my_atom = src
|
||||
R.add_reagent("fuel", max_fuel)
|
||||
update_icon()
|
||||
if(always_process)
|
||||
processing_objects |= src
|
||||
..()
|
||||
|
||||
/obj/item/weapon/weldingtool/Destroy()
|
||||
if(welding || always_process)
|
||||
processing_objects -= src
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/weldingtool/examine(mob/user)
|
||||
if(..(user, 0))
|
||||
if(max_fuel)
|
||||
to_chat(user, text("\icon[] The [] contains []/[] units of fuel!", src, src.name, get_fuel(),src.max_fuel ))
|
||||
|
||||
/obj/item/weapon/weldingtool/attack(var/atom/A, var/mob/living/user, var/def_zone)
|
||||
if(ishuman(A) && user.a_intent == I_HELP)
|
||||
var/mob/living/carbon/human/H = A
|
||||
var/obj/item/organ/external/S = H.organs_by_name[user.zone_sel.selecting]
|
||||
|
||||
if(!S || S.robotic < ORGAN_ROBOT || S.open == 3)
|
||||
return ..()
|
||||
|
||||
if(!welding)
|
||||
to_chat(user, "<span class='warning'>You'll need to turn [src] on to patch the damage on [H]'s [S.name]!</span>")
|
||||
return 1
|
||||
|
||||
if(S.robo_repair(15, BRUTE, "some dents", src, user))
|
||||
remove_fuel(1, user)
|
||||
return 1
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/weldingtool/attackby(obj/item/W as obj, mob/living/user as mob)
|
||||
if(istype(W,/obj/item/weapon/tool/screwdriver))
|
||||
if(welding)
|
||||
to_chat(user, "<span class='danger'>Stop welding first!</span>")
|
||||
return
|
||||
status = !status
|
||||
if(status)
|
||||
to_chat(user, "<span class='notice'>You secure the welder.</span>")
|
||||
else
|
||||
to_chat(user, "<span class='notice'>The welder can now be attached and modified.</span>")
|
||||
src.add_fingerprint(user)
|
||||
return
|
||||
|
||||
if((!status) && (istype(W,/obj/item/stack/rods)))
|
||||
var/obj/item/stack/rods/R = W
|
||||
R.use(1)
|
||||
var/obj/item/weapon/flamethrower/F = new/obj/item/weapon/flamethrower(user.loc)
|
||||
src.loc = F
|
||||
F.weldtool = src
|
||||
if (user.client)
|
||||
user.client.screen -= src
|
||||
if (user.r_hand == src)
|
||||
user.remove_from_mob(src)
|
||||
else
|
||||
user.remove_from_mob(src)
|
||||
src.master = F
|
||||
src.layer = initial(src.layer)
|
||||
user.remove_from_mob(src)
|
||||
if (user.client)
|
||||
user.client.screen -= src
|
||||
src.loc = F
|
||||
src.add_fingerprint(user)
|
||||
return
|
||||
|
||||
..()
|
||||
return
|
||||
|
||||
|
||||
/obj/item/weapon/weldingtool/process()
|
||||
if(welding)
|
||||
++burned_fuel_for
|
||||
if(burned_fuel_for >= WELDER_FUEL_BURN_INTERVAL)
|
||||
remove_fuel(1)
|
||||
if(get_fuel() < 1)
|
||||
setWelding(0)
|
||||
//I'm not sure what this does. I assume it has to do with starting fires...
|
||||
//...but it doesnt check to see if the welder is on or not.
|
||||
var/turf/location = src.loc
|
||||
if(istype(location, /mob/living))
|
||||
var/mob/living/M = location
|
||||
if(M.item_is_in_hands(src))
|
||||
location = get_turf(M)
|
||||
if (istype(location, /turf))
|
||||
location.hotspot_expose(700, 5)
|
||||
|
||||
/obj/item/weapon/weldingtool/afterattack(obj/O as obj, mob/user as mob, proximity)
|
||||
if(!proximity) return
|
||||
if (istype(O, /obj/structure/reagent_dispensers/fueltank) && get_dist(src,O) <= 1)
|
||||
if(!welding && max_fuel)
|
||||
O.reagents.trans_to_obj(src, max_fuel)
|
||||
to_chat(user, "<span class='notice'>Welder refueled</span>")
|
||||
playsound(src.loc, 'sound/effects/refill.ogg', 50, 1, -6)
|
||||
return
|
||||
else if(!welding)
|
||||
to_chat(user, "<span class='notice'>[src] doesn't use fuel.</span>")
|
||||
return
|
||||
else
|
||||
message_admins("[key_name_admin(user)] triggered a fueltank explosion with a welding tool.")
|
||||
log_game("[key_name(user)] triggered a fueltank explosion with a welding tool.")
|
||||
to_chat(user, "<span class='danger'>You begin welding on the fueltank and with a moment of lucidity you realize, this might not have been the smartest thing you've ever done.</span>")
|
||||
var/obj/structure/reagent_dispensers/fueltank/tank = O
|
||||
tank.explode()
|
||||
return
|
||||
if (src.welding)
|
||||
remove_fuel(1)
|
||||
var/turf/location = get_turf(user)
|
||||
if(isliving(O))
|
||||
var/mob/living/L = O
|
||||
L.IgniteMob()
|
||||
if (istype(location, /turf))
|
||||
location.hotspot_expose(700, 50, 1)
|
||||
|
||||
/obj/item/weapon/weldingtool/attack_self(mob/user as mob)
|
||||
setWelding(!welding, usr)
|
||||
|
||||
//Returns the amount of fuel in the welder
|
||||
/obj/item/weapon/weldingtool/proc/get_fuel()
|
||||
return reagents.get_reagent_amount("fuel")
|
||||
|
||||
/obj/item/weapon/weldingtool/proc/get_max_fuel()
|
||||
return max_fuel
|
||||
|
||||
//Removes fuel from the welding tool. If a mob is passed, it will perform an eyecheck on the mob. This should probably be renamed to use()
|
||||
/obj/item/weapon/weldingtool/proc/remove_fuel(var/amount = 1, var/mob/M = null)
|
||||
if(!welding)
|
||||
return 0
|
||||
if(amount)
|
||||
burned_fuel_for = 0 // Reset the counter since we're removing fuel.
|
||||
if(get_fuel() >= amount)
|
||||
reagents.remove_reagent("fuel", amount)
|
||||
if(M)
|
||||
eyecheck(M)
|
||||
update_icon()
|
||||
return 1
|
||||
else
|
||||
if(M)
|
||||
to_chat(M, "<span class='notice'>You need more welding fuel to complete this task.</span>")
|
||||
update_icon()
|
||||
return 0
|
||||
|
||||
//Returns whether or not the welding tool is currently on.
|
||||
/obj/item/weapon/weldingtool/proc/isOn()
|
||||
return welding
|
||||
|
||||
/obj/item/weapon/weldingtool/update_icon()
|
||||
..()
|
||||
overlays.Cut()
|
||||
// Welding overlay.
|
||||
if(welding)
|
||||
var/image/I = image(icon, src, "[icon_state]-on")
|
||||
overlays.Add(I)
|
||||
item_state = "[initial(item_state)]1"
|
||||
else
|
||||
item_state = initial(item_state)
|
||||
|
||||
// Fuel counter overlay.
|
||||
if(change_icons && get_max_fuel())
|
||||
var/ratio = get_fuel() / get_max_fuel()
|
||||
ratio = CEILING(ratio * 4, 1) * 25
|
||||
var/image/I = image(icon, src, "[icon_state][ratio]")
|
||||
overlays.Add(I)
|
||||
|
||||
// Lights
|
||||
if(welding && flame_intensity)
|
||||
set_light(flame_intensity, flame_intensity, flame_color)
|
||||
else
|
||||
set_light(0)
|
||||
|
||||
// icon_state = welding ? "[icon_state]1" : "[initial(icon_state)]"
|
||||
var/mob/M = loc
|
||||
if(istype(M))
|
||||
M.update_inv_l_hand()
|
||||
M.update_inv_r_hand()
|
||||
|
||||
/obj/item/weapon/weldingtool/MouseDrop(obj/over_object as obj)
|
||||
if(!canremove)
|
||||
return
|
||||
|
||||
if (ishuman(usr) || issmall(usr)) //so monkeys can take off their backpacks -- Urist
|
||||
|
||||
if (istype(usr.loc,/obj/mecha)) // stops inventory actions in a mech. why?
|
||||
return
|
||||
|
||||
if (!( istype(over_object, /obj/screen) ))
|
||||
return ..()
|
||||
|
||||
//makes sure that the thing is equipped, so that we can't drag it into our hand from miles away.
|
||||
//there's got to be a better way of doing this.
|
||||
if (!(src.loc == usr) || (src.loc && src.loc.loc == usr))
|
||||
return
|
||||
|
||||
if (( usr.restrained() ) || ( usr.stat ))
|
||||
return
|
||||
|
||||
if ((src.loc == usr) && !(istype(over_object, /obj/screen)) && !usr.unEquip(src))
|
||||
return
|
||||
|
||||
switch(over_object.name)
|
||||
if("r_hand")
|
||||
usr.u_equip(src)
|
||||
usr.put_in_r_hand(src)
|
||||
if("l_hand")
|
||||
usr.u_equip(src)
|
||||
usr.put_in_l_hand(src)
|
||||
src.add_fingerprint(usr)
|
||||
|
||||
//Sets the welding state of the welding tool. If you see W.welding = 1 anywhere, please change it to W.setWelding(1)
|
||||
//so that the welding tool updates accordingly
|
||||
/obj/item/weapon/weldingtool/proc/setWelding(var/set_welding, var/mob/M)
|
||||
if(!status) return
|
||||
|
||||
var/turf/T = get_turf(src)
|
||||
//If we're turning it on
|
||||
if(set_welding && !welding)
|
||||
if (get_fuel() > 0)
|
||||
if(M)
|
||||
to_chat(M, "<span class='notice'>You switch the [src] on.</span>")
|
||||
else if(T)
|
||||
T.visible_message("<span class='danger'>\The [src] turns on.</span>")
|
||||
playsound(loc, acti_sound, 50, 1)
|
||||
src.force = 15
|
||||
src.damtype = "fire"
|
||||
src.w_class = ITEMSIZE_LARGE
|
||||
src.hitsound = 'sound/items/welder.ogg'
|
||||
welding = 1
|
||||
update_icon()
|
||||
if(!always_process)
|
||||
processing_objects |= src
|
||||
else
|
||||
if(M)
|
||||
var/msg = max_fuel ? "welding fuel" : "charge"
|
||||
to_chat(M, "<span class='notice'>You need more [msg] to complete this task.</span>")
|
||||
return
|
||||
//Otherwise
|
||||
else if(!set_welding && welding)
|
||||
if(!always_process)
|
||||
processing_objects -= src
|
||||
if(M)
|
||||
to_chat(M, "<span class='notice'>You switch \the [src] off.</span>")
|
||||
else if(T)
|
||||
T.visible_message("<span class='warning'>\The [src] turns off.</span>")
|
||||
playsound(loc, deac_sound, 50, 1)
|
||||
src.force = 3
|
||||
src.damtype = "brute"
|
||||
src.w_class = initial(src.w_class)
|
||||
src.welding = 0
|
||||
src.hitsound = initial(src.hitsound)
|
||||
update_icon()
|
||||
|
||||
//Decides whether or not to damage a player's eyes based on what they're wearing as protection
|
||||
//Note: This should probably be moved to mob
|
||||
/obj/item/weapon/weldingtool/proc/eyecheck(mob/living/carbon/user)
|
||||
if(!istype(user))
|
||||
return 1
|
||||
var/safety = user.eyecheck()
|
||||
safety = between(-1, safety + eye_safety_modifier, 2)
|
||||
if(istype(user, /mob/living/carbon/human))
|
||||
var/mob/living/carbon/human/H = user
|
||||
var/obj/item/organ/internal/eyes/E = H.internal_organs_by_name[O_EYES]
|
||||
if(!E)
|
||||
return
|
||||
switch(safety)
|
||||
if(1)
|
||||
to_chat(usr, "<span class='warning'>Your eyes sting a little.</span>")
|
||||
E.damage += rand(1, 2)
|
||||
if(E.damage > 12)
|
||||
user.eye_blurry += rand(3,6)
|
||||
if(0)
|
||||
to_chat(usr, "<span class='warning'>Your eyes burn.</span>")
|
||||
E.damage += rand(2, 4)
|
||||
if(E.damage > 10)
|
||||
E.damage += rand(4,10)
|
||||
if(-1)
|
||||
to_chat(usr, "<span class='danger'>Your thermals intensify the welder's glow. Your eyes itch and burn severely.</span>")
|
||||
user.eye_blurry += rand(12,20)
|
||||
E.damage += rand(12, 16)
|
||||
if(safety<2)
|
||||
|
||||
if(E.damage > 10)
|
||||
to_chat(user, "<span class='warning'>Your eyes are really starting to hurt. This can't be good for you!</span>")
|
||||
|
||||
if (E.damage >= E.min_broken_damage)
|
||||
to_chat(user, "<span class='danger'>You go blind!</span>")
|
||||
user.sdisabilities |= BLIND
|
||||
else if (E.damage >= E.min_bruised_damage)
|
||||
to_chat(user, "<span class='danger'>You go blind!</span>")
|
||||
user.Blind(5)
|
||||
user.eye_blurry = 5
|
||||
user.disabilities |= NEARSIGHTED
|
||||
spawn(100)
|
||||
user.disabilities &= ~NEARSIGHTED
|
||||
return
|
||||
|
||||
/obj/item/weapon/weldingtool/is_hot()
|
||||
return isOn()
|
||||
|
||||
/obj/item/weapon/weldingtool/largetank
|
||||
name = "industrial welding tool"
|
||||
desc = "A slightly larger welder with a larger tank."
|
||||
icon_state = "indwelder"
|
||||
max_fuel = 40
|
||||
origin_tech = list(TECH_ENGINEERING = 2, TECH_PHORON = 2)
|
||||
matter = list(DEFAULT_WALL_MATERIAL = 70, "glass" = 60)
|
||||
|
||||
/obj/item/weapon/weldingtool/largetank/cyborg
|
||||
name = "integrated welding tool"
|
||||
desc = "An advanced welder designed to be used in robotic systems."
|
||||
toolspeed = 0.5
|
||||
|
||||
/obj/item/weapon/weldingtool/hugetank
|
||||
name = "upgraded welding tool"
|
||||
desc = "A much larger welder with a huge tank."
|
||||
icon_state = "indwelder"
|
||||
max_fuel = 80
|
||||
w_class = ITEMSIZE_NORMAL
|
||||
origin_tech = list(TECH_ENGINEERING = 3)
|
||||
matter = list(DEFAULT_WALL_MATERIAL = 70, "glass" = 120)
|
||||
|
||||
/obj/item/weapon/weldingtool/mini
|
||||
name = "emergency welding tool"
|
||||
desc = "A miniature welder used during emergencies."
|
||||
icon_state = "miniwelder"
|
||||
max_fuel = 10
|
||||
w_class = ITEMSIZE_SMALL
|
||||
matter = list(MAT_METAL = 30, MAT_GLASS = 10)
|
||||
change_icons = 0
|
||||
toolspeed = 2
|
||||
eye_safety_modifier = 1 // Safer on eyes.
|
||||
|
||||
/obj/item/weapon/weldingtool/alien
|
||||
name = "alien welding tool"
|
||||
desc = "An alien welding tool. Whatever fuel it uses, it never runs out."
|
||||
icon = 'icons/obj/abductor.dmi'
|
||||
icon_state = "welder"
|
||||
toolspeed = 0.1
|
||||
flame_color = "#6699FF" // Light bluish.
|
||||
eye_safety_modifier = 2
|
||||
change_icons = 0
|
||||
origin_tech = list(TECH_PHORON = 5 ,TECH_ENGINEERING = 5)
|
||||
always_process = TRUE
|
||||
|
||||
/obj/item/weapon/weldingtool/alien/process()
|
||||
if(get_fuel() <= get_max_fuel())
|
||||
reagents.add_reagent("fuel", 1)
|
||||
..()
|
||||
|
||||
/obj/item/weapon/weldingtool/experimental
|
||||
name = "experimental welding tool"
|
||||
desc = "An experimental welder capable of synthesizing its own fuel from waste compounds. It can output a flame hotter than regular welders."
|
||||
icon_state = "exwelder"
|
||||
max_fuel = 40
|
||||
w_class = ITEMSIZE_NORMAL
|
||||
origin_tech = list(TECH_ENGINEERING = 4, TECH_PHORON = 3)
|
||||
matter = list(DEFAULT_WALL_MATERIAL = 70, "glass" = 120)
|
||||
toolspeed = 0.5
|
||||
change_icons = 0
|
||||
flame_intensity = 3
|
||||
always_process = TRUE
|
||||
var/nextrefueltick = 0
|
||||
|
||||
/obj/item/weapon/weldingtool/experimental/process()
|
||||
..()
|
||||
if(get_fuel() < get_max_fuel() && nextrefueltick < world.time)
|
||||
nextrefueltick = world.time + 10
|
||||
reagents.add_reagent("fuel", 1)
|
||||
|
||||
/*
|
||||
* Backpack Welder.
|
||||
*/
|
||||
|
||||
/obj/item/weapon/weldingtool/tubefed
|
||||
name = "tube-fed welding tool"
|
||||
desc = "A bulky, cooler-burning welding tool that draws from a worn welding tank."
|
||||
icon_state = "tubewelder"
|
||||
max_fuel = 10
|
||||
w_class = ITEMSIZE_NO_CONTAINER
|
||||
matter = null
|
||||
toolspeed = 1.25
|
||||
change_icons = 0
|
||||
flame_intensity = 1
|
||||
eye_safety_modifier = 1
|
||||
always_process = TRUE
|
||||
var/obj/item/weapon/weldpack/mounted_pack = null
|
||||
|
||||
/obj/item/weapon/weldingtool/tubefed/New(location)
|
||||
..()
|
||||
if(istype(location, /obj/item/weapon/weldpack))
|
||||
var/obj/item/weapon/weldpack/holder = location
|
||||
mounted_pack = holder
|
||||
else
|
||||
qdel(src)
|
||||
|
||||
/obj/item/weapon/weldingtool/tubefed/Destroy()
|
||||
mounted_pack.nozzle = null
|
||||
mounted_pack = null
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/weldingtool/tubefed/process()
|
||||
if(mounted_pack)
|
||||
if(!istype(mounted_pack.loc,/mob/living/carbon/human))
|
||||
mounted_pack.return_nozzle()
|
||||
else
|
||||
var/mob/living/carbon/human/H = mounted_pack.loc
|
||||
if(H.back != mounted_pack)
|
||||
mounted_pack.return_nozzle()
|
||||
|
||||
if(mounted_pack.loc != src.loc && src.loc != mounted_pack)
|
||||
mounted_pack.return_nozzle()
|
||||
visible_message("<span class='notice'>\The [src] retracts to its fueltank.</span>")
|
||||
|
||||
if(get_fuel() <= get_max_fuel())
|
||||
mounted_pack.reagents.trans_to_obj(src, 1)
|
||||
|
||||
..()
|
||||
|
||||
/obj/item/weapon/weldingtool/tubefed/dropped(mob/user)
|
||||
..()
|
||||
if(src.loc != user)
|
||||
mounted_pack.return_nozzle()
|
||||
to_chat(user, "<span class='notice'>\The [src] retracts to its fueltank.</span>")
|
||||
|
||||
/*
|
||||
* Electric/Arc Welder
|
||||
*/
|
||||
|
||||
/obj/item/weapon/weldingtool/electric //AND HIS WELDING WAS ELECTRIC
|
||||
name = "electric welding tool"
|
||||
desc = "A welder which runs off of electricity."
|
||||
icon_state = "arcwelder"
|
||||
max_fuel = 0 //We'll handle the consumption later.
|
||||
item_state = "ewelder"
|
||||
var/obj/item/weapon/cell/power_supply //What type of power cell this uses
|
||||
var/charge_cost = 24 //The rough equivalent of 1 unit of fuel, based on us wanting 10 welds per battery
|
||||
var/cell_type = /obj/item/weapon/cell/device
|
||||
var/use_external_power = 0 //If in a borg or hardsuit, this needs to = 1
|
||||
flame_color = "#00CCFF" // Blue-ish, to set it apart from the gas flames.
|
||||
acti_sound = 'sound/effects/sparks4.ogg'
|
||||
deac_sound = 'sound/effects/sparks4.ogg'
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/unloaded/New()
|
||||
cell_type = null
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/New()
|
||||
..()
|
||||
if(cell_type == null)
|
||||
update_icon()
|
||||
else if(cell_type)
|
||||
power_supply = new cell_type(src)
|
||||
else
|
||||
power_supply = new /obj/item/weapon/cell/device(src)
|
||||
update_icon()
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/get_cell()
|
||||
return power_supply
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/examine(mob/user)
|
||||
if(get_dist(src, user) > 1)
|
||||
to_chat(user, desc)
|
||||
else // The << need to stay, for some reason
|
||||
if(power_supply)
|
||||
user << text("\icon[] The [] has [] charge left.", src, src.name, get_fuel())
|
||||
else
|
||||
user << text("\icon[] The [] has no power cell!", src, src.name)
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/get_fuel()
|
||||
if(use_external_power)
|
||||
var/obj/item/weapon/cell/external = get_external_power_supply()
|
||||
if(external)
|
||||
return external.charge
|
||||
else if(power_supply)
|
||||
return power_supply.charge
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/get_max_fuel()
|
||||
if(use_external_power)
|
||||
var/obj/item/weapon/cell/external = get_external_power_supply()
|
||||
if(external)
|
||||
return external.maxcharge
|
||||
else if(power_supply)
|
||||
return power_supply.maxcharge
|
||||
return 0
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/remove_fuel(var/amount = 1, var/mob/M = null)
|
||||
if(!welding)
|
||||
return 0
|
||||
if(get_fuel() >= amount)
|
||||
power_supply.checked_use(charge_cost)
|
||||
if(use_external_power)
|
||||
var/obj/item/weapon/cell/external = get_external_power_supply()
|
||||
if(!external || !external.use(charge_cost)) //Take power from the borg...
|
||||
power_supply.give(charge_cost) //Give it back to the cell.
|
||||
if(M)
|
||||
eyecheck(M)
|
||||
update_icon()
|
||||
return 1
|
||||
else
|
||||
if(M)
|
||||
to_chat(M, "<span class='notice'>You need more energy to complete this task.</span>")
|
||||
update_icon()
|
||||
return 0
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/attack_hand(mob/user as mob)
|
||||
if(user.get_inactive_hand() == src)
|
||||
if(power_supply)
|
||||
power_supply.update_icon()
|
||||
user.put_in_hands(power_supply)
|
||||
power_supply = null
|
||||
to_chat(user, "<span class='notice'>You remove the cell from the [src].</span>")
|
||||
setWelding(0)
|
||||
update_icon()
|
||||
return
|
||||
..()
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/attackby(obj/item/weapon/W, mob/user as mob)
|
||||
if(istype(W, /obj/item/weapon/cell))
|
||||
if(istype(W, /obj/item/weapon/cell/device))
|
||||
if(!power_supply)
|
||||
user.drop_item()
|
||||
W.loc = src
|
||||
power_supply = W
|
||||
to_chat(user, "<span class='notice'>You install a cell in \the [src].</span>")
|
||||
update_icon()
|
||||
else
|
||||
to_chat(user, "<span class='notice'>\The [src] already has a cell.</span>")
|
||||
else
|
||||
to_chat(user, "<span class='notice'>\The [src] cannot use that type of cell.</span>")
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/proc/get_external_power_supply()
|
||||
if(isrobot(src.loc))
|
||||
var/mob/living/silicon/robot/R = src.loc
|
||||
return R.cell
|
||||
if(istype(src.loc, /obj/item/rig_module))
|
||||
var/obj/item/rig_module/module = src.loc
|
||||
if(module.holder && module.holder.wearer)
|
||||
var/mob/living/carbon/human/H = module.holder.wearer
|
||||
if(istype(H) && H.back)
|
||||
var/obj/item/weapon/rig/suit = H.back
|
||||
if(istype(suit))
|
||||
return suit.cell
|
||||
return null
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/mounted
|
||||
use_external_power = 1
|
||||
|
||||
/obj/item/weapon/weldingtool/electric/mounted/cyborg
|
||||
toolspeed = 0.5
|
||||
|
||||
#undef WELDER_FUEL_BURN_INTERVAL
|
||||
|
||||
>>>>>>> 8da11c1... Makes math helpers defines for performance (#5654)
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
// adjust locker size to hold all items with 5 units of free store room
|
||||
var/content_size = 0
|
||||
for(I in src.contents)
|
||||
content_size += Ceiling(I.w_class/2)
|
||||
content_size += CEILING(I.w_class/2, 1)
|
||||
if(content_size > storage_capacity-5)
|
||||
storage_capacity = content_size + 5
|
||||
update_icon()
|
||||
@@ -57,7 +57,7 @@
|
||||
var/content_size = 0
|
||||
for(var/obj/item/I in src.contents)
|
||||
if(!I.anchored)
|
||||
content_size += Ceiling(I.w_class/2)
|
||||
content_size += CEILING(I.w_class/2, 1)
|
||||
if(!content_size)
|
||||
to_chat(user, "It is empty.")
|
||||
else if(storage_capacity > content_size*4)
|
||||
@@ -154,7 +154,7 @@
|
||||
/obj/structure/closet/proc/store_items(var/stored_units)
|
||||
var/added_units = 0
|
||||
for(var/obj/item/I in src.loc)
|
||||
var/item_size = Ceiling(I.w_class / 2)
|
||||
var/item_size = CEILING(I.w_class / 2, 1)
|
||||
if(stored_units + added_units + item_size > storage_capacity)
|
||||
continue
|
||||
if(!I.anchored)
|
||||
|
||||
@@ -458,7 +458,7 @@
|
||||
|
||||
// Damage overlays.
|
||||
var/ratio = health / maxhealth
|
||||
ratio = Ceiling(ratio * 4) * 25
|
||||
ratio = CEILING(ratio * 4, 1) * 25
|
||||
|
||||
if(ratio > 75)
|
||||
return
|
||||
|
||||
@@ -239,7 +239,7 @@ proc/admin_notice(var/message, var/rights)
|
||||
|
||||
// Display the notes on the current page
|
||||
var/number_pages = note_keys.len / PLAYER_NOTES_ENTRIES_PER_PAGE
|
||||
// Emulate ceil(why does BYOND not have ceil)
|
||||
// Emulate CEILING(why does BYOND not have ceil, 1)
|
||||
if(number_pages != round(number_pages))
|
||||
number_pages = round(number_pages) + 1
|
||||
var/page_index = page - 1
|
||||
|
||||
@@ -546,7 +546,7 @@
|
||||
|
||||
data["charge"] = cell ? round(cell.charge,1) : 0
|
||||
data["maxcharge"] = cell ? cell.maxcharge : 0
|
||||
data["chargestatus"] = cell ? Floor((cell.charge/cell.maxcharge)*50) : 0
|
||||
data["chargestatus"] = cell ? FLOOR((cell.charge/cell.maxcharge)*50, 1) : 0
|
||||
|
||||
data["emagged"] = subverted
|
||||
data["coverlock"] = locked
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
kill()
|
||||
return
|
||||
|
||||
if(IsMultiple(activeFor, 5))
|
||||
if(ISMULTIPLE(activeFor, 5))
|
||||
if(prob(15))
|
||||
var/obj/machinery/vending/infectedMachine = pick(vendingMachines)
|
||||
vendingMachines.Remove(infectedMachine)
|
||||
@@ -58,8 +58,12 @@
|
||||
infectedMachine.shut_up = 0
|
||||
infectedMachine.shoot_inventory = 1
|
||||
|
||||
<<<<<<< HEAD
|
||||
if(IsMultiple(activeFor, 12))
|
||||
/* VORESTATION Removal - Using the pick below.
|
||||
=======
|
||||
if(ISMULTIPLE(activeFor, 12))
|
||||
>>>>>>> 8da11c1... Makes math helpers defines for performance (#5654)
|
||||
originMachine.speak(pick("Try our aggressive new marketing strategies!", \
|
||||
"You should buy products to feed your lifestyle obsession!", \
|
||||
"Consume!", \
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
cooking_obj = null
|
||||
else
|
||||
var/failed
|
||||
var/overcook_period = max(Floor(cook_time/5),1)
|
||||
var/overcook_period = max(FLOOR(cook_time/5, 1),1)
|
||||
cooking_obj = result
|
||||
var/count = overcook_period
|
||||
while(1)
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
var/activeness = ((metric.assess_department(ROLE_SECURITY) + metric.assess_department(ROLE_ENGINEERING) + metric.assess_department(ROLE_MEDICAL)) / 3)
|
||||
activeness = max(activeness, 20)
|
||||
|
||||
carp_amount = Ceiling(station_strength * (activeness / 100) + 1)
|
||||
carp_amount = CEILING(station_strength * (activeness / 100) + 1, 1)
|
||||
|
||||
/datum/gm_action/carp_migration/start()
|
||||
..()
|
||||
|
||||
@@ -413,7 +413,7 @@
|
||||
overlays += I
|
||||
return
|
||||
|
||||
var/offset = Floor(20/cards.len)
|
||||
var/offset = FLOOR(20/cards.len, 1)
|
||||
|
||||
var/matrix/M = matrix()
|
||||
if(direction)
|
||||
|
||||
@@ -265,7 +265,7 @@
|
||||
pull_data()
|
||||
var/incoming = get_pin_data(IC_INPUT, 1)
|
||||
if(!isnull(incoming))
|
||||
result = ToDegrees(incoming)
|
||||
result = TODEGREES(incoming)
|
||||
|
||||
set_pin_data(IC_OUTPUT, 1, result)
|
||||
push_data()
|
||||
@@ -283,7 +283,7 @@
|
||||
pull_data()
|
||||
var/incoming = get_pin_data(IC_INPUT, 1)
|
||||
if(!isnull(incoming))
|
||||
result = ToRadians(incoming)
|
||||
result = TORADIANS(incoming)
|
||||
|
||||
set_pin_data(IC_OUTPUT, 1, result)
|
||||
push_data()
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
var/result = null
|
||||
var/A = get_pin_data(IC_INPUT, 1)
|
||||
if(!isnull(A))
|
||||
result = Tan(A)
|
||||
result = TAN(A)
|
||||
|
||||
set_pin_data(IC_OUTPUT, 1, result)
|
||||
push_data()
|
||||
@@ -91,7 +91,7 @@
|
||||
var/result = null
|
||||
var/A = get_pin_data(IC_INPUT, 1)
|
||||
if(!isnull(A))
|
||||
result = Csc(A)
|
||||
result = CSC(A)
|
||||
|
||||
set_pin_data(IC_OUTPUT, 1, result)
|
||||
push_data()
|
||||
@@ -112,7 +112,7 @@
|
||||
var/result = null
|
||||
var/A = get_pin_data(IC_INPUT, 1)
|
||||
if(!isnull(A))
|
||||
result = Sec(A)
|
||||
result = SEC(A)
|
||||
|
||||
set_pin_data(IC_OUTPUT, 1, result)
|
||||
push_data()
|
||||
@@ -133,7 +133,7 @@
|
||||
var/result = null
|
||||
var/A = get_pin_data(IC_INPUT, 1)
|
||||
if(!isnull(A))
|
||||
result = Cot(A)
|
||||
result = COT(A)
|
||||
|
||||
set_pin_data(IC_OUTPUT, 1, result)
|
||||
push_data()
|
||||
|
||||
@@ -202,7 +202,7 @@ var/list/mining_overlay_cache = list()
|
||||
if(severity <= 2) // Now to expose the ore lying under the sand.
|
||||
spawn(1) // Otherwise most of the ore is lost to the explosion, which makes this rather moot.
|
||||
for(var/ore in resources)
|
||||
var/amount_to_give = rand(Ceiling(resources[ore]/2), resources[ore]) // Should result in at least one piece of ore.
|
||||
var/amount_to_give = rand(CEILING(resources[ore]/2, 1), resources[ore]) // Should result in at least one piece of ore.
|
||||
for(var/i=1, i <= amount_to_give, i++)
|
||||
var/oretype = ore_types[ore]
|
||||
new oretype(src)
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
for(var/i = 0;i<name_count;i++)
|
||||
new_name = ""
|
||||
for(var/x = rand(Floor(syllable_count/syllable_divisor),syllable_count);x>0;x--)
|
||||
for(var/x = rand(FLOOR(syllable_count/syllable_divisor, 1),syllable_count);x>0;x--)
|
||||
new_name += pick(syllables)
|
||||
full_name += " [capitalize(lowertext(new_name))]"
|
||||
|
||||
|
||||
@@ -364,7 +364,7 @@
|
||||
stop_pulling()
|
||||
src << "<span class='warning'>You slipped on [slipped_on]!</span>"
|
||||
playsound(src.loc, 'sound/misc/slip.ogg', 50, 1, -3)
|
||||
Weaken(Floor(stun_duration/2))
|
||||
Weaken(FLOOR(stun_duration/2, 1))
|
||||
return 1
|
||||
|
||||
/mob/living/carbon/proc/add_chemical_effect(var/effect, var/magnitude = 1)
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
chargen_value_descriptors = list()
|
||||
for(var/i = 1 to LAZYLEN(standalone_value_descriptors))
|
||||
chargen_value_descriptors[standalone_value_descriptors[i]] = i
|
||||
default_value = ceil(LAZYLEN(standalone_value_descriptors) * 0.5)
|
||||
default_value = CEILING(LAZYLEN(standalone_value_descriptors) * 0.5, 1)
|
||||
..()
|
||||
|
||||
/datum/mob_descriptor/proc/get_third_person_message_start(var/datum/gender/my_gender)
|
||||
@@ -99,10 +99,10 @@
|
||||
|
||||
/datum/mob_descriptor/proc/get_comparative_value_string_smaller(var/value, var/datum/gender/my_gender, var/datum/gender/other_gender)
|
||||
var/maxval = LAZYLEN(comparative_value_descriptors_smaller)
|
||||
value = Clamp(ceil(value * maxval), 1, maxval)
|
||||
value = Clamp(CEILING(value * maxval, 1), 1, maxval)
|
||||
return comparative_value_descriptors_smaller[value]
|
||||
|
||||
/datum/mob_descriptor/proc/get_comparative_value_string_larger(var/value, var/datum/gender/my_gender, var/datum/gender/other_gender)
|
||||
var/maxval = LAZYLEN(comparative_value_descriptors_larger)
|
||||
value = Clamp(ceil(value * maxval), 1, maxval)
|
||||
value = Clamp(CEILING(value * maxval, 1), 1, maxval)
|
||||
return comparative_value_descriptors_larger[value]
|
||||
|
||||
@@ -165,4 +165,4 @@
|
||||
else
|
||||
src << "<span class='notice'>I am not ready to reproduce yet...</span>"
|
||||
else
|
||||
src << "<span class='notice'>I am not old enough to reproduce yet...</span>"
|
||||
src << "<span class='notice'>I am not old enough to reproduce yet...</span>"
|
||||
|
||||
@@ -681,7 +681,7 @@
|
||||
|
||||
//Robots take half damage from basic attacks.
|
||||
/mob/living/silicon/robot/attack_generic(var/mob/user, var/damage, var/attack_message)
|
||||
return ..(user,Floor(damage/2),attack_message)
|
||||
return ..(user,FLOOR(damage/2, 1),attack_message)
|
||||
|
||||
/mob/living/silicon/robot/proc/allowed(mob/M)
|
||||
//check if it doesn't require any access at all
|
||||
|
||||
@@ -197,9 +197,9 @@ Nurse Family
|
||||
for(var/I = 1 to spiderling_count)
|
||||
if(prob(10) && src)
|
||||
var/mob/living/simple_animal/hostile/giant_spider/swarmling = new swarmling_type(src.loc)
|
||||
var/swarm_health = Floor(swarmling.maxHealth * 0.4)
|
||||
var/swarm_dam_lower = Floor(melee_damage_lower * 0.4)
|
||||
var/swarm_dam_upper = Floor(melee_damage_upper * 0.4)
|
||||
var/swarm_health = FLOOR(swarmling.maxHealth * 0.4, 1)
|
||||
var/swarm_dam_lower = FLOOR(melee_damage_lower * 0.4, 1)
|
||||
var/swarm_dam_upper = FLOOR(melee_damage_upper * 0.4, 1)
|
||||
swarmling.name = "spiderling"
|
||||
swarmling.maxHealth = swarm_health
|
||||
swarmling.health = swarm_health
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// Carriers are not too dangerous on their own, but they create more spiders when dying.
|
||||
|
||||
/mob/living/simple_mob/animal/giant_spider/carrier
|
||||
desc = "Furry, beige, and red, it makes you shudder to look at it. This one has luminous green eyes."
|
||||
icon_state = "carrier"
|
||||
icon_living = "carrier"
|
||||
icon_dead = "carrier_dead"
|
||||
|
||||
maxHealth = 100
|
||||
health = 100
|
||||
|
||||
melee_damage_lower = 8
|
||||
melee_damage_upper = 25
|
||||
|
||||
poison_per_bite = 3
|
||||
poison_type = "chloralhydrate"
|
||||
|
||||
movement_cooldown = 5
|
||||
|
||||
player_msg = "Upon dying, you will release a swarm of spiderlings or young hunter spiders.<br>\
|
||||
If a spider emerges, you will be placed in control of it."
|
||||
|
||||
var/spiderling_count = 0
|
||||
var/spiderling_type = /obj/effect/spider/spiderling
|
||||
var/swarmling_type = /mob/living/simple_mob/animal/giant_spider/hunter
|
||||
var/swarmling_faction = "spiders"
|
||||
var/swarmling_prob = 10 // Odds that a spiderling will be a swarmling instead.
|
||||
|
||||
/mob/living/simple_mob/animal/giant_spider/carrier/initialize()
|
||||
spiderling_count = rand(5, 10)
|
||||
adjust_scale(1.2)
|
||||
return ..()
|
||||
|
||||
/mob/living/simple_mob/animal/giant_spider/carrier/death()
|
||||
visible_message(span("warning", "\The [src]'s abdomen splits as it rolls over, spiderlings crawling from the wound.") )
|
||||
spawn(1)
|
||||
var/list/new_spiders = list()
|
||||
for(var/i = 1 to spiderling_count)
|
||||
if(prob(swarmling_prob) && src)
|
||||
var/mob/living/simple_mob/animal/giant_spider/swarmling = new swarmling_type(src.loc)
|
||||
var/swarm_health = FLOOR(swarmling.maxHealth * 0.4, 1)
|
||||
var/swarm_dam_lower = FLOOR(melee_damage_lower * 0.4, 1)
|
||||
var/swarm_dam_upper = FLOOR(melee_damage_upper * 0.4, 1)
|
||||
swarmling.name = "spiderling"
|
||||
swarmling.maxHealth = swarm_health
|
||||
swarmling.health = swarm_health
|
||||
swarmling.melee_damage_lower = swarm_dam_lower
|
||||
swarmling.melee_damage_upper = swarm_dam_upper
|
||||
swarmling.faction = swarmling_faction
|
||||
swarmling.adjust_scale(0.75)
|
||||
new_spiders += swarmling
|
||||
else if(src)
|
||||
var/obj/effect/spider/spiderling/child = new spiderling_type(src.loc)
|
||||
child.skitter()
|
||||
else // We might've gibbed or got deleted.
|
||||
break
|
||||
// Transfer our player to their new body, if RNG provided one.
|
||||
if(new_spiders.len && client)
|
||||
var/mob/living/simple_mob/animal/giant_spider/new_body = pick(new_spiders)
|
||||
new_body.key = src.key
|
||||
return ..()
|
||||
|
||||
/mob/living/simple_mob/animal/giant_spider/carrier/recursive
|
||||
desc = "Furry, beige, and red, it makes you shudder to look at it. This one has luminous green eyes. \
|
||||
You have a distinctly <font face='comic sans ms'>bad</font> feeling about this."
|
||||
|
||||
swarmling_type = /mob/living/simple_mob/animal/giant_spider/carrier/recursive
|
||||
@@ -289,5 +289,5 @@ var/list/robot_hud_colours = list("#CFCFCF","#AFAFAF","#8F8F8F","#6F6F6F","#4F4F
|
||||
dam_state = min_dam_state
|
||||
// Apply colour and return product.
|
||||
var/list/hud_colours = (robotic < ORGAN_ROBOT) ? flesh_hud_colours : robot_hud_colours
|
||||
hud_damage_image.color = hud_colours[max(1,min(ceil(dam_state*hud_colours.len),hud_colours.len))]
|
||||
hud_damage_image.color = hud_colours[max(1,min(CEILING(dam_state*hud_colours.len, 1),hud_colours.len))]
|
||||
return hud_damage_image
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
else
|
||||
icon_state = "shredder-off"
|
||||
// Fullness overlay
|
||||
overlays += "shredder-[max(0,min(5,Floor(paperamount/max_paper*5)))]"
|
||||
overlays += "shredder-[max(0,min(5,FLOOR(paperamount/max_paper*5, 1)))]"
|
||||
if (panel_open)
|
||||
overlays += "panel_open"
|
||||
|
||||
|
||||
@@ -70,12 +70,12 @@ var/datum/planet/sif/planet_sif = null
|
||||
high_color = "#FFFFFF"
|
||||
min = 0.70
|
||||
|
||||
var/lerp_weight = (abs(min - sun_position)) * 4
|
||||
var/interpolate_weight = (abs(min - sun_position)) * 4
|
||||
var/weather_light_modifier = 1
|
||||
if(weather_holder && weather_holder.current_weather)
|
||||
weather_light_modifier = weather_holder.current_weather.light_modifier
|
||||
|
||||
var/new_brightness = (Interpolate(low_brightness, high_brightness, weight = lerp_weight) ) * weather_light_modifier
|
||||
var/new_brightness = (LERP(low_brightness, high_brightness, interpolate_weight) ) * weather_light_modifier
|
||||
|
||||
var/new_color = null
|
||||
if(weather_holder && weather_holder.current_weather && weather_holder.current_weather.light_color)
|
||||
@@ -91,9 +91,9 @@ var/datum/planet/sif/planet_sif = null
|
||||
var/high_g = high_color_list[2]
|
||||
var/high_b = high_color_list[3]
|
||||
|
||||
var/new_r = Interpolate(low_r, high_r, weight = lerp_weight)
|
||||
var/new_g = Interpolate(low_g, high_g, weight = lerp_weight)
|
||||
var/new_b = Interpolate(low_b, high_b, weight = lerp_weight)
|
||||
var/new_r = LERP(low_r, high_r, interpolate_weight)
|
||||
var/new_g = LERP(low_g, high_g, interpolate_weight)
|
||||
var/new_b = LERP(low_b, high_b, interpolate_weight)
|
||||
|
||||
new_color = rgb(new_r, new_g, new_b)
|
||||
|
||||
|
||||
@@ -54,15 +54,15 @@
|
||||
var/seconds = remaining_hour % seconds_in_minute / 10
|
||||
|
||||
|
||||
var/hour_text = num2text(Floor(hours))
|
||||
var/hour_text = num2text(FLOOR(hours, 1))
|
||||
if(length(hour_text) < 2)
|
||||
hour_text = "0[hour_text]" // Add padding if needed, to look more like time2text().
|
||||
|
||||
var/minute_text = num2text(Floor(minutes))
|
||||
var/minute_text = num2text(FLOOR(minutes, 1))
|
||||
if(length(minute_text) < 2)
|
||||
minute_text = "0[minute_text]"
|
||||
|
||||
var/second_text = num2text(Floor(seconds))
|
||||
var/second_text = num2text(FLOOR(seconds, 1))
|
||||
if(length(second_text) < 2)
|
||||
second_text = "0[second_text]"
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
visuals.icon_state = current_weather.icon_state
|
||||
|
||||
/datum/weather_holder/proc/update_temperature()
|
||||
temperature = Interpolate(current_weather.temp_low, current_weather.temp_high, weight = our_planet.sun_position)
|
||||
temperature = LERP(current_weather.temp_low, current_weather.temp_high, our_planet.sun_position)
|
||||
our_planet.needs_work |= PLANET_PROCESS_TEMP
|
||||
|
||||
/datum/weather_holder/proc/get_weather_datum(desired_type)
|
||||
|
||||
@@ -532,7 +532,7 @@ obj/structure/cable/proc/cableColor(var/colorC)
|
||||
if(!S || S.robotic < ORGAN_ROBOT || S.open == 3)
|
||||
return ..()
|
||||
|
||||
var/use_amt = min(src.amount, ceil(S.burn_dam/5), 5)
|
||||
var/use_amt = min(src.amount, CEILING(S.burn_dam/5, 1), 5)
|
||||
if(can_use(use_amt))
|
||||
if(S.robo_repair(5*use_amt, BURN, "some damaged wiring", src, user))
|
||||
src.use(use_amt)
|
||||
|
||||
@@ -171,8 +171,8 @@
|
||||
use_power = light_max_power
|
||||
else
|
||||
var/temp_mod = ((plasma_temperature-5000)/20000)
|
||||
use_range = light_min_range + ceil((light_max_range-light_min_range)*temp_mod)
|
||||
use_power = light_min_power + ceil((light_max_power-light_min_power)*temp_mod)
|
||||
use_range = light_min_range + CEILING((light_max_range-light_min_range)*temp_mod, 1)
|
||||
use_power = light_min_power + CEILING((light_max_power-light_min_power)*temp_mod, 1)
|
||||
|
||||
if(last_range != use_range || last_power != use_power)
|
||||
set_light(use_range,use_power)
|
||||
@@ -318,8 +318,8 @@
|
||||
|
||||
/obj/effect/fusion_em_field/proc/Radiate()
|
||||
if(istype(loc, /turf))
|
||||
var/empsev = max(1, min(3, ceil(size/2)))
|
||||
for(var/atom/movable/AM in range(max(1,Floor(size/2)), loc))
|
||||
var/empsev = max(1, min(3, CEILING(size/2, 1)))
|
||||
for(var/atom/movable/AM in range(max(1,FLOOR(size/2, 1)), loc))
|
||||
|
||||
if(AM == src || AM == owned_core || !AM.simulated)
|
||||
continue
|
||||
@@ -386,7 +386,7 @@
|
||||
//determine a random amount to actually react this cycle, and remove it from the standard pool
|
||||
//this is a hack, and quite nonrealistic :(
|
||||
for(var/reactant in react_pool)
|
||||
react_pool[reactant] = rand(Floor(react_pool[reactant]/2),react_pool[reactant])
|
||||
react_pool[reactant] = rand(FLOOR(react_pool[reactant]/2, 1),react_pool[reactant])
|
||||
dormant_reactant_quantities[reactant] -= react_pool[reactant]
|
||||
if(!react_pool[reactant])
|
||||
react_pool -= reactant
|
||||
@@ -574,7 +574,7 @@
|
||||
/obj/effect/fusion_em_field/proc/Rupture()
|
||||
visible_message("<span class='danger'>\The [src] shudders like a dying animal before flaring to eye-searing brightness and rupturing!</span>")
|
||||
set_light(15, 15, "#CCCCFF")
|
||||
empulse(get_turf(src), ceil(plasma_temperature/1000), ceil(plasma_temperature/300))
|
||||
empulse(get_turf(src), CEILING(plasma_temperature/1000, 1), CEILING(plasma_temperature/300, 1))
|
||||
global_announcer.autosay("WARNING: FIELD RUPTURE IMMINENT!", "Containment Monitor")
|
||||
RadiateAll()
|
||||
var/list/things_in_range = range(10, owned_core)
|
||||
@@ -584,7 +584,7 @@
|
||||
turfs_in_range.Add(T)
|
||||
|
||||
explosion(pick(things_in_range), -1, 5, 5, 5)
|
||||
empulse(pick(things_in_range), ceil(plasma_temperature/1000), ceil(plasma_temperature/300))
|
||||
empulse(pick(things_in_range), CEILING(plasma_temperature/1000, 1), CEILING(plasma_temperature/300, 1))
|
||||
spawn(25)
|
||||
explosion(pick(things_in_range), -1, 5, 5, 5)
|
||||
spawn(25)
|
||||
@@ -655,7 +655,7 @@
|
||||
/obj/effect/fusion_em_field/proc/BluespaceQuenchEvent() //!!FUN!! causes a number of explosions in an area around the core. Will likely destory or heavily damage the reactor.
|
||||
visible_message("<span class='danger'>\The [src] shudders like a dying animal before flaring to eye-searing brightness and rupturing!</span>")
|
||||
set_light(15, 15, "#CCCCFF")
|
||||
empulse(get_turf(src), ceil(plasma_temperature/1000), ceil(plasma_temperature/300))
|
||||
empulse(get_turf(src), CEILING(plasma_temperature/1000, 1), CEILING(plasma_temperature/300, 1))
|
||||
global_announcer.autosay("WARNING: FIELD RUPTURE IMMINENT!", "Containment Monitor")
|
||||
RadiateAll()
|
||||
var/list/things_in_range = range(10, owned_core)
|
||||
@@ -665,7 +665,7 @@
|
||||
turfs_in_range.Add(T)
|
||||
for(var/loopcount = 1 to 10)
|
||||
explosion(pick(things_in_range), -1, 5, 5, 5)
|
||||
empulse(pick(things_in_range), ceil(plasma_temperature/1000), ceil(plasma_temperature/300))
|
||||
empulse(pick(things_in_range), CEILING(plasma_temperature/1000, 1), CEILING(plasma_temperature/300, 1))
|
||||
Destroy()
|
||||
owned_core.Shutdown()
|
||||
return
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
return PROCESS_KILL
|
||||
|
||||
if(istype(loc, /turf))
|
||||
radiation_repository.radiate(src, max(1,ceil(radioactivity/30)))
|
||||
radiation_repository.radiate(src, max(1,CEILING(radioactivity/30, 1)))
|
||||
|
||||
/obj/item/weapon/fuel_assembly/Destroy()
|
||||
processing_objects -= src
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
return
|
||||
|
||||
if(istype(W, /obj/item/stack/material) && W.get_material_name() == DEFAULT_WALL_MATERIAL)
|
||||
var/amt = Ceiling(( initial(integrity) - integrity)/10)
|
||||
var/amt = CEILING(( initial(integrity) - integrity)/10, 1)
|
||||
if(!amt)
|
||||
to_chat(user, "<span class='notice'>\The [src] is already fully repaired.</span>")
|
||||
return
|
||||
|
||||
@@ -618,7 +618,7 @@
|
||||
|
||||
if(one_handed_penalty)
|
||||
if(!held_twohanded)
|
||||
acc_mod += -ceil(one_handed_penalty/2)
|
||||
acc_mod += -CEILING(one_handed_penalty/2, 1)
|
||||
disp_mod += one_handed_penalty*0.5 //dispersion per point of two-handedness
|
||||
|
||||
//Accuracy modifiers
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
/datum/random_map/noise/set_map_size()
|
||||
// Make sure the grid is a square with limits that are
|
||||
// (n^2)+1, otherwise diamond-square won't work.
|
||||
if(!IsPowerOfTwo((limit_x-1)))
|
||||
limit_x = RoundUpToPowerOfTwo(limit_x) + 1
|
||||
if(!IsPowerOfTwo((limit_y-1)))
|
||||
limit_y = RoundUpToPowerOfTwo(limit_y) + 1
|
||||
if(!ISPOWEROFTWO((limit_x-1)))
|
||||
limit_x = ROUNDUPTOPOWEROFTWO(limit_x) + 1
|
||||
if(!ISPOWEROFTWO((limit_y-1)))
|
||||
limit_y = ROUNDUPTOPOWEROFTWO(limit_y) + 1
|
||||
// Sides must be identical lengths.
|
||||
if(limit_x > limit_y)
|
||||
limit_y = limit_x
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
/datum/reagent/toxin/hydrophoron/touch_turf(var/turf/simulated/T)
|
||||
if(!istype(T))
|
||||
return
|
||||
T.assume_gas("phoron", ceil(volume/2), T20C)
|
||||
T.assume_gas("phoron", CEILING(volume/2, 1), T20C)
|
||||
for(var/turf/simulated/floor/target_tile in range(0,T))
|
||||
target_tile.assume_gas("phoron", volume/2, 400+T0C)
|
||||
spawn (0) target_tile.hotspot_expose(700, 400)
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
|
||||
user.setClickCooldown(user.get_attack_speed(src)) //puts a limit on how fast people can eat/drink things
|
||||
self_feed_message(user)
|
||||
reagents.trans_to_mob(user, issmall(user) ? ceil(amount_per_transfer_from_this/2) : amount_per_transfer_from_this, CHEM_INGEST)
|
||||
reagents.trans_to_mob(user, issmall(user) ? CEILING(amount_per_transfer_from_this/2, 1) : amount_per_transfer_from_this, CHEM_INGEST)
|
||||
feed_sound(user)
|
||||
return 1
|
||||
else
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
// Makes shields become gradually more red as the projector's health decreases.
|
||||
/obj/item/shield_projector/proc/update_shield_colors()
|
||||
// This is done at the projector instead of the shields themselves to avoid needing to calculate this more than once every update.
|
||||
var/lerp_weight = shield_health / max_shield_health
|
||||
var/interpolate_weight = shield_health / max_shield_health
|
||||
|
||||
var/list/low_color_list = hex2rgb(low_color)
|
||||
var/low_r = low_color_list[1]
|
||||
@@ -164,9 +164,9 @@
|
||||
var/high_g = high_color_list[2]
|
||||
var/high_b = high_color_list[3]
|
||||
|
||||
var/new_r = Interpolate(low_r, high_r, weight = lerp_weight)
|
||||
var/new_g = Interpolate(low_g, high_g, weight = lerp_weight)
|
||||
var/new_b = Interpolate(low_b, high_b, weight = lerp_weight)
|
||||
var/new_r = LERP(low_r, high_r, interpolate_weight)
|
||||
var/new_g = LERP(low_g, high_g, interpolate_weight)
|
||||
var/new_b = LERP(low_b, high_b, interpolate_weight)
|
||||
|
||||
var/new_color = rgb(new_r, new_g, new_b)
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
if(autopilot_delay % 10 == 0) // Every ten ticks.
|
||||
var/seconds_left = autopilot_delay * 2
|
||||
if(seconds_left >= 60) // A minute
|
||||
var/minutes_left = Floor(seconds_left / 60)
|
||||
var/minutes_left = FLOOR(seconds_left / 60, 1)
|
||||
seconds_left = seconds_left % 60
|
||||
autopilot_say("Departing in [minutes_left] minute\s[seconds_left ? ", [seconds_left] seconds":""].")
|
||||
else
|
||||
|
||||
@@ -59,8 +59,13 @@
|
||||
|
||||
if(NORTH)
|
||||
|
||||
<<<<<<< HEAD
|
||||
int_panel_x = ux + Floor(lift_size_x/2)
|
||||
int_panel_y = uy + (make_walls ? 1 : 0)
|
||||
=======
|
||||
int_panel_x = ux + FLOOR(lift_size_x/2, 1)
|
||||
int_panel_y = uy + 1
|
||||
>>>>>>> 8da11c1... Makes math helpers defines for performance (#5654)
|
||||
ext_panel_x = ux
|
||||
ext_panel_y = ey + 2
|
||||
|
||||
@@ -76,8 +81,13 @@
|
||||
|
||||
if(SOUTH)
|
||||
|
||||
<<<<<<< HEAD
|
||||
int_panel_x = ux + Floor(lift_size_x/2)
|
||||
int_panel_y = ey - (make_walls ? 1 : 0)
|
||||
=======
|
||||
int_panel_x = ux + FLOOR(lift_size_x/2, 1)
|
||||
int_panel_y = ey - 1
|
||||
>>>>>>> 8da11c1... Makes math helpers defines for performance (#5654)
|
||||
ext_panel_x = ex
|
||||
ext_panel_y = uy - 2
|
||||
|
||||
@@ -93,8 +103,13 @@
|
||||
|
||||
if(EAST)
|
||||
|
||||
<<<<<<< HEAD
|
||||
int_panel_x = ux + (make_walls ? 1 : 0)
|
||||
int_panel_y = uy + Floor(lift_size_y/2)
|
||||
=======
|
||||
int_panel_x = ux+1
|
||||
int_panel_y = uy + FLOOR(lift_size_y/2, 1)
|
||||
>>>>>>> 8da11c1... Makes math helpers defines for performance (#5654)
|
||||
ext_panel_x = ex+2
|
||||
ext_panel_y = ey
|
||||
|
||||
@@ -110,8 +125,13 @@
|
||||
|
||||
if(WEST)
|
||||
|
||||
<<<<<<< HEAD
|
||||
int_panel_x = ex - (make_walls ? 1 : 0)
|
||||
int_panel_y = uy + Floor(lift_size_y/2)
|
||||
=======
|
||||
int_panel_x = ex-1
|
||||
int_panel_y = uy + FLOOR(lift_size_y/2, 1)
|
||||
>>>>>>> 8da11c1... Makes math helpers defines for performance (#5654)
|
||||
ext_panel_x = ux-2
|
||||
ext_panel_y = uy
|
||||
|
||||
|
||||
@@ -93,8 +93,11 @@
|
||||
#include "code\_helpers\icons_vr.dm"
|
||||
#include "code\_helpers\lists.dm"
|
||||
#include "code\_helpers\logging.dm"
|
||||
<<<<<<< HEAD:vorestation.dme
|
||||
#include "code\_helpers\logging_vr.dm"
|
||||
#include "code\_helpers\maths.dm"
|
||||
=======
|
||||
>>>>>>> 8da11c1... Makes math helpers defines for performance (#5654):polaris.dme
|
||||
#include "code\_helpers\matrices.dm"
|
||||
#include "code\_helpers\mobs.dm"
|
||||
#include "code\_helpers\names.dm"
|
||||
|
||||
Reference in New Issue
Block a user