From 64ba9ab933ddafbfce0085530914d5c27998915b Mon Sep 17 00:00:00 2001 From: mwerezak Date: Mon, 7 Jul 2014 17:01:15 -0400 Subject: [PATCH] Fixes #5532 and increases the time required for organs to become infected from wounds Also removes the now unnecessary get_cure_threshold() proc, caps the rate at which an organ can receive germs from wounds, and makes germs spread from external to internal organs happen one organ at a time instead of all at once. Conflicts: code/modules/organs/organ_internal.dm code/setup.dm --- code/modules/organs/organ.dm | 8 +----- code/modules/organs/organ_external.dm | 37 +++++++++++++++++++-------- code/modules/organs/organ_internal.dm | 23 +++++++++++++---- code/setup.dm | 23 +++++++++-------- 4 files changed, 58 insertions(+), 33 deletions(-) diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index fb52683bb79..13b45ea53a8 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -18,16 +18,10 @@ return icon('icons/mob/human.dmi',"blank") //Germs -/datum/organ/proc/get_cure_threshold() - //before reaching level three, the amount of spaceacillin required to cure infections scales between 5 and 30 units - //var/germ_scale = max((germ_level - INFECTION_LEVEL_ONE)/(INFECTION_LEVEL_THREE - INFECTION_LEVEL_ONE), 0) - //return min(5 + germ_scale*25, 30) - return 5 //Based on Hubble's suggestion - /datum/organ/proc/handle_antibiotics() var/antibiotics = owner.reagents.get_reagent_amount("spaceacillin") - if (antibiotics <= get_cure_threshold()) + if (antibiotics < 5) return if (germ_level < INFECTION_LEVEL_ONE) diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index 44531006a6e..9142725df85 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -379,13 +379,18 @@ Note that amputating the affected organ does in fact remove the infection from t if (owner.germ_level > W.germ_level && W.infection_check()) W.germ_level++ - //Infected wounds raise the organ's germ level - if (W.germ_level > germ_level && antibiotics < 5) //Badly infected wounds raise internal germ levels - germ_level++ + if (antibiotics < 5) + for(var/datum/wound/W in wounds) + //Infected wounds raise the organ's germ level + if (W.germ_level > germ_level) + germ_level++ + break //limit increase to a maximum of one per second /datum/organ/external/proc/handle_germ_effects() var/antibiotics = owner.reagents.get_reagent_amount("spaceacillin") - var/cure_threshold = get_cure_threshold() + + if (germ_level < INFECTION_LEVEL_ONE & prob(60)) //this could be an else clause, but it looks cleaner this way + germ_level-- //since germ_level increases at a rate of 1 per second with dirty wounds, prob(60) should give us about 5 minutes before level one. if(germ_level >= INFECTION_LEVEL_ONE) //having an infection raises your body temperature @@ -395,17 +400,29 @@ Note that amputating the affected organ does in fact remove the infection from t owner.bodytemperature++ if(prob(round(germ_level/10))) - if (antibiotics < cure_threshold) + if (antibiotics < 5) germ_level++ - if (prob(3)) //adjust this to tweak how fast people take toxin damage from infections + if (prob(5)) //adjust this to tweak how fast people take toxin damage from infections owner.adjustToxLoss(1) - if(germ_level >= INFECTION_LEVEL_TWO && antibiotics < cure_threshold) + if(germ_level >= INFECTION_LEVEL_TWO && antibiotics < 5) //spread the infection + var/datum/organ/internal/target_organ //make internal organs become infected one at a time instead of all at once for (var/datum/organ/internal/I in internal_organs) - if (I.germ_level < germ_level) - I.germ_level++ + if (I.germ_level > 0 && I.germ_level < min(germ_level, INFECTION_LEVEL_TWO)) //once the organ reaches whatever we can give it, or level two, switch to a different one + if (!target_organ || I.germ_level > target_organ.germ_level) //choose the organ with the highest germ_level + target_organ = I + + if (!target_organ) + //figure out which organs we can spread germs to and pick one at random + var/list/candidate_organs = list() + for (var/datum/organ/internal/I in internal_organs) + if (I.germ_level < germ_level) + candidate_organs += I + target_organ = pick(candidate_organs) + + target_organ.germ_level++ if (children) //To child organs for (var/datum/organ/external/child in children) @@ -474,8 +491,8 @@ Note that amputating the affected organ does in fact remove the infection from t // Salving also helps against infection if(W.germ_level > 0 && W.salved && prob(2)) - W.germ_level = 0 W.disinfected = 1 + W.germ_level = 0 // sync the organ's damage with its wounds src.update_damages() diff --git a/code/modules/organs/organ_internal.dm b/code/modules/organs/organ_internal.dm index 0b9795efa70..263253a0560 100644 --- a/code/modules/organs/organ_internal.dm +++ b/code/modules/organs/organ_internal.dm @@ -33,7 +33,6 @@ src.owner = H /datum/organ/internal/process() - //Process infections if (!germ_level) return @@ -49,23 +48,23 @@ //** Handle the effects of infections var/antibiotics = owner.reagents.get_reagent_amount("spaceacillin") + if (germ_level < INFECTION_LEVEL_ONE/2 && prob(60)) + germ_level-- + if (germ_level >= INFECTION_LEVEL_ONE/2) //aiming for germ level to go from ambient to INFECTION_LEVEL_TWO in an average of 15 minutes if(antibiotics < 5 && prob(round(germ_level/6))) germ_level++ - if(prob(1)) - take_damage(1,silent=prob(60)) if (germ_level >= INFECTION_LEVEL_TWO) var/datum/organ/external/parent = owner.get_organ(parent_organ) //spread germs - if (antibiotics < get_cure_threshold() && parent.germ_level < germ_level && ( parent.germ_level < INFECTION_LEVEL_ONE*2 || prob(30) )) + if (antibiotics < 5 && parent.germ_level < germ_level && ( parent.germ_level < INFECTION_LEVEL_ONE*2 || prob(30) )) parent.germ_level++ if (prob(3)) //about once every 30 seconds take_damage(1,silent=prob(30)) - /datum/organ/internal/proc/take_damage(amount, var/silent=0) if(src.robotic == 2) src.damage += amount * 0.8 @@ -125,6 +124,11 @@ parent_organ = "chest" process() + ..() + if (germ_level > INFECTION_LEVEL_ONE) + if(prob(1)) + owner.emote("cough") //respitory tract infection + if(is_bruised()) if(prob(2)) spawn owner.emote("me", 1, "coughs up blood!") @@ -139,6 +143,14 @@ var/process_accuracy = 10 process() + ..() + if (germ_level > INFECTION_LEVEL_ONE) + if(prob(1)) + owner << "\red Your skin itches." + if (germ_level > INFECTION_LEVEL_TWO) + if(prob(1)) + spawn owner.vomit() + if(owner.life_tick % process_accuracy == 0) if(src.damage < 0) src.damage = 0 @@ -183,6 +195,7 @@ parent_organ = "head" process() //Eye damage replaces the old eye_stat var. + ..() if(is_bruised()) owner.eye_blurry = 20 if(is_broken()) diff --git a/code/setup.dm b/code/setup.dm index 81133e7f972..9c9eace6cf6 100644 --- a/code/setup.dm +++ b/code/setup.dm @@ -852,6 +852,18 @@ var/list/RESTRICTED_CAMERA_NETWORKS = list( //Those networks can only be accesse +/* + Germs and infections +*/ + +#define GERM_LEVEL_AMBIENT 110 //maximum germ level you can reach by standing still +#define GERM_LEVEL_MOVE_CAP 200 //maximum germ level you can reach by running around + +#define INFECTION_LEVEL_ONE 100 +#define INFECTION_LEVEL_TWO 500 +#define INFECTION_LEVEL_THREE 1000 + + /* Shuttles */ @@ -868,17 +880,6 @@ var/list/RESTRICTED_CAMERA_NETWORKS = list( //Those networks can only be accesse #define SHUTTLE_WARMUP 1 #define SHUTTLE_INTRANSIT 2 -/* - Germs and infections -*/ - -#define GERM_LEVEL_AMBIENT 110 //maximum germ level you can reach by standing still -#define GERM_LEVEL_MOVE_CAP 200 //maximum germ level you can reach by running around - -#define INFECTION_LEVEL_ONE 100 -#define INFECTION_LEVEL_TWO 500 -#define INFECTION_LEVEL_THREE 1500 - //Ferry shuttle processing status #define IDLE_STATE 0 #define WAIT_LAUNCH 1