Skip to content

Commit

Permalink
make npc list better
Browse files Browse the repository at this point in the history
  • Loading branch information
Rerik007 committed Mar 2, 2024
1 parent 9b151cc commit 3cf1866
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
17 changes: 11 additions & 6 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion code/modules/mob/transform_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit 3cf1866

Please sign in to comment.