From 1648c69f9d4ec522b23deabe9b9e3619becd1791 Mon Sep 17 00:00:00 2001 From: cib Date: Tue, 12 Feb 2013 16:19:39 +0100 Subject: [PATCH 1/4] Implemented medical side-effects. --- baystation12.dme | 1 + code/WorkInProgress/Cib/MedicalSideEffects.dm | 64 +++++++++++++++++++ code/modules/mob/living/carbon/human/life.dm | 2 + code/modules/reagents/Chemistry-Reagents.dm | 1 + 4 files changed, 68 insertions(+) create mode 100644 code/WorkInProgress/Cib/MedicalSideEffects.dm diff --git a/baystation12.dme b/baystation12.dme index 8216e5f77c7..c09a3896260 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1431,6 +1431,7 @@ #include "code\WorkInProgress\Cael_Aislinn\Supermatter\SuperMatter.dm" #include "code\WorkInProgress\Cael_Aislinn\Supermatter\ZeroPointLaser.dm" #include "code\WorkInProgress\Chinsky\ashtray.dm" +#include "code\WorkInProgress\Cib\MedicalSideEffects.dm" #include "code\WorkInProgress\Mini\ATM.dm" #include "code\WorkInProgress\Ported\policetape.dm" #include "code\WorkInProgress\SkyMarshal\Ultralight_procs.dm" diff --git a/code/WorkInProgress/Cib/MedicalSideEffects.dm b/code/WorkInProgress/Cib/MedicalSideEffects.dm new file mode 100644 index 00000000000..fa096ef1a96 --- /dev/null +++ b/code/WorkInProgress/Cib/MedicalSideEffects.dm @@ -0,0 +1,64 @@ +// MEDICAL SIDE EFFECT BASE +// ======================== +/datum/medical_effect/var/name = "None" +/datum/medical_effect/var/strength = 0 +/datum/medical_effect/proc/on_life(mob/living/carbon/human/H, strength) +/datum/medical_effect/proc/cure(mob/living/carbon/human/H) + + +// MOB HELPERS +// =========== +/mob/living/carbon/human/var/list/datum/medical_effect/side_effects = list() +/mob/proc/add_side_effect(name, strength = 0) +/mob/living/carbon/human/add_side_effect(name, strength = 0) + for(var/datum/medical_effect/M in src.side_effects) if(M.name == name) + M.strength = max(M.strength, strength = 10) + return + + var/list/L = typesof(/datum/medical_effect)-/datum/medical_effect + + for(var/T in L) + var/datum/medical_effect/M = new L + if(M.name == name) + M.strength = strength + side_effects += M + +/mob/living/carbon/human/proc/handle_medical_side_effects() + // Only process every 30 ticks + if(life_tick % 30 == 0) + // One full cycle(in terms of strength) every 10 minutes + var/strength_percent = sin(life_tick / 600) + + // Only do anything if the effect is currently strong enough + if(strength_percent >= 0.7) + for (var/datum/medical_effect/M in side_effects) + if (M.cure()) + side_effects -= M + del(M) + else + M.on_life(src, 0.7*M.strength) + // Effect slowly growing stronger + M.strength++ + +// HEADACHE +// ======== +/datum/medical_effect/headache/name = "Headache" +/datum/medical_effect/headache/on_life(mob/living/carbon/human/H, strength) + switch(strength) + if(1 to 10) + H.custom_pain("You feel a light pain in your head.",0) + if(11 to 30) + H.custom_pain("You feel a throbbing pain in your head!",1) + if(31 to 99) + H.custom_pain("You feel an excrutiating pain in your head!",1) + H.adjustBrainLoss(1) + if(99 to INFINITY) + H.custom_pain("It feels like your head is about to split open!",1) + H.adjustBrainLoss(3) + var/datum/organ/external/O = H.organs_by_name["head"] + O.take_damage(0, 1, 0, "Headache") + +/datum/medical_effect/headache/cure(mob/living/carbon/human/H) + if(H.reagents.has_reagent("alkysine")) + return 1 + return 0 \ No newline at end of file diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 1fb111b9ed8..8a74afc08e4 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -99,6 +99,8 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 handle_pain() + handle_medical_side_effects() + //Status updates, death etc. handle_regular_status_updates() //TODO: optimise ~Carn update_canmove() diff --git a/code/modules/reagents/Chemistry-Reagents.dm b/code/modules/reagents/Chemistry-Reagents.dm index acec96cba7c..623e45c6cd1 100644 --- a/code/modules/reagents/Chemistry-Reagents.dm +++ b/code/modules/reagents/Chemistry-Reagents.dm @@ -1501,6 +1501,7 @@ datum return if(!M) M = holder.my_atom M.heal_organ_damage(2*REM,0) + M.add_side_effect("Headache") ..() return From 3f04c7ae991a67518ae91fd1a59cf389066beea0 Mon Sep 17 00:00:00 2001 From: cib Date: Tue, 12 Feb 2013 16:38:44 +0100 Subject: [PATCH 2/4] Bugfix for medical side effects. --- code/WorkInProgress/Cib/MedicalSideEffects.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/WorkInProgress/Cib/MedicalSideEffects.dm b/code/WorkInProgress/Cib/MedicalSideEffects.dm index fa096ef1a96..8f0fc6291f8 100644 --- a/code/WorkInProgress/Cib/MedicalSideEffects.dm +++ b/code/WorkInProgress/Cib/MedicalSideEffects.dm @@ -18,7 +18,7 @@ var/list/L = typesof(/datum/medical_effect)-/datum/medical_effect for(var/T in L) - var/datum/medical_effect/M = new L + var/datum/medical_effect/M = new T if(M.name == name) M.strength = strength side_effects += M From 1ed5c7ec3718be977bc7ef24ec5b4fcacf8af56e Mon Sep 17 00:00:00 2001 From: cib Date: Tue, 12 Feb 2013 16:57:33 +0100 Subject: [PATCH 3/4] Previously your nanotrasen loyalty setting wouldn't save. --- code/modules/client/preferences_savefile.dm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 80d5e718df0..5727e7b671e 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -143,6 +143,8 @@ S["skills"] >> skills S["skill_specialization"] >> skill_specialization S["organ_data"] >> organ_data + + S["nanotrasen_relation"] >> nanotrasen_relation //S["skin_style"] >> skin_style //Sanitize @@ -238,6 +240,8 @@ S["skills"] << skills S["skill_specialization"] << skill_specialization S["organ_data"] << organ_data + + S["nanotrasen_relation"] << nanotrasen_relation //S["skin_style"] << skin_style return 1 From 7a0c37867ad1eb5e7edf6cbf5ff1ba9f139ed68f Mon Sep 17 00:00:00 2001 From: cib Date: Tue, 12 Feb 2013 17:14:10 +0100 Subject: [PATCH 4/4] Adjusted medical side effect strength. --- code/WorkInProgress/Cib/MedicalSideEffects.dm | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/code/WorkInProgress/Cib/MedicalSideEffects.dm b/code/WorkInProgress/Cib/MedicalSideEffects.dm index 8f0fc6291f8..eb23d21b141 100644 --- a/code/WorkInProgress/Cib/MedicalSideEffects.dm +++ b/code/WorkInProgress/Cib/MedicalSideEffects.dm @@ -24,21 +24,20 @@ side_effects += M /mob/living/carbon/human/proc/handle_medical_side_effects() - // Only process every 30 ticks - if(life_tick % 30 == 0) - // One full cycle(in terms of strength) every 10 minutes - var/strength_percent = sin(life_tick / 600) + // One full cycle(in terms of strength) every 10 minutes + var/strength_percent = sin(life_tick / 300) - // Only do anything if the effect is currently strong enough - if(strength_percent >= 0.7) - for (var/datum/medical_effect/M in side_effects) - if (M.cure()) - side_effects -= M - del(M) - else - M.on_life(src, 0.7*M.strength) - // Effect slowly growing stronger - M.strength++ + // Only do anything if the effect is currently strong enough + if(strength_percent >= 0.4) + for (var/datum/medical_effect/M in side_effects) + if (M.cure()) + side_effects -= M + del(M) + else + if(life_tick % 30 == 0) + M.on_life(src, strength_percent*M.strength) + // Effect slowly growing stronger + M.strength+=0.2 // HEADACHE // ========