diff --git a/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm b/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm
index 7709bb56580..d95326b2ab2 100644
--- a/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/dp_vent_pump.dm
@@ -232,23 +232,23 @@
pump_direction = 1
if(signal.data["set_input_pressure"])
- input_pressure_min = between(
- 0,
+ input_pressure_min = clamp(
text2num(signal.data["set_input_pressure"]),
+ 0,
ONE_ATMOSPHERE*50
)
if(signal.data["set_output_pressure"])
- output_pressure_max = between(
- 0,
+ output_pressure_max = clamp(
text2num(signal.data["set_output_pressure"]),
+ 0,
ONE_ATMOSPHERE*50
)
if(signal.data["set_external_pressure"])
- external_pressure_bound = between(
- 0,
+ external_pressure_bound = clamp(
text2num(signal.data["set_external_pressure"]),
+ 0,
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..76d98a8416f 100644
--- a/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/passive_gate.dm
@@ -181,9 +181,9 @@
unlocked = !unlocked
if("set_target_pressure" in signal.data)
- target_pressure = between(
- 0,
+ target_pressure = clamp(
text2num(signal.data["set_target_pressure"]),
+ 0,
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(new_pressure, 0, 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(new_flow_rate, 0, 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..13c0e4b6ff4 100644
--- a/code/ATMOSPHERICS/components/binary_devices/pump.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/pump.dm
@@ -182,9 +182,9 @@ 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(
- 0,
+ target_pressure = clamp(
text2num(signal.data["set_output_pressure"]),
+ 0,
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(new_pressure, 0, 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..be5f1a3caea 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(new_flow_rate, 0, 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(new_con, 0, 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..44b132cfa2c 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(text2num(params["value"]), 0, 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..6d68d18f5d5 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(number, 0, 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..3a58f12c698 100644
--- a/code/ATMOSPHERICS/components/unary/vent_pump.dm
+++ b/code/ATMOSPHERICS/components/unary/vent_pump.dm
@@ -165,7 +165,7 @@
soundloop.stop()
return 0
if(!use_power)
- soundloop.stop()
+ soundloop.stop()
return 0
if(welded)
soundloop.stop()
@@ -323,9 +323,9 @@
if (signal.data["set_internal_pressure"] == "default")
internal_pressure_bound = internal_pressure_bound_default
else
- internal_pressure_bound = between(
- 0,
+ internal_pressure_bound = clamp(
text2num(signal.data["set_internal_pressure"]),
+ 0,
ONE_ATMOSPHERE*50
)
@@ -333,25 +333,25 @@
if (signal.data["set_external_pressure"] == "default")
external_pressure_bound = external_pressure_bound_default
else
- external_pressure_bound = between(
- 0,
+ external_pressure_bound = clamp(
text2num(signal.data["set_external_pressure"]),
+ 0,
ONE_ATMOSPHERE*50
)
if(signal.data["adjust_internal_pressure"] != null)
- internal_pressure_bound = between(
- 0,
+ internal_pressure_bound = clamp(
internal_pressure_bound + text2num(signal.data["adjust_internal_pressure"]),
+ 0,
ONE_ATMOSPHERE*50
)
if(signal.data["adjust_external_pressure"] != null)
- external_pressure_bound = between(
- 0,
+ external_pressure_bound = clamp(
external_pressure_bound + text2num(signal.data["adjust_external_pressure"]),
+ 0,
ONE_ATMOSPHERE*50
)
diff --git a/code/_helpers/unsorted.dm b/code/_helpers/unsorted.dm
index 25c68a9a277..3c0aa803e18 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(X, 1, world.maxx), clamp(Y, 1, 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..e28a964ab9e 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(danger + amount, 0, 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(staleness + amount, -20, 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..796794928a1 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(dist_travelled / total_distance, 0, 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..bf1ed41dcc3 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(temp_apc.cell.maxcharge / 2 + 500, 0, 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..9ace672997b 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(round(instability + amount, TECHNOMANCER_INSTABILITY_PRECISION), 0, 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(round(instability, TECHNOMANCER_INSTABILITY_PRECISION), 0, 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..503bee3e085 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(calculate_spell_power(100) - 100, 0, 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(calculate_spell_power(100) - 100, 0, 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..c576e5a2ef1 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(removed.temperature, 0, 10000)
env.merge(removed)
diff --git a/code/game/machinery/atmo_control.dm b/code/game/machinery/atmo_control.dm
index fafd8e34417..bd52049ccf2 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(new_pressure, 0, 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(new_flow, 0, 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(new_pressure, 0, 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(new_flow, 0, 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..3d50453782b 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(clone_sickness_length, 0.2, 1) // 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..00da6f73f78 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 + repairing * DOOR_REPAIR_AMOUNT, health, maxhealth)
update_icon()
repairing = 0
return
diff --git a/code/game/machinery/telecomms/telecomms.dm b/code/game/machinery/telecomms/telecomms.dm
index 78d42a3df4e..8a5227c7b15 100644
--- a/code/game/machinery/telecomms/telecomms.dm
+++ b/code/game/machinery/telecomms/telecomms.dm
@@ -54,7 +54,7 @@
var/obj/item/stack/nanopaste/T = P
if (integrity < 100)
if (T.use(1))
- integrity = between(0, integrity + rand(10, 20), 100)
+ integrity = clamp(integrity + rand(10, 20), 0, 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.")
@@ -272,7 +272,7 @@
if ((T0C + 200) to INFINITY)
damage_chance = 100
if (damage_chance && prob(damage_chance))
- integrity = between(0, integrity - 1, 100)
+ integrity = clamp(integrity - 1, 0, 100)
if (delay > 0)
delay--
else if (on)
diff --git a/code/game/objects/items/devices/defib.dm b/code/game/objects/items/devices/defib.dm
index 24b06080233..ffe52aaefbd 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(damage_calc, H.getBrainLoss(), 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..fee8fa142ad 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(round(power_source.percent(), 25), 0, 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..02f47e96312 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(number, 0, 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(material.conductivity / 10, 0, 10)
- var/slowdownModified = between(0, round(material.weight / 10, 0.1), 6)
+ var/slowdownModified = clamp(round(material.weight / 10, 0.1), 0, 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 26d44c7e30e..262e7bd7f7d 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(safety + eye_safety_modifier, -1, 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..65077d91650 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(rider.getMaxHealth() * 0.4, 20, 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(L.getMaxHealth() * 0.4, 10, 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(Mech.maxhealth * 0.4 * harm, 50, 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(L.getMaxHealth() * 0.4, 20, 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 7cdea0e42c5..5924238aa45 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(health + amount, 0, 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..3416c173b69 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(Proj.damage / 60, 0, 0.5)
if(prob(max((damage-10)/25, 0))*100)
passthrough = 1
else
- Proj.damage *= between(0, Proj.damage/60, 1)
+ Proj.damage *= clamp(Proj.damage / 60, 0, 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((damage - Proj.damage) * (Proj.damage_type == BRUTE ? 0.4 : 1), 0, 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..4d715ea2bca 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(temperature - M.bodytemperature, BODYTEMP_COOLING_MAX, 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..af8e1ceef95 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(discipline + amount, 0, 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..adb97f157f3 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(integrity + amount, 0, 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..84f10451140 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(blob_points + points, 0, 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..60bb61b8c23 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(round(class), 1, 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..5ffa17839e7 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(coinsToProduce + text2num(href_list["chooseAmt"]), 0, 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..2c8259a36fe 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(round(seed.get_trait(TRAIT_YIELD) * 3 / 14), 1, 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..f780219245d 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(detonation_time.data, 1, 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..816388cf7e5 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(vol, 0, 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(holo_scale, -2, 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(holo_x, -7, 7)
+ holo_y = clamp(holo_y, -7, 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..99f7bb45227 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(L.mind.changeling.chem_charges - chem_maintenance, 0, 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..a127f811445 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(current_fear + amount, 0, 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..14cd00aa150 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(catch_chance, 1, 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..77f3de8e1ed 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(temp_adj * relative_density, BODYTEMP_COOLING_MAX, 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..c8e6aa9b88e 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(R + RGB[1], 0, 255)
+ G = clamp(G + RGB[2], 0, 255)
+ B = clamp(B + RGB[3], 0, 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(nutrition + amount, 0, 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..8c63a20f6a7 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(power_charge + rand(0, 3), 0, 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..d1ea8d2f86d 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(amount_grown + 1, 0, 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..fe3d557970c 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(power_charge + round(shock_damage / 10), 0, 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..4196b6fcc08 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(power_charge + 1, 0, 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(H.nutrition + rand(15, 25), 0, 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(power_charge + amount, 0, 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..1c26c7b36b4 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(lognumber, MIN_NTNET_LOGS, 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..b2ef2773aac 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(damage, 0, max_damage)
if(component_probability)
for(var/obj/item/computer_hardware/H in get_all_components())
@@ -52,4 +52,4 @@
if(HALLOSS)
take_damage(Proj.damage, Proj.damage / 3, 0)
if(BURN)
- take_damage(Proj.damage, Proj.damage / 1.5)
\ No newline at end of file
+ take_damage(Proj.damage, Proj.damage / 1.5)
diff --git a/code/modules/modular_computers/hardware/_hardware.dm b/code/modules/modular_computers/hardware/_hardware.dm
index c979b1732d3..ddc8781941f 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(damage, 0, max_damage) // Clamp the value.
diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm
index d6025465306..df7bb61155a 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((fever_temperature - T20C)/BODYTEMP_COLD_DIVISOR + 1, 0, 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
@@ -319,10 +319,10 @@ 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)
+ if(robotic >= ORGAN_ROBOT)
+ damage = clamp(damage + (amount * 0.8), 0, max_damage)
else
- src.damage = between(0, src.damage + amount, max_damage)
+ damage = clamp(damage + amount, 0, 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..b5956526c53 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(round(Percentage() / 12), 0, 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(charge, 0, 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(celldiff, 0, 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(text2num(href_list["enable"]), 1, 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..961e4e63537 100644
--- a/code/modules/power/port_gen.dm
+++ b/code/modules/power/port_gen.dm
@@ -125,7 +125,7 @@
default_apply_parts()
if(anchored)
connect_to_network()
-
+
/obj/machinery/power/port_gen/pacman/Destroy()
DropFuel()
return ..()
@@ -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(rand(-7 + bias, 7 + bias), dec_limit, 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(round(temp_loss, 1), 2, TEMPERATURE_CHANGE_MAX)
temperature = max(temperature - temp_loss, cooling_temperature)
updateDialog()
@@ -312,7 +312,7 @@
if(!ui)
ui = new(user, src, "PortableGenerator", name)
ui.open()
-
+
/obj/machinery/power/port_gen/pacman/tgui_data(mob/user)
var/list/data = list()
@@ -324,7 +324,7 @@
data["is_ai"] = TRUE
else
data["is_ai"] = FALSE
-
+
data["sheet_name"] = capitalize(sheet_name)
data["fuel_stored"] = round((sheets * 1000) + (sheet_left * 1000))
data["fuel_capacity"] = round(max_sheets * 1000, 0.1)
diff --git a/code/modules/power/powernet.dm b/code/modules/power/powernet.dm
index 734d2a8fd2b..3d3970c42ed 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(amount, 0, 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((netexcess / smes_demand) * 100, 0, 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((smes_used / smes_avail) * 100, 0, 100) // Otherwise return percentage load of SMESs.
else
if(!load)
return 0
- return between(0, (load / avail) * 100, 100)
+ return clamp((load / avail) * 100, 0, 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..a7f662c8950 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(integrity + amount, 0, 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!")
@@ -288,4 +288,4 @@
return burst_delay
/obj/machinery/power/emitter/proc/get_emitter_beam()
- return new /obj/item/projectile/beam/emitter(get_turf(src))
\ No newline at end of file
+ return new /obj/item/projectile/beam/emitter(get_turf(src))
diff --git a/code/modules/power/singularity/field_generator.dm b/code/modules/power/singularity/field_generator.dm
index 69ee2c16bd3..2852711394b 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(level, 0, 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..4d5e62524d7 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(to_input, 0, 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(total_restore, 0, 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
@@ -482,4 +482,4 @@ GLOBAL_LIST_EMPTY(smeses)
if(25 to 49)
. += "It's casing is quite seriously damaged."
if(0 to 24)
- . += "It's casing has some minor damage."
\ No newline at end of file
+ . += "It's casing has some minor damage."
diff --git a/code/modules/power/smes_construction.dm b/code/modules/power/smes_construction.dm
index a0b939044fb..92c286cda0d 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(charge, 0, 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(new_input, 0, 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(new_output, 0, output_level_max)
+ update_icon()
diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm
index 28040c8f19f..5ffed06c322 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((power - DETONATION_EXPLODE_MIN_POWER) / ((DETONATION_EXPLODE_MAX_POWER - DETONATION_EXPLODE_MIN_POWER) / 100), 0, 100)
+ explosion_power = clamp((((max_explosion_power - min_explosion_power) * (strength_percentage / 100)) + min_explosion_power), 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(removed.temperature, 0, 10000)
env.merge(removed)
diff --git a/code/modules/projectiles/projectile/arc.dm b/code/modules/projectiles/projectile/arc.dm
index 90df3bd98a7..421b9ec8b1c 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(pixels_flown / distance_to_fly, 0, 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..848404a6493 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(volume * WATER_LATENT_HEAT, 0, -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..7e2874eb47e 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(T.level, 0, 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..6d059097939 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(health, 0, 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..05e4a9f0e16 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(shield_health + amount, 0, 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..d73d0491c7a 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(strength + amount, 0, 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..993f89940af 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(max_stored_power - storedpower, 500, 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..1386fdc4bed 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(max_charge - stored_charge, 0, 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..f1471e57c65 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(percent_finished, 0, 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..13bfc7d4616 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(health + amount, 0, 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..167c16abad9 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((H.bodytemperature - ((H.bodytemperature - 50) * cold_factor)), 50, 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..a8023853c20 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(M.mutation_chance - 15, 0, 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(M.mutation_chance + 12, 0, 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..c1a8eb9809d 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(out_group_multiplier, 1, group_multiplier)
ratio = min(ratio, 1)