Skip to content

Commit 7c62a0d

Browse files
Merge pull request #5278 from out-of-phaze/codequality/make-blood-make-sense
Fix issues with blood volume calculations
2 parents 5019b16 + 846b15c commit 7c62a0d

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

code/modules/mob/living/human/human_blood.dm

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@
185185

186186
//Percentage of maximum blood volume, affected by the condition of circulation organs
187187
/mob/living/human/proc/get_blood_circulation()
188-
189-
190188
var/obj/item/organ/internal/heart/heart = get_organ(BP_HEART, /obj/item/organ/internal/heart)
191189
if(!heart)
192190
return 0.25 * get_blood_volume()
@@ -210,8 +208,7 @@
210208
if(PULSE_2FAST, PULSE_THREADY)
211209
pulse_mod *= 1.25
212210
blood_volume *= pulse_mod
213-
if(current_posture.prone)
214-
blood_volume *= 1.25
211+
blood_volume *= current_posture.blood_volume_multiplier
215212

216213
var/min_efficiency = recent_pump ? 0.5 : 0.3
217214
blood_volume *= max(min_efficiency, (1-(heart.get_organ_damage() / heart.max_damage)))
@@ -236,7 +233,8 @@
236233
else
237234
blood_volume = 100
238235

239-
var/blood_volume_mod = max(0, 1 - getOxyLossPercent()/(species.total_health/2))
236+
// blood_volume_mod is 1 with no oxyloss, 0 at half species health (50%), and cannot go below 0
237+
var/blood_volume_mod = max(0, (1 - getOxyLossFraction()*2))
240238
var/oxygenated_mult = 0
241239
switch(GET_CHEMICAL_EFFECT(src, CE_OXYGENATED))
242240
if(1)
@@ -245,6 +243,6 @@
245243
oxygenated_mult = 0.7
246244
if(3)
247245
oxygenated_mult = 0.9
248-
blood_volume_mod = blood_volume_mod + oxygenated_mult - (blood_volume_mod * oxygenated_mult)
249-
blood_volume = blood_volume * blood_volume_mod
250-
return min(blood_volume, 100)
246+
blood_volume_mod += oxygenated_mult * (1 - blood_volume_mod) // give us back a fraction of our missing oxygenation
247+
blood_volume *= blood_volume_mod
248+
return clamp(blood_volume, 0, 100)

code/modules/mob/living/human/human_damage.dm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@
130130
..()
131131

132132
/mob/living/human/proc/getOxyLossPercent()
133-
return (get_damage(OXY) / species.total_health) * 100
133+
return getOxyLossFraction() * 100
134+
135+
/mob/living/human/proc/getOxyLossFraction()
136+
return (get_damage(OXY) / species.total_health)
134137

135138
/mob/living/human/getOxyLoss()
136139
if(need_breathe())

code/modules/posture/_posture.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
var/selectable_type
1515
/// String to use in Change Posture.
1616
var/posture_change_message
17+
/// Postural multiplier to effective blood circulation volume, a generalization of the old feature of 'laying down increases your effective blood volume'.
18+
var/blood_volume_multiplier = 1
1719

1820
/decl/posture/proc/can_be_selected_by(mob/mob)
1921
return is_user_selectable

code/modules/posture/posture_subtypes.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
prone = TRUE
1010
posture_change_message = "lying down"
1111
selectable_type = /decl/posture/lying/deliberate
12+
blood_volume_multiplier = 1.25
1213

1314
/decl/posture/lying/deliberate
1415
name = "resting"
@@ -21,3 +22,4 @@
2122
is_user_selectable = TRUE
2223
deliberate = TRUE
2324
prone = TRUE
25+
blood_volume_multiplier = 1.1 // sitting is a little less intense than standing

0 commit comments

Comments
 (0)