From 3cf1866e08a2b21477bfc54edfe91309c9bbdd31 Mon Sep 17 00:00:00 2001 From: Rerik007 <120549107+Rerik007@users.noreply.github.com> Date: Sat, 2 Mar 2024 16:44:51 +0300 Subject: [PATCH] make npc list better --- code/modules/mob/mob.dm | 17 +++++++++++------ code/modules/mob/transform_procs.dm | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 381106e834b..40e5630bea3 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -874,19 +874,24 @@ to_chat(usr, span_warning("You are not dead or you have given up your right to be respawned!")) return - var/list/allowed_creatures = list("Mouse") + var/list/allowed_creatures = list() for(var/mob/living/alive_mob as anything in GLOB.alive_mob_list) - if(!alive_mob.key && alive_mob.stat != DEAD && safe_respawn(alive_mob)) - allowed_creatures += alive_mob + if(!alive_mob.key && alive_mob.stat != DEAD && safe_respawn(alive_mob, TRUE)) + allowed_creatures[++allowed_creatures.len] = "[alive_mob.name]" + " ([get_area_name(alive_mob, TRUE)])" + allowed_creatures["[alive_mob.name]" + " ([get_area_name(alive_mob, TRUE)])"] = alive_mob - var/mob/living/picked_mob = tgui_input_list(usr, "Please select an NPC to respawn as", "Respawn as NPC", allowed_creatures) - if(!picked_mob) + allowed_creatures.Insert(1, "Mouse") + + var/mob/living/picked = tgui_input_list(usr, "Please select an NPC to respawn as", "Respawn as NPC", allowed_creatures) + if(!picked) return - if(picked_mob == "Mouse") + if(picked == "Mouse") become_mouse() return + var/mob/living/picked_mob = allowed_creatures[picked] + if(QDELETED(picked_mob) || picked_mob.key || picked_mob.stat == DEAD) to_chat(usr, span_warning("[capitalize(picked_mob)] is no longer available to respawn!")) return diff --git a/code/modules/mob/transform_procs.dm b/code/modules/mob/transform_procs.dm index 641a1f7b50a..7e4901d797b 100644 --- a/code/modules/mob/transform_procs.dm +++ b/code/modules/mob/transform_procs.dm @@ -227,7 +227,7 @@ qdel(src) -/mob/proc/safe_respawn(mob/living/passed_mob) +/mob/proc/safe_respawn(mob/living/passed_mob, check_station_level = TRUE) . = FALSE var/static/list/safe_respawn_typecache_nuclear = typecacheof(list( @@ -237,6 +237,8 @@ if(is_type_in_typecache(passed_mob, safe_respawn_typecache_nuclear)) return GAMEMODE_IS_NUCLEAR + if(check_station_level && !is_admin(src) && !is_station_level(passed_mob.z)) + return FALSE if(istype(passed_mob, /mob/living/simple_animal/borer) && !jobban_isbanned(src, ROLE_BORER) && !jobban_isbanned(src, ROLE_SYNDICATE)) return TRUE