Files
VOREStation/code/game/machinery/telecomms/machine_interactions.dm
T

371 lines
12 KiB
Plaintext

//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:32
/*
All telecommunications interactions:
*/
#define STATION_Z 1
#define TELECOMM_Z 3
/obj/machinery/telecomms
var/temp = "" // output message
/obj/machinery/telecomms/attackby(obj/item/P as obj, mob/user as mob)
// Using a multitool lets you access the receiver's interface
if(istype(P, /obj/item/device/multitool))
attack_hand(user)
// REPAIRING: Use Nanopaste to repair 10-20 integrity points.
if(istype(P, /obj/item/stack/nanopaste))
var/obj/item/stack/nanopaste/T = P
if (integrity < 100) //Damaged, let's repair!
if (T.use(1))
integrity = between(0, integrity + rand(10,20), 100)
to_chat(usr, "You apply the Nanopaste to [src], repairing some of the damage.")
else
to_chat(usr, "This machine is already in perfect condition.")
return
if(default_deconstruction_screwdriver(user, P))
return
if(default_deconstruction_crowbar(user, P))
return
/obj/machinery/telecomms/attack_ai(var/mob/user as mob)
attack_hand(user)
/obj/machinery/telecomms/attack_hand(var/mob/user as mob)
// You need a multitool to use this, or be silicon
if(!issilicon(user))
// istype returns false if the value is null
if(!istype(user.get_active_hand(), /obj/item/device/multitool))
return
if(stat & (BROKEN|NOPOWER))
return
var/obj/item/device/multitool/P = get_multitool(user)
user.set_machine(src)
var/dat
dat = "<font face = \"Courier\"><HEAD><TITLE>[src.name]</TITLE></HEAD><center><H3>[src.name] Access</H3></center>"
dat += "<br>[temp]<br>"
dat += "<br>Power Status: <a href='?src=\ref[src];input=toggle'>[src.toggled ? "On" : "Off"]</a>"
if(on && toggled)
if(id != "" && id)
dat += "<br>Identification String: <a href='?src=\ref[src];input=id'>[id]</a>"
else
dat += "<br>Identification String: <a href='?src=\ref[src];input=id'>NULL</a>"
dat += "<br>Network: <a href='?src=\ref[src];input=network'>[network]</a>"
dat += "<br>Prefabrication: [autolinkers.len ? "TRUE" : "FALSE"]"
if(hide) dat += "<br>Shadow Link: ACTIVE</a>"
//Show additional options for certain machines.
dat += Options_Menu()
dat += "<br>Linked Network Entities: <ol>"
var/i = 0
for(var/obj/machinery/telecomms/T in links)
i++
if(T.hide && !src.hide)
continue
dat += "<li>\ref[T] [T.name] ([T.id]) <a href='?src=\ref[src];unlink=[i]'>\[X\]</a></li>"
dat += "</ol>"
dat += "<br>Filtering Frequencies: "
i = 0
if(length(freq_listening))
for(var/x in freq_listening)
i++
if(i < length(freq_listening))
dat += "[format_frequency(x)] GHz<a href='?src=\ref[src];delete=[x]'>\[X\]</a>; "
else
dat += "[format_frequency(x)] GHz<a href='?src=\ref[src];delete=[x]'>\[X\]</a>"
else
dat += "NONE"
dat += "<br> <a href='?src=\ref[src];input=freq'>\[Add Filter\]</a>"
dat += "<hr>"
if(P)
if(P.buffer)
dat += "<br><br>MULTITOOL BUFFER: [P.buffer] ([P.buffer.id]) <a href='?src=\ref[src];link=1'>\[Link\]</a> <a href='?src=\ref[src];flush=1'>\[Flush\]"
else
dat += "<br><br>MULTITOOL BUFFER: <a href='?src=\ref[src];buffer=1'>\[Add Machine\]</a>"
P.update_icon()
dat += "</font>"
temp = ""
user << browse(dat, "window=tcommachine;size=520x500;can_resize=0")
onclose(user, "dormitory")
// Off-Site Relays
//
// You are able to send/receive signals from the station's z level (changeable in the STATION_Z #define) if
// the relay is on the telecomm satellite (changable in the TELECOMM_Z #define)
/obj/machinery/telecomms/relay/proc/toggle_level()
var/turf/position = get_turf(src)
// Toggle on/off getting signals from the station or the current Z level
if(src.listening_level == STATION_Z) // equals the station
src.listening_level = position.z
return 1
else if(position.z == TELECOMM_Z)
src.listening_level = STATION_Z
return 1
return 0
// Returns a multitool from a user depending on their mobtype.
/obj/machinery/proc/get_multitool(mob/user as mob) //No need to have this being a telecomms specific proc.
var/obj/item/device/multitool/P = null
// Let's double check
if(!issilicon(user) && istype(user.get_active_hand(), /obj/item/device/multitool))
P = user.get_active_hand()
else if(isAI(user))
var/mob/living/silicon/ai/U = user
P = U.aiMulti
else if(isrobot(user) && in_range(user, src))
if(istype(user.get_active_hand(), /obj/item/device/multitool))
P = user.get_active_hand()
return P
// Additional Options for certain machines. Use this when you want to add an option to a specific machine.
// Example of how to use below.
/obj/machinery/telecomms/proc/Options_Menu()
return ""
/*
// Add an option to the processor to switch processing mode. (COMPRESS -> UNCOMPRESS or UNCOMPRESS -> COMPRESS)
/obj/machinery/telecomms/processor/Options_Menu()
var/dat = "<br>Processing Mode: <A href='?src=\ref[src];process=1'>[process_mode ? "UNCOMPRESS" : "COMPRESS"]</a>"
return dat
*/
// The topic for Additional Options. Use this for checking href links for your specific option.
// Example of how to use below.
/obj/machinery/telecomms/proc/Options_Topic(href, href_list)
return
/*
/obj/machinery/telecomms/processor/Options_Topic(href, href_list)
if(href_list["process"])
temp = "<font color = #666633>-% Processing mode changed. %-</font>"
src.process_mode = !src.process_mode
*/
// RELAY
/obj/machinery/telecomms/relay/Options_Menu()
var/dat = ""
if(src.z == TELECOMM_Z)
dat += "<br>Signal Locked to Station: <A href='?src=\ref[src];change_listening=1'>[listening_level == STATION_Z ? "TRUE" : "FALSE"]</a>"
dat += "<br>Broadcasting: <A href='?src=\ref[src];broadcast=1'>[broadcasting ? "YES" : "NO"]</a>"
dat += "<br>Receiving: <A href='?src=\ref[src];receive=1'>[receiving ? "YES" : "NO"]</a>"
return dat
/obj/machinery/telecomms/relay/Options_Topic(href, href_list)
if(href_list["receive"])
receiving = !receiving
temp = "<font color = #666633>-% Receiving mode changed. %-</font>"
if(href_list["broadcast"])
broadcasting = !broadcasting
temp = "<font color = #666633>-% Broadcasting mode changed. %-</font>"
if(href_list["change_listening"])
//Lock to the station OR lock to the current position!
//You need at least two receivers and two broadcasters for this to work, this includes the machine.
var/result = toggle_level()
if(result)
temp = "<font color = #666633>-% [src]'s signal has been successfully changed.</font>"
else
temp = "<font color = #666633>-% [src] could not lock it's signal onto the station. Two broadcasters or receivers required.</font>"
// BUS
/obj/machinery/telecomms/bus/Options_Menu()
var/dat = "<br>Change Signal Frequency: <A href='?src=\ref[src];change_freq=1'>[change_frequency ? "YES ([change_frequency])" : "NO"]</a>"
return dat
/obj/machinery/telecomms/bus/Options_Topic(href, href_list)
if(href_list["change_freq"])
var/newfreq = input(usr, "Specify a new frequency for new signals to change to. Enter null to turn off frequency changing. Decimals assigned automatically.", src, network) as null|num
if(canAccess(usr))
if(newfreq)
if(findtext(num2text(newfreq), "."))
newfreq *= 10 // shift the decimal one place
if(newfreq < 10000)
change_frequency = newfreq
temp = "<font color = #666633>-% New frequency to change to assigned: \"[newfreq] GHz\" %-</font>"
else
change_frequency = 0
temp = "<font color = #666633>-% Frequency changing deactivated %-</font>"
// BROADCASTER
/obj/machinery/telecomms/broadcaster/Options_Menu()
// Note the machine 'displays' 1 higher than overmap_range to save users from the abstraction that range '0' is valid and everything on the same turf.
var/dat = "<br>Broadcast Range (affects power usage)<br><a href='?src=\ref[src];range_down=1'>-</a> [overmap_range+1] gigameter\s <a href='?src=\ref[src];range_up=1'>+</a>"
return dat
/obj/machinery/telecomms/broadcaster/Options_Topic(href, href_list)
if(href_list["range_down"])
if(overmap_range > overmap_range_min)
overmap_range--
update_idle_power_usage(initial(idle_power_usage)**(overmap_range+1))
if(href_list["range_up"])
if(overmap_range < overmap_range_max)
overmap_range++
update_idle_power_usage(initial(idle_power_usage)**(overmap_range+1))
// RECEIVER
/obj/machinery/telecomms/receiver/Options_Menu()
// Note the machine 'displays' 1 higher than overmap_range to save users from the abstraction that range '0' is valid and everything on the same turf.
var/dat = "<br>Receive Range (affects power usage)<br><a href='?src=\ref[src];range_down=1'>-</a> [overmap_range+1] gigameter\s <a href='?src=\ref[src];range_up=1'>+</a>"
return dat
/obj/machinery/telecomms/receiver/Options_Topic(href, href_list)
if(href_list["range_down"])
if(overmap_range > overmap_range_min)
overmap_range--
update_idle_power_usage(initial(idle_power_usage)**(overmap_range+1))
if(href_list["range_up"])
if(overmap_range < overmap_range_max)
overmap_range++
update_idle_power_usage(initial(idle_power_usage)**(overmap_range+1))
/obj/machinery/telecomms/Topic(href, href_list)
if(!issilicon(usr))
if(!istype(usr.get_active_hand(), /obj/item/device/multitool))
return
if(stat & (BROKEN|NOPOWER))
return
var/obj/item/device/multitool/P = get_multitool(usr)
if(href_list["input"])
switch(href_list["input"])
if("toggle")
src.toggled = !src.toggled
temp = "<font color = #666633>-% [src] has been [src.toggled ? "activated" : "deactivated"].</font>"
update_power()
/*
if("hide")
src.hide = !hide
temp = "<font color = #666633>-% Shadow Link has been [src.hide ? "activated" : "deactivated"].</font>"
*/
if("id")
var/newid = copytext(reject_bad_text(input(usr, "Specify the new ID for this machine", src, id) as null|text),1,MAX_MESSAGE_LEN)
if(newid && canAccess(usr))
id = newid
temp = "<font color = #666633>-% New ID assigned: \"[id]\" %-</font>"
if("network")
var/newnet = input(usr, "Specify the new network for this machine. This will break all current links.", src, network) as null|text
if(newnet && canAccess(usr))
if(length(newnet) > 15)
temp = "<font color = #666633>-% Too many characters in new network tag %-</font>"
else
for(var/obj/machinery/telecomms/T in links)
T.links.Remove(src)
network = newnet
links = list()
temp = "<font color = #666633>-% New network tag assigned: \"[network]\" %-</font>"
if("freq")
var/newfreq = input(usr, "Specify a new frequency to filter (GHz). Decimals assigned automatically.", src, network) as null|num
if(newfreq && canAccess(usr))
if(findtext(num2text(newfreq), "."))
newfreq *= 10 // shift the decimal one place
if(!(newfreq in freq_listening) && newfreq < 10000)
freq_listening.Add(newfreq)
temp = "<font color = #666633>-% New frequency filter assigned: \"[newfreq] GHz\" %-</font>"
if(href_list["delete"])
// changed the layout about to workaround a pesky runtime -- Doohl
var/x = text2num(href_list["delete"])
temp = "<font color = #666633>-% Removed frequency filter [x] %-</font>"
freq_listening.Remove(x)
if(href_list["unlink"])
if(text2num(href_list["unlink"]) <= length(links))
var/obj/machinery/telecomms/T = links[text2num(href_list["unlink"])]
temp = "<font color = #666633>-% Removed \ref[T] [T.name] from linked entities. %-</font>"
// Remove link entries from both T and src.
if(src in T.links)
T.links.Remove(src)
links.Remove(T)
if(href_list["link"])
if(P)
if(P.buffer && P.buffer != src)
if(!(src in P.buffer.links))
P.buffer.links.Add(src)
if(!(P.buffer in src.links))
src.links.Add(P.buffer)
temp = "<font color = #666633>-% Successfully linked with \ref[P.buffer] [P.buffer.name] %-</font>"
else
temp = "<font color = #666633>-% Unable to acquire buffer %-</font>"
if(href_list["buffer"])
P.buffer = src
temp = "<font color = #666633>-% Successfully stored \ref[P.buffer] [P.buffer.name] in buffer %-</font>"
if(href_list["flush"])
temp = "<font color = #666633>-% Buffer successfully flushed. %-</font>"
P.buffer = null
src.Options_Topic(href, href_list)
usr.set_machine(src)
src.add_fingerprint(usr)
updateUsrDialog()
/obj/machinery/telecomms/proc/canAccess(var/mob/user)
if(issilicon(user) || in_range(user, src))
return 1
return 0
#undef TELECOMM_Z
#undef STATION_Z