Simplify checks for valid nuke detonation sites. (#21518)

* Simplify checks for valid nuke detonation sites.

* falsy check was replaced with equality so this needs to be exact

* Use SSmapping.existing_station_areas instead

* swap to guard clause

* Update code/game/gamemodes/nuclear/nuclearbomb.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>

* switch to switch

---------

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
This commit is contained in:
warriorstar-orion
2023-08-21 19:28:52 +01:00
committed by GitHub
co-authored by Contrabang
parent 76d0428022
commit e2a647188e
4 changed files with 81 additions and 50 deletions
@@ -314,7 +314,7 @@
for(var/explodee in GLOB.player_list)
SEND_SOUND(explodee, doomsday_alarm)
sleep(100)
SSticker.station_explosion_cinematic(null, "AI malfunction")
SSticker.station_explosion_cinematic(NUKE_SITE_ON_STATION, "AI malfunction")
to_chat(world, "<B>The AI cleansed the station of life with the doomsday device!</B>")
SSticker.mode.station_was_nuked = TRUE
+31 -16
View File
@@ -531,7 +531,23 @@ GLOBAL_VAR(bomb_set)
if(zap_flags & ZAP_MACHINE_EXPLOSIVE)
qdel(src)//like the singulo, tesla deletes it. stops it from exploding over and over
#define NUKERANGE 80
/// Determine the location of the nuke with respect to the station. Used for,
/// among other things, calculating win conditions for nukies and choosing which
/// round-end cinematic to play.
/obj/machinery/nuclearbomb/proc/get_nuke_site()
var/turf/bomb_turf = get_turf(src)
if(!bomb_turf)
return NUKE_SITE_INVALID
if(!is_station_level(bomb_turf.z))
return NUKE_SITE_OFF_STATION_ZLEVEL
if(get_area(src) in SSmapping.existing_station_areas)
return NUKE_SITE_ON_STATION
return NUKE_SITE_ON_STATION_ZLEVEL
/obj/machinery/nuclearbomb/proc/explode()
if(safety)
timing = FALSE
@@ -549,35 +565,34 @@ GLOBAL_VAR(bomb_set)
GLOB.enter_allowed = 0
var/off_station = 0
var/turf/bomb_location = get_turf(src)
var/area/A = get_area(src)
if( bomb_location && is_station_level(bomb_location.z) )
if( (bomb_location.x < (128 - NUKERANGE)) || (bomb_location.x > (128 + NUKERANGE)) || (bomb_location.y < (128 - NUKERANGE)) || (bomb_location.y > (128 + NUKERANGE)) && (!(A in GLOB.the_station_areas)))
off_station = 1
else
off_station = 2
var/nuke_site = get_nuke_site()
if(SSticker)
if(SSticker.mode && SSticker.mode.name == "nuclear emergency")
var/obj/docking_port/mobile/syndie_shuttle = SSshuttle.getShuttle("syndicate")
if(syndie_shuttle)
SSticker.mode:syndies_didnt_escape = is_station_level(syndie_shuttle.z)
SSticker.mode:nuke_off_station = off_station
SSticker.station_explosion_cinematic(off_station,null)
SSticker.mode:nuke_off_station = nuke_site
SSticker.station_explosion_cinematic(nuke_site, null)
if(SSticker.mode)
SSticker.mode.explosion_in_progress = FALSE
if(SSticker.mode.name == "nuclear emergency")
SSticker.mode:nukes_left --
else if(off_station == 1)
else if(nuke_site == NUKE_SITE_ON_STATION_ZLEVEL)
to_chat(world, "<b>A nuclear device was set off, but the explosion was out of reach of the station!</b>")
else if(off_station == 2)
to_chat(world, "<b>A nuclear device was set off, but the device was not on the station!</b>")
else if(nuke_site == NUKE_SITE_OFF_STATION_ZLEVEL)
to_chat(world, "<b>A nuclear device was set off, but the device nowhere near the station!</b>")
else if(nuke_site == NUKE_SITE_INVALID)
to_chat(world, "<b>A nuclear device was set off in an unknown location!</b>")
log_admin("The nuclear device [src] detonated but was not located on a valid turf.")
else
to_chat(world, "<b>The station was destroyed by the nuclear blast!</b>")
SSticker.mode.station_was_nuked = (off_station < 2) //offstation==1 is a draw. the station becomes irradiated and needs to be evacuated.
//kinda shit but I couldn't get permission to do what I wanted to do.
// NUKE_SITE_ON_STATION_ZLEVEL still counts as nuked for the
// purposes of /datum/game_mode/nuclear/declare_completion() and its
// weird logic of specifying whether the nuke blew up "something
// that wasn't" the station.
SSticker.mode.station_was_nuked = nuke_site == NUKE_SITE_ON_STATION || nuke_site == NUKE_SITE_ON_STATION_ZLEVEL
if(!SSticker.mode.check_finished())//If the mode does not deal with the nuke going off so just reboot because everyone is stuck as is
SSticker.reboot_helper("Station destroyed by Nuclear Device.", "nuke - unhandled ending")