[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
🆑
refactor: suicide code doesnt check damagetype multiple times
/🆑

Co-authored-by: etherware-novice <candy@ notarealaddr.com>

* minor refactor to suicide code

Co-authored-by: texan-down-under <73374039+etherware-novice@users.noreply.github.com>
Co-authored-by: etherware-novice <candy@ notarealaddr.com>
This commit is contained in:
SkyratBot
2022-11-02 00:39:07 -04:00
committed by GitHub
co-authored by etherware-novice texan-down-under
parent c42a7396b1
commit 039a2a9527
+42 -44
View File
@@ -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)