From 039a2a952708526ef49ac1cdc74f382e41ca839f Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Wed, 2 Nov 2022 05:39:07 +0100 Subject: [PATCH] [MIRROR] minor refactor to suicide code [MDB IGNORE] (#17310) * minor refactor to suicide code (#70960) ## About The Pull Request Removes a redundant if statement and moves the code up an indentation ## Why It's Good For The Game Makes the code look better ## Changelog :cl: refactor: suicide code doesnt check damagetype multiple times /:cl: Co-authored-by: etherware-novice * minor refactor to suicide code Co-authored-by: texan-down-under <73374039+etherware-novice@users.noreply.github.com> Co-authored-by: etherware-novice --- code/modules/client/verbs/suicide.dm | 86 ++++++++++++++-------------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/code/modules/client/verbs/suicide.dm b/code/modules/client/verbs/suicide.dm index 0d63e645e70..32c1bfc4c19 100644 --- a/code/modules/client/verbs/suicide.dm +++ b/code/modules/client/verbs/suicide.dm @@ -37,53 +37,51 @@ return set_suicide(TRUE) //need to be called before calling suicide_act as fuck knows what suicide_act will do with your suicider var/obj/item/held_item = get_active_held_item() - var/damagetype = SEND_SIGNAL(src, COMSIG_HUMAN_SUICIDE_ACT) - if(held_item || damagetype) - if(!damagetype && held_item) - damagetype = held_item.suicide_act(src) - if(damagetype) - if(damagetype & SHAME) - adjustStaminaLoss(200) - set_suicide(FALSE) - add_mood_event("shameful_suicide", /datum/mood_event/shameful_suicide) - return - - if(damagetype & MANUAL_SUICIDE_NONLETHAL) //Make sure to call the necessary procs if it does kill later - set_suicide(FALSE) - return - - suicide_log() - - var/damage_mod = 0 - for(var/T in list(BRUTELOSS, FIRELOSS, TOXLOSS, OXYLOSS)) - damage_mod += (T & damagetype) ? 1 : 0 - damage_mod = max(1, damage_mod) - - //Do 200 damage divided by the number of damage types applied. - if(damagetype & BRUTELOSS) - adjustBruteLoss(200/damage_mod) - - if(damagetype & FIRELOSS) - adjustFireLoss(200/damage_mod) - - if(damagetype & TOXLOSS) - adjustToxLoss(200/damage_mod) - - if(damagetype & OXYLOSS) - adjustOxyLoss(200/damage_mod) - - if(damagetype & MANUAL_SUICIDE) //Assume the object will handle the death. - return - - //If something went wrong, just do normal oxyloss - if(!(damagetype & (BRUTELOSS | FIRELOSS | TOXLOSS | OXYLOSS) )) - adjustOxyLoss(max(200 - getToxLoss() - getFireLoss() - getBruteLoss() - getOxyLoss(), 0)) - - death(FALSE) - ghostize(FALSE) // Disallows reentering body and disassociates mind + var/damagetype = SEND_SIGNAL(src, COMSIG_HUMAN_SUICIDE_ACT) || held_item?.suicide_act(src) + if(damagetype) + if(damagetype & SHAME) + adjustStaminaLoss(200) + set_suicide(FALSE) + add_mood_event("shameful_suicide", /datum/mood_event/shameful_suicide) return + if(damagetype & MANUAL_SUICIDE_NONLETHAL) //Make sure to call the necessary procs if it does kill later + set_suicide(FALSE) + return + + suicide_log() + + var/damage_mod = 0 + for(var/T in list(BRUTELOSS, FIRELOSS, TOXLOSS, OXYLOSS)) + damage_mod += (T & damagetype) ? 1 : 0 + damage_mod = max(1, damage_mod) + + //Do 200 damage divided by the number of damage types applied. + if(damagetype & BRUTELOSS) + adjustBruteLoss(200/damage_mod) + + if(damagetype & FIRELOSS) + adjustFireLoss(200/damage_mod) + + if(damagetype & TOXLOSS) + adjustToxLoss(200/damage_mod) + + if(damagetype & OXYLOSS) + adjustOxyLoss(200/damage_mod) + + if(damagetype & MANUAL_SUICIDE) //Assume the object will handle the death. + return + + //If something went wrong, just do normal oxyloss + if(!(damagetype & (BRUTELOSS | FIRELOSS | TOXLOSS | OXYLOSS) )) + adjustOxyLoss(max(200 - getToxLoss() - getFireLoss() - getBruteLoss() - getOxyLoss(), 0)) + + death(FALSE) + ghostize(FALSE) // Disallows reentering body and disassociates mind + + return + var/suicide_message if(!combat_mode)