Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fixes respawn as npc verb #4543

Merged
merged 3 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 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.type))
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 All @@ -908,16 +913,14 @@
return

//find a viable mouse candidate
var/list/found_vents = get_valid_vent_spawns(min_network_size = 0, station_levels_only = FALSE, z_level = z)
var/list/found_vents = get_valid_vent_spawns(min_network_size = 0)
if(length(found_vents))
GLOB.respawnable_list -= src
client.time_joined_as_mouse = world.time
var/obj/vent_found = pick(found_vents)
var/choosen_type = prob(90) ? /mob/living/simple_animal/mouse : /mob/living/simple_animal/mouse/rat
var/mob/living/simple_animal/mouse/host = new choosen_type(vent_found.loc)
host.ckey = src.ckey
if(istype(get_area(vent_found), /area/syndicate/unpowered/syndicate_space_base))
host.faction += "syndicate"
to_chat(host, "<span class='info'>You are now a mouse. Try to avoid interaction with players, and do not give hints away that you are more than a simple rodent.</span>")
else
to_chat(src, "<span class='warning'>Unable to find any unwelded vents to spawn mice at.</span>")
Expand Down
15 changes: 7 additions & 8 deletions code/modules/mob/transform_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,23 @@
qdel(src)


/mob/proc/safe_respawn(passed_path)
/mob/proc/safe_respawn(mob/living/passed_mob, check_station_level = TRUE)
. = FALSE

if(!ispath(passed_path))
return .

var/static/list/safe_respawn_typecache_nuclear = typecacheof(list(
/mob/living/simple_animal/pet/cat/Syndi,
/mob/living/simple_animal/pet/dog/fox/Syndifox,
))
if(is_type_in_typecache(passed_path, safe_respawn_typecache_nuclear))
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(ispath(passed_path, /mob/living/simple_animal/borer) && !jobban_isbanned(src, ROLE_BORER) && !jobban_isbanned(src, ROLE_SYNDICATE))
if(istype(passed_mob, /mob/living/simple_animal/borer) && !jobban_isbanned(src, ROLE_BORER) && !jobban_isbanned(src, ROLE_SYNDICATE))
return TRUE

if(ispath(passed_path, /mob/living/simple_animal/diona) && !jobban_isbanned(src, ROLE_NYMPH))
if(isnymph(passed_mob) && !jobban_isbanned(src, ROLE_NYMPH))
return TRUE

// Whitelist typecache. Alphabetical order please!
Expand Down Expand Up @@ -280,6 +279,6 @@
/mob/living/simple_animal/pet/dog/fox/alisa,
))

if(is_type_in_typecache(passed_path, safe_respawn_typecache_whitelist) && !is_type_in_typecache(passed_path, safe_respawn_typecache_blacklist))
if(is_type_in_typecache(passed_mob, safe_respawn_typecache_whitelist) && !is_type_in_typecache(passed_mob, safe_respawn_typecache_blacklist))
return TRUE

Loading