/* * Nuclearbomb -- A nuclear explosive * * Requires authentication disk and code to activate * * As used in "Nuclear" mode. * * TODO: Unify explosion proc with other explosions (plamsabombs, etc.) * */ obj/machinery/nuclearbomb desc = "Uh oh." name = "Nuclear Fission Explosive" icon = 'stationobjs.dmi' icon_state = "nuclearbomb0" density = 1 flags = FPRINT|DRIVABLE var extended = 0 // True if bomb is deployed timeleft = 60.0 // Time (seconds) until explosion timing = 0 // True if counting down the timer r_code = "ADMIN" // The activation code of the nuke code = "" // The code typed in yes_code = 0 // True if typed code matches safety = 1 // False to enable bomb to explode obj/item/weapon/disk/nuclear/auth = null // The authenication disk of the nuke, or null if none inserted // Create a nuclear bomb. // nuke_code is a global integer randomly set between 10000 and 99999 New() if (nuke_code) src.r_code = "[nuke_code]" ..() // Timed process // If timing, count down the timer and explode when expires // Update interaction window of viewing clients process() if (src.timing) src.timeleft-- if (src.timeleft <= 0) explode() src.updateDialog() // Monkey interact same as human attack_paw(mob/user) return src.attack_hand(user) // Human interact // If already deployed, show the interaction window // Otherwise, deploy and anchor the bomb attack_hand(mob/user) if (src.extended) // Bomb deployed? user.machine = src // insert auth disk here var/dat = {"Nuclear Fission Explosive
Auth. Disk: [(src.auth ? "++++++++++" : "----------")]
"} if (src.auth) // auth disk inserted if (src.yes_code) // and code is correct // show full control panel dat += {" Status: [(src.timing ? "Func/Set" : "Functional")]-[(src.safety ? "Safe" : "Engaged")]
Timer: [src.timeleft]

Timer: [(src.timing ? "On" : "Off")] Toggle
Time: - - [src.timeleft] + +

Safety: [(src.safety ? "On" : "Off")] Toggle
Anchor: [(src.anchored ? "Engaged" : "Off")] Toggle
"} else // otherwise, lock controls until code entered dat += {" Status: Auth. S2-[(src.safety ? "Safe" : "Engaged")]
Timer: [src.timeleft]

\nTimer: [(src.timing ? "On" : "Off")] Toggle
Time: - - [src.timeleft] + +

Safety: [(src.safety ? "On" : "Off")] Toggle
Anchor: [(src.anchored ? "Engaged" : "Off")] Toggle
"} else if (src.timing) // auth disk removed, but counting down, lock controls dat += {" Status: Set-[(src.safety ? "Safe" : "Engaged")]
Timer: [src.timeleft]

Timer: [(src.timing ? "On" : "Off")] Toggle
Time: - - [src.timeleft] + +

Safety: [(src.safety ? "On" : "Off")] Toggle
Anchor: [(src.anchored ? "Engaged" : "Off")] Toggle
"} else // also lock controls if not counting, no auth disk dat += {" Status: Auth. S1-[(src.safety ? "Safe" : "Engaged")]
Timer: [src.timeleft]

Timer: [(src.timing ? "On" : "Off")] Toggle
Time: - - [src.timeleft] + +

Safety: [(src.safety ? "On" : "Off")] Toggle
Anchor: [(src.anchored ? "Engaged" : "Off")] Toggle
"} var/message = "AUTH" if (src.auth) message = "[src.code]" if (src.yes_code) message = "*****" // The keypad - enter code here dat += {"
[message]
1-2-3
4-5-6
7-8-9
R-0-E
"} user.client_mob() << browse(dat, "window=nuclearbomb;size=300x400") else // Deploy and anchor the bomb. src.anchored = 1 flick("nuclearbombc", src) src.icon_state = "nuclearbomb1" src.extended = 1 return // Handle topic links from interaction window Topic(href, href_list) ..() if (usr.stat || usr.restrained()) return if ((!( istype(usr, /mob/human) ) && (!( ticker ) || (ticker && ticker.mode != "monkey")))) if (!istype(usr, /mob/drone)) usr.client_mob() << "\red You don't have the dexterity to do this!" return if ((usr.contents.Find(src) || (get_dist(src, usr) <= 1 && istype(src.loc, /turf)))) usr.machine = src if (href_list["auth"]) // auth link - if disk already inserted, remove it if (src.auth) src.auth.loc = src.loc src.yes_code = 0 src.auth = null else // if not inserted, check that it's in the player's hand var/obj/item/I = usr.equipped() if (istype(I, /obj/item/weapon/disk/nuclear)) usr.drop_item() I.loc = src src.auth = I if (src.auth) if (href_list["type"]) // keypad typing if (href_list["type"] == "E") // enter the current code, check against nuke code if (src.code == src.r_code) src.yes_code = 1 src.code = null else src.code = "ERROR" else if (href_list["type"] == "R") // reset code src.yes_code = 0 src.code = null else src.code += "[href_list["type"]]" // otherwise, add a digit if (length(src.code) > 5) src.code = "ERROR" if (src.yes_code) if (href_list["time"]) var/time = text2num(href_list["time"]) src.timeleft += time src.timeleft = min(max(round(src.timeleft), 5), 600) if (href_list["timer"]) if (src.timing == -1.0) return src.timing = !( src.timing ) if (src.timing) src.icon_state = "nuclearbomb2" else src.icon_state = "nuclearbomb1" if (href_list["safety"]) src.safety = !( src.safety ) if (href_list["anchor"]) src.anchored = !( src.anchored ) src.add_fingerprint(usr) src.updateDialog() else usr.client_mob() << browse(null, "window=nuclearbomb") return // On explosion, only (potentially) delete nuke if not about to explode ex_act() if (src.timing == -1.0) return else return ..() // Blob attack same as explosion blob_act() if (src.timing == -1.0) return else return ..() // Explode the nuke, destroying almost everything around // TODO: Unify this explosion proc with others proc/explode() if (src.safety) src.timing = 0 return src.timing = -1.0 src.yes_code = 0 src.icon_state = "nuclearbomb3" sleep(20) // 2 second delay var/turf/T = src.loc while(!( istype(T, /turf) )) T = T.loc var/min = 50 var/med = 250 var/max = 500 var/sw = locate(1, 1, T.z) // explosion encompasses whole of z-level var/ne = locate(world.maxx, world.maxy, T.z) defer_powernet_rebuild = 1 // Prevent powenet being rebuilt when cable objects deleted for(var/turf/U in block(sw, ne)) var/zone = 4 if ((U.y <= T.y + max && U.y >= T.y - max && U.x <= T.x + max && U.x >= T.x - max)) zone = 3 if ((U.y <= T.y + med && U.y >= T.y - med && U.x <= T.x + med && U.x >= T.x - med)) zone = 2 if ((U.y <= T.y + min && U.y >= T.y - min && U.x <= T.x + min && U.x >= T.x - min)) zone = 1 for(var/atom/A in U) A.ex_act(zone) U.ex_act(zone) U.buildlinks() defer_powernet_rebuild = 0 // Renable powernet rebuilt makepowernets() // And do so ticker.nuclear(src.z) // inform gameticker that nuke exploded del(src)