Porting a load of disease/symptoms code updates.

This commit is contained in:
Ghommie
2019-10-05 07:14:25 +02:00
parent 7dada70447
commit 3d22f4ec60
26 changed files with 357 additions and 153 deletions
+1 -1
View File
@@ -234,7 +234,7 @@
/datum/component/storage/proc/quick_empty(mob/M)
var/atom/A = parent
if((!ishuman(M) && (A.loc != M)) || (M.stat != CONSCIOUS) || M.restrained() || !M.canmove)
if(!M.canUseStorage() || !A.Adjacent(M) || M.incapacitated())
return
if(check_locked(null, M, TRUE))
return FALSE
+6
View File
@@ -144,3 +144,9 @@
if(!((locate(thing) in bodyparts) || (locate(thing) in internal_organs)))
return FALSE
return ..()
/mob/living/proc/CanSpreadAirborneDisease()
return !is_mouth_covered()
/mob/living/carbon/CanSpreadAirborneDisease()
return !((head && (head.flags_cover & HEADCOVERSMOUTH) && (head.armor.getRating("bio") >= 25)) || (wear_mask && (wear_mask.flags_cover & MASKCOVERSMOUTH) && (wear_mask.armor.getRating("bio") >= 25)))
+11 -2
View File
@@ -55,6 +55,13 @@
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()
@@ -65,15 +72,17 @@
if(!cure)
if(prob(stage_prob))
stage = min(stage + 1,max_stages)
update_stage(min(stage + 1,max_stages))
else
if(prob(cure_chance))
stage = max(stage - 1, 1)
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))
+33 -16
View File
@@ -31,9 +31,9 @@
var/id = ""
var/processing = FALSE
var/mutable = TRUE //set to FALSE to prevent most in-game methods of altering the disease via virology
var/oldres
var/oldres //To prevent setting new cures unless resistance changes.
// The order goes from easy to cure to hard to cure.
// The order goes from easy to cure to hard to cure. Keep in mind that sentient diseases pick two cures from tier 6 and up, ensure they wont react away in bodies.
var/static/list/advance_cures = list(
list( // level 1
"copper", "silver", "iodine", "iron", "carbon"
@@ -110,15 +110,22 @@
return
if(symptoms && symptoms.len)
if(!processing)
processing = TRUE
for(var/datum/symptom/S in symptoms)
S.Start(src)
if(S.Start(src)) //this will return FALSE if the symptom is neutered
S.next_activation = world.time + rand(S.symptom_delay_min * 10, S.symptom_delay_max * 10)
S.on_stage_change(src)
for(var/datum/symptom/S in symptoms)
S.Activate(src)
// Tell symptoms stage changed
/datum/disease/advance/update_stage(new_stage)
..()
for(var/datum/symptom/S in symptoms)
S.on_stage_change(src)
// Compares type then ID.
/datum/disease/advance/IsSame(datum/disease/advance/D)
@@ -138,9 +145,18 @@
A.properties = properties.Copy()
A.id = id
A.mutable = mutable
A.oldres = oldres
//this is a new disease starting over at stage 1, so processing is not copied
return A
//Describe this disease to an admin in detail (for logging)
/datum/disease/advance/admin_details()
var/list/name_symptoms = list()
for(var/datum/symptom/S in symptoms)
name_symptoms += S.name
return "[name] sym:[english_list(name_symptoms)] r:[totalResistance()] s:[totalStealth()] ss:[totalStageSpeed()] t:[totalTransmittable()]"
/*
NEW PROCS
@@ -191,6 +207,10 @@
/datum/disease/advance/proc/Refresh(new_name = FALSE)
GenerateProperties()
AssignProperties()
if(processing && symptoms && symptoms.len)
for(var/datum/symptom/S in symptoms)
S.Start(src)
S.on_stage_change(src)
id = null
var/the_id = GetDiseaseID()
@@ -342,28 +362,28 @@
return id
// Add a symptom, if it is over the limit (with a small chance to be able to go over)
// we take a random symptom away and add the new one.
// Add a symptom, if it is over the limit we take a random symptom away and add the new one.
/datum/disease/advance/proc/AddSymptom(datum/symptom/S)
if(HasSymptom(S))
return
if(symptoms.len < (VIRUS_SYMPTOM_LIMIT - 1) + rand(-1, 1))
symptoms += S
else
if(!(symptoms.len < (VIRUS_SYMPTOM_LIMIT - 1) + rand(-1, 1)))
RemoveSymptom(pick(symptoms))
symptoms += S
symptoms += S
S.OnAdd(src)
// Simply removes the symptom.
/datum/disease/advance/proc/RemoveSymptom(datum/symptom/S)
symptoms -= S
S.OnRemove(src)
// Neuter a symptom, so it will only affect stats
/datum/disease/advance/proc/NeuterSymptom(datum/symptom/S)
if(!S.neutered)
S.neutered = TRUE
S.name += " (neutered)"
S.OnRemove(src)
/*
@@ -417,7 +437,7 @@
var/i = VIRUS_SYMPTOM_LIMIT
var/datum/disease/advance/D = new(0, null)
var/datum/disease/advance/D = new()
D.symptoms = list()
var/list/symptoms = list()
@@ -445,9 +465,6 @@
D.AssignName(new_name)
D.Refresh()
for(var/datum/disease/advance/AD in SSdisease.active_diseases)
AD.Refresh()
for(var/mob/living/carbon/human/H in shuffle(GLOB.alive_mob_list))
if(!is_station_level(H.z))
continue
@@ -458,8 +475,8 @@
var/list/name_symptoms = list()
for(var/datum/symptom/S in D.symptoms)
name_symptoms += S.name
message_admins("[key_name_admin(user)] has triggered a custom virus outbreak of [D.name]! It has these symptoms: [english_list(name_symptoms)]")
message_admins("[key_name_admin(user)] has triggered a custom virus outbreak of [D.admin_details()]")
log_virus("[key_name(user)] has triggered a custom virus outbreak of [D.admin_details()]!")
/datum/disease/advance/proc/totalStageSpeed()
return properties["stage_rate"]
@@ -70,6 +70,6 @@ BONUS
addtimer(CALLBACK(M, /mob/.proc/emote, "cough"), 6)
addtimer(CALLBACK(M, /mob/.proc/emote, "cough"), 12)
addtimer(CALLBACK(M, /mob/.proc/emote, "cough"), 18)
if(infective)
if(infective && M.CanSpreadAirborneDisease())
A.spread(1)
@@ -219,8 +219,10 @@
level = 8
passive_message = "<span class='notice'>The pain from your wounds makes you feel oddly sleepy...</span>"
var/deathgasp = FALSE
var/stabilize = FALSE
var/active_coma = FALSE //to prevent multiple coma procs
threshold_desc = "<b>Stealth 2:</b> Host appears to die when falling into a coma.<br>\
<b>Resistance 4:</b> The virus also stabilizes the host while they are in critical condition.<br>\
<b>Stage Speed 7:</b> Increases healing speed."
/datum/symptom/heal/coma/Start(datum/disease/advance/A)
@@ -228,9 +230,25 @@
return
if(A.properties["stage_rate"] >= 7)
power = 1.5
if(A.properties["resistance"] >= 4)
stabilize = TRUE
if(A.properties["stealth"] >= 2)
deathgasp = TRUE
/datum/symptom/heal/coma/on_stage_change(datum/disease/advance/A) //mostly copy+pasted from the code for self-respiration's TRAIT_NOBREATH stuff
if(!..())
return FALSE
if(A.stage >= 4 && stabilize)
ADD_TRAIT(A.affected_mob, TRAIT_NOCRITDAMAGE, DISEASE_TRAIT)
else
REMOVE_TRAIT(A.affected_mob, TRAIT_NOCRITDAMAGE, DISEASE_TRAIT)
return TRUE
/datum/symptom/heal/coma/End(datum/disease/advance/A)
if(!..())
return
REMOVE_TRAIT(A.affected_mob, TRAIT_NOCRITDAMAGE, DISEASE_TRAIT)
/datum/symptom/heal/coma/CanHeal(datum/disease/advance/A)
var/mob/living/M = A.affected_mob
if(HAS_TRAIT(M, TRAIT_DEATHCOMA))
@@ -50,3 +50,19 @@ Bonus
if(prob(base_message_chance))
to_chat(M, "<span class='notice'>[pick("Your lungs feel great.", "You realize you haven't been breathing.", "You don't feel the need to breathe.")]</span>")
return
/datum/symptom/oxygen/on_stage_change(datum/disease/advance/A)
if(!..())
return FALSE
var/mob/living/carbon/M = A.affected_mob
if(A.stage >= 4)
ADD_TRAIT(M, TRAIT_NOBREATH, DISEASE_TRAIT)
else
REMOVE_TRAIT(M, TRAIT_NOBREATH, DISEASE_TRAIT)
return TRUE
/datum/symptom/oxygen/End(datum/disease/advance/A)
if(!..())
return
if(A.stage >= 4)
REMOVE_TRAIT(A.affected_mob, TRAIT_NOBREATH, DISEASE_TRAIT)
@@ -48,4 +48,5 @@ Bonus
M.emote("sniff")
else
M.emote("sneeze")
A.spread(4 + power)
if(M.CanSpreadAirborneDisease()) //don't spread germs if they covered their mouth
A.spread(4 + power)
@@ -8,12 +8,14 @@
level = 5
severity = 0
/datum/symptom/undead_adaptation/Start(datum/disease/advance/A)
if(!..())
return
/datum/symptom/undead_adaptation/OnAdd(datum/disease/advance/A)
A.process_dead = TRUE
A.infectable_biotypes |= MOB_UNDEAD
/datum/symptom/undead_adaptation/OnRemove(datum/disease/advance/A)
A.process_dead = FALSE
A.infectable_biotypes -= MOB_UNDEAD
/datum/symptom/inorganic_adaptation
name = "Inorganic Biology"
desc = "The virus can survive and replicate even in an inorganic environment, increasing its resistance and infection rate."
@@ -24,7 +26,8 @@
level = 5
severity = 0
/datum/symptom/inorganic_adaptation/Start(datum/disease/advance/A)
if(!..())
return
A.infectable_biotypes |= MOB_INORGANIC
/datum/symptom/inorganic_adaptation/OnAdd(datum/disease/advance/A)
A.infectable_biotypes |= MOB_INORGANIC
/datum/symptom/inorganic_adaptation/OnRemove(datum/disease/advance/A)
A.infectable_biotypes -= MOB_INORGANIC
@@ -38,11 +38,10 @@
return
CRASH("We couldn't assign an ID!")
// Called when processing of the advance disease, which holds this symptom, starts.
// Called when processing of the advance disease that holds this symptom infects a host and upon each Refresh() of that advance disease.
/datum/symptom/proc/Start(datum/disease/advance/A)
if(neutered)
return FALSE
next_activation = world.time + rand(symptom_delay_min * 10, symptom_delay_max * 10) //so it doesn't instantly activate on infection
return TRUE
// Called when the advance disease is going to be deleted or when the advance disease stops processing.
@@ -60,6 +59,11 @@
next_activation = world.time + rand(symptom_delay_min * 10, symptom_delay_max * 10)
return TRUE
/datum/symptom/proc/on_stage_change(datum/disease/advance/A)
if(neutered)
return FALSE
return TRUE
/datum/symptom/proc/Copy()
var/datum/symptom/new_symp = new type
new_symp.name = name
@@ -69,3 +73,9 @@
/datum/symptom/proc/generate_threshold_desc()
return
/datum/symptom/proc/OnAdd(datum/disease/advance/A) //Overload when a symptom needs to be active before processing, like changing biotypes.
return
/datum/symptom/proc/OnRemove(datum/disease/advance/A) //But dont forget to remove them too.
return