Skip to content

Commit

Permalink
[MIRROR] Self-destruct Can Trigger Evacuation (#1459)
Browse files Browse the repository at this point in the history
Co-authored-by: orelbon <[email protected]>
  • Loading branch information
SierraHelper and Chiquiii authored Nov 15, 2023
1 parent 2202b8d commit 5d0f016
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 112 deletions.
13 changes: 7 additions & 6 deletions code/controllers/evacuation/evacuation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,17 @@ var/global/datum/evacuation_controller/evacuation_controller
GLOB.using_map.emergency_shuttle_called_announcement()
else
if(!skip_announce)
priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.shuttle_called_message, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETA%", "[round(get_eta()/60)] minute\s"))
priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.shuttle_called_message, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETA%", "[round(get_eta()/60,0.5)] minute\s"))

return 1

/datum/evacuation_controller/proc/cancel_evacuation()

if(!can_cancel())
return 0
if(!emergency_evacuation)
evac_cooldown_time = world.time + (world.time - evac_called_at)

evac_cooldown_time = world.time + (world.time - evac_called_at)
state = EVAC_COOLDOWN

evac_ready_time = null
Expand All @@ -129,9 +130,9 @@ var/global/datum/evacuation_controller/evacuation_controller
/datum/evacuation_controller/proc/finish_preparing_evac()
state = EVAC_LAUNCHING

var/estimated_time = round(get_eta()/60,1)
var/estimated_time = round(get_eta()/60,0.5)
if (emergency_evacuation)
evac_waiting.Announce(replacetext(GLOB.using_map.emergency_shuttle_docked_message, "%ETD%", "[estimated_time] minute\s"), new_sound = sound('sound/effects/Evacuation.ogg', volume = 35))
evac_waiting.Announce(replacetext(GLOB.using_map.emergency_shuttle_docked_message, "%ETD%", "[estimated_time] minute\s"), new_sound = sound('sound/effects/Evacuation.ogg', volume = 30))
else
priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.shuttle_docked_message, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETD%", "[estimated_time] minute\s"))
if(config.announce_evac_to_irc)
Expand All @@ -145,9 +146,9 @@ var/global/datum/evacuation_controller/evacuation_controller
state = EVAC_IN_TRANSIT

if (emergency_evacuation)
priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.emergency_shuttle_leaving_dock, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETA%", "[round(get_eta()/60,1)] minute\s"))
priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.emergency_shuttle_leaving_dock, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETA%", "[round(get_eta()/60,0.5)] minute\s"))
else
priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.shuttle_leaving_dock, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETA%", "[round(get_eta()/60,1)] minute\s"))
priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.shuttle_leaving_dock, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETA%", "[round(get_eta()/60,0.5)] minute\s"))

return 1

Expand Down
4 changes: 2 additions & 2 deletions code/controllers/evacuation/evacuation_pods.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
pod.move_time = (evac_transit_delay/10)
pod.launch(src)

priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.emergency_shuttle_leaving_dock, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETA%", "[round(get_eta()/60,1)] minute\s"))
priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.emergency_shuttle_leaving_dock, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETA%", "[round(get_eta()/60,0.5)] minute\s"))
else
// Bluespace Jump
priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.shuttle_leaving_dock, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETA%", "[round(get_eta()/60,1)] minute\s"))
priority_announcement.Announce(replacetext(replacetext(GLOB.using_map.shuttle_leaving_dock, "%dock_name%", "[GLOB.using_map.dock_name]"), "%ETA%", "[round(get_eta()/60,0.5)] minute\s"))
SetUniversalState(/datum/universal_state/bluespace_jump, arguments=list(GLOB.using_map.station_levels))

/datum/evacuation_controller/starship/finish_evacuation()
Expand Down
2 changes: 1 addition & 1 deletion code/datums/security_state.dm
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@

psionic_control_level = PSI_IMPLANT_DISABLED

var/static/datum/announcement/priority/security/security_announcement_delta = new(do_log = 0, do_newscast = 1, new_sound = sound('sound/effects/siren.ogg'))
var/static/datum/announcement/priority/security/security_announcement_delta = new(do_log = 0, do_newscast = 1, new_sound = sound('sound/effects/siren.ogg', volume = 70))

/singleton/security_level/default/code_delta/switching_up_to()
security_announcement_delta.Announce("The self-destruct mechanism has been engaged. All crew are instructed to obey all instructions given by heads of staff. Any violations of these orders can be punished by death. This is not a drill.", "Attention! Delta security level reached!")
Expand Down
77 changes: 46 additions & 31 deletions code/game/machinery/nuclear_bomb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ var/global/bomb_set
unacidable = TRUE
interact_offline = TRUE

var/evacuate = FALSE
var/deployable = 0
var/extended = 0
var/lighthack = 0
var/timeleft = 120
var/minTime = 120
var/maxTime = 600
var/timeleft = 120 SECONDS
var/minTime = 120 SECONDS
var/maxTime = 600 SECONDS
var/timing = 0
var/r_code = "ADMIN"
var/code = ""
Expand All @@ -38,11 +39,10 @@ var/global/bomb_set
auth = null
return ..()

/obj/machinery/nuclearbomb/Process(wait)
/obj/machinery/nuclearbomb/Process()
if(timing)
timeleft = max(timeleft - (wait / 10), 0)
playsound(loc, 'sound/items/timer.ogg', 50)
if(timeleft <= 0)
playsound(loc, 'sound/items/timer.ogg',50)
if(world.time > timeleft)
addtimer(new Callback(src, .proc/explode), 0)
SSnano.update_uis(src)

Expand Down Expand Up @@ -165,9 +165,10 @@ var/global/bomb_set

/obj/machinery/nuclearbomb/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
var/data[0]
data["evacuate"] = evacuate
data["hacking"] = 0
data["auth"] = is_auth(user)
data["moveable_anchor"] = !istype(src, /obj/machinery/nuclearbomb/station)
data["is_regular_nuke"] = !istype(src, /obj/machinery/nuclearbomb/station)
if(is_auth(user))
if(yes_code)
data["authstatus"] = timing ? "Functional/Set" : "Functional"
Expand All @@ -179,7 +180,7 @@ var/global/bomb_set
else
data["authstatus"] = "Auth. S1"
data["safe"] = safety ? "Safe" : "Engaged"
data["time"] = timeleft
data["time"] = timing ? round((timeleft - world.time)/10, 1) : round(timeleft/10, 1)
data["timer"] = timing
data["safety"] = safety
data["anchored"] = anchored
Expand Down Expand Up @@ -262,7 +263,7 @@ var/global/bomb_set
to_chat(usr, SPAN_WARNING("Cannot alter the timing during countdown."))
return

var/time = text2num(href_list["time"])
var/time = text2num(href_list["time"]) SECONDS
timeleft += time
timeleft = clamp(timeleft, minTime, maxTime)
if(href_list["timer"])
Expand All @@ -280,7 +281,7 @@ var/global/bomb_set
if(!timing && !safety)
start_bomb()
else
check_cutoff()
secure_device()
if(href_list["safety"])
if (wires.IsIndexCut(NUCLEARBOMB_WIRE_SAFETY))
to_chat(usr, SPAN_WARNING("Nothing happens, something might be wrong with the wiring."))
Expand All @@ -289,6 +290,11 @@ var/global/bomb_set
if(safety)
secure_device()
update_icon()
if(href_list["evacuate"])
if(timing)
to_chat(usr, SPAN_WARNING("Cannot alter evacuation during countdown."))
return
evacuate = !evacuate
if(href_list["anchor"])
if(removal_stage == 5)
anchored = FALSE
Expand All @@ -307,6 +313,7 @@ var/global/bomb_set
return 1

/obj/machinery/nuclearbomb/proc/start_bomb()
timeleft += world.time
timing = 1
log_and_message_admins("activated the detonation countdown of \the [src]")
bomb_set++ //There can still be issues with this resetting when there are multiple bombs. Not a big deal though for Nuke/N
Expand All @@ -315,9 +322,6 @@ var/global/bomb_set
security_state.set_security_level(security_state.severe_security_level, TRUE)
update_icon()

/obj/machinery/nuclearbomb/proc/check_cutoff()
secure_device()

/obj/machinery/nuclearbomb/proc/secure_device()
if(timing <= 0)
return
Expand All @@ -326,7 +330,7 @@ var/global/bomb_set
bomb_set--
safety = TRUE
timing = 0
timeleft = clamp(timeleft, minTime, maxTime)
timeleft = clamp(timeleft - world.time, minTime, maxTime)
update_icon()

/obj/machinery/nuclearbomb/ex_act(severity)
Expand Down Expand Up @@ -454,12 +458,12 @@ var/global/bomb_set
var/list/inserters = list()
var/last_turf_state

var/announced = 0
var/announced = FALSE
var/time_to_explosion = 0
var/self_destruct_cutoff = 60 //Seconds
timeleft = 300
minTime = 300
maxTime = 900
var/self_destruct_cutoff = 60 SECONDS
timeleft = 300 SECONDS
minTime = 300 SECONDS
maxTime = 900 SECONDS

/obj/machinery/nuclearbomb/station/Initialize()
..()
Expand Down Expand Up @@ -491,25 +495,40 @@ var/global/bomb_set
if(!istype(sd) || !sd.armed)
to_chat(usr, SPAN_WARNING("An inserter has not been armed or is damaged."))
return
visible_message(SPAN_WARNING("Warning. The self-destruct sequence override will be disabled [self_destruct_cutoff] seconds before detonation."))
..()
visible_message(SPAN_WARNING("Warning. The self-destruct sequence override will be disabled [self_destruct_cutoff/10] seconds before detonation."))
if(evacuate)
if(!evacuation_controller)
visible_message(SPAN_DANGER("Warning. Unable to initiate evacuation procedures."))
return
for (var/datum/evacuation_option/EO in evacuation_controller.available_evac_options())
if(EO.abandon_ship)
evacuation_controller.evac_prep_delay = timeleft - world.time - 2 MINUTES
evacuation_controller.evac_launch_delay = 1.75 MINUTES //Escape pods take time to arm and eject appart from this delay. Take into account.
evacuation_controller.handle_evac_option(EO.option_target, usr)

/obj/machinery/nuclearbomb/station/check_cutoff()
if(timeleft <= self_destruct_cutoff)
/obj/machinery/nuclearbomb/station/secure_device()
if(timing && timeleft - world.time <= self_destruct_cutoff)
visible_message(SPAN_WARNING("Self-Destruct abort is no longer possible."))
return
..()
announced = FALSE
for (var/datum/evacuation_option/EO in evacuation_controller.available_evac_options())
if(EO.option_target == "cancel_abandon_ship")
evacuation_controller.handle_evac_option(EO.option_target, usr)
evacuation_controller.evac_prep_delay = 5 MINUTES
evacuation_controller.evac_launch_delay = 3 MINUTES

/obj/machinery/nuclearbomb/station/Process()
..()
if(timeleft > 0 && GAME_STATE < RUNLEVEL_POSTGAME)
if(timeleft <= self_destruct_cutoff)
if(timing && timeleft - world.time > 0 && GAME_STATE < RUNLEVEL_POSTGAME)
if(timeleft - world.time <= self_destruct_cutoff)
if(!announced)
priority_announcement.Announce("The self-destruct sequence has reached terminal countdown, abort systems have been disabled.", "Self-Destruct Control Computer")
announced = 1
announced = TRUE
if(world.time >= time_to_explosion)
var/range
if(timeleft <= (self_destruct_cutoff/2))
if(timeleft - world.time <= (self_destruct_cutoff/2))
range = rand(14, 21)
time_to_explosion = world.time + 2 SECONDS
else
Expand All @@ -518,10 +537,6 @@ var/global/bomb_set
var/turf/T = pick_area_and_turf(GLOB.is_station_but_not_space_or_shuttle_area)
explosion(T, range)

/obj/machinery/nuclearbomb/station/secure_device()
..()
announced = 0

/obj/machinery/nuclearbomb/station/on_update_icon()
var/target_icon_state
var/turf_color = COLOR_BLACK
Expand Down
Loading

0 comments on commit 5d0f016

Please sign in to comment.