From 9d38bcc149cac1d10cb7a50a3ce59ad22be11320 Mon Sep 17 00:00:00 2001 From: PsiOmegaDelta Date: Wed, 17 Jun 2015 16:01:26 +0200 Subject: [PATCH] mob/living/Life() now handles regular status updates. --- code/modules/mob/living/carbon/alien/life.dm | 3 +- code/modules/mob/living/carbon/brain/life.dm | 16 +------ code/modules/mob/living/carbon/human/life.dm | 17 ++++--- .../modules/mob/living/carbon/metroid/life.dm | 6 +-- code/modules/mob/living/life.dm | 47 +++++++++++++++++++ code/modules/mob/living/living.dm | 12 +++++ code/modules/mob/living/silicon/robot/life.dm | 2 +- code/modules/mob/living/silicon/silicon.dm | 6 +++ code/modules/mob/mob.dm | 6 +++ 9 files changed, 86 insertions(+), 29 deletions(-) diff --git a/code/modules/mob/living/carbon/alien/life.dm b/code/modules/mob/living/carbon/alien/life.dm index fcd5a372d43..a28afc25dcf 100644 --- a/code/modules/mob/living/carbon/alien/life.dm +++ b/code/modules/mob/living/carbon/alien/life.dm @@ -16,7 +16,6 @@ blinded = null //Status updates, death etc. - handle_regular_status_updates() update_icons() /mob/living/carbon/alien/handle_mutations_and_radiation() @@ -35,7 +34,7 @@ adjustToxLoss(-(rads)) return -/mob/living/carbon/alien/proc/handle_regular_status_updates() +/mob/living/carbon/alien/handle_regular_status_updates() if(status_flags & GODMODE) return 0 diff --git a/code/modules/mob/living/carbon/brain/life.dm b/code/modules/mob/living/carbon/brain/life.dm index ca0d1aa1de5..40f709efb5e 100644 --- a/code/modules/mob/living/carbon/brain/life.dm +++ b/code/modules/mob/living/carbon/brain/life.dm @@ -1,20 +1,6 @@ /mob/living/carbon/brain/handle_breathing() return -/mob/living/carbon/brain/Life() - set invisibility = 0 - set background = 1 - ..() - - //Apparently, the person who wrote this code designed it so that - //blinded get reset each cycle and then get activated later in the - //code. Very ugly. I dont care. Moving this stuff here so its easy - //to find it. - blinded = null - - //Status updates, death etc. - handle_regular_status_updates() - /mob/living/carbon/brain/handle_mutations_and_radiation() if (radiation) if (radiation > 100) @@ -108,7 +94,7 @@ return //TODO: DEFERRED -/mob/living/carbon/brain/proc/handle_regular_status_updates() //TODO: comment out the unused bits >_> +/mob/living/carbon/brain/handle_regular_status_updates() //TODO: comment out the unused bits >_> updatehealth() if(stat == DEAD) //DEAD. BROWN BREAD. SWIMMING WITH THE SPESS CARP diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index e9d55414bd1..ac76041fb61 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -87,17 +87,19 @@ handle_stasis_bag() - if(life_tick > 5 && timeofdeath && (timeofdeath < 5 || world.time - timeofdeath > 6000)) //We are long dead, or we're junk mobs spawned like the clowns on the clown shuttle + if(!handle_some_updates()) return //We go ahead and process them 5 times for HUD images and other stuff though. - //Status updates, death etc. - handle_regular_status_updates() //Optimized a bit - //Update our name based on whether our face is obscured/disfigured name = get_visible_name() pulse = handle_pulse() +/mob/living/carbon/human/proc/handle_some_updates() + if(life_tick > 5 && timeofdeath && (timeofdeath < 5 || world.time - timeofdeath > 6000)) //We are long dead, or we're junk mobs spawned like the clowns on the clown shuttle + return 0 + return 1 + /mob/living/carbon/human/breathe() if(!in_stasis) ..() @@ -149,7 +151,7 @@ else return ONE_ATMOSPHERE + pressure_difference -/mob/living/carbon/human/proc/handle_disabilities() +/mob/living/carbon/human/handle_disabilities() if (disabilities & EPILEPSY) if ((prob(1) && paralysis < 1)) src << "\red You have a seizure!" @@ -911,7 +913,10 @@ return //TODO: DEFERRED -/mob/living/carbon/human/proc/handle_regular_status_updates() +/mob/living/carbon/human/handle_regular_status_updates() + if(!handle_some_updates()) + return 0 + if(status_flags & GODMODE) return 0 //SSD check, if a logged player is awake put them back to sleep! diff --git a/code/modules/mob/living/carbon/metroid/life.dm b/code/modules/mob/living/carbon/metroid/life.dm index a04db40e073..73f6913361b 100644 --- a/code/modules/mob/living/carbon/metroid/life.dm +++ b/code/modules/mob/living/carbon/metroid/life.dm @@ -17,10 +17,6 @@ handle_AI() handle_speech_and_mood() - regular_hud_updates() - - handle_regular_status_updates() // Status updates, death etc. - /mob/living/carbon/slime/handle_environment(datum/gas_mixture/environment) if(!environment) adjustToxLoss(rand(10,20)) @@ -91,7 +87,7 @@ return //TODO: DEFERRED -/mob/living/carbon/slime/proc/handle_regular_status_updates() +/mob/living/carbon/slime/handle_regular_status_updates() src.blinded = null diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index 7214f2e18f5..14bdd03a7ae 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -43,6 +43,10 @@ for(var/obj/item/weapon/grab/G in src) G.process() + if(handle_regular_status_updates()) // Status & health update, are we dead or alive etc. + handle_disabilities() // eye, ear, brain damages + handle_status_effects() //all special effects, stunned, weakened, jitteryness, hallucination, sleeping, etc + update_canmove() if(client) @@ -74,6 +78,49 @@ if(incapacitated()) stop_pulling() +//This updates the health and status of the mob (conscious, unconscious, dead) +/mob/living/proc/handle_regular_status_updates() + updatehealth() + if(stat != DEAD) + if(paralysis) + stat = UNCONSCIOUS + else if (status_flags & FAKEDEATH) + stat = UNCONSCIOUS + else + stat = CONSCIOUS + return 1 + +//this updates all special effects: stunned, sleeping, weakened, druggy, stuttering, etc.. +/mob/living/proc/handle_status_effects() + if(paralysis) + paralysis = max(paralysis-1,0) + if(stunned) + stunned = max(stunned-1,0) + if(!stunned) + update_icons() + + if(weakened) + weakened = max(weakened-1,0) + if(!weakened) + update_icons() + +/mob/living/proc/handle_disabilities() + //Eyes + if(disabilities & BLIND || stat) //blindness from disability or unconsciousness doesn't get better on its own + eye_blind = max(eye_blind, 1) + else if(eye_blind) //blindness, heals slowly over time + eye_blind = max(eye_blind-1,0) + else if(eye_blurry) //blurry eyes heal slowly + eye_blurry = max(eye_blurry-1, 0) + + //Ears + if(disabilities & DEAF) //disabled-deaf, doesn't get better on its own + setEarDamage(-1, max(ear_deaf, 1)) + else + // deafness heals slowly over time, unless ear_damage is over 100 + if(ear_damage < 100) + adjustEarDamage(-0.05,-1) + //this handles hud updates. Calls update_vision() and handle_hud_icons() /mob/living/proc/handle_regular_hud_updates() if(!client) return 0 diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index af99441108d..e24fa8a7827 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -800,3 +800,15 @@ default behaviour is: return ..() + +//damage/heal the mob ears and adjust the deaf amount +/mob/living/adjustEarDamage(var/damage, var/deaf) + ear_damage = max(0, ear_damage + damage) + ear_deaf = max(0, ear_deaf + deaf) + +//pass a negative argument to skip one of the variable +/mob/living/setEarDamage(var/damage, var/deaf) + if(damage >= 0) + ear_damage = damage + if(deaf >= 0) + ear_deaf = deaf diff --git a/code/modules/mob/living/silicon/robot/life.dm b/code/modules/mob/living/silicon/robot/life.dm index 6051c9c122e..d86ab2ba2ca 100644 --- a/code/modules/mob/living/silicon/robot/life.dm +++ b/code/modules/mob/living/silicon/robot/life.dm @@ -61,7 +61,7 @@ lights_on = 0 set_light(0) -/mob/living/silicon/robot/proc/handle_regular_status_updates() +/mob/living/silicon/robot/handle_regular_status_updates() if(src.camera && !scrambledcodes) if(src.stat == 2 || wires.IsIndexCut(BORG_WIRE_CAMERA)) diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index de279566784..270f618a852 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -350,3 +350,9 @@ /mob/living/silicon/proc/is_malf_or_traitor() return is_traitor() || is_malf() + +/mob/living/silicon/adjustEarDamage() + return + +/mob/living/silicon/setEarDamage() + return diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 6fba60f97ce..40d39fff322 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1027,3 +1027,9 @@ mob/proc/yank_out_object() /mob/verb/westfaceperm() set hidden = 1 set_face_dir(WEST) + +/mob/proc/adjustEarDamage() + return + +/mob/proc/setEarDamage() + return