From c3de9ca3c727974582365b28fd3010ea410c0876 Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Mon, 11 Aug 2014 09:15:28 +0200 Subject: [PATCH] Fixes #5946 and cuts down on duplicate code across Life() procs. --- .../mob/living/carbon/alien/humanoid/life.dm | 22 +++------- .../mob/living/carbon/alien/larva/life.dm | 15 +------ code/modules/mob/living/carbon/brain/life.dm | 15 +------ code/modules/mob/living/carbon/human/life.dm | 39 +++++++++-------- code/modules/mob/living/carbon/monkey/life.dm | 15 +------ code/modules/mob/living/silicon/ai/life.dm | 3 +- code/modules/mob/living/silicon/pai/life.dm | 1 + .../mob/living/simple_animal/simple_animal.dm | 9 ++-- code/modules/mob/mob.dm | 43 +++++++++++++++++++ 9 files changed, 77 insertions(+), 85 deletions(-) diff --git a/code/modules/mob/living/carbon/alien/humanoid/life.dm b/code/modules/mob/living/carbon/alien/humanoid/life.dm index 15ff3dd7218..defcc968d13 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/life.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/life.dm @@ -357,22 +357,7 @@ ear_damage = max(ear_damage-0.05, 0) //Other - if(stunned) - AdjustStunned(-1) - if(!stunned) - update_icons() - - if(weakened) - weakened = max(weakened-1,0) //before you get mad Rockdtben: I done this so update_canmove isn't called multiple times - - if(stuttering) - stuttering = max(stuttering-1, 0) - - if(silent) - silent = max(silent-1, 0) - - if(druggy) - druggy = max(druggy-1, 0) + handle_statuses() return 1 @@ -461,3 +446,8 @@ if(!(status_flags & GODMODE)) M.adjustBruteLoss(5) nutrition += 10 + +/mob/living/carbon/alien/humanoid/handle_stunned() + if(stunned && !..()) + update_icons() + return stunned diff --git a/code/modules/mob/living/carbon/alien/larva/life.dm b/code/modules/mob/living/carbon/alien/larva/life.dm index cc9dbaea988..9bb6ae43767 100644 --- a/code/modules/mob/living/carbon/alien/larva/life.dm +++ b/code/modules/mob/living/carbon/alien/larva/life.dm @@ -274,20 +274,7 @@ FUCK YOU MORE FAT CODE -Hawk*/ ear_damage = max(ear_damage-0.05, 0) //Other - if(stunned) - AdjustStunned(-1) - - if(weakened) - weakened = max(weakened-1,0) //before you get mad Rockdtben: I done this so update_canmove isn't called multiple times - - if(stuttering) - stuttering = max(stuttering-1, 0) - - if(silent) - silent = max(silent-1, 0) - - if(druggy) - druggy = max(druggy-1, 0) + handle_statuses() return 1 diff --git a/code/modules/mob/living/carbon/brain/life.dm b/code/modules/mob/living/carbon/brain/life.dm index 1943242bce2..89cf9faa971 100644 --- a/code/modules/mob/living/carbon/brain/life.dm +++ b/code/modules/mob/living/carbon/brain/life.dm @@ -186,20 +186,7 @@ emp_damage -= 1 //Other - if(stunned) - AdjustStunned(-1) - - if(weakened) - weakened = max(weakened-1,0) //before you get mad Rockdtben: I done this so update_canmove isn't called multiple times - - if(stuttering) - stuttering = max(stuttering-1, 0) - - if(silent) - silent = max(silent-1, 0) - - if(druggy) - druggy = max(druggy-1, 0) + handle_statuses() return 1 diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 0aff39fe285..8f7837bd99a 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1180,25 +1180,7 @@ ear_damage = max(ear_damage-0.05, 0) //Other - if(stunned) - speech_problem_flag = 1 - AdjustStunned(-1) - - if(weakened) - weakened = max(weakened-1,0) //before you get mad Rockdtben: I done this so update_canmove isn't called multiple times - - if(stuttering) - speech_problem_flag = 1 - stuttering = max(stuttering-1, 0) - if (slurring) - speech_problem_flag = 1 - slurring = max(slurring-1, 0) - if(silent) - speech_problem_flag = 1 - silent = max(silent-1, 0) - - if(druggy) - druggy = max(druggy-1, 0) + handle_statuses() // If you're dirty, your gloves will become dirty, too. if(gloves && germ_level > gloves.germ_level && prob(10)) @@ -1826,6 +1808,25 @@ hud_list[SPECIALROLE_HUD] = holder hud_updateflag = 0 +/mob/living/carbon/human/handle_silent() + if(..()) + speech_problem_flag = 1 + return silent + +/mob/living/carbon/human/handle_slurring() + if(..()) + speech_problem_flag = 1 + return slurring + +/mob/living/carbon/human/handle_stunned() + if(..()) + speech_problem_flag = 1 + return stunned + +/mob/living/carbon/human/handle_stuttering() + if(..()) + speech_problem_flag = 1 + return stuttering #undef HUMAN_MAX_OXYLOSS #undef HUMAN_CRIT_MAX_OXYLOSS diff --git a/code/modules/mob/living/carbon/monkey/life.dm b/code/modules/mob/living/carbon/monkey/life.dm index 091c5630301..08bd3cd97e9 100644 --- a/code/modules/mob/living/carbon/monkey/life.dm +++ b/code/modules/mob/living/carbon/monkey/life.dm @@ -555,20 +555,7 @@ ear_damage = max(ear_damage-0.05, 0) //Other - if(stunned) - AdjustStunned(-1) - - if(weakened) - weakened = max(weakened-1,0) //before you get mad Rockdtben: I done this so update_canmove isn't called multiple times - - if(stuttering) - stuttering = max(stuttering-1, 0) - - if(silent) - silent = max(silent-1, 0) - - if(druggy) - druggy = max(druggy-1, 0) + handle_statuses() return 1 diff --git a/code/modules/mob/living/silicon/ai/life.dm b/code/modules/mob/living/silicon/ai/life.dm index 17f273e9660..d0c6c767fcf 100644 --- a/code/modules/mob/living/silicon/ai/life.dm +++ b/code/modules/mob/living/silicon/ai/life.dm @@ -36,8 +36,7 @@ adjustOxyLoss(-1) // Handle EMP-stun - if(stunned) - AdjustStunned(-1) + handle_stunned() //stage = 1 //if (istype(src, /mob/living/silicon/ai)) // Are we not sure what we are? diff --git a/code/modules/mob/living/silicon/pai/life.dm b/code/modules/mob/living/silicon/pai/life.dm index 2ed190fc060..cebdf2a5359 100644 --- a/code/modules/mob/living/silicon/pai/life.dm +++ b/code/modules/mob/living/silicon/pai/life.dm @@ -17,6 +17,7 @@ if(world.timeofday >= silence_time) silence_time = null src << "Communication circuit reinitialized. Speech and messaging functionality restored." + handle_statuses() /mob/living/silicon/pai/updatehealth() if(status_flags & GODMODE) diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 628534e75b1..5abbe38e28e 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -87,12 +87,9 @@ if(health > maxHealth) health = maxHealth - if(stunned) - AdjustStunned(-1) - if(weakened) - AdjustWeakened(-1) - if(paralysis) - AdjustParalysis(-1) + handle_stunned() + handle_weakened() + handle_paralysed() //Movement if(!client && !stop_automated_movement && wander && !anchored) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 5a5fda48e32..8887fefd15e 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -991,3 +991,46 @@ mob/proc/yank_out_object() if(!pinned.len) anchored = 0 return 1 + +/mob/living/proc/handle_statuses() + handle_stunned() + handle_weakened() + handle_stuttering() + handle_silent() + handle_drugged() + handle_slurring() + +/mob/living/proc/handle_stunned() + if(stunned) + AdjustStunned(-1) + return stunned + +/mob/living/proc/handle_weakened() + if(weakened) + weakened = max(weakened-1,0) //before you get mad Rockdtben: I done this so update_canmove isn't called multiple times + return weakened + +/mob/living/proc/handle_stuttering() + if(stuttering) + stuttering = max(stuttering-1, 0) + return stuttering + +/mob/living/proc/handle_silent() + if(silent) + silent = max(silent-1, 0) + return silent + +/mob/living/proc/handle_drugged() + if(druggy) + druggy = max(druggy-1, 0) + return druggy + +/mob/living/proc/handle_slurring() + if(slurring) + slurring = max(slurring-1, 0) + return slurring + +/mob/living/proc/handle_paralysed() // Currently only used by simple_animal.dm, treated as a special case in other mobs + if(paralysis) + AdjustParalysis(-1) + return paralysis