diff --git a/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm b/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm index 7709bb56580..6707399ecfc 100644 --- a/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm +++ b/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm @@ -232,21 +232,21 @@ pump_direction = 1 if(signal.data["set_input_pressure"]) - input_pressure_min = between( + input_pressure_min = clamp( 0, text2num(signal.data["set_input_pressure"]), ONE_ATMOSPHERE*50 ) if(signal.data["set_output_pressure"]) - output_pressure_max = between( + output_pressure_max = clamp( 0, text2num(signal.data["set_output_pressure"]), ONE_ATMOSPHERE*50 ) if(signal.data["set_external_pressure"]) - external_pressure_bound = between( + external_pressure_bound = clamp( 0, text2num(signal.data["set_external_pressure"]), ONE_ATMOSPHERE*50 diff --git a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm index c80bfdc8338..96887fb56ac 100644 --- a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm +++ b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm @@ -181,7 +181,7 @@ unlocked = !unlocked if("set_target_pressure" in signal.data) - target_pressure = between( + target_pressure = clamp( 0, text2num(signal.data["set_target_pressure"]), max_pressure_setting @@ -262,7 +262,7 @@ target_pressure = max_pressure_setting if("set") var/new_pressure = input(usr,"Enter new output pressure (0-[max_pressure_setting]kPa)","Pressure Control",src.target_pressure) as num - src.target_pressure = between(0, new_pressure, max_pressure_setting) + src.target_pressure = clamp(0, new_pressure, max_pressure_setting) if("set_flow_rate") . = TRUE @@ -273,7 +273,7 @@ set_flow_rate = air1.volume if("set") var/new_flow_rate = input(usr,"Enter new flow rate limit (0-[air1.volume]L/s)","Flow Rate Control",src.set_flow_rate) as num - src.set_flow_rate = between(0, new_flow_rate, air1.volume) + src.set_flow_rate = clamp(0, new_flow_rate, air1.volume) update_icon() add_fingerprint(usr) diff --git a/code/ATMOSPHERICS/components/binary_devices/pump.dm b/code/ATMOSPHERICS/components/binary_devices/pump.dm index 3178d7bf85e..1f6c60b7297 100644 --- a/code/ATMOSPHERICS/components/binary_devices/pump.dm +++ b/code/ATMOSPHERICS/components/binary_devices/pump.dm @@ -182,7 +182,7 @@ Thus, the two variables affect pump operation are set in New(): update_use_power(!use_power) if(signal.data["set_output_pressure"]) - target_pressure = between( + target_pressure = clamp( 0, text2num(signal.data["set_output_pressure"]), ONE_ATMOSPHERE*50 @@ -227,7 +227,7 @@ Thus, the two variables affect pump operation are set in New(): target_pressure = max_pressure_setting if("set") var/new_pressure = input(usr,"Enter new output pressure (0-[max_pressure_setting]kPa)","Pressure control",src.target_pressure) as num - src.target_pressure = between(0, new_pressure, max_pressure_setting) + src.target_pressure = clamp(0, new_pressure, max_pressure_setting) . = TRUE add_fingerprint(usr) diff --git a/code/ATMOSPHERICS/components/omni_devices/mixer.dm b/code/ATMOSPHERICS/components/omni_devices/mixer.dm index 7f422df44aa..45c62c20dbe 100644 --- a/code/ATMOSPHERICS/components/omni_devices/mixer.dm +++ b/code/ATMOSPHERICS/components/omni_devices/mixer.dm @@ -184,7 +184,7 @@ if(!configuring || use_power) return var/new_flow_rate = input(usr,"Enter new flow rate limit (0-[max_flow_rate]L/s)","Flow Rate Control",set_flow_rate) as num - set_flow_rate = between(0, new_flow_rate, max_flow_rate) + set_flow_rate = clamp(0, new_flow_rate, max_flow_rate) if("switch_mode") . = TRUE if(!configuring || use_power) @@ -268,7 +268,7 @@ var/new_con = (input(usr,"Enter a new concentration (0-[round(remain_con * 100, 0.5)])%","Concentration control", min(remain_con, old_con)*100) as num) / 100 //cap it between 0 and the max remaining concentration - new_con = between(0, new_con, remain_con) + new_con = clamp(0, new_con, remain_con) //new_con = min(remain_con, new_con) @@ -294,4 +294,4 @@ /obj/machinery/atmospherics/omni/mixer/proc/con_lock(var/port = NORTH) for(var/datum/omni_port/P in inputs) if(P.dir == port) - P.con_lock = !P.con_lock \ No newline at end of file + P.con_lock = !P.con_lock diff --git a/code/ATMOSPHERICS/components/unary/heat_source.dm b/code/ATMOSPHERICS/components/unary/heat_source.dm index 5fcc679adfc..98774d01662 100644 --- a/code/ATMOSPHERICS/components/unary/heat_source.dm +++ b/code/ATMOSPHERICS/components/unary/heat_source.dm @@ -120,7 +120,7 @@ else set_temperature = max(amount, 0) if("setPower") //setting power to 0 is redundant anyways - var/new_setting = between(0, text2num(params["value"]), 100) + var/new_setting = clamp(0, text2num(params["value"]), 100) set_power_level(new_setting) add_fingerprint(usr) diff --git a/code/ATMOSPHERICS/components/unary/outlet_injector.dm b/code/ATMOSPHERICS/components/unary/outlet_injector.dm index d3ea8cbbdca..5bb5ff52394 100644 --- a/code/ATMOSPHERICS/components/unary/outlet_injector.dm +++ b/code/ATMOSPHERICS/components/unary/outlet_injector.dm @@ -140,7 +140,7 @@ if(signal.data["set_volume_rate"]) var/number = text2num(signal.data["set_volume_rate"]) - volume_rate = between(0, number, air_contents.volume) + volume_rate = clamp(0, number, air_contents.volume) if(signal.data["status"]) spawn(2) diff --git a/code/ATMOSPHERICS/components/unary/vent_pump.dm b/code/ATMOSPHERICS/components/unary/vent_pump.dm index 7ed4040e66d..b61ccf4b70b 100644 --- a/code/ATMOSPHERICS/components/unary/vent_pump.dm +++ b/code/ATMOSPHERICS/components/unary/vent_pump.dm @@ -323,7 +323,7 @@ if (signal.data["set_internal_pressure"] == "default") internal_pressure_bound = internal_pressure_bound_default else - internal_pressure_bound = between( + internal_pressure_bound = clamp( 0, text2num(signal.data["set_internal_pressure"]), ONE_ATMOSPHERE*50 @@ -333,14 +333,14 @@ if (signal.data["set_external_pressure"] == "default") external_pressure_bound = external_pressure_bound_default else - external_pressure_bound = between( + external_pressure_bound = clamp( 0, text2num(signal.data["set_external_pressure"]), ONE_ATMOSPHERE*50 ) if(signal.data["adjust_internal_pressure"] != null) - internal_pressure_bound = between( + internal_pressure_bound = clamp( 0, internal_pressure_bound + text2num(signal.data["adjust_internal_pressure"]), ONE_ATMOSPHERE*50 @@ -349,7 +349,7 @@ if(signal.data["adjust_external_pressure"] != null) - external_pressure_bound = between( + external_pressure_bound = clamp( 0, external_pressure_bound + text2num(signal.data["adjust_external_pressure"]), ONE_ATMOSPHERE*50 diff --git a/code/_helpers/unsorted.dm b/code/_helpers/unsorted.dm index 25c68a9a277..63302d27183 100644 --- a/code/_helpers/unsorted.dm +++ b/code/_helpers/unsorted.dm @@ -206,7 +206,7 @@ Turf and target are separate in case you want to teleport some distance from a t line+=locate(px,py,M.z) return line -#define LOCATE_COORDS(X, Y, Z) locate(between(1, X, world.maxx), between(1, Y, world.maxy), Z) +#define LOCATE_COORDS(X, Y, Z) locate(clamp(1, X, world.maxx), clamp(1, Y, world.maxy), Z) /proc/getcircle(turf/center, var/radius) //Uses a fast Bresenham rasterization algorithm to return the turfs in a thin circle. if(!radius) return list(center) @@ -566,10 +566,6 @@ Turf and target are separate in case you want to teleport some distance from a t var/y = min(world.maxy, max(1, A.y + dy)) return locate(x,y,A.z) -//Makes sure MIDDLE is between LOW and HIGH. If not, it adjusts it. Returns the adjusted value. -/proc/between(var/low, var/middle, var/high) - return max(min(middle, high), low) - //returns random gauss number /proc/GaussRand(var/sigma) var/x,y,rsq diff --git a/code/controllers/subsystems/game_master.dm b/code/controllers/subsystems/game_master.dm index 6c1e1adbef6..c5e71483aed 100644 --- a/code/controllers/subsystems/game_master.dm +++ b/code/controllers/subsystems/game_master.dm @@ -85,12 +85,12 @@ SUBSYSTEM_DEF(game_master) // Tell the game master that something dangerous happened, e.g. someone dying, station explosions. /datum/controller/subsystem/game_master/proc/adjust_danger(amount) amount *= GM.danger_modifier - danger = round(between(0, danger + amount, 1000), 0.1) + danger = round(clamp(0, danger + amount, 1000), 0.1) // Tell the game master that things are getting boring if positive, or something interesting if negative.. /datum/controller/subsystem/game_master/proc/adjust_staleness(amount) amount *= GM.staleness_modifier - staleness = round( between(-20, staleness + amount, 100), 0.1) + staleness = round( clamp(-20, staleness + amount, 100), 0.1) // These are ran before committing to an event. // Returns TRUE if the system is allowed to proceed, otherwise returns FALSE. @@ -364,4 +364,4 @@ SUBSYSTEM_DEF(game_master) danger = amount message_admins("GM danger was set to [amount] by [usr.key].") - interact(usr) // To refresh the UI. \ No newline at end of file + interact(usr) // To refresh the UI. diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index c50ecf89d8b..4cefa846369 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -498,7 +498,7 @@ a = get_area(src.loc) // and yet it moves - var/arc_progress = between(0, dist_travelled/total_distance, 1) + var/arc_progress = clamp(0, dist_travelled/total_distance, 1) var/sine_position = arc_progress * 180 var/pixel_z_position = arc * sin(sine_position) diff --git a/code/game/gamemodes/malfunction/newmalf_ability_trees/tree_manipulation.dm b/code/game/gamemodes/malfunction/newmalf_ability_trees/tree_manipulation.dm index 19642c31d76..52567b9572a 100644 --- a/code/game/gamemodes/malfunction/newmalf_ability_trees/tree_manipulation.dm +++ b/code/game/gamemodes/malfunction/newmalf_ability_trees/tree_manipulation.dm @@ -190,7 +190,7 @@ if(temp_apc) temp_apc.emp_act(3) // Such power surges are not good for APC electronics if(temp_apc.cell) - temp_apc.cell.maxcharge -= between(0, (temp_apc.cell.maxcharge/2) + 500, temp_apc.cell.maxcharge) + temp_apc.cell.maxcharge -= clamp(0, (temp_apc.cell.maxcharge/2) + 500, temp_apc.cell.maxcharge) if(temp_apc.cell.maxcharge < 100) // That's it, you busted the APC cell completely. Break the APC and completely destroy the cell. qdel(temp_apc.cell) temp_apc.set_broken() diff --git a/code/game/gamemodes/technomancer/instability.dm b/code/game/gamemodes/technomancer/instability.dm index 335c0536597..91b9b849462 100644 --- a/code/game/gamemodes/technomancer/instability.dm +++ b/code/game/gamemodes/technomancer/instability.dm @@ -18,7 +18,7 @@ // Parameters: 0 // Description: Does nothing, because inheritance. /mob/living/proc/adjust_instability(var/amount) - instability = between(0, round(instability + amount, TECHNOMANCER_INSTABILITY_PRECISION), 200) + instability = clamp(0, round(instability + amount, TECHNOMANCER_INSTABILITY_PRECISION), 200) // Proc: adjust_instability() // Parameters: 1 (amount - how much instability to give) @@ -56,7 +56,7 @@ // Description: Makes instability decay. instability_effects() handles the bad effects for having instability. It will also hold back // from causing bad effects more than one every ten seconds, to prevent sudden death from angry RNG. /mob/living/proc/handle_instability() - instability = between(0, round(instability, TECHNOMANCER_INSTABILITY_PRECISION), 200) + instability = clamp(0, round(instability, TECHNOMANCER_INSTABILITY_PRECISION), 200) last_instability = instability //This should cushion against really bad luck. @@ -287,4 +287,3 @@ else to_chat(src, "The purple glow makes you feel strange...") adjust_instability(amount) - diff --git a/code/game/gamemodes/technomancer/spells/gambit.dm b/code/game/gamemodes/technomancer/spells/gambit.dm index cde2e9e28b8..0d36a8e3bf5 100644 --- a/code/game/gamemodes/technomancer/spells/gambit.dm +++ b/code/game/gamemodes/technomancer/spells/gambit.dm @@ -46,7 +46,7 @@ // Gives a random spell. /obj/item/spell/gambit/proc/random_spell() var/list/potential_spells = all_technomancer_gambit_spells.Copy() - var/rare_spell_chance = between(0, calculate_spell_power(100) - 100, 100) // Having 120% spellpower means a 20% chance to get to roll for rare spells. + var/rare_spell_chance = clamp(0, calculate_spell_power(100) - 100, 100) // Having 120% spellpower means a 20% chance to get to roll for rare spells. if(prob(rare_spell_chance)) potential_spells += rare_spells.Copy() to_chat(owner, "You feel a bit luckier...") @@ -55,7 +55,7 @@ // Gives a "random" spell. /obj/item/spell/gambit/proc/biased_random_spell() var/list/potential_spells = list() - var/rare_spell_chance = between(0, calculate_spell_power(100) - 100, 100) + var/rare_spell_chance = clamp(0, calculate_spell_power(100) - 100, 100) var/give_rare_spells = FALSE if(prob(rare_spell_chance)) give_rare_spells = TRUE @@ -131,4 +131,4 @@ if(!potential_spells.len) potential_spells = all_technomancer_gambit_spells.Copy() - return pick(potential_spells) \ No newline at end of file + return pick(potential_spells) diff --git a/code/game/gamemodes/technomancer/spells/radiance.dm b/code/game/gamemodes/technomancer/spells/radiance.dm index c9d37ecacfc..85984e1f783 100644 --- a/code/game/gamemodes/technomancer/spells/radiance.dm +++ b/code/game/gamemodes/technomancer/spells/radiance.dm @@ -40,7 +40,7 @@ var/thermal_power = 300 * adjusted_power removed.add_thermal_energy(thermal_power) - removed.temperature = between(0, removed.temperature, 10000) + removed.temperature = clamp(0, removed.temperature, 10000) env.merge(removed) diff --git a/code/game/machinery/atmo_control.dm b/code/game/machinery/atmo_control.dm index fafd8e34417..e156d1d552b 100644 --- a/code/game/machinery/atmo_control.dm +++ b/code/game/machinery/atmo_control.dm @@ -187,12 +187,12 @@ switch(action) if("adj_pressure") var/new_pressure = text2num(params["adj_pressure"]) - pressure_setting = between(0, new_pressure, 50*ONE_ATMOSPHERE) + pressure_setting = clamp(0, new_pressure, 50*ONE_ATMOSPHERE) return TRUE if("adj_input_flow_rate") var/new_flow = text2num(params["adj_input_flow_rate"]) - input_flow_setting = between(0, new_flow, ATMOS_DEFAULT_VOLUME_PUMP + 500) //default flow rate limit for air injectors + input_flow_setting = clamp(0, new_flow, ATMOS_DEFAULT_VOLUME_PUMP + 500) //default flow rate limit for air injectors return TRUE if(!radio_connection) @@ -288,12 +288,12 @@ switch(action) if("adj_pressure") var/new_pressure = text2num(params["adj_pressure"]) - pressure_setting = between(0, new_pressure, 10*ONE_ATMOSPHERE) + pressure_setting = clamp(0, new_pressure, 10*ONE_ATMOSPHERE) return TRUE if("adj_input_flow_rate") var/new_flow = text2num(params["adj_input_flow_rate"]) - input_flow_setting = between(0, new_flow, ATMOS_DEFAULT_VOLUME_PUMP + 500) //default flow rate limit for air injectors + input_flow_setting = clamp(0, new_flow, ATMOS_DEFAULT_VOLUME_PUMP + 500) //default flow rate limit for air injectors return TRUE if(!radio_connection) @@ -399,7 +399,7 @@ /obj/machinery/computer/general_air_control/fuel_injection/tgui_act(action, params) if(..()) return TRUE - + switch(action) if("refresh_status") device_info = null @@ -452,4 +452,4 @@ ) radio_connection.post_signal(src, signal, radio_filter = RADIO_ATMOSIA) - . = TRUE \ No newline at end of file + . = TRUE diff --git a/code/game/machinery/cloning.dm b/code/game/machinery/cloning.dm index 51eb39765cf..f86cec40fa2 100644 --- a/code/game/machinery/cloning.dm +++ b/code/game/machinery/cloning.dm @@ -150,7 +150,7 @@ // Upgraded cloners can reduce the time of the modifier, up to 80% var/clone_sickness_length = abs(((heal_level - 20) / 100 ) - 1) - clone_sickness_length = between(0.2, clone_sickness_length, 1.0) // Caps it off just incase. + clone_sickness_length = clamp(0.2, clone_sickness_length, 1.0) // Caps it off just incase. modifier_lower_bound = round(modifier_lower_bound * clone_sickness_length, 1) modifier_upper_bound = round(modifier_upper_bound * clone_sickness_length, 1) diff --git a/code/game/machinery/doors/door.dm b/code/game/machinery/doors/door.dm index 2d433f6b7de..4fdeff8f1ac 100644 --- a/code/game/machinery/doors/door.dm +++ b/code/game/machinery/doors/door.dm @@ -266,7 +266,7 @@ playsound(src, welder.usesound, 50, 1) if(do_after(user, (5 * repairing) * welder.toolspeed) && welder && welder.isOn()) to_chat(user, "You finish repairing the damage to \the [src].") - health = between(health, health + repairing*DOOR_REPAIR_AMOUNT, maxhealth) + health = clamp(health, health + repairing*DOOR_REPAIR_AMOUNT, maxhealth) update_icon() repairing = 0 return diff --git a/code/game/machinery/telecomms/machine_interactions.dm b/code/game/machinery/telecomms/machine_interactions.dm index 5e8cd17351e..f016c573ea5 100644 --- a/code/game/machinery/telecomms/machine_interactions.dm +++ b/code/game/machinery/telecomms/machine_interactions.dm @@ -24,7 +24,7 @@ var/obj/item/stack/nanopaste/T = P if (integrity < 100) //Damaged, let's repair! if (T.use(1)) - integrity = between(0, integrity + rand(10,20), 100) + integrity = clamp(0, integrity + rand(10,20), 100) to_chat(usr, "You apply the Nanopaste to [src], repairing some of the damage.") else to_chat(usr, "This machine is already in perfect condition.") @@ -41,7 +41,7 @@ /obj/machinery/telecomms/tgui_data(mob/user) var/list/data = list() - + data["temp"] = temp data["on"] = on @@ -81,7 +81,7 @@ "index" = i, ))) data["linked"] = linked - + var/list/filter = list() if(LAZYLEN(freq_listening)) for(var/x in freq_listening) @@ -214,7 +214,7 @@ /obj/machinery/telecomms/bus/Options_Act(action, params) if(..()) return TRUE - + switch(action) if("change_freq") . = TRUE @@ -268,7 +268,7 @@ /obj/machinery/telecomms/receiver/Options_Act(action, params) if(..()) return TRUE - + switch(action) if("range") var/new_range = params["range"] diff --git a/code/game/machinery/telecomms/telecommunications.dm b/code/game/machinery/telecomms/telecommunications.dm index 7a741f7ae8c..f4f390514c9 100644 --- a/code/game/machinery/telecomms/telecommunications.dm +++ b/code/game/machinery/telecomms/telecommunications.dm @@ -203,7 +203,7 @@ var/global/list/obj/machinery/telecomms/telecomms_list = list() if((T0C + 200) to INFINITY) // More than 200C, INFERNO. Takes damage every tick. damage_chance = 100 if (damage_chance && prob(damage_chance)) - integrity = between(0, integrity - 1, 100) + integrity = clamp(0, integrity - 1, 100) if(delay > 0) diff --git a/code/game/objects/items/devices/defib.dm b/code/game/objects/items/devices/defib.dm index 24b06080233..6f2c404274e 100644 --- a/code/game/objects/items/devices/defib.dm +++ b/code/game/objects/items/devices/defib.dm @@ -518,7 +518,7 @@ var/damage_calc = LERP(brain.max_damage, H.getBrainLoss(), brain_death_scale) // A bit of sanity. - var/brain_damage = between(H.getBrainLoss(), damage_calc, brain.max_damage) + var/brain_damage = clamp(H.getBrainLoss(), damage_calc, brain.max_damage) H.setBrainLoss(brain_damage) diff --git a/code/game/objects/items/devices/radio/jammer.dm b/code/game/objects/items/devices/radio/jammer.dm index 7943ab92650..24c4345df28 100644 --- a/code/game/objects/items/devices/radio/jammer.dm +++ b/code/game/objects/items/devices/radio/jammer.dm @@ -106,7 +106,7 @@ var/global/list/active_radio_jammers = list() var/overlay_percent = 0 if(power_source) - overlay_percent = between(0, round( power_source.percent() , 25), 100) + overlay_percent = clamp(0, round( power_source.percent() , 25), 100) else overlay_percent = 0 @@ -115,4 +115,3 @@ var/global/list/active_radio_jammers = list() cut_overlays() add_overlay("jammer_overlay_[overlay_percent]") last_overlay_percent = overlay_percent - diff --git a/code/game/objects/items/weapons/material/material_armor.dm b/code/game/objects/items/weapons/material/material_armor.dm index b203fbb0578..bcb17d76c6b 100644 --- a/code/game/objects/items/weapons/material/material_armor.dm +++ b/code/game/objects/items/weapons/material/material_armor.dm @@ -182,7 +182,7 @@ Protectiveness | Armor % // Makes sure the numbers stay capped. for(var/number in list(melee_armor, bullet_armor, laser_armor, energy_armor, bomb_armor)) - number = between(0, number, 100) + number = clamp(0, number, 100) armor["melee"] = melee_armor armor["bullet"] = bullet_armor @@ -191,9 +191,9 @@ Protectiveness | Armor % armor["bomb"] = bomb_armor if(!isnull(material.conductivity)) - siemens_coefficient = between(0, material.conductivity / 10, 10) + siemens_coefficient = clamp(0, material.conductivity / 10, 10) - var/slowdownModified = between(0, round(material.weight / 10, 0.1), 6) + var/slowdownModified = clamp(0, round(material.weight / 10, 0.1), 6) var/slowdownUncapped = (material_slowdown_multiplier * slowdownModified) - material_slowdown_modifier diff --git a/code/game/objects/items/weapons/tools/weldingtool.dm b/code/game/objects/items/weapons/tools/weldingtool.dm index 9af46a1e5a7..fcc3a366f21 100644 --- a/code/game/objects/items/weapons/tools/weldingtool.dm +++ b/code/game/objects/items/weapons/tools/weldingtool.dm @@ -311,7 +311,7 @@ if(!istype(user)) return 1 var/safety = user.eyecheck() - safety = between(-1, safety + eye_safety_modifier, 2) + safety = clamp(-1, safety + eye_safety_modifier, 2) if(istype(user, /mob/living/carbon/human)) var/mob/living/carbon/human/H = user var/obj/item/organ/internal/eyes/E = H.internal_organs_by_name[O_EYES] diff --git a/code/game/objects/structures/cliff.dm b/code/game/objects/structures/cliff.dm index ad235424489..5c9eb3a357d 100644 --- a/code/game/objects/structures/cliff.dm +++ b/code/game/objects/structures/cliff.dm @@ -254,7 +254,7 @@ two tiles on initialization, and which way a cliff is facing may change during m if(length(vehicle.buckled_mobs)) for(var/mob/living/rider in vehicle.buckled_mobs) - var/damage = between(20, rider.getMaxHealth() * 0.4, 100) + var/damage = clamp(20, rider.getMaxHealth() * 0.4, 100) var/target_zone = ran_zone() var/blocked = rider.run_armor_check(target_zone, "melee") * harm var/soaked = rider.get_armor_soak(target_zone, "melee") * harm @@ -278,7 +278,7 @@ two tiles on initialization, and which way a cliff is facing may change during m continue passengers |= passenger - var/damage = between(10, L.getMaxHealth() * 0.4, 50) + var/damage = clamp(10, L.getMaxHealth() * 0.4, 50) var/target_zone = ran_zone() var/blocked = passenger.run_armor_check(target_zone, "melee") * harm var/soaked = passenger.get_armor_soak(target_zone, "melee") * harm @@ -287,7 +287,7 @@ two tiles on initialization, and which way a cliff is facing may change during m shake_camera(passenger, 1, 1) to_chat(passenger, SPAN_WARNING("\The [MP] shakes, bouncing you violently!")) - Mech.take_damage(between(50, Mech.maxhealth * 0.4 * harm, 300)) + Mech.take_damage(clamp(50, Mech.maxhealth * 0.4 * harm, 300)) if(QDELETED(Mech) && length(passengers)) // Damage caused the mech to explode, or otherwise vanish. for(var/mob/living/victim in passengers) @@ -316,7 +316,7 @@ two tiles on initialization, and which way a cliff is facing may change during m // The bigger they are, the harder they fall. // They will take at least 20 damage at the minimum, and tries to scale up to 40% of their max health. // This scaling is capped at 100 total damage, which occurs if the thing that fell has more than 250 health. - var/damage = between(20, L.getMaxHealth() * 0.4, 100) + var/damage = clamp(20, L.getMaxHealth() * 0.4, 100) var/target_zone = ran_zone() var/blocked = L.run_armor_check(target_zone, "melee") * harm var/soaked = L.get_armor_soak(target_zone, "melee") * harm diff --git a/code/game/objects/structures/flora/trees.dm b/code/game/objects/structures/flora/trees.dm index 3afd4276eee..e3e76a0edcf 100644 --- a/code/game/objects/structures/flora/trees.dm +++ b/code/game/objects/structures/flora/trees.dm @@ -128,7 +128,7 @@ var/wood = initial(product_amount) product_amount -= round(wood * (abs(amount)/max_health)) - health = between(0, health + amount, max_health) + health = clamp(0, health + amount, max_health) if(health <= 0) die() return diff --git a/code/game/objects/structures/grille.dm b/code/game/objects/structures/grille.dm index 810d6b7461f..812797f5fd2 100644 --- a/code/game/objects/structures/grille.dm +++ b/code/game/objects/structures/grille.dm @@ -70,11 +70,11 @@ if(BRUTE) //bullets if(Proj.original == src || prob(20)) - Proj.damage *= between(0, Proj.damage/60, 0.5) + Proj.damage *= clamp(0, Proj.damage/60, 0.5) if(prob(max((damage-10)/25, 0))*100) passthrough = 1 else - Proj.damage *= between(0, Proj.damage/60, 1) + Proj.damage *= clamp(0, Proj.damage/60, 1) passthrough = 1 if(BURN) //beams and other projectiles are either blocked completely by grilles or stop half the damage. @@ -84,7 +84,7 @@ if(passthrough) . = PROJECTILE_CONTINUE - damage = between(0, (damage - Proj.damage)*(Proj.damage_type == BRUTE? 0.4 : 1), 10) //if the bullet passes through then the grille avoids most of the damage + damage = clamp(0, (damage - Proj.damage)*(Proj.damage_type == BRUTE? 0.4 : 1), 10) //if the bullet passes through then the grille avoids most of the damage src.health -= damage*0.2 spawn(0) healthcheck() //spawn to make sure we return properly if the grille is deleted diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm index 21531a02366..090c5cb6c4c 100644 --- a/code/game/objects/structures/watercloset.dm +++ b/code/game/objects/structures/watercloset.dm @@ -292,7 +292,7 @@ if(!on || !istype(M)) return var/temperature = temperature_settings[watertemp] - var/temp_adj = between(BODYTEMP_COOLING_MAX, temperature - M.bodytemperature, BODYTEMP_HEATING_MAX) + var/temp_adj = clamp(BODYTEMP_COOLING_MAX, temperature - M.bodytemperature, BODYTEMP_HEATING_MAX) M.bodytemperature += temp_adj if(ishuman(M)) diff --git a/code/modules/ai/ai_holder_subtypes/slime_xenobio_ai.dm b/code/modules/ai/ai_holder_subtypes/slime_xenobio_ai.dm index a55cb07f809..ae05b49a310 100644 --- a/code/modules/ai/ai_holder_subtypes/slime_xenobio_ai.dm +++ b/code/modules/ai/ai_holder_subtypes/slime_xenobio_ai.dm @@ -92,7 +92,7 @@ holder.say(pick("Why...?", "I don't understand...?", "Cruel...", "Stop...", "Nooo...")) resentment++ // Done after check so first time will never enrage. - discipline = between(0, discipline + amount, 10) + discipline = clamp(0, discipline + amount, 10) my_slime.update_mood() // This slime always enrages if disciplined. diff --git a/code/modules/blob2/blobs/base_blob.dm b/code/modules/blob2/blobs/base_blob.dm index 05a231dbfa7..bbac3927078 100644 --- a/code/modules/blob2/blobs/base_blob.dm +++ b/code/modules/blob2/blobs/base_blob.dm @@ -437,7 +437,7 @@ GLOBAL_LIST_EMPTY(all_blobs) return /obj/structure/blob/proc/adjust_integrity(amount) - integrity = between(0, integrity + amount, max_integrity) + integrity = clamp(0, integrity + amount, max_integrity) if(integrity == 0) playsound(src, 'sound/effects/splat.ogg', 50, 1) if(overmind) diff --git a/code/modules/blob2/overmind/overmind.dm b/code/modules/blob2/overmind/overmind.dm index ec03e52c321..6045115d53c 100644 --- a/code/modules/blob2/overmind/overmind.dm +++ b/code/modules/blob2/overmind/overmind.dm @@ -97,7 +97,7 @@ var/global/list/overminds = list() return TRUE /mob/observer/blob/proc/add_points(points) - blob_points = between(0, blob_points + points, max_blob_points) + blob_points = clamp(0, blob_points + points, max_blob_points) /mob/observer/blob/Life() if(ai_controlled && (!client || auto_pilot)) diff --git a/code/modules/clothing/spacesuits/breaches.dm b/code/modules/clothing/spacesuits/breaches.dm index b306fd92cc9..5cdc830b981 100644 --- a/code/modules/clothing/spacesuits/breaches.dm +++ b/code/modules/clothing/spacesuits/breaches.dm @@ -44,7 +44,7 @@ var/global/list/breach_burn_descriptors = list( /datum/breach/proc/update_descriptor() //Sanity... - class = between(1, round(class), 5) + class = clamp(1, round(class), 5) //Apply the correct descriptor. if(damtype == BURN) descriptor = breach_burn_descriptors[class] diff --git a/code/modules/economy/mint.dm b/code/modules/economy/mint.dm index 8e3f8665291..fe82ef951fe 100644 --- a/code/modules/economy/mint.dm +++ b/code/modules/economy/mint.dm @@ -123,7 +123,7 @@ if(href_list["choose"]) chosen = href_list["choose"] if(href_list["chooseAmt"]) - coinsToProduce = between(0, coinsToProduce + text2num(href_list["chooseAmt"]), 1000) + coinsToProduce = clamp(0, coinsToProduce + text2num(href_list["chooseAmt"]), 1000) if(href_list["makeCoins"]) var/temp_coins = coinsToProduce if (src.output) @@ -207,4 +207,4 @@ processing = 0; coinsToProduce = temp_coins src.updateUsrDialog() - return \ No newline at end of file + return diff --git a/code/modules/hydroponics/spreading/spreading_growth.dm b/code/modules/hydroponics/spreading/spreading_growth.dm index e2890f44f4a..4b32aeb4e8c 100644 --- a/code/modules/hydroponics/spreading/spreading_growth.dm +++ b/code/modules/hydroponics/spreading/spreading_growth.dm @@ -103,7 +103,7 @@ if(length(neighbors) && prob(spread_chance)) //spread to 1-3 adjacent turfs depending on yield trait. - var/max_spread = between(1, round(seed.get_trait(TRAIT_YIELD)*3/14), 3) + var/max_spread = clamp(1, round(seed.get_trait(TRAIT_YIELD)*3/14), 3) for(var/i in 1 to max_spread) if(prob(spread_chance)) diff --git a/code/modules/integrated_electronics/subtypes/manipulation.dm b/code/modules/integrated_electronics/subtypes/manipulation.dm index 0920ada64cb..0498b7e5aa5 100644 --- a/code/modules/integrated_electronics/subtypes/manipulation.dm +++ b/code/modules/integrated_electronics/subtypes/manipulation.dm @@ -180,7 +180,7 @@ if(attached_grenade && !attached_grenade.active) var/datum/integrated_io/detonation_time = inputs[1] if(isnum(detonation_time.data) && detonation_time.data > 0) - attached_grenade.det_time = between(1, detonation_time.data, 12) SECONDS + attached_grenade.det_time = clamp(1, detonation_time.data, 12) SECONDS attached_grenade.activate() var/atom/holder = loc log_and_message_admins("activated a grenade assembly. Last touches: Assembly: [holder.fingerprintslast] Circuit: [fingerprintslast] Grenade: [attached_grenade.fingerprintslast]") @@ -203,4 +203,4 @@ /obj/item/integrated_circuit/manipulation/grenade/frag pre_attached_grenade_type = /obj/item/grenade/explosive origin_tech = list(TECH_ENGINEERING = 3, TECH_DATA = 3, TECH_COMBAT = 10) - spawn_flags = null // Used for world initializing, see the #defines above. \ No newline at end of file + spawn_flags = null // Used for world initializing, see the #defines above. diff --git a/code/modules/integrated_electronics/subtypes/output.dm b/code/modules/integrated_electronics/subtypes/output.dm index e73c9cb5cf5..9cb6281aa6b 100644 --- a/code/modules/integrated_electronics/subtypes/output.dm +++ b/code/modules/integrated_electronics/subtypes/output.dm @@ -196,7 +196,7 @@ var/selected_sound = sounds[ID] if(!selected_sound) return - vol = between(0, vol, 100) + vol = clamp(0, vol, 100) playsound(src, selected_sound, vol, freq, -1) /obj/item/integrated_circuit/output/sound/beeper @@ -449,7 +449,7 @@ if(!isnum(holo_scale) || !isnum(holo_rotation) ) return FALSE // Invalid. - hologram.adjust_scale(between(-2, holo_scale, 2) ) + hologram.adjust_scale(clamp(-2, holo_scale, 2) ) hologram.adjust_rotation(holo_rotation) update_hologram_position() @@ -462,8 +462,8 @@ if(!isnum(holo_x) || !isnum(holo_y) ) return FALSE - holo_x = between(-7, holo_x, 7) - holo_y = between(-7, holo_y, 7) + holo_x = clamp(-7, holo_x, 7) + holo_y = clamp(-7, holo_y, 7) var/turf/T = get_turf(src) if(T) diff --git a/code/modules/mob/_modifiers/changeling.dm b/code/modules/mob/_modifiers/changeling.dm index 7e83c454617..2da68836695 100644 --- a/code/modules/mob/_modifiers/changeling.dm +++ b/code/modules/mob/_modifiers/changeling.dm @@ -40,7 +40,7 @@ else L = holder - L.mind.changeling.chem_charges = between(0, L.mind.changeling.chem_charges - chem_maintenance, L.mind.changeling.chem_storage) + L.mind.changeling.chem_charges = clamp(0, L.mind.changeling.chem_charges - chem_maintenance, L.mind.changeling.chem_storage) /datum/modifier/changeling/thermal_sight name = "Thermal Adaptation" diff --git a/code/modules/mob/_modifiers/traits_phobias.dm b/code/modules/mob/_modifiers/traits_phobias.dm index f63a906ef1d..55b957b6a6a 100644 --- a/code/modules/mob/_modifiers/traits_phobias.dm +++ b/code/modules/mob/_modifiers/traits_phobias.dm @@ -26,7 +26,7 @@ /datum/modifier/trait/phobia/proc/adjust_fear(var/amount) var/last_fear = current_fear - current_fear = between(0, current_fear + amount, max_fear) + current_fear = clamp(0, current_fear + amount, max_fear) // Handle messages. safepick() is used so that if no messages are defined, it just does nothing, verses runtiming. var/message = null @@ -689,4 +689,3 @@ "WetSkrell was a mistake." ) return pick(generic_responses) - diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index d0f7d9ab973..b8e95583f4f 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -508,7 +508,7 @@ emp_act catch_chance -= get_accuracy_penalty() // Same issues with shooting a gun, or swinging a weapon - catch_chance = between(1, catch_chance, 100) + catch_chance = clamp(1, catch_chance, 100) if(prob(catch_chance)) return TRUE diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 3a6ac91730e..14ded623f0a 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -747,7 +747,7 @@ //Use heat transfer as proportional to the gas density. However, we only care about the relative density vs standard 101 kPa/20 C air. Therefore we can use mole ratios var/relative_density = environment.total_moles / MOLES_CELLSTANDARD - bodytemperature += between(BODYTEMP_COOLING_MAX, temp_adj*relative_density, BODYTEMP_HEATING_MAX) + bodytemperature += clamp(BODYTEMP_COOLING_MAX, temp_adj*relative_density, BODYTEMP_HEATING_MAX) // +/- 50 degrees from 310.15K is the 'safe' zone, where no damage is dealt. if(bodytemperature >= species.heat_level_1) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index f4a52d42b19..12bf3203609 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -899,9 +899,9 @@ for(var/C in colors_to_blend) var/RGB = rgb2num(C) - R = between(0, R + RGB[1], 255) - G = between(0, G + RGB[2], 255) - B = between(0, B + RGB[3], 255) + R = clamp(0, R + RGB[1], 255) + G = clamp(0, G + RGB[2], 255) + B = clamp(0, B + RGB[3], 255) final_color = rgb(R,G,B) if(final_color) @@ -1067,7 +1067,7 @@ return !isSynthetic() /mob/living/proc/adjust_nutrition(amount) - nutrition = between(0, nutrition + amount, max_nutrition) + nutrition = clamp(0, nutrition + amount, max_nutrition) /mob/living/vv_get_header() . = ..() diff --git a/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/combat.dm b/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/combat.dm index b8539349eb1..5dc467023fa 100644 --- a/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/combat.dm +++ b/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/combat.dm @@ -8,7 +8,7 @@ return FALSE if(I_DISARM) - var/stun_power = between(0, power_charge + rand(0, 3), 10) + var/stun_power = clamp(0, power_charge + rand(0, 3), 10) if(ishuman(L)) var/mob/living/carbon/human/H = L diff --git a/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/consumption.dm b/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/consumption.dm index 6031213d8b2..f82c0c21ac4 100644 --- a/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/consumption.dm +++ b/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/consumption.dm @@ -40,7 +40,7 @@ else if(nutrition >= get_grow_nutrition() && amount_grown < 10) adjust_nutrition(-20) - amount_grown = between(0, amount_grown + 1, 10) + amount_grown = clamp(0, amount_grown + 1, 10) // Called if above proc happens while below a nutrition threshold. /mob/living/simple_mob/slime/xenobio/proc/handle_starvation() diff --git a/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/defense.dm b/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/defense.dm index 51266a6d883..43f5f42b710 100644 --- a/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/defense.dm +++ b/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/defense.dm @@ -45,7 +45,7 @@ // Shocked grilles don't hurt slimes, and in fact give them charge. /mob/living/simple_mob/slime/xenobio/electrocute_act(shock_damage, obj/source, siemens_coeff = 1.0, def_zone = null) - power_charge = between(0, power_charge + round(shock_damage / 10), 10) + power_charge = clamp(0, power_charge + round(shock_damage / 10), 10) to_chat(src, span("notice", "\The [source] shocks you, and it charges you.")) // Getting slimebatoned/xenotased. diff --git a/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/subtypes.dm b/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/subtypes.dm index 82cd6346aea..403092a6370 100644 --- a/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/subtypes.dm +++ b/code/modules/mob/living/simple_mob/subtypes/slime/xenobio/subtypes.dm @@ -166,7 +166,7 @@ /mob/living/simple_mob/slime/xenobio/yellow/handle_special() if(stat == CONSCIOUS) if(prob(25)) - power_charge = between(0, power_charge + 1, 10) + power_charge = clamp(0, power_charge + 1, 10) ..() /obj/item/projectile/beam/lightning/slime @@ -461,7 +461,7 @@ var/mob/living/carbon/human/H = L if(H.isSynthetic()) continue - H.nutrition = between(0, H.nutrition + rand(15, 25), 800) + H.nutrition = clamp(0, H.nutrition + rand(15, 25), 800) /mob/living/simple_mob/slime/xenobio/cerulean desc = "This slime is generally superior in a wide range of attributes, compared to the common slime. The jack of all trades, but master of none." @@ -609,7 +609,7 @@ ) /mob/living/simple_mob/slime/xenobio/gold/slimebatoned(mob/living/user, amount) - power_charge = between(0, power_charge + amount, 10) + power_charge = clamp(0, power_charge + amount, 10) /mob/living/simple_mob/slime/xenobio/gold/get_description_interaction() // So it doesn't say to use a baton on them. return list() @@ -787,4 +787,4 @@ /mob/living/simple_mob/slime/xenobio/rainbow/kendrick/Initialize() pacify() // So the physical mob also gets made harmless. - return ..() \ No newline at end of file + return ..() diff --git a/code/modules/modular_computers/NTNet/NTNet.dm b/code/modules/modular_computers/NTNet/NTNet.dm index 9dea977e560..1fc56f0d809 100644 --- a/code/modules/modular_computers/NTNet/NTNet.dm +++ b/code/modules/modular_computers/NTNet/NTNet.dm @@ -153,7 +153,7 @@ var/global/datum/ntnet/ntnet_global = new() if(!lognumber) return 0 // Trim the value if necessary - lognumber = between(MIN_NTNET_LOGS, lognumber, MAX_NTNET_LOGS) + lognumber = clamp(MIN_NTNET_LOGS, lognumber, MAX_NTNET_LOGS) setting_maxlogcount = lognumber add_log("Configuration Updated. Now keeping [setting_maxlogcount] logs in system memory.") @@ -185,4 +185,3 @@ var/global/datum/ntnet/ntnet_global = new() for(var/datum/ntnet_conversation/chan in chat_channels) if(chan.id == id) return chan - diff --git a/code/modules/modular_computers/computers/modular_computer/damage.dm b/code/modules/modular_computers/computers/modular_computer/damage.dm index deba8273e19..38eb72ade13 100644 --- a/code/modules/modular_computers/computers/modular_computer/damage.dm +++ b/code/modules/modular_computers/computers/modular_computer/damage.dm @@ -23,7 +23,7 @@ amount = round(amount) if(damage_casing) damage += amount - damage = between(0, damage, max_damage) + damage = clamp(0, damage, max_damage) if(component_probability) for(var/obj/item/computer_hardware/H in get_all_components()) diff --git a/code/modules/modular_computers/hardware/_hardware.dm b/code/modules/modular_computers/hardware/_hardware.dm index c979b1732d3..45e5c67d07e 100644 --- a/code/modules/modular_computers/hardware/_hardware.dm +++ b/code/modules/modular_computers/hardware/_hardware.dm @@ -84,5 +84,4 @@ // Damages the component. Contains necessary checks. Negative damage "heals" the component. /obj/item/computer_hardware/take_damage(var/amount) damage += round(amount) // We want nice rounded numbers here. - damage = between(0, damage, max_damage) // Clamp the value. - + damage = clamp(0, damage, max_damage) // Clamp the value. diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index d6025465306..42f9278a655 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -226,7 +226,7 @@ var/global/list/organ_cache = list() if(germ_level >= INFECTION_LEVEL_ONE) . = 1 //Organ qualifies for effect-specific processing //var/fever_temperature = (owner.species.heat_level_1 - owner.species.body_temperature - 5)* min(germ_level/INFECTION_LEVEL_TWO, 1) + owner.species.body_temperature - //owner.bodytemperature += between(0, (fever_temperature - T20C)/BODYTEMP_COLD_DIVISOR + 1, fever_temperature - owner.bodytemperature) + //owner.bodytemperature += clamp(0, (fever_temperature - T20C)/BODYTEMP_COLD_DIVISOR + 1, fever_temperature - owner.bodytemperature) var/fever_temperature = owner?.species.heat_discomfort_level * 1.10 //Heat discomfort level plus 10% if(owner?.bodytemperature < fever_temperature) owner?.bodytemperature += min(0.2,(fever_temperature - owner?.bodytemperature) / 10) //Will usually climb by 0.2, else 10% of the difference if less @@ -320,9 +320,9 @@ var/global/list/organ_cache = list() //Note: external organs have their own version of this proc /obj/item/organ/take_damage(amount, var/silent=0) if(src.robotic >= ORGAN_ROBOT) - src.damage = between(0, src.damage + (amount * 0.8), max_damage) + src.damage = clamp(0, src.damage + (amount * 0.8), max_damage) else - src.damage = between(0, src.damage + amount, max_damage) + src.damage = clamp(0, src.damage + amount, max_damage) //only show this if the organ is not robotic if(owner && parent_organ && amount > 0) diff --git a/code/modules/power/batteryrack.dm b/code/modules/power/batteryrack.dm index 97f97be9152..e39797e22d6 100644 --- a/code/modules/power/batteryrack.dm +++ b/code/modules/power/batteryrack.dm @@ -65,7 +65,7 @@ icon_update = 0 var/cellcount = 0 - var/charge_level = between(0, round(Percentage() / 12), 7) + var/charge_level = clamp(0, round(Percentage() / 12), 7) add_overlay("charge[charge_level]") @@ -87,7 +87,7 @@ newmaxcharge /= CELLRATE // Convert to Joules newmaxcharge *= SMESRATE // And to SMES charge units (which are for some reason different than CELLRATE) capacity = newmaxcharge - charge = between(0, charge, newmaxcharge) + charge = clamp(0, charge, newmaxcharge) // Sets input/output depending on our "mode" var. @@ -204,7 +204,7 @@ celldiff = (least.maxcharge / 100) * percentdiff else celldiff = (most.maxcharge / 100) * percentdiff - celldiff = between(0, celldiff, max_transfer_rate * CELLRATE) + celldiff = clamp(0, celldiff, max_transfer_rate * CELLRATE) // Ensure we don't transfer more energy than the most charged cell has, and that the least charged cell can input. celldiff = min(min(celldiff, most.charge), least.maxcharge - least.charge) least.give(most.use(celldiff)) @@ -286,7 +286,7 @@ update_io(0) return 1 else if( href_list["enable"] ) - update_io(between(1, text2num(href_list["enable"]), 3)) + update_io(clamp(1, text2num(href_list["enable"]), 3)) return 1 else if( href_list["equaliseon"] ) equalise = 1 @@ -309,4 +309,4 @@ update_icon() RefreshParts() update_maxcharge() - return 1 \ No newline at end of file + return 1 diff --git a/code/modules/power/port_gen.dm b/code/modules/power/port_gen.dm index 94e2fa32567..b2cfcdbd636 100644 --- a/code/modules/power/port_gen.dm +++ b/code/modules/power/port_gen.dm @@ -212,7 +212,7 @@ //or if it is already above upper_limit, limit the increase to 0. var/inc_limit = max(upper_limit - temperature, 0) var/dec_limit = min(temperature - lower_limit, 0) - temperature += between(dec_limit, rand(-7 + bias, 7 + bias), inc_limit) + temperature += clamp(dec_limit, rand(-7 + bias, 7 + bias), inc_limit) if (temperature > max_temperature) overheat() @@ -229,7 +229,7 @@ if(temperature > cooling_temperature) var/temp_loss = (temperature - cooling_temperature)/TEMPERATURE_DIVISOR - temp_loss = between(2, round(temp_loss, 1), TEMPERATURE_CHANGE_MAX) + temp_loss = clamp(2, round(temp_loss, 1), TEMPERATURE_CHANGE_MAX) temperature = max(temperature - temp_loss, cooling_temperature) updateDialog() diff --git a/code/modules/power/powernet.dm b/code/modules/power/powernet.dm index 734d2a8fd2b..d455ad62470 100644 --- a/code/modules/power/powernet.dm +++ b/code/modules/power/powernet.dm @@ -40,7 +40,7 @@ return max(avail - load, 0) /datum/powernet/proc/draw_power(var/amount) - var/draw = between(0, amount, avail - load) + var/draw = clamp(0, amount, avail - load) load += draw return draw @@ -122,7 +122,7 @@ // At this point, all other machines have finished using power. Anything left over may be used up to charge SMESs. if(inputting.len && smes_demand) - var/smes_input_percentage = between(0, (netexcess / smes_demand) * 100, 100) + var/smes_input_percentage = clamp(0, (netexcess / smes_demand) * 100, 100) for(var/obj/machinery/power/terminal/T in inputting) var/obj/machinery/power/smes/S = T.master if(istype(S)) @@ -152,11 +152,11 @@ var/smes_used = load - (avail - smes_avail) // SMESs are always last to provide power if(!smes_used || smes_used < 0 || !smes_avail) // SMES power isn't available or being used at all, SMES load is therefore 0% return 0 - return between(0, (smes_used / smes_avail) * 100, 100) // Otherwise return percentage load of SMESs. + return clamp(0, (smes_used / smes_avail) * 100, 100) // Otherwise return percentage load of SMESs. else if(!load) return 0 - return between(0, (load / avail) * 100, 100) + return clamp(0, (load / avail) * 100, 100) /datum/powernet/proc/get_electrocute_damage() switch(avail) diff --git a/code/modules/power/singularity/emitter.dm b/code/modules/power/singularity/emitter.dm index 695935bfeee..f76f1d5e418 100644 --- a/code/modules/power/singularity/emitter.dm +++ b/code/modules/power/singularity/emitter.dm @@ -256,7 +256,7 @@ adjust_integrity(-1000) // This kills the emitter. /obj/machinery/power/emitter/proc/adjust_integrity(amount) - integrity = between(0, integrity + amount, initial(integrity)) + integrity = clamp(0, integrity + amount, initial(integrity)) if(integrity == 0) if(powernet && avail(active_power_usage)) // If it's powered, it goes boom if killed. visible_message(src, "\The [src] explodes violently!", "You hear an explosion!") diff --git a/code/modules/power/singularity/field_generator.dm b/code/modules/power/singularity/field_generator.dm index 69ee2c16bd3..a1fbee7de41 100644 --- a/code/modules/power/singularity/field_generator.dm +++ b/code/modules/power/singularity/field_generator.dm @@ -48,7 +48,7 @@ field_generator power level display // Scale % power to % num_power_levels and truncate value var/level = round(num_power_levels * power / field_generator_max_power) // Clamp between 0 and num_power_levels for out of range power values - level = between(0, level, num_power_levels) + level = clamp(0, level, num_power_levels) if(level) add_overlay("+p[level]") diff --git a/code/modules/power/smes.dm b/code/modules/power/smes.dm index 741c516d9d6..a748f9ac819 100644 --- a/code/modules/power/smes.dm +++ b/code/modules/power/smes.dm @@ -126,7 +126,7 @@ GLOBAL_LIST_EMPTY(smeses) /obj/machinery/power/smes/proc/input_power(var/percentage, var/obj/machinery/power/terminal/term) var/to_input = target_load * (percentage/100) - to_input = between(0, to_input, target_load) + to_input = clamp(0, to_input, target_load) if(percentage == 100) inputting = 2 else if(percentage) @@ -193,7 +193,7 @@ GLOBAL_LIST_EMPTY(smeses) return var/total_restore = output_used * (percent_load / 100) // First calculate amount of power used from our output - total_restore = between(0, total_restore, output_used) // Now clamp the value between 0 and actual output, just for clarity. + total_restore = clamp(0, total_restore, output_used) // Now clamp the value between 0 and actual output, just for clarity. total_restore = output_used - total_restore // And, at last, subtract used power from outputted power, to get amount of power we will give back to the SMES. // now recharge this amount diff --git a/code/modules/power/smes_construction.dm b/code/modules/power/smes_construction.dm index a0b939044fb..afeffb2511a 100644 --- a/code/modules/power/smes_construction.dm +++ b/code/modules/power/smes_construction.dm @@ -154,7 +154,7 @@ capacity += C.ChargeCapacity input_level_max += C.IOCapacity output_level_max += C.IOCapacity - charge = between(0, charge, capacity) + charge = clamp(0, charge, capacity) return 1 return 0 @@ -383,12 +383,12 @@ // Parameters: 1 (new_input - New input value in Watts) // Description: Sets input setting on this SMES. Trims it if limits are exceeded. /obj/machinery/power/smes/buildable/proc/set_input(var/new_input = 0) - input_level = between(0, new_input, input_level_max) + input_level = clamp(0, new_input, input_level_max) update_icon() // Proc: set_output() // Parameters: 1 (new_output - New output value in Watts) // Description: Sets output setting on this SMES. Trims it if limits are exceeded. /obj/machinery/power/smes/buildable/proc/set_output(var/new_output = 0) - output_level = between(0, new_output, output_level_max) - update_icon() \ No newline at end of file + output_level = clamp(0, new_output, output_level_max) + update_icon() diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm index 28040c8f19f..6f00f006e04 100644 --- a/code/modules/power/supermatter/supermatter.dm +++ b/code/modules/power/supermatter/supermatter.dm @@ -218,8 +218,8 @@ var/explosion_power = min_explosion_power if(power > 0) // 0-100% where 0% is at DETONATION_EXPLODE_MIN_POWER or lower and 100% is at DETONATION_EXPLODE_MAX_POWER or higher - var/strength_percentage = between(0, (power - DETONATION_EXPLODE_MIN_POWER) / ((DETONATION_EXPLODE_MAX_POWER - DETONATION_EXPLODE_MIN_POWER) / 100), 100) - explosion_power = between(min_explosion_power, (((max_explosion_power - min_explosion_power) * (strength_percentage / 100)) + min_explosion_power), max_explosion_power) + var/strength_percentage = clamp(0, (power - DETONATION_EXPLODE_MIN_POWER) / ((DETONATION_EXPLODE_MAX_POWER - DETONATION_EXPLODE_MIN_POWER) / 100), 100) + explosion_power = clamp(min_explosion_power, (((max_explosion_power - min_explosion_power) * (strength_percentage / 100)) + min_explosion_power), max_explosion_power) explosion(TS, explosion_power/2, explosion_power, max_explosion_power, explosion_power * 4, 1) qdel(src) @@ -377,7 +377,7 @@ visible_message("[src]: Releasing additional [round((heat_capacity_new - heat_capacity)*removed.temperature)] W with exhaust gasses.") removed.add_thermal_energy(thermal_power) - removed.temperature = between(0, removed.temperature, 10000) + removed.temperature = clamp(0, removed.temperature, 10000) env.merge(removed) diff --git a/code/modules/projectiles/projectile/arc.dm b/code/modules/projectiles/projectile/arc.dm index 90df3bd98a7..89ebb864cf2 100644 --- a/code/modules/projectiles/projectile/arc.dm +++ b/code/modules/projectiles/projectile/arc.dm @@ -79,7 +79,7 @@ else // Handle visual projectile turning in flight. - var/arc_progress = between(0, pixels_flown / distance_to_fly, 1) + var/arc_progress = clamp(0, pixels_flown / distance_to_fly, 1) var/new_visual_degree = LERP(45, 135, arc_progress) if(fired_dir & EAST) diff --git a/code/modules/reagents/reagents/core.dm b/code/modules/reagents/reagents/core.dm index b2cc27a579e..ead37ba526f 100644 --- a/code/modules/reagents/reagents/core.dm +++ b/code/modules/reagents/reagents/core.dm @@ -163,7 +163,7 @@ qdel(hotspot) if (environment && environment.temperature > min_temperature) // Abstracted as steam or something - var/removed_heat = between(0, volume * WATER_LATENT_HEAT, -environment.get_thermal_energy_change(min_temperature)) + var/removed_heat = clamp(0, volume * WATER_LATENT_HEAT, -environment.get_thermal_energy_change(min_temperature)) environment.add_thermal_energy(-removed_heat) if (prob(5)) T.visible_message("The water sizzles as it lands on \the [T]!") diff --git a/code/modules/research/research.dm b/code/modules/research/research.dm index c9c7e29b3fe..3c5ac5a5df3 100644 --- a/code/modules/research/research.dm +++ b/code/modules/research/research.dm @@ -112,7 +112,7 @@ research holder datum. if(DesignHasReqs(PD)) AddDesign2Known(PD) for(var/datum/tech/T in known_tech) - T = between(0, T.level, 20) + T = clamp(0, T.level, 20) return //Refreshes the levels of a given tech. diff --git a/code/modules/research/server.dm b/code/modules/research/server.dm index ecdfc0b1500..97d4517f93b 100644 --- a/code/modules/research/server.dm +++ b/code/modules/research/server.dm @@ -48,7 +48,7 @@ if(0 to T0C) health = min(100, health + 1) if(T0C to (T20C + 20)) - health = between(0, health, 100) + health = clamp(0, health, 100) if((T20C + 20) to (T0C + 70)) health = max(0, health - 1) if(health <= 0) @@ -303,4 +303,4 @@ name = "Core R&D Server" id_with_upload_string = "1" id_with_download_string = "1" - server_id = 1 \ No newline at end of file + server_id = 1 diff --git a/code/modules/shieldgen/directional_shield.dm b/code/modules/shieldgen/directional_shield.dm index e4252103e22..72243c54e2d 100644 --- a/code/modules/shieldgen/directional_shield.dm +++ b/code/modules/shieldgen/directional_shield.dm @@ -140,7 +140,7 @@ S.relocate() /obj/item/shield_projector/proc/adjust_health(amount) - shield_health = between(0, shield_health + amount, max_shield_health) + shield_health = clamp(0, shield_health + amount, max_shield_health) if(amount < 0) if(shield_health <= 0) destroy_shields() diff --git a/code/modules/shieldgen/energy_field.dm b/code/modules/shieldgen/energy_field.dm index ba972065754..04941d5f464 100644 --- a/code/modules/shieldgen/energy_field.dm +++ b/code/modules/shieldgen/energy_field.dm @@ -90,7 +90,7 @@ /obj/effect/energy_field/proc/adjust_strength(amount, impact = 1) var/old_density = density - strength = between(0, strength + amount, max_strength) + strength = clamp(0, strength + amount, max_strength) //maptext = "[round(strength, 0.1)]/[max_strength]" @@ -139,7 +139,7 @@ // Small visual effect, makes the shield tiles brighten up by becoming more opaque for a moment, and spreads to nearby shields. /obj/effect/energy_field/proc/impact_effect(var/i, var/list/affected_shields = list()) - i = between(1, i, 10) + i = clamp(1, i, 10) alpha = 200 animate(src, alpha = initial(alpha), time = 1 SECOND) affected_shields |= src @@ -152,4 +152,3 @@ for(var/obj/effect/energy_field/F in T) if(!(F in affected_shields)) F.impact_effect(i, affected_shields) // Spread the effect to them. - diff --git a/code/modules/shieldgen/sheldwallgen.dm b/code/modules/shieldgen/sheldwallgen.dm index 18fd9836783..de6a64d3000 100644 --- a/code/modules/shieldgen/sheldwallgen.dm +++ b/code/modules/shieldgen/sheldwallgen.dm @@ -66,7 +66,7 @@ power = 0 return 0 - var/shieldload = between(500, max_stored_power - storedpower, power_draw) //what we try to draw + var/shieldload = clamp(500, max_stored_power - storedpower, power_draw) //what we try to draw shieldload = PN.draw_power(shieldload) //what we actually get storedpower += shieldload diff --git a/code/modules/shieldgen/shield_capacitor.dm b/code/modules/shieldgen/shield_capacitor.dm index 2026a6ba510..23bb4858fa7 100644 --- a/code/modules/shieldgen/shield_capacitor.dm +++ b/code/modules/shieldgen/shield_capacitor.dm @@ -105,7 +105,7 @@ PN = C.powernet if (PN) - var/power_draw = between(0, max_charge - stored_charge, charge_rate) //what we are trying to draw + var/power_draw = clamp(0, max_charge - stored_charge, charge_rate) //what we are trying to draw power_draw = PN.draw_power(power_draw) //what we actually get stored_charge += power_draw @@ -145,4 +145,4 @@ return src.set_dir(turn(src.dir, 270)) - return \ No newline at end of file + return diff --git a/code/modules/shuttles/shuttles_web.dm b/code/modules/shuttles/shuttles_web.dm index 59b875b865f..6bac6fbc021 100644 --- a/code/modules/shuttles/shuttles_web.dm +++ b/code/modules/shuttles/shuttles_web.dm @@ -348,7 +348,7 @@ "docking_status" = shuttle.shuttle_docking_controller? shuttle.shuttle_docking_controller.get_docking_status() : null, "docking_override" = shuttle.shuttle_docking_controller? shuttle.shuttle_docking_controller.override_enabled : null, "is_in_transit" = shuttle.has_arrive_time(), - "travel_progress" = between(0, percent_finished, 100), + "travel_progress" = clamp(0, percent_finished, 100), "time_left" = round( (total_time - elapsed_time) / 10), "can_cloak" = shuttle.can_cloak ? 1 : 0, "cloaked" = shuttle.cloaked ? 1 : 0, diff --git a/code/modules/vehicles/vehicle.dm b/code/modules/vehicles/vehicle.dm index 9bece57fbcd..f775f4aa752 100644 --- a/code/modules/vehicles/vehicle.dm +++ b/code/modules/vehicles/vehicle.dm @@ -137,7 +137,7 @@ healthcheck() /obj/vehicle/proc/adjust_health(amount) - health = between(0, health + amount, maxhealth) + health = clamp(0, health + amount, maxhealth) healthcheck() /obj/vehicle/ex_act(severity) diff --git a/code/modules/xenobio/items/extracts.dm b/code/modules/xenobio/items/extracts.dm index 7dc38c4dbb1..98b84b84c90 100644 --- a/code/modules/xenobio/items/extracts.dm +++ b/code/modules/xenobio/items/extracts.dm @@ -513,7 +513,7 @@ if(protection < 1) var/cold_factor = abs(protection - 1) - H.bodytemperature = between(50, (H.bodytemperature - ((H.bodytemperature - 50) * cold_factor) ), H.bodytemperature) + H.bodytemperature = clamp(50, (H.bodytemperature - ((H.bodytemperature - 50) * cold_factor) ), H.bodytemperature) if(protection < 0.7) to_chat(L, "A chilling wave of cold overwhelms you!") diff --git a/code/modules/xenobio/items/slimepotions.dm b/code/modules/xenobio/items/slimepotions.dm index 2a600fb8019..0b62c12830f 100644 --- a/code/modules/xenobio/items/slimepotions.dm +++ b/code/modules/xenobio/items/slimepotions.dm @@ -33,7 +33,7 @@ return ..() to_chat(user, "You feed the slime the stabilizer. It is now less likely to mutate.") - M.mutation_chance = between(0, M.mutation_chance - 15, 100) + M.mutation_chance = clamp(0, M.mutation_chance - 15, 100) playsound(src, 'sound/effects/bubbles.ogg', 50, 1) qdel(src) @@ -57,7 +57,7 @@ return ..() to_chat(user, "You feed the slime the mutator. It is now more likely to mutate.") - M.mutation_chance = between(0, M.mutation_chance + 12, 100) + M.mutation_chance = clamp(0, M.mutation_chance + 12, 100) playsound(src, 'sound/effects/bubbles.ogg', 50, 1) qdel(src) diff --git a/code/modules/xgm/xgm_gas_mixture.dm b/code/modules/xgm/xgm_gas_mixture.dm index fd52efca22c..27a9758e8e5 100644 --- a/code/modules/xgm/xgm_gas_mixture.dm +++ b/code/modules/xgm/xgm_gas_mixture.dm @@ -230,7 +230,7 @@ /datum/gas_mixture/proc/remove_ratio(ratio, out_group_multiplier = 1) if(ratio <= 0) return null - out_group_multiplier = between(1, out_group_multiplier, group_multiplier) + out_group_multiplier = clamp(1, out_group_multiplier, group_multiplier) ratio = min(ratio, 1)