|
|
|
@@ -11,9 +11,10 @@
|
|
|
|
|
var/default_timer_set = 90
|
|
|
|
|
var/minimum_timer_set = 90
|
|
|
|
|
var/maximum_timer_set = 3600
|
|
|
|
|
var/ui_style = "nanotrasen"
|
|
|
|
|
ui_style = "nanotrasen"
|
|
|
|
|
|
|
|
|
|
var/numeric_input = ""
|
|
|
|
|
var/ui_mode = NUKEUI_AWAIT_DISK
|
|
|
|
|
var/timing = FALSE
|
|
|
|
|
var/exploding = FALSE
|
|
|
|
|
var/exploded = FALSE
|
|
|
|
@@ -97,6 +98,8 @@
|
|
|
|
|
if(!user.transferItemToLoc(I, src))
|
|
|
|
|
return
|
|
|
|
|
auth = I
|
|
|
|
|
update_ui_mode()
|
|
|
|
|
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
|
|
|
|
|
add_fingerprint(user)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
@@ -233,113 +236,154 @@
|
|
|
|
|
var/volume = (get_time_left() <= 20 ? 30 : 5)
|
|
|
|
|
playsound(loc, 'sound/items/timer.ogg', volume, 0)
|
|
|
|
|
|
|
|
|
|
/obj/machinery/nuclearbomb/proc/update_ui_mode()
|
|
|
|
|
if(exploded)
|
|
|
|
|
ui_mode = NUKEUI_EXPLODED
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if(!auth)
|
|
|
|
|
ui_mode = NUKEUI_AWAIT_DISK
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if(timing)
|
|
|
|
|
ui_mode = NUKEUI_TIMING
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if(!safety)
|
|
|
|
|
ui_mode = NUKEUI_AWAIT_ARM
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if(!yes_code)
|
|
|
|
|
ui_mode = NUKEUI_AWAIT_CODE
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
ui_mode = NUKEUI_AWAIT_TIMER
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/obj/machinery/nuclearbomb/ui_interact(mob/user, ui_key="main", datum/tgui/ui=null, force_open=0, datum/tgui/master_ui=null, datum/ui_state/state=GLOB.default_state)
|
|
|
|
|
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
|
|
|
|
if(!ui)
|
|
|
|
|
ui = new(user, src, ui_key, "nuclear_bomb", name, 500, 600, master_ui, state)
|
|
|
|
|
ui = new(user, src, ui_key, "nuclear_bomb", name, 350, 442, master_ui, state)
|
|
|
|
|
ui.set_style(ui_style)
|
|
|
|
|
ui.open()
|
|
|
|
|
|
|
|
|
|
/obj/machinery/nuclearbomb/ui_data(mob/user)
|
|
|
|
|
var/list/data = list()
|
|
|
|
|
data["disk_present"] = auth
|
|
|
|
|
data["code_approved"] = yes_code
|
|
|
|
|
var/first_status
|
|
|
|
|
if(auth)
|
|
|
|
|
if(yes_code)
|
|
|
|
|
first_status = timing ? "Func/Set" : "Functional"
|
|
|
|
|
else
|
|
|
|
|
first_status = "Auth S2."
|
|
|
|
|
var/hidden_code = (ui_mode == NUKEUI_AWAIT_CODE && numeric_input != "ERROR")
|
|
|
|
|
var/current_code = ""
|
|
|
|
|
if(hidden_code)
|
|
|
|
|
while(length(current_code) < length(numeric_input))
|
|
|
|
|
current_code = "[current_code]*"
|
|
|
|
|
else
|
|
|
|
|
if(timing)
|
|
|
|
|
first_status = "Set"
|
|
|
|
|
else
|
|
|
|
|
first_status = "Auth S1."
|
|
|
|
|
var/second_status = exploded ? "Warhead triggered, thanks for flying Nanotrasen" : (safety ? "Safe" : "Engaged")
|
|
|
|
|
data["status1"] = first_status
|
|
|
|
|
data["status2"] = second_status
|
|
|
|
|
data["anchored"] = anchored
|
|
|
|
|
data["safety"] = safety
|
|
|
|
|
data["timing"] = timing
|
|
|
|
|
data["time_left"] = get_time_left()
|
|
|
|
|
|
|
|
|
|
data["timer_set"] = timer_set
|
|
|
|
|
data["timer_is_not_default"] = timer_set != default_timer_set
|
|
|
|
|
data["timer_is_not_min"] = timer_set != minimum_timer_set
|
|
|
|
|
data["timer_is_not_max"] = timer_set != maximum_timer_set
|
|
|
|
|
|
|
|
|
|
var/message = "AUTH"
|
|
|
|
|
if(auth)
|
|
|
|
|
message = "[numeric_input]"
|
|
|
|
|
if(yes_code)
|
|
|
|
|
message = "*****"
|
|
|
|
|
data["message"] = message
|
|
|
|
|
current_code = numeric_input
|
|
|
|
|
while(length(current_code) < 5)
|
|
|
|
|
current_code = "[current_code]-"
|
|
|
|
|
var/first_status = null
|
|
|
|
|
var/second_status = null
|
|
|
|
|
switch(ui_mode)
|
|
|
|
|
if(NUKEUI_AWAIT_DISK)
|
|
|
|
|
first_status = "DEVICE LOCKED"
|
|
|
|
|
if(timing)
|
|
|
|
|
second_status = "TIME: [get_time_left()]"
|
|
|
|
|
else
|
|
|
|
|
second_status = "AWAIT DISK"
|
|
|
|
|
if(NUKEUI_AWAIT_CODE)
|
|
|
|
|
first_status = "INPUT CODE"
|
|
|
|
|
second_status = "CODE: [current_code]"
|
|
|
|
|
if(NUKEUI_AWAIT_TIMER)
|
|
|
|
|
first_status = "INPUT TIME"
|
|
|
|
|
second_status = "TIME: [current_code]"
|
|
|
|
|
if(NUKEUI_AWAIT_ARM)
|
|
|
|
|
first_status = "DEVICE READY"
|
|
|
|
|
second_status = "TIME: [get_time_left()]"
|
|
|
|
|
if(NUKEUI_TIMING)
|
|
|
|
|
first_status = "DEVICE ARMED"
|
|
|
|
|
second_status = "TIME: [get_time_left()]"
|
|
|
|
|
if(NUKEUI_EXPLODED)
|
|
|
|
|
first_status = "DEVICE DEPLOYED"
|
|
|
|
|
second_status = "THANK YOU"
|
|
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
/obj/machinery/nuclearbomb/ui_act(action, params)
|
|
|
|
|
if(..())
|
|
|
|
|
return
|
|
|
|
|
playsound(src, "terminal_type", 20, FALSE)
|
|
|
|
|
switch(action)
|
|
|
|
|
if("eject_disk")
|
|
|
|
|
if(auth && auth.loc == src)
|
|
|
|
|
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
|
|
|
|
|
playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE)
|
|
|
|
|
auth.forceMove(get_turf(src))
|
|
|
|
|
auth = null
|
|
|
|
|
. = TRUE
|
|
|
|
|
if("insert_disk")
|
|
|
|
|
if(!auth)
|
|
|
|
|
else
|
|
|
|
|
var/obj/item/I = usr.is_holding_item_of_type(/obj/item/disk/nuclear)
|
|
|
|
|
if(I && disk_check(I) && usr.transferItemToLoc(I, src))
|
|
|
|
|
playsound(src, 'sound/machines/terminal_insert_disc.ogg', 50, FALSE)
|
|
|
|
|
playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE)
|
|
|
|
|
auth = I
|
|
|
|
|
. = TRUE
|
|
|
|
|
update_ui_mode()
|
|
|
|
|
if("keypad")
|
|
|
|
|
if(auth)
|
|
|
|
|
var/digit = params["digit"]
|
|
|
|
|
switch(digit)
|
|
|
|
|
if("R")
|
|
|
|
|
if("C")
|
|
|
|
|
if(auth && ui_mode == NUKEUI_AWAIT_ARM)
|
|
|
|
|
set_safety()
|
|
|
|
|
yes_code = FALSE
|
|
|
|
|
playsound(src, 'sound/machines/nuke/confirm_beep.ogg', 50, FALSE)
|
|
|
|
|
update_ui_mode()
|
|
|
|
|
else
|
|
|
|
|
playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE)
|
|
|
|
|
numeric_input = ""
|
|
|
|
|
yes_code = FALSE
|
|
|
|
|
. = TRUE
|
|
|
|
|
if("E")
|
|
|
|
|
if(numeric_input == r_code)
|
|
|
|
|
numeric_input = ""
|
|
|
|
|
yes_code = TRUE
|
|
|
|
|
. = TRUE
|
|
|
|
|
else
|
|
|
|
|
numeric_input = "ERROR"
|
|
|
|
|
switch(ui_mode)
|
|
|
|
|
if(NUKEUI_AWAIT_CODE)
|
|
|
|
|
if(numeric_input == r_code)
|
|
|
|
|
numeric_input = ""
|
|
|
|
|
yes_code = TRUE
|
|
|
|
|
playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE)
|
|
|
|
|
. = TRUE
|
|
|
|
|
else
|
|
|
|
|
playsound(src, 'sound/machines/nuke/angry_beep.ogg', 50, FALSE)
|
|
|
|
|
numeric_input = "ERROR"
|
|
|
|
|
if(NUKEUI_AWAIT_TIMER)
|
|
|
|
|
var/number_value = text2num(numeric_input)
|
|
|
|
|
if(number_value)
|
|
|
|
|
timer_set = CLAMP(number_value, minimum_timer_set, maximum_timer_set)
|
|
|
|
|
playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE)
|
|
|
|
|
set_safety()
|
|
|
|
|
. = TRUE
|
|
|
|
|
else
|
|
|
|
|
playsound(src, 'sound/machines/nuke/angry_beep.ogg', 50, FALSE)
|
|
|
|
|
update_ui_mode()
|
|
|
|
|
if("0","1","2","3","4","5","6","7","8","9")
|
|
|
|
|
if(numeric_input != "ERROR")
|
|
|
|
|
numeric_input += digit
|
|
|
|
|
if(length(numeric_input) > 5)
|
|
|
|
|
numeric_input = "ERROR"
|
|
|
|
|
else
|
|
|
|
|
playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE)
|
|
|
|
|
. = TRUE
|
|
|
|
|
if("timer")
|
|
|
|
|
if(auth && yes_code)
|
|
|
|
|
var/change = params["change"]
|
|
|
|
|
if(change == "reset")
|
|
|
|
|
timer_set = default_timer_set
|
|
|
|
|
else if(change == "decrease")
|
|
|
|
|
timer_set = max(minimum_timer_set, timer_set - 10)
|
|
|
|
|
else if(change == "increase")
|
|
|
|
|
timer_set = min(maximum_timer_set, timer_set + 10)
|
|
|
|
|
else if(change == "input")
|
|
|
|
|
var/user_input = input(usr, "Set time to detonation.", name) as null|num
|
|
|
|
|
if(!user_input)
|
|
|
|
|
return
|
|
|
|
|
var/N = text2num(user_input)
|
|
|
|
|
if(!N)
|
|
|
|
|
return
|
|
|
|
|
timer_set = CLAMP(N,minimum_timer_set,maximum_timer_set)
|
|
|
|
|
. = TRUE
|
|
|
|
|
if("safety")
|
|
|
|
|
if(auth && yes_code && !exploded)
|
|
|
|
|
set_safety()
|
|
|
|
|
else
|
|
|
|
|
playsound(src, 'sound/machines/nuke/angry_beep.ogg', 50, FALSE)
|
|
|
|
|
if("arm")
|
|
|
|
|
if(auth && yes_code && !safety && !exploded)
|
|
|
|
|
playsound(src, 'sound/machines/nuke/confirm_beep.ogg', 50, FALSE)
|
|
|
|
|
set_active()
|
|
|
|
|
update_ui_mode()
|
|
|
|
|
else
|
|
|
|
|
playsound(src, 'sound/machines/nuke/angry_beep.ogg', 50, FALSE)
|
|
|
|
|
if("anchor")
|
|
|
|
|
if(auth && yes_code)
|
|
|
|
|
playsound(src, 'sound/machines/nuke/general_beep.ogg', 50, FALSE)
|
|
|
|
|
set_anchor()
|
|
|
|
|
if("toggle_timer")
|
|
|
|
|
if(auth && yes_code && !safety && !exploded)
|
|
|
|
|
set_active()
|
|
|
|
|
else
|
|
|
|
|
playsound(src, 'sound/machines/nuke/angry_beep.ogg', 50, FALSE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/obj/machinery/nuclearbomb/proc/set_anchor()
|
|
|
|
|