/obj/machinery/computer/teleporter name = "teleporter control console" desc = "Used to control a linked teleportation Hub and Station." icon_screen = "teleport" icon_keyboard = "teleport_key" light_color = LIGHT_COLOR_BLUE circuit = /obj/item/circuitboard/computer/teleporter var/obj/item/device/gps/locked var/regime_set = "Teleporter" var/id var/obj/machinery/teleport/station/power_station var/calibrating var/turf/target //Used for one-time-use teleport cards (such as clown planet coordinates.) //Setting this to 1 will set src.locked to null after a player enters the portal and will not allow hand-teles to open portals to that location. /obj/machinery/computer/teleporter/Initialize() . = ..() id = "[rand(1000, 9999)]" link_power_station() /obj/machinery/computer/teleporter/Destroy() if (power_station) power_station.teleporter_console = null power_station = null return ..() /obj/machinery/computer/teleporter/proc/link_power_station() if(power_station) return for(var/direction in GLOB.cardinals) power_station = locate(/obj/machinery/teleport/station, get_step(src, direction)) if(power_station) break return power_station /obj/machinery/computer/teleporter/attackby(obj/I, mob/living/user, params) if(istype(I, /obj/item/device/gps)) var/obj/item/device/gps/L = I if(L.locked_location && !(stat & (NOPOWER|BROKEN))) if(!user.transferItemToLoc(L, src)) to_chat(user, "\the [I] is stuck to your hand, you cannot put it in \the [src]!") return locked = L to_chat(user, "You insert the GPS device into the [name]'s slot.") else return ..() /obj/machinery/computer/teleporter/attack_ai(mob/user) return attack_hand(user) /obj/machinery/computer/teleporter/attack_hand(mob/user) if(..()) return interact(user) /obj/machinery/computer/teleporter/interact(mob/user) var/data = "

Teleporter Status

" if(!power_station) data += "
No power station linked.
" else if(!power_station.teleporter_hub) data += "
No hub linked.
" else data += "
Current regime: [regime_set]
" data += "Current target: [(!target) ? "None" : "[get_area(target)] [(regime_set != "Gate") ? "" : "Teleporter"]"]
" if(calibrating) data += "Calibration: In Progress" else if(power_station.teleporter_hub.calibrated || power_station.teleporter_hub.accurate >= 3) data += "Calibration: Optimal" else data += "Calibration: Sub-Optimal" data += "

" data += "Change regime
" data += "Set target
" if(locked) data += "
Get target from memory
" data += "Eject GPS device
" else data += "
Get target from memory
" data += "Eject GPS device
" data += "
Calibrate Hub" var/datum/browser/popup = new(user, "teleporter", name, 400, 400) popup.set_content(data) popup.open() /obj/machinery/computer/teleporter/Topic(href, href_list) if(..()) return if(href_list["eject"]) eject() updateDialog() return if(!check_hub_connection()) say("Error: Unable to detect hub.") return if(calibrating) say("Error: Calibration in progress. Stand by.") return if(href_list["regimeset"]) power_station.engaged = 0 power_station.teleporter_hub.update_icon() power_station.teleporter_hub.calibrated = 0 reset_regime() if(href_list["settarget"]) power_station.engaged = 0 power_station.teleporter_hub.update_icon() power_station.teleporter_hub.calibrated = 0 set_target(usr) if(href_list["locked"]) power_station.engaged = 0 power_station.teleporter_hub.update_icon() power_station.teleporter_hub.calibrated = 0 target = get_turf(locked.locked_location) if(href_list["calibrate"]) if(!target) say("Error: No target set to calibrate to.") return if(power_station.teleporter_hub.calibrated || power_station.teleporter_hub.accurate >= 3) say("Hub is already calibrated!") return say("Processing hub calibration to target...") calibrating = 1 spawn(50 * (3 - power_station.teleporter_hub.accurate)) //Better parts mean faster calibration calibrating = 0 if(check_hub_connection()) power_station.teleporter_hub.calibrated = 1 say("Calibration complete.") else say("Error: Unable to detect hub.") updateDialog() updateDialog() /obj/machinery/computer/teleporter/proc/check_hub_connection() if(!power_station) return FALSE if(!power_station.teleporter_hub) return FALSE return TRUE /obj/machinery/computer/teleporter/proc/reset_regime() target = null if(regime_set == "Teleporter") regime_set = "Gate" else regime_set = "Teleporter" /obj/machinery/computer/teleporter/proc/eject() if(locked) locked.forceMove(get_turf(src)) locked = null /obj/machinery/computer/teleporter/proc/set_target(mob/user) var/list/L = list() var/list/areaindex = list() if(regime_set == "Teleporter") for(var/obj/item/device/radio/beacon/R in GLOB.teleportbeacons) var/turf/T = get_turf(R) if(!T) continue if(T.z == ZLEVEL_CENTCOM || T.z > ZLEVEL_SPACEMAX) continue L[avoid_assoc_duplicate_keys(T.loc.name, areaindex)] = R for(var/obj/item/implant/tracking/I in GLOB.tracked_implants) if(!I.imp_in || !ismob(I.loc)) continue else var/mob/M = I.loc if(M.stat == DEAD) if(M.timeofdeath + 6000 < world.time) continue var/turf/T = get_turf(M) if(!T) continue if(T.z == ZLEVEL_CENTCOM) continue L[avoid_assoc_duplicate_keys(M.real_name, areaindex)] = I var/desc = input("Please select a location to lock in.", "Locking Computer") as null|anything in L target = L[desc] else var/list/S = power_station.linked_stations if(!S.len) to_chat(user, "No connected stations located.") return for(var/obj/machinery/teleport/station/R in S) var/turf/T = get_turf(R) if(!T || !R.teleporter_hub || !R.teleporter_console) continue if(T.z == ZLEVEL_CENTCOM || T.z > ZLEVEL_SPACEMAX) continue L[avoid_assoc_duplicate_keys(T.loc.name, areaindex)] = R var/desc = input("Please select a station to lock in.", "Locking Computer") as null|anything in L target = L[desc] if(target) var/obj/machinery/teleport/station/trg = target trg.linked_stations |= power_station trg.stat &= ~NOPOWER if(trg.teleporter_hub) trg.teleporter_hub.stat &= ~NOPOWER trg.teleporter_hub.update_icon() if(trg.teleporter_console) trg.teleporter_console.stat &= ~NOPOWER trg.teleporter_console.update_icon()