Files

152 lines
4.8 KiB
Plaintext

/datum/immune_system
var/mob/living/carbon/human/body = null
var/strength = 1
var/overloaded = FALSE
var/list/antibodies = list(
ANTIGEN_O = 0,
ANTIGEN_A = 0,
ANTIGEN_B = 0,
ANTIGEN_RH = 0,
ANTIGEN_Q = 0,
ANTIGEN_U = 0,
ANTIGEN_V = 0,
ANTIGEN_M = 0,
ANTIGEN_N = 0,
ANTIGEN_P = 0,
ANTIGEN_X = 0,
ANTIGEN_Y = 0,
ANTIGEN_Z = 0,
//ANTIGEN_CULT = 0,
)
/datum/immune_system/New(var/mob/living/L)
..()
if (!L)
qdel(src)
return
body = L
for (var/antibody in antibodies)
if (antibody in rare_antigens)
antibodies[antibody] = rand(1,15)
if (prob(5))
antibodies[antibody] += 10
if (antibody in common_antigens)
antibodies[antibody] = rand(10,30)
if (antibody in blood_antigens)
antibodies[antibody] = rand(10,20)
if (body.dna && body.dna.b_type)
if (antibody == "ANTIGEN_O")
antibodies[antibody] += rand(12,15)
if (antibody == "ANTIGEN_A" && findtext(body.dna.b_type,"A"))
antibodies[antibody] += rand(12,15)
if (antibody == "ANTIGEN_B" && findtext(body.dna.b_type,"B"))
antibodies[antibody] += rand(12,15)
if (antibody == "ANTIGEN_RH" && findtext(body.dna.b_type,"+"))
antibodies[antibody] += rand(12,15)
/datum/immune_system/Destroy()
if(body)
//body.immune_system = null
body.immune_system = null
body = null
..()
/*i think this is supposed to be for blood transfusions?
but i don't see it used in their code, so i'm commenting it out
/datum/immune_system/proc/transfer_to(var/mob/living/L)
if (!L.immune_system)
L.immune_system = new (L)
L.immune_system.strength = strength
L.immune_system.overloaded = overloaded
L.immune_system.antibodies = antibodies.Copy()
*/
/datum/immune_system/proc/GetImmunity()
var/effective_strength = strength
var/mob/living/carbon/human/L = body
if (L)
if (L.species.get_species_id() == SPECIES_ID_VOX || L.species.get_species_id() == SPECIES_ID_ZADDAT)
effective_strength *= 0.5
if (L.species.get_species_id() == SPECIES_ID_AURIL || L.species.get_species_id() == SPECIES_ID_DREMACHIR)
effective_strength *= 2
return list(effective_strength, antibodies.Copy())
/datum/immune_system/proc/Overload()
body.adjustToxLoss(100)
body.afflict_radiation(50, 0, 0) //don't check for armor since Overload is only called when someone has taken Radium
body.bodytemperature = max(body.bodytemperature, LEGACY_BODYTEMP_HEAT_DAMAGE_THRESHOLD)
to_chat(body, "<span class='danger'>A terrible fever assails your body, you feel ill as your immune system kicks into overdrive to drive away your infections.</span>")
if (ishuman(body))
var/mob/living/carbon/human/H = body
H.vomit(0,1)//hope you're wearing a biosuit or you'll get reinfected from your vomit, lol
for(var/ID in body.virus2)
var/datum/disease2/disease/D = body.virus2[ID]
D.cure(body,2)
strength = 0
overloaded = TRUE
//If even one antibody hass sufficient concentration, the disease won't be able to infect
/datum/immune_system/proc/CanInfect(var/datum/disease2/disease/disease)
if (overloaded)
return TRUE
/*if(!disease.CanInfect(body)) disease.CanInfect() literally just returned true. i don't know why this was here.
return FALSE*/
for (var/antigen in disease.antigen)
if ((strength * antibodies[antigen]) >= disease.strength)
return FALSE
return TRUE
/datum/immune_system/proc/ApplyAntipathogenics(var/threshold, var/list/antigen_restriction = list(), var/multiplier = 1)
if (overloaded)
return
for (var/ID in body.virus2)
var/datum/disease2/disease/disease = body.virus2[ID]
for (var/A in disease.antigen)
if((antigen_restriction.len == 0) || (A in antigen_restriction))
var/tally = 0.5
if (isturf(body.loc) && body.lying)
tally += 0.5
var/obj/structure/bed/B = locate() in body.loc
if (B && body.buckled != null)//fucking chairs n stuff
tally += 1
if (body.resting_intentionally)
if (tally < 2)
tally += 1
else
tally += 2//if we're sleeping in a bed, we get up to 4
else if(istype(body.loc, /obj/machinery/atmospherics/component/unary/cryo_cell))
tally += 1.5
//else if(body.locked_to && istype(body.locked_to, /obj/item/critter_cage))
// tally += 2
if (antibodies[A] < threshold)
antibodies[A] = min(antibodies[A] + (tally*multiplier), threshold)//no overshooting here
else
if (prob(threshold) && prob(tally * 10) && prob((100 - antibodies[A])*100/(100-threshold)))//smaller and smaller chance for further increase
antibodies[A] = min(antibodies[A] + 1, 100)
/datum/immune_system/proc/ApplyVaccine(var/list/antigen)
if (overloaded)
return
for (var/A in antigen)
antibodies[A] = min(antibodies[A] + 20, 100)
/* dunno what this is for
/datum/immune_system/send_to_past(var/duration)
..()
var/static/list/resettable_vars = list(
"strength",
"overloaded",
"antibodies"
)
reset_vars_after_duration(resettable_vars, duration)
*/