From f875d4e17659762ac01a32b239c8e200088d7af8 Mon Sep 17 00:00:00 2001 From: Emmett Gaines Date: Sun, 17 Dec 2017 11:02:11 -0500 Subject: [PATCH] Defines math, take 2 --- code/__DEFINES/atmospherics.dm | 6 + code/__DEFINES/math.dm | 27 -- code/__DEFINES/maths.dm | 209 +++++++++++ code/__HELPERS/_lists.dm | 4 +- code/__HELPERS/maths.dm | 257 ------------- code/__HELPERS/radio.dm | 17 + code/__HELPERS/time.dm | 6 +- code/__HELPERS/type2type.dm | 2 +- code/__HELPERS/unsorted.dm | 18 +- code/_onclick/hud/parallax.dm | 4 +- code/_onclick/hud/robot.dm | 280 ++++++++++++++ code/_onclick/item_attack.dm | 4 +- .../controllers/configuration/config_entry.dm | 2 +- code/controllers/master.dm | 2 +- code/controllers/subsystem/throwing.dm | 2 +- code/datums/beam.dm | 4 +- code/datums/components/archaeology.dm | 2 +- code/datums/components/decal.dm | 2 +- code/datums/dash_weapon.dm | 2 +- code/datums/diseases/advance/advance.dm | 8 +- code/datums/explosion.dm | 2 +- code/datums/martial/krav_maga.dm | 4 +- code/datums/progressbar.dm | 2 +- code/datums/radiation_wave.dm | 4 +- code/datums/status_effects/buffs.dm | 6 +- code/datums/status_effects/debuffs.dm | 4 +- code/game/gamemodes/blob/blobs/blob_mobs.dm | 2 +- code/game/gamemodes/blob/overmind.dm | 2 +- .../clock_cult/clock_effects/clock_sigils.dm | 2 +- .../clock_helpers/fabrication_helpers.dm | 4 +- .../scripture_applications.dm | 2 +- .../clock_structures/mania_motor.dm | 2 +- .../clock_structures/taunting_trail.dm | 2 +- code/game/gamemodes/meteor/meteor.dm | 2 +- code/game/gamemodes/nuclear/nuclearbomb.dm | 2 +- code/game/machinery/computer/apc_control.dm | 4 +- code/game/machinery/computer/atmos_control.dm | 2 +- code/game/machinery/computer/dna_console.dm | 33 +- .../machinery/computer/gulag_teleporter.dm | 2 +- .../machinery/computer/telecrystalconsoles.dm | 6 + code/game/machinery/deployable.dm | 2 +- code/game/machinery/doors/brigdoors.dm | 2 +- code/game/machinery/pipe/pipe_dispenser.dm | 4 +- code/game/machinery/shieldgen.dm | 2 +- code/game/machinery/spaceheater.dm | 4 +- code/game/machinery/syndicatebomb.dm | 2 +- code/game/machinery/vending.dm | 2 +- code/game/mecha/mech_fabricator.dm | 6 +- code/game/mecha/working/ripley.dm | 2 +- code/game/objects/effects/anomalies.dm | 5 + code/game/objects/items/chrono_eraser.dm | 2 +- code/game/objects/items/defib.dm | 2 +- .../objects/items/devices/lightreplacer.dm | 2 +- .../objects/items/devices/traitordevices.dm | 2 +- code/game/objects/items/dice.dm | 2 +- code/game/objects/items/grenades/plastic.dm | 4 +- code/game/objects/items/his_grace.dm | 6 +- code/game/objects/items/pneumaticCannon.dm | 4 +- code/game/objects/items/robot/robot_items.dm | 4 +- code/game/objects/items/sharpener.dm | 6 +- code/game/objects/items/stacks/stack.dm | 4 +- code/game/objects/items/tanks/tanks.dm | 2 +- code/game/objects/items/tools/weldingtool.dm | 347 ++++++++++++++++++ code/game/objects/obj_defense.dm | 2 +- code/game/objects/structures/fireplace.dm | 2 +- code/game/objects/structures/grille.dm | 2 +- code/game/objects/structures/lattice.dm | 4 +- code/game/objects/structures/musician.dm | 2 +- code/game/objects/structures/reflector.dm | 33 +- code/game/objects/structures/tables_racks.dm | 4 +- code/game/objects/structures/window.dm | 2 +- .../turfs/simulated/floor/plating/asteroid.dm | 2 +- code/game/turfs/simulated/walls.dm | 2 +- code/modules/admin/sound_emitter.dm | 4 +- code/modules/admin/sql_message_system.dm | 2 +- code/modules/admin/topic.dm | 2 +- code/modules/admin/verbs/SDQL2/SDQL_2.dm | 2 +- code/modules/admin/verbs/playsound.dm | 2 +- .../components/binary_devices/dp_vent_pump.dm | 6 +- .../components/binary_devices/passive_gate.dm | 4 +- .../components/binary_devices/pump.dm | 7 +- .../components/binary_devices/volume_pump.dm | 7 +- .../components/trinary_devices/filter.dm | 2 +- .../components/trinary_devices/mixer.dm | 2 +- .../unary_devices/outlet_injector.dm | 4 +- .../components/unary_devices/thermomachine.dm | 2 +- .../components/unary_devices/vent_pump.dm | 8 +- .../machinery/pipes/layermanifold.dm | 4 +- .../machinery/portable/canister.dm | 4 +- .../atmospherics/machinery/portable/pump.dm | 2 +- code/modules/cargo/exports.dm | 6 +- code/modules/client/client_procs.dm | 12 +- code/modules/client/preferences.dm | 4 +- .../modules/clothing/spacesuits/flightsuit.dm | 20 +- code/modules/clothing/spacesuits/hardsuit.dm | 2 +- code/modules/events/_event.dm | 4 +- code/modules/events/brand_intelligence.dm | 4 +- code/modules/events/disease_outbreak.dm | 9 + code/modules/events/meteor_wave.dm | 2 +- code/modules/events/portal_storm.dm | 6 +- .../kitchen_machinery/food_cart.dm | 2 +- code/modules/food_and_drinks/pizzabox.dm | 2 +- code/modules/goonchat/browserOutput.dm | 2 +- code/modules/hydroponics/gene_modder.dm | 2 +- code/modules/hydroponics/grown.dm | 2 +- code/modules/hydroponics/grown/towercap.dm | 4 +- code/modules/hydroponics/growninedible.dm | 2 +- code/modules/hydroponics/hydroponics.dm | 12 +- code/modules/hydroponics/seeds.dm | 28 +- .../core/special_pins/index_pin.dm | 2 +- .../subtypes/converters.dm | 4 +- .../subtypes/data_transfer.dm | 2 +- .../integrated_electronics/subtypes/input.dm | 4 +- .../subtypes/manipulation.dm | 12 +- .../integrated_electronics/subtypes/output.dm | 4 +- .../subtypes/reagents.dm | 8 +- .../integrated_electronics/subtypes/time.dm | 2 +- .../integrated_electronics/subtypes/trig.dm | 8 +- code/modules/language/language.dm | 2 +- code/modules/library/lib_machines.dm | 4 +- code/modules/lighting/lighting_source.dm | 4 +- code/modules/mapping/reader.dm | 10 +- .../mining/lavaland/necropolis_chests.dm | 4 +- code/modules/mining/machine_redemption.dm | 2 +- code/modules/mining/mint.dm | 2 +- .../modules/mob/dead/new_player/new_player.dm | 4 +- code/modules/mob/dead/observer/observer.dm | 2 +- code/modules/mob/living/brain/brain_item.dm | 2 +- .../mob/living/carbon/alien/status_procs.dm | 2 +- .../modules/mob/living/carbon/damage_procs.dm | 2 +- .../mob/living/carbon/human/human_defense.dm | 6 +- .../carbon/human/species_types/golems.dm | 2 +- .../carbon/human/species_types/vampire.dm | 4 +- code/modules/mob/living/carbon/life.dm | 2 +- .../modules/mob/living/carbon/status_procs.dm | 4 +- code/modules/mob/living/damage_procs.dm | 10 +- code/modules/mob/living/living.dm | 2 +- code/modules/mob/living/living_defense.dm | 4 +- code/modules/mob/living/silicon/pai/pai.dm | 6 +- .../mob/living/silicon/pai/pai_defense.dm | 2 +- code/modules/mob/living/silicon/robot/life.dm | 2 +- .../mob/living/simple_animal/damage_procs.dm | 2 +- .../hostile/megafauna/bubblegum.dm | 4 +- .../hostile/megafauna/colossus.dm | 2 +- .../simple_animal/hostile/megafauna/dragon.dm | 6 +- .../hostile/megafauna/hierophant.dm | 2 +- .../mob/living/simple_animal/simple_animal.dm | 2 +- .../mob/living/simple_animal/slime/powers.dm | 2 +- code/modules/power/apc.dm | 4 +- code/modules/power/cell.dm | 4 +- code/modules/power/powernet.dm | 2 +- code/modules/power/smes.dm | 6 +- code/modules/power/solar.dm | 4 +- code/modules/power/supermatter/supermatter.dm | 10 +- code/modules/power/tesla/energy_ball.dm | 4 +- .../boxes_magazines/external_mag.dm | 2 +- .../projectiles/guns/ballistic/automatic.dm | 8 +- code/modules/projectiles/guns/beam_rifle.dm | 6 +- code/modules/projectiles/guns/energy.dm | 2 +- code/modules/projectiles/guns/magic/wand.dm | 4 +- code/modules/projectiles/projectile.dm | 12 +- code/modules/reagents/chemistry/holder.dm | 2 +- .../chemistry/machinery/chem_dispenser.dm | 2 +- .../chemistry/machinery/chem_heater.dm | 2 +- .../chemistry/machinery/chem_master.dm | 4 +- .../chemistry/machinery/reagentgrinder.dm | 2 +- code/modules/reagents/chemistry/reagents.dm | 2 +- .../chemistry/reagents/alcohol_reagents.dm | 2 +- .../chemistry/reagents/toxin_reagents.dm | 4 +- .../chemistry/recipes/pyrotechnics.dm | 8 +- .../reagents/reagent_containers/syringes.dm | 2 +- code/modules/recycling/disposal/bin.dm | 2 +- code/modules/research/protolathe.dm | 2 +- .../research/xenobiology/xenobiology.dm | 4 +- code/modules/shuttle/shuttle.dm | 14 +- code/modules/spells/spell_types/wizard.dm | 2 +- .../surgery/bodyparts/dismemberment.dm | 2 +- code/modules/surgery/organs/eyes.dm | 2 +- code/modules/surgery/organs/lungs.dm | 6 +- tgstation.dme | 3 +- 180 files changed, 1250 insertions(+), 644 deletions(-) delete mode 100644 code/__DEFINES/math.dm create mode 100644 code/__DEFINES/maths.dm delete mode 100644 code/__HELPERS/maths.dm diff --git a/code/__DEFINES/atmospherics.dm b/code/__DEFINES/atmospherics.dm index dacd09c995..20d80cb904 100644 --- a/code/__DEFINES/atmospherics.dm +++ b/code/__DEFINES/atmospherics.dm @@ -12,6 +12,12 @@ //ATMOS //stuff you should probably leave well alone! +#define R_IDEAL_GAS_EQUATION 8.31 //kPa*L/(K*mol) +#define ONE_ATMOSPHERE 101.325 //kPa +#define T0C 273.15 // 0degC +#define T20C 293.15 // 20degC +#define TCMB 2.7 // -270.3degC + #define MOLES_CELLSTANDARD (ONE_ATMOSPHERE*CELL_VOLUME/(T20C*R_IDEAL_GAS_EQUATION)) //moles in a 2.5 m^3 cell at 101.325 Pa and 20 degC #define M_CELL_WITH_RATIO (MOLES_CELLSTANDARD * 0.005) //compared against for superconductivity #define O2STANDARD 0.21 //percentage of oxygen in a normal mixture of air diff --git a/code/__DEFINES/math.dm b/code/__DEFINES/math.dm deleted file mode 100644 index 5b3f51b4e3..0000000000 --- a/code/__DEFINES/math.dm +++ /dev/null @@ -1,27 +0,0 @@ -#define PI 3.1415 -#define SPEED_OF_LIGHT 3e8 //not exact but hey! -#define SPEED_OF_LIGHT_SQ 9e+16 -#define INFINITY 1e31 //closer then enough - -//atmos -#define R_IDEAL_GAS_EQUATION 8.31 //kPa*L/(K*mol) -#define ONE_ATMOSPHERE 101.325 //kPa -#define T0C 273.15 // 0degC -#define T20C 293.15 // 20degC -#define TCMB 2.7 // -270.3degC - -#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 ) diff --git a/code/__DEFINES/maths.dm b/code/__DEFINES/maths.dm new file mode 100644 index 0000000000..0ff3ade369 --- /dev/null +++ b/code/__DEFINES/maths.dm @@ -0,0 +1,209 @@ +// 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 NUM_SQRT2 1.41421356 + +#define PI 3.1415 +#define SPEED_OF_LIGHT 3e8 //not exact but hey! +#define SPEED_OF_LIGHT_SQ 9e+16 +#define INFINITY 1e31 //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_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 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 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 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) + ((b) - (a)) * 0.5) + +// 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)) + +//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/mouse_angle_from_client(client/client) + var/list/mouse_control = params2list(client.mouseParams) + if(mouse_control["screen-loc"] && client) + var/list/screen_loc_params = splittext(mouse_control["screen-loc"], ",") + var/list/screen_loc_X = splittext(screen_loc_params[1],":") + var/list/screen_loc_Y = splittext(screen_loc_params[2],":") + var/x = (text2num(screen_loc_X[1]) * 32 + text2num(screen_loc_X[2]) - 32) + var/y = (text2num(screen_loc_Y[1]) * 32 + text2num(screen_loc_Y[2]) - 32) + var/list/screenview = getviewsize(client.view) + var/screenviewX = screenview[1] * world.icon_size + var/screenviewY = screenview[2] * world.icon_size + var/ox = round(screenviewX/2) - client.pixel_x //"origin" x + var/oy = round(screenviewY/2) - client.pixel_y //"origin" y + var/angle = SIMPLIFY_DEGREES(ATAN2(y - oy, x - ox)) + return angle + +/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) + +// ) \ No newline at end of file diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index 631214de98..91eee45b4d 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -43,8 +43,8 @@ //Returns list element or null. Should prevent "index out of bounds" error. /proc/listgetindex(list/L, index) if(LAZYLEN(L)) - if(isnum(index) && IsInteger(index)) - if(IsInRange(index,1,L.len)) + if(isnum(index) && ISINTEGER(index)) + if(ISINRANGE(index,1,L.len)) return L[index] else if(index in L) return L[index] diff --git a/code/__HELPERS/maths.dm b/code/__HELPERS/maths.dm deleted file mode 100644 index 0af8b8ae1a..0000000000 --- a/code/__HELPERS/maths.dm +++ /dev/null @@ -1,257 +0,0 @@ -// Credits to Nickr5 for the useful procs I've taken from his library resource. - -GLOBAL_VAR_INIT(E, 2.71828183) -GLOBAL_VAR_INIT(Sqrt2, 1.41421356) - -// List of square roots for the numbers 1-100. -GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10)) - -/proc/sign(x) - return x!=0?x/abs(x):0 - -/proc/Atan2(x, y) - if(!x && !y) - return 0 - var/a = arccos(x / sqrt(x*x + y*y)) - return y >= 0 ? a : -a - -/proc/Ceiling(x, y=1) - return -round(-x / y) * y - -/proc/Floor(x, y=1) - return round(x / y) * y - -#define Clamp(CLVALUE,CLMIN,CLMAX) ( max( (CLMIN), min((CLVALUE), (CLMAX)) ) ) - -/proc/Modulus(x, y) //Byond's modulus doesn't work with decimals. - return x - y * round(x / y) - -// cotangent -/proc/Cot(x) - return 1 / Tan(x) - -// cosecant -/proc/Csc(x) - return 1 / sin(x) - -/proc/Default(a, b) - return a ? a : b - -// Greatest Common Divisor - Euclid's algorithm -/proc/Gcd(a, b) - return b ? Gcd(b, a % b) : a - -/proc/Inverse(x) - return 1 / x - -#define InverseSquareLaw(initial_strength,cur_distance,initial_distance) (initial_strength*(initial_distance**2/cur_distance**2)) - -/proc/IsAboutEqual(a, b, deviation = 0.1) - return abs(a - b) <= deviation - -/proc/IsEven(x) - return x % 2 == 0 - -// Returns true if val is from min to max, inclusive. -/proc/IsInRange(val, min, max) - return min <= val && val <= max - -/proc/IsInteger(x) - return round(x) == x - -/proc/IsOdd(x) - return !IsEven(x) - -/proc/IsMultiple(x, y) - return x % y == 0 - -// Least Common Multiple -/proc/Lcm(a, b) - return abs(a) / Gcd(a, b) * abs(b) - -// 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. -/proc/Lerp(a, b, amount = 0.5) - return a + (b - a) * amount - -//Calculates the sum of a list of numbers. -/proc/Sum(var/list/data) - . = 0 - for(var/val in data) - .+= val - -//Calculates the mean of a list of numbers. -/proc/Mean(var/list/data) - . = Sum(data) / (data.len) - - -// Returns the nth root of x. -/proc/Root(n, x) - return x ** (1 / n) - -// secant -/proc/Sec(x) - return 1 / cos(x) - -// 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 - -// tangent -/proc/Tan(x) - return sin(x) / cos(x) - -/proc/ToDegrees(radians) - // 180 / Pi - return radians * 57.2957795 - -/proc/ToRadians(degrees) - // Pi / 180 - return degrees * 0.0174532925 - -// Will filter out extra rotations and negative rotations -// E.g: 540 becomes 180. -180 becomes 180. -/proc/SimplifyDegrees(degrees) - degrees = degrees % 360 - if(degrees < 0) - degrees += 360 - return degrees - -// min is inclusive, max is exclusive -/proc/Wrap(val, min, max) - var/d = max - min - var/t = round((val - min) / d) - return val - (t * d) - -#define NORM_ROT(rot) ((((rot % 360) + (rot - round(rot, 1))) >= 0) ? ((rot % 360) + (rot - round(rot, 1))) : (((rot % 360) + (rot - round(rot, 1))) + 360)) - -/proc/get_angle_of_incidence(face_angle, angle_in, auto_normalize = TRUE) - - var/angle_in_s = NORM_ROT(angle_in) - var/face_angle_s = NORM_ROT(face_angle) - var/incidence = face_angle_s - angle_in_s - var/incidence_s = incidence - while(incidence_s < -90) - incidence_s += 180 - while(incidence_s > 90) - incidence_s -= 180 - if(auto_normalize) - return incidence_s - else - return incidence - -//A logarithm that converts an integer to a number scaled between 0 and 1 (can be tweaked to be higher). -//Currently, this is used for hydroponics-produce sprite transforming, but could be useful for other transform functions. -/proc/TransformUsingVariable(input, inputmaximum, scaling_modifier = 0) - - var/inputToDegrees = (input/inputmaximum)*180 //Converting from a 0 -> 100 scale to a 0 -> 180 scale. The 0 -> 180 scale corresponds to degrees - var/size_factor = ((-cos(inputToDegrees) +1) /2) //returns a value from 0 to 1 - - return size_factor + scaling_modifier //scale mod of 0 results in a number from 0 to 1. A scale modifier of +0.5 returns 0.5 to 1.5 - -//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/mouse_angle_from_client(client/client) - var/list/mouse_control = params2list(client.mouseParams) - if(mouse_control["screen-loc"] && client) - var/list/screen_loc_params = splittext(mouse_control["screen-loc"], ",") - var/list/screen_loc_X = splittext(screen_loc_params[1],":") - var/list/screen_loc_Y = splittext(screen_loc_params[2],":") - var/x = (text2num(screen_loc_X[1]) * 32 + text2num(screen_loc_X[2]) - 32) - var/y = (text2num(screen_loc_Y[1]) * 32 + text2num(screen_loc_Y[2]) - 32) - var/list/screenview = getviewsize(client.view) - var/screenviewX = screenview[1] * world.icon_size - var/screenviewY = screenview[2] * world.icon_size - var/ox = round(screenviewX/2) - client.pixel_x //"origin" x - var/oy = round(screenviewY/2) - client.pixel_y //"origin" y - var/angle = NORM_ROT(Atan2(y - oy, x - ox)) - return angle - -/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) - -/proc/round_down(num) - if(round(num) != num) - return round(num--) - else return num - -//proc/get_overlap() -// 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) \ No newline at end of file diff --git a/code/__HELPERS/radio.dm b/code/__HELPERS/radio.dm index 1706e8658c..56471142ca 100644 --- a/code/__HELPERS/radio.dm +++ b/code/__HELPERS/radio.dm @@ -1,3 +1,4 @@ +<<<<<<< HEAD // Ensure the frequency is within bounds of what it should be sending/recieving at /proc/sanitize_frequency(frequency, free = FALSE) . = round(frequency) @@ -12,3 +13,19 @@ /proc/format_frequency(frequency) frequency = text2num(frequency) return "[round(frequency / 10)].[frequency % 10]" +======= +// Ensure the frequency is within bounds of what it should be sending/recieving at +/proc/sanitize_frequency(frequency, free = FALSE) + . = round(frequency) + if(free) + . = CLAMP(frequency, MIN_FREE_FREQ, MAX_FREE_FREQ) + else + . = CLAMP(frequency, MIN_FREQ, MAX_FREQ) + if(!(. % 2)) // Ensure the last digit is an odd number + . += 1 + +// Format frequency by moving the decimal. +/proc/format_frequency(frequency) + frequency = text2num(frequency) + return "[round(frequency / 10)].[frequency % 10]" +>>>>>>> 25080ff... defines math (#33498) diff --git a/code/__HELPERS/time.dm b/code/__HELPERS/time.dm index 74c565da52..68ab173ecd 100644 --- a/code/__HELPERS/time.dm +++ b/code/__HELPERS/time.dm @@ -60,7 +60,7 @@ GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0) if(!second) return "0 seconds" if(second >= 60) - minute = round_down(second/60) + minute = FLOOR(second/60, 1) second = round(second - (minute*60), 0.1) second_rounded = TRUE if(second) //check if we still have seconds remaining to format, or if everything went into minute. @@ -91,7 +91,7 @@ GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0) if(!minute) return "[second]" if(minute >= 60) - hour = round_down(minute/60,1) + hour = FLOOR(minute/60, 1) minute = (minute - (hour*60)) if(minute) //alot simpler from here since you don't have to worry about fractions if(minute != 1) @@ -114,7 +114,7 @@ GLOBAL_VAR_INIT(rollovercheck_last_timeofday, 0) if(!hour) return "[minute][second]" if(hour >= 24) - day = round_down(hour/24,1) + day = FLOOR(hour/24, 1) hour = (hour - (day*24)) if(hour) if(hour != 1) diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index bae773b27e..2ebe24b85b 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -117,7 +117,7 @@ //Converts an angle (degrees) into an ss13 direction /proc/angle2dir(degree) - degree = SimplifyDegrees(degree) + degree = SIMPLIFY_DEGREES(degree) switch(degree) if(0 to 22.5) //north requires two angle ranges return NORTH diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 9ec23fa966..207e69fa9b 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -147,10 +147,10 @@ Turf and target are separate in case you want to teleport some distance from a t var/line[] = list(locate(px,py,M.z)) var/dx=N.x-px //x distance var/dy=N.y-py - var/dxabs=abs(dx)//Absolute value of x distance - var/dyabs=abs(dy) - var/sdx=sign(dx) //Sign of x distance (+ or -) - var/sdy=sign(dy) + var/dxabs = abs(dx)//Absolute value of x distance + var/dyabs = abs(dy) + var/sdx = SIGN(dx) //Sign of x distance (+ or -) + var/sdy = SIGN(dy) var/x=dxabs>>1 //Counters for steps taken, setting to distance/2 var/y=dyabs>>1 //Bit-shifting makes me l33t. It also makes getline() unnessecarrily fast. var/j //Generic integer for counting @@ -953,8 +953,8 @@ GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list( tY = tY[1] tX = splittext(tX[1], ":") tX = tX[1] - tX = Clamp(origin.x + text2num(tX) - world.view - 1, 1, world.maxx) - tY = Clamp(origin.y + text2num(tY) - world.view - 1, 1, world.maxy) + tX = CLAMP(origin.x + text2num(tX) - world.view - 1, 1, world.maxx) + tY = CLAMP(origin.y + text2num(tY) - world.view - 1, 1, world.maxy) return locate(tX, tY, tZ) /proc/screen_loc2turf(text, turf/origin) @@ -966,8 +966,8 @@ GLOBAL_LIST_INIT(WALLITEMS_INVERSE, typecacheof(list( tX = splittext(tZ[2], "-") tX = text2num(tX[2]) tZ = origin.z - tX = Clamp(origin.x + 7 - tX, 1, world.maxx) - tY = Clamp(origin.y + 7 - tY, 1, world.maxy) + tX = CLAMP(origin.x + 7 - tX, 1, world.maxx) + tY = CLAMP(origin.y + 7 - tY, 1, world.maxy) return locate(tX, tY, tZ) /proc/IsValidSrc(datum/D) @@ -1272,7 +1272,7 @@ proc/pick_closest_path(value, list/matches = get_fancy_list_of_atom_types()) . = 0 var/i = DS2TICKS(initial_delay) do - . += Ceiling(i*DELTA_CALC) + . += CEILING(i*DELTA_CALC, 1) sleep(i*world.tick_lag*DELTA_CALC) i *= 2 while (TICK_USAGE > min(TICK_LIMIT_TO_RUN, Master.current_ticklimit)) diff --git a/code/_onclick/hud/parallax.dm b/code/_onclick/hud/parallax.dm index ff38107bfb..52319b7866 100755 --- a/code/_onclick/hud/parallax.dm +++ b/code/_onclick/hud/parallax.dm @@ -257,8 +257,8 @@ view = world.view var/list/viewscales = getviewsize(view) - var/countx = Ceiling((viewscales[1]/2)/(480/world.icon_size))+1 - var/county = Ceiling((viewscales[2]/2)/(480/world.icon_size))+1 + var/countx = CEILING((viewscales[1]/2)/(480/world.icon_size), 1)+1 + var/county = CEILING((viewscales[2]/2)/(480/world.icon_size), 1)+1 var/list/new_overlays = new for(var/x in -countx to countx) for(var/y in -county to county) diff --git a/code/_onclick/hud/robot.dm b/code/_onclick/hud/robot.dm index f1ec409520..e227968f57 100644 --- a/code/_onclick/hud/robot.dm +++ b/code/_onclick/hud/robot.dm @@ -1,3 +1,4 @@ +<<<<<<< HEAD /obj/screen/robot icon = 'icons/mob/screen_cyborg.dmi' @@ -275,3 +276,282 @@ else for(var/obj/item/I in R.held_items) screenmob.client.screen -= I +======= +/obj/screen/robot + icon = 'icons/mob/screen_cyborg.dmi' + +/obj/screen/robot/module + name = "cyborg module" + icon_state = "nomod" + +/obj/screen/robot/Click() + if(isobserver(usr)) + return 1 + +/obj/screen/robot/module/Click() + if(..()) + return + var/mob/living/silicon/robot/R = usr + if(R.module.type != /obj/item/robot_module) + R.hud_used.toggle_show_robot_modules() + return 1 + R.pick_module() + +/obj/screen/robot/module1 + name = "module1" + icon_state = "inv1" + +/obj/screen/robot/module1/Click() + if(..()) + return + var/mob/living/silicon/robot/R = usr + R.toggle_module(1) + +/obj/screen/robot/module2 + name = "module2" + icon_state = "inv2" + +/obj/screen/robot/module2/Click() + if(..()) + return + var/mob/living/silicon/robot/R = usr + R.toggle_module(2) + +/obj/screen/robot/module3 + name = "module3" + icon_state = "inv3" + +/obj/screen/robot/module3/Click() + if(..()) + return + var/mob/living/silicon/robot/R = usr + R.toggle_module(3) + +/obj/screen/robot/radio + name = "radio" + icon_state = "radio" + +/obj/screen/robot/radio/Click() + if(..()) + return + var/mob/living/silicon/robot/R = usr + R.radio.interact(R) + +/obj/screen/robot/store + name = "store" + icon_state = "store" + +/obj/screen/robot/store/Click() + if(..()) + return + var/mob/living/silicon/robot/R = usr + R.uneq_active() + +/obj/screen/robot/lamp + name = "headlamp" + icon_state = "lamp0" + +/obj/screen/robot/lamp/Click() + if(..()) + return + var/mob/living/silicon/robot/R = usr + R.control_headlamp() + +/obj/screen/robot/thrusters + name = "ion thrusters" + icon_state = "ionpulse0" + +/obj/screen/robot/thrusters/Click() + if(..()) + return + var/mob/living/silicon/robot/R = usr + R.toggle_ionpulse() + +/datum/hud/robot + ui_style_icon = 'icons/mob/screen_cyborg.dmi' + +/datum/hud/robot/New(mob/owner, ui_style = 'icons/mob/screen_cyborg.dmi') + ..() + var/mob/living/silicon/robot/mymobR = mymob + var/obj/screen/using + + using = new/obj/screen/language_menu + using.screen_loc = ui_borg_language_menu + static_inventory += using + +//Radio + using = new /obj/screen/robot/radio() + using.screen_loc = ui_borg_radio + static_inventory += using + +//Module select + using = new /obj/screen/robot/module1() + using.screen_loc = ui_inv1 + static_inventory += using + mymobR.inv1 = using + + using = new /obj/screen/robot/module2() + using.screen_loc = ui_inv2 + static_inventory += using + mymobR.inv2 = using + + using = new /obj/screen/robot/module3() + using.screen_loc = ui_inv3 + static_inventory += using + mymobR.inv3 = using + +//End of module select + +//Photography stuff + using = new /obj/screen/ai/image_take() + using.screen_loc = ui_borg_camera + static_inventory += using + + using = new /obj/screen/ai/image_view() + using.screen_loc = ui_borg_album + static_inventory += using + +//Sec/Med HUDs + using = new /obj/screen/ai/sensors() + using.screen_loc = ui_borg_sensor + static_inventory += using + +//Headlamp control + using = new /obj/screen/robot/lamp() + using.screen_loc = ui_borg_lamp + static_inventory += using + mymobR.lamp_button = using + +//Thrusters + using = new /obj/screen/robot/thrusters() + using.screen_loc = ui_borg_thrusters + static_inventory += using + mymobR.thruster_button = using + +//Intent + action_intent = new /obj/screen/act_intent/robot() + action_intent.icon_state = mymob.a_intent + static_inventory += action_intent + +//Health + healths = new /obj/screen/healths/robot() + infodisplay += healths + +//Installed Module + mymobR.hands = new /obj/screen/robot/module() + mymobR.hands.screen_loc = ui_borg_module + static_inventory += mymobR.hands + +//Store + module_store_icon = new /obj/screen/robot/store() + module_store_icon.screen_loc = ui_borg_store + + pull_icon = new /obj/screen/pull() + pull_icon.icon = 'icons/mob/screen_cyborg.dmi' + pull_icon.update_icon(mymob) + pull_icon.screen_loc = ui_borg_pull + hotkeybuttons += pull_icon + + + zone_select = new /obj/screen/zone_sel/robot() + zone_select.update_icon(mymob) + static_inventory += zone_select + + +/datum/hud/proc/toggle_show_robot_modules() + if(!iscyborg(mymob)) + return + + var/mob/living/silicon/robot/R = mymob + + R.shown_robot_modules = !R.shown_robot_modules + update_robot_modules_display() + +/datum/hud/proc/update_robot_modules_display(mob/viewer) + if(!iscyborg(mymob)) + return + + var/mob/living/silicon/robot/R = mymob + + var/mob/screenmob = viewer || R + + if(!R.module) + return + + if(!R.client) + return + + if(R.shown_robot_modules && screenmob.hud_used.hud_shown) + //Modules display is shown + screenmob.client.screen += module_store_icon //"store" icon + + if(!R.module.modules) + to_chat(usr, "Selected module has no modules to select") + return + + if(!R.robot_modules_background) + return + + var/display_rows = CEILING(length(R.module.get_inactive_modules()) / 8, 1) + R.robot_modules_background.screen_loc = "CENTER-4:16,SOUTH+1:7 to CENTER+3:16,SOUTH+[display_rows]:7" + screenmob.client.screen += R.robot_modules_background + + var/x = -4 //Start at CENTER-4,SOUTH+1 + var/y = 1 + + for(var/atom/movable/A in R.module.get_inactive_modules()) + //Module is not currently active + screenmob.client.screen += A + if(x < 0) + A.screen_loc = "CENTER[x]:16,SOUTH+[y]:7" + else + A.screen_loc = "CENTER+[x]:16,SOUTH+[y]:7" + A.layer = ABOVE_HUD_LAYER + A.plane = ABOVE_HUD_PLANE + + x++ + if(x == 4) + x = -4 + y++ + + else + //Modules display is hidden + screenmob.client.screen -= module_store_icon //"store" icon + + for(var/atom/A in R.module.get_inactive_modules()) + //Module is not currently active + screenmob.client.screen -= A + R.shown_robot_modules = 0 + screenmob.client.screen -= R.robot_modules_background + +/mob/living/silicon/robot/create_mob_hud() + if(client && !hud_used) + hud_used = new /datum/hud/robot(src) + + +/datum/hud/robot/persistent_inventory_update(mob/viewer) + if(!mymob) + return + var/mob/living/silicon/robot/R = mymob + + var/mob/screenmob = viewer || R + + if(screenmob.hud_used) + if(screenmob.hud_used.hud_shown) + for(var/i in 1 to R.held_items.len) + var/obj/item/I = R.held_items[i] + if(I) + switch(i) + if(1) + I.screen_loc = ui_inv1 + if(2) + I.screen_loc = ui_inv2 + if(3) + I.screen_loc = ui_inv3 + else + return + screenmob.client.screen += I + else + for(var/obj/item/I in R.held_items) + screenmob.client.screen -= I +>>>>>>> 25080ff... defines math (#33498) diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 859c957a43..727e149a97 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -119,9 +119,9 @@ /obj/item/proc/get_clamped_volume() if(w_class) if(force) - return Clamp((force + w_class) * 4, 30, 100)// Add the item's force to its weight class and multiply by 4, then clamp the value between 30 and 100 + return CLAMP((force + w_class) * 4, 30, 100)// Add the item's force to its weight class and multiply by 4, then clamp the value between 30 and 100 else - return Clamp(w_class * 6, 10, 100) // Multiply the item's weight class by 6, then clamp the value between 10 and 100 + return CLAMP(w_class * 6, 10, 100) // Multiply the item's weight class by 6, then clamp the value between 10 and 100 /mob/living/proc/send_item_attack_message(obj/item/I, mob/living/user, hit_area) var/message_verb = "attacked" diff --git a/code/controllers/configuration/config_entry.dm b/code/controllers/configuration/config_entry.dm index 92dcb9baf0..804060aaa8 100644 --- a/code/controllers/configuration/config_entry.dm +++ b/code/controllers/configuration/config_entry.dm @@ -110,7 +110,7 @@ /datum/config_entry/number/ValidateAndSet(str_val) var/temp = text2num(trim(str_val)) if(!isnull(temp)) - value = Clamp(integer ? round(temp) : temp, min_val, max_val) + value = CLAMP(integer ? round(temp) : temp, min_val, max_val) if(value != temp && !var_edited) log_config("Changing [name] from [temp] to [value]!") return TRUE diff --git a/code/controllers/master.dm b/code/controllers/master.dm index 568257e10f..b9950da7b9 100644 --- a/code/controllers/master.dm +++ b/code/controllers/master.dm @@ -301,7 +301,7 @@ GLOBAL_REAL(Master, /datum/controller/master) = new continue //Byond resumed us late. assume it might have to do the same next tick - if (last_run + Ceiling(world.tick_lag * (processing * sleep_delta), world.tick_lag) < world.time) + if (last_run + CEILING(world.tick_lag * (processing * sleep_delta), world.tick_lag) < world.time) sleep_delta += 1 sleep_delta = MC_AVERAGE_FAST(sleep_delta, 1) //decay sleep_delta diff --git a/code/controllers/subsystem/throwing.dm b/code/controllers/subsystem/throwing.dm index 97d84a0d3b..ec21f3bab2 100644 --- a/code/controllers/subsystem/throwing.dm +++ b/code/controllers/subsystem/throwing.dm @@ -80,7 +80,7 @@ SUBSYSTEM_DEF(throwing) last_move = world.time //calculate how many tiles to move, making up for any missed ticks. - var/tilestomove = Ceiling(min(((((world.time+world.tick_lag) - start_time + delayed_time) * speed) - (dist_travelled ? dist_travelled : -1)), speed*MAX_TICKS_TO_MAKE_UP) * (world.tick_lag * SSthrowing.wait)) + var/tilestomove = CEILING(min(((((world.time+world.tick_lag) - start_time + delayed_time) * speed) - (dist_travelled ? dist_travelled : -1)), speed*MAX_TICKS_TO_MAKE_UP) * (world.tick_lag * SSthrowing.wait), 1) while (tilestomove-- > 0) if ((dist_travelled >= maxrange || AM.loc == target_turf) && AM.has_gravity(AM.loc)) finalize() diff --git a/code/datums/beam.dm b/code/datums/beam.dm index c1a75c8b7e..dc68de933a 100644 --- a/code/datums/beam.dm +++ b/code/datums/beam.dm @@ -128,11 +128,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 diff --git a/code/datums/components/archaeology.dm b/code/datums/components/archaeology.dm index 6fb2b67051..30bf107ad0 100644 --- a/code/datums/components/archaeology.dm +++ b/code/datums/components/archaeology.dm @@ -6,7 +6,7 @@ var/datum/callback/callback /datum/component/archaeology/Initialize(_prob2drop, list/_archdrops = list(), datum/callback/_callback) - prob2drop = Clamp(_prob2drop, 0, 100) + prob2drop = CLAMP(_prob2drop, 0, 100) archdrops = _archdrops callback = _callback RegisterSignal(COMSIG_PARENT_ATTACKBY,.proc/Dig) diff --git a/code/datums/components/decal.dm b/code/datums/components/decal.dm index a28213b0b5..20cc9cd134 100644 --- a/code/datums/components/decal.dm +++ b/code/datums/components/decal.dm @@ -48,7 +48,7 @@ if(old_dir == new_dir) return remove() - var/rotation = SimplifyDegrees(dir2angle(new_dir)-dir2angle(old_dir)) + var/rotation = SIMPLIFY_DEGREES(dir2angle(new_dir)-dir2angle(old_dir)) pic.dir = turn(pic.dir, rotation) apply() diff --git a/code/datums/dash_weapon.dm b/code/datums/dash_weapon.dm index 1637655d18..03badb2069 100644 --- a/code/datums/dash_weapon.dm +++ b/code/datums/dash_weapon.dm @@ -43,7 +43,7 @@ addtimer(CALLBACK(src, .proc/charge), charge_rate) /datum/action/innate/dash/proc/charge() - current_charges = Clamp(current_charges + 1, 0, max_charges) + current_charges = CLAMP(current_charges + 1, 0, max_charges) holder.update_action_buttons_icon() if(recharge_sound) playsound(dashing_item, recharge_sound, 50, 1) diff --git a/code/datums/diseases/advance/advance.dm b/code/datums/diseases/advance/advance.dm index 0c1058a287..60f90d61ad 100644 --- a/code/datums/diseases/advance/advance.dm +++ b/code/datums/diseases/advance/advance.dm @@ -185,10 +185,10 @@ if(properties["stealth"] >= 2) visibility_flags = HIDDEN_SCANNER - SetSpread(Clamp(2 ** (properties["transmittable"] - symptoms.len), VIRUS_SPREAD_BLOOD, VIRUS_SPREAD_AIRBORNE)) + SetSpread(CLAMP(2 ** (properties["transmittable"] - symptoms.len), VIRUS_SPREAD_BLOOD, VIRUS_SPREAD_AIRBORNE)) - permeability_mod = max(Ceiling(0.4 * properties["transmittable"]), 1) - cure_chance = 15 - Clamp(properties["resistance"], -5, 5) // can be between 10 and 20 + permeability_mod = max(CEILING(0.4 * properties["transmittable"], 1), 1) + cure_chance = 15 - CLAMP(properties["resistance"], -5, 5) // can be between 10 and 20 stage_prob = max(properties["stage_rate"], 2) SetSeverity(properties["severity"]) GenerateCure(properties) @@ -243,7 +243,7 @@ // Will generate a random cure, the less resistance the symptoms have, the harder the cure. /datum/disease/advance/proc/GenerateCure() if(properties && properties.len) - var/res = Clamp(properties["resistance"] - (symptoms.len / 2), 1, advance_cures.len) + var/res = CLAMP(properties["resistance"] - (symptoms.len / 2), 1, advance_cures.len) cures = list(advance_cures[res]) // Get the cure name from the cure_id diff --git a/code/datums/explosion.dm b/code/datums/explosion.dm index b71c560193..73b76a9155 100644 --- a/code/datums/explosion.dm +++ b/code/datums/explosion.dm @@ -121,7 +121,7 @@ GLOBAL_LIST_EMPTY(explosions) M.playsound_local(epicenter, null, 100, 1, frequency, falloff = 5, S = explosion_sound) // You hear a far explosion if you're outside the blast radius. Small bombs shouldn't be heard all over the station. else if(dist <= far_dist) - var/far_volume = Clamp(far_dist, 30, 50) // Volume is based on explosion size and dist + var/far_volume = CLAMP(far_dist, 30, 50) // Volume is based on explosion size and dist far_volume += (dist <= far_dist * 0.5 ? 50 : 0) // add 50 volume if the mob is pretty close to the explosion M.playsound_local(epicenter, null, far_volume, 1, frequency, falloff = 5, S = far_explosion_sound) EX_PREPROCESS_CHECK_TICK diff --git a/code/datums/martial/krav_maga.dm b/code/datums/martial/krav_maga.dm index 5c78a0c321..82497adf45 100644 --- a/code/datums/martial/krav_maga.dm +++ b/code/datums/martial/krav_maga.dm @@ -101,7 +101,7 @@ "[A] slams your chest! You can't breathe!") playsound(get_turf(A), 'sound/effects/hit_punch.ogg', 50, 1, -1) if(D.losebreath <= 10) - D.losebreath = Clamp(D.losebreath + 5, 0, 10) + D.losebreath = CLAMP(D.losebreath + 5, 0, 10) D.adjustOxyLoss(10) add_logs(A, D, "quickchoked") return 1 @@ -112,7 +112,7 @@ playsound(get_turf(A), 'sound/effects/hit_punch.ogg', 50, 1, -1) D.apply_damage(5, BRUTE) if(D.silent <= 10) - D.silent = Clamp(D.silent + 10, 0, 10) + D.silent = CLAMP(D.silent + 10, 0, 10) add_logs(A, D, "neck chopped") return 1 diff --git a/code/datums/progressbar.dm b/code/datums/progressbar.dm index f9883cfe50..3599c60f89 100644 --- a/code/datums/progressbar.dm +++ b/code/datums/progressbar.dm @@ -38,7 +38,7 @@ if (user.client) user.client.images += bar - progress = Clamp(progress, 0, goal) + progress = CLAMP(progress, 0, goal) bar.icon_state = "prog_bar_[round(((progress / goal) * 100), 5)]" if (!shown) user.client.images += bar diff --git a/code/datums/radiation_wave.dm b/code/datums/radiation_wave.dm index f065ccfeab..68d8ebc31f 100644 --- a/code/datums/radiation_wave.dm +++ b/code/datums/radiation_wave.dm @@ -34,7 +34,7 @@ var/strength if(steps>1) - strength = InverseSquareLaw(intensity, max(range_modifier*steps, 1), 1) + strength = INVERSE_SQUARE(intensity, max(range_modifier*steps, 1), 1) else strength = intensity @@ -42,7 +42,7 @@ qdel(src) return - radiate(atoms, Floor(strength)) + radiate(atoms, FLOOR(strength, 1)) check_obstructions(atoms) // reduce our overall strength if there are radiation insulators diff --git a/code/datums/status_effects/buffs.dm b/code/datums/status_effects/buffs.dm index 20d218f767..ec4b81acbe 100644 --- a/code/datums/status_effects/buffs.dm +++ b/code/datums/status_effects/buffs.dm @@ -60,8 +60,8 @@ if(istype(L)) //this is probably more safety than actually needed var/vanguard = L.stun_absorption["vanguard"] desc = initial(desc) - desc += "
[Floor(vanguard["stuns_absorbed"] * 0.1)] seconds of stuns held back.\ - [GLOB.ratvar_awakens ? "":"
[Floor(min(vanguard["stuns_absorbed"] * 0.025, 20))] seconds of stun will affect you."]" + desc += "
[FLOOR(vanguard["stuns_absorbed"] * 0.1, 1)] seconds of stuns held back.\ + [GLOB.ratvar_awakens ? "":"
[FLOOR(min(vanguard["stuns_absorbed"] * 0.025, 20), 1)] seconds of stun will affect you."]" ..() /datum/status_effect/vanguard_shield/Destroy() @@ -87,7 +87,7 @@ var/vanguard = owner.stun_absorption["vanguard"] var/stuns_blocked = 0 if(vanguard) - stuns_blocked = Floor(min(vanguard["stuns_absorbed"] * 0.25, 400)) + stuns_blocked = FLOOR(min(vanguard["stuns_absorbed"] * 0.25, 400), 1) vanguard["end_time"] = 0 //so it doesn't absorb the stuns we're about to apply if(owner.stat != DEAD) var/message_to_owner = "You feel your Vanguard quietly fade..." diff --git a/code/datums/status_effects/debuffs.dm b/code/datums/status_effects/debuffs.dm index 2ea1469481..cc64cc2eb8 100644 --- a/code/datums/status_effects/debuffs.dm +++ b/code/datums/status_effects/debuffs.dm @@ -230,7 +230,7 @@ if(prob(severity * 0.15)) to_chat(owner, "\"[text2ratvar(pick(mania_messages))]\"") owner.playsound_local(get_turf(motor), hum, severity, 1) - owner.adjust_drugginess(Clamp(max(severity * 0.075, 1), 0, max(0, 50 - owner.druggy))) //7.5% of severity per second, minimum 1 + owner.adjust_drugginess(CLAMP(max(severity * 0.075, 1), 0, max(0, 50 - owner.druggy))) //7.5% of severity per second, minimum 1 if(owner.hallucination < 50) owner.hallucination = min(owner.hallucination + max(severity * 0.075, 1), 50) //7.5% of severity per second, minimum 1 if(owner.dizziness < 50) @@ -310,7 +310,7 @@ var/icon/I = icon(owner.icon, owner.icon_state, owner.dir) var/icon_height = I.Height() bleed_overlay.pixel_x = -owner.pixel_x - bleed_overlay.pixel_y = Floor(icon_height * 0.25) + bleed_overlay.pixel_y = FLOOR(icon_height * 0.25, 1) bleed_overlay.transform = matrix() * (icon_height/world.icon_size) //scale the bleed overlay's size based on the target's icon size bleed_underlay.pixel_x = -owner.pixel_x bleed_underlay.transform = matrix() * (icon_height/world.icon_size) * 3 diff --git a/code/game/gamemodes/blob/blobs/blob_mobs.dm b/code/game/gamemodes/blob/blobs/blob_mobs.dm index c5c813ecfc..9e4bf51d41 100644 --- a/code/game/gamemodes/blob/blobs/blob_mobs.dm +++ b/code/game/gamemodes/blob/blobs/blob_mobs.dm @@ -42,7 +42,7 @@ /mob/living/simple_animal/hostile/blob/fire_act(exposed_temperature, exposed_volume) ..() if(exposed_temperature) - adjustFireLoss(Clamp(0.01 * exposed_temperature, 1, 5)) + adjustFireLoss(CLAMP(0.01 * exposed_temperature, 1, 5)) else adjustFireLoss(5) diff --git a/code/game/gamemodes/blob/overmind.dm b/code/game/gamemodes/blob/overmind.dm index 4f26563da1..c0516fa2dd 100644 --- a/code/game/gamemodes/blob/overmind.dm +++ b/code/game/gamemodes/blob/overmind.dm @@ -153,7 +153,7 @@ GLOBAL_LIST_EMPTY(blob_nodes) B.hud_used.blobpwrdisplay.maptext = "
[round(blob_core.obj_integrity)]
" /mob/camera/blob/proc/add_points(points) - blob_points = Clamp(blob_points + points, 0, max_blob_points) + blob_points = CLAMP(blob_points + points, 0, max_blob_points) hud_used.blobpwrdisplay.maptext = "
[round(blob_points)]
" /mob/camera/blob/say(message) diff --git a/code/game/gamemodes/clock_cult/clock_effects/clock_sigils.dm b/code/game/gamemodes/clock_cult/clock_effects/clock_sigils.dm index e5a8c9b6f3..19f9e37319 100644 --- a/code/game/gamemodes/clock_cult/clock_effects/clock_sigils.dm +++ b/code/game/gamemodes/clock_cult/clock_effects/clock_sigils.dm @@ -207,7 +207,7 @@ to_chat(cyborg, "You start to charge from the [sigil_name]...") if(!do_after(cyborg, 50, target = src, extra_checks = CALLBACK(src, .proc/cyborg_checks, cyborg, TRUE))) return - var/giving_power = min(Floor(cyborg.cell.maxcharge - cyborg.cell.charge, MIN_CLOCKCULT_POWER), get_clockwork_power()) //give the borg either all our power or their missing power floored to MIN_CLOCKCULT_POWER + var/giving_power = min(FLOOR(cyborg.cell.maxcharge - cyborg.cell.charge, MIN_CLOCKCULT_POWER), get_clockwork_power()) //give the borg either all our power or their missing power floored to MIN_CLOCKCULT_POWER if(adjust_clockwork_power(-giving_power)) cyborg.visible_message("[cyborg] glows a brilliant orange!") var/previous_color = cyborg.color diff --git a/code/game/gamemodes/clock_cult/clock_helpers/fabrication_helpers.dm b/code/game/gamemodes/clock_cult/clock_helpers/fabrication_helpers.dm index a5af47ff05..74f7119193 100644 --- a/code/game/gamemodes/clock_cult/clock_helpers/fabrication_helpers.dm +++ b/code/game/gamemodes/clock_cult/clock_helpers/fabrication_helpers.dm @@ -90,7 +90,7 @@ if(amount_temp < 2) to_chat(user, "You need at least 2 floor tiles to convert into power.") return TRUE - if(IsOdd(amount_temp)) + if(ISODD(amount_temp)) amount_temp-- no_delete = TRUE use(amount_temp) @@ -239,7 +239,7 @@ if(!do_after(user, repair_values["healing_for_cycle"] * fabricator.speed_multiplier, target = src, \ extra_checks = CALLBACK(fabricator, /obj/item/clockwork/replica_fabricator.proc/fabricator_repair_checks, repair_values, src, user, TRUE))) break - obj_integrity = Clamp(obj_integrity + repair_values["healing_for_cycle"], 0, max_integrity) + obj_integrity = CLAMP(obj_integrity + repair_values["healing_for_cycle"], 0, max_integrity) adjust_clockwork_power(-repair_values["power_required"]) playsound(src, 'sound/machines/click.ogg', 50, 1) diff --git a/code/game/gamemodes/clock_cult/clock_scriptures/scripture_applications.dm b/code/game/gamemodes/clock_cult/clock_scriptures/scripture_applications.dm index 5aa626bac5..da1f5965bd 100644 --- a/code/game/gamemodes/clock_cult/clock_scriptures/scripture_applications.dm +++ b/code/game/gamemodes/clock_cult/clock_scriptures/scripture_applications.dm @@ -97,7 +97,7 @@ if(ishuman(M.current)) human_servants++ construct_limit = human_servants / 4 //1 per 4 human servants, and a maximum of 3 marauders - construct_limit = Clamp(construct_limit, 1, 3) + construct_limit = CLAMP(construct_limit, 1, 3) /datum/clockwork_scripture/create_object/construct/clockwork_marauder/pre_recital() channel_time = initial(channel_time) diff --git a/code/game/gamemodes/clock_cult/clock_structures/mania_motor.dm b/code/game/gamemodes/clock_cult/clock_structures/mania_motor.dm index b95d9cc0db..447b077d87 100644 --- a/code/game/gamemodes/clock_cult/clock_structures/mania_motor.dm +++ b/code/game/gamemodes/clock_cult/clock_structures/mania_motor.dm @@ -60,4 +60,4 @@ break if(!M) M = H.apply_status_effect(STATUS_EFFECT_MANIAMOTOR, src) - M.severity = Clamp(M.severity + ((11 - get_dist(src, H)) * efficiency * efficiency), 0, MAX_MANIA_SEVERITY) + M.severity = CLAMP(M.severity + ((11 - get_dist(src, H)) * efficiency * efficiency), 0, MAX_MANIA_SEVERITY) diff --git a/code/game/gamemodes/clock_cult/clock_structures/taunting_trail.dm b/code/game/gamemodes/clock_cult/clock_structures/taunting_trail.dm index 9d4667ee9f..e417cbbc32 100644 --- a/code/game/gamemodes/clock_cult/clock_structures/taunting_trail.dm +++ b/code/game/gamemodes/clock_cult/clock_structures/taunting_trail.dm @@ -57,5 +57,5 @@ L.confused = min(L.confused + 15, 50) L.dizziness = min(L.dizziness + 15, 50) if(L.confused >= 25) - L.Knockdown(Floor(L.confused * 0.8)) + L.Knockdown(FLOOR(L.confused * 0.8, 1)) take_damage(max_integrity) diff --git a/code/game/gamemodes/meteor/meteor.dm b/code/game/gamemodes/meteor/meteor.dm index b7a6580570..4918e94131 100644 --- a/code/game/gamemodes/meteor/meteor.dm +++ b/code/game/gamemodes/meteor/meteor.dm @@ -25,7 +25,7 @@ if (prob(meteorminutes/2)) wavetype = GLOB.meteors_catastrophic - var/ramp_up_final = Clamp(round(meteorminutes/rampupdelta), 1, 10) + var/ramp_up_final = CLAMP(round(meteorminutes/rampupdelta), 1, 10) spawn_meteors(ramp_up_final, wavetype) diff --git a/code/game/gamemodes/nuclear/nuclearbomb.dm b/code/game/gamemodes/nuclear/nuclearbomb.dm index 908ecd797f..e35eaed9f1 100644 --- a/code/game/gamemodes/nuclear/nuclearbomb.dm +++ b/code/game/gamemodes/nuclear/nuclearbomb.dm @@ -353,7 +353,7 @@ var/N = text2num(user_input) if(!N) return - timer_set = Clamp(N,minimum_timer_set,maximum_timer_set) + timer_set = CLAMP(N,minimum_timer_set,maximum_timer_set) . = TRUE if("safety") if(auth && yes_code) diff --git a/code/game/machinery/computer/apc_control.dm b/code/game/machinery/computer/apc_control.dm index cbdc28883f..e9390a3cf5 100644 --- a/code/game/machinery/computer/apc_control.dm +++ b/code/game/machinery/computer/apc_control.dm @@ -161,7 +161,7 @@ return log_activity("changed greater than charge filter to \"[new_filter]\"") if(new_filter) - new_filter = Clamp(new_filter, 0, 100) + new_filter = CLAMP(new_filter, 0, 100) playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, 0) result_filters["Charge Above"] = new_filter if(href_list["below_filter"]) @@ -171,7 +171,7 @@ return log_activity("changed lesser than charge filter to \"[new_filter]\"") if(new_filter) - new_filter = Clamp(new_filter, 0, 100) + new_filter = CLAMP(new_filter, 0, 100) playsound(src, 'sound/machines/terminal_prompt_confirm.ogg', 50, 0) result_filters["Charge Below"] = new_filter if(href_list["access_filter"]) diff --git a/code/game/machinery/computer/atmos_control.dm b/code/game/machinery/computer/atmos_control.dm index 2d1d771203..a4881546cf 100644 --- a/code/game/machinery/computer/atmos_control.dm +++ b/code/game/machinery/computer/atmos_control.dm @@ -211,7 +211,7 @@ if("pressure") var/target = input("New target pressure:", name, output_info ? output_info["internal"] : 0) as num|null if(!isnull(target) && !..()) - target = Clamp(target, 0, 50 * ONE_ATMOSPHERE) + target = CLAMP(target, 0, 50 * ONE_ATMOSPHERE) signal.data += list("tag" = output_tag, "set_internal_pressure" = target) . = TRUE radio_connection.post_signal(src, signal, filter = GLOB.RADIO_ATMOSIA) diff --git a/code/game/machinery/computer/dna_console.dm b/code/game/machinery/computer/dna_console.dm index 9fa196bd46..7bbd545981 100644 --- a/code/game/machinery/computer/dna_console.dm +++ b/code/game/machinery/computer/dna_console.dm @@ -337,12 +337,12 @@ if(!num) num = round(input(usr, "Choose pulse duration:", "Input an Integer", null) as num|null) if(num) - radduration = Wrap(num, 1, RADIATION_DURATION_MAX+1) + radduration = WRAP(num, 1, RADIATION_DURATION_MAX+1) if("setstrength") if(!num) num = round(input(usr, "Choose pulse strength:", "Input an Integer", null) as num|null) if(num) - radstrength = Wrap(num, 1, RADIATION_STRENGTH_MAX+1) + radstrength = WRAP(num, 1, RADIATION_STRENGTH_MAX+1) if("screen") current_screen = href_list["text"] if("rejuv") @@ -353,13 +353,13 @@ if("setbufferlabel") var/text = sanitize(input(usr, "Input a new label:", "Input an Text", null) as text|null) if(num && text) - num = Clamp(num, 1, NUMBER_OF_BUFFERS) + num = CLAMP(num, 1, NUMBER_OF_BUFFERS) var/list/buffer_slot = buffer[num] if(istype(buffer_slot)) buffer_slot["label"] = text if("setbuffer") if(num && viable_occupant) - num = Clamp(num, 1, NUMBER_OF_BUFFERS) + num = CLAMP(num, 1, NUMBER_OF_BUFFERS) buffer[num] = list( "label"="Buffer[num]:[viable_occupant.real_name]", "UI"=viable_occupant.dna.uni_identity, @@ -370,7 +370,7 @@ ) if("clearbuffer") if(num) - num = Clamp(num, 1, NUMBER_OF_BUFFERS) + num = CLAMP(num, 1, NUMBER_OF_BUFFERS) var/list/buffer_slot = buffer[num] if(istype(buffer_slot)) buffer_slot.Cut() @@ -387,7 +387,7 @@ apply_buffer(SCANNER_ACTION_MIXED,num) if("injector") if(num && injectorready < world.time) - num = Clamp(num, 1, NUMBER_OF_BUFFERS) + num = CLAMP(num, 1, NUMBER_OF_BUFFERS) var/list/buffer_slot = buffer[num] if(istype(buffer_slot)) var/obj/item/dnainjector/timed/I @@ -436,11 +436,11 @@ injectorready = world.time + INJECTOR_TIMEOUT if("loaddisk") if(num && diskette && diskette.fields) - num = Clamp(num, 1, NUMBER_OF_BUFFERS) + num = CLAMP(num, 1, NUMBER_OF_BUFFERS) buffer[num] = diskette.fields.Copy() if("savedisk") if(num && diskette && !diskette.read_only) - num = Clamp(num, 1, NUMBER_OF_BUFFERS) + num = CLAMP(num, 1, NUMBER_OF_BUFFERS) var/list/buffer_slot = buffer[num] if(istype(buffer_slot)) diskette.name = "data disk \[[buffer_slot["label"]]\]" @@ -454,8 +454,8 @@ delayed_action = list("action"=text2num(href_list["delayaction"]),"buffer"=num) if("pulseui","pulsese") if(num && viable_occupant && connected) - radduration = Wrap(radduration, 1, RADIATION_DURATION_MAX+1) - radstrength = Wrap(radstrength, 1, RADIATION_STRENGTH_MAX+1) + radduration = WRAP(radduration, 1, RADIATION_DURATION_MAX+1) + radstrength = WRAP(radstrength, 1, RADIATION_STRENGTH_MAX+1) var/locked_state = connected.locked connected.locked = TRUE @@ -471,7 +471,7 @@ switch(href_list["task"]) //Same thing as there but values are even lower, on best part they are about 0.0*, effectively no damage if("pulseui") var/len = length(viable_occupant.dna.uni_identity) - num = Wrap(num, 1, len+1) + num = WRAP(num, 1, len+1) num = randomize_radiation_accuracy(num, radduration + (connected.precision_coeff ** 2), len) //Each manipulator level above 1 makes randomization as accurate as selected time + manipulator lvl^2 //Value is this high for the same reason as with laser - not worth the hassle of upgrading if the bonus is low var/block = round((num-1)/DNA_BLOCK_SIZE)+1 @@ -487,7 +487,7 @@ viable_occupant.updateappearance(mutations_overlay_update=1) if("pulsese") var/len = length(viable_occupant.dna.struc_enzymes) - num = Wrap(num, 1, len+1) + num = WRAP(num, 1, len+1) num = randomize_radiation_accuracy(num, radduration + (connected.precision_coeff ** 2), len) var/block = round((num-1)/DNA_BLOCK_SIZE)+1 @@ -518,10 +518,11 @@ ran = round(ran) //negative, so floor it else ran = -round(-ran) //positive, so ceiling it - return num2hex(Wrap(hex2num(input)+ran, 0, 16**length), length) + return num2hex(WRAP(hex2num(input)+ran, 0, 16**length), length) -/obj/machinery/computer/scan_consolenew/proc/randomize_radiation_accuracy(position_we_were_supposed_to_hit, radduration, number_of_blocks) - return Wrap(round(position_we_were_supposed_to_hit + gaussian(0, RADIATION_ACCURACY_MULTIPLIER/radduration), 1), 1, number_of_blocks+1) +/obj/machinery/computer/scan_consolenew/proc/randomize_radiation_accuracy(position, radduration, number_of_blocks) + var/val = round(gaussian(0, RADIATION_ACCURACY_MULTIPLIER/radduration) + position, 1) + return WRAP(val, 1, number_of_blocks+1) /obj/machinery/computer/scan_consolenew/proc/get_viable_occupant() var/mob/living/carbon/viable_occupant = null @@ -532,7 +533,7 @@ return viable_occupant /obj/machinery/computer/scan_consolenew/proc/apply_buffer(action,buffer_num) - buffer_num = Clamp(buffer_num, 1, NUMBER_OF_BUFFERS) + buffer_num = CLAMP(buffer_num, 1, NUMBER_OF_BUFFERS) var/list/buffer_slot = buffer[buffer_num] var/mob/living/carbon/viable_occupant = get_viable_occupant() if(istype(buffer_slot)) diff --git a/code/game/machinery/computer/gulag_teleporter.dm b/code/game/machinery/computer/gulag_teleporter.dm index 36da1288a9..2419dd2299 100644 --- a/code/game/machinery/computer/gulag_teleporter.dm +++ b/code/game/machinery/computer/gulag_teleporter.dm @@ -106,7 +106,7 @@ return if(!new_goal) new_goal = default_goal - id.goal = Clamp(new_goal, 0, 1000) //maximum 1000 points + id.goal = CLAMP(new_goal, 0, 1000) //maximum 1000 points if("toggle_open") if(teleporter.locked) to_chat(usr, "The teleporter is locked") diff --git a/code/game/machinery/computer/telecrystalconsoles.dm b/code/game/machinery/computer/telecrystalconsoles.dm index 959253036b..6670bfbfa7 100644 --- a/code/game/machinery/computer/telecrystalconsoles.dm +++ b/code/game/machinery/computer/telecrystalconsoles.dm @@ -154,8 +154,14 @@ GLOBAL_LIST_INIT(possible_uplinker_IDs, list("Alfa","Bravo","Charlie","Delta","E /obj/machinery/computer/telecrystals/boss/proc/getDangerous()//This scales the TC assigned with the round population. ..() +<<<<<<< HEAD var/danger = GLOB.joined_player_list.len - SSticker.mode.syndicates.len danger = Ceiling(danger, 10) +======= + var/list/nukeops = get_antagonists(/datum/antagonist/nukeop) + var/danger = GLOB.joined_player_list.len - nukeops.len + danger = CEILING(danger, 10) +>>>>>>> 25080ff... defines math (#33498) scaleTC(danger) /obj/machinery/computer/telecrystals/boss/proc/scaleTC(amt)//Its own proc, since it'll probably need a lot of tweaks for balance, use a fancier algorhithm, etc. diff --git a/code/game/machinery/deployable.dm b/code/game/machinery/deployable.dm index f0e1e8a18a..b9a2a68b34 100644 --- a/code/game/machinery/deployable.dm +++ b/code/game/machinery/deployable.dm @@ -33,7 +33,7 @@ to_chat(user, "You begin repairing [src]...") playsound(loc, WT.usesound, 40, 1) if(do_after(user, 40*I.toolspeed, target = src)) - obj_integrity = Clamp(obj_integrity + 20, 0, max_integrity) + obj_integrity = CLAMP(obj_integrity + 20, 0, max_integrity) else return ..() diff --git a/code/game/machinery/doors/brigdoors.dm b/code/game/machinery/doors/brigdoors.dm index 4c0d4a1804..a622f0af3d 100644 --- a/code/game/machinery/doors/brigdoors.dm +++ b/code/game/machinery/doors/brigdoors.dm @@ -142,7 +142,7 @@ . /= 10 /obj/machinery/door_timer/proc/set_timer(value) - var/new_time = Clamp(value,0,MAX_TIMER) + var/new_time = CLAMP(value,0,MAX_TIMER) . = new_time == timer_duration //return 1 on no change timer_duration = new_time diff --git a/code/game/machinery/pipe/pipe_dispenser.dm b/code/game/machinery/pipe/pipe_dispenser.dm index 06cdfcda7d..a67ce24c9c 100644 --- a/code/game/machinery/pipe/pipe_dispenser.dm +++ b/code/game/machinery/pipe/pipe_dispenser.dm @@ -53,9 +53,9 @@ new /obj/item/pipe_meter(loc) wait = world.time + 15 if(href_list["layer_up"]) - piping_layer = Clamp(++piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX) + piping_layer = CLAMP(++piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX) if(href_list["layer_down"]) - piping_layer = Clamp(--piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX) + piping_layer = CLAMP(--piping_layer, PIPING_LAYER_MIN, PIPING_LAYER_MAX) return /obj/machinery/pipedispenser/attackby(obj/item/W, mob/user, params) diff --git a/code/game/machinery/shieldgen.dm b/code/game/machinery/shieldgen.dm index 9356314973..cdbdb195cc 100644 --- a/code/game/machinery/shieldgen.dm +++ b/code/game/machinery/shieldgen.dm @@ -256,7 +256,7 @@ use_stored_power(50) /obj/machinery/shieldwallgen/proc/use_stored_power(amount) - power = Clamp(power - amount, 0, maximum_stored_power) + power = CLAMP(power - amount, 0, maximum_stored_power) update_activity() /obj/machinery/shieldwallgen/proc/update_activity() diff --git a/code/game/machinery/spaceheater.dm b/code/game/machinery/spaceheater.dm index b45b393ab2..f7a18ff246 100644 --- a/code/game/machinery/spaceheater.dm +++ b/code/game/machinery/spaceheater.dm @@ -121,7 +121,7 @@ settableTemperatureRange = cap * 30 efficiency = (cap + 1) * 10000 - targetTemperature = Clamp(targetTemperature, + targetTemperature = CLAMP(targetTemperature, max(settableTemperatureMedian - settableTemperatureRange, TCMB), settableTemperatureMedian + settableTemperatureRange) @@ -223,7 +223,7 @@ target= text2num(target) + T0C . = TRUE if(.) - targetTemperature = Clamp(round(target), + targetTemperature = CLAMP(round(target), max(settableTemperatureMedian - settableTemperatureRange, TCMB), settableTemperatureMedian + settableTemperatureRange) if("eject") diff --git a/code/game/machinery/syndicatebomb.dm b/code/game/machinery/syndicatebomb.dm index 5b510d965e..528faba57f 100644 --- a/code/game/machinery/syndicatebomb.dm +++ b/code/game/machinery/syndicatebomb.dm @@ -205,7 +205,7 @@ /obj/machinery/syndicatebomb/proc/settings(mob/user) var/new_timer = input(user, "Please set the timer.", "Timer", "[timer_set]") as num if(in_range(src, user) && isliving(user)) //No running off and setting bombs from across the station - timer_set = Clamp(new_timer, minimum_timer, maximum_timer) + timer_set = CLAMP(new_timer, minimum_timer, maximum_timer) loc.visible_message("[icon2html(src, viewers(src))] timer set for [timer_set] seconds.") if(alert(user,"Would you like to start the countdown now?",,"Yes","No") == "Yes" && in_range(src, user) && isliving(user)) if(defused || active) diff --git a/code/game/machinery/vending.dm b/code/game/machinery/vending.dm index bfa89db368..d3598d4866 100644 --- a/code/game/machinery/vending.dm +++ b/code/game/machinery/vending.dm @@ -175,7 +175,7 @@ for(var/datum/data/vending_product/machine_content in machine) if(refill.charges[charge_type] == 0) break - var/restock = Ceiling(((machine_content.max_amount - machine_content.amount)/to_restock)*tmp_charges) + var/restock = CEILING(((machine_content.max_amount - machine_content.amount)/to_restock)*tmp_charges, 1) if(restock > refill.charges[charge_type]) restock = refill.charges[charge_type] machine_content.amount += restock diff --git a/code/game/mecha/mech_fabricator.dm b/code/game/mecha/mech_fabricator.dm index 1766a8cc3a..6ef98120f5 100644 --- a/code/game/mecha/mech_fabricator.dm +++ b/code/game/mecha/mech_fabricator.dm @@ -188,7 +188,7 @@ return queue.len /obj/machinery/mecha_part_fabricator/proc/remove_from_queue(index) - if(!isnum(index) || !IsInteger(index) || !istype(queue) || (index<1 || index>queue.len)) + if(!isnum(index) || !ISINTEGER(index) || !istype(queue) || (index<1 || index>queue.len)) return FALSE queue.Cut(index,++index) return TRUE @@ -375,8 +375,8 @@ if(href_list["queue_move"] && href_list["index"]) var/index = afilter.getNum("index") var/new_index = index + afilter.getNum("queue_move") - if(isnum(index) && isnum(new_index) && IsInteger(index) && IsInteger(new_index)) - if(IsInRange(new_index,1,queue.len)) + if(isnum(index) && isnum(new_index) && ISINTEGER(index) && ISINTEGER(new_index)) + if(ISINRANGE(new_index,1,queue.len)) queue.Swap(index,new_index) return update_queue_on_page() if(href_list["clear_queue"]) diff --git a/code/game/mecha/working/ripley.dm b/code/game/mecha/working/ripley.dm index 5688214044..a7115abd1d 100644 --- a/code/game/mecha/working/ripley.dm +++ b/code/game/mecha/working/ripley.dm @@ -94,7 +94,7 @@ /obj/mecha/working/ripley/mining/Initialize() . = ..() if(cell) - cell.charge = Floor(cell.charge * 0.25) //Starts at very low charge + cell.charge = FLOOR(cell.charge * 0.25, 1) //Starts at very low charge if(prob(70)) //Maybe add a drill if(prob(15)) //Possible diamond drill... Feeling lucky? var/obj/item/mecha_parts/mecha_equipment/drill/diamonddrill/D = new diff --git a/code/game/objects/effects/anomalies.dm b/code/game/objects/effects/anomalies.dm index 04737f2e4c..70a6f1bdba 100644 --- a/code/game/objects/effects/anomalies.dm +++ b/code/game/objects/effects/anomalies.dm @@ -27,8 +27,13 @@ aSignal.name = "[name] core" aSignal.code = rand(1,100) +<<<<<<< HEAD aSignal.frequency = rand(1200, 1599) if(IsMultiple(aSignal.frequency, 2))//signaller frequencies are always uneven! +======= + aSignal.frequency = rand(MIN_FREE_FREQ, MAX_FREE_FREQ) + if(ISMULTIPLE(aSignal.frequency, 2))//signaller frequencies are always uneven! +>>>>>>> 25080ff... defines math (#33498) aSignal.frequency++ if(new_lifespan) diff --git a/code/game/objects/items/chrono_eraser.dm b/code/game/objects/items/chrono_eraser.dm index 8ac9643c39..11336cd06a 100644 --- a/code/game/objects/items/chrono_eraser.dm +++ b/code/game/objects/items/chrono_eraser.dm @@ -187,7 +187,7 @@ /obj/effect/chrono_field/update_icon() var/ttk_frame = 1 - (tickstokill / initial(tickstokill)) - ttk_frame = Clamp(Ceiling(ttk_frame * CHRONO_FRAME_COUNT), 1, CHRONO_FRAME_COUNT) + ttk_frame = CLAMP(CEILING(ttk_frame * CHRONO_FRAME_COUNT, 1), 1, CHRONO_FRAME_COUNT) if(ttk_frame != RPpos) RPpos = ttk_frame mob_underlay.icon_state = "frame[RPpos]" diff --git a/code/game/objects/items/defib.dm b/code/game/objects/items/defib.dm index bbeed24168..afed9c4b4c 100644 --- a/code/game/objects/items/defib.dm +++ b/code/game/objects/items/defib.dm @@ -69,7 +69,7 @@ if(powered) //so it doesn't show charge if it's unpowered if(cell) var/ratio = cell.charge / cell.maxcharge - ratio = Ceiling(ratio*4) * 25 + ratio = CEILING(ratio*4, 1) * 25 add_overlay("[initial(icon_state)]-charge[ratio]") /obj/item/defibrillator/CheckParts(list/parts_list) diff --git a/code/game/objects/items/devices/lightreplacer.dm b/code/game/objects/items/devices/lightreplacer.dm index cdd95a2f71..4ea91ccccf 100644 --- a/code/game/objects/items/devices/lightreplacer.dm +++ b/code/game/objects/items/devices/lightreplacer.dm @@ -169,7 +169,7 @@ // Negative numbers will subtract /obj/item/device/lightreplacer/proc/AddUses(amount = 1) - uses = Clamp(uses + amount, 0, max_uses) + uses = CLAMP(uses + amount, 0, max_uses) /obj/item/device/lightreplacer/proc/AddShards(amount = 1, user) bulb_shards += amount diff --git a/code/game/objects/items/devices/traitordevices.dm b/code/game/objects/items/devices/traitordevices.dm index 338f113afb..5afc8602ff 100644 --- a/code/game/objects/items/devices/traitordevices.dm +++ b/code/game/objects/items/devices/traitordevices.dm @@ -228,7 +228,7 @@ effective or pretty fucking useless. charge = max(0,charge - 25)//Quick decrease in light else charge = min(max_charge,charge + 50) //Charge in the dark - animate(user,alpha = Clamp(255 - charge,0,255),time = 10) + animate(user,alpha = CLAMP(255 - charge,0,255),time = 10) /obj/item/device/jammer diff --git a/code/game/objects/items/dice.dm b/code/game/objects/items/dice.dm index 334be4a645..e14363a1c1 100644 --- a/code/game/objects/items/dice.dm +++ b/code/game/objects/items/dice.dm @@ -166,7 +166,7 @@ /obj/item/dice/proc/diceroll(mob/user) result = rand(1, sides) if(rigged && result != rigged) - if(prob(Clamp(1/(sides - 1) * 100, 25, 80))) + if(prob(CLAMP(1/(sides - 1) * 100, 25, 80))) result = rigged var/fake_result = rand(1, sides)//Daredevil isn't as good as he used to be var/comment = "" diff --git a/code/game/objects/items/grenades/plastic.dm b/code/game/objects/items/grenades/plastic.dm index dd0d397e81..0375e5529e 100644 --- a/code/game/objects/items/grenades/plastic.dm +++ b/code/game/objects/items/grenades/plastic.dm @@ -87,7 +87,7 @@ return var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num if(user.get_active_held_item() == src) - newtime = Clamp(newtime, 10, 60000) + newtime = CLAMP(newtime, 10, 60000) det_time = newtime to_chat(user, "Timer set for [det_time] seconds.") @@ -204,7 +204,7 @@ /obj/item/grenade/plastic/c4/attack_self(mob/user) var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num if(user.get_active_held_item() == src) - newtime = Clamp(newtime, 10, 60000) + newtime = CLAMP(newtime, 10, 60000) timer = newtime to_chat(user, "Timer set for [timer] seconds.") diff --git a/code/game/objects/items/his_grace.dm b/code/game/objects/items/his_grace.dm index 98121f7772..d13d6cc1dd 100644 --- a/code/game/objects/items/his_grace.dm +++ b/code/game/objects/items/his_grace.dm @@ -75,7 +75,7 @@ drowse() return if(bloodthirst < HIS_GRACE_CONSUME_OWNER) - adjust_bloodthirst(1 + Floor(LAZYLEN(contents) * 0.5)) //Maybe adjust this? + adjust_bloodthirst(1 + FLOOR(LAZYLEN(contents) * 0.5, 1)) //Maybe adjust this? else adjust_bloodthirst(1) //don't cool off rapidly once we're at the point where His Grace consumes all. var/mob/living/master = get_atom_on_turf(src, /mob/living) @@ -164,9 +164,9 @@ /obj/item/his_grace/proc/adjust_bloodthirst(amt) prev_bloodthirst = bloodthirst if(prev_bloodthirst < HIS_GRACE_CONSUME_OWNER) - bloodthirst = Clamp(bloodthirst + amt, HIS_GRACE_SATIATED, HIS_GRACE_CONSUME_OWNER) + bloodthirst = CLAMP(bloodthirst + amt, HIS_GRACE_SATIATED, HIS_GRACE_CONSUME_OWNER) else - bloodthirst = Clamp(bloodthirst + amt, HIS_GRACE_CONSUME_OWNER, HIS_GRACE_FALL_ASLEEP) + bloodthirst = CLAMP(bloodthirst + amt, HIS_GRACE_CONSUME_OWNER, HIS_GRACE_FALL_ASLEEP) update_stats() /obj/item/his_grace/proc/update_stats() diff --git a/code/game/objects/items/pneumaticCannon.dm b/code/game/objects/items/pneumaticCannon.dm index 9bf0b949c0..8baeee3550 100644 --- a/code/game/objects/items/pneumaticCannon.dm +++ b/code/game/objects/items/pneumaticCannon.dm @@ -198,8 +198,8 @@ return target var/x_o = (target.x - starting.x) var/y_o = (target.y - starting.y) - var/new_x = Clamp((starting.x + (x_o * range_multiplier)), 0, world.maxx) - var/new_y = Clamp((starting.y + (y_o * range_multiplier)), 0, world.maxy) + var/new_x = CLAMP((starting.x + (x_o * range_multiplier)), 0, world.maxx) + var/new_y = CLAMP((starting.y + (y_o * range_multiplier)), 0, world.maxy) var/turf/newtarget = locate(new_x, new_y, starting.z) return newtarget diff --git a/code/game/objects/items/robot/robot_items.dm b/code/game/objects/items/robot/robot_items.dm index e4485266b5..97e6752efb 100644 --- a/code/game/objects/items/robot/robot_items.dm +++ b/code/game/objects/items/robot/robot_items.dm @@ -616,7 +616,7 @@ continue usage += projectile_tick_speed_ecost usage += (tracked[I] * projectile_damage_tick_ecost_coefficient) - energy = Clamp(energy - usage, 0, maxenergy) + energy = CLAMP(energy - usage, 0, maxenergy) if(energy <= 0) deactivate_field() visible_message("[src] blinks \"ENERGY DEPLETED\".") @@ -626,7 +626,7 @@ if(iscyborg(host.loc)) host = host.loc else - energy = Clamp(energy + energy_recharge, 0, maxenergy) + energy = CLAMP(energy + energy_recharge, 0, maxenergy) return if((host.cell.charge >= (host.cell.maxcharge * cyborg_cell_critical_percentage)) && (energy < maxenergy)) host.cell.use(energy_recharge*energy_recharge_cyborg_drain_coefficient) diff --git a/code/game/objects/items/sharpener.dm b/code/game/objects/items/sharpener.dm index fb25cb1d76..93056adc99 100644 --- a/code/game/objects/items/sharpener.dm +++ b/code/game/objects/items/sharpener.dm @@ -35,14 +35,14 @@ if(TH.force_wielded > initial(TH.force_wielded)) to_chat(user, "[TH] has already been refined before. It cannot be sharpened further!") return - TH.force_wielded = Clamp(TH.force_wielded + increment, 0, max)//wieldforce is increased since normal force wont stay + TH.force_wielded = CLAMP(TH.force_wielded + increment, 0, max)//wieldforce is increased since normal force wont stay if(I.force > initial(I.force)) to_chat(user, "[I] has already been refined before. It cannot be sharpened further!") return user.visible_message("[user] sharpens [I] with [src]!", "You sharpen [I], making it much more deadly than before.") I.sharpness = IS_SHARP_ACCURATE - I.force = Clamp(I.force + increment, 0, max) - I.throwforce = Clamp(I.throwforce + increment, 0, max) + I.force = CLAMP(I.force + increment, 0, max) + I.throwforce = CLAMP(I.throwforce + increment, 0, max) I.name = "[prefix] [I.name]" name = "worn out [name]" desc = "[desc] At least, it used to." diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm index 1faad3462b..7cea6d71e8 100644 --- a/code/game/objects/items/stacks/stack.dm +++ b/code/game/objects/items/stacks/stack.dm @@ -37,9 +37,9 @@ /obj/item/stack/proc/update_weight() if(amount <= (max_amount * (1/3))) - w_class = Clamp(full_w_class-2, WEIGHT_CLASS_TINY, full_w_class) + w_class = CLAMP(full_w_class-2, WEIGHT_CLASS_TINY, full_w_class) else if (amount <= (max_amount * (2/3))) - w_class = Clamp(full_w_class-1, WEIGHT_CLASS_TINY, full_w_class) + w_class = CLAMP(full_w_class-1, WEIGHT_CLASS_TINY, full_w_class) else w_class = full_w_class diff --git a/code/game/objects/items/tanks/tanks.dm b/code/game/objects/items/tanks/tanks.dm index 3d1c091a2b..0109b67b00 100644 --- a/code/game/objects/items/tanks/tanks.dm +++ b/code/game/objects/items/tanks/tanks.dm @@ -194,7 +194,7 @@ pressure = text2num(pressure) . = TRUE if(.) - distribute_pressure = Clamp(round(pressure), TANK_MIN_RELEASE_PRESSURE, TANK_MAX_RELEASE_PRESSURE) + distribute_pressure = CLAMP(round(pressure), TANK_MIN_RELEASE_PRESSURE, TANK_MAX_RELEASE_PRESSURE) /obj/item/tank/remove_air(amount) return air_contents.remove(amount) diff --git a/code/game/objects/items/tools/weldingtool.dm b/code/game/objects/items/tools/weldingtool.dm index 1c20c95e93..415cd02585 100644 --- a/code/game/objects/items/tools/weldingtool.dm +++ b/code/game/objects/items/tools/weldingtool.dm @@ -1,3 +1,4 @@ +<<<<<<< HEAD #define WELDER_FUEL_BURN_INTERVAL 13 /obj/item/weldingtool name = "welding tool" @@ -336,4 +337,350 @@ if(get_fuel() < max_fuel && nextrefueltick < world.time) nextrefueltick = world.time + 10 reagents.add_reagent("welding_fuel", 1) +======= +#define WELDER_FUEL_BURN_INTERVAL 13 +/obj/item/weldingtool + name = "welding tool" + desc = "A standard edition welder provided by Nanotrasen." + icon = 'icons/obj/tools.dmi' + icon_state = "welder" + item_state = "welder" + lefthand_file = 'icons/mob/inhands/equipment/tools_lefthand.dmi' + righthand_file = 'icons/mob/inhands/equipment/tools_righthand.dmi' + flags_1 = CONDUCT_1 + slot_flags = SLOT_BELT + force = 3 + throwforce = 5 + hitsound = "swing_hit" + usesound = 'sound/items/welder.ogg' + var/acti_sound = 'sound/items/welderactivate.ogg' + var/deac_sound = 'sound/items/welderdeactivate.ogg' + throw_speed = 3 + throw_range = 5 + w_class = WEIGHT_CLASS_SMALL + armor = list(melee = 0, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0, fire = 100, acid = 30) + resistance_flags = FIRE_PROOF + + materials = list(MAT_METAL=70, MAT_GLASS=30) + var/welding = 0 //Whether or not the welding tool is off(0), on(1) or currently welding(2) + var/status = TRUE //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/change_icons = 1 + var/can_off_process = 0 + var/light_intensity = 2 //how powerful the emitted light is when used. + var/burned_fuel_for = 0 //when fuel was last removed + heat = 3800 + toolspeed = 1 + +/obj/item/weldingtool/Initialize() + . = ..() + create_reagents(max_fuel) + reagents.add_reagent("welding_fuel", max_fuel) + update_icon() + + +/obj/item/weldingtool/proc/update_torch() + if(welding) + add_overlay("[initial(icon_state)]-on") + item_state = "[initial(item_state)]1" + else + item_state = "[initial(item_state)]" + + +/obj/item/weldingtool/update_icon() + cut_overlays() + if(change_icons) + var/ratio = get_fuel() / max_fuel + ratio = CEILING(ratio*4, 1) * 25 + add_overlay("[initial(icon_state)][ratio]") + update_torch() + return + + +/obj/item/weldingtool/process() + switch(welding) + if(0) + force = 3 + damtype = "brute" + update_icon() + if(!can_off_process) + STOP_PROCESSING(SSobj, src) + return + //Welders left on now use up fuel, but lets not have them run out quite that fast + if(1) + force = 15 + damtype = "fire" + ++burned_fuel_for + if(burned_fuel_for >= WELDER_FUEL_BURN_INTERVAL) + remove_fuel(1) + update_icon() + + //This is to start fires. process() is only called if the welder is on. + open_flame() + + +/obj/item/weldingtool/suicide_act(mob/user) + user.visible_message("[user] welds [user.p_their()] every orifice closed! It looks like [user.p_theyre()] trying to commit suicide!") + return (FIRELOSS) + + +/obj/item/weldingtool/attackby(obj/item/I, mob/user, params) + if(istype(I, /obj/item/screwdriver)) + flamethrower_screwdriver(I, user) + else if(istype(I, /obj/item/stack/rods)) + flamethrower_rods(I, user) + else + . = ..() + update_icon() + +/obj/item/weldingtool/proc/explode() + var/turf/T = get_turf(loc) + var/plasmaAmount = reagents.get_reagent_amount("plasma") + dyn_explosion(T, plasmaAmount/5)//20 plasma in a standard welder has a 4 power explosion. no breaches, but enough to kill/dismember holder + qdel(src) + +/obj/item/weldingtool/attack(mob/living/carbon/human/H, mob/user) + if(!istype(H)) + return ..() + + var/obj/item/bodypart/affecting = H.get_bodypart(check_zone(user.zone_selected)) + + if(affecting && affecting.status == BODYPART_ROBOTIC && user.a_intent != INTENT_HARM) + if(src.remove_fuel(1)) + playsound(loc, usesound, 50, 1) + if(user == H) + user.visible_message("[user] starts to fix some of the dents on [H]'s [affecting.name].", "You start fixing some of the dents on [H]'s [affecting.name].") + if(!do_mob(user, H, 50)) + return + item_heal_robotic(H, user, 15, 0) + else + return ..() + + +/obj/item/weldingtool/afterattack(atom/O, mob/user, proximity) + if(!proximity) + return + if(!status && istype(O, /obj/item/reagent_containers) && O.is_open_container()) + reagents.trans_to(O, reagents.total_volume) + to_chat(user, "You empty [src]'s fuel tank into [O].") + update_icon() + if(welding) + remove_fuel(1) + var/turf/location = get_turf(user) + location.hotspot_expose(700, 50, 1) + if(get_fuel() <= 0) + set_light(0) + + if(isliving(O)) + var/mob/living/L = O + if(L.IgniteMob()) + message_admins("[key_name_admin(user)] set [key_name_admin(L)] on fire") + log_game("[key_name(user)] set [key_name(L)] on fire") + + +/obj/item/weldingtool/attack_self(mob/user) + if(src.reagents.has_reagent("plasma")) + message_admins("[key_name_admin(user)] activated a rigged welder.") + explode() + switched_on(user) + if(welding) + set_light(light_intensity) + + update_icon() + + +//Returns the amount of fuel in the welder +/obj/item/weldingtool/proc/get_fuel() + return reagents.get_reagent_amount("welding_fuel") + + +//Removes fuel from the welding tool. If a mob is passed, it will try to flash the mob's eyes. This should probably be renamed to use() +/obj/item/weldingtool/proc/remove_fuel(amount = 1, mob/living/M = null) + if(!welding || !check_fuel()) + return 0 + if(amount) + burned_fuel_for = 0 + if(get_fuel() >= amount) + reagents.remove_reagent("welding_fuel", amount) + check_fuel() + if(M) + M.flash_act(light_intensity) + return TRUE + else + if(M) + to_chat(M, "You need more welding fuel to complete this task!") + return FALSE + + +//Turns off the welder if there is no more fuel (does this really need to be its own proc?) +/obj/item/weldingtool/proc/check_fuel(mob/user) + if(get_fuel() <= 0 && welding) + switched_on(user) + update_icon() + //mob icon update + if(ismob(loc)) + var/mob/M = loc + M.update_inv_hands(0) + + return 0 + return 1 + +//Switches the welder on +/obj/item/weldingtool/proc/switched_on(mob/user) + if(!status) + to_chat(user, "[src] can't be turned on while unsecured!") + return + welding = !welding + if(welding) + if(get_fuel() >= 1) + to_chat(user, "You switch [src] on.") + playsound(loc, acti_sound, 50, 1) + force = 15 + damtype = "fire" + hitsound = 'sound/items/welder.ogg' + update_icon() + START_PROCESSING(SSobj, src) + else + to_chat(user, "You need more fuel!") + switched_off(user) + else + to_chat(user, "You switch [src] off.") + playsound(loc, deac_sound, 50, 1) + switched_off(user) + +//Switches the welder off +/obj/item/weldingtool/proc/switched_off(mob/user) + welding = 0 + set_light(0) + + force = 3 + damtype = "brute" + hitsound = "swing_hit" + update_icon() + + +/obj/item/weldingtool/examine(mob/user) + ..() + to_chat(user, "It contains [get_fuel()] unit\s of fuel out of [max_fuel].") + +/obj/item/weldingtool/is_hot() + return welding * heat + +//Returns whether or not the welding tool is currently on. +/obj/item/weldingtool/proc/isOn() + return welding + + +/obj/item/weldingtool/proc/flamethrower_screwdriver(obj/item/I, mob/user) + if(welding) + to_chat(user, "Turn it off first!") + return + status = !status + if(status) + to_chat(user, "You resecure [src] and close the fuel tank.") + container_type = NONE + else + to_chat(user, "[src] can now be attached, modified, and refuelled.") + container_type = OPENCONTAINER_1 + add_fingerprint(user) + +/obj/item/weldingtool/proc/flamethrower_rods(obj/item/I, mob/user) + if(!status) + var/obj/item/stack/rods/R = I + if (R.use(1)) + var/obj/item/flamethrower/F = new /obj/item/flamethrower(user.loc) + if(!remove_item_from_storage(F)) + user.transferItemToLoc(src, F, TRUE) + F.weldtool = src + add_fingerprint(user) + to_chat(user, "You add a rod to a welder, starting to build a flamethrower.") + user.put_in_hands(F) + else + to_chat(user, "You need one rod to start building a flamethrower!") + +/obj/item/weldingtool/ignition_effect(atom/A, mob/user) + if(welding && remove_fuel(1, user)) + . = "[user] casually lights [A] with [src], what a badass." + else + . = "" + +/obj/item/weldingtool/largetank + name = "industrial welding tool" + desc = "A slightly larger welder with a larger tank." + icon_state = "indwelder" + max_fuel = 40 + materials = list(MAT_GLASS=60) + +/obj/item/weldingtool/largetank/cyborg + name = "integrated welding tool" + desc = "An advanced welder designed to be used in robotic systems." + toolspeed = 0.5 + +/obj/item/weldingtool/largetank/flamethrower_screwdriver() + return + + +/obj/item/weldingtool/mini + name = "emergency welding tool" + desc = "A miniature welder used during emergencies." + icon_state = "miniwelder" + max_fuel = 10 + w_class = WEIGHT_CLASS_TINY + materials = list(MAT_METAL=30, MAT_GLASS=10) + change_icons = 0 + +/obj/item/weldingtool/mini/flamethrower_screwdriver() + return + +/obj/item/weldingtool/abductor + 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 + light_intensity = 0 + change_icons = 0 + +/obj/item/weldingtool/abductor/process() + if(get_fuel() <= max_fuel) + reagents.add_reagent("welding_fuel", 1) + ..() + +/obj/item/weldingtool/hugetank + name = "upgraded industrial welding tool" + desc = "An upgraded welder based of the industrial welder." + icon_state = "upindwelder" + item_state = "upindwelder" + max_fuel = 80 + materials = list(MAT_METAL=70, MAT_GLASS=120) + +/obj/item/weldingtool/experimental + name = "experimental welding tool" + desc = "An experimental welder capable of self-fuel generation and less harmful to the eyes." + icon_state = "exwelder" + item_state = "exwelder" + max_fuel = 40 + materials = list(MAT_METAL=70, MAT_GLASS=120) + var/last_gen = 0 + change_icons = 0 + can_off_process = 1 + light_intensity = 1 + toolspeed = 0.5 + var/nextrefueltick = 0 + +/obj/item/weldingtool/experimental/brass + name = "brass welding tool" + desc = "A brass welder that seems to constantly refuel itself. It is faintly warm to the touch." + resistance_flags = FIRE_PROOF | ACID_PROOF + icon_state = "brasswelder" + item_state = "brasswelder" + + +/obj/item/weldingtool/experimental/process() + ..() + if(get_fuel() < max_fuel && nextrefueltick < world.time) + nextrefueltick = world.time + 10 + reagents.add_reagent("welding_fuel", 1) + +>>>>>>> 25080ff... defines math (#33498) #undef WELDER_FUEL_BURN_INTERVAL \ No newline at end of file diff --git a/code/game/objects/obj_defense.dm b/code/game/objects/obj_defense.dm index ad5f69672b..ff8bcc3e1e 100644 --- a/code/game/objects/obj_defense.dm +++ b/code/game/objects/obj_defense.dm @@ -198,7 +198,7 @@ GLOBAL_DATUM_INIT(acid_overlay, /mutable_appearance, mutable_appearance('icons/e if(T.intact && level == 1) //fire can't damage things hidden below the floor. return if(exposed_temperature && !(resistance_flags & FIRE_PROOF)) - take_damage(Clamp(0.02 * exposed_temperature, 0, 20), BURN, "fire", 0) + take_damage(CLAMP(0.02 * exposed_temperature, 0, 20), BURN, "fire", 0) if(!(resistance_flags & ON_FIRE) && (resistance_flags & FLAMMABLE)) resistance_flags |= ON_FIRE SSfire_burning.processing[src] = src diff --git a/code/game/objects/structures/fireplace.dm b/code/game/objects/structures/fireplace.dm index 04d7f983c0..2735bd7e81 100644 --- a/code/game/objects/structures/fireplace.dm +++ b/code/game/objects/structures/fireplace.dm @@ -129,7 +129,7 @@ if(burn_time_remaining() < MAXIMUM_BURN_TIMER) flame_expiry_timer = world.time + MAXIMUM_BURN_TIMER else - fuel_added = Clamp(fuel_added + amount, 0, MAXIMUM_BURN_TIMER) + fuel_added = CLAMP(fuel_added + amount, 0, MAXIMUM_BURN_TIMER) /obj/structure/fireplace/proc/burn_time_remaining() if(lit) diff --git a/code/game/objects/structures/grille.dm b/code/game/objects/structures/grille.dm index 009bbcd70e..a7bfb92c45 100644 --- a/code/game/objects/structures/grille.dm +++ b/code/game/objects/structures/grille.dm @@ -30,7 +30,7 @@ return var/ratio = obj_integrity / max_integrity - ratio = Ceiling(ratio*4) * 25 + ratio = CEILING(ratio*4, 1) * 25 if(smooth) queue_smooth(src) diff --git a/code/game/objects/structures/lattice.dm b/code/game/objects/structures/lattice.dm index c0dcd866d8..306d3d0b84 100644 --- a/code/game/objects/structures/lattice.dm +++ b/code/game/objects/structures/lattice.dm @@ -67,7 +67,7 @@ resistance_flags |= INDESTRUCTIBLE /obj/structure/lattice/clockwork/ratvar_act() - if(IsOdd(x+y)) + if(ISODD(x+y)) icon = 'icons/obj/smooth_structures/lattice_clockwork_large.dmi' pixel_x = -9 pixel_y = -9 @@ -124,7 +124,7 @@ resistance_flags |= INDESTRUCTIBLE /obj/structure/lattice/catwalk/clockwork/ratvar_act() - if(IsOdd(x+y)) + if(ISODD(x+y)) icon = 'icons/obj/smooth_structures/catwalk_clockwork_large.dmi' pixel_x = -9 pixel_y = -9 diff --git a/code/game/objects/structures/musician.dm b/code/game/objects/structures/musician.dm index 1265594eff..a73824ca2b 100644 --- a/code/game/objects/structures/musician.dm +++ b/code/game/objects/structures/musician.dm @@ -119,7 +119,7 @@ else cur_oct[cur_note] = text2num(ni) if(user.dizziness > 0 && prob(user.dizziness / 2)) - cur_note = Clamp(cur_note + rand(round(-user.dizziness / 10), round(user.dizziness / 10)), 1, 7) + cur_note = CLAMP(cur_note + rand(round(-user.dizziness / 10), round(user.dizziness / 10)), 1, 7) if(user.dizziness > 0 && prob(user.dizziness / 5)) if(prob(30)) cur_acc[cur_note] = "#" diff --git a/code/game/objects/structures/reflector.dm b/code/game/objects/structures/reflector.dm index e47afd53d4..1ae513f847 100644 --- a/code/game/objects/structures/reflector.dm +++ b/code/game/objects/structures/reflector.dm @@ -165,7 +165,7 @@ to_chat(user, "You can't do that right now!") return if(!isnull(new_angle)) - setAngle(NORM_ROT(new_angle)) + setAngle(SIMPLIFY_DEGREES(new_angle)) return TRUE /obj/structure/reflector/AltClick(mob/user) @@ -197,16 +197,12 @@ anchored = TRUE /obj/structure/reflector/single/auto_reflect(obj/item/projectile/P, pdir, turf/ploc, pangle) - var/incidence = get_angle_of_incidence(rotation_angle, P.Angle) - var/incidence_norm = get_angle_of_incidence(rotation_angle, P.Angle, FALSE) - if((incidence_norm > -90) && (incidence_norm < 90)) + var/incidence = GET_ANGLE_OF_INCIDENCE(rotation_angle, P.Angle) + var/norm_inc = WRAP(incidence, -90, 90) + var/new_angle = WRAP(rotation_angle + norm_inc, 180, -180) + if(ISINRANGE_EX(norm_inc, -90, 90)) return FALSE - var/new_angle_s = rotation_angle + incidence - while(new_angle_s > 180) // Translate to regular projectile degrees - new_angle_s -= 360 - while(new_angle_s < -180) - new_angle_s += 360 - P.Angle = new_angle_s + P.Angle = new_angle return ..() //DOUBLE @@ -228,17 +224,12 @@ anchored = TRUE /obj/structure/reflector/double/auto_reflect(obj/item/projectile/P, pdir, turf/ploc, pangle) - var/incidence = get_angle_of_incidence(rotation_angle, P.Angle) - var/incidence_norm = get_angle_of_incidence(rotation_angle, P.Angle, FALSE) - var/invert = ((incidence_norm > -90) && (incidence_norm < 90)) - var/new_angle_s = rotation_angle + incidence - if(invert) - new_angle_s += 180 - while(new_angle_s > 180) // Translate to regular projectile degrees - new_angle_s -= 360 - while(new_angle_s < -180) - new_angle_s += 360 - P.Angle = new_angle_s + var/incidence = GET_ANGLE_OF_INCIDENCE(rotation_angle, P.Angle) + var/norm_inc = WRAP(incidence, -90, 90) + var/new_angle = WRAP(rotation_angle + norm_inc, 180, -180) + if(ISINRANGE_EX(norm_inc, -90, 90)) + new_angle += 180 + P.Angle = new_angle return ..() //BOX diff --git a/code/game/objects/structures/tables_racks.dm b/code/game/objects/structures/tables_racks.dm index 26582515f8..65d25055f8 100644 --- a/code/game/objects/structures/tables_racks.dm +++ b/code/game/objects/structures/tables_racks.dm @@ -134,8 +134,8 @@ if(!click_params || !click_params["icon-x"] || !click_params["icon-y"]) return //Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf) - I.pixel_x = Clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2) - I.pixel_y = Clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2) + I.pixel_x = CLAMP(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2) + I.pixel_y = CLAMP(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2) return 1 else return ..() diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm index 2b9494c535..5380f0ca20 100644 --- a/code/game/objects/structures/window.dm +++ b/code/game/objects/structures/window.dm @@ -380,7 +380,7 @@ return var/ratio = obj_integrity / max_integrity - ratio = Ceiling(ratio*4) * 25 + ratio = CEILING(ratio*4, 1) * 25 if(smooth) queue_smooth(src) diff --git a/code/game/turfs/simulated/floor/plating/asteroid.dm b/code/game/turfs/simulated/floor/plating/asteroid.dm index b2ab28dcae..1419036d07 100644 --- a/code/game/turfs/simulated/floor/plating/asteroid.dm +++ b/code/game/turfs/simulated/floor/plating/asteroid.dm @@ -188,7 +188,7 @@ break var/list/L = list(45) - if(IsOdd(dir2angle(dir))) // We're going at an angle and we want thick angled tunnels. + if(ISODD(dir2angle(dir))) // We're going at an angle and we want thick angled tunnels. L += -45 // Expand the edges of our tunnel diff --git a/code/game/turfs/simulated/walls.dm b/code/game/turfs/simulated/walls.dm index 337bb051a8..00377e4f3f 100644 --- a/code/game/turfs/simulated/walls.dm +++ b/code/game/turfs/simulated/walls.dm @@ -54,7 +54,7 @@ var/turf/p_turf = get_turf(P) var/face_direction = get_dir(src, p_turf) var/face_angle = dir2angle(face_direction) - var/incidence_s = get_angle_of_incidence(face_angle, P.Angle) + var/incidence_s = WRAP(GET_ANGLE_OF_INCIDENCE(face_angle, P.Angle), -90, 90) var/new_angle = face_angle + incidence_s var/new_angle_s = new_angle while(new_angle_s > 180) // Translate to regular projectile degrees diff --git a/code/modules/admin/sound_emitter.dm b/code/modules/admin/sound_emitter.dm index b7ec8c36b5..87024f7832 100644 --- a/code/modules/admin/sound_emitter.dm +++ b/code/modules/admin/sound_emitter.dm @@ -92,7 +92,7 @@ var/new_volume = input(user, "Choose a volume.", "Sound Emitter", sound_volume) as null|num if(isnull(new_volume)) return - new_volume = Clamp(new_volume, 0, 100) + new_volume = CLAMP(new_volume, 0, 100) sound_volume = new_volume to_chat(user, "Volume set to [sound_volume]%.") if(href_list["edit_mode"]) @@ -115,7 +115,7 @@ var/new_radius = input(user, "Choose a radius.", "Sound Emitter", sound_volume) as null|num if(isnull(new_radius)) return - new_radius = Clamp(new_radius, 0, 127) + new_radius = CLAMP(new_radius, 0, 127) play_radius = new_radius to_chat(user, "Audible radius set to [play_radius].") if(href_list["play"]) diff --git a/code/modules/admin/sql_message_system.dm b/code/modules/admin/sql_message_system.dm index 587bd6b26c..38316c904f 100644 --- a/code/modules/admin/sql_message_system.dm +++ b/code/modules/admin/sql_message_system.dm @@ -220,7 +220,7 @@ var/nsd = CONFIG_GET(number/note_stale_days) var/nfd = CONFIG_GET(number/note_fresh_days) if (agegate && type == "note" && isnum(nsd) && isnum(nfd) && nsd > nfd) - var/alpha = Clamp(100 - (age - nfd) * (85 / (nsd - nfd)), 15, 100) + var/alpha = CLAMP(100 - (age - nfd) * (85 / (nsd - nfd)), 15, 100) if (alpha < 100) if (alpha <= 15) if (skipped) diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index de8dff1518..0cec1ef3a8 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -1892,7 +1892,7 @@ return var/list/offset = splittext(href_list["offset"],",") - var/number = Clamp(text2num(href_list["object_count"]), 1, 100) + var/number = CLAMP(text2num(href_list["object_count"]), 1, 100) var/X = offset.len > 0 ? text2num(offset[1]) : 0 var/Y = offset.len > 1 ? text2num(offset[2]) : 0 var/Z = offset.len > 2 ? text2num(offset[3]) : 0 diff --git a/code/modules/admin/verbs/SDQL2/SDQL_2.dm b/code/modules/admin/verbs/SDQL2/SDQL_2.dm index 9e9e727b39..0421807abe 100644 --- a/code/modules/admin/verbs/SDQL2/SDQL_2.dm +++ b/code/modules/admin/verbs/SDQL2/SDQL_2.dm @@ -435,7 +435,7 @@ else if(expression[start + 1] == "\[" && islist(v)) var/list/L = v var/index = SDQL_expression(source, expression[start + 2]) - if(isnum(index) && (!IsInteger(index) || L.len < index)) + if(isnum(index) && (!ISINTEGER(index) || L.len < index)) to_chat(usr, "Invalid list index: [index]") return null return L[index] diff --git a/code/modules/admin/verbs/playsound.dm b/code/modules/admin/verbs/playsound.dm index 6b1edf7709..29d95c639f 100644 --- a/code/modules/admin/verbs/playsound.dm +++ b/code/modules/admin/verbs/playsound.dm @@ -12,7 +12,7 @@ var/vol = input(usr, "What volume would you like the sound to play at?",, 100) as null|num if(!vol) return - vol = Clamp(vol, 1, 100) + vol = CLAMP(vol, 1, 100) var/sound/admin_sound = new() admin_sound.file = S diff --git a/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm index f8204947f1..6f72724e1e 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/dp_vent_pump.dm @@ -185,13 +185,13 @@ Acts like a normal vent, but has an input AND output. pump_direction = 1 if("set_input_pressure" in signal.data) - input_pressure_min = Clamp(text2num(signal.data["set_input_pressure"]),0,ONE_ATMOSPHERE*50) + input_pressure_min = CLAMP(text2num(signal.data["set_input_pressure"]),0,ONE_ATMOSPHERE*50) if("set_output_pressure" in signal.data) - output_pressure_max = Clamp(text2num(signal.data["set_output_pressure"]),0,ONE_ATMOSPHERE*50) + output_pressure_max = CLAMP(text2num(signal.data["set_output_pressure"]),0,ONE_ATMOSPHERE*50) if("set_external_pressure" in signal.data) - external_pressure_bound = Clamp(text2num(signal.data["set_external_pressure"]),0,ONE_ATMOSPHERE*50) + external_pressure_bound = CLAMP(text2num(signal.data["set_external_pressure"]),0,ONE_ATMOSPHERE*50) if("status" in signal.data) spawn(2) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm b/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm index 86c5375d07..ef4e487efd 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/passive_gate.dm @@ -127,7 +127,7 @@ Passive gate is similar to the regular pump except: pressure = text2num(pressure) . = TRUE if(.) - target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE) + target_pressure = CLAMP(pressure, 0, MAX_OUTPUT_PRESSURE) investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS) update_icon() @@ -149,7 +149,7 @@ Passive gate is similar to the regular pump except: on = !on if("set_output_pressure" in signal.data) - target_pressure = Clamp(text2num(signal.data["set_output_pressure"]),0,ONE_ATMOSPHERE*50) + target_pressure = CLAMP(text2num(signal.data["set_output_pressure"]),0,ONE_ATMOSPHERE*50) if(on != old_on) investigate_log("was turned [on ? "on" : "off"] by a remote signal", INVESTIGATE_ATMOS) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/pump.dm index 97bba0e534..898a8157ae 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/pump.dm @@ -133,9 +133,14 @@ Thus, the two variables affect pump operation are set in New(): pressure = text2num(pressure) . = TRUE if(.) +<<<<<<< HEAD target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE) investigate_log("Pump, [src.name], was set to [target_pressure] kPa by [key_name(usr)] at [x], [y], [z], [A]", INVESTIGATE_ATMOS) message_admins("Pump, [src.name], was set to [target_pressure] kPa by [ADMIN_LOOKUPFLW(usr)] at [ADMIN_COORDJMP(T)], [A]") +======= + target_pressure = CLAMP(pressure, 0, MAX_OUTPUT_PRESSURE) + investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS) +>>>>>>> 25080ff... defines math (#33498) update_icon() /obj/machinery/atmospherics/components/binary/pump/atmosinit() @@ -156,7 +161,7 @@ Thus, the two variables affect pump operation are set in New(): on = !on if("set_output_pressure" in signal.data) - target_pressure = Clamp(text2num(signal.data["set_output_pressure"]),0,ONE_ATMOSPHERE*50) + target_pressure = CLAMP(text2num(signal.data["set_output_pressure"]),0,ONE_ATMOSPHERE*50) if(on != old_on) investigate_log("was turned [on ? "on" : "off"] by a remote signal", INVESTIGATE_ATMOS) diff --git a/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm b/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm index b154c0d3e4..bdc1ae15a3 100644 --- a/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm +++ b/code/modules/atmospherics/machinery/components/binary_devices/volume_pump.dm @@ -133,9 +133,14 @@ Thus, the two variables affect pump operation are set in New(): rate = text2num(rate) . = TRUE if(.) +<<<<<<< HEAD transfer_rate = Clamp(rate, 0, MAX_TRANSFER_RATE) investigate_log("Volume Pump, [src.name], was set to [transfer_rate] L/s by [key_name(usr)] at [x], [y], [z], [A]", INVESTIGATE_ATMOS) message_admins("Volume Pump, [src.name], was set to [transfer_rate] L/s by [ADMIN_LOOKUPFLW(usr)] at [ADMIN_COORDJMP(T)], [A]") +======= + transfer_rate = CLAMP(rate, 0, MAX_TRANSFER_RATE) + investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", INVESTIGATE_ATMOS) +>>>>>>> 25080ff... defines math (#33498) update_icon() /obj/machinery/atmospherics/components/binary/volume_pump/receive_signal(datum/signal/signal) @@ -152,7 +157,7 @@ Thus, the two variables affect pump operation are set in New(): if("set_transfer_rate" in signal.data) var/datum/gas_mixture/air1 = AIR1 - transfer_rate = Clamp(text2num(signal.data["set_transfer_rate"]),0,air1.volume) + transfer_rate = CLAMP(text2num(signal.data["set_transfer_rate"]),0,air1.volume) if(on != old_on) investigate_log("was turned [on ? "on" : "off"] by a remote signal", INVESTIGATE_ATMOS) diff --git a/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm b/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm index 4baeb3dd3e..9a8034064c 100644 --- a/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm +++ b/code/modules/atmospherics/machinery/components/trinary_devices/filter.dm @@ -162,7 +162,7 @@ pressure = text2num(pressure) . = TRUE if(.) - target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE) + target_pressure = CLAMP(pressure, 0, MAX_OUTPUT_PRESSURE) investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS) if("filter") filter_type = null diff --git a/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm b/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm index b706cd3cd9..b15df59662 100644 --- a/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm +++ b/code/modules/atmospherics/machinery/components/trinary_devices/mixer.dm @@ -152,7 +152,7 @@ pressure = text2num(pressure) . = TRUE if(.) - target_pressure = Clamp(pressure, 0, MAX_OUTPUT_PRESSURE) + target_pressure = CLAMP(pressure, 0, MAX_OUTPUT_PRESSURE) investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS) if("node1") var/value = text2num(params["concentration"]) diff --git a/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm b/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm index 37bfb5d952..64e6e56504 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/outlet_injector.dm @@ -131,7 +131,7 @@ if("set_volume_rate" in signal.data) var/number = text2num(signal.data["set_volume_rate"]) var/datum/gas_mixture/air_contents = AIR1 - volume_rate = Clamp(number, 0, air_contents.volume) + volume_rate = CLAMP(number, 0, air_contents.volume) if("status" in signal.data) spawn(2) @@ -180,7 +180,7 @@ rate = text2num(rate) . = TRUE if(.) - volume_rate = Clamp(rate, 0, MAX_TRANSFER_RATE) + volume_rate = CLAMP(rate, 0, MAX_TRANSFER_RATE) investigate_log("was set to [volume_rate] L/s by [key_name(usr)]", INVESTIGATE_ATMOS) update_icon() broadcast_status() diff --git a/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm b/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm index fa336c7a34..8d34d5adfa 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/thermomachine.dm @@ -153,7 +153,7 @@ target = text2num(target) . = TRUE if(.) - target_temperature = Clamp(target, min_temperature, max_temperature) + target_temperature = CLAMP(target, min_temperature, max_temperature) investigate_log("was set to [target_temperature] K by [key_name(usr)]", INVESTIGATE_ATMOS) update_icon() diff --git a/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm b/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm index a05a13217d..2c9a308ec9 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/vent_pump.dm @@ -244,10 +244,10 @@ pump_direction = text2num(signal.data["direction"]) if("set_internal_pressure" in signal.data) - internal_pressure_bound = Clamp(text2num(signal.data["set_internal_pressure"]),0,ONE_ATMOSPHERE*50) + internal_pressure_bound = CLAMP(text2num(signal.data["set_internal_pressure"]),0,ONE_ATMOSPHERE*50) if("set_external_pressure" in signal.data) - external_pressure_bound = Clamp(text2num(signal.data["set_external_pressure"]),0,ONE_ATMOSPHERE*50) + external_pressure_bound = CLAMP(text2num(signal.data["set_external_pressure"]),0,ONE_ATMOSPHERE*50) if("reset_external_pressure" in signal.data) external_pressure_bound = ONE_ATMOSPHERE @@ -256,10 +256,10 @@ internal_pressure_bound = 0 if("adjust_internal_pressure" in signal.data) - internal_pressure_bound = Clamp(internal_pressure_bound + text2num(signal.data["adjust_internal_pressure"]),0,ONE_ATMOSPHERE*50) + internal_pressure_bound = CLAMP(internal_pressure_bound + text2num(signal.data["adjust_internal_pressure"]),0,ONE_ATMOSPHERE*50) if("adjust_external_pressure" in signal.data) - external_pressure_bound = Clamp(external_pressure_bound + text2num(signal.data["adjust_external_pressure"]),0,ONE_ATMOSPHERE*50) + external_pressure_bound = CLAMP(external_pressure_bound + text2num(signal.data["adjust_external_pressure"]),0,ONE_ATMOSPHERE*50) if("init" in signal.data) name = signal.data["init"] diff --git a/code/modules/atmospherics/machinery/pipes/layermanifold.dm b/code/modules/atmospherics/machinery/pipes/layermanifold.dm index fee00baf50..d2f85c7667 100644 --- a/code/modules/atmospherics/machinery/pipes/layermanifold.dm +++ b/code/modules/atmospherics/machinery/pipes/layermanifold.dm @@ -121,7 +121,7 @@ if(initialize_directions & dir) return ..() if((NORTH|EAST) & dir) - user.ventcrawl_layer = Clamp(user.ventcrawl_layer + 1, PIPING_LAYER_MIN, PIPING_LAYER_MAX) + user.ventcrawl_layer = CLAMP(user.ventcrawl_layer + 1, PIPING_LAYER_MIN, PIPING_LAYER_MAX) if((SOUTH|WEST) & dir) - user.ventcrawl_layer = Clamp(user.ventcrawl_layer - 1, PIPING_LAYER_MIN, PIPING_LAYER_MAX) + user.ventcrawl_layer = CLAMP(user.ventcrawl_layer - 1, PIPING_LAYER_MIN, PIPING_LAYER_MAX) to_chat(user, "You align yourself with the [user.ventcrawl_layer]\th output.") diff --git a/code/modules/atmospherics/machinery/portable/canister.dm b/code/modules/atmospherics/machinery/portable/canister.dm index 585b6e896a..ddc562bbb7 100644 --- a/code/modules/atmospherics/machinery/portable/canister.dm +++ b/code/modules/atmospherics/machinery/portable/canister.dm @@ -411,7 +411,7 @@ pressure = text2num(pressure) . = TRUE if(.) - release_pressure = Clamp(round(pressure), can_min_release_pressure, can_max_release_pressure) + release_pressure = CLAMP(round(pressure), can_min_release_pressure, can_max_release_pressure) investigate_log("was set to [release_pressure] kPa by [key_name(usr)].", INVESTIGATE_ATMOS) if("valve") var/logmsg @@ -455,7 +455,7 @@ var/N = text2num(user_input) if(!N) return - timer_set = Clamp(N,minimum_timer_set,maximum_timer_set) + timer_set = CLAMP(N,minimum_timer_set,maximum_timer_set) log_admin("[key_name(usr)] has activated a prototype valve timer") . = TRUE if("toggle_timer") diff --git a/code/modules/atmospherics/machinery/portable/pump.dm b/code/modules/atmospherics/machinery/portable/pump.dm index 3f2bceaa04..807759e43c 100644 --- a/code/modules/atmospherics/machinery/portable/pump.dm +++ b/code/modules/atmospherics/machinery/portable/pump.dm @@ -131,7 +131,7 @@ pressure = text2num(pressure) . = TRUE if(.) - pump.target_pressure = Clamp(round(pressure), PUMP_MIN_PRESSURE, PUMP_MAX_PRESSURE) + pump.target_pressure = CLAMP(round(pressure), PUMP_MIN_PRESSURE, PUMP_MAX_PRESSURE) investigate_log("was set to [pump.target_pressure] kPa by [key_name(usr)].", INVESTIGATE_ATMOS) if("eject") if(holding) diff --git a/code/modules/cargo/exports.dm b/code/modules/cargo/exports.dm index 92b953e7b2..b4c0aa350d 100644 --- a/code/modules/cargo/exports.dm +++ b/code/modules/cargo/exports.dm @@ -86,7 +86,7 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they /datum/export/process() ..() - cost *= GLOB.E**(k_elasticity * (1/30)) + cost *= NUM_E**(k_elasticity * (1/30)) if(cost > init_cost) cost = init_cost @@ -94,7 +94,7 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they /datum/export/proc/get_cost(obj/O, contr = 0, emag = 0) var/amount = get_amount(O, contr, emag) if(k_elasticity!=0) - return round((cost/k_elasticity) * (1 - GLOB.E**(-1 * k_elasticity * amount))) //anti-derivative of the marginal cost function + return round((cost/k_elasticity) * (1 - NUM_E**(-1 * k_elasticity * amount))) //anti-derivative of the marginal cost function else return round(cost * amount) //alternative form derived from L'Hopital to avoid division by 0 @@ -131,7 +131,7 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they else total_amount += amount - cost *= GLOB.E**(-1*k_elasticity*amount) //marginal cost modifier + cost *= NUM_E**(-1*k_elasticity*amount) //marginal cost modifier SSblackbox.record_feedback("nested tally", "export_sold_cost", 1, list("[O.type]", "[the_cost]")) // Total printout for the cargo console. diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index cb1712dff5..f356d6c057 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -152,7 +152,7 @@ GLOBAL_LIST(external_rsc_urls) #if (PRELOAD_RSC == 0) var/static/next_external_rsc = 0 if(external_rsc_urls && external_rsc_urls.len) - next_external_rsc = Wrap(next_external_rsc+1, 1, external_rsc_urls.len+1) + next_external_rsc = WRAP(next_external_rsc+1, 1, external_rsc_urls.len+1) preload_rsc = external_rsc_urls[next_external_rsc] #endif @@ -673,6 +673,16 @@ GLOBAL_LIST(external_rsc_urls) return TRUE . = ..() +<<<<<<< HEAD +======= +/client/proc/rescale_view(change, min, max) + var/viewscale = getviewsize(view) + var/x = viewscale[1] + var/y = viewscale[2] + x = CLAMP(x+change, min, max) + y = CLAMP(y+change, min,max) + change_view("[x]x[y]") +>>>>>>> 25080ff... defines math (#33498) /client/proc/change_view(new_size) if (isnull(new_size)) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 175a23c91e..0469f31aba 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -1596,12 +1596,12 @@ GLOBAL_LIST_EMPTY(preferences_datums) toggles ^= MIDROUND_ANTAG if("parallaxup") - parallax = Wrap(parallax + 1, PARALLAX_INSANE, PARALLAX_DISABLE + 1) + parallax = WRAP(parallax + 1, PARALLAX_INSANE, PARALLAX_DISABLE + 1) if (parent && parent.mob && parent.mob.hud_used) parent.mob.hud_used.update_parallax_pref(parent.mob) if("parallaxdown") - parallax = Wrap(parallax - 1, PARALLAX_INSANE, PARALLAX_DISABLE + 1) + parallax = WRAP(parallax - 1, PARALLAX_INSANE, PARALLAX_DISABLE + 1) if (parent && parent.mob && parent.mob.hud_used) parent.mob.hud_used.update_parallax_pref(parent.mob) diff --git a/code/modules/clothing/spacesuits/flightsuit.dm b/code/modules/clothing/spacesuits/flightsuit.dm index 7e4b0bad89..681ba3e789 100644 --- a/code/modules/clothing/spacesuits/flightsuit.dm +++ b/code/modules/clothing/spacesuits/flightsuit.dm @@ -164,7 +164,7 @@ assembled = TRUE boost_chargerate *= cap boost_drain -= manip - powersetting_high = Clamp(laser, 0, 3) + powersetting_high = CLAMP(laser, 0, 3) emp_disable_threshold = bin*1.25 stabilizer_decay_amount = scan*3.5 airbrake_decay_amount = manip*8 @@ -194,15 +194,15 @@ /obj/item/device/flightpack/proc/adjust_momentum(amountx, amounty, reduce_amount_total = 0) if(reduce_amount_total != 0) if(momentum_x > 0) - momentum_x = Clamp(momentum_x - reduce_amount_total, 0, momentum_max) + momentum_x = CLAMP(momentum_x - reduce_amount_total, 0, momentum_max) else if(momentum_x < 0) - momentum_x = Clamp(momentum_x + reduce_amount_total, -momentum_max, 0) + momentum_x = CLAMP(momentum_x + reduce_amount_total, -momentum_max, 0) if(momentum_y > 0) - momentum_y = Clamp(momentum_y - reduce_amount_total, 0, momentum_max) + momentum_y = CLAMP(momentum_y - reduce_amount_total, 0, momentum_max) else if(momentum_y < 0) - momentum_y = Clamp(momentum_y + reduce_amount_total, -momentum_max, 0) - momentum_x = Clamp(momentum_x + amountx, -momentum_max, momentum_max) - momentum_y = Clamp(momentum_y + amounty, -momentum_max, momentum_max) + momentum_y = CLAMP(momentum_y + reduce_amount_total, -momentum_max, 0) + momentum_x = CLAMP(momentum_x + amountx, -momentum_max, momentum_max) + momentum_y = CLAMP(momentum_y + amounty, -momentum_max, momentum_max) calculate_momentum_speed() /obj/item/device/flightpack/intercept_user_move(dir, mob, newLoc, oldLoc) @@ -314,7 +314,7 @@ /obj/item/device/flightpack/proc/handle_damage() if(emp_damage) - emp_damage = Clamp(emp_damage-emp_heal_amount, 0, emp_disable_threshold * 10) + emp_damage = CLAMP(emp_damage-emp_heal_amount, 0, emp_disable_threshold * 10) if(emp_damage >= emp_disable_threshold) emp_disabled = TRUE if(emp_disabled && (emp_damage <= 0.5)) @@ -347,11 +347,11 @@ /obj/item/device/flightpack/proc/handle_boost() if(boost) - boost_charge = Clamp(boost_charge-boost_drain, 0, boost_maxcharge) + boost_charge = CLAMP(boost_charge-boost_drain, 0, boost_maxcharge) if(boost_charge < 1) deactivate_booster() if(boost_charge < boost_maxcharge) - boost_charge = Clamp(boost_charge+boost_chargerate, 0, boost_maxcharge) + boost_charge = CLAMP(boost_charge+boost_chargerate, 0, boost_maxcharge) /obj/item/device/flightpack/proc/cycle_power() powersetting < powersetting_high? (powersetting++) : (powersetting = 1) diff --git a/code/modules/clothing/spacesuits/hardsuit.dm b/code/modules/clothing/spacesuits/hardsuit.dm index cc1df785b5..73d7ee04e8 100644 --- a/code/modules/clothing/spacesuits/hardsuit.dm +++ b/code/modules/clothing/spacesuits/hardsuit.dm @@ -654,7 +654,7 @@ /obj/item/clothing/suit/space/hardsuit/shielded/process() if(world.time > recharge_cooldown && current_charges < max_charges) - current_charges = Clamp((current_charges + recharge_rate), 0, max_charges) + current_charges = CLAMP((current_charges + recharge_rate), 0, max_charges) playsound(loc, 'sound/magic/charge.ogg', 50, 1) if(current_charges == max_charges) playsound(loc, 'sound/machines/ding.ogg', 50, 1) diff --git a/code/modules/events/_event.dm b/code/modules/events/_event.dm index a5b23623f2..471dad12d7 100644 --- a/code/modules/events/_event.dm +++ b/code/modules/events/_event.dm @@ -29,8 +29,8 @@ /datum/round_event_control/New() if(config && !wizardevent) // Magic is unaffected by configs - earliest_start = Ceiling(earliest_start * CONFIG_GET(number/events_min_time_mul)) - min_players = Ceiling(min_players * CONFIG_GET(number/events_min_players_mul)) + earliest_start = CEILING(earliest_start * CONFIG_GET(number/events_min_time_mul), 1) + min_players = CEILING(min_players * CONFIG_GET(number/events_min_players_mul), 1) /datum/round_event_control/wizard wizardevent = 1 diff --git a/code/modules/events/brand_intelligence.dm b/code/modules/events/brand_intelligence.dm index e898729f2d..c2f98be8d5 100644 --- a/code/modules/events/brand_intelligence.dm +++ b/code/modules/events/brand_intelligence.dm @@ -67,12 +67,12 @@ kill() return - if(IsMultiple(activeFor, 4)) + if(ISMULTIPLE(activeFor, 4)) var/obj/machinery/vending/rebel = pick(vendingMachines) vendingMachines.Remove(rebel) infectedMachines.Add(rebel) rebel.shut_up = 0 rebel.shoot_inventory = 1 - if(IsMultiple(activeFor, 8)) + if(ISMULTIPLE(activeFor, 8)) originMachine.speak(pick(rampant_speeches)) \ No newline at end of file diff --git a/code/modules/events/disease_outbreak.dm b/code/modules/events/disease_outbreak.dm index eb7625e08c..1ade939ad3 100644 --- a/code/modules/events/disease_outbreak.dm +++ b/code/modules/events/disease_outbreak.dm @@ -18,7 +18,16 @@ announceWhen = rand(15, 30) /datum/round_event/disease_outbreak/start() +<<<<<<< HEAD if(!virus_type) +======= + var/advanced_virus = FALSE + max_severity = 3 + max(FLOOR((world.time - control.earliest_start)/6000, 1),0) //3 symptoms at 20 minutes, plus 1 per 10 minutes + if(prob(20 + (10 * max_severity))) + advanced_virus = TRUE + + if(!virus_type && !advanced_virus) +>>>>>>> 25080ff... defines math (#33498) virus_type = pick(/datum/disease/dnaspread, /datum/disease/advance/flu, /datum/disease/advance/cold, /datum/disease/brainrot, /datum/disease/magnitis) for(var/mob/living/carbon/human/H in shuffle(GLOB.alive_mob_list)) diff --git a/code/modules/events/meteor_wave.dm b/code/modules/events/meteor_wave.dm index 35eb02f082..798bcf82dd 100644 --- a/code/modules/events/meteor_wave.dm +++ b/code/modules/events/meteor_wave.dm @@ -49,7 +49,7 @@ priority_announce("Meteors have been detected on collision course with the station.", "Meteor Alert", 'sound/ai/meteors.ogg') /datum/round_event/meteor_wave/tick() - if(IsMultiple(activeFor, 3)) + if(ISMULTIPLE(activeFor, 3)) spawn_meteors(5, wave_type) //meteor list types defined in gamemode/meteor/meteors.dm /datum/round_event_control/meteor_wave/threatening diff --git a/code/modules/events/portal_storm.dm b/code/modules/events/portal_storm.dm index 7e17124d59..55d9e69f71 100644 --- a/code/modules/events/portal_storm.dm +++ b/code/modules/events/portal_storm.dm @@ -64,7 +64,7 @@ T = safepick(get_area_turfs(pick(station_areas))) hostiles_spawn += T - next_boss_spawn = startWhen + Ceiling(2 * number_of_hostiles / number_of_bosses) + next_boss_spawn = startWhen + CEILING(2 * number_of_hostiles / number_of_bosses, 1) /datum/round_event/portal_storm/announce(fake) set waitfor = 0 @@ -117,14 +117,14 @@ /datum/round_event/portal_storm/proc/spawn_hostile() if(!hostile_types || !hostile_types.len) return 0 - return IsMultiple(activeFor, 2) + return ISMULTIPLE(activeFor, 2) /datum/round_event/portal_storm/proc/spawn_boss() if(!boss_types || !boss_types.len) return 0 if(activeFor == next_boss_spawn) - next_boss_spawn += Ceiling(number_of_hostiles / number_of_bosses) + next_boss_spawn += CEILING(number_of_hostiles / number_of_bosses, 1) return 1 /datum/round_event/portal_storm/proc/time_to_end() diff --git a/code/modules/food_and_drinks/kitchen_machinery/food_cart.dm b/code/modules/food_and_drinks/kitchen_machinery/food_cart.dm index 8573a84c9b..c2be28fb21 100644 --- a/code/modules/food_and_drinks/kitchen_machinery/food_cart.dm +++ b/code/modules/food_and_drinks/kitchen_machinery/food_cart.dm @@ -123,7 +123,7 @@ break if(href_list["portion"]) - portion = Clamp(input("How much drink do you want to dispense per glass?") as num, 0, 50) + portion = CLAMP(input("How much drink do you want to dispense per glass?") as num, 0, 50) if(href_list["pour"] || href_list["m_pour"]) if(glasses-- <= 0) diff --git a/code/modules/food_and_drinks/pizzabox.dm b/code/modules/food_and_drinks/pizzabox.dm index 82ba8ab405..6ef8e5e4e9 100644 --- a/code/modules/food_and_drinks/pizzabox.dm +++ b/code/modules/food_and_drinks/pizzabox.dm @@ -124,7 +124,7 @@ return else bomb_timer = input(user, "Set the [bomb] timer from [BOMB_TIMER_MIN] to [BOMB_TIMER_MAX].", bomb, bomb_timer) as num - bomb_timer = Clamp(Ceiling(bomb_timer / 2), BOMB_TIMER_MIN, BOMB_TIMER_MAX) + bomb_timer = CLAMP(CEILING(bomb_timer / 2, 1), BOMB_TIMER_MIN, BOMB_TIMER_MAX) bomb_defused = FALSE var/message = "[ADMIN_LOOKUPFLW(user)] has trapped a [src] with [bomb] set to [bomb_timer * 2] seconds." diff --git a/code/modules/goonchat/browserOutput.dm b/code/modules/goonchat/browserOutput.dm index 5bfcb9963d..0832f372c8 100644 --- a/code/modules/goonchat/browserOutput.dm +++ b/code/modules/goonchat/browserOutput.dm @@ -132,7 +132,7 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic /datum/chatOutput/proc/setMusicVolume(volume = "") if(volume) - adminMusicVolume = Clamp(text2num(volume), 0, 100) + adminMusicVolume = CLAMP(text2num(volume), 0, 100) //Sends client connection details to the chat to handle and save /datum/chatOutput/proc/sendClientData() diff --git a/code/modules/hydroponics/gene_modder.dm b/code/modules/hydroponics/gene_modder.dm index bd0215138a..d9c36ae0fd 100644 --- a/code/modules/hydroponics/gene_modder.dm +++ b/code/modules/hydroponics/gene_modder.dm @@ -42,7 +42,7 @@ for(var/obj/item/stock_parts/micro_laser/ML in component_parts) var/wratemod = ML.rating * 2.5 - min_wrate = Floor(10-wratemod,1) // 7,5,2,0 Clamps at 0 and 10 You want this low + min_wrate = FLOOR(10-wratemod,1) // 7,5,2,0 Clamps at 0 and 10 You want this low min_wchance = 67-(ML.rating*16) // 48,35,19,3 Clamps at 0 and 67 You want this low for(var/obj/item/circuitboard/machine/plantgenes/vaultcheck in component_parts) if(istype(vaultcheck, /obj/item/circuitboard/machine/plantgenes/vault)) // DUMB BOTANY TUTS diff --git a/code/modules/hydroponics/grown.dm b/code/modules/hydroponics/grown.dm index d003f40d4a..df2b07113a 100644 --- a/code/modules/hydroponics/grown.dm +++ b/code/modules/hydroponics/grown.dm @@ -36,7 +36,7 @@ for(var/datum/plant_gene/trait/T in seed.genes) T.on_new(src, loc) seed.prepare_result(src) - transform *= TransformUsingVariable(seed.potency, 100, 0.5) //Makes the resulting produce's sprite larger or smaller based on potency! + transform *= TRANSFORM_USING_VARIABLE(seed.potency, 100) + 0.5 //Makes the resulting produce's sprite larger or smaller based on potency! add_juice() diff --git a/code/modules/hydroponics/grown/towercap.dm b/code/modules/hydroponics/grown/towercap.dm index 59af735b01..1a3db5ef03 100644 --- a/code/modules/hydroponics/grown/towercap.dm +++ b/code/modules/hydroponics/grown/towercap.dm @@ -154,8 +154,8 @@ if(!click_params || !click_params["icon-x"] || !click_params["icon-y"]) return //Clamp it so that the icon never moves more than 16 pixels in either direction (thus leaving the table turf) - W.pixel_x = Clamp(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2) - W.pixel_y = Clamp(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2) + W.pixel_x = CLAMP(text2num(click_params["icon-x"]) - 16, -(world.icon_size/2), world.icon_size/2) + W.pixel_y = CLAMP(text2num(click_params["icon-y"]) - 16, -(world.icon_size/2), world.icon_size/2) else return ..() diff --git a/code/modules/hydroponics/growninedible.dm b/code/modules/hydroponics/growninedible.dm index a77808f006..b0bd44ac8a 100644 --- a/code/modules/hydroponics/growninedible.dm +++ b/code/modules/hydroponics/growninedible.dm @@ -28,7 +28,7 @@ if(istype(src, seed.product)) // no adding reagents if it is just a trash item seed.prepare_result(src) - transform *= TransformUsingVariable(seed.potency, 100, 0.5) + transform *= TRANSFORM_USING_VARIABLE(seed.potency, 100) + 0.5 add_juice() diff --git a/code/modules/hydroponics/hydroponics.dm b/code/modules/hydroponics/hydroponics.dm index 9eafcec71b..4fd840082b 100644 --- a/code/modules/hydroponics/hydroponics.dm +++ b/code/modules/hydroponics/hydroponics.dm @@ -881,26 +881,26 @@ /// Tray Setters - The following procs adjust the tray or plants variables, and make sure that the stat doesn't go out of bounds./// /obj/machinery/hydroponics/proc/adjustNutri(adjustamt) - nutrilevel = Clamp(nutrilevel + adjustamt, 0, maxnutri) + nutrilevel = CLAMP(nutrilevel + adjustamt, 0, maxnutri) /obj/machinery/hydroponics/proc/adjustWater(adjustamt) - waterlevel = Clamp(waterlevel + adjustamt, 0, maxwater) + waterlevel = CLAMP(waterlevel + adjustamt, 0, maxwater) if(adjustamt>0) adjustToxic(-round(adjustamt/4))//Toxicity dilutation code. The more water you put in, the lesser the toxin concentration. /obj/machinery/hydroponics/proc/adjustHealth(adjustamt) if(myseed && !dead) - plant_health = Clamp(plant_health + adjustamt, 0, myseed.endurance) + plant_health = CLAMP(plant_health + adjustamt, 0, myseed.endurance) /obj/machinery/hydroponics/proc/adjustToxic(adjustamt) - toxic = Clamp(toxic + adjustamt, 0, 100) + toxic = CLAMP(toxic + adjustamt, 0, 100) /obj/machinery/hydroponics/proc/adjustPests(adjustamt) - pestlevel = Clamp(pestlevel + adjustamt, 0, 10) + pestlevel = CLAMP(pestlevel + adjustamt, 0, 10) /obj/machinery/hydroponics/proc/adjustWeeds(adjustamt) - weedlevel = Clamp(weedlevel + adjustamt, 0, 10) + weedlevel = CLAMP(weedlevel + adjustamt, 0, 10) /obj/machinery/hydroponics/proc/spawnplant() // why would you put strange reagent in a hydro tray you monster I bet you also feed them blood var/list/livingplants = list(/mob/living/simple_animal/hostile/tree, /mob/living/simple_animal/hostile/killertomato) diff --git a/code/modules/hydroponics/seeds.dm b/code/modules/hydroponics/seeds.dm index aa35b4ae07..56f80c548d 100644 --- a/code/modules/hydroponics/seeds.dm +++ b/code/modules/hydroponics/seeds.dm @@ -170,7 +170,7 @@ /// Setters procs /// /obj/item/seeds/proc/adjust_yield(adjustamt) if(yield != -1) // Unharvestable shouldn't suddenly turn harvestable - yield = Clamp(yield + adjustamt, 0, 10) + yield = CLAMP(yield + adjustamt, 0, 10) if(yield <= 0 && get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism)) yield = 1 // Mushrooms always have a minimum yield of 1. @@ -179,39 +179,39 @@ C.value = yield /obj/item/seeds/proc/adjust_lifespan(adjustamt) - lifespan = Clamp(lifespan + adjustamt, 10, 100) + lifespan = CLAMP(lifespan + adjustamt, 10, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/lifespan) if(C) C.value = lifespan /obj/item/seeds/proc/adjust_endurance(adjustamt) - endurance = Clamp(endurance + adjustamt, 10, 100) + endurance = CLAMP(endurance + adjustamt, 10, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/endurance) if(C) C.value = endurance /obj/item/seeds/proc/adjust_production(adjustamt) if(yield != -1) - production = Clamp(production + adjustamt, 1, 10) + production = CLAMP(production + adjustamt, 1, 10) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/production) if(C) C.value = production /obj/item/seeds/proc/adjust_potency(adjustamt) if(potency != -1) - potency = Clamp(potency + adjustamt, 0, 100) + potency = CLAMP(potency + adjustamt, 0, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/potency) if(C) C.value = potency /obj/item/seeds/proc/adjust_weed_rate(adjustamt) - weed_rate = Clamp(weed_rate + adjustamt, 0, 10) + weed_rate = CLAMP(weed_rate + adjustamt, 0, 10) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/weed_rate) if(C) C.value = weed_rate /obj/item/seeds/proc/adjust_weed_chance(adjustamt) - weed_chance = Clamp(weed_chance + adjustamt, 0, 67) + weed_chance = CLAMP(weed_chance + adjustamt, 0, 67) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/weed_chance) if(C) C.value = weed_chance @@ -220,7 +220,7 @@ /obj/item/seeds/proc/set_yield(adjustamt) if(yield != -1) // Unharvestable shouldn't suddenly turn harvestable - yield = Clamp(adjustamt, 0, 10) + yield = CLAMP(adjustamt, 0, 10) if(yield <= 0 && get_gene(/datum/plant_gene/trait/plant_type/fungal_metabolism)) yield = 1 // Mushrooms always have a minimum yield of 1. @@ -229,39 +229,39 @@ C.value = yield /obj/item/seeds/proc/set_lifespan(adjustamt) - lifespan = Clamp(adjustamt, 10, 100) + lifespan = CLAMP(adjustamt, 10, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/lifespan) if(C) C.value = lifespan /obj/item/seeds/proc/set_endurance(adjustamt) - endurance = Clamp(adjustamt, 10, 100) + endurance = CLAMP(adjustamt, 10, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/endurance) if(C) C.value = endurance /obj/item/seeds/proc/set_production(adjustamt) if(yield != -1) - production = Clamp(adjustamt, 1, 10) + production = CLAMP(adjustamt, 1, 10) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/production) if(C) C.value = production /obj/item/seeds/proc/set_potency(adjustamt) if(potency != -1) - potency = Clamp(adjustamt, 0, 100) + potency = CLAMP(adjustamt, 0, 100) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/potency) if(C) C.value = potency /obj/item/seeds/proc/set_weed_rate(adjustamt) - weed_rate = Clamp(adjustamt, 0, 10) + weed_rate = CLAMP(adjustamt, 0, 10) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/weed_rate) if(C) C.value = weed_rate /obj/item/seeds/proc/set_weed_chance(adjustamt) - weed_chance = Clamp(adjustamt, 0, 67) + weed_chance = CLAMP(adjustamt, 0, 67) var/datum/plant_gene/core/C = get_gene(/datum/plant_gene/core/weed_chance) if(C) C.value = weed_chance diff --git a/code/modules/integrated_electronics/core/special_pins/index_pin.dm b/code/modules/integrated_electronics/core/special_pins/index_pin.dm index 802a2612d3..51b12a0f3a 100644 --- a/code/modules/integrated_electronics/core/special_pins/index_pin.dm +++ b/code/modules/integrated_electronics/core/special_pins/index_pin.dm @@ -14,7 +14,7 @@ new_data = 1 if(isnum(new_data)) - data = Clamp(round(new_data), 1, IC_MAX_LIST_LENGTH) + data = CLAMP(round(new_data), 1, IC_MAX_LIST_LENGTH) holder.on_data_written() /datum/integrated_io/index/display_pin_type() diff --git a/code/modules/integrated_electronics/subtypes/converters.dm b/code/modules/integrated_electronics/subtypes/converters.dm index 272dbef071..4e4e447193 100644 --- a/code/modules/integrated_electronics/subtypes/converters.dm +++ b/code/modules/integrated_electronics/subtypes/converters.dm @@ -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() diff --git a/code/modules/integrated_electronics/subtypes/data_transfer.dm b/code/modules/integrated_electronics/subtypes/data_transfer.dm index 20b80926c8..a769a16768 100644 --- a/code/modules/integrated_electronics/subtypes/data_transfer.dm +++ b/code/modules/integrated_electronics/subtypes/data_transfer.dm @@ -123,7 +123,7 @@ /obj/item/integrated_circuit/transfer/pulsedemultiplexer/do_work() var/output_index = get_pin_data(IC_INPUT, 1) - if(output_index == Clamp(output_index, 1, number_of_pins)) + if(output_index == CLAMP(output_index, 1, number_of_pins)) activate_pin(round(output_index + 1 ,1)) /obj/item/integrated_circuit/transfer/pulsedemultiplexer/medium diff --git a/code/modules/integrated_electronics/subtypes/input.dm b/code/modules/integrated_electronics/subtypes/input.dm index 276d3d9ca0..c39cfeac44 100644 --- a/code/modules/integrated_electronics/subtypes/input.dm +++ b/code/modules/integrated_electronics/subtypes/input.dm @@ -373,7 +373,7 @@ var/rad = get_pin_data(IC_INPUT, 2) if(isnum(rad)) - rad = Clamp(rad, 0, 8) + rad = CLAMP(rad, 0, 8) radius = rad /obj/item/integrated_circuit/input/advanced_locator_list/do_work() @@ -426,7 +426,7 @@ /obj/item/integrated_circuit/input/advanced_locator/on_data_written() var/rad = get_pin_data(IC_INPUT, 2) if(isnum(rad)) - rad = Clamp(rad, 0, 8) + rad = CLAMP(rad, 0, 8) radius = rad /obj/item/integrated_circuit/input/advanced_locator/do_work() diff --git a/code/modules/integrated_electronics/subtypes/manipulation.dm b/code/modules/integrated_electronics/subtypes/manipulation.dm index 42a55f1a1d..f32f414fbb 100644 --- a/code/modules/integrated_electronics/subtypes/manipulation.dm +++ b/code/modules/integrated_electronics/subtypes/manipulation.dm @@ -93,8 +93,8 @@ yo.data = round(yo.data, 1) var/turf/T = get_turf(assembly) - var/target_x = Clamp(T.x + xo.data, 0, world.maxx) - var/target_y = Clamp(T.y + yo.data, 0, world.maxy) + var/target_x = CLAMP(T.x + xo.data, 0, world.maxx) + var/target_y = CLAMP(T.y + yo.data, 0, world.maxy) shootAt(locate(target_x, target_y, T.z)) @@ -210,7 +210,7 @@ var/datum/integrated_io/detonation_time = inputs[1] var/dt if(isnum(detonation_time.data) && detonation_time.data > 0) - dt = Clamp(detonation_time.data, 1, 12)*10 + dt = CLAMP(detonation_time.data, 1, 12)*10 else dt = 15 addtimer(CALLBACK(attached_grenade, /obj/item/grenade.proc/prime), dt) @@ -389,9 +389,9 @@ if(!M.temporarilyRemoveItemFromInventory(A)) return - var/x_abs = Clamp(T.x + target_x_rel, 0, world.maxx) - var/y_abs = Clamp(T.y + target_y_rel, 0, world.maxy) - var/range = round(Clamp(sqrt(target_x_rel*target_x_rel+target_y_rel*target_y_rel),0,8),1) + var/x_abs = CLAMP(T.x + target_x_rel, 0, world.maxx) + var/y_abs = CLAMP(T.y + target_y_rel, 0, world.maxy) + var/range = round(CLAMP(sqrt(target_x_rel*target_x_rel+target_y_rel*target_y_rel),0,8),1) A.forceMove(drop_location()) A.throw_at(locate(x_abs, y_abs, T.z), range, 3) diff --git a/code/modules/integrated_electronics/subtypes/output.dm b/code/modules/integrated_electronics/subtypes/output.dm index ef6cc644d8..6a90ff5f2a 100644 --- a/code/modules/integrated_electronics/subtypes/output.dm +++ b/code/modules/integrated_electronics/subtypes/output.dm @@ -88,7 +88,7 @@ var/brightness = get_pin_data(IC_INPUT, 2) if(new_color && isnum(brightness)) - brightness = Clamp(brightness, 0, 6) + brightness = CLAMP(brightness, 0, 6) light_rgb = new_color light_brightness = brightness @@ -146,7 +146,7 @@ var/selected_sound = sounds[ID] if(!selected_sound) return - vol = Clamp(vol ,0 , 100) + vol = CLAMP(vol ,0 , 100) playsound(get_turf(src), selected_sound, vol, freq, -1) /obj/item/integrated_circuit/output/sound/on_data_written() diff --git a/code/modules/integrated_electronics/subtypes/reagents.dm b/code/modules/integrated_electronics/subtypes/reagents.dm index 564c3a4851..78b1e9682e 100644 --- a/code/modules/integrated_electronics/subtypes/reagents.dm +++ b/code/modules/integrated_electronics/subtypes/reagents.dm @@ -111,7 +111,7 @@ else direction_mode = SYRINGE_INJECT if(isnum(new_amount)) - new_amount = Clamp(new_amount, 0, volume) + new_amount = CLAMP(new_amount, 0, volume) transfer_amount = new_amount // Hydroponics trays have no reagents holder and handle reagents in their own snowflakey way. @@ -184,7 +184,7 @@ activate_pin(3) return - var/tramount = Clamp(transfer_amount, 0, reagents.total_volume) + var/tramount = CLAMP(transfer_amount, 0, reagents.total_volume) if(isliving(AM)) var/mob/living/L = AM @@ -235,7 +235,7 @@ else direction_mode = SYRINGE_INJECT if(isnum(new_amount)) - new_amount = Clamp(new_amount, 0, 50) + new_amount = CLAMP(new_amount, 0, 50) transfer_amount = new_amount /obj/item/integrated_circuit/reagent/pump/do_work() @@ -383,7 +383,7 @@ else direction_mode = SYRINGE_INJECT if(isnum(new_amount)) - new_amount = Clamp(new_amount, 0, 50) + new_amount = CLAMP(new_amount, 0, 50) transfer_amount = new_amount /obj/item/integrated_circuit/reagent/filter/do_work() diff --git a/code/modules/integrated_electronics/subtypes/time.dm b/code/modules/integrated_electronics/subtypes/time.dm index 57fc16ccf9..d93aafef58 100644 --- a/code/modules/integrated_electronics/subtypes/time.dm +++ b/code/modules/integrated_electronics/subtypes/time.dm @@ -62,7 +62,7 @@ /obj/item/integrated_circuit/time/delay/custom/do_work() var/delay_input = get_pin_data(IC_INPUT, 1) if(delay_input && isnum(delay_input) ) - var/new_delay = Clamp(delay_input ,1 ,36000) //An hour. + var/new_delay = CLAMP(delay_input ,1 ,36000) //An hour. delay = new_delay ..() diff --git a/code/modules/integrated_electronics/subtypes/trig.dm b/code/modules/integrated_electronics/subtypes/trig.dm index 1d7f660bd4..cefa25e945 100644 --- a/code/modules/integrated_electronics/subtypes/trig.dm +++ b/code/modules/integrated_electronics/subtypes/trig.dm @@ -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() @@ -111,7 +111,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() @@ -131,7 +131,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() diff --git a/code/modules/language/language.dm b/code/modules/language/language.dm index 67881f7510..598fb41e6c 100644 --- a/code/modules/language/language.dm +++ b/code/modules/language/language.dm @@ -49,7 +49,7 @@ for(var/i in 0 to name_count) new_name = "" - var/Y = rand(Floor(syllable_count/syllable_divisor), syllable_count) + var/Y = rand(FLOOR(syllable_count/syllable_divisor, 1), syllable_count) for(var/x in Y to 0) new_name += pick(syllables) full_name += " [capitalize(lowertext(new_name))]" diff --git a/code/modules/library/lib_machines.dm b/code/modules/library/lib_machines.dm index 52077d2367..d47bb46c63 100644 --- a/code/modules/library/lib_machines.dm +++ b/code/modules/library/lib_machines.dm @@ -263,7 +263,7 @@ GLOBAL_LIST(cachedbooks) // List of our cached book datums dat += "(Order book by SS13BN)

" dat += "" dat += "" - dat += libcomp_menu[Clamp(page,1,libcomp_menu.len)] + dat += libcomp_menu[CLAMP(page,1,libcomp_menu.len)] dat += "" dat += "
AUTHORTITLECATEGORY
<<<< >>>>
" dat += "
(Return to main menu)
" @@ -444,7 +444,7 @@ GLOBAL_LIST(cachedbooks) // List of our cached book datums else var/orderid = input("Enter your order:") as num|null if(orderid) - if(isnum(orderid) && IsInteger(orderid)) + if(isnum(orderid) && ISINTEGER(orderid)) href_list["targetid"] = num2text(orderid) if(href_list["targetid"]) diff --git a/code/modules/lighting/lighting_source.dm b/code/modules/lighting/lighting_source.dm index 8e56acc2fb..a6c28b4146 100644 --- a/code/modules/lighting/lighting_source.dm +++ b/code/modules/lighting/lighting_source.dm @@ -232,8 +232,8 @@ var/turf/T if (source_turf) var/oldlum = source_turf.luminosity - source_turf.luminosity = Ceiling(light_range) - for(T in view(Ceiling(light_range), source_turf)) + source_turf.luminosity = CEILING(light_range, 1) + for(T in view(CEILING(light_range, 1), source_turf)) for (thing in T.get_corners(source_turf)) C = thing corners[C] = 0 diff --git a/code/modules/mapping/reader.dm b/code/modules/mapping/reader.dm index 862de852bc..559a93b87f 100644 --- a/code/modules/mapping/reader.dm +++ b/code/modules/mapping/reader.dm @@ -102,7 +102,7 @@ GLOBAL_DATUM_INIT(_preloader, /dmm_suite/preloader, new) if(!no_changeturf) WARNING("Z-level expansion occurred without no_changeturf set, this may cause problems when /turf/AfterChange is called") - bounds[MAP_MINX] = min(bounds[MAP_MINX], Clamp(xcrdStart, x_lower, x_upper)) + bounds[MAP_MINX] = min(bounds[MAP_MINX], CLAMP(xcrdStart, x_lower, x_upper)) bounds[MAP_MINZ] = min(bounds[MAP_MINZ], zcrd) bounds[MAP_MAXZ] = max(bounds[MAP_MAXZ], zcrd) @@ -119,15 +119,15 @@ GLOBAL_DATUM_INIT(_preloader, /dmm_suite/preloader, new) if(gridLines.len && gridLines[gridLines.len] == "") gridLines.Cut(gridLines.len) // Remove only one blank line at the end. - bounds[MAP_MINY] = min(bounds[MAP_MINY], Clamp(ycrd, y_lower, y_upper)) + bounds[MAP_MINY] = min(bounds[MAP_MINY], CLAMP(ycrd, y_lower, y_upper)) ycrd += gridLines.len - 1 // Start at the top and work down if(!cropMap && ycrd > world.maxy) if(!measureOnly) world.maxy = ycrd // Expand Y here. X is expanded in the loop below - bounds[MAP_MAXY] = max(bounds[MAP_MAXY], Clamp(ycrd, y_lower, y_upper)) + bounds[MAP_MAXY] = max(bounds[MAP_MAXY], CLAMP(ycrd, y_lower, y_upper)) else - bounds[MAP_MAXY] = max(bounds[MAP_MAXY], Clamp(min(ycrd, world.maxy), y_lower, y_upper)) + bounds[MAP_MAXY] = max(bounds[MAP_MAXY], CLAMP(min(ycrd, world.maxy), y_lower, y_upper)) var/maxx = xcrdStart if(measureOnly) @@ -166,7 +166,7 @@ GLOBAL_DATUM_INIT(_preloader, /dmm_suite/preloader, new) ++xcrd --ycrd - bounds[MAP_MAXX] = Clamp(max(bounds[MAP_MAXX], cropMap ? min(maxx, world.maxx) : maxx), x_lower, x_upper) + bounds[MAP_MAXX] = CLAMP(max(bounds[MAP_MAXX], cropMap ? min(maxx, world.maxx) : maxx), x_lower, x_upper) CHECK_TICK diff --git a/code/modules/mining/lavaland/necropolis_chests.dm b/code/modules/mining/lavaland/necropolis_chests.dm index 7fdecaaeb6..cf290112f4 100644 --- a/code/modules/mining/lavaland/necropolis_chests.dm +++ b/code/modules/mining/lavaland/necropolis_chests.dm @@ -799,13 +799,13 @@ force = 0 var/ghost_counter = ghost_check() - force = Clamp((ghost_counter * 4), 0, 75) + force = CLAMP((ghost_counter * 4), 0, 75) user.visible_message("[user] strikes with the force of [ghost_counter] vengeful spirits!") ..() /obj/item/melee/ghost_sword/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK) var/ghost_counter = ghost_check() - final_block_chance += Clamp((ghost_counter * 5), 0, 75) + final_block_chance += CLAMP((ghost_counter * 5), 0, 75) owner.visible_message("[owner] is protected by a ring of [ghost_counter] ghosts!") return ..() diff --git a/code/modules/mining/machine_redemption.dm b/code/modules/mining/machine_redemption.dm index 60715ef26a..e16eb0e5b2 100644 --- a/code/modules/mining/machine_redemption.dm +++ b/code/modules/mining/machine_redemption.dm @@ -82,7 +82,7 @@ if(!M || !redemption_mat) return FALSE - var/smeltable_sheets = Floor(redemption_mat.amount / M) + var/smeltable_sheets = FLOOR(redemption_mat.amount / M, 1) if(!smeltable_sheets) return FALSE diff --git a/code/modules/mining/mint.dm b/code/modules/mining/mint.dm index fe4c2fab84..ca21456163 100644 --- a/code/modules/mining/mint.dm +++ b/code/modules/mining/mint.dm @@ -68,7 +68,7 @@ if(materials.materials[href_list["choose"]]) chosen = href_list["choose"] if(href_list["chooseAmt"]) - coinsToProduce = Clamp(coinsToProduce + text2num(href_list["chooseAmt"]), 0, 1000) + coinsToProduce = CLAMP(coinsToProduce + text2num(href_list["chooseAmt"]), 0, 1000) if(href_list["makeCoins"]) var/temp_coins = coinsToProduce processing = TRUE diff --git a/code/modules/mob/dead/new_player/new_player.dm b/code/modules/mob/dead/new_player/new_player.dm index 458a54aa48..495b65bfa7 100644 --- a/code/modules/mob/dead/new_player/new_player.dm +++ b/code/modules/mob/dead/new_player/new_player.dm @@ -185,7 +185,7 @@ var/pollid = href_list["pollid"] if(istext(pollid)) pollid = text2num(pollid) - if(isnum(pollid) && IsInteger(pollid)) + if(isnum(pollid) && ISINTEGER(pollid)) src.poll_player(pollid) return @@ -223,7 +223,7 @@ rating = null else rating = text2num(href_list["o[optionid]"]) - if(!isnum(rating) || !IsInteger(rating)) + if(!isnum(rating) || !ISINTEGER(rating)) return if(!vote_on_numval_poll(pollid, optionid, rating)) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index d19f3d4bf8..c838376d28 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -462,7 +462,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp views |= i var/new_view = input("Choose your new view", "Modify view range", 7) as null|anything in views if(new_view) - client.change_view(Clamp(new_view, 7, max_view)) + client.change_view(CLAMP(new_view, 7, max_view)) else client.change_view(CONFIG_GET(string/default_view)) diff --git a/code/modules/mob/living/brain/brain_item.dm b/code/modules/mob/living/brain/brain_item.dm index db48302f49..aef5489b04 100644 --- a/code/modules/mob/living/brain/brain_item.dm +++ b/code/modules/mob/living/brain/brain_item.dm @@ -154,7 +154,7 @@ var/adjusted_amount if(amount >= 0 && maximum) var/brainloss = get_brain_damage() - var/new_brainloss = Clamp(brainloss + amount, 0, maximum) + var/new_brainloss = CLAMP(brainloss + amount, 0, maximum) if(brainloss > new_brainloss) //brainloss is over the cap already return 0 adjusted_amount = new_brainloss - brainloss diff --git a/code/modules/mob/living/carbon/alien/status_procs.dm b/code/modules/mob/living/carbon/alien/status_procs.dm index 61de87b6cb..33ba8fea1d 100644 --- a/code/modules/mob/living/carbon/alien/status_procs.dm +++ b/code/modules/mob/living/carbon/alien/status_procs.dm @@ -17,4 +17,4 @@ /mob/living/carbon/alien/AdjustStun(amount, updating = 1, ignore_canstun = 0) . = ..() if(!.) - move_delay_add = Clamp(move_delay_add + round(amount/2), 0, 10) + move_delay_add = CLAMP(move_delay_add + round(amount/2), 0, 10) diff --git a/code/modules/mob/living/carbon/damage_procs.dm b/code/modules/mob/living/carbon/damage_procs.dm index aecf966350..a6efaaa967 100644 --- a/code/modules/mob/living/carbon/damage_procs.dm +++ b/code/modules/mob/living/carbon/damage_procs.dm @@ -185,7 +185,7 @@ /mob/living/carbon/adjustStaminaLoss(amount, updating_stamina = 1) if(status_flags & GODMODE) return 0 - staminaloss = Clamp(staminaloss + amount, 0, maxHealth*2) + staminaloss = CLAMP(staminaloss + amount, 0, maxHealth*2) if(updating_stamina) update_stamina() diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index e8d4baba63..75800dc75f 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -89,15 +89,15 @@ for(var/obj/item/I in held_items) if(!istype(I, /obj/item/clothing)) - var/final_block_chance = I.block_chance - (Clamp((armour_penetration-I.armour_penetration)/2,0,100)) + block_chance_modifier //So armour piercing blades can still be parried by other blades, for example + var/final_block_chance = I.block_chance - (CLAMP((armour_penetration-I.armour_penetration)/2,0,100)) + block_chance_modifier //So armour piercing blades can still be parried by other blades, for example if(I.hit_reaction(src, AM, attack_text, final_block_chance, damage, attack_type)) return 1 if(wear_suit) - var/final_block_chance = wear_suit.block_chance - (Clamp((armour_penetration-wear_suit.armour_penetration)/2,0,100)) + block_chance_modifier + var/final_block_chance = wear_suit.block_chance - (CLAMP((armour_penetration-wear_suit.armour_penetration)/2,0,100)) + block_chance_modifier if(wear_suit.hit_reaction(src, AM, attack_text, final_block_chance, damage, attack_type)) return 1 if(w_uniform) - var/final_block_chance = w_uniform.block_chance - (Clamp((armour_penetration-w_uniform.armour_penetration)/2,0,100)) + block_chance_modifier + var/final_block_chance = w_uniform.block_chance - (CLAMP((armour_penetration-w_uniform.armour_penetration)/2,0,100)) + block_chance_modifier if(w_uniform.hit_reaction(src, AM, attack_text, final_block_chance, damage, attack_type)) return 1 return 0 diff --git a/code/modules/mob/living/carbon/human/species_types/golems.dm b/code/modules/mob/living/carbon/human/species_types/golems.dm index d2c83fa39f..2b86d2945d 100644 --- a/code/modules/mob/living/carbon/human/species_types/golems.dm +++ b/code/modules/mob/living/carbon/human/species_types/golems.dm @@ -369,7 +369,7 @@ var/new_y = P.starting.y + pick(0, 0, 0, 0, 0, -1, 1, -2, 2) var/turf/target = get_turf(P.starting) // redirect the projectile - P.preparePixelProjectile(locate(Clamp(target.x + new_x, 1, world.maxx), Clamp(target.y + new_y, 1, world.maxy), H.z), H) + P.preparePixelProjectile(locate(CLAMP(target.x + new_x, 1, world.maxx), CLAMP(target.y + new_y, 1, world.maxy), H.z), H) return -1 return 0 diff --git a/code/modules/mob/living/carbon/human/species_types/vampire.dm b/code/modules/mob/living/carbon/human/species_types/vampire.dm index 6d1384f12f..aff8440930 100644 --- a/code/modules/mob/living/carbon/human/species_types/vampire.dm +++ b/code/modules/mob/living/carbon/human/species_types/vampire.dm @@ -94,8 +94,8 @@ to_chat(victim, "[H] is draining your blood!") to_chat(H, "You drain some blood!") playsound(H, 'sound/items/drink.ogg', 30, 1, -2) - victim.blood_volume = Clamp(victim.blood_volume - drained_blood, 0, BLOOD_VOLUME_MAXIMUM) - H.blood_volume = Clamp(H.blood_volume + drained_blood, 0, BLOOD_VOLUME_MAXIMUM) + victim.blood_volume = CLAMP(victim.blood_volume - drained_blood, 0, BLOOD_VOLUME_MAXIMUM) + H.blood_volume = CLAMP(H.blood_volume + drained_blood, 0, BLOOD_VOLUME_MAXIMUM) if(!victim.blood_volume) to_chat(H, "You finish off [victim]'s blood supply!") diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm index 5eb09a8d83..4399607984 100644 --- a/code/modules/mob/living/carbon/life.dm +++ b/code/modules/mob/living/carbon/life.dm @@ -182,7 +182,7 @@ //TOXINS/PLASMA if(Toxins_partialpressure > safe_tox_max) var/ratio = (breath_gases[/datum/gas/plasma][MOLES]/safe_tox_max) * 10 - adjustToxLoss(Clamp(ratio, MIN_TOXIC_GAS_DAMAGE, MAX_TOXIC_GAS_DAMAGE)) + adjustToxLoss(CLAMP(ratio, MIN_TOXIC_GAS_DAMAGE, MAX_TOXIC_GAS_DAMAGE)) throw_alert("too_much_tox", /obj/screen/alert/too_much_tox) else clear_alert("too_much_tox") diff --git a/code/modules/mob/living/carbon/status_procs.dm b/code/modules/mob/living/carbon/status_procs.dm index e46ae2f8e6..7c40b6f144 100644 --- a/code/modules/mob/living/carbon/status_procs.dm +++ b/code/modules/mob/living/carbon/status_procs.dm @@ -59,10 +59,10 @@ clear_alert("high") /mob/living/carbon/adjust_disgust(amount) - disgust = Clamp(disgust+amount, 0, DISGUST_LEVEL_MAXEDOUT) + disgust = CLAMP(disgust+amount, 0, DISGUST_LEVEL_MAXEDOUT) /mob/living/carbon/set_disgust(amount) - disgust = Clamp(amount, 0, DISGUST_LEVEL_MAXEDOUT) + disgust = CLAMP(amount, 0, DISGUST_LEVEL_MAXEDOUT) /mob/living/carbon/cure_blind() if(disabilities & BLIND) diff --git a/code/modules/mob/living/damage_procs.dm b/code/modules/mob/living/damage_procs.dm index dbc8da5a05..9517e1b705 100644 --- a/code/modules/mob/living/damage_procs.dm +++ b/code/modules/mob/living/damage_procs.dm @@ -157,7 +157,7 @@ /mob/living/proc/adjustBruteLoss(amount, updating_health = TRUE, forced = FALSE) if(!forced && (status_flags & GODMODE)) return FALSE - bruteloss = Clamp((bruteloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) + bruteloss = CLAMP((bruteloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) if(updating_health) updatehealth() return amount @@ -168,7 +168,7 @@ /mob/living/proc/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE) if(!forced && (status_flags & GODMODE)) return FALSE - oxyloss = Clamp((oxyloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) + oxyloss = CLAMP((oxyloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) if(updating_health) updatehealth() return amount @@ -187,7 +187,7 @@ /mob/living/proc/adjustToxLoss(amount, updating_health = TRUE, forced = FALSE) if(!forced && (status_flags & GODMODE)) return FALSE - toxloss = Clamp((toxloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) + toxloss = CLAMP((toxloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) if(updating_health) updatehealth() return amount @@ -206,7 +206,7 @@ /mob/living/proc/adjustFireLoss(amount, updating_health = TRUE, forced = FALSE) if(!forced && (status_flags & GODMODE)) return FALSE - fireloss = Clamp((fireloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) + fireloss = CLAMP((fireloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) if(updating_health) updatehealth() return amount @@ -217,7 +217,7 @@ /mob/living/proc/adjustCloneLoss(amount, updating_health = TRUE, forced = FALSE) if(!forced && (status_flags & GODMODE)) return FALSE - cloneloss = Clamp((cloneloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) + cloneloss = CLAMP((cloneloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) if(updating_health) updatehealth() return amount diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index f589ecbb20..a5fac98d49 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -918,7 +918,7 @@ update_fire() /mob/living/proc/adjust_fire_stacks(add_fire_stacks) //Adjusting the amount of fire_stacks we have on person - fire_stacks = Clamp(fire_stacks + add_fire_stacks, -20, 20) + fire_stacks = CLAMP(fire_stacks + add_fire_stacks, -20, 20) if(on_fire && fire_stacks <= 0) ExtinguishMob() diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index f77c65225f..8d4f29a0ee 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -55,9 +55,9 @@ /obj/item/proc/get_volume_by_throwforce_and_or_w_class() if(throwforce && w_class) - return Clamp((throwforce + w_class) * 5, 30, 100)// Add the item's throwforce to its weight class and multiply by 5, then clamp the value between 30 and 100 + return CLAMP((throwforce + w_class) * 5, 30, 100)// Add the item's throwforce to its weight class and multiply by 5, then clamp the value between 30 and 100 else if(w_class) - return Clamp(w_class * 8, 20, 100) // Multiply the item's weight class by 8, then clamp the value between 20 and 100 + return CLAMP(w_class * 8, 20, 100) // Multiply the item's weight class by 8, then clamp the value between 20 and 100 else return 0 diff --git a/code/modules/mob/living/silicon/pai/pai.dm b/code/modules/mob/living/silicon/pai/pai.dm index b12430d26d..924ab615b8 100644 --- a/code/modules/mob/living/silicon/pai/pai.dm +++ b/code/modules/mob/living/silicon/pai/pai.dm @@ -138,7 +138,7 @@ /mob/living/silicon/pai/proc/process_hack() if(cable && cable.machine && istype(cable.machine, /obj/machinery/door) && cable.machine == hackdoor && get_dist(src, hackdoor) <= 1) - hackprogress = Clamp(hackprogress + 4, 0, 100) + hackprogress = CLAMP(hackprogress + 4, 0, 100) else temp = "Door Jack: Connection to airlock has been lost. Hack aborted." hackprogress = 0 @@ -283,8 +283,8 @@ /mob/living/silicon/pai/process() - emitterhealth = Clamp((emitterhealth + emitterregen), -50, emittermaxhealth) - hit_slowdown = Clamp((hit_slowdown - 1), 0, 100) + emitterhealth = CLAMP((emitterhealth + emitterregen), -50, emittermaxhealth) + hit_slowdown = CLAMP((hit_slowdown - 1), 0, 100) /mob/living/silicon/pai/generateStaticOverlay() return diff --git a/code/modules/mob/living/silicon/pai/pai_defense.dm b/code/modules/mob/living/silicon/pai/pai_defense.dm index 83da7d9087..2c6c42e3bb 100644 --- a/code/modules/mob/living/silicon/pai/pai_defense.dm +++ b/code/modules/mob/living/silicon/pai/pai_defense.dm @@ -57,7 +57,7 @@ return FALSE //No we're not flammable /mob/living/silicon/pai/proc/take_holo_damage(amount) - emitterhealth = Clamp((emitterhealth - amount), -50, emittermaxhealth) + emitterhealth = CLAMP((emitterhealth - amount), -50, emittermaxhealth) if(emitterhealth < 0) fold_in(force = TRUE) to_chat(src, "The impact degrades your holochassis!") diff --git a/code/modules/mob/living/silicon/robot/life.dm b/code/modules/mob/living/silicon/robot/life.dm index aab1f204f6..ce0571ca4e 100644 --- a/code/modules/mob/living/silicon/robot/life.dm +++ b/code/modules/mob/living/silicon/robot/life.dm @@ -23,7 +23,7 @@ if(cell && cell.charge) if(cell.charge <= 100) uneq_all() - var/amt = Clamp((lamp_intensity - 2) * 2,1,cell.charge) //Always try to use at least one charge per tick, but allow it to completely drain the cell. + var/amt = CLAMP((lamp_intensity - 2) * 2,1,cell.charge) //Always try to use at least one charge per tick, but allow it to completely drain the cell. cell.use(amt) //Usage table: 1/tick if off/lowest setting, 4 = 4/tick, 6 = 8/tick, 8 = 12/tick, 10 = 16/tick else uneq_all() diff --git a/code/modules/mob/living/simple_animal/damage_procs.dm b/code/modules/mob/living/simple_animal/damage_procs.dm index 5405ee03c6..bb6794a36a 100644 --- a/code/modules/mob/living/simple_animal/damage_procs.dm +++ b/code/modules/mob/living/simple_animal/damage_procs.dm @@ -2,7 +2,7 @@ /mob/living/simple_animal/proc/adjustHealth(amount, updating_health = TRUE, forced = FALSE) if(!forced && (status_flags & GODMODE)) return FALSE - bruteloss = Clamp(bruteloss + amount, 0, maxHealth) + bruteloss = CLAMP(bruteloss + amount, 0, maxHealth) if(updating_health) updatehealth() return amount diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm index a977338008..c6f0f6a91c 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/bubblegum.dm @@ -79,10 +79,10 @@ Difficulty: Hard /mob/living/simple_animal/hostile/megafauna/bubblegum/Life() ..() - move_to_delay = Clamp((health/maxHealth) * 10, 5, 10) + move_to_delay = CLAMP((health/maxHealth) * 10, 5, 10) /mob/living/simple_animal/hostile/megafauna/bubblegum/OpenFire() - anger_modifier = Clamp(((maxHealth - health)/60),0,20) + anger_modifier = CLAMP(((maxHealth - health)/60),0,20) if(charging) return ranged_cooldown = world.time + ranged_cooldown_time diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm index 58e3e0837b..d47385efc3 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/colossus.dm @@ -57,7 +57,7 @@ Difficulty: Very Hard L.dust() /mob/living/simple_animal/hostile/megafauna/colossus/OpenFire() - anger_modifier = Clamp(((maxHealth - health)/50),0,20) + anger_modifier = CLAMP(((maxHealth - health)/50),0,20) ranged_cooldown = world.time + 120 if(enrage(target)) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/dragon.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/dragon.dm index 7f12e684e8..724e4fc5c7 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/dragon.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/dragon.dm @@ -101,7 +101,7 @@ Difficulty: Medium /mob/living/simple_animal/hostile/megafauna/dragon/OpenFire() if(swooping) return - anger_modifier = Clamp(((maxHealth - health)/50),0,20) + anger_modifier = CLAMP(((maxHealth - health)/50),0,20) ranged_cooldown = world.time + ranged_cooldown_time if(prob(15 + anger_modifier) && !client) @@ -227,10 +227,10 @@ Difficulty: Medium //ensure swoop direction continuity. if(negative) - if(IsInRange(x, initial_x + 1, initial_x + DRAKE_SWOOP_DIRECTION_CHANGE_RANGE)) + if(ISINRANGE(x, initial_x + 1, initial_x + DRAKE_SWOOP_DIRECTION_CHANGE_RANGE)) negative = FALSE else - if(IsInRange(x, initial_x - DRAKE_SWOOP_DIRECTION_CHANGE_RANGE, initial_x - 1)) + if(ISINRANGE(x, initial_x - DRAKE_SWOOP_DIRECTION_CHANGE_RANGE, initial_x - 1)) negative = TRUE new /obj/effect/temp_visual/dragon_flight/end(loc, negative) new /obj/effect/temp_visual/dragon_swoop(loc) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm index 02fb81a1ed..8dc1780e5e 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm @@ -187,7 +187,7 @@ Difficulty: Hard /mob/living/simple_animal/hostile/megafauna/hierophant/proc/calculate_rage() //how angry we are overall did_reset = FALSE //oh hey we're doing SOMETHING, clearly we might need to heal if we recall - anger_modifier = Clamp(((maxHealth - health) / 42),0,50) + anger_modifier = CLAMP(((maxHealth - health) / 42),0,50) burst_range = initial(burst_range) + round(anger_modifier * 0.08) beam_range = initial(beam_range) + round(anger_modifier * 0.12) diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index a4851bb432..4c5b94f2e3 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -111,7 +111,7 @@ /mob/living/simple_animal/updatehealth() ..() - health = Clamp(health, 0, maxHealth) + health = CLAMP(health, 0, maxHealth) /mob/living/simple_animal/update_stat() if(status_flags & GODMODE) diff --git a/code/modules/mob/living/simple_animal/slime/powers.dm b/code/modules/mob/living/simple_animal/slime/powers.dm index e7e71bf091..9654f91b6c 100644 --- a/code/modules/mob/living/simple_animal/slime/powers.dm +++ b/code/modules/mob/living/simple_animal/slime/powers.dm @@ -166,7 +166,7 @@ step_away(M,src) M.Friends = Friends.Copy() babies += M - M.mutation_chance = Clamp(mutation_chance+(rand(5,-5)),0,100) + M.mutation_chance = CLAMP(mutation_chance+(rand(5,-5)),0,100) SSblackbox.record_feedback("tally", "slime_babies_born", 1, M.colour) var/mob/living/simple_animal/slime/new_slime = pick(babies) diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 7f3b428978..40401cf0a8 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -153,7 +153,7 @@ GLOB.apcs_list -= src if(malfai && operating) - malfai.malf_picker.processing_time = Clamp(malfai.malf_picker.processing_time - 10,0,1000) + malfai.malf_picker.processing_time = CLAMP(malfai.malf_picker.processing_time - 10,0,1000) area.power_light = FALSE area.power_equip = FALSE area.power_environ = FALSE @@ -1253,7 +1253,7 @@ /obj/machinery/power/apc/proc/set_broken() if(malfai && operating) - malfai.malf_picker.processing_time = Clamp(malfai.malf_picker.processing_time - 10,0,1000) + malfai.malf_picker.processing_time = CLAMP(malfai.malf_picker.processing_time - 10,0,1000) stat |= BROKEN operating = FALSE if(occupier) diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index 1e1407e852..2d85612e1b 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -155,7 +155,7 @@ /obj/item/stock_parts/cell/proc/get_electrocute_damage() if(charge >= 1000) - return Clamp(round(charge/10000), 10, 90) + rand(-5,5) + return CLAMP(round(charge/10000), 10, 90) + rand(-5,5) else return 0 @@ -334,7 +334,7 @@ return /obj/item/stock_parts/cell/beam_rifle/emp_act(severity) - charge = Clamp((charge-(10000/severity)),0,maxcharge) + charge = CLAMP((charge-(10000/severity)),0,maxcharge) /obj/item/stock_parts/cell/emergency_light name = "miniature power cell" diff --git a/code/modules/power/powernet.dm b/code/modules/power/powernet.dm index b6f61103ca..c34edc53f3 100644 --- a/code/modules/power/powernet.dm +++ b/code/modules/power/powernet.dm @@ -94,6 +94,6 @@ /datum/powernet/proc/get_electrocute_damage() if(avail >= 1000) - return Clamp(round(avail/10000), 10, 90) + rand(-5,5) + return CLAMP(round(avail/10000), 10, 90) + rand(-5,5) else return 0 \ No newline at end of file diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm index 70776b5c05..95b78ff0b5 100644 --- a/code/modules/power/smes.dm +++ b/code/modules/power/smes.dm @@ -227,7 +227,7 @@ /obj/machinery/power/smes/proc/chargedisplay() - return Clamp(round(5.5*charge/capacity),0,5) + return CLAMP(round(5.5*charge/capacity),0,5) /obj/machinery/power/smes/process() if(stat & BROKEN) @@ -382,7 +382,7 @@ target = text2num(target) . = TRUE if(.) - input_level = Clamp(target, 0, input_level_max) + input_level = CLAMP(target, 0, input_level_max) log_smes(usr.ckey) if("output") var/target = params["target"] @@ -404,7 +404,7 @@ target = text2num(target) . = TRUE if(.) - output_level = Clamp(target, 0, output_level_max) + output_level = CLAMP(target, 0, output_level_max) log_smes(usr.ckey) /obj/machinery/power/smes/proc/log_smes(user = "") diff --git a/code/modules/power/solar.dm b/code/modules/power/solar.dm index fb530f128f..ab8009df55 100644 --- a/code/modules/power/solar.dm +++ b/code/modules/power/solar.dm @@ -378,14 +378,14 @@ if("direction") var/adjust = text2num(params["adjust"]) if(adjust) - currentdir = Clamp((360 + adjust + currentdir) % 360, 0, 359) + currentdir = CLAMP((360 + adjust + currentdir) % 360, 0, 359) targetdir = currentdir set_panels(currentdir) . = TRUE if("rate") var/adjust = text2num(params["adjust"]) if(adjust) - trackrate = Clamp(trackrate + adjust, -7200, 7200) + trackrate = CLAMP(trackrate + adjust, -7200, 7200) if(trackrate) nexttime = world.time + 36000 / abs(trackrate) . = TRUE diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm index 02cc80291e..5f9f6042d3 100644 --- a/code/modules/power/supermatter/supermatter.dm +++ b/code/modules/power/supermatter/supermatter.dm @@ -317,10 +317,10 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_shard) mole_heat_penalty = max(combined_gas / MOLE_HEAT_PENALTY, 0.25) if (combined_gas > POWERLOSS_INHIBITION_MOLE_THRESHOLD && co2comp > POWERLOSS_INHIBITION_GAS_THRESHOLD) - powerloss_dynamic_scaling = Clamp(powerloss_dynamic_scaling + Clamp(co2comp - powerloss_dynamic_scaling, -0.02, 0.02), 0, 1) + powerloss_dynamic_scaling = CLAMP(powerloss_dynamic_scaling + CLAMP(co2comp - powerloss_dynamic_scaling, -0.02, 0.02), 0, 1) else - powerloss_dynamic_scaling = Clamp(powerloss_dynamic_scaling - 0.05,0, 1) - powerloss_inhibitor = Clamp(1-(powerloss_dynamic_scaling * Clamp(combined_gas/POWERLOSS_INHIBITION_MOLE_BOOST_THRESHOLD,1 ,1.5)),0 ,1) + powerloss_dynamic_scaling = CLAMP(powerloss_dynamic_scaling - 0.05,0, 1) + powerloss_inhibitor = CLAMP(1-(powerloss_dynamic_scaling * CLAMP(combined_gas/POWERLOSS_INHIBITION_MOLE_BOOST_THRESHOLD,1 ,1.5)),0 ,1) if(matter_power) var/removed_matter = max(matter_power/MATTER_POWER_CONVERSION, 40) @@ -368,7 +368,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_shard) if(!istype(l.glasses, /obj/item/clothing/glasses/meson)) var/D = sqrt(1 / max(1, get_dist(l, src))) l.hallucination += power * config_hallucination_power * D - l.hallucination = Clamp(0, 200, l.hallucination) + l.hallucination = CLAMP(0, 200, l.hallucination) for(var/mob/living/l in range(src, round((power / 100) ** 0.25))) var/rads = (power / 10) * sqrt( 1 / max(get_dist(l, src),1) ) @@ -386,7 +386,7 @@ GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_shard) supermatter_zap(src, 5, min(power*2, 20000)) else if (damage > damage_penalty_point && prob(20)) playsound(src.loc, 'sound/weapons/emitter2.ogg', 100, 1, extrarange = 10) - supermatter_zap(src, 5, Clamp(power*2, 4000, 20000)) + supermatter_zap(src, 5, CLAMP(power*2, 4000, 20000)) if(prob(15) && power > POWER_PENALTY_THRESHOLD) supermatter_pull(src, power/750) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 4a26950217..51cb99a34f 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -62,7 +62,7 @@ pixel_x = -32 pixel_y = -32 for (var/ball in orbiting_balls) - var/range = rand(1, Clamp(orbiting_balls.len, 3, 7)) + var/range = rand(1, CLAMP(orbiting_balls.len, 3, 7)) tesla_zap(ball, range, TESLA_MINI_POWER/7*range, TRUE) else energy = 0 // ensure we dont have miniballs of miniballs @@ -268,7 +268,7 @@ closest_grounding_rod.tesla_act(power, explosive, stun_mobs) else if(closest_mob) - var/shock_damage = Clamp(round(power/400), 10, 90) + rand(-5, 5) + var/shock_damage = CLAMP(round(power/400), 10, 90) + rand(-5, 5) closest_mob.electrocute_act(shock_damage, source, 1, tesla_shock = 1, stun = stun_mobs) if(issilicon(closest_mob)) var/mob/living/silicon/S = closest_mob diff --git a/code/modules/projectiles/boxes_magazines/external_mag.dm b/code/modules/projectiles/boxes_magazines/external_mag.dm index 09ae7cb905..b7b3a3e286 100644 --- a/code/modules/projectiles/boxes_magazines/external_mag.dm +++ b/code/modules/projectiles/boxes_magazines/external_mag.dm @@ -176,7 +176,7 @@ /obj/item/ammo_box/magazine/m12g/update_icon() ..() - icon_state = "[initial(icon_state)]-[Ceiling(ammo_count(0)/8)*8]" + icon_state = "[initial(icon_state)]-[CEILING(ammo_count(0)/8, 1)*8]" /obj/item/ammo_box/magazine/m12g/buckshot name = "shotgun magazine (12g buckshot slugs)" diff --git a/code/modules/projectiles/guns/ballistic/automatic.dm b/code/modules/projectiles/guns/ballistic/automatic.dm index eb36608e77..f392fda24e 100644 --- a/code/modules/projectiles/guns/ballistic/automatic.dm +++ b/code/modules/projectiles/guns/ballistic/automatic.dm @@ -108,7 +108,7 @@ /obj/item/gun/ballistic/automatic/c20r/update_icon() ..() - icon_state = "c20r[magazine ? "-[Ceiling(get_ammo(0)/4)*4]" : ""][chambered ? "" : "-e"][suppressed ? "-suppressed" : ""]" + icon_state = "c20r[magazine ? "-[CEILING(get_ammo(0)/4, 1)*4]" : ""][chambered ? "" : "-e"][suppressed ? "-suppressed" : ""]" /obj/item/gun/ballistic/automatic/wt550 name = "security auto rifle" @@ -123,7 +123,7 @@ /obj/item/gun/ballistic/automatic/wt550/update_icon() ..() - icon_state = "wt550[magazine ? "-[Ceiling(get_ammo(0)/4)*4]" : ""]" + icon_state = "wt550[magazine ? "-[CEILING(get_ammo(0)/4, 1)*4]" : ""]" /obj/item/gun/ballistic/automatic/mini_uzi name = "\improper Type U3 Uzi" @@ -304,7 +304,7 @@ /obj/item/gun/ballistic/automatic/l6_saw/update_icon() - icon_state = "l6[cover_open ? "open" : "closed"][magazine ? Ceiling(get_ammo(0)/12.5)*25 : "-empty"][suppressed ? "-suppressed" : ""]" + icon_state = "l6[cover_open ? "open" : "closed"][magazine ? CEILING(get_ammo(0)/12.5, 1)*25 : "-empty"][suppressed ? "-suppressed" : ""]" item_state = "l6[cover_open ? "openmag" : "closedmag"]" @@ -415,5 +415,5 @@ /obj/item/gun/ballistic/automatic/laser/update_icon() ..() - icon_state = "oldrifle[magazine ? "-[Ceiling(get_ammo(0)/4)*4]" : ""]" + icon_state = "oldrifle[magazine ? "-[CEILING(get_ammo(0)/4, 1)*4]" : ""]" return diff --git a/code/modules/projectiles/guns/beam_rifle.dm b/code/modules/projectiles/guns/beam_rifle.dm index e1069a6bce..7443286d24 100644 --- a/code/modules/projectiles/guns/beam_rifle.dm +++ b/code/modules/projectiles/guns/beam_rifle.dm @@ -365,7 +365,7 @@ AC.sync_stats() /obj/item/gun/energy/beam_rifle/proc/delay_penalty(amount) - aiming_time_left = Clamp(aiming_time_left + amount, 0, aiming_time) + aiming_time_left = CLAMP(aiming_time_left + amount, 0, aiming_time) /obj/item/ammo_casing/energy/beam_rifle name = "particle acceleration lens" @@ -416,11 +416,11 @@ HS_BB.stun = projectile_stun HS_BB.impact_structure_damage = impact_structure_damage HS_BB.aoe_mob_damage = aoe_mob_damage - HS_BB.aoe_mob_range = Clamp(aoe_mob_range, 0, 15) //Badmin safety lock + HS_BB.aoe_mob_range = CLAMP(aoe_mob_range, 0, 15) //Badmin safety lock HS_BB.aoe_fire_chance = aoe_fire_chance HS_BB.aoe_fire_range = aoe_fire_range HS_BB.aoe_structure_damage = aoe_structure_damage - HS_BB.aoe_structure_range = Clamp(aoe_structure_range, 0, 15) //Badmin safety lock + HS_BB.aoe_structure_range = CLAMP(aoe_structure_range, 0, 15) //Badmin safety lock HS_BB.wall_devastate = wall_devastate HS_BB.wall_pierce_amount = wall_pierce_amount HS_BB.structure_pierce_amount = structure_piercing diff --git a/code/modules/projectiles/guns/energy.dm b/code/modules/projectiles/guns/energy.dm index 3adadb90eb..12b0c57d38 100644 --- a/code/modules/projectiles/guns/energy.dm +++ b/code/modules/projectiles/guns/energy.dm @@ -130,7 +130,7 @@ ..() if(!automatic_charge_overlays) return - var/ratio = Ceiling((cell.charge / cell.maxcharge) * charge_sections) + var/ratio = CEILING((cell.charge / cell.maxcharge) * charge_sections, 1) var/obj/item/ammo_casing/energy/shot = ammo_type[select] var/iconState = "[icon_state]_charge" var/itemState = null diff --git a/code/modules/projectiles/guns/magic/wand.dm b/code/modules/projectiles/guns/magic/wand.dm index 27fb040de4..bf3ade0748 100644 --- a/code/modules/projectiles/guns/magic/wand.dm +++ b/code/modules/projectiles/guns/magic/wand.dm @@ -12,9 +12,9 @@ /obj/item/gun/magic/wand/Initialize() if(prob(75) && variable_charges) //25% chance of listed max charges, 50% chance of 1/2 max charges, 25% chance of 1/3 max charges if(prob(33)) - max_charges = Ceiling(max_charges / 3) + max_charges = CEILING(max_charges / 3, 1) else - max_charges = Ceiling(max_charges / 2) + max_charges = CEILING(max_charges / 2, 1) return ..() /obj/item/gun/magic/wand/examine(mob/user) diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 0e3bd98c68..79e2fdf903 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -168,7 +168,7 @@ /obj/item/projectile/proc/vol_by_damage() if(src.damage) - return Clamp((src.damage) * 0.67, 30, 100)// Multiply projectile damage by 0.67, then clamp the value between 30 and 100 + return CLAMP((src.damage) * 0.67, 30, 100)// Multiply projectile damage by 0.67, then clamp the value between 30 and 100 else return 50 //if the projectile doesn't do damage, play its hitsound at 50% volume @@ -188,7 +188,7 @@ def_zone = ran_zone(def_zone, max(100-(7*distance), 5)) //Lower accurancy/longer range tradeoff. 7 is a balanced number to use. if(isturf(A) && hitsound_wall) - var/volume = Clamp(vol_by_damage() + 20, 0, 100) + var/volume = CLAMP(vol_by_damage() + 20, 0, 100) if(suppressed) volume = 5 playsound(loc, hitsound_wall, volume, 1, -1) @@ -259,7 +259,7 @@ return var/elapsed_time_deciseconds = (world.time - last_projectile_move) + time_offset time_offset = 0 - var/required_moves = speed > 0? Floor(elapsed_time_deciseconds / speed) : MOVES_HITSCAN //Would be better if a 0 speed made hitscan but everyone hates those so I can't make it a universal system :< + var/required_moves = speed > 0? FLOOR(elapsed_time_deciseconds / speed, 1) : MOVES_HITSCAN //Would be better if a 0 speed made hitscan but everyone hates those so I can't make it a universal system :< if(required_moves == MOVES_HITSCAN) required_moves = SSprojectiles.global_max_tick_moves else @@ -267,7 +267,7 @@ var/overrun = required_moves - SSprojectiles.global_max_tick_moves required_moves = SSprojectiles.global_max_tick_moves time_offset += overrun * speed - time_offset += Modulus(elapsed_time_deciseconds, speed) + time_offset += MODULUS(elapsed_time_deciseconds, speed) for(var/i in 1 to required_moves) pixel_move(required_moves) @@ -287,7 +287,7 @@ setAngle(Angle + ((rand() - 0.5) * spread)) if(isnull(Angle)) //Try to resolve through offsets if there's no angle set. var/turf/starting = get_turf(src) - var/turf/target = locate(Clamp(starting + xo, 1, world.maxx), Clamp(starting + yo, 1, world.maxy), starting.z) + var/turf/target = locate(CLAMP(starting + xo, 1, world.maxx), CLAMP(starting + yo, 1, world.maxy), starting.z) setAngle(Get_Angle(src, target)) if(!nondirectional_sprite) var/matrix/M = new @@ -403,7 +403,7 @@ var/ox = round(screenviewX/2) - user.client.pixel_x //"origin" x var/oy = round(screenviewY/2) - user.client.pixel_y //"origin" y - angle = Atan2(y - oy, x - ox) + angle = ATAN2(y - oy, x - ox) return list(angle, p_x, p_y) /obj/item/projectile/Crossed(atom/movable/AM) //A mob moving on a tile with a projectile is hit by it. diff --git a/code/modules/reagents/chemistry/holder.dm b/code/modules/reagents/chemistry/holder.dm index 9c4bff72cb..ef609696a2 100644 --- a/code/modules/reagents/chemistry/holder.dm +++ b/code/modules/reagents/chemistry/holder.dm @@ -580,7 +580,7 @@ if (R.id == reagent) //clamp the removal amount to be between current reagent amount //and zero, to prevent removing more than the holder has stored - amount = Clamp(amount, 0, R.volume) + amount = CLAMP(amount, 0, R.volume) R.volume -= amount update_total() if(!safety)//So it does not handle reactions when it need not to diff --git a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm index 745843474e..51ddf549e0 100644 --- a/code/modules/reagents/chemistry/machinery/chem_dispenser.dm +++ b/code/modules/reagents/chemistry/machinery/chem_dispenser.dm @@ -211,7 +211,7 @@ /obj/machinery/chem_dispenser/emp_act(severity) var/list/datum/reagents/R = list() - var/total = min(rand(7,15), Floor(cell.charge*powerefficiency)) + var/total = min(rand(7,15), FLOOR(cell.charge*powerefficiency, 1)) var/datum/reagents/Q = new(total*10) if(beaker && beaker.reagents) R += beaker.reagents diff --git a/code/modules/reagents/chemistry/machinery/chem_heater.dm b/code/modules/reagents/chemistry/machinery/chem_heater.dm index a6d958220a..722ddbf15f 100644 --- a/code/modules/reagents/chemistry/machinery/chem_heater.dm +++ b/code/modules/reagents/chemistry/machinery/chem_heater.dm @@ -126,7 +126,7 @@ target = text2num(target) . = TRUE if(.) - target_temperature = Clamp(target, 0, 1000) + target_temperature = CLAMP(target, 0, 1000) if("eject") on = FALSE eject_beaker() diff --git a/code/modules/reagents/chemistry/machinery/chem_master.dm b/code/modules/reagents/chemistry/machinery/chem_master.dm index 3e06449e3a..631a027d9a 100644 --- a/code/modules/reagents/chemistry/machinery/chem_master.dm +++ b/code/modules/reagents/chemistry/machinery/chem_master.dm @@ -215,7 +215,7 @@ var/amount = 1 var/vol_each = min(reagents.total_volume, 50) if(text2num(many)) - amount = Clamp(round(input(usr, "Max 10. Buffer content will be split evenly.", "How many pills?", amount) as num|null), 0, 10) + amount = CLAMP(round(input(usr, "Max 10. Buffer content will be split evenly.", "How many pills?", amount) as num|null), 0, 10) if(!amount) return vol_each = min(reagents.total_volume / amount, 50) @@ -251,7 +251,7 @@ var/amount = 1 var/vol_each = min(reagents.total_volume, 40) if(text2num(many)) - amount = Clamp(round(input(usr, "Max 10. Buffer content will be split evenly.", "How many patches?", amount) as num|null), 0, 10) + amount = CLAMP(round(input(usr, "Max 10. Buffer content will be split evenly.", "How many patches?", amount) as num|null), 0, 10) if(!amount) return vol_each = min(reagents.total_volume / amount, 40) diff --git a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm index 77fcd50306..1369a4e959 100644 --- a/code/modules/reagents/chemistry/machinery/reagentgrinder.dm +++ b/code/modules/reagents/chemistry/machinery/reagentgrinder.dm @@ -484,7 +484,7 @@ /obj/machinery/reagentgrinder/proc/mix_complete() if(beaker && beaker.reagents.total_volume) //Recipe to make Butter - var/butter_amt = Floor(beaker.reagents.get_reagent_amount("milk") / MILK_TO_BUTTER_COEFF) + var/butter_amt = FLOOR(beaker.reagents.get_reagent_amount("milk") / MILK_TO_BUTTER_COEFF, 1) beaker.reagents.remove_reagent("milk", MILK_TO_BUTTER_COEFF * butter_amt) for(var/i in 1 to butter_amt) new /obj/item/reagent_containers/food/snacks/butter(drop_location()) diff --git a/code/modules/reagents/chemistry/reagents.dm b/code/modules/reagents/chemistry/reagents.dm index 5f76a87654..9f8e129420 100644 --- a/code/modules/reagents/chemistry/reagents.dm +++ b/code/modules/reagents/chemistry/reagents.dm @@ -41,7 +41,7 @@ return 0 if(method == VAPOR) //smoke, foam, spray if(M.reagents) - var/modifier = Clamp((1 - touch_protection), 0, 1) + var/modifier = CLAMP((1 - touch_protection), 0, 1) var/amount = round(reac_volume*modifier, 0.1) if(amount >= 0.5) M.reagents.add_reagent(id, amount) diff --git a/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm b/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm index 6a3b1a1637..00fd7d56a3 100644 --- a/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm @@ -961,7 +961,7 @@ All effects don't start immediately, but rather get worse over time; the rate is var/datum/antagonist/changeling/changeling = M.mind.has_antag_datum(/datum/antagonist/changeling) if(changeling) changeling.chem_charges += metabolization_rate - changeling.chem_charges = Clamp(changeling.chem_charges, 0, changeling.chem_storage) + changeling.chem_charges = CLAMP(changeling.chem_charges, 0, changeling.chem_storage) return ..() /datum/reagent/consumable/ethanol/irishcarbomb diff --git a/code/modules/reagents/chemistry/reagents/toxin_reagents.dm b/code/modules/reagents/chemistry/reagents/toxin_reagents.dm index 711c333896..7bee2ef958 100644 --- a/code/modules/reagents/chemistry/reagents/toxin_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/toxin_reagents.dm @@ -850,9 +850,9 @@ /datum/reagent/toxin/peaceborg/confuse/on_mob_life(mob/living/M) if(M.confused < 6) - M.confused = Clamp(M.confused + 3, 0, 5) + M.confused = CLAMP(M.confused + 3, 0, 5) if(M.dizziness < 6) - M.dizziness = Clamp(M.dizziness + 3, 0, 5) + M.dizziness = CLAMP(M.dizziness + 3, 0, 5) if(prob(20)) to_chat(M, "You feel confused and disorientated.") ..() diff --git a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm index 0e645e3798..b77dcc435a 100644 --- a/code/modules/reagents/chemistry/recipes/pyrotechnics.dm +++ b/code/modules/reagents/chemistry/recipes/pyrotechnics.dm @@ -168,7 +168,7 @@ return holder.remove_reagent("sorium", created_volume*4) var/turf/T = get_turf(holder.my_atom) - var/range = Clamp(sqrt(created_volume*4), 1, 6) + var/range = CLAMP(sqrt(created_volume*4), 1, 6) goonchem_vortex(T, 1, range) /datum/chemical_reaction/sorium_vortex @@ -179,7 +179,7 @@ /datum/chemical_reaction/sorium_vortex/on_reaction(datum/reagents/holder, created_volume) var/turf/T = get_turf(holder.my_atom) - var/range = Clamp(sqrt(created_volume), 1, 6) + var/range = CLAMP(sqrt(created_volume), 1, 6) goonchem_vortex(T, 1, range) /datum/chemical_reaction/liquid_dark_matter @@ -193,7 +193,7 @@ return holder.remove_reagent("liquid_dark_matter", created_volume*3) var/turf/T = get_turf(holder.my_atom) - var/range = Clamp(sqrt(created_volume*3), 1, 6) + var/range = CLAMP(sqrt(created_volume*3), 1, 6) goonchem_vortex(T, 0, range) /datum/chemical_reaction/ldm_vortex @@ -204,7 +204,7 @@ /datum/chemical_reaction/ldm_vortex/on_reaction(datum/reagents/holder, created_volume) var/turf/T = get_turf(holder.my_atom) - var/range = Clamp(sqrt(created_volume/2), 1, 6) + var/range = CLAMP(sqrt(created_volume/2), 1, 6) goonchem_vortex(T, 0, range) /datum/chemical_reaction/flash_powder diff --git a/code/modules/reagents/reagent_containers/syringes.dm b/code/modules/reagents/reagent_containers/syringes.dm index 87fb2b8a9e..d60d415e9a 100644 --- a/code/modules/reagents/reagent_containers/syringes.dm +++ b/code/modules/reagents/reagent_containers/syringes.dm @@ -157,7 +157,7 @@ /obj/item/reagent_containers/syringe/update_icon() - var/rounded_vol = Clamp(round((reagents.total_volume / volume * 15),5), 0, 15) + var/rounded_vol = CLAMP(round((reagents.total_volume / volume * 15),5), 0, 15) cut_overlays() if(ismob(loc)) var/injoverlay diff --git a/code/modules/recycling/disposal/bin.dm b/code/modules/recycling/disposal/bin.dm index ed14ae63c1..c58704de4b 100644 --- a/code/modules/recycling/disposal/bin.dm +++ b/code/modules/recycling/disposal/bin.dm @@ -297,7 +297,7 @@ data["full_pressure"] = full_pressure data["pressure_charging"] = pressure_charging data["panel_open"] = panel_open - var/per = Clamp(100* air_contents.return_pressure() / (SEND_PRESSURE), 0, 100) + var/per = CLAMP(100* air_contents.return_pressure() / (SEND_PRESSURE), 0, 100) data["per"] = round(per, 1) data["isai"] = isAI(user) return data diff --git a/code/modules/research/protolathe.dm b/code/modules/research/protolathe.dm index 6c52fd4678..521f1d7f29 100644 --- a/code/modules/research/protolathe.dm +++ b/code/modules/research/protolathe.dm @@ -93,7 +93,7 @@ Note: Must be placed west/left of and R&D console to function. return FALSE var/power = 1000 - amount = Clamp(amount, 1, 10) + amount = CLAMP(amount, 1, 10) for(var/M in D.materials) power += round(D.materials[M] * amount / 5) power = max(3000, power) diff --git a/code/modules/research/xenobiology/xenobiology.dm b/code/modules/research/xenobiology/xenobiology.dm index cf250f50f1..9c5510a814 100644 --- a/code/modules/research/xenobiology/xenobiology.dm +++ b/code/modules/research/xenobiology/xenobiology.dm @@ -290,7 +290,7 @@ return ..() to_chat(user, "You feed the slime the stabilizer. It is now less likely to mutate.") - M.mutation_chance = Clamp(M.mutation_chance-15,0,100) + M.mutation_chance = CLAMP(M.mutation_chance-15,0,100) qdel(src) /obj/item/slimepotion/mutator @@ -314,7 +314,7 @@ return ..() to_chat(user, "You feed the slime the mutator. It is now more likely to mutate.") - M.mutation_chance = Clamp(M.mutation_chance+12,0,100) + M.mutation_chance = CLAMP(M.mutation_chance+12,0,100) M.mutator_used = TRUE qdel(src) diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index a4303078a5..3811fa0e4a 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -146,13 +146,13 @@ var/y0 = bounds[2] var/x1 = bounds[3] var/y1 = bounds[4] - if(x0 <= x1 && !IsInRange(T.x, x0, x1)) + if(x0 <= x1 && !ISINRANGE(T.x, x0, x1)) return FALSE - else if(!IsInRange(T.x, x1, x0)) + else if(!ISINRANGE(T.x, x1, x0)) return FALSE - if(y0 <= y1 && !IsInRange(T.y, y0, y1)) + if(y0 <= y1 && !ISINRANGE(T.y, y0, y1)) return FALSE - else if(!IsInRange(T.y, y1, y0)) + else if(!ISINRANGE(T.y, y1, y0)) return FALSE return TRUE @@ -534,7 +534,7 @@ rotation = dir2angle(new_dock.dir)-dir2angle(dir) if ((rotation % 90) != 0) rotation += (rotation % 90) //diagonal rotations not allowed, round up - rotation = SimplifyDegrees(rotation) + rotation = SIMPLIFY_DEGREES(rotation) if(!movement_direction) movement_direction = turn(preferred_direction, 180) @@ -888,13 +888,13 @@ var/change_per_engine = (1 - ENGINE_COEFF_MIN) / ENGINE_DEFAULT_MAXSPEED_ENGINES // 5 by default if(initial_engines > 0) change_per_engine = (1 - ENGINE_COEFF_MIN) / initial_engines // or however many it had - return Clamp(1 - delta * change_per_engine,ENGINE_COEFF_MIN,ENGINE_COEFF_MAX) + return CLAMP(1 - delta * change_per_engine,ENGINE_COEFF_MIN,ENGINE_COEFF_MAX) if(new_value < initial_engines) var/delta = initial_engines - new_value var/change_per_engine = 1 //doesn't really matter should not be happening for 0 engine shuttles if(initial_engines > 0) change_per_engine = (ENGINE_COEFF_MAX - 1) / initial_engines //just linear drop to max delay - return Clamp(1 + delta * change_per_engine,ENGINE_COEFF_MIN,ENGINE_COEFF_MAX) + return CLAMP(1 + delta * change_per_engine,ENGINE_COEFF_MIN,ENGINE_COEFF_MAX) /obj/docking_port/mobile/proc/in_flight() diff --git a/code/modules/spells/spell_types/wizard.dm b/code/modules/spells/spell_types/wizard.dm index 9b120c2e7f..39d340927e 100644 --- a/code/modules/spells/spell_types/wizard.dm +++ b/code/modules/spells/spell_types/wizard.dm @@ -289,7 +289,7 @@ var/mob/living/M = AM M.Knockdown(stun_amt) to_chat(M, "You're thrown back by [user]!") - AM.throw_at(throwtarget, ((Clamp((maxthrow - (Clamp(distfromcaster - 2, 0, distfromcaster))), 3, maxthrow))), 1,user)//So stuff gets tossed around at the same time. + AM.throw_at(throwtarget, ((CLAMP((maxthrow - (CLAMP(distfromcaster - 2, 0, distfromcaster))), 3, maxthrow))), 1,user)//So stuff gets tossed around at the same time. /obj/effect/proc_holder/spell/aoe_turf/repulse/xeno //i fixed conflicts only to find out that this is in the WIZARD file instead of the xeno file?! name = "Tail Sweep" diff --git a/code/modules/surgery/bodyparts/dismemberment.dm b/code/modules/surgery/bodyparts/dismemberment.dm index e99455c833..a385d009e5 100644 --- a/code/modules/surgery/bodyparts/dismemberment.dm +++ b/code/modules/surgery/bodyparts/dismemberment.dm @@ -18,7 +18,7 @@ return 0 var/obj/item/bodypart/affecting = C.get_bodypart("chest") - affecting.receive_damage(Clamp(brute_dam/2, 15, 50), Clamp(burn_dam/2, 0, 50)) //Damage the chest based on limb's existing damage + affecting.receive_damage(CLAMP(brute_dam/2, 15, 50), CLAMP(burn_dam/2, 0, 50)) //Damage the chest based on limb's existing damage C.visible_message("[C]'s [src.name] has been violently dismembered!") C.emote("scream") drop_limb() diff --git a/code/modules/surgery/organs/eyes.dm b/code/modules/surgery/organs/eyes.dm index 51e39605c4..f8f57c650f 100644 --- a/code/modules/surgery/organs/eyes.dm +++ b/code/modules/surgery/organs/eyes.dm @@ -199,7 +199,7 @@ return var/range = input(user, "Enter range (0 - [max_light_beam_distance])", "Range Select", 0) as null|num - set_distance(Clamp(range, 0, max_light_beam_distance)) + set_distance(CLAMP(range, 0, max_light_beam_distance)) assume_rgb(C) /obj/item/organ/eyes/robotic/glow/proc/assume_rgb(newcolor) diff --git a/code/modules/surgery/organs/lungs.dm b/code/modules/surgery/organs/lungs.dm index 02f1ee4ec3..102ac9720f 100644 --- a/code/modules/surgery/organs/lungs.dm +++ b/code/modules/surgery/organs/lungs.dm @@ -111,7 +111,7 @@ if(safe_oxygen_max) if(O2_pp > safe_oxygen_max) var/ratio = (breath_gases[/datum/gas/oxygen][MOLES]/safe_oxygen_max) * 10 - H.apply_damage_type(Clamp(ratio, oxy_breath_dam_min, oxy_breath_dam_max), oxy_damage_type) + H.apply_damage_type(CLAMP(ratio, oxy_breath_dam_min, oxy_breath_dam_max), oxy_damage_type) H.throw_alert("too_much_oxy", /obj/screen/alert/too_much_oxy) else H.clear_alert("too_much_oxy") @@ -139,7 +139,7 @@ if(safe_nitro_max) if(N2_pp > safe_nitro_max) var/ratio = (breath_gases[/datum/gas/nitrogen][MOLES]/safe_nitro_max) * 10 - H.apply_damage_type(Clamp(ratio, nitro_breath_dam_min, nitro_breath_dam_max), nitro_damage_type) + H.apply_damage_type(CLAMP(ratio, nitro_breath_dam_min, nitro_breath_dam_max), nitro_damage_type) H.throw_alert("too_much_nitro", /obj/screen/alert/too_much_nitro) else H.clear_alert("too_much_nitro") @@ -205,7 +205,7 @@ if(safe_toxins_max) if(Toxins_pp > safe_toxins_max) var/ratio = (breath_gases[/datum/gas/plasma][MOLES]/safe_toxins_max) * 10 - H.apply_damage_type(Clamp(ratio, tox_breath_dam_min, tox_breath_dam_max), tox_damage_type) + H.apply_damage_type(CLAMP(ratio, tox_breath_dam_min, tox_breath_dam_max), tox_damage_type) H.throw_alert("too_much_tox", /obj/screen/alert/too_much_tox) else H.clear_alert("too_much_tox") diff --git a/tgstation.dme b/tgstation.dme index 11399a1b14..3ccdf79ee6 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -54,7 +54,7 @@ #include "code\__DEFINES\logging.dm" #include "code\__DEFINES\machines.dm" #include "code\__DEFINES\maps.dm" -#include "code\__DEFINES\math.dm" +#include "code\__DEFINES\maths.dm" #include "code\__DEFINES\MC.dm" #include "code\__DEFINES\menu.dm" #include "code\__DEFINES\misc.dm" @@ -100,7 +100,6 @@ #include "code\__HELPERS\global_lists.dm" #include "code\__HELPERS\icon_smoothing.dm" #include "code\__HELPERS\icons.dm" -#include "code\__HELPERS\maths.dm" #include "code\__HELPERS\matrices.dm" #include "code\__HELPERS\mobs.dm" #include "code\__HELPERS\names.dm"