mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-08-24 13:46:53 +01:00
between() -> clamp() & swaps args 1 and 2 in uses
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user