diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm index 4611dda0d8..6926adde9b 100644 --- a/code/modules/mob/living/carbon/human/human_defines.dm +++ b/code/modules/mob/living/carbon/human/human_defines.dm @@ -53,7 +53,10 @@ var/failed_last_breath = 0 //This is used to determine if the mob failed a breath. If they did fail a brath, they will attempt to breathe each tick, otherwise just once per 4 ticks. + var/last_dam = -1 //Used for determining if we need to process all organs or just some or even none. + var/list/bad_external_organs = list()// organs we check until they are good. + var/xylophone = 0 //For the spoooooooky xylophone cooldown var/mob/remoteview_target = null - var/hand_blood_color \ No newline at end of file + var/hand_blood_color diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index b80c848bfa..9009cbf2db 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -997,8 +997,8 @@ else //ALIVE. LIGHTS ARE ON updatehealth() //TODO if(!in_stasis) - handle_organs() - handle_blood() + handle_organs() //Optimized. + handle_blood() if(health <= config.health_threshold_dead || brain_op_stage == 4.0) death() @@ -1109,20 +1109,21 @@ if(stuttering) stuttering = max(stuttering-1, 0) - if (src.slurring) + if (slurring) slurring = max(slurring-1, 0) if(silent) silent = max(silent-1, 0) if(druggy) druggy = max(druggy-1, 0) - +/* // Increase germ_level regularly if(prob(40)) germ_level += 1 // If you're dirty, your gloves will become dirty, too. if(gloves && germ_level > gloves.germ_level && prob(10)) gloves.germ_level += 1 +*/ return 1 proc/handle_regular_hud_updates() diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index eec57edea9..3e169f22b6 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -69,54 +69,70 @@ /mob/living/carbon/human/proc/handle_organs() number_wounds = 0 var/leg_tally = 2 - for(var/datum/organ/external/E in organs) + var/force_process = 0 + var/damage_this_tick = getBruteLoss() + getFireLoss() + getToxLoss() + if(damage_this_tick > last_dam) + force_process = 1 + last_dam = damage_this_tick + if(!force_process && !bad_external_organs.len) + return + if(force_process) + bad_external_organs.Cut() + for(var/datum/organ/external/Ex in organs) + bad_external_organs += Ex + + for(var/datum/organ/external/E in bad_external_organs) if(!E) continue - E.process() - number_wounds += E.number_wounds + if(!E.need_process()) + bad_external_organs -= E + continue + else + E.process() + number_wounds += E.number_wounds - //Robotic limb malfunctions - var/malfunction = 0 - if (E.status & ORGAN_ROBOT && prob(E.brute_dam + E.burn_dam)) - malfunction = 1 + //Robotic limb malfunctions + var/malfunction = 0 + if (E.status & ORGAN_ROBOT && prob(E.brute_dam + E.burn_dam)) + malfunction = 1 - //Broken limbs hurt too - var/broken = 0 - if(E.status & ORGAN_BROKEN && !(E.status & ORGAN_SPLINTED) ) - broken = 1 + //Broken limbs hurt too + var/broken = 0 + if(E.status & ORGAN_BROKEN && !(E.status & ORGAN_SPLINTED) ) + broken = 1 - //Moving around with fractured ribs won't do you any good - if (broken && E.internal_organs && prob(15)) - if (!lying && world.timeofday - l_move_time < 15) - var/datum/organ/internal/I = pick(E.internal_organs) - custom_pain("You feel broken bones moving in your [E.display_name]!", 1) - I.take_damage(rand(3,5)) + //Moving around with fractured ribs won't do you any good + if (broken && E.internal_organs && prob(15)) + if (!lying && world.timeofday - l_move_time < 15) + var/datum/organ/internal/I = pick(E.internal_organs) + custom_pain("You feel broken bones moving in your [E.display_name]!", 1) + I.take_damage(rand(3,5)) - //Special effects for limbs. - 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 - if(E.name == "r_hand" || E.name == "r_arm") - c_hand = r_hand + //Special effects for limbs. + 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 + if(E.name == "r_hand" || E.name == "r_arm") + c_hand = r_hand - if (c_hand) - u_equip(c_hand) + if (c_hand) + u_equip(c_hand) - if(broken) - emote("me", 1, "[(species && species.flags & NO_PAIN) ? "" : "screams in pain and"] drops what they were holding in their [E.display_name?"[E.display_name]":"[E]"]!") - if(malfunction) - emote("me", 1, "drops what they were holding, their [E.display_name?"[E.display_name]":"[E]"] malfunctioning!") - var/datum/effect/effect/system/spark_spread/spark_system = new /datum/effect/effect/system/spark_spread() - spark_system.set_up(5, 0, src) - spark_system.attach(src) - spark_system.start() - spawn(10) - del(spark_system) + if(broken) + emote("me", 1, "[(species && species.flags & NO_PAIN) ? "" : "screams in pain and"] drops what they were holding in their [E.display_name?"[E.display_name]":"[E]"]!") + if(malfunction) + emote("me", 1, "drops what they were holding, their [E.display_name?"[E.display_name]":"[E]"] malfunctioning!") + var/datum/effect/effect/system/spark_spread/spark_system = new /datum/effect/effect/system/spark_spread() + spark_system.set_up(5, 0, src) + spark_system.attach(src) + spark_system.start() + spawn(10) + del(spark_system) - else if(E.name in list("l_leg","l_foot","r_leg","r_foot") && !lying) - if (!E.is_usable() || malfunction || (broken && !(E.status & ORGAN_SPLINTED))) - leg_tally-- // let it fail even if just foot&leg + else if(E.name in list("l_leg","l_foot","r_leg","r_foot") && !lying) + if (!E.is_usable() || malfunction || (broken && !(E.status & ORGAN_SPLINTED))) + leg_tally-- // let it fail even if just foot&leg // standing is poor if(leg_tally <= 0 && !paralysis && !(lying || resting) && prob(5)) @@ -124,7 +140,7 @@ emote("scream") emote("collapse") paralysis = 10 - + //Check arms and legs for existence can_stand = 2 //can stand on both legs var/datum/organ/external/E = organs_by_name["l_foot"] diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index 27d8db993f..28c2324bae 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -12,6 +12,7 @@ var/burn_dam = 0 var/max_damage = 0 var/max_size = 0 + var/last_dam = -1 var/display_name var/list/wounds = list() @@ -273,6 +274,19 @@ This function completely restores a damaged organ to perfect condition. PROCESSING & UPDATING ****************************************************/ +//Determines if we even need to process this organ. + +/datum/organ/external/proc/need_process() + if(status && status != ORGAN_ROBOT) // If it's robotic, that's fine it will have a status. + return 1 + if(brute_dam || burn_dam) + return 1 + if(last_dam != brute_dam + burn_dam) // Process when we are fully healed up. + last_dam = brute_dam + burn_dam + return 1 + last_dam = brute_dam + burn_dam + return 0 + /datum/organ/external/process() // Process wounds, doing healing etc. Only do this every few ticks to save processing power if(owner.life_tick % wound_update_accuracy == 0)