Skip to content

Commit

Permalink
Blood refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
davipatury committed Jul 30, 2016
1 parent 3b73626 commit adcbeb9
Show file tree
Hide file tree
Showing 12 changed files with 111 additions and 124 deletions.
7 changes: 7 additions & 0 deletions code/__DEFINES/genetics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@
#define NUTRITION_LEVEL_HUNGRY 250
#define NUTRITION_LEVEL_STARVING 150

//Blood levels
#define BLOOD_VOLUME_NORMAL 560
#define BLOOD_VOLUME_SAFE 501
#define BLOOD_VOLUME_OKAY 336
#define BLOOD_VOLUME_BAD 224
#define BLOOD_VOLUME_SURVIVE 122

//Used for calculations for negative effects of having genetics powers
#define DEFAULT_GENE_STABILITY 100
#define GENE_INSTABILITY_MINOR 5
Expand Down
5 changes: 3 additions & 2 deletions code/game/machinery/Sleeper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,12 @@
// I'm not sure WHY you'd want to put a simple_animal in a sleeper, but precedent is precedent
// Runtime is aptly named, isn't she?
if (ishuman(occupant) && occupant.vessel && !(occupant.species && occupant.species.flags & NO_BLOOD))
var/blood_type = occupant.get_blood_name()
occupantData["pulse"] = occupant.get_pulse(GETPULSE_TOOL)
occupantData["hasBlood"] = 1
occupantData["bloodLevel"] = round(occupant.vessel.get_reagent_amount("blood"))
occupantData["bloodLevel"] = round(occupant.vessel.get_reagent_amount(blood_type))
occupantData["bloodMax"] = occupant.max_blood
occupantData["bloodPercent"] = round(100*(occupant.vessel.get_reagent_amount("blood")/occupant.max_blood), 0.01)
occupantData["bloodPercent"] = round(100*(occupant.vessel.get_reagent_amount(blood_type)/occupant.max_blood), 0.01)

data["occupant"] = occupantData
data["maxchem"] = connected.max_chem
Expand Down
13 changes: 7 additions & 6 deletions code/game/machinery/adv_med.dm
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,13 @@
var/bloodData[0]
bloodData["hasBlood"] = 0
if(ishuman(H) && H.vessel && !(H.species && H.species.flags & NO_BLOOD))
var/blood_volume = round(H.vessel.get_reagent_amount("blood"))
var/blood_type = H.get_blood_name()
var/blood_volume = round(H.vessel.get_reagent_amount(blood_type))
bloodData["hasBlood"] = 1
bloodData["volume"] = blood_volume
bloodData["percent"] = round(((blood_volume / 560)*100))
bloodData["percent"] = round(((blood_volume / BLOOD_VOLUME_NORMAL)*100))
bloodData["pulse"] = H.get_pulse(GETPULSE_TOOL)
bloodData["bloodLevel"] = round(H.vessel.get_reagent_amount("blood"))
bloodData["bloodLevel"] = blood_volume
bloodData["bloodMax"] = H.max_blood
occupantData["blood"] = bloodData

Expand Down Expand Up @@ -530,9 +531,9 @@
dat += "Large growth detected in frontal lobe, possibly cancerous. Surgical removal is recommended.<br>"

if(occupant.vessel)
var/blood_volume = round(occupant.vessel.get_reagent_amount("blood"))
var/blood_percent = blood_volume / 560
blood_percent *= 100
var/blood_type = occupant.get_blood_name()
var/blood_volume = round(occupant.vessel.get_reagent_amount(blood_type))
var/blood_percent = blood_volume / BLOOD_VOLUME_NORMAL

extra_font = (blood_volume > 448 ? "<font color='blue'>" : "<font color='red'>")
dat += "[extra_font]\tBlood Level %: [blood_percent] ([blood_volume] units)</font><br>"
Expand Down
5 changes: 3 additions & 2 deletions code/game/machinery/computer/Operating.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@
occupantData["btFaren"] = ((occupant.bodytemperature - T0C) * (9.0/5.0))+ 32

if (ishuman(occupant) && occupant.vessel && !(occupant.species && occupant.species.flags & NO_BLOOD))
var/blood_type = occupant.get_blood_name()
occupantData["pulse"] = occupant.get_pulse(GETPULSE_TOOL)
occupantData["hasBlood"] = 1
occupantData["bloodLevel"] = round(occupant.vessel.get_reagent_amount("blood"))
occupantData["bloodLevel"] = round(occupant.vessel.get_reagent_amount(blood_type))
occupantData["bloodMax"] = occupant.max_blood
occupantData["bloodPercent"] = round(100*(occupant.vessel.get_reagent_amount("blood")/occupant.max_blood), 0.01) //copy pasta ends here
occupantData["bloodPercent"] = round(100*(occupant.vessel.get_reagent_amount(blood_type)/occupant.max_blood), 0.01) //copy pasta ends here

occupantData["bloodType"]=occupant.b_type
if(occupant.surgeries.len)
Expand Down
14 changes: 9 additions & 5 deletions code/game/objects/items/devices/scanners.dm
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,19 @@ REAGENT SCANNER
user.show_message(text("\red Internal bleeding detected. Advanced scanner required for location."), 1)
break
if(H.vessel)
var/blood_volume = round(M:vessel.get_reagent_amount("blood"))
var/blood_percent = blood_volume / 560
var/blood_type = H.get_blood_name()
var/blood_volume = round(H.vessel.get_reagent_amount(blood_type))
var/blood_percent = blood_volume / BLOOD_VOLUME_NORMAL
blood_percent *= 100
if(blood_volume <= 500)
user.show_message("\red <b>Warning: Blood Level LOW: [blood_percent]% [blood_volume]cl")
user.show_message("<span class='warning'>Warning: Blood Level LOW: [blood_percent]% [blood_volume]cl</span>")
else if(blood_volume <= 336)
user.show_message("\red <b>Warning: Blood Level CRITICAL: [blood_percent]% [blood_volume]cl")
user.show_message("<span class='warning'>Warning: Blood Level CRITICAL: [blood_percent]% [blood_volume]cl</span>")
else
user.show_message("\blue Blood Level Normal: [blood_percent]% [blood_volume]cl")
user.show_message("<span class='notice'>Blood Level Normal: [blood_percent]% [blood_volume]cl</span>")
if(H.species.exotic_blood)
user.show_message("<span class='warning'>Subject possesses exotic blood.</span>")
user.show_message("<span class='warning'>Exotic blood type: [blood_type].</span>")
if(H.heart_attack && H.stat != DEAD)
user.show_message("<span class='userdanger'>Subject suffering from heart attack: Apply defibrillator immediately.</span>")
user.show_message("\blue Subject's pulse: <font color='[H.pulse == PULSE_THREADY || H.pulse == PULSE_NONE ? "red" : "blue"]'>[H.get_pulse(GETPULSE_TOOL)] bpm.</font>")
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/living/carbon/human/human_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ This function restores the subjects blood to max.
*/
/mob/living/carbon/human/proc/restore_blood()
if(!(species.flags & NO_BLOOD))
var/blood_volume = vessel.get_reagent_amount("blood")
vessel.add_reagent("blood", 560.0 - blood_volume)
var/blood_type = get_blood_name()
var/blood_volume = vessel.get_reagent_amount(blood_type)
vessel.add_reagent(blood_type, BLOOD_VOLUME_NORMAL - blood_volume)

/*
This function restores all organs.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var/global/default_martial_art = new/datum/martial_art
var/mob/remoteview_target = null
var/meatleft = 3 //For chef item
var/decaylevel = 0 // For rotting bodies
var/max_blood = 560 // For stuff in the vessel
var/max_blood = BLOOD_VOLUME_NORMAL // For stuff in the vessel
var/slime_color = "blue" //For slime people this defines their color, it's blue by default to pay tribute to the old icons

var/check_mutations=0 // Check mutations on next life tick
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/living/carbon/human/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,8 @@

var/temp = PULSE_NORM

if(round(vessel.get_reagent_amount("blood")) <= BLOOD_VOLUME_BAD) //how much blood do we have
var/blood_type = get_blood_name()
if(round(vessel.get_reagent_amount(blood_type)) <= BLOOD_VOLUME_BAD) //how much blood do we have
temp = PULSE_THREADY //not enough :(

if(status_flags & FAKEDEATH)
Expand Down
42 changes: 23 additions & 19 deletions code/modules/reagents/newchem/medicine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

#define REM REAGENTS_EFFECT_MULTIPLIER

datum/reagent/silver_sulfadiazine
/datum/reagent/silver_sulfadiazine
name = "Silver Sulfadiazine"
id = "silver_sulfadiazine"
description = "This antibacterial compound is used to treat burn victims."
reagent_state = LIQUID
color = "#F0C814"
metabolization_rate = 3

datum/reagent/silver_sulfadiazine/reaction_mob(var/mob/living/M as mob, var/method=TOUCH, var/volume, var/show_message = 1)
/datum/reagent/silver_sulfadiazine/reaction_mob(var/mob/living/M as mob, var/method=TOUCH, var/volume, var/show_message = 1)
if(iscarbon(M))
if(method == TOUCH)
M.adjustFireLoss(-volume)
Expand All @@ -25,21 +25,21 @@ datum/reagent/silver_sulfadiazine/reaction_mob(var/mob/living/M as mob, var/meth
..()
return

datum/reagent/silver_sulfadiazine/on_mob_life(var/mob/living/M as mob)
/datum/reagent/silver_sulfadiazine/on_mob_life(var/mob/living/M as mob)
if(!M) M = holder.my_atom
M.adjustFireLoss(-2*REM)
..()
return

datum/reagent/styptic_powder
/datum/reagent/styptic_powder
name = "Styptic Powder"
id = "styptic_powder"
description = "Styptic (aluminium sulfate) powder helps control bleeding and heal physical wounds."
reagent_state = LIQUID
color = "#C8A5DC"
metabolization_rate = 3

datum/reagent/styptic_powder/reaction_mob(var/mob/living/M as mob, var/method=TOUCH, var/volume, var/show_message = 1)
/datum/reagent/styptic_powder/reaction_mob(var/mob/living/M as mob, var/method=TOUCH, var/volume, var/show_message = 1)
if(iscarbon(M))
if(method == TOUCH)
M.adjustBruteLoss(-volume)
Expand All @@ -53,13 +53,13 @@ datum/reagent/styptic_powder/reaction_mob(var/mob/living/M as mob, var/method=TO
..()
return

datum/reagent/styptic_powder/on_mob_life(var/mob/living/M as mob)
/datum/reagent/styptic_powder/on_mob_life(var/mob/living/M as mob)
if(!M) M = holder.my_atom
M.adjustBruteLoss(-2*REM)
..()
return

datum/reagent/salglu_solution
/datum/reagent/salglu_solution
name = "Saline-Glucose Solution"
id = "salglu_solution"
description = "This saline and glucose solution can help stabilize critically injured patients and cleanse wounds."
Expand All @@ -68,22 +68,26 @@ datum/reagent/salglu_solution
penetrates_skin = 1
metabolization_rate = 0.15

datum/reagent/salglu_solution/on_mob_life(var/mob/living/M as mob)
if(!M) M = holder.my_atom
/datum/reagent/salglu_solution/on_mob_life(mob/living/M)
if(!M)
M = holder.my_atom
if(prob(33))
M.adjustBruteLoss(-2*REM)
M.adjustFireLoss(-2*REM)
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(!H.species.exotic_blood && !(H.species.flags & NO_BLOOD) && prob(33))
H.vessel.add_reagent("blood", 1)
..()
return

datum/reagent/synthflesh
/datum/reagent/synthflesh
name = "Synthflesh"
id = "synthflesh"
description = "A resorbable microfibrillar collagen and protein mixture that can rapidly heal injuries when applied topically."
reagent_state = LIQUID
color = "#FFEBEB"

datum/reagent/synthflesh/reaction_mob(var/mob/living/M, var/method=TOUCH, var/volume,var/show_message = 1)
/datum/reagent/synthflesh/reaction_mob(var/mob/living/M, var/method=TOUCH, var/volume,var/show_message = 1)
if(!M) M = holder.my_atom
if(iscarbon(M))
if(method == TOUCH)
Expand All @@ -94,21 +98,21 @@ datum/reagent/synthflesh/reaction_mob(var/mob/living/M, var/method=TOUCH, var/vo
..()
return

datum/reagent/synthflesh/reaction_turf(var/turf/T, var/volume) //let's make a mess!
/datum/reagent/synthflesh/reaction_turf(var/turf/T, var/volume) //let's make a mess!
src = null
if(volume >= 5)
new /obj/effect/decal/cleanable/blood/gibs/cleangibs(T)
playsound(T, 'sound/effects/splat.ogg', 50, 1, -3)
return

datum/reagent/charcoal
/datum/reagent/charcoal
name = "Charcoal"
id = "charcoal"
description = "Activated charcoal helps to absorb toxins."
reagent_state = LIQUID
color = "#000000"

datum/reagent/charcoal/on_mob_life(var/mob/living/M as mob)
/datum/reagent/charcoal/on_mob_life(var/mob/living/M as mob)
if(!M) M = holder.my_atom
M.adjustToxLoss(-1.5*REM)
if(prob(50))
Expand Down Expand Up @@ -216,15 +220,15 @@ datum/reagent/omnizine
M.Dizzy(5)
M.Weaken(3)

datum/reagent/calomel
/datum/reagent/calomel
name = "Calomel"
id = "calomel"
description = "This potent purgative rids the body of impurities. It is highly toxic however and close supervision is required."
reagent_state = LIQUID
color = "#22AB35"
metabolization_rate = 0.8

datum/reagent/calomel/on_mob_life(var/mob/living/M as mob)
/datum/reagent/calomel/on_mob_life(var/mob/living/M as mob)
if(!M) M = holder.my_atom
for(var/datum/reagent/R in M.reagents.reagent_list)
if(R != src)
Expand All @@ -245,14 +249,14 @@ datum/reagent/calomel/on_mob_life(var/mob/living/M as mob)
min_temp = 374
mix_message = "Stinging vapors rise from the solution."

datum/reagent/potass_iodide
/datum/reagent/potass_iodide
name = "Potassium Iodide"
id = "potass_iodide"
description = "Potassium Iodide is a medicinal drug used to counter the effects of radiation poisoning."
reagent_state = LIQUID
color = "#B4DCBE"

datum/reagent/potass_iodide/on_mob_life(var/mob/living/M as mob)
/datum/reagent/potass_iodide/on_mob_life(var/mob/living/M as mob)
if(!M) M = holder.my_atom
if(prob(80))
M.radiation = max(0, M.radiation-1)
Expand Down
18 changes: 12 additions & 6 deletions code/modules/reagents/oldchem/reagents/reagents_food.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,25 @@
nutriment_factor = 12 * REAGENTS_METABOLISM
color = "#664330" // rgb: 102, 67, 48

/datum/reagent/nutriment/on_mob_life(var/mob/living/M as mob)
if(!M) M = holder.my_atom
/datum/reagent/nutriment/on_mob_life(mob/living/M)
if(!M)
M = holder.my_atom
if(!(M.mind in ticker.mode.vampires))
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(H.can_eat()) //Make sure the species has it's dietflag set, otherwise it can't digest any nutrients
H.nutrition += nutriment_factor // For hunger and fatness
if(prob(50)) M.adjustBruteLoss(-1)
if(prob(50))
M.adjustBruteLoss(-1)
if(H.species.exotic_blood)
H.vessel.add_reagent(H.species.exotic_blood, 0.4)
else
if(!(H.species.flags & NO_BLOOD))
H.vessel.add_reagent("blood", 0.4)
if(istype(M,/mob/living/simple_animal)) //Any nutrients can heal simple animals
if(prob(50)) M.heal_organ_damage(1,0)
if(prob(50))
M.heal_organ_damage(1,0)
..()
return


/datum/reagent/protein // Meat-based protein, digestable by carnivores and omnivores, worthless to herbivores
name = "Protein"
Expand Down
8 changes: 8 additions & 0 deletions code/modules/reagents/oldchem/reagents/reagents_misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@
return
*/

/datum/reagent/iron/on_mob_life(mob/living/M)
if(!M)
M = holder.my_atom
if(ishuman(M))
var/mob/living/carbon/human/H = M
if(!H.species.exotic_blood && !(H.species.flags & NO_BLOOD))
H.vessel.add_reagent("blood", 0.8)
..()


//foam
Expand Down
Loading

0 comments on commit adcbeb9

Please sign in to comment.