/obj/item/device/gps
name = "space GPS"
desc = "Tells you your coordinates based on the nearest coordinate beacon."
icon_state = "gps"
item_state = "electronic"
var/allowtrack = 1 // defaults to on so people know where you are (sort of!)
var/serial = "4200" // shouldnt show up as this
var/identifier = "NT13" // four characters max plz
var/distress = 0
flags = FPRINT | TABLEPASS| CONDUCT
w_class = 2.0
m_amt = 50
g_amt = 100
mats = 2
module_research = list("science" = 1, "devices" = 1, "miniaturization" = 8)
proc/get_z_info(var/turf/T)
. = "Landmark: Unknown"
if (!T)
return
if (!istype(T))
T = get_turf(T)
if (!T)
return
if (T.z == 1)
if (map_setting == "DESTINY")
. = "Landmark: NSS Destiny"
else
. = "Landmark: Station"
else if (T.z == 2)
. = "Landmark: Restricted"
else if (T.z == 3)
. = "Landmark: Debris Field"
return
proc/show_HTML(var/mob/user)
if (!user)
return
user.machine = src
var/HTML = "(Refresh)
"
HTML += "Each GPS is coined with a unique four digit number followed by a four letter identifier.
This GPS is assigned [serial]-[identifier].
"
HTML += "Get Local Coordinates
"
if (allowtrack == 0)
HTML += "Enable Tracking
"
if (allowtrack == 1)
HTML += "Disable Tracking
"
HTML += "Change Identifier
"
HTML += "Toggle Distress Signal
"
HTML += "
"
HTML += "GPSes:
"
for (var/obj/item/device/gps/G in world)
if (G.allowtrack == 1)
var/turf/T = get_turf(G.loc)
if (!T)
continue
HTML += "[G.serial]-[G.identifier] located at: [T.x], [T.y]. [src.get_z_info(T)]
"
HTML += "[G.distress ? "(DISTRESS)" : "(DISTRESS)"]
"
HTML += "
"
HTML += "Tracking Implants:
"
for (var/obj/item/implant/tracking/imp in world)
if (iscarbon(imp.loc))
var/turf/T = get_turf(imp.loc)
if (!T)
continue
HTML += "[imp.loc.name] located at: [T.x], [T.y]. [src.get_z_info(T)]
"
HTML += "
"
HTML += "Beacons:
"
for (var/obj/machinery/beacon/B in machines)
if (B.enabled == 1)
var/turf/T = get_turf(B.loc)
HTML += "[B.sname] located at: [T.x], [T.y]. [src.get_z_info(T)]
"
HTML += "
"
//user << browse(HTML, "window=gps;size=400x540")
user.Browse(HTML, "window=gps_[src];title=GPS;size=400x540")
onclose(user, "gps")
attack_self(mob/user as mob)
if ((user.contents.Find(src) || user.contents.Find(src.master) || get_dist(src, user) <= 1 && istype(src.loc, /turf)))
src.show_HTML(user)
else
//user << browse(null, "window=gps")
user.Browse(null, "window=gps_[src]")
user.machine = null
return
Topic(href, href_list)
..()
if (usr.stat || usr.restrained() || usr.lying)
return
if ((usr.contents.Find(src) || usr.contents.Find(src.master) || in_range(src, usr) && istype(src.loc, /turf)))
usr.machine = src
if(href_list["getcords"])
boutput(usr, "Located at: X: [usr.x], Y: [usr.y]")
if(href_list["track1"])
boutput(usr, "Tracking enabled.")
src.allowtrack = 1
if(href_list["track2"])
boutput(usr, "Tracking disabled.")
src.allowtrack = 0
if(href_list["changeid"])
var/t = strip_html(input(usr, "Enter new GPS identification name (must be 4 characters)", src.identifier) as text)
if(length(t) > 4)
boutput(usr, "Input too long.")
return
if(length(t) < 4)
boutput(usr, "Input too short.")
return
if(!t)
return
src.identifier = t
if(href_list["help"])
if(!distress)
boutput(usr, "Sending distress signal.")
distress = 1
//IBMNOTE: This really should be changed to use the radio system, for (x in world) sucks
for(var/obj/item/device/gps/G in world)
G.visible_message("[bicon(G)] [G] beeps, \"NOTICE: Distress signal recieved.\".")
else
distress = 0
boutput(usr, "Distress signal cleared.")
for(var/obj/item/device/gps/G in world)
G.visible_message("[bicon(G)] [G] beeps, \"NOTICE: Distress signal cleared.\".")
if(href_list["refresh"])
..()
if (!src.master)
if (istype(src.loc, /mob))
attack_self(src.loc)
else
for(var/mob/M in viewers(1, src))
if (M.client && (M.machine == src.master || M.machine == src))
src.attack_self(M)
else
if (istype(src.master.loc, /mob))
src.attack_self(src.master.loc)
else
for(var/mob/M in viewers(1, src.master))
if (M.client && (M.machine == src.master || M.machine == src))
src.attack_self(M)
src.add_fingerprint(usr)
else
//usr << browse(null, "window=gps")
usr.Browse(null, "window=gps_[src]")
return
return
New()
serial = rand(4201,7999)
desc += " It's serial code is [src.serial]-[identifier]."
// coordinate beacons. pretty useless but whatever you never know
/obj/machinery/beacon
name = "coordinate beacon"
desc = "A coordinate beacon used for space GPSes."
icon = 'icons/obj/ship.dmi'
icon_state = "beacon"
var/sname = "unidentified"
var/enabled = 1
process()
if(enabled == 1)
use_power(50)
attack_hand()
enabled = !enabled
boutput(usr, "You switch the beacon [src.enabled ? "on" : "off"].")
attack_ai(mob/user as mob)
var/t = input(user, "Enter new beacon identification name", src.sname) as text
t = strip_html(replacetext(t, "'",""))
t = copytext(t, 1, 45)
if (!t)
return
src.sname = t