mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
* Remove reagent ids and use typepaths where applicable * Remove reagent ids and use typepaths where applicable * Resolves some easier conflicts * Resolves medical_tools.dm * Resolves robots.dm * Handles cinnamon Wow, I cannot do this manually. Fuckin' regex time. * Removes 27 merge conflicts (!!!!!) * Makes it actually half-attempt to compile * I just -- I give up, it's over * mk * mk * mk * hm * ok * what a bloody chain reaction jesus * ok * and done * went threw and changed the ones I missed * ok * dangit altoids hurry the fek up * Fixes whatever I found find thru this regex: reagents[\s\w]*=[\s\w]*list\([^\/]+\)
190 lines
5.3 KiB
Plaintext
190 lines
5.3 KiB
Plaintext
/datum/disease
|
|
//Flags
|
|
var/visibility_flags = 0
|
|
var/disease_flags = CURABLE|CAN_CARRY|CAN_RESIST
|
|
var/spread_flags = DISEASE_SPREAD_AIRBORNE | DISEASE_SPREAD_CONTACT_FLUIDS | DISEASE_SPREAD_CONTACT_SKIN
|
|
|
|
//Fluff
|
|
var/form = "Virus"
|
|
var/name = "No disease"
|
|
var/desc = ""
|
|
var/agent = "some microbes"
|
|
var/spread_text = ""
|
|
var/cure_text = ""
|
|
|
|
//Stages
|
|
var/stage = 1
|
|
var/max_stages = 0
|
|
var/stage_prob = 4
|
|
|
|
//Other
|
|
var/list/viable_mobtypes = list() //typepaths of viable mobs
|
|
var/mob/living/carbon/affected_mob = null
|
|
var/list/cures = list() //list of cures if the disease has the CURABLE flag, these are reagent ids
|
|
var/infectivity = 65
|
|
var/cure_chance = 8
|
|
var/carrier = FALSE //If our host is only a carrier
|
|
var/bypasses_immunity = FALSE //Does it skip species virus immunity check? Some things may diseases and not viruses
|
|
var/permeability_mod = 1
|
|
var/severity = DISEASE_SEVERITY_NONTHREAT
|
|
var/list/required_organs = list()
|
|
var/needs_all_cures = TRUE
|
|
var/list/strain_data = list() //dna_spread special bullshit
|
|
var/list/infectable_biotypes = list(MOB_ORGANIC) //if the disease can spread on organics, synthetics, or undead
|
|
var/process_dead = FALSE //if this ticks while the host is dead
|
|
var/copy_type = null //if this is null, copies will use the type of the instance being copied
|
|
|
|
/datum/disease/Destroy()
|
|
. = ..()
|
|
if(affected_mob)
|
|
remove_disease()
|
|
SSdisease.active_diseases.Remove(src)
|
|
|
|
//add this disease if the host does not already have too many
|
|
/datum/disease/proc/try_infect(var/mob/living/infectee, make_copy = TRUE)
|
|
infect(infectee, make_copy)
|
|
return TRUE
|
|
|
|
//add the disease with no checks
|
|
/datum/disease/proc/infect(var/mob/living/infectee, make_copy = TRUE)
|
|
var/datum/disease/D = make_copy ? Copy() : src
|
|
infectee.diseases += D
|
|
D.affected_mob = infectee
|
|
SSdisease.active_diseases += D //Add it to the active diseases list, now that it's actually in a mob and being processed.
|
|
|
|
D.after_add()
|
|
infectee.med_hud_set_status()
|
|
|
|
var/turf/source_turf = get_turf(infectee)
|
|
log_virus("[key_name(infectee)] was infected by virus: [src.admin_details()] at [loc_name(source_turf)]")
|
|
|
|
//Return a string for admin logging uses, should describe the disease in detail
|
|
/datum/disease/proc/admin_details()
|
|
return "[src.name] : [src.type]"
|
|
|
|
/datum/disease/proc/stage_act()
|
|
var/cure = has_cure()
|
|
|
|
if(carrier && !cure)
|
|
return
|
|
|
|
stage = min(stage, max_stages)
|
|
|
|
if(!cure)
|
|
if(prob(stage_prob))
|
|
update_stage(min(stage + 1,max_stages))
|
|
else
|
|
if(prob(cure_chance))
|
|
update_stage(max(stage - 1, 1))
|
|
|
|
if(disease_flags & CURABLE)
|
|
if(cure && prob(cure_chance))
|
|
cure()
|
|
|
|
/datum/disease/proc/update_stage(new_stage)
|
|
stage = new_stage
|
|
|
|
/datum/disease/proc/has_cure()
|
|
if(!(disease_flags & CURABLE))
|
|
return FALSE
|
|
|
|
. = cures.len
|
|
for(var/C_id in cures)
|
|
if(!affected_mob.reagents.has_reagent(C_id))
|
|
.--
|
|
if(!. || (needs_all_cures && . < cures.len))
|
|
return FALSE
|
|
|
|
//Airborne spreading
|
|
/datum/disease/proc/spread(force_spread = 0)
|
|
if(!affected_mob)
|
|
return
|
|
|
|
if(!(spread_flags & DISEASE_SPREAD_AIRBORNE) && !force_spread)
|
|
return
|
|
|
|
if(affected_mob.reagents.has_reagent(/datum/reagent/medicine/spaceacillin) || (affected_mob.satiety > 0 && prob(affected_mob.satiety/10)))
|
|
return
|
|
|
|
var/spread_range = 2
|
|
|
|
if(force_spread)
|
|
spread_range = force_spread
|
|
|
|
var/turf/T = affected_mob.loc
|
|
if(istype(T))
|
|
for(var/mob/living/carbon/C in oview(spread_range, affected_mob))
|
|
var/turf/V = get_turf(C)
|
|
if(disease_air_spread_walk(T, V))
|
|
C.AirborneContractDisease(src, force_spread)
|
|
|
|
/proc/disease_air_spread_walk(turf/start, turf/end)
|
|
if(!start || !end)
|
|
return FALSE
|
|
while(TRUE)
|
|
if(end == start)
|
|
return TRUE
|
|
var/turf/Temp = get_step_towards(end, start)
|
|
if(!CANATMOSPASS(end, Temp))
|
|
return FALSE
|
|
end = Temp
|
|
|
|
|
|
/datum/disease/proc/cure(add_resistance = TRUE)
|
|
if(affected_mob)
|
|
if(add_resistance && (disease_flags & CAN_RESIST))
|
|
affected_mob.disease_resistances |= GetDiseaseID()
|
|
qdel(src)
|
|
|
|
/datum/disease/proc/IsSame(datum/disease/D)
|
|
if(istype(src, D.type))
|
|
return TRUE
|
|
return FALSE
|
|
|
|
|
|
/datum/disease/proc/Copy()
|
|
//note that stage is not copied over - the copy starts over at stage 1
|
|
var/static/list/copy_vars = list("name", "visibility_flags", "disease_flags", "spread_flags", "form", "desc", "agent", "spread_text",
|
|
"cure_text", "max_stages", "stage_prob", "viable_mobtypes", "cures", "infectivity", "cure_chance",
|
|
"bypasses_immunity", "permeability_mod", "severity", "required_organs", "needs_all_cures", "strain_data",
|
|
"infectable_biotypes", "process_dead")
|
|
|
|
var/datum/disease/D = copy_type ? new copy_type() : new type()
|
|
for(var/V in copy_vars)
|
|
var/val = vars[V]
|
|
if(islist(val))
|
|
var/list/L = val
|
|
val = L.Copy()
|
|
D.vars[V] = val
|
|
return D
|
|
|
|
/datum/disease/proc/after_add()
|
|
return
|
|
|
|
|
|
/datum/disease/proc/GetDiseaseID()
|
|
return "[type]"
|
|
|
|
/datum/disease/proc/remove_disease()
|
|
affected_mob.diseases -= src //remove the datum from the list
|
|
affected_mob.med_hud_set_status()
|
|
affected_mob = null
|
|
|
|
//Use this to compare severities
|
|
/proc/get_disease_severity_value(severity)
|
|
switch(severity)
|
|
if(DISEASE_SEVERITY_POSITIVE)
|
|
return 1
|
|
if(DISEASE_SEVERITY_NONTHREAT)
|
|
return 2
|
|
if(DISEASE_SEVERITY_MINOR)
|
|
return 3
|
|
if(DISEASE_SEVERITY_MEDIUM)
|
|
return 4
|
|
if(DISEASE_SEVERITY_HARMFUL)
|
|
return 5
|
|
if(DISEASE_SEVERITY_DANGEROUS)
|
|
return 6
|
|
if(DISEASE_SEVERITY_BIOHAZARD)
|
|
return 7
|