From bf61975b2a94c54d167bcd38835ad8ea35d672f4 Mon Sep 17 00:00:00 2001 From: Vi3trice <80771500+Vi3trice@users.noreply.github.com> Date: Sat, 14 Jan 2023 11:26:51 -0500 Subject: [PATCH] Nuke disc respawn checks its surroundings for an open space if someone winds up building a wall over it (#20121) * Give it space * Update nuclearbomb.dm * Update nuclearbomb.dm --- code/game/gamemodes/nuclear/nuclearbomb.dm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/code/game/gamemodes/nuclear/nuclearbomb.dm b/code/game/gamemodes/nuclear/nuclearbomb.dm index c2450e16375..a9826b46feb 100644 --- a/code/game/gamemodes/nuclear/nuclearbomb.dm +++ b/code/game/gamemodes/nuclear/nuclearbomb.dm @@ -586,17 +586,29 @@ GLOBAL_VAR(bomb_set) STOP_PROCESSING(SSobj, src) return ..() - if(length(GLOB.nukedisc_respawn)) + var/turf/new_spawn = find_respawn() + if(new_spawn) GLOB.poi_list.Remove(src) - var/obj/item/disk/nuclear/NEWDISK = new(pick(GLOB.nukedisc_respawn)) + var/obj/item/disk/nuclear/NEWDISK = new(new_spawn) transfer_fingerprints_to(NEWDISK) message_admins("[src] has been destroyed at ([diskturf.x], [diskturf.y], [diskturf.z] - JMP). Moving it to ([NEWDISK.x], [NEWDISK.y], [NEWDISK.z] - JMP).") log_game("[src] has been destroyed in ([diskturf.x], [diskturf.y], [diskturf.z]). Moving it to ([NEWDISK.x], [NEWDISK.y], [NEWDISK.z]).") return QDEL_HINT_HARDDEL_NOW else - error("[src] was supposed to be destroyed, but we were unable to locate a nukedisc_respawn landmark to spawn a new one.") + error("[src] was supposed to be destroyed, but we were unable to locate a nukedisc_respawn landmark or open surroundings to spawn a new one.") return QDEL_HINT_LETMELIVE // Cancel destruction unless forced. +/obj/item/disk/nuclear/proc/find_respawn() + var/list/possible_spawns = GLOB.nukedisc_respawn + while(length(possible_spawns)) + var/turf/current_spawn = pick_n_take(possible_spawns) + if(!current_spawn.density) + return current_spawn + // Someone built a wall over it, check the surroundings + var/list/open_turfs = current_spawn.AdjacentTurfs(open_only = TRUE) + if(length(open_turfs)) + return pick(open_turfs) + #undef NUKE_INTACT #undef NUKE_COVER_OFF #undef NUKE_COVER_OPEN