diff --git a/code/ATMOSPHERICS/components/unary/cold_sink.dm b/code/ATMOSPHERICS/components/unary/cold_sink.dm index 656ff925a6..dbe7dd2994 100644 --- a/code/ATMOSPHERICS/components/unary/cold_sink.dm +++ b/code/ATMOSPHERICS/components/unary/cold_sink.dm @@ -100,7 +100,7 @@ else set_temperature = max(amount, 0) if("setPower") //setting power to 0 is redundant anyways - var/new_setting = CLAMP(text2num(params["value"]), 0, 100) + var/new_setting = clamp(text2num(params["value"]), 0, 100) set_power_level(new_setting) add_fingerprint(usr) diff --git a/code/__defines/math.dm b/code/__defines/math.dm index 02b1689ea7..f9c520276d 100644 --- a/code/__defines/math.dm +++ b/code/__defines/math.dm @@ -9,15 +9,6 @@ #define SHORT_REAL_LIMIT 16777216 -#define CLAMP01(x) clamp(x, 0, 1) - -#define CLAMP(CLVALUE, CLMIN, CLMAX) clamp(CLVALUE, CLMIN, CLMAX) - -#define TAN(x) tan(x) - -#define ATAN2(x, y) arctan(x, y) - - //"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 @@ -45,7 +36,7 @@ #define MODULUS(x, y) ( (x) - (y) * round((x) / (y)) ) // Cotangent -#define COT(x) (1 / TAN(x)) +#define COT(x) (1 / tan(x)) // Secant #define SEC(x) (1 / cos(x)) @@ -190,8 +181,8 @@ 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) + 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 diff --git a/code/_helpers/icons.dm b/code/_helpers/icons.dm index 7cbcac1a83..a10c351d12 100644 --- a/code/_helpers/icons.dm +++ b/code/_helpers/icons.dm @@ -929,9 +929,9 @@ GLOBAL_LIST_EMPTY(cached_examine_icons) if (!value) return color var/list/RGB = ReadRGB(color) - RGB[1] = CLAMP(RGB[1]+value,0,255) - RGB[2] = CLAMP(RGB[2]+value,0,255) - RGB[3] = CLAMP(RGB[3]+value,0,255) + RGB[1] = clamp(RGB[1]+value,0,255) + RGB[2] = clamp(RGB[2]+value,0,255) + RGB[3] = clamp(RGB[3]+value,0,255) return rgb(RGB[1],RGB[2],RGB[3]) /proc/sort_atoms_by_layer(var/list/atoms) diff --git a/code/_helpers/matrices.dm b/code/_helpers/matrices.dm index a5ef701c2d..11d367afc4 100644 --- a/code/_helpers/matrices.dm +++ b/code/_helpers/matrices.dm @@ -50,7 +50,7 @@ /proc/color_rotation(angle) if(angle == 0) return color_identity() - angle = CLAMP(angle, -180, 180) + angle = clamp(angle, -180, 180) var/cos = cos(angle) var/sin = sin(angle) @@ -65,7 +65,7 @@ //Makes everything brighter or darker without regard to existing color or brightness /proc/color_brightness(power) - power = CLAMP(power, -255, 255) + power = clamp(power, -255, 255) power = power/255 return list(1,0,0, 0,1,0, 0,0,1, power,power,power) @@ -85,7 +85,7 @@ //Exxagerates or removes brightness /proc/color_contrast(value) - value = CLAMP(value, -100, 100) + value = clamp(value, -100, 100) if(value == 0) return color_identity() @@ -108,7 +108,7 @@ /proc/color_saturation(value as num) if(value == 0) return color_identity() - value = CLAMP(value, -100, 100) + value = clamp(value, -100, 100) if(value > 0) value *= 3 var/x = 1 + value / 100 diff --git a/code/_onclick/hud/minihud_rigmech.dm b/code/_onclick/hud/minihud_rigmech.dm index e54a733f80..d13de41305 100644 --- a/code/_onclick/hud/minihud_rigmech.dm +++ b/code/_onclick/hud/minihud_rigmech.dm @@ -41,7 +41,7 @@ var/obj/item/weapon/tank/rigtank = owner_rig.air_supply var/charge_percentage = rigcell ? rigcell.charge / rigcell.maxcharge : 0 - var/air_percentage = rigtank ? CLAMP(rigtank.air_contents.total_moles / 17.4693, 0, 1) : 0 + var/air_percentage = rigtank ? clamp(rigtank.air_contents.total_moles / 17.4693, 0, 1) : 0 var/air_on = owner_rig.wearer?.internal ? 1 : 0 power.icon_state = "pwr[round(charge_percentage / 0.2, 1)]" @@ -91,7 +91,7 @@ var/obj/machinery/portable_atmospherics/canister/mechtank = owner_mech.internal_tank var/charge_percentage = mechcell ? mechcell.charge / mechcell.maxcharge : 0 - var/air_percentage = mechtank ? CLAMP(mechtank.air_contents.total_moles / 1863.47, 0, 1) : 0 + var/air_percentage = mechtank ? clamp(mechtank.air_contents.total_moles / 1863.47, 0, 1) : 0 var/health_percentage = owner_mech.health / owner_mech.maxhealth var/air_on = owner_mech.use_internal_tank diff --git a/code/_onclick/hud/picture_in_picture.dm b/code/_onclick/hud/picture_in_picture.dm index 3df659a687..57f0c13293 100644 --- a/code/_onclick/hud/picture_in_picture.dm +++ b/code/_onclick/hud/picture_in_picture.dm @@ -132,8 +132,8 @@ overlays += dir /obj/screen/movable/pic_in_pic/proc/set_view_size(width, height, do_refresh = TRUE) - width = CLAMP(width, 0, max_dimensions) - height = CLAMP(height, 0, max_dimensions) + width = clamp(width, 0, max_dimensions) + height = clamp(height, 0, max_dimensions) src.width = width src.height = height diff --git a/code/datums/position_point_vector.dm b/code/datums/position_point_vector.dm index eb5127aed6..0b39481f85 100644 --- a/code/datums/position_point_vector.dm +++ b/code/datums/position_point_vector.dm @@ -64,7 +64,7 @@ return sqrt(((b.x - a.x) ** 2) + ((b.y - a.y) ** 2)) /proc/angle_between_points(datum/point/a, datum/point/b) - return ATAN2((b.y - a.y), (b.x - a.x)) + return arctan((b.y - a.y), (b.x - a.x)) /datum/point //A precise point on the map in absolute pixel locations based on world.icon_size. Pixels are FROM THE EDGE OF THE MAP! var/x = 0 diff --git a/code/datums/progressbar.dm b/code/datums/progressbar.dm index 01e4119b55..073d09b537 100644 --- a/code/datums/progressbar.dm +++ b/code/datums/progressbar.dm @@ -39,7 +39,7 @@ shown = 0 client = user.client - progress = CLAMP(progress, 0, goal) + progress = clamp(progress, 0, goal) bar.icon_state = "prog_bar_[round(((progress / goal) * 100), 5)]" if (!shown && user.is_preference_enabled(/datum/client_preference/show_progress_bar)) user.client.images += bar diff --git a/code/game/machinery/atmoalter/scrubber.dm b/code/game/machinery/atmoalter/scrubber.dm index f6cadfbff1..0f06398891 100644 --- a/code/game/machinery/atmoalter/scrubber.dm +++ b/code/game/machinery/atmoalter/scrubber.dm @@ -140,7 +140,7 @@ holding = null . = TRUE if("volume_adj") - volume_rate = CLAMP(text2num(params["vol"]), minrate, maxrate) + volume_rate = clamp(text2num(params["vol"]), minrate, maxrate) . = TRUE update_icon() diff --git a/code/game/machinery/pointdefense.dm b/code/game/machinery/pointdefense.dm index 4efd32c273..c3f95202f4 100644 --- a/code/game/machinery/pointdefense.dm +++ b/code/game/machinery/pointdefense.dm @@ -213,7 +213,7 @@ GLOBAL_LIST_BOILERPLATE(pointdefense_turrets, /obj/machinery/pointdefense) addtimer(CALLBACK(src, .proc/finish_shot, target), rotation_speed) animate(src, transform = rot_matrix, rotation_speed, easing = SINE_EASING) - set_dir(ATAN2(transform.b, transform.a) > 0 ? NORTH : SOUTH) + set_dir(arctan(transform.b, transform.a) > 0 ? NORTH : SOUTH) /obj/machinery/pointdefense/proc/finish_shot(var/weakref/target) @@ -237,7 +237,7 @@ GLOBAL_LIST_BOILERPLATE(pointdefense_turrets, /obj/machinery/pointdefense) return if(!active) return - var/desiredir = ATAN2(transform.b, transform.a) > 0 ? NORTH : SOUTH + var/desiredir = arctan(transform.b, transform.a) > 0 ? NORTH : SOUTH if(dir != desiredir) set_dir(desiredir) diff --git a/code/game/objects/explosion.dm b/code/game/objects/explosion.dm index afa536d38f..cb861acd90 100644 --- a/code/game/objects/explosion.dm +++ b/code/game/objects/explosion.dm @@ -39,7 +39,7 @@ if(dist <= round(max_range + world.view - 2, 1)) M.playsound_local(epicenter, get_sfx("explosion"), 100, 1, frequency, falloff = 5) // get_sfx() is so that everyone gets the same sound 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, 'sound/effects/explosionfar.ogg', far_volume, 1, frequency, falloff = 5) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 165d261080..43f333b2e2 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -276,9 +276,9 @@ /obj/item/proc/get_volume_by_throwforce_and_or_w_class() // This is used for figuring out how loud our sounds are for throwing. 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/game/objects/items/weapons/explosives.dm b/code/game/objects/items/weapons/explosives.dm index f1f6e85bb3..8cbd953a6b 100644 --- a/code/game/objects/items/weapons/explosives.dm +++ b/code/game/objects/items/weapons/explosives.dm @@ -41,7 +41,7 @@ /obj/item/weapon/plastique/attack_self(mob/user as mob) var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num if(user.get_active_hand() == 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/weapons/tanks/tanks.dm b/code/game/objects/items/weapons/tanks/tanks.dm index d19539f29a..7879a36c68 100644 --- a/code/game/objects/items/weapons/tanks/tanks.dm +++ b/code/game/objects/items/weapons/tanks/tanks.dm @@ -494,7 +494,7 @@ var/list/global/tank_gauge_cache = list() var/release_ratio = 0.002 if(tank_pressure) - release_ratio = CLAMP(sqrt(max(tank_pressure-env_pressure,0)/tank_pressure), 0.002, 1) + release_ratio = clamp(sqrt(max(tank_pressure-env_pressure,0)/tank_pressure), 0.002, 1) var/datum/gas_mixture/leaked_gas = air_contents.remove_ratio(release_ratio) //dynamic air release based on ambient pressure diff --git a/code/modules/blob2/overmind/types/pressurized_slime.dm b/code/modules/blob2/overmind/types/pressurized_slime.dm index 6b2ff5800f..5c95494c43 100644 --- a/code/modules/blob2/overmind/types/pressurized_slime.dm +++ b/code/modules/blob2/overmind/types/pressurized_slime.dm @@ -53,4 +53,4 @@ /datum/blob_type/pressurized_slime/on_chunk_use(obj/item/weapon/blobcore_chunk/B, mob/living/user) // Drenches you in water. if(user) user.ExtinguishMob() - user.fire_stacks = CLAMP(user.fire_stacks - 1, -25, 25) \ No newline at end of file + user.fire_stacks = clamp(user.fire_stacks - 1, -25, 25) \ No newline at end of file diff --git a/code/modules/client/preference_setup/general/03_body.dm b/code/modules/client/preference_setup/general/03_body.dm index 41b6446b88..bf075564d8 100644 --- a/code/modules/client/preference_setup/general/03_body.dm +++ b/code/modules/client/preference_setup/general/03_body.dm @@ -400,7 +400,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O if(isnull(last_descriptors[entry])) pref.body_descriptors[entry] = descriptor.default_value // Species datums have initial default value. else - pref.body_descriptors[entry] = CLAMP(last_descriptors[entry], 1, LAZYLEN(descriptor.standalone_value_descriptors)) + pref.body_descriptors[entry] = clamp(last_descriptors[entry], 1, LAZYLEN(descriptor.standalone_value_descriptors)) /datum/category_item/player_setup_item/general/body/content(var/mob/user) . = list() diff --git a/code/modules/client/preference_setup/volume_sliders/01_volume.dm b/code/modules/client/preference_setup/volume_sliders/01_volume.dm index 5a65b99f40..328735a2a4 100644 --- a/code/modules/client/preference_setup/volume_sliders/01_volume.dm +++ b/code/modules/client/preference_setup/volume_sliders/01_volume.dm @@ -42,7 +42,7 @@ pref.volume_channels["[channel]"] = 1 var/value = input("Choose your volume for [channel] (0-200%)", "[channel] volume", (pref.volume_channels[channel] * 100)) if(isnum(value)) - value = CLAMP(value, 0, 200) + value = clamp(value, 0, 200) pref.volume_channels["[channel]"] = (value / 100) return TOPIC_REFRESH return ..() diff --git a/code/modules/compass/compass_holder.dm b/code/modules/compass/compass_holder.dm index 1a2148d5c4..b4f739224e 100644 --- a/code/modules/compass/compass_holder.dm +++ b/code/modules/compass/compass_holder.dm @@ -43,7 +43,7 @@ if(numeric_directions) str = "[angle]" else - str = angle_step_to_dir[CLAMP(round(angle/45)+1, 1, length(angle_step_to_dir))] + str = angle_step_to_dir[clamp(round(angle/45)+1, 1, length(angle_step_to_dir))] str_col = "#ffffffaa" else str = "〡" diff --git a/code/modules/compass/compass_waypoint.dm b/code/modules/compass/compass_waypoint.dm index 24f9978bb8..b7ef7b6509 100644 --- a/code/modules/compass/compass_waypoint.dm +++ b/code/modules/compass/compass_waypoint.dm @@ -23,5 +23,5 @@ /datum/compass_waypoint/proc/recalculate_heading(var/cx, var/cy) var/matrix/M = matrix() M.Translate(0, (name ? COMPASS_LABEL_OFFSET-4 : COMPASS_LABEL_OFFSET)) - M.Turn(ATAN2(cy-y, cx-x)+180) + M.Turn(arctan(cy-y, cx-x)+180) compass_overlay.transform = M diff --git a/code/modules/economy/Accounts_DB.dm b/code/modules/economy/Accounts_DB.dm index db25064483..516ab1692a 100644 --- a/code/modules/economy/Accounts_DB.dm +++ b/code/modules/economy/Accounts_DB.dm @@ -145,7 +145,7 @@ var/account_name = href_list["holder_name"] var/starting_funds = max(text2num(href_list["starting_funds"]), 0) - starting_funds = CLAMP(starting_funds, 0, station_account.money) // Not authorized to put the station in debt. + starting_funds = clamp(starting_funds, 0, station_account.money) // Not authorized to put the station in debt. starting_funds = min(starting_funds, fund_cap) // Not authorized to give more than the fund cap. create_account(account_name, starting_funds, src) diff --git a/code/modules/economy/cash.dm b/code/modules/economy/cash.dm index b54df3cfc1..ac7fbe577e 100644 --- a/code/modules/economy/cash.dm +++ b/code/modules/economy/cash.dm @@ -83,7 +83,7 @@ var/amount = input(usr, "How many [initial_name]s do you want to take? (0 to [src.worth])", "Take Money", 20) as num if(!src || QDELETED(src)) return - amount = round(CLAMP(amount, 0, src.worth)) + amount = round(clamp(amount, 0, src.worth)) if(!amount) return diff --git a/code/modules/economy/cash_register.dm b/code/modules/economy/cash_register.dm index cd8b77a219..e337a06656 100644 --- a/code/modules/economy/cash_register.dm +++ b/code/modules/economy/cash_register.dm @@ -130,7 +130,7 @@ if("set_amount") var/item_name = locate(href_list["item"]) var/n_amount = round(input("Enter amount", "New amount") as num) - n_amount = CLAMP(n_amount, 0, 20) + n_amount = clamp(n_amount, 0, 20) if (!item_list[item_name] || !Adjacent(usr)) return transaction_amount += (n_amount - item_list[item_name]) * price_list[item_name] if(!n_amount) diff --git a/code/modules/economy/retail_scanner.dm b/code/modules/economy/retail_scanner.dm index 0245c62638..e35a09039e 100644 --- a/code/modules/economy/retail_scanner.dm +++ b/code/modules/economy/retail_scanner.dm @@ -125,7 +125,7 @@ if("set_amount") var/item_name = locate(href_list["item"]) var/n_amount = round(input("Enter amount", "New amount") as num) - n_amount = CLAMP(n_amount, 0, 20) + n_amount = clamp(n_amount, 0, 20) if (!item_list[item_name] || !Adjacent(usr)) return transaction_amount += (n_amount - item_list[item_name]) * price_list[item_name] if(!n_amount) diff --git a/code/modules/food/food/sandwich.dm b/code/modules/food/food/sandwich.dm index 6929586c05..1b40e84026 100644 --- a/code/modules/food/food/sandwich.dm +++ b/code/modules/food/food/sandwich.dm @@ -71,7 +71,7 @@ name = lowertext("[fullname] sandwich") if(length(name) > 80) name = "[pick(list("absurd","colossal","enormous","ridiculous"))] sandwich" - w_class = n_ceil(CLAMP((ingredients.len/2),2,4)) + w_class = n_ceil(clamp((ingredients.len/2),2,4)) /obj/item/weapon/reagent_containers/food/snacks/csandwich/Destroy() for(var/obj/item/O in ingredients) diff --git a/code/modules/integrated_electronics/subtypes/data_transfer.dm b/code/modules/integrated_electronics/subtypes/data_transfer.dm index d6a74203c9..fd1c4fd37d 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_outputs)) + if(output_index == clamp(output_index, 1, number_of_outputs)) 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 b2c0afb732..bb75f20f5c 100644 --- a/code/modules/integrated_electronics/subtypes/input.dm +++ b/code/modules/integrated_electronics/subtypes/input.dm @@ -296,7 +296,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, 7) + rad = clamp(rad, 0, 7) radius = rad /obj/item/integrated_circuit/input/advanced_locator/do_work() diff --git a/code/modules/integrated_electronics/subtypes/output.dm b/code/modules/integrated_electronics/subtypes/output.dm index 01d16ed517..99c6cdd9cc 100644 --- a/code/modules/integrated_electronics/subtypes/output.dm +++ b/code/modules/integrated_electronics/subtypes/output.dm @@ -108,7 +108,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 diff --git a/code/modules/integrated_electronics/subtypes/reagents.dm b/code/modules/integrated_electronics/subtypes/reagents.dm index 2dd4e454c9..094a6faccc 100644 --- a/code/modules/integrated_electronics/subtypes/reagents.dm +++ b/code/modules/integrated_electronics/subtypes/reagents.dm @@ -83,7 +83,7 @@ else direc = 1 if(isnum(new_amount)) - new_amount = CLAMP(new_amount, 0, volume) + new_amount = clamp(new_amount, 0, volume) transfer_amount = new_amount @@ -132,7 +132,7 @@ if(!TS.Adjacent(TT)) activate_pin(3) return - var/tramount = CLAMP(min(transfer_amount, reagents.maximum_volume - reagents.total_volume), 0, reagents.maximum_volume) + var/tramount = clamp(min(transfer_amount, reagents.maximum_volume - reagents.total_volume), 0, reagents.maximum_volume) if(ismob(target))//Blood! if(istype(target, /mob/living/carbon)) var/mob/living/carbon/T = target @@ -206,7 +206,7 @@ else direc = 1 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() @@ -328,7 +328,7 @@ else direc = 1 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 9633ef7881..5c8b916f2a 100644 --- a/code/modules/integrated_electronics/subtypes/time.dm +++ b/code/modules/integrated_electronics/subtypes/time.dm @@ -22,7 +22,7 @@ /obj/item/integrated_circuit/time/delay/do_work() var/delay_input = get_pin_data(IC_INPUT, 1) if(delay_input && isnum(delay_input) ) - var/new_delay = CLAMP(delay_input, 1, 1 HOUR) + var/new_delay = clamp(delay_input, 1, 1 HOUR) delay = new_delay addtimer(CALLBACK(src, .proc/activate_pin, 2), delay) @@ -51,7 +51,7 @@ /obj/item/integrated_circuit/time/ticker/on_data_written() var/delay_input = get_pin_data(IC_INPUT, 2) if(delay_input && isnum(delay_input) ) - var/new_delay = CLAMP(delay_input, 1, 1 HOUR) + var/new_delay = clamp(delay_input, 1, 1 HOUR) delay = new_delay power_draw_per_use = CEILING((max_power_draw / delay) / delay, 1) diff --git a/code/modules/integrated_electronics/subtypes/trig.dm b/code/modules/integrated_electronics/subtypes/trig.dm index 303053639f..e6ed841e11 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() diff --git a/code/modules/lighting/lighting_source.dm b/code/modules/lighting/lighting_source.dm index 451b8273c8..a25de730a3 100644 --- a/code/modules/lighting/lighting_source.dm +++ b/code/modules/lighting/lighting_source.dm @@ -189,7 +189,7 @@ ); // This is the define used to calculate falloff. -#define LUM_FALLOFF(C, T)(1 - CLAMP01(((C.x - T.x) ** 2 +(C.y - T.y) ** 2 + LIGHTING_HEIGHT) ** 0.6 / max(1, light_range))) +#define LUM_FALLOFF(C, T)(1 - clamp(((C.x - T.x) ** 2 +(C.y - T.y) ** 2 + LIGHTING_HEIGHT) ** 0.6 / max(1, light_range), 0, 1)) /datum/light_source/proc/apply_lum() var/static/update_gen = 1 diff --git a/code/modules/lighting/lighting_turf.dm b/code/modules/lighting/lighting_turf.dm index bc3c099091..dcd8b902af 100644 --- a/code/modules/lighting/lighting_turf.dm +++ b/code/modules/lighting/lighting_turf.dm @@ -54,7 +54,7 @@ totallums =(totallums - minlum) /(maxlum - minlum) - return CLAMP01(totallums) + return clamp(totallums, 0, 1) // Can't think of a good name, this proc will recalculate the has_opaque_atom variable. /turf/proc/recalc_atom_opacity() diff --git a/code/modules/mining/machinery/machine_processing.dm b/code/modules/mining/machinery/machine_processing.dm index ca38880286..edd88022ab 100644 --- a/code/modules/mining/machinery/machine_processing.dm +++ b/code/modules/mining/machinery/machine_processing.dm @@ -296,7 +296,7 @@ else if(ores_processing[metal] == PROCESS_COMPRESS && O.compresses_to) //Compressing. - var/can_make = CLAMP(ores_stored[metal],0,sheets_per_tick-sheets) + var/can_make = clamp(ores_stored[metal],0,sheets_per_tick-sheets) if(can_make%2>0) can_make-- var/datum/material/M = get_material_by_name(O.compresses_to) @@ -311,7 +311,7 @@ else if(ores_processing[metal] == PROCESS_SMELT && O.smelts_to) //Smelting. - var/can_make = CLAMP(ores_stored[metal],0,sheets_per_tick-sheets) + var/can_make = clamp(ores_stored[metal],0,sheets_per_tick-sheets) var/datum/material/M = get_material_by_name(O.smelts_to) if(!istype(M) || !can_make || ores_stored[metal] < 1) diff --git a/code/modules/mob/living/carbon/human/descriptors/_descriptors.dm b/code/modules/mob/living/carbon/human/descriptors/_descriptors.dm index 815914f40c..4183179b6a 100644 --- a/code/modules/mob/living/carbon/human/descriptors/_descriptors.dm +++ b/code/modules/mob/living/carbon/human/descriptors/_descriptors.dm @@ -99,10 +99,10 @@ /datum/mob_descriptor/proc/get_comparative_value_string_smaller(var/value, var/datum/gender/my_gender, var/datum/gender/other_gender) var/maxval = LAZYLEN(comparative_value_descriptors_smaller) - value = CLAMP(CEILING(value * maxval, 1), 1, maxval) + value = clamp(CEILING(value * maxval, 1), 1, maxval) return comparative_value_descriptors_smaller[value] /datum/mob_descriptor/proc/get_comparative_value_string_larger(var/value, var/datum/gender/my_gender, var/datum/gender/other_gender) var/maxval = LAZYLEN(comparative_value_descriptors_larger) - value = CLAMP(CEILING(value * maxval, 1), 1, maxval) + value = clamp(CEILING(value * maxval, 1), 1, maxval) return comparative_value_descriptors_larger[value] diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index c8d17cd63b..b0b2a7c8ae 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -106,7 +106,7 @@ for(var/datum/modifier/M in modifiers) if(!isnull(M.explosion_modifier)) - severity = CLAMP(severity + M.explosion_modifier, 1, 4) + severity = clamp(severity + M.explosion_modifier, 1, 4) severity = round(severity) diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index cdfef35b59..48b01f9a53 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -604,7 +604,7 @@ emp_act var/converted_protection = 1 - protection var/perm = reagent_permeability() converted_protection *= perm - return CLAMP(1-converted_protection, 0, 1) + return clamp(1-converted_protection, 0, 1) /mob/living/carbon/human/water_act(amount) adjust_fire_stacks(-amount * 5) diff --git a/code/modules/mob/living/carbon/human/human_movement.dm b/code/modules/mob/living/carbon/human/human_movement.dm index 1dc7ba4e94..9cc7052a36 100644 --- a/code/modules/mob/living/carbon/human/human_movement.dm +++ b/code/modules/mob/living/carbon/human/human_movement.dm @@ -127,22 +127,22 @@ var/turf_move_cost = T.movement_cost if(istype(T, /turf/simulated/floor/water)) if(species.water_movement) - turf_move_cost = CLAMP(turf_move_cost + species.water_movement, HUMAN_LOWEST_SLOWDOWN, 15) + turf_move_cost = clamp(turf_move_cost + species.water_movement, HUMAN_LOWEST_SLOWDOWN, 15) if(shoes) var/obj/item/clothing/shoes/feet = shoes if(feet.water_speed) - turf_move_cost = CLAMP(turf_move_cost + feet.water_speed, HUMAN_LOWEST_SLOWDOWN, 15) + turf_move_cost = clamp(turf_move_cost + feet.water_speed, HUMAN_LOWEST_SLOWDOWN, 15) . += turf_move_cost else if(istype(T, /turf/simulated/floor/outdoors/snow)) if(species.snow_movement) - turf_move_cost = CLAMP(turf_move_cost + species.snow_movement, HUMAN_LOWEST_SLOWDOWN, 15) + turf_move_cost = clamp(turf_move_cost + species.snow_movement, HUMAN_LOWEST_SLOWDOWN, 15) if(shoes) var/obj/item/clothing/shoes/feet = shoes if(feet.water_speed) - turf_move_cost = CLAMP(turf_move_cost + feet.snow_speed, HUMAN_LOWEST_SLOWDOWN, 15) + turf_move_cost = clamp(turf_move_cost + feet.snow_speed, HUMAN_LOWEST_SLOWDOWN, 15) . += turf_move_cost else - turf_move_cost = CLAMP(turf_move_cost, HUMAN_LOWEST_SLOWDOWN, 15) + turf_move_cost = clamp(turf_move_cost, HUMAN_LOWEST_SLOWDOWN, 15) . += turf_move_cost // Wind makes it easier or harder to move, depending on if you're with or against the wind. diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index ed915c0471..55c825b521 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -265,7 +265,7 @@ if(gene.is_active(src)) gene.OnMobLife(src) - radiation = CLAMP(radiation,0,250) + radiation = clamp(radiation,0,250) if(!radiation) if(species.appearance_flags & RADIATION_GLOWS) @@ -533,7 +533,7 @@ if(toxins_pp > safe_toxins_max) var/ratio = (poison/safe_toxins_max) * 10 if(reagents) - reagents.add_reagent("toxin", CLAMP(ratio, MIN_TOXIN_DAMAGE, MAX_TOXIN_DAMAGE)) + reagents.add_reagent("toxin", clamp(ratio, MIN_TOXIN_DAMAGE, MAX_TOXIN_DAMAGE)) breath.adjust_gas(poison_type, -poison/6, update = 0) //update after throw_alert("tox_in_air", /obj/screen/alert/tox_in_air) else diff --git a/code/modules/mob/living/carbon/human/species/species_attack.dm b/code/modules/mob/living/carbon/human/species/species_attack.dm index 2755255252..9be2a2f7e8 100644 --- a/code/modules/mob/living/carbon/human/species/species_attack.dm +++ b/code/modules/mob/living/carbon/human/species/species_attack.dm @@ -30,7 +30,7 @@ var/datum/gender/T = gender_datums[user.get_visible_gender()] var/datum/gender/TT = gender_datums[target.get_visible_gender()] if(!skill) skill = 1 - attack_damage = CLAMP(attack_damage, 1, 5) + attack_damage = clamp(attack_damage, 1, 5) if(target == user) user.visible_message("[user] [pick(attack_verb)] [T.himself] in the [affecting.name]!") diff --git a/code/modules/mob/living/carbon/human/unarmed_attack.dm b/code/modules/mob/living/carbon/human/unarmed_attack.dm index 4e3facb09c..aee956e86b 100644 --- a/code/modules/mob/living/carbon/human/unarmed_attack.dm +++ b/code/modules/mob/living/carbon/human/unarmed_attack.dm @@ -145,7 +145,7 @@ var/global/list/sparring_attack_cache = list() var/datum/gender/TU = gender_datums[user.get_visible_gender()] var/datum/gender/TT = gender_datums[target.get_visible_gender()] - attack_damage = CLAMP(attack_damage, 1, 5) // We expect damage input of 1 to 5 for this proc. But we leave this check juuust in case. + attack_damage = clamp(attack_damage, 1, 5) // We expect damage input of 1 to 5 for this proc. But we leave this check juuust in case. if(target == user) user.visible_message("[user] [pick(attack_verb)] [TU.himself] in the [organ]!") @@ -220,7 +220,7 @@ var/global/list/sparring_attack_cache = list() var/datum/gender/TT = gender_datums[target.get_visible_gender()] var/organ = affecting.name - attack_damage = CLAMP(attack_damage, 1, 5) + attack_damage = clamp(attack_damage, 1, 5) switch(attack_damage) if(1 to 2) user.visible_message("[user] threw [target] a glancing [pick(attack_noun)] to the [organ]!") //it's not that they're kicking lightly, it's that the kick didn't quite connect @@ -267,7 +267,7 @@ var/global/list/sparring_attack_cache = list() var/obj/item/clothing/shoes = user.shoes var/datum/gender/TU = gender_datums[user.get_visible_gender()] - attack_damage = CLAMP(attack_damage, 1, 5) + attack_damage = clamp(attack_damage, 1, 5) switch(attack_damage) if(1 to 4) user.visible_message("[pick("[user] stomped on", "[user] slammed [TU.his] [shoes ? copytext(shoes.name, 1, -1) : "foot"] down onto")] [target]'s [organ]!") diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 889a05401e..8b7881a29a 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -171,7 +171,7 @@ if(LAZYLEN(modifiers)) for(var/datum/modifier/M in modifiers) if(!isnull(M.emp_modifier)) - severity = CLAMP(severity + M.emp_modifier, 1, 5) + severity = clamp(severity + M.emp_modifier, 1, 5) if(severity == 5) // Effectively nullified. return @@ -385,7 +385,7 @@ return /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, FIRE_MIN_STACKS, FIRE_MAX_STACKS) + fire_stacks = clamp(fire_stacks + add_fire_stacks, FIRE_MIN_STACKS, FIRE_MAX_STACKS) /mob/living/proc/handle_fire() if(fire_stacks < 0) diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index 1d66ec017c..20a9c55ff2 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -306,7 +306,7 @@ var/list/channel_to_radio_key = new if(sb_alpha < 0) break speech_bubble.loc = loc_before_turf - speech_bubble.alpha = CLAMP(sb_alpha, 0, 255) + speech_bubble.alpha = clamp(sb_alpha, 0, 255) images_to_clients[speech_bubble] = list() // Attempt Multi-Z Talking diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index d6cf390806..6e6cf32f3a 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -289,7 +289,7 @@ for(var/datum/modifier/M in modifiers) if(!isnull(M.explosion_modifier)) - severity = CLAMP(severity + M.explosion_modifier, 1, 4) + severity = clamp(severity + M.explosion_modifier, 1, 4) severity = round(severity) diff --git a/code/modules/mob/living/simple_mob/defense.dm b/code/modules/mob/living/simple_mob/defense.dm index 355bdc62ce..8672acf4ad 100644 --- a/code/modules/mob/living/simple_mob/defense.dm +++ b/code/modules/mob/living/simple_mob/defense.dm @@ -116,7 +116,7 @@ for(var/datum/modifier/M in modifiers) if(!isnull(M.explosion_modifier)) - severity = CLAMP(severity + M.explosion_modifier, 1, 4) + severity = clamp(severity + M.explosion_modifier, 1, 4) severity = round(severity) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 7f77722fb5..7250bf525f 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -831,10 +831,10 @@ return /mob/proc/AdjustLosebreath(amount) - losebreath = CLAMP(losebreath + amount, 0, 25) + losebreath = clamp(losebreath + amount, 0, 25) /mob/proc/SetLosebreath(amount) - losebreath = CLAMP(amount, 0, 25) + losebreath = clamp(amount, 0, 25) /mob/proc/get_species() return "" diff --git a/code/modules/mob/mob_grab.dm b/code/modules/mob/mob_grab.dm index eb6527586b..e4e5951a79 100644 --- a/code/modules/mob/mob_grab.dm +++ b/code/modules/mob/mob_grab.dm @@ -377,7 +377,7 @@ //It's easier to break out of a grab by a smaller mob break_strength += max(size_difference(affecting, assailant), 0) - var/break_chance = break_chance_table[CLAMP(break_strength, 1, break_chance_table.len)] + var/break_chance = break_chance_table[clamp(break_strength, 1, break_chance_table.len)] if(prob(break_chance)) if(state == GRAB_KILL) reset_kill_state() diff --git a/code/modules/mob/mob_grab_specials.dm b/code/modules/mob/mob_grab_specials.dm index a7a9d45db7..c1c3c8f3e2 100644 --- a/code/modules/mob/mob_grab_specials.dm +++ b/code/modules/mob/mob_grab_specials.dm @@ -61,7 +61,7 @@ to_chat(target, "You feel extreme pain!") var/max_halloss = round(target.species.total_health * 0.8) //up to 80% of passing out - affecting.adjustHalLoss(CLAMP(max_halloss - affecting.halloss, 0, 30)) + affecting.adjustHalLoss(clamp(max_halloss - affecting.halloss, 0, 30)) /obj/item/weapon/grab/proc/attack_eye(mob/living/carbon/human/target, mob/living/carbon/human/attacker) if(!istype(attacker)) diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index 103c64a925..90df82f7e2 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -144,7 +144,7 @@ var/list/organ_cache = list() owner.death() /obj/item/organ/proc/adjust_germ_level(var/amount) // Unless you're setting germ level directly to 0, use this proc instead - germ_level = CLAMP(germ_level + amount, 0, INFECTION_LEVEL_MAX) + germ_level = clamp(germ_level + amount, 0, INFECTION_LEVEL_MAX) /obj/item/organ/process() diff --git a/code/modules/organs/subtypes/slime.dm b/code/modules/organs/subtypes/slime.dm index eef360a515..94ddb95700 100644 --- a/code/modules/organs/subtypes/slime.dm +++ b/code/modules/organs/subtypes/slime.dm @@ -114,7 +114,7 @@ else if(amount > 0) last_strain_increase = world.time - strain = CLAMP(strain + amount, 0, min_broken_damage) + strain = clamp(strain + amount, 0, min_broken_damage) /obj/item/organ/internal/regennetwork/process() ..() diff --git a/code/modules/organs/subtypes/xenos.dm b/code/modules/organs/subtypes/xenos.dm index d021186ca6..07e0f30232 100644 --- a/code/modules/organs/subtypes/xenos.dm +++ b/code/modules/organs/subtypes/xenos.dm @@ -48,7 +48,7 @@ adjust_plasma(1) /obj/item/organ/internal/xenos/plasmavessel/proc/adjust_plasma(var/amount = 0) - stored_plasma = CLAMP(stored_plasma + amount, 0, max_plasma) + stored_plasma = clamp(stored_plasma + amount, 0, max_plasma) /obj/item/organ/internal/xenos/plasmavessel/grey icon_state = "plasma_grey" diff --git a/code/modules/overmap/ships/computers/engine_control.dm b/code/modules/overmap/ships/computers/engine_control.dm index c07fdf45cb..3d734921d3 100644 --- a/code/modules/overmap/ships/computers/engine_control.dm +++ b/code/modules/overmap/ships/computers/engine_control.dm @@ -59,13 +59,13 @@ var/newlim = input("Input new thrust limit (0..100%)", "Thrust limit", linked.thrust_limit*100) as num if(!CanInteract(user, state)) return TOPIC_NOACTION - linked.thrust_limit = CLAMP(newlim/100, 0, 1) + linked.thrust_limit = clamp(newlim/100, 0, 1) for(var/datum/ship_engine/E in linked.engines) E.set_thrust_limit(linked.thrust_limit) return TOPIC_REFRESH if(href_list["global_limit"]) - linked.thrust_limit = CLAMP(linked.thrust_limit + text2num(href_list["global_limit"]), 0, 1) + linked.thrust_limit = clamp(linked.thrust_limit + text2num(href_list["global_limit"]), 0, 1) for(var/datum/ship_engine/E in linked.engines) E.set_thrust_limit(linked.thrust_limit) return TOPIC_REFRESH @@ -76,13 +76,13 @@ var/newlim = input("Input new thrust limit (0..100)", "Thrust limit", E.get_thrust_limit()) as num if(!CanInteract(user, state)) return - var/limit = CLAMP(newlim/100, 0, 1) + var/limit = clamp(newlim/100, 0, 1) if(istype(E)) E.set_thrust_limit(limit) return TOPIC_REFRESH if(href_list["limit"]) var/datum/ship_engine/E = locate(href_list["engine"]) - var/limit = CLAMP(E.get_thrust_limit() + text2num(href_list["limit"]), 0, 1) + var/limit = clamp(E.get_thrust_limit() + text2num(href_list["limit"]), 0, 1) if(istype(E)) E.set_thrust_limit(limit) return TOPIC_REFRESH diff --git a/code/modules/overmap/ships/computers/helm.dm b/code/modules/overmap/ships/computers/helm.dm index cd23a5305e..22febd4f39 100644 --- a/code/modules/overmap/ships/computers/helm.dm +++ b/code/modules/overmap/ships/computers/helm.dm @@ -163,8 +163,8 @@ GLOBAL_LIST_EMPTY(all_waypoints) var/newy = input("Input new entry y coordinate", "Coordinate input", linked.y) as num if(!CanInteract(user,state)) return TOPIC_NOACTION - R.fields["x"] = CLAMP(newx, 1, world.maxx) - R.fields["y"] = CLAMP(newy, 1, world.maxy) + R.fields["x"] = clamp(newx, 1, world.maxx) + R.fields["y"] = clamp(newy, 1, world.maxy) known_sectors[sec_name] = R if (href_list["remove"]) @@ -178,14 +178,14 @@ GLOBAL_LIST_EMPTY(all_waypoints) if(!CanInteract(user,state)) return if (newx) - dx = CLAMP(newx, 1, world.maxx) + dx = clamp(newx, 1, world.maxx) if (href_list["sety"]) var/newy = input("Input new destiniation y coordinate", "Coordinate input", dy) as num|null if(!CanInteract(user,state)) return if (newy) - dy = CLAMP(newy, 1, world.maxy) + dy = clamp(newy, 1, world.maxy) if (href_list["x"] && href_list["y"]) dx = text2num(href_list["x"]) @@ -198,7 +198,7 @@ GLOBAL_LIST_EMPTY(all_waypoints) if (href_list["speedlimit"]) var/newlimit = input("Input new speed limit for autopilot (0 to brake)", "Autopilot speed limit", speedlimit*1000) as num|null if(newlimit) - speedlimit = CLAMP(newlimit/1000, 0, 100) + speedlimit = clamp(newlimit/1000, 0, 100) if (href_list["accellimit"]) var/newlimit = input("Input new acceleration limit", "Acceleration limit", accellimit*1000) as num|null if(newlimit) diff --git a/code/modules/overmap/ships/computers/sensors.dm b/code/modules/overmap/ships/computers/sensors.dm index 374992b65f..216e93718f 100644 --- a/code/modules/overmap/ships/computers/sensors.dm +++ b/code/modules/overmap/ships/computers/sensors.dm @@ -49,7 +49,7 @@ continue if(!O.scannable) continue - var/bearing = round(90 - ATAN2(O.x - linked.x, O.y - linked.y),5) + var/bearing = round(90 - arctan(O.x - linked.x, O.y - linked.y),5) if(bearing < 0) bearing += 360 contacts.Add(list(list("name"=O.name, "ref"="\ref[O]", "bearing"=bearing))) @@ -91,7 +91,7 @@ if(!CanInteract(user,state)) return TOPIC_NOACTION if (nrange) - sensors.set_range(CLAMP(nrange, 1, world.view)) + sensors.set_range(clamp(nrange, 1, world.view)) return TOPIC_REFRESH if (href_list["toggle"]) sensors.toggle() diff --git a/code/modules/overmap/ships/engines/gas_thruster.dm b/code/modules/overmap/ships/engines/gas_thruster.dm index 9ee03ade78..6ee897f918 100644 --- a/code/modules/overmap/ships/engines/gas_thruster.dm +++ b/code/modules/overmap/ships/engines/gas_thruster.dm @@ -175,11 +175,11 @@ /obj/machinery/atmospherics/unary/engine/RefreshParts() ..() //allows them to upgrade the max limit of fuel intake (which only gives diminishing returns) for increase in max thrust but massive reduction in fuel economy - var/bin_upgrade = 5 * CLAMP(total_component_rating_of_type(/obj/item/weapon/stock_parts/matter_bin), 0, 6)//5 litre per rank + var/bin_upgrade = 5 * clamp(total_component_rating_of_type(/obj/item/weapon/stock_parts/matter_bin), 0, 6)//5 litre per rank volume_per_burn = bin_upgrade ? initial(volume_per_burn) + bin_upgrade : 2 //Penalty missing part: 10% fuel use, no thrust boot_time = bin_upgrade ? initial(boot_time) - bin_upgrade : initial(boot_time) * 2 //energy cost - thb all of this is to limit the use of back up batteries - var/energy_upgrade = CLAMP(total_component_rating_of_type(/obj/item/weapon/stock_parts/capacitor), 0.1, 6) + var/energy_upgrade = clamp(total_component_rating_of_type(/obj/item/weapon/stock_parts/capacitor), 0.1, 6) charge_per_burn = initial(charge_per_burn) / energy_upgrade change_power_consumption(initial(idle_power_usage) / energy_upgrade, USE_POWER_IDLE) diff --git a/code/modules/overmap/ships/ship.dm b/code/modules/overmap/ships/ship.dm index bde8e2aa1a..3816454144 100644 --- a/code/modules/overmap/ships/ship.dm +++ b/code/modules/overmap/ships/ship.dm @@ -1,6 +1,6 @@ #define SHIP_MOVE_RESOLUTION 0.00001 #define MOVING(speed) abs(speed) >= min_speed -#define SANITIZE_SPEED(speed) SIGN(speed) * CLAMP(abs(speed), 0, max_speed) +#define SANITIZE_SPEED(speed) SIGN(speed) * clamp(abs(speed), 0, max_speed) #define CHANGE_SPEED_BY(speed_var, v_diff) \ v_diff = SANITIZE_SPEED(v_diff);\ if(!MOVING(speed_var + v_diff)) \ @@ -106,7 +106,7 @@ // Get heading in degrees (like a compass heading) /obj/effect/overmap/visitable/ship/proc/get_heading_degrees() - return (ATAN2(speed[2], speed[1]) + 360) % 360 // Yes ATAN2(y, x) is correct to get clockwise degrees + return (arctan(speed[2], speed[1]) + 360) % 360 // Yes arctan(y, x) is correct to get clockwise degrees /obj/effect/overmap/visitable/ship/proc/adjust_speed(n_x, n_y) var/old_still = is_still() diff --git a/code/modules/power/fusion/core/_core.dm b/code/modules/power/fusion/core/_core.dm index e7a93f71a3..2c24f69a64 100644 --- a/code/modules/power/fusion/core/_core.dm +++ b/code/modules/power/fusion/core/_core.dm @@ -120,7 +120,7 @@ GLOBAL_LIST_EMPTY(fusion_cores) . = owned_field.bullet_act(Proj) /obj/machinery/power/fusion_core/proc/set_strength(var/value) - value = CLAMP(value, MIN_FIELD_STR, MAX_FIELD_STR) + value = clamp(value, MIN_FIELD_STR, MAX_FIELD_STR) if(field_strength != value) field_strength = value diff --git a/code/modules/power/fusion/core/core_control.dm b/code/modules/power/fusion/core/core_control.dm index 2ee1350693..b635cfc524 100644 --- a/code/modules/power/fusion/core/core_control.dm +++ b/code/modules/power/fusion/core/core_control.dm @@ -162,7 +162,7 @@ return if(href_list["access_device"]) - var/idx = CLAMP(text2num(href_list["toggle_active"]), 1, connected_devices.len) + var/idx = clamp(text2num(href_list["toggle_active"]), 1, connected_devices.len) cur_viewed_device = connected_devices[idx] updateUsrDialog() return 1 diff --git a/code/modules/power/fusion/gyrotron/gyrotron_control.dm b/code/modules/power/fusion/gyrotron/gyrotron_control.dm index e51e5c8f1f..2e29434c1e 100644 --- a/code/modules/power/fusion/gyrotron/gyrotron_control.dm +++ b/code/modules/power/fusion/gyrotron/gyrotron_control.dm @@ -94,7 +94,7 @@ if(!new_val) to_chat(usr, "That's not a valid number.") return 1 - G.mega_energy = CLAMP(new_val, 1, 50) + G.mega_energy = clamp(new_val, 1, 50) G.update_active_power_usage(G.mega_energy * 1500) updateUsrDialog() return 1 @@ -104,7 +104,7 @@ if(!new_val) to_chat(usr, "That's not a valid number.") return 1 - G.rate = CLAMP(new_val, 1, 10) + G.rate = clamp(new_val, 1, 10) updateUsrDialog() return 1 diff --git a/code/modules/power/singularity/particle_accelerator/particle_smasher.dm b/code/modules/power/singularity/particle_accelerator/particle_smasher.dm index adff836cee..56e8c78b06 100644 --- a/code/modules/power/singularity/particle_accelerator/particle_smasher.dm +++ b/code/modules/power/singularity/particle_accelerator/particle_smasher.dm @@ -152,7 +152,7 @@ if(energy) SSradiation.radiate(src, round(((src.energy-150)/50)*5,1)) - energy = CLAMP(energy - 5, 0, max_energy) + energy = clamp(energy - 5, 0, max_energy) return diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm index 0ea630d7bd..e9efd6c37d 100644 --- a/code/modules/power/smes.dm +++ b/code/modules/power/smes.dm @@ -158,7 +158,7 @@ GLOBAL_LIST_EMPTY(smeses) //inputting if(input_attempt && (!input_pulsed && !input_cut) && !grid_check) - target_load = CLAMP((capacity-charge)/SMESRATE, 0, input_level) // Amount we will request from the powernet. + target_load = clamp((capacity-charge)/SMESRATE, 0, input_level) // Amount we will request from the powernet. var/input_available = FALSE for(var/obj/machinery/power/terminal/term in terminals) if(!term.powernet) diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm index 76ed1d5723..6556e37be2 100644 --- a/code/modules/power/supermatter/supermatter.dm +++ b/code/modules/power/supermatter/supermatter.dm @@ -303,7 +303,7 @@ // Volume will be 1 at no power, ~12.5 at ENERGY_NITROGEN, and 20+ at ENERGY_PHORON. // Capped to 20 volume since higher volumes get annoying and it sounds worse. // Formula previously was min(round(power/10)+1, 20) - soundloop.volume = CLAMP((50 + (power / 50)), 50, 100) + soundloop.volume = clamp((50 + (power / 50)), 50, 100) // Swap loops between calm and delamming. if(damage >= 300) diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index 989c521ff6..dd6c4b005c 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -62,7 +62,7 @@ set_dir(tesla_zap(src.loc, 7, TESLA_DEFAULT_POWER, TRUE)) 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 @@ -279,7 +279,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 - closest_mob.get_shock_protection(), ran_zone()) log_game("TESLA([source.x],[source.y],[source.z]) Shocked [key_name(closest_mob)] for [shock_damage]dmg.") message_admins("Tesla zapped [key_name_admin(closest_mob)]!") diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 0aa9fb0a8d..b06e33db76 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -241,10 +241,10 @@ if(!homing_target) return FALSE var/datum/point/PT = RETURN_PRECISE_POINT(homing_target) - PT.x += CLAMP(homing_offset_x, 1, world.maxx) - PT.y += CLAMP(homing_offset_y, 1, world.maxy) + PT.x += clamp(homing_offset_x, 1, world.maxx) + PT.y += clamp(homing_offset_y, 1, world.maxy) var/angle = closer_angle_difference(Angle, angle_between_points(RETURN_PRECISE_POINT(src), PT)) - setAngle(Angle + CLAMP(angle, -homing_turn_speed, homing_turn_speed)) + setAngle(Angle + clamp(angle, -homing_turn_speed, homing_turn_speed)) /obj/item/projectile/proc/set_homing_target(atom/A) if(!A || (!isturf(A) && !isturf(A.loc))) @@ -322,7 +322,7 @@ crash_with("WARNING: Projectile [type] deleted due to being unable to resolve a target after angle was null!") qdel(src) return - 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(dispersion) setAngle(Angle + rand(-dispersion, dispersion)) @@ -427,7 +427,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 = arctan(y - oy, x - ox) return list(angle, p_x, p_y) /obj/item/projectile/proc/redirect(x, y, starting, source) @@ -464,7 +464,7 @@ // Multiply projectile damage by 1.2, then CLAMP the value between 30 and 100. // This was 0.67 but in practice it made all projectiles that did 45 or less damage play at 30, // which is hard to hear over the gunshots, and is rather rare for a projectile to do that much. - return CLAMP((value_to_use) * 1.2, 30, 100) + return clamp((value_to_use) * 1.2, 30, 100) else return 50 //if the projectile doesn't do damage or agony, play its hitsound at 50% volume. @@ -812,7 +812,7 @@ /obj/item/projectile/proc/impact_sounds(atom/A) if(hitsound_wall && !ismob(A)) // Mob sounds are handled in attack_mob(). - var/volume = CLAMP(vol_by_damage() + 20, 0, 100) + var/volume = clamp(vol_by_damage() + 20, 0, 100) if(silenced) volume = 5 playsound(A, hitsound_wall, volume, 1, -1) diff --git a/code/modules/random_map/noise/noise.dm b/code/modules/random_map/noise/noise.dm index d8702a59a6..4428a757db 100644 --- a/code/modules/random_map/noise/noise.dm +++ b/code/modules/random_map/noise/noise.dm @@ -113,7 +113,7 @@ subdivide(iteration, x, y+hsize, hsize) subdivide(iteration, x+hsize, y+hsize, hsize) -#define NOISE2VALUE(X) CLAMP(round(((X)/cell_range)*10), 0, 9) +#define NOISE2VALUE(X) clamp(round(((X)/cell_range)*10), 0, 9) /datum/random_map/noise/cleanup() var/is_not_border_left var/is_not_border_right diff --git a/code/modules/reagents/machinery/chem_master.dm b/code/modules/reagents/machinery/chem_master.dm index ffceb9548d..347e58ed6f 100644 --- a/code/modules/reagents/machinery/chem_master.dm +++ b/code/modules/reagents/machinery/chem_master.dm @@ -197,7 +197,7 @@ if(!num) return arguments["num"] = num - var/amount_per_pill = CLAMP(reagents.total_volume / num, 0, MAX_UNITS_PER_PILL) + var/amount_per_pill = clamp(reagents.total_volume / num, 0, MAX_UNITS_PER_PILL) var/default_name = "[reagents.get_master_reagent_name()] ([amount_per_pill]u)" var/pills_text = num == 1 ? "new pill" : "[num] new pills" tgui_modal_input(src, id, "Please name your [pills_text]:", null, arguments, default_name, MAX_CUSTOM_NAME_LEN) @@ -217,7 +217,7 @@ if(!num) return arguments["num"] = num - var/amount_per_patch = CLAMP(reagents.total_volume / num, 0, MAX_UNITS_PER_PATCH) + var/amount_per_patch = clamp(reagents.total_volume / num, 0, MAX_UNITS_PER_PATCH) var/default_name = "[reagents.get_master_reagent_name()] ([amount_per_patch]u)" var/patches_text = num == 1 ? "new patch" : "[num] new patches" tgui_modal_input(src, id, "Please name your [patches_text]:", null, arguments, default_name, MAX_CUSTOM_NAME_LEN) @@ -232,7 +232,7 @@ if(!num) return arguments["num"] = num - var/amount_per_bottle = CLAMP(reagents.total_volume / num, 0, MAX_UNITS_PER_BOTTLE) + var/amount_per_bottle = clamp(reagents.total_volume / num, 0, MAX_UNITS_PER_BOTTLE) var/default_name = "[reagents.get_master_reagent_name()]" var/bottles_text = num == 1 ? "new bottle" : "[num] new bottles" tgui_modal_input(src, id, "Please name your [bottles_text] ([amount_per_bottle]u in bottle):", null, arguments, default_name, MAX_CUSTOM_NAME_LEN) @@ -288,13 +288,13 @@ if("create_pill") if(condi || !reagents.total_volume) return - var/count = CLAMP(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT) + var/count = clamp(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT) if(!count) return if(!length(answer)) answer = reagents.get_master_reagent_name() - var/amount_per_pill = CLAMP(reagents.total_volume / count, 0, MAX_UNITS_PER_PILL) + var/amount_per_pill = clamp(reagents.total_volume / count, 0, MAX_UNITS_PER_PILL) while(count--) if(reagents.total_volume <= 0) to_chat(usr, "Not enough reagents to create these pills!") @@ -316,20 +316,20 @@ return tgui_act("modal_open", list("id" = "create_pill", "arguments" = list("num" = answer)), ui, state) if("change_pill_style") - var/new_style = CLAMP(text2num(answer) || 0, 0, MAX_PILL_SPRITE) + var/new_style = clamp(text2num(answer) || 0, 0, MAX_PILL_SPRITE) if(!new_style) return pillsprite = new_style if("create_patch") if(condi || !reagents.total_volume) return - var/count = CLAMP(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT) + var/count = clamp(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT) if(!count) return if(!length(answer)) answer = reagents.get_master_reagent_name() - var/amount_per_patch = CLAMP(reagents.total_volume / count, 0, MAX_UNITS_PER_PATCH) + var/amount_per_patch = clamp(reagents.total_volume / count, 0, MAX_UNITS_PER_PATCH) // var/is_medical_patch = chemical_safety_check(reagents) while(count--) if(reagents.total_volume <= 0) @@ -351,13 +351,13 @@ if("create_bottle") if(condi || !reagents.total_volume) return - var/count = CLAMP(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT) + var/count = clamp(round(text2num(arguments["num"]) || 0), 0, MAX_MULTI_AMOUNT) if(!count) return if(!length(answer)) answer = reagents.get_master_reagent_name() - var/amount_per_bottle = CLAMP(reagents.total_volume / count, 0, MAX_UNITS_PER_BOTTLE) + var/amount_per_bottle = clamp(reagents.total_volume / count, 0, MAX_UNITS_PER_BOTTLE) while(count--) if(reagents.total_volume <= 0) to_chat(usr, "Not enough reagents to create these bottles!") @@ -374,7 +374,7 @@ return tgui_act("modal_open", list("id" = "create_bottle", "arguments" = list("num" = answer)), ui, state) if("change_bottle_style") - var/new_style = CLAMP(text2num(answer) || 0, 0, MAX_BOTTLE_SPRITE) + var/new_style = clamp(text2num(answer) || 0, 0, MAX_BOTTLE_SPRITE) if(!new_style) return bottlesprite = new_style diff --git a/code/modules/reagents/machinery/distillery.dm b/code/modules/reagents/machinery/distillery.dm index d64d8b3211..23c296a982 100644 --- a/code/modules/reagents/machinery/distillery.dm +++ b/code/modules/reagents/machinery/distillery.dm @@ -205,7 +205,7 @@ if("adjust temp") target_temp = input("Choose a target temperature.", "Temperature.", T20C) as num - target_temp = CLAMP(target_temp, min_temp, max_temp) + target_temp = clamp(target_temp, min_temp, max_temp) update_icon() @@ -310,7 +310,7 @@ // As of initial testing, a *10 gives ~5-6 minutes to go from room temp to 500C (+/-0.5C) var/temp_diff = (current_temp < target_temp ? dy * 10 * target_temp / current_temp : dy * -10 * current_temp / target_temp) - current_temp = CLAMP(round((current_temp + temp_diff), 0.01), min_temp, max_temp) + current_temp = clamp(round((current_temp + temp_diff), 0.01), min_temp, max_temp) use_power(power_rating * CELLRATE) if(target_temp == round(current_temp, 1.0)) diff --git a/code/modules/reagents/reagents/food_drinks.dm b/code/modules/reagents/reagents/food_drinks.dm index 967227c311..c445659d37 100644 --- a/code/modules/reagents/reagents/food_drinks.dm +++ b/code/modules/reagents/reagents/food_drinks.dm @@ -542,7 +542,7 @@ if(iscarbon(M) && !M.isSynthetic()) var/message = pick("Oh god, it smells disgusting here.", "What is that stench?", "That's an awful odor.") to_chat(M, "[message]") - if(prob(CLAMP(amount, 5, 90))) + if(prob(clamp(amount, 5, 90))) var/mob/living/L = M L.vomit() return ..() diff --git a/code/modules/reagents/reagents/medicine.dm b/code/modules/reagents/reagents/medicine.dm index 04e51fc5ac..c93d4f0c32 100644 --- a/code/modules/reagents/reagents/medicine.dm +++ b/code/modules/reagents/reagents/medicine.dm @@ -797,7 +797,7 @@ if(H.losebreath >= 15 && prob(H.losebreath)) H.Stun(2) else - H.losebreath = CLAMP(H.losebreath + 3, 0, 20) + H.losebreath = clamp(H.losebreath + 3, 0, 20) else H.losebreath = max(H.losebreath - 4, 0) @@ -892,7 +892,7 @@ I.damage = max(I.damage - 4 * removed * repair_strength, 0) H.Confuse(2) if(M.reagents.has_reagent("respirodaxon") || M.reagents.has_reagent("peridaxon")) - H.losebreath = CLAMP(H.losebreath + 1, 0, 10) + H.losebreath = clamp(H.losebreath + 1, 0, 10) else H.adjustOxyLoss(-30 * removed) // Deals with blood oxygenation. diff --git a/code/modules/tgui/modules/law_manager.dm b/code/modules/tgui/modules/law_manager.dm index d454ad94cf..bd1092289d 100644 --- a/code/modules/tgui/modules/law_manager.dm +++ b/code/modules/tgui/modules/law_manager.dm @@ -91,7 +91,7 @@ if("change_supplied_law_position") var/new_position = input(usr, "Enter new supplied law position between 1 and [MAX_SUPPLIED_LAW_NUMBER], inclusive. Inherent laws at the same index as a supplied law will not be stated.", "Law Position", supplied_law_position) as num|null if(isnum(new_position) && can_still_topic(usr, state)) - supplied_law_position = CLAMP(new_position, 1, MAX_SUPPLIED_LAW_NUMBER) + supplied_law_position = clamp(new_position, 1, MAX_SUPPLIED_LAW_NUMBER) return TRUE if("edit_law") diff --git a/code/modules/vchat/vchat_client.dm b/code/modules/vchat/vchat_client.dm index c03c9e201a..ab98c37adb 100644 --- a/code/modules/vchat/vchat_client.dm +++ b/code/modules/vchat/vchat_client.dm @@ -242,7 +242,7 @@ GLOBAL_DATUM_INIT(iconCache, /savefile, new("data/iconCache.sav")) //Cache of ic data = debugmsg(arglist(params)) if(href_list["showingnum"]) - message_buffer = CLAMP(text2num(href_list["showingnum"]), 50, 2000) + message_buffer = clamp(text2num(href_list["showingnum"]), 50, 2000) if(data) send_event(event = data) diff --git a/tgui/docs/tutorial-and-examples.md b/tgui/docs/tutorial-and-examples.md index c0e32ebf8e..0e5f8bef19 100644 --- a/tgui/docs/tutorial-and-examples.md +++ b/tgui/docs/tutorial-and-examples.md @@ -310,7 +310,7 @@ upon code review): if("copypasta") var/newvar = params["var"] // A demo of proper input sanitation. - var = CLAMP(newvar, min_val, max_val) + var = clamp(newvar, min_val, max_val) . = TRUE update_icon() // Not applicable to all objects. ```