From 56f6b3a14ecdb1950544065519dbfb6a8f6fc0ba Mon Sep 17 00:00:00 2001 From: Krausus Date: Thu, 28 Jul 2016 17:02:46 -0400 Subject: [PATCH] Adds multi-mob warning to admin click shortcuts Also, cleans up admin_mob_info code a bit --- code/__HELPERS/mobs.dm | 32 +++++++++++++++++++++++++++----- code/_onclick/observer.dm | 10 +++------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index fc58bd0e81d..889a0824f35 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -301,9 +301,12 @@ proc/add_logs(mob/target, mob/user, what_done, var/object=null, var/addition=nul var/mob/living/L = M var/status switch(M.stat) - if(0) status = "Alive" - if(1) status = "Unconscious" - if(2) status = "Dead" + if(CONSCIOUS) + status = "Alive" + if(UNCONSCIOUS) + status = "Unconscious" + if(DEAD) + status = "Dead" health_description = "Status = [status]" health_description += "
Oxy: [L.getOxyLoss()] - Tox: [L.getToxLoss()] - Fire: [L.getFireLoss()] - Brute: [L.getBruteLoss()] - Clone: [L.getCloneLoss()] - Brain: [L.getBrainLoss()]" else @@ -311,8 +314,10 @@ proc/add_logs(mob/target, mob/user, what_done, var/object=null, var/addition=nul //Gener switch(M.gender) - if(MALE,FEMALE) gender_description = "[M.gender]" - else gender_description = "[M.gender]" + if(MALE, FEMALE) + gender_description = "[M.gender]" + else + gender_description = "[M.gender]" to_chat(user, "Info about [M.name]: ") to_chat(user, "Mob type = [M.type]; Gender = [gender_description] Damage = [health_description]") @@ -320,3 +325,20 @@ proc/add_logs(mob/target, mob/user, what_done, var/object=null, var/addition=nul to_chat(user, "Location = [location_description];") to_chat(user, "[special_role_description]") to_chat(user, "(PM) (PP) (VV) (SM) (FLW) (CA)") + +// Gets the first mob contained in an atom, and warns the user if there's not exactly one +/proc/get_mob_in_atom_with_warning(atom/A, mob/user = usr) + if(!istype(A)) + return null + if(ismob(A)) + return A + + . = null + for(var/mob/M in A) + if(!.) + . = M + else + to_chat(user, "Multiple mobs in [A], using first mob found...") + break + if(!.) + to_chat(user, "No mob located in [A].") diff --git a/code/_onclick/observer.dm b/code/_onclick/observer.dm index 8927af5f7be..d04abfe5a87 100644 --- a/code/_onclick/observer.dm +++ b/code/_onclick/observer.dm @@ -26,23 +26,19 @@ var/list/modifiers = params2list(params) if(check_rights(R_ADMIN, 0)) // Admin click shortcuts - var/mob/M = A - if(!istype(M)) - M = locate() in A + var/mob/M if(modifiers["shift"] && modifiers["ctrl"]) client.debug_variables(A) return if(modifiers["ctrl"]) + M = get_mob_in_atom_with_warning(A) if(M) client.holder.show_player_panel(M) - else - to_chat(src, "No mob was found in the atom you clicked on.") return if(modifiers["shift"] && modifiers["middle"]) + M = get_mob_in_atom_with_warning(A) if(M) admin_mob_info(M) - else - to_chat(src, "No mob was found in the atom you clicked on.") return if(modifiers["shift"]) ShiftClickOn(A)