diff --git a/code/_onclick/observer.dm b/code/_onclick/observer.dm index 88309b5074..485df1de41 100644 --- a/code/_onclick/observer.dm +++ b/code/_onclick/observer.dm @@ -50,8 +50,8 @@ /obj/machinery/teleport/hub/attack_ghost(mob/user as mob) var/atom/l = loc var/obj/machinery/computer/teleporter/com = locate(/obj/machinery/computer/teleporter, locate(l.x - 2, l.y, l.z)) - if(com.locked) - user.loc = get_turf(com.locked) + if(com?.teleport_control.locked) + user.loc = get_turf(com.teleport_control.locked) /obj/effect/portal/attack_ghost(mob/user as mob) if(target) diff --git a/code/game/machinery/teleporter.dm b/code/game/machinery/teleporter.dm index 7fb7836aa5..1cf1e901fb 100644 --- a/code/game/machinery/teleporter.dm +++ b/code/game/machinery/teleporter.dm @@ -1,3 +1,6 @@ +////// +////// Teleporter computer +////// /obj/machinery/computer/teleporter name = "teleporter control console" desc = "Used to control a linked teleportation Hub and Station." @@ -5,23 +8,23 @@ icon_screen = "teleport" circuit = /obj/item/weapon/circuitboard/teleporter dir = 4 - var/obj/item/locked = null var/id = null var/one_time_use = 0 //Used for one-time-use teleport cards (such as clown planet coordinates.) //Setting this to 1 will set locked to null after a player enters the portal and will not allow hand-teles to open portals to that location. + var/datum/nano_module/program/teleport_control/teleport_control /obj/machinery/computer/teleporter/New() id = "[rand(1000, 9999)]" ..() underlays.Cut() underlays += image('icons/obj/stationobjs_vr.dmi', icon_state = "telecomp-wires") //VOREStation Edit: different direction for wires to account for dirs - return + teleport_control = new(src) /obj/machinery/computer/teleporter/Initialize() . = ..() - var/obj/machinery/teleport/station/station - var/obj/machinery/teleport/hub/hub - + var/obj/machinery/teleport/station/station = null + var/obj/machinery/teleport/hub/hub = null + // Search surrounding turfs for the station, and then search the station's surrounding turfs for the hub. for(var/direction in cardinal) station = locate(/obj/machinery/teleport/station, get_step(src, direction)) @@ -34,9 +37,15 @@ if(istype(station)) station.com = hub + teleport_control.hub = hub if(istype(hub)) hub.com = src + teleport_control.station = station + +/obj/machinery/computer/teleporter/Destroy() + qdel_null(teleport_control) + return ..() /obj/machinery/computer/teleporter/attackby(I as obj, mob/living/user as mob) if(istype(I, /obj/item/weapon/card/data/)) @@ -74,7 +83,7 @@ else for(var/mob/O in hearers(src, null)) O.show_message("Locked In", 2) - locked = L + teleport_control.locked = L one_time_use = 1 add_fingerprint(usr) @@ -86,57 +95,109 @@ /obj/machinery/teleport/station/attack_ai() attack_hand() -/obj/machinery/computer/teleporter/attack_hand(user as mob) - if(..()) return +/obj/machinery/computer/teleporter/attack_ai(mob/user) + ui_interact(user) - /* Ghosts can't use this one because it's a direct selection */ - if(istype(user, /mob/observer/dead)) return +/obj/machinery/computer/teleporter/attack_hand(mob/user) + add_fingerprint(user) + if(stat & (BROKEN|NOPOWER)) + return + ui_interact(user) - var/list/L = list() - var/list/areaindex = list() +/obj/machinery/computer/teleporter/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) + teleport_control.ui_interact(user, ui_key, ui, force_open) - for(var/obj/item/device/radio/beacon/R in all_beacons) - var/turf/T = get_turf(R) - if(!T) - continue - if(!(T.z in using_map.player_levels)) - continue - var/tmpname = T.loc.name - if(areaindex[tmpname]) - tmpname = "[tmpname] ([++areaindex[tmpname]])" - else - areaindex[tmpname] = 1 - L[tmpname] = R +/obj/machinery/computer/teleporter/interact(mob/user) + teleport_control.ui_interact(user) - for (var/obj/item/weapon/implant/tracking/I in all_tracking_implants) - if(!I.implanted || !ismob(I.loc)) - continue - else - var/mob/M = I.loc - if(M.stat == 2) - if(M.timeofdeath + 6000 < world.time) - continue - var/turf/T = get_turf(M) - if(T) continue - if(T.z == 2) continue - var/tmpname = M.real_name +////// +////// Nano-module for teleporter +////// +/datum/nano_module/program/teleport_control + name = "Teleporter Control" + var/locked_name = "Not Locked" + var/obj/item/locked = null + var/obj/machinery/teleport/station/station = null + var/obj/machinery/teleport/hub/hub = null + +/datum/nano_module/program/teleport_control/Topic(href, href_list) + if(..()) return 1 + + if(href_list["select_target"]) + var/list/L = list() + var/list/areaindex = list() + + for(var/obj/item/device/radio/beacon/R in all_beacons) + var/turf/T = get_turf(R) + if(!T) + continue + if(!(T.z in using_map.player_levels)) + continue + var/tmpname = T.loc.name if(areaindex[tmpname]) tmpname = "[tmpname] ([++areaindex[tmpname]])" else areaindex[tmpname] = 1 - L[tmpname] = I + L[tmpname] = R - var/desc = input("Please select a location to lock in.", "Locking Computer") in L|null - if(!desc) - return - if(get_dist(src, usr) > 1 && !issilicon(usr)) - return + for (var/obj/item/weapon/implant/tracking/I in all_tracking_implants) + if(!I.implanted || !ismob(I.loc)) + continue + else + var/mob/M = I.loc + if(M.stat == 2) + if(M.timeofdeath + 6000 < world.time) + continue + var/turf/T = get_turf(M) + if(T) continue + if(T.z == 2) continue + var/tmpname = M.real_name + if(areaindex[tmpname]) + tmpname = "[tmpname] ([++areaindex[tmpname]])" + else + areaindex[tmpname] = 1 + L[tmpname] = I - locked = L[desc] - for(var/mob/O in hearers(src, null)) - O.show_message("Locked In", 2) - add_fingerprint(usr) - return + var/desc = input("Please select a location to lock in.", "Locking Menu") in L|null + if(!desc) + return 0 + if(get_dist(host, usr) > 1 && !issilicon(usr)) + return 0 + + locked = L[desc] + locked_name = desc + return 1 + + if(href_list["test_fire"]) + station?.testfire() + return 1 + + if(href_list["toggle_on"]) + if(!station) + return 0 + + if(station.engaged) + station.disengage() + else + station.engage() + + return 1 + +/datum/nano_module/program/teleport_control/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = default_state) + var/list/data = host.initial_data() + + data["locked_name"] = locked_name ? locked_name : "No Target" + data["station_connected"] = station ? 1 : 0 + data["hub_connected"] = hub ? 1 : 0 + data["calibrated"] = hub ? hub.accurate : 0 + data["teleporter_on"] = station ? station.engaged : 0 + + ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open) + if(!ui) + ui = new(user, src, ui_key, "teleport_control.tmpl", "Teleport Control Console", 400, 500, state = state) + ui.set_initial_data(data) + ui.open() + ui.set_auto_update(1) /obj/machinery/computer/teleporter/verb/set_id(t as text) set category = "Object" @@ -158,6 +219,9 @@ if(!T || istype(T, /area)) return null return T +////// +////// Root of all the machinery +////// /obj/machinery/teleport name = "teleport" icon = 'icons/obj/stationobjs.dmi' @@ -165,6 +229,9 @@ anchored = 1.0 var/lockeddown = 0 +////// +////// The part you step into +////// /obj/machinery/teleport/hub name = "teleporter hub" desc = "It's the hub of a teleporting machine." @@ -183,6 +250,11 @@ underlays += image('icons/obj/stationobjs.dmi', icon_state = "tele-wires") default_apply_parts() +/obj/machinery/teleport/hub/Destroy() + com?.teleport_control.hub = null + com = null + return ..() + /obj/machinery/teleport/hub/Bumped(M as mob|obj) spawn() if(icon_state == "tele1") @@ -193,7 +265,7 @@ /obj/machinery/teleport/hub/proc/teleport(atom/movable/M as mob|obj) if(!com) return - if(!com.locked) + if(!com.teleport_control.locked) for(var/mob/O in hearers(src, null)) O.show_message("Failure: Cannot authenticate locked on coordinates. Please reinstate coordinate matrix.") return @@ -209,11 +281,11 @@ if(prob(5) && !accurate) //oh dear a problem, put em in deep space do_teleport(M, locate(rand((2*TRANSITIONEDGE), world.maxx - (2*TRANSITIONEDGE)), rand((2*TRANSITIONEDGE), world.maxy - (2*TRANSITIONEDGE)), 3), 2) else - do_teleport(M, com.locked) //dead-on precision + do_teleport(M, com.teleport_control.locked) //dead-on precision if(com.one_time_use) //Make one-time-use cards only usable one time! com.one_time_use = 0 - com.locked = null + com.teleport_control.locked = null else var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread s.set_up(5, 1, src) @@ -223,92 +295,10 @@ for(var/mob/B in hearers(src, null)) B.show_message("Test fire completed.") return -/* -/proc/do_teleport(atom/movable/M as mob|obj, atom/destination, precision) - if(istype(M, /obj/effect)) - qdel(M) - return - if(istype(M, /obj/item/weapon/disk/nuclear)) // Don't let nuke disks get teleported --NeoFite - for(var/mob/O in viewers(M, null)) - O.show_message(text("The [] bounces off of the portal!", M.name), 1) - return - if(istype(M, /mob/living)) - var/mob/living/MM = M - if(MM.check_contents_for(/obj/item/weapon/disk/nuclear)) - to_chat(MM, "Something you are carrying seems to be unable to pass through the portal. Better drop it if you want to go through.") - return - var/disky = 0 - for (var/atom/O in M.contents) //I'm pretty sure this accounts for the maximum amount of container in container stacking. --NeoFite - if(istype(O, /obj/item/weapon/storage) || istype(O, /obj/item/weapon/gift)) - for (var/obj/OO in O.contents) - if(istype(OO, /obj/item/weapon/storage) || istype(OO, /obj/item/weapon/gift)) - for (var/obj/OOO in OO.contents) - if(istype(OOO, /obj/item/weapon/disk/nuclear)) - disky = 1 - if(istype(OO, /obj/item/weapon/disk/nuclear)) - disky = 1 - if(istype(O, /obj/item/weapon/disk/nuclear)) - disky = 1 - if(istype(O, /mob/living)) - var/mob/living/MM = O - if(MM.check_contents_for(/obj/item/weapon/disk/nuclear)) - disky = 1 - if(disky) - for(var/mob/P in viewers(M, null)) - P.show_message(text("The [] bounces off of the portal!", M.name), 1) - return - -//Bags of Holding cause bluespace teleportation to go funky. --NeoFite - if(istype(M, /mob/living)) - var/mob/living/MM = M - if(MM.check_contents_for(/obj/item/weapon/storage/backpack/holding)) - to_chat(MM, "The Bluespace interface on your Bag of Holding interferes with the teleport!") - precision = rand(1,100) - if(istype(M, /obj/item/weapon/storage/backpack/holding)) - precision = rand(1,100) - for (var/atom/O in M.contents) //I'm pretty sure this accounts for the maximum amount of container in container stacking. --NeoFite - if(istype(O, /obj/item/weapon/storage) || istype(O, /obj/item/weapon/gift)) - for (var/obj/OO in O.contents) - if(istype(OO, /obj/item/weapon/storage) || istype(OO, /obj/item/weapon/gift)) - for (var/obj/OOO in OO.contents) - if(istype(OOO, /obj/item/weapon/storage/backpack/holding)) - precision = rand(1,100) - if(istype(OO, /obj/item/weapon/storage/backpack/holding)) - precision = rand(1,100) - if(istype(O, /obj/item/weapon/storage/backpack/holding)) - precision = rand(1,100) - if(istype(O, /mob/living)) - var/mob/living/MM = O - if(MM.check_contents_for(/obj/item/weapon/storage/backpack/holding)) - precision = rand(1,100) - - var/turf/destturf = get_turf(destination) - - var/tx = destturf.x + rand(precision * -1, precision) - var/ty = destturf.y + rand(precision * -1, precision) - - var/tmploc - - if(ismob(destination.loc)) //If this is an implant. - tmploc = locate(tx, ty, destturf.z) - else - tmploc = locate(tx, ty, destination.z) - - if(tx == destturf.x && ty == destturf.y && (istype(destination.loc, /obj/structure/closet) || istype(destination.loc, /obj/structure/closet/secure_closet))) - tmploc = destination.loc - - if(tmploc==null) - return - - M.loc = tmploc - sleep(2) - - var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread - s.set_up(5, 1, M) - s.start() - return -*/ +////// +////// The middle part +////// /obj/machinery/teleport/station name = "station" desc = "It's the station thingy of a teleport thingy." //seriously, wtf. @@ -327,18 +317,11 @@ . = ..() add_overlay("controller-wires") default_apply_parts() - -/obj/machinery/teleport/station/attackby(var/obj/item/weapon/W) - attack_hand() -/obj/machinery/teleport/station/attack_ai() - attack_hand() - -/obj/machinery/teleport/station/attack_hand() - if(engaged) - disengage() - else - engage() +/obj/machinery/teleport/station/Destroy() + com?.com?.teleport_control.station = null + com = null + return ..() /obj/machinery/teleport/station/proc/engage() if(stat & (BROKEN|NOPOWER)) @@ -370,27 +353,17 @@ engaged = 0 return -/obj/machinery/teleport/station/verb/testfire() - set name = "Test Fire Teleporter" - set category = "Object" - set src in oview(1) - - if(stat & (BROKEN|NOPOWER) || !istype(usr,/mob/living)) +/obj/machinery/teleport/station/proc/testfire() + if(!com || active) return - if(com && !active) - active = 1 - for(var/mob/O in hearers(src, null)) - O.show_message("Test firing!", 2) - com.teleport() - use_power(5000) - flick(src, "controller-c") //VOREStation Add + active = TRUE + visible_message("Test firing!") + com.teleport() + use_power(5000) + flick(src, "controller-c") //VOREStation Add - spawn(30) - active=0 - - add_fingerprint(usr) - return + VARSET_IN(src, active, FALSE, 3 SECONDS) /obj/machinery/teleport/station/power_change() ..() diff --git a/code/game/objects/items/weapons/teleportation.dm b/code/game/objects/items/weapons/teleportation.dm index 03436bafb5..c219c89eb7 100644 --- a/code/game/objects/items/weapons/teleportation.dm +++ b/code/game/objects/items/weapons/teleportation.dm @@ -147,11 +147,11 @@ Frequency: if(com) break break - if (istype(com, /obj/machinery/computer/teleporter) && com.locked && !com.one_time_use) + if (istype(com, /obj/machinery/computer/teleporter) && com.teleport_control.locked && !com.one_time_use) if(R.icon_state == "tele1") - L["[com.id] (Active)"] = com.locked + L["[com.id] (Active)"] = com.teleport_control.locked else - L["[com.id] (Inactive)"] = com.locked + L["[com.id] (Inactive)"] = com.teleport_control.locked var/list/turfs = list( ) for(var/turf/T in orange(10)) if(T.x>world.maxx-8 || T.x<8) continue //putting them at the edge is dumb diff --git a/nano/templates/teleport_control.tmpl b/nano/templates/teleport_control.tmpl new file mode 100644 index 0000000000..c849eb516f --- /dev/null +++ b/nano/templates/teleport_control.tmpl @@ -0,0 +1,44 @@ +