between() -> clamp() & swaps args 1 and 2 in uses

This commit is contained in:
Spookerton
2024-02-05 15:47:07 +00:00
parent dfac4a77fe
commit ebbf0e33fb
68 changed files with 137 additions and 146 deletions
+4 -4
View File
@@ -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
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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))