From a90888b85181ba74dab9145093864d3fc0889736 Mon Sep 17 00:00:00 2001 From: Chinsky Date: Fri, 8 Nov 2013 02:10:20 +0400 Subject: [PATCH 1/5] Missed last debug line --- 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 c11f62a78e..2d0b8b6ba8 100644 --- a/code/WorkInProgress/Cib/MedicalSideEffects.dm +++ b/code/WorkInProgress/Cib/MedicalSideEffects.dm @@ -64,7 +64,7 @@ // Only do anything if the effect is currently strong enough if(strength_percent >= 0.4) - log_debug ("[src], tick [life_tick] : Active phase ; strength [M.strength]") +// log_debug ("[src], tick [life_tick] : Active phase ; strength [M.strength]") if (M.cure(src) || M.strength > 50) // log_debug ("[src], tick [life_tick] : [M] cured or reached end of lifecycle") side_effects -= M From 8b89b542330bf07904f1148340b757a7017abbb8 Mon Sep 17 00:00:00 2001 From: Chinsky Date: Fri, 8 Nov 2013 03:18:25 +0400 Subject: [PATCH 2/5] Caches side effect types to a global list, less loops on addition. Makes them process only every 15 ticks, to cut down on the calls. Removes damage because it was supposed to be gone, no idea why I didn't delete the lines. --- code/WorkInProgress/Cib/MedicalSideEffects.dm | 32 +++++++++---------- code/__HELPERS/global_lists.dm | 8 +++++ 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/code/WorkInProgress/Cib/MedicalSideEffects.dm b/code/WorkInProgress/Cib/MedicalSideEffects.dm index 2d0b8b6ba8..15580c4bd2 100644 --- a/code/WorkInProgress/Cib/MedicalSideEffects.dm +++ b/code/WorkInProgress/Cib/MedicalSideEffects.dm @@ -23,7 +23,8 @@ /datum/medical_effect/proc/cure(mob/living/carbon/human/H) for(var/R in cures) if(H.reagents.has_reagent(R)) - H <<"\red [cure_message]" + if (cure_message) + H <<"\blue [cure_message]" return 1 return 0 @@ -39,16 +40,21 @@ M.start = life_tick return - var/list/L = typesof(/datum/medical_effect)-/datum/medical_effect - for(var/T in L) - var/datum/medical_effect/M = new T - if(M.name == name) - M.strength = strength - M.start = life_tick - side_effects += M + var/T = side_effects[name] + if (!T) + return + + var/datum/medical_effect/M = new T + if(M.name == name) + M.strength = strength + M.start = life_tick + side_effects += M /mob/living/carbon/human/proc/handle_medical_side_effects() + //Going to handle those things only every few ticks. + if(life_tick % 15 != 0) + return 0 var/list/L = typesof(/datum/medical_effect)-/datum/medical_effect for(var/T in L) @@ -60,18 +66,14 @@ for (var/datum/medical_effect/M in side_effects) if (!M) continue var/strength_percent = sin((life_tick - M.start) / 2) -// log_debug ("[src], tick [life_tick] : Processing [M], Current phase: [strength_percent]") // Only do anything if the effect is currently strong enough if(strength_percent >= 0.4) -// log_debug ("[src], tick [life_tick] : Active phase ; strength [M.strength]") if (M.cure(src) || M.strength > 50) -// log_debug ("[src], tick [life_tick] : [M] cured or reached end of lifecycle") side_effects -= M - del(M) + M = null else if(life_tick % 45 == 0) -// log_debug ("[src], tick [life_tick] : Activating [M] ") M.on_life(src, strength_percent*M.strength) // Effect slowly growing stronger M.strength+=0.08 @@ -92,7 +94,6 @@ H.custom_pain("You feel a throbbing pain in your head!",1) if(31 to INFINITY) H.custom_pain("You feel an excrutiating pain in your head!",1) - H.adjustBrainLoss(1) // BAD STOMACH // =========== @@ -110,7 +111,6 @@ H.custom_pain("Your stomach hurts.",0) if(31 to INFINITY) H.custom_pain("You feel sick.",1) - H.adjustToxLoss(1) // CRAMPS // ====== @@ -129,7 +129,6 @@ if(31 to INFINITY) H.emote("me",1,"flinches as all the muscles in their body cramp up.") H.custom_pain("There's pain all over your body.",1) - H.adjustToxLoss(1) // ITCH // ==== @@ -148,4 +147,3 @@ if(31 to INFINITY) H.emote("me",1,"shivers slightly.") H.custom_pain("This itch makes it really hard to concentrate.",1) - H.adjustToxLoss(1) \ No newline at end of file diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index 956e6be255..9625d9c716 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -15,6 +15,7 @@ var/global/list/chemical_reactions_list //list of all /datum/chemical_reactio var/global/list/chemical_reagents_list //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff var/global/list/landmarks_list = list() //list of all landmarks created var/global/list/surgery_steps = list() //list of all surgery steps |BS12 +var/global/list/side_effects = list() //list of all medical sideeffects types by thier names |BS12 var/global/list/mechas_list = list() //list of all mechs. Used by hostile mobs target tracking. //Languages/species/whitelist. @@ -75,6 +76,13 @@ var/global/list/backbaglist = list("Nothing", "Backpack", "Satchel", "Satchel Al surgery_steps += S sort_surgeries() + //Medical side effects. List all effects by their names + paths = typesof(/datum/medical_effect)-/datum/medical_effect + for(var/T in paths) + var/datum/medical_effect/M = new T + side_effects[S.name] = T + + //Languages and species. paths = typesof(/datum/language)-/datum/language for(var/T in paths) From 6d369caae7b972cacac7ed2b87ee90ef62012ab7 Mon Sep 17 00:00:00 2001 From: Chinsky Date: Fri, 8 Nov 2013 03:55:22 +0400 Subject: [PATCH 3/5] Replaces long check with lots of get_organ calls with shorter one. Also changed weird condition that amputated leg must not be splinted. Removed checks for haslimbs, since movement while downed is not possible anyway. Moved some special effects for broken limbs after check for such, so healthy ones wont bother. Fixed a derp in populating the global list of sideffects. --- code/__HELPERS/global_lists.dm | 2 +- code/modules/organs/organ.dm | 43 +++++++--------------------------- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index 9625d9c716..ce8d788f25 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -80,7 +80,7 @@ var/global/list/backbaglist = list("Nothing", "Backpack", "Satchel", "Satchel Al paths = typesof(/datum/medical_effect)-/datum/medical_effect for(var/T in paths) var/datum/medical_effect/M = new T - side_effects[S.name] = T + side_effects[M.name] = T //Languages and species. diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index 45828edc2a..33ce1131c5 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -91,7 +91,7 @@ I.take_damage(rand(3,5)) //Special effects for limbs. - if(E.name in list("l_hand","l_arm","r_hand","r_arm")) + if(E.name in list("l_hand","l_arm","r_hand","r_arm") && (broken||malfunction)) var/obj/item/c_hand //Getting what's in this hand if(E.name == "l_hand" || E.name == "l_arm") c_hand = l_hand @@ -99,8 +99,7 @@ c_hand = r_hand if (c_hand) - if (broken||malfunction) - u_equip(c_hand) + u_equip(c_hand) if(broken) emote("me", 1, "screams in pain and drops what they were holding in their [E.display_name?"[E.display_name]":"[E]"]!") @@ -124,35 +123,11 @@ paralysis = 10 //Check arms and legs for existence - var/canstand_l = 1 //Can stand on left leg - var/canstand_r = 1 //Can stand on right leg - var/hasleg_l = 1 //Have left leg - var/hasleg_r = 1 //Have right leg - var/hasarm_l = 1 //Have left arm - var/hasarm_r = 1 //Have right arm - var/datum/organ/external/E - E = get_organ("l_leg") - if(E.status & ORGAN_DESTROYED && !(E.status & ORGAN_SPLINTED)) - canstand_l = 0 - hasleg_l = 0 - E = get_organ("r_leg") - if(E.status & ORGAN_DESTROYED && !(E.status & ORGAN_SPLINTED)) - canstand_r = 0 - hasleg_r = 0 - E = get_organ("l_foot") - if(E.status & ORGAN_DESTROYED && !(E.status & ORGAN_SPLINTED)) - canstand_l = 0 - E = get_organ("r_foot") - if(E.status & ORGAN_DESTROYED && !(E.status & ORGAN_SPLINTED)) - canstand_r = 0 - E = get_organ("l_arm") - if(E.status & ORGAN_DESTROYED && !(E.status & ORGAN_SPLINTED)) - hasarm_l = 0 - E = get_organ("r_arm") - if(E.status & ORGAN_DESTROYED && !(E.status & ORGAN_SPLINTED)) - hasarm_r = 0 + can_stand = 2 //can stand on both legs + var/datum/organ/external/E = organs_by_name["l_foot"] + if(E.status & ORGAN_DESTROYED) + can_stand-- - // Can stand if have at least one full leg (with leg and foot parts present) - // Has limbs to move around if at least one arm or leg is at least partially there - can_stand = canstand_l||canstand_r - has_limbs = hasleg_l||hasleg_r||hasarm_l||hasarm_r + E = organs_by_name["r_foot"] + if(E.status & ORGAN_DESTROYED) + can_stand-- From 3992888ea6f0fafda363c73ee11488d1d28e808c Mon Sep 17 00:00:00 2001 From: Chinsky Date: Fri, 8 Nov 2013 04:34:37 +0400 Subject: [PATCH 4/5] removed some unneeded icon update calls (haha totally unneeded yeah) replaced complete regenerate_icons with just body_update in case of dropping limb --- code/modules/organs/organ_external.dm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index e3488a7cbe..4a182962c5 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -415,10 +415,6 @@ This function completely restores a damaged organ to perfect condition. var/n_is = damage_state_text() if (n_is != damage_state) damage_state = n_is - if(status & ORGAN_DESTROYED) - owner.update_body(1) - else - owner.UpdateDamageIcon(1) return 1 return 0 @@ -550,7 +546,7 @@ This function completely restores a damaged organ to perfect condition. var/lol = pick(cardinal) step(organ,lol) - owner.regenerate_icons() + owner.update_body(1) /**************************************************** From d1be0cba0b13226a4650e789911260a0040677c4 Mon Sep 17 00:00:00 2001 From: Chinsky Date: Fri, 8 Nov 2013 08:10:50 +0400 Subject: [PATCH 5/5] Healing wounds should properly update damage overlay if needed. --- code/modules/organs/organ_external.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index 4a182962c5..14171bd869 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -203,7 +203,6 @@ This function completely restores a damaged organ to perfect condition. implants -= implanted_object owner.updatehealth() - update_icon() /datum/organ/external/proc/createwound(var/type = CUT, var/damage) @@ -290,7 +289,6 @@ This function completely restores a damaged organ to perfect condition. perma_injury = 0 update_germs() - update_icon() return //Updating germ levels. Handles organ germ levels and necrosis. @@ -383,6 +381,8 @@ This function completely restores a damaged organ to perfect condition. // sync the organ's damage with its wounds src.update_damages() + if (update_icon()) + owner.UpdateDamageIcon(1) //Updates brute_damn and burn_damn from wound damages. Updates BLEEDING status. /datum/organ/external/proc/update_damages()