Files
Paradise/code/modules/surgery/organs/blood.dm
T
a5260456ae Advanced Disease Rework (#28451)
* Reworks cures, adds strains, adds treatment chems to symptoms

* Enables coexistence of different samples of the same strain at different stages within the same container

* Adds symptom guessing. Correct guesses reduce analysis time and wrong ones increase it.

* Adds a chance for a virus to evolve into a new strain. changing the cure and adding/subtracting symptoms

* Revert "Adds a chance for a virus to evolve into a new strain. changing the cure and adding/subtracting symptoms"

This reverts commit 124dd485c7.

* Adds spontaneous virus mutations, strain tracking. Removes antibody metabolism

* change the amount of time added/reduced by each factor

* Creates a disease outbreak event that allows admins to cause an outbreak of a virus of their choosing. Allows virus creation when choosing virus to give someone or for an outbreak.

* The normal base property values are now the defaults for disease creation

* Rebuild TGUI

* Rebuild TGUI

* Rebuild TGUI

* Update tgui.bundle.js

* remove redundant lines

* improves ui some and moves to using world time for analysis time

* fixes a bug with the analysis time and updates the initial known advanced disease list

* Buffs the disease outbreak event and adds a base stat row to the PANDEMIC

* Update tgui.bundle.js

* Implements calibration

* Adds a remove from database button

* Moves the known disease global list to work per z level

* Removes treatments from most chems and makes each instance of a symptom not acting purge some of the reagent that treated it

* Update symptoms.dm

* Adds stage to unknown diseases

* Moves accumulated error to work per z level and change the location of the delete strain data button

* Adds confirmation to the delete data button and moves the disease text out of the loop in the copy constructor

* fix indentation

* Replaces pent with hydrocodone in the advanced cure list

* gives more buffs to event disease based on severity. removes longevity from possible symptoms an event disease can get.  Fixes a bug with determining analysis time

* Update tgui.bundle.js

* Update pandemic.dm

* Update pandemic.dm

* Update tgui.bundle.js

* review changes

* Update tgui.bundle.js

* Update tgui.bundle.js

* Update tgui.bundle.js

* Update tgui.bundle.js

* Update tgui.bundle.js

* Update tgui.bundle.js

* Update tgui.bundle.js

* Update tgui.bundle.js

* review changes

* Update tgui.bundle.js

* Makes vaccines only add resistances and no longer cure

* improves pandemic ui and fixes calibration button not being properly disabled

* Update tgui.bundle.js

* Add the new agars to the virologist's fridge

* lowered evolution chance of viruses a bit

* further lowers evolution chance

* Update advance.dm

* Changes the scaling of analysis time and fixes stage speed presentation in the pandemic

* Scanners can now see virus strains that have been inserted in the pandemic

* Allows a mob to be infected by both an event and non event disease

* Fixes the +1 syringe of translocation stabbing your feet

* Update tgui.bundle.js

* Changes spontanous mutation to be per spread and makes disease events less likely.

* Diseases less common, mutations happen only on spread now, symptom list ordered alphabetically in the dropdown, fixed some bugs

* Update tgui.bundle.js

* changes virus alerts

* Removes numbers from the virus alert text and fixes a bug that caused excessive virus mutations

* Update tgui.bundle.js

* refactor disease spread

* Changes disease spread logic to give players options to protect themselves and others

* Blackbox things

* Increases announcement timer and fixes the infection talley

* Update disease_outbreak.dm

* Adds an incubation period to advanced viruses. bumps sneeze back to 5 range

* Adds failsafe to disease outbreaks that will infect a random crew member if none have arrived in 10 minutes

* Only record advanced disease infections

* Properly handle recording of disease infection events

* Changed resistance effect on cure

* another adjustment to res effect on cure

* Small resist buff, spontanous combustion buff and some calculation fixes

* changes spontanous combustion stat bonuses and maluses

* Update flesh_eating.dm

* Update flesh_eating.dm

* Update flesh_eating.dm

* Big trait changes and rebalance

* adds treatments to fire and necro

* Introduces viral contamination of food and reagent containers, as well as disinfection

* Fix runtime in reagent transfers

* Revert the prefs and config changes

* Slowed down diseases and made symptoms more gradual, improved disease alerts to both crew and dchat

* Sterilizine now sterilizes things contaminated with viruses. Heat reactions now take place alongside chemical reactions when adding reagents to a beaker

* Adds option to order sterile masks, goggles and biosuits in packs of 4. Makes sterile masks as good as internals for viruses

* adds logging to pandemic

* Changes symptom stats and increased disease varaiety

* Fixes some disease bugs

* Fixes some bugs and makes it behave better

* Adds shiver emote to shiver symptom

* Adds admin message/log to contracting an event disease and fixes copy behaviour when infecting

* Prefix spread defines

* Change the rest of the macros

* correct the disinfection temp macro

* Moves disease signals to their own file

* move disnifection temp back

* fix a type

* viral contaminations component review changes

* var name changes

* more style fixes

* Update tgui.bundle.js

* fixes pandemic

* Fixes disease outbreak having two carriers sometimes and changes the virus alert to the new one

* Update disease_defines.dm

* fixes samples not passing stages on properly

* actually fixes the bug

* Fixes stabilization being lost on cloning

* Finally completely and absolutely fixes the sample stages bug(please)

* Makes the pandemic a machine

* Update pandemic.dm

* removed drinks from cure requirements

* lowers chance of major viral outbreak

* fixes pandemic not processing properly

* Changes the cure system to have more options

* Makes mixing event viruses more random

* Fixes hardsuits having a 1% chance to be infected

* Increases virus protection of most clothing. medical scrubs and surgical hat buffed sunstantially

* Slow down progress of diseases

* makes spread less likely

* envirosuit is now slightly more protective from viruses, while the medical one is as good as scrubs

* Adds further protection to helmets

* Increases the number of possible cures and the scaling of required cures

* Pandemic ui improvements

* Update _disease.dm

* fix a bug with spread target in the disease outbreak event

* changes some clothing permeability

* Adds the ability to make viral DNA extracts by injecting a sample into a black slime core. It's equivalent to 2 stages

* Adds age to health analyzer, makes viral evolution toggle minor disabilities, confusion symptom now confuses more often

* Update pandemic.dm

* replace lazarus with acetic acid in the cures

* Changes the relation of the amount of cure options to required cures and the scaling of required cures with resistance

* Fixes virus renaming

* changes description and permeability of some medical jumpsuits

* Adds a list of all diseases infecting client mobs to the disease outbreak event

* uses event UID instead of ref in the disease

* Adds advanced disease carriers to admin antag menu

* Adds viral eraser which removes tracking and stabilizing. Admin spawn only for now

* Update tgui.bundle.js

* Adds the ability to create viral genetic material using radiation. it can be used in addition to that produced in xenobio

* changes alert logic, disease generation logic, adds treatments to weakness, cough and sneeze now more gradual and cough spreads at range 3

* makes disease advance a bit faster

* reduce time to announcement to 6 minutes after 3 people are infected

* Changes medibot disease detection to be the same as analyzers. Treatment chems now put the symptom on a cooldown that persists after they leave the body.

* Make sure the disease outbreak event only selects crew

* Fix abductor virus gland virus generation

* Adds sterilizine to viro locker

* Fixes null viruses appearing when merging virusless blood

* Adds oculine to hyphema treatments

* Rebalances weight loss and flesh eating

* Improvements to advanced disease carrier tab on the TGUI antag menu

* change the flag on away missions

* Update mob_spawn.dm

* Update tgui.bundle.js

* adds sterilizine recipe back

* Adds viral contamination to surgery tools and surgery steps

* small changes

* fixes pandemic ui. should work properly now(I hope)

* CI compliance

* Update flesh_eating.dm

* Update vomit.dm

* Update tgui.bundle.js

* Initial revision of analysis and fixes the UI issue with multiple stage samples

* refactors treatment and makes treatment chems more adjustable

* var correction

* symptoms and their contribution now show up on the pandemic

* Update tgui.bundle.js

* Update code/datums/diseases/advance/symptoms/cough.dm

Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com>

* change wizard disease and zombie disease macros to new ones

* Update tgui.bundle.js

* changes the part requirements on the pandemic boards to fit the actual parts

* fix misbehaviour when inserting samples without symptoms

* Some changes to difficulty scaling, reverts the level of projectile vomiting back to 4, and disallows germaphobes to avoid infection by injection

* Adds viral contamination to IV bags

---------

Signed-off-by: Burzah <116982774+Burzah@users.noreply.github.com>
Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com>
2025-08-08 01:54:36 +00:00

376 lines
13 KiB
Plaintext

/****************************************************
MARK: BLOOD SYSTEM
****************************************************/
#define EXOTIC_BLEED_MULTIPLIER 4 //Multiplies the actually bled amount by this number for the purposes of turf reaction calculations.
/mob/living/carbon/human/proc/suppress_bloodloss(amount)
if(bleedsuppress)
return
else
bleedsuppress = TRUE
addtimer(CALLBACK(src, PROC_REF(resume_bleeding)), amount)
/mob/living/carbon/human/proc/resume_bleeding()
if(stat != DEAD && bleed_rate && bleedsuppress)
to_chat(src, "<span class='warning'>The blood soaks through your bandage.</span>")
bleedsuppress = FALSE
// Takes care blood loss and regeneration
/mob/living/carbon/human/handle_blood()
if(NO_BLOOD in dna.species.species_traits)
bleed_rate = 0
return
if(bodytemperature >= TCRYO && !HAS_TRAIT(src, TRAIT_BADDNA)) //cryosleep or husked people do not pump the blood.
if(blood_volume < BLOOD_VOLUME_NORMAL)
blood_volume += 0.1 // regenerate blood VERY slowly
if(nutrition >= NUTRITION_LEVEL_WELL_FED)
blood_volume += 0.1 // double it if you are well fed
//Effects of bloodloss
var/word = pick("dizzy","woozy","faint")
switch(blood_volume)
if(BLOOD_VOLUME_OKAY to BLOOD_VOLUME_SAFE)
if(prob(5))
to_chat(src, "<span class='warning'>You feel [word].</span>")
apply_damage_type(round((BLOOD_VOLUME_NORMAL - blood_volume) * 0.01, 1), dna.species.blood_damage_type)
if(BLOOD_VOLUME_BAD to BLOOD_VOLUME_OKAY)
apply_damage_type(round((BLOOD_VOLUME_NORMAL - blood_volume) * 0.02, 1), dna.species.blood_damage_type)
if(prob(5))
EyeBlurry(12 SECONDS)
to_chat(src, "<span class='warning'>You feel very [word].</span>")
if(BLOOD_VOLUME_SURVIVE to BLOOD_VOLUME_BAD)
apply_damage_type(5, dna.species.blood_damage_type)
if(prob(15))
Paralyse(rand(2 SECONDS, 6 SECONDS))
to_chat(src, "<span class='warning'>You feel extremely [word].</span>")
if(-INFINITY to BLOOD_VOLUME_SURVIVE)
death()
var/temp_bleed = 0
var/internal_bleeding_rate = 0
//Bleeding out
for(var/X in bodyparts)
var/obj/item/organ/external/BP = X
var/brutedamage = BP.brute_dam
if(BP.is_robotic())
continue
//We want an accurate reading of length()
listclearnulls(BP.embedded_objects)
temp_bleed += 0.5 * length(BP.embedded_objects)
if(brutedamage >= 20)
temp_bleed += (brutedamage * 0.013)
if(BP.open)
temp_bleed += 0.5
if(BP.status & ORGAN_INT_BLEEDING)
internal_bleeding_rate += 0.5
bleed_rate = max(bleed_rate - 0.5, temp_bleed)//if no wounds, other bleed effects naturally decreases
var/additional_bleed = round(clamp((reagents.get_reagent_amount("heparin") / 10), 0, 2), 1) //Heparin worsens existing bleeding
if(internal_bleeding_rate && !HAS_TRAIT(src, TRAIT_FAKEDEATH))
bleed_internal(internal_bleeding_rate + additional_bleed)
if(bleed_rate && !bleedsuppress && !HAS_TRAIT(src, TRAIT_FAKEDEATH))
bleed(bleed_rate + additional_bleed)
//Makes a blood drop, leaking amt units of blood from the mob
/mob/living/carbon/proc/bleed(amt)
if(blood_volume)
blood_volume = max(blood_volume - amt, 0)
if(isturf(loc)) //Blood loss still happens in locker, floor stays clean
if(amt >= 10)
add_splatter_floor(loc)
else
add_splatter_floor(loc, 1)
/mob/living/carbon/human/bleed(amt)
amt *= physiology.bleed_mod
if(!(NO_BLOOD in dna.species.species_traits))
..()
if(dna.species.exotic_blood)
var/datum/reagent/R = GLOB.chemical_reagents_list[get_blood_id()]
if(istype(R) && isturf(loc))
if(EXOTIC_COLOR in dna.species.species_traits)
R.reaction_turf(get_turf(src), amt * EXOTIC_BLEED_MULTIPLIER, dna.species.blood_color)
else
R.reaction_turf(get_turf(src), amt * EXOTIC_BLEED_MULTIPLIER)
/mob/living/carbon/proc/bleed_internal(amt) // Return 1 if we've coughed blood up, 2 if we're vomited it.
if(blood_volume)
blood_volume = max(blood_volume - amt, 0)
if(prob(10 * amt)) // +5% chance per internal bleeding site that we'll cough up blood on a given tick.
custom_emote(EMOTE_VISIBLE, "coughs up blood!")
add_splatter_floor(loc, 1)
return 1
else if(amt >= 1 && prob(5 * amt)) // +2.5% chance per internal bleeding site that we'll cough up blood on a given tick. Must be bleeding internally in more than one place to have a chance at this.
vomit(0, 1)
return 2
return 0
/mob/living/carbon/human/bleed_internal(amt)
if(!(NO_BLOOD in dna.species.species_traits))
.=..()
if(dna.species.exotic_blood && .) // Do we have exotic blood, and have we left any on the ground?
var/datum/reagent/R = GLOB.chemical_reagents_list[get_blood_id()]
if(istype(R) && isturf(loc))
if(EXOTIC_COLOR in dna.species.species_traits)
R.reaction_turf(get_turf(src), amt * EXOTIC_BLEED_MULTIPLIER, dna.species.blood_color)
else
R.reaction_turf(get_turf(src), amt * EXOTIC_BLEED_MULTIPLIER)
/mob/living/proc/restore_blood()
blood_volume = initial(blood_volume)
/mob/living/carbon/human/restore_blood()
blood_volume = BLOOD_VOLUME_NORMAL
bleed_rate = 0
/****************************************************
MARK: BLOOD TRANSFERS
****************************************************/
//Gets blood from mob to a container or other mob, preserving all data in it.
/mob/living/proc/transfer_blood_to(atom/movable/AM, amount, forced)
if(!blood_volume || !AM.reagents)
return FALSE
if(blood_volume < BLOOD_VOLUME_BAD && !forced)
return FALSE
if(blood_volume < amount)
amount = blood_volume
var/blood_id = get_blood_id()
if(!blood_id)
return FALSE
blood_volume -= amount
SEND_SIGNAL(AM, COMSIG_MOB_REAGENT_EXCHANGE, src)
var/list/blood_data = get_blood_data(blood_id)
if(iscarbon(AM))
var/mob/living/carbon/C = AM
if(blood_id == C.get_blood_id())//both mobs have the same blood substance
if(blood_id == "blood") //normal blood
if(blood_data["viruses"])
for(var/thing in blood_data["viruses"])
var/datum/disease/D = thing
if((D.spread_flags & SPREAD_SPECIAL) || (D.spread_flags & SPREAD_NON_CONTAGIOUS))
continue
C.ForceContractDisease(D)
if(!(blood_data?["blood_type"] in get_safe_blood(C.dna.blood_type)) || C.dna.species.name != blood_data["species"] && (blood_data["species_only"] || C.dna.species.own_species_blood))
C.reagents.add_reagent("toxin", amount * 0.5)
return 1
C.blood_volume = min(C.blood_volume + round(amount, 0.1), BLOOD_VOLUME_NORMAL)
return 1
AM.reagents.add_reagent(blood_id, amount, blood_data, bodytemperature)
return 1
/mob/living/proc/get_blood_data(blood_id)
return
/mob/living/carbon/human/get_blood_data(blood_id)
if(blood_id == "blood") //actual blood reagent
var/blood_data = list()
//set the blood data
blood_data["donor"] = src
blood_data["viruses"] = list()
for(var/thing in viruses)
var/datum/disease/D = thing
blood_data["viruses"] += D.Copy()
blood_data["blood_DNA"] = copytext(dna.unique_enzymes,1,0)
if(resistances && length(resistances))
blood_data["resistances"] = resistances.Copy()
var/list/temp_chem = list()
for(var/datum/reagent/R in reagents.reagent_list)
temp_chem[R.id] = R.volume
blood_data["trace_chem"] = list2params(temp_chem)
if(mind)
blood_data["mind"] = mind
if(ckey)
blood_data["ckey"] = ckey
if(!suiciding)
blood_data["cloneable"] = 1
blood_data["blood_type"] = copytext(src.dna.blood_type,1,0)
blood_data["gender"] = gender
blood_data["real_name"] = real_name
blood_data["blood_color"] = dna.species.blood_color
blood_data["factions"] = faction
blood_data["dna"] = dna.Clone()
blood_data["species"] = dna.species.name
blood_data["species_only"] = dna.species.own_species_blood
return blood_data
if(blood_id == "slimejelly")
var/blood_data = list()
blood_data["blood_color"] = dna.species.blood_color
return blood_data
//get the id of the substance this mob use as blood.
/mob/proc/get_blood_id()
return
/mob/living/simple_animal/get_blood_id()
if(blood_volume)
return "blood"
/mob/living/carbon/human/get_blood_id()
if(dna.species.exotic_blood)//some races may bleed water..or kethcup..
return dna.species.exotic_blood
else if((NO_BLOOD in dna.species.species_traits) || HAS_TRAIT(src, TRAIT_HUSK))
return
return "blood"
// This is has more potential uses, and is probably faster than the old proc.
/proc/get_safe_blood(bloodtype)
. = list(BLOOD_TYPE_FAKE_BLOOD)
if(!bloodtype)
return
switch(bloodtype)
if("A-")
. += list("A-", "O-")
if("A+")
. += list("A-", "A+", "O-", "O+")
if("B-")
. += list("B-", "O-")
if("B+")
. += list("B-", "B+", "O-", "O+")
if("AB-")
. += list("A-", "B-", "O-", "AB-")
if("AB+")
. += list("A-", "A+", "B-", "B+", "O-", "O+", "AB-", "AB+")
if("O-")
. += list("O-")
if("O+")
. += list("O-", "O+")
//to add a splatter of blood or other mob liquid.
/mob/living/proc/add_splatter_floor(turf/T, small_drip, shift_x, shift_y)
if((get_blood_id() != "blood") && (get_blood_id() != "slimejelly") && (get_blood_id() != "tomatojuice"))//is it blood or welding fuel?
return
if(!T)
T = get_turf(src)
var/list/temp_blood_DNA
var/list/b_data = get_blood_data(get_blood_id())
var/datum/move_loop/move/move_loop = GLOB.move_manager.processing_on(src, SSspacedrift)
if(small_drip)
// Only a certain number of drips (or one large splatter) can be on a given turf.
var/obj/effect/decal/cleanable/blood/drip/drop = locate() in T
if(drop)
if(move_loop)
drop.newtonian_move(move_loop.direction, instant = TRUE)
if(drop.drips < 5)
drop.drips++
var/image/I = image(drop.icon, drop.random_icon_states)
I.icon += drop.basecolor
drop.overlays |= I
drop.transfer_mob_blood_dna(src)
if(b_data && !isnull(b_data["blood_color"]))
drop.basecolor = b_data["blood_color"]
else
drop.basecolor = "#A10808"
drop.update_icon()
else
temp_blood_DNA = list()
temp_blood_DNA |= drop.blood_DNA.Copy() //we transfer the dna from the drip to the splatter
qdel(drop)
else
drop = new(T)
drop.transfer_mob_blood_dna(src)
if(b_data && !isnull(b_data["blood_color"]))
drop.basecolor = b_data["blood_color"]
else
drop.basecolor = "#A10808"
drop.update_icon()
if(move_loop)
drop.newtonian_move(move_loop.direction, instant = TRUE)
return
// Find a blood decal or create a new one.
var/obj/effect/decal/cleanable/blood/splatter/B = locate() in T
var/list/bloods = get_atoms_of_type(T, B, TRUE, 0, 0) //Get all the non-projectile-splattered blood on this turf (not pixel-shifted).
if(shift_x || shift_y)
bloods = get_atoms_of_type(T, B, TRUE, shift_x, shift_y) //Get all the projectile-splattered blood at these pixels on this turf (pixel-shifted).
B = locate() in bloods
if(!B)
B = new(T)
if(B.bloodiness < MAX_SHOE_BLOODINESS) //add more blood, up to a limit
B.bloodiness += BLOOD_AMOUNT_PER_DECAL
B.transfer_mob_blood_dna(src) //give blood info to the blood decal.
if(temp_blood_DNA)
B.blood_DNA |= temp_blood_DNA
B.pixel_x = (shift_x)
B.pixel_y = (shift_y)
B.update_icon()
if(shift_x || shift_y)
B.off_floor = TRUE
B.layer = BELOW_MOB_LAYER //So the blood lands ontop of things like posters, windows, etc.
if(move_loop)
B.newtonian_move(move_loop.direction, instant = TRUE)
/mob/living/carbon/human/add_splatter_floor(turf/T, small_drip, shift_x, shift_y, emittor_intertia)
if(!(NO_BLOOD in dna.species.species_traits))
..()
/mob/living/carbon/alien/add_splatter_floor(turf/T, small_drip, shift_x, shift_y, emittor_intertia)
if(!T)
T = get_turf(src)
var/obj/effect/decal/cleanable/blood/xeno/splatter/B = locate() in T
var/list/bloods = get_atoms_of_type(T, B, TRUE, 0, 0) //The more the better.
if(shift_x || shift_y)
bloods = get_atoms_of_type(T, B, TRUE, shift_x, shift_y)
B = locate() in bloods
if(!B)
B = new(T)
B.blood_DNA["UNKNOWN DNA"] = "X*"
B.pixel_x = (shift_x)
B.pixel_y = (shift_y)
if(shift_x || shift_y)
B.off_floor = TRUE
B.layer = BELOW_MOB_LAYER
/mob/living/silicon/robot/add_splatter_floor(turf/T, small_drip, shift_x, shift_y)
if(!T)
T = get_turf(src)
var/obj/effect/decal/cleanable/blood/oil/streak/O = locate() in T
var/list/oils = get_atoms_of_type(T, O, TRUE, 0, 0) //Don't let OSHA catch wind of this.
if(shift_x || shift_y)
oils = get_atoms_of_type(T, O, TRUE, shift_x, shift_y)
O = locate() in oils
if(!O)
O = new(T)
O.pixel_x = (shift_x)
O.pixel_y = (shift_y)
if(shift_x || shift_y)
O.off_floor = TRUE
O.layer = BELOW_MOB_LAYER
/mob/living/proc/absorb_blood()
// This merely deletes the blood reagent inside of the mob to look nice on health scans.
// The update to .blood_volume happens in `/datum/reagent/proc/reaction_mob`
var/id = get_blood_id()
if(id)
reagents.del_reagent(get_blood_id())
#undef EXOTIC_BLEED_MULTIPLIER