From ca31767ea72cdb2dd3a919ab866aabe2b20246dc Mon Sep 17 00:00:00 2001 From: Deniz <66401072+Oyu07@users.noreply.github.com> Date: Fri, 17 May 2024 13:58:50 +0100 Subject: [PATCH] Cleans up a nested proc with returns (#25339) * indent culling 1 * PAI done * hemostat done * Re-ordered message * Update code/modules/mob/living/simple_animal/bot/bot.dm Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com> Signed-off-by: Deniz <66401072+Oyu07@users.noreply.github.com> --------- Signed-off-by: Deniz <66401072+Oyu07@users.noreply.github.com> Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com> --- .../mob/living/simple_animal/bot/bot.dm | 90 +++++++++++-------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/code/modules/mob/living/simple_animal/bot/bot.dm b/code/modules/mob/living/simple_animal/bot/bot.dm index 802ec42db94..cfc7a597101 100644 --- a/code/modules/mob/living/simple_animal/bot/bot.dm +++ b/code/modules/mob/living/simple_animal/bot/bot.dm @@ -400,51 +400,63 @@ if(allowed(user) && !open && !emagged) locked = !locked to_chat(user, "Controls are now [locked ? "locked." : "unlocked."]") + return + if(emagged) + to_chat(user, "ERROR") + if(open) + to_chat(user, "Please close the access panel before locking it.") else - if(emagged) - to_chat(user, "ERROR") - if(open) - to_chat(user, "Please close the access panel before locking it.") - else - to_chat(user, "Access denied.") - else if(istype(W, /obj/item/paicard)) + to_chat(user, "Access denied.") + return + + if(istype(W, /obj/item/paicard)) if(paicard) to_chat(user, "A [paicard] is already inserted!") - else if(allow_pai && !key) - if(!locked && !open && !hijacked) - var/obj/item/paicard/card = W - if(card.pai && card.pai.mind) - if(!card.pai.ckey || jobban_isbanned(card.pai, ROLE_SENTIENT)) - to_chat(user, "[W] is unable to establish a connection to [src].") - return - if(!user.drop_item()) - return - W.forceMove(src) - paicard = card - user.visible_message("[user] inserts [W] into [src]!","You insert [W] into [src].") - paicard.pai.mind.transfer_to(src) - to_chat(src, "You sense your form change as you are uploaded into [src].") - bot_name = name - name = paicard.pai.name - faction = user.faction - add_attack_logs(user, paicard.pai, "Uploaded to [src.bot_name]") - else - to_chat(user, "[W] is inactive.") - else - to_chat(user, "The personality slot is locked.") - else + return + + if(!allow_pai || key) to_chat(user, "[src] is not compatible with [W].") - else if(istype(W, /obj/item/hemostat) && paicard) + return + + if(locked || open || hijacked) + to_chat(user, "The personality slot is locked.") + return + + var/obj/item/paicard/card = W + if(!card.pai?.mind) + to_chat(user, "[W] is inactive.") + return + + if(!card.pai.ckey || jobban_isbanned(card.pai, ROLE_SENTIENT)) + to_chat(user, "[W] is unable to establish a connection to [src].") + return + + if(!user.drop_item()) + return + + W.forceMove(src) + paicard = card + user.visible_message("[user] inserts [W] into [src]!", "You insert [W] into [src].") + paicard.pai.mind.transfer_to(src) + to_chat(src, "You sense your form change as you are uploaded into [src].") + bot_name = name + name = paicard.pai.name + faction = user.faction + add_attack_logs(user, paicard.pai, "Uploaded to [src.bot_name]") + return + + if(istype(W, /obj/item/hemostat) && paicard) if(open) to_chat(user, "Close the access panel before manipulating the personality slot!") - else - to_chat(user, "You attempt to pull [paicard] free...") - if(do_after(user, 30 * W.toolspeed, target = src)) - if(paicard) - user.visible_message("[user] uses [W] to pull [paicard] out of [bot_name]!","You pull [paicard] out of [bot_name] with [W].") - ejectpai(user) - else - return ..() + return + + to_chat(user, "You attempt to pull [paicard] free...") + if(do_after(user, 30 * W.toolspeed, target = src)) + if(paicard) + user.visible_message("[user] uses [W] to pull [paicard] out of [bot_name]!","You pull [paicard] out of [bot_name] with [W].") + ejectpai(user) + return + return ..() /mob/living/simple_animal/bot/screwdriver_act(mob/living/user, obj/item/I) if(user.a_intent == INTENT_HARM)