Modern Modular Computers

This commit is contained in:
Unknown
2019-04-13 14:58:08 -04:00
parent a0904cb9fd
commit dfd9415458
164 changed files with 3597 additions and 2080 deletions
@@ -27,10 +27,7 @@ var/global/ntnrc_uid = 0
/datum/ntnet_conversation/proc/trim_message_list()
if(messages.len <= 50)
return
for(var/message in messages)
messages -= message
if(messages <= 50)
return
messages.Cut(1, (messages.len-49))
/datum/ntnet_conversation/proc/add_client(var/datum/computer_file/program/chatclient/C)
if(!istype(C))
+15 -1
View File
@@ -10,6 +10,7 @@ var/global/datum/ntnet/ntnet_global = new()
var/list/available_news = list()
var/list/chat_channels = list()
var/list/fileservers = list()
var/list/email_accounts = list() // I guess we won't have more than 999 email accounts active at once in single round, so this will do until Servers are implemented someday.
// Amount of logs the system tries to keep in memory. Keep below 999 to prevent byond from acting weirdly.
// High values make displaying logs much laggier.
var/setting_maxlogcount = 100
@@ -34,8 +35,13 @@ var/global/datum/ntnet/ntnet_global = new()
R.NTNet = src
build_software_lists()
build_news_list()
build_emails_list()
add_log("NTNet logging system activated.")
/datum/ntnet/proc/add_log_with_ids_check(var/log_string, var/obj/item/weapon/computer_hardware/network_card/source = null)
if(intrusion_detection_enabled)
add_log(log_string, source)
// Simplified logging: Adds a log. log_string is mandatory parameter, source is optional.
/datum/ntnet/proc/add_log(var/log_string, var/obj/item/weapon/computer_hardware/network_card/source = null)
var/log_text = "[stationtime2text()] - "
@@ -103,6 +109,10 @@ var/global/datum/ntnet/ntnet_global = new()
if(news.stored_data)
available_news.Add(news)
// Generates service email list. Currently only used by broadcaster service
/datum/ntnet/proc/build_emails_list()
for(var/F in subtypesof(/datum/computer_file/data/email_account/service))
new F()
// Attempts to find a downloadable file according to filename var
/datum/ntnet/proc/find_ntnet_file_by_name(var/filename)
@@ -153,7 +163,11 @@ var/global/datum/ntnet/ntnet_global = new()
setting_systemcontrol = !setting_systemcontrol
add_log("Configuration Updated. Wireless network firewall now [setting_systemcontrol ? "allows" : "disallows"] remote control of station's systems.")
/datum/ntnet/proc/does_email_exist(var/login)
for(var/datum/computer_file/data/email_account/A in ntnet_global.email_accounts)
if(A.login == login)
return 1
return 0
@@ -0,0 +1,82 @@
/datum/computer_file/data/email_account/
var/list/inbox = list()
var/list/spam = list()
var/list/deleted = list()
var/login = ""
var/password = ""
var/can_login = TRUE // Whether you can log in with this account. Set to false for system accounts
var/suspended = FALSE // Whether the account is banned by the SA.
/datum/computer_file/data/email_account/calculate_size()
size = 1
for(var/datum/computer_file/data/email_message/stored_message in all_emails())
stored_message.calculate_size()
size += stored_message.size
/datum/computer_file/data/email_account/New()
ntnet_global.email_accounts.Add(src)
..()
/datum/computer_file/data/email_account/Destroy()
ntnet_global.email_accounts.Remove(src)
. = ..()
/datum/computer_file/data/email_account/proc/all_emails()
return (inbox | spam | deleted)
/datum/computer_file/data/email_account/proc/send_mail(var/recipient_address, var/datum/computer_file/data/email_message/message, var/relayed = 0)
var/datum/computer_file/data/email_account/recipient
for(var/datum/computer_file/data/email_account/account in ntnet_global.email_accounts)
if(account.login == recipient_address)
recipient = account
break
if(!istype(recipient))
return 0
if(!recipient.receive_mail(message, relayed))
return
ntnet_global.add_log_with_ids_check("EMAIL LOG: [login] -> [recipient.login] title: [message.title].")
return 1
/datum/computer_file/data/email_account/proc/receive_mail(var/datum/computer_file/data/email_message/received_message, var/relayed)
received_message.set_timestamp()
if(!ntnet_global.intrusion_detection_enabled)
inbox.Add(received_message)
return 1
// Spam filters may occassionally let something through, or mark something as spam that isn't spam.
if(received_message.spam)
if(prob(98))
spam.Add(received_message)
else
inbox.Add(received_message)
else
if(prob(1))
spam.Add(received_message)
else
inbox.Add(received_message)
return 1
// Address namespace (@internal-services.nt) for email addresses with special purpose only!.
/datum/computer_file/data/email_account/service/
can_login = FALSE
/datum/computer_file/data/email_account/service/broadcaster/
login = "broadcast@internal-services.nt"
/datum/computer_file/data/email_account/service/broadcaster/receive_mail(var/datum/computer_file/data/email_message/received_message, var/relayed)
if(!istype(received_message) || relayed)
return 0
// Possibly exploitable for user spamming so keep admins informed.
if(!received_message.spam)
log_and_message_admins("Broadcast email address used by [usr]. Message title: [received_message.title].")
spawn(0)
for(var/datum/computer_file/data/email_account/email_account in ntnet_global.email_accounts)
var/datum/computer_file/data/email_message/new_message = received_message.clone()
send_mail(email_account.login, new_message, 1)
sleep(2)
return 1
@@ -0,0 +1,32 @@
// Currently not actually represented in file systems, though the support for it is in place already.
/datum/computer_file/data/email_message/
stored_data = ""
var/title = ""
var/source = ""
var/spam = FALSE
var/timestamp = ""
var/datum/computer_file/attachment = null
/datum/computer_file/data/email_message/clone()
var/datum/computer_file/data/email_message/temp = ..()
temp.title = title
temp.source = source
temp.spam = spam
temp.timestamp = timestamp
if(attachment)
temp.attachment = attachment.clone()
return temp
// Turns /email_message/ file into regular /data/ file.
/datum/computer_file/data/email_message/proc/export()
var/datum/computer_file/data/dat = new/datum/computer_file/data()
dat.stored_data = "Received from [source] at [timestamp]."
dat.stored_data += "\[b\][title]\[/b\]"
dat.stored_data += stored_data
dat.calculate_size()
return dat
/datum/computer_file/data/email_message/proc/set_timestamp()
timestamp = stationtime2text()
@@ -1,826 +0,0 @@
// This is the base type that does all the hardware stuff.
// Other types expand it - tablets use a direct subtypes, and
// consoles and laptops use "procssor" item that is held inside machinery piece
/obj/item/modular_computer
name = "Modular Microcomputer"
desc = "A small portable microcomputer."
var/enabled = 0 // Whether the computer is turned on.
var/screen_on = 1 // Whether the computer is active/opened/it's screen is on.
var/datum/computer_file/program/active_program = null // A currently active program running on the computer.
var/hardware_flag = 0 // A flag that describes this device type
var/last_power_usage = 0
var/last_battery_percent = 0 // Used for deciding if battery percentage has chandged
var/last_world_time = "00:00"
var/list/last_header_icons
var/computer_emagged = FALSE // Whether the computer is emagged.
var/apc_powered = FALSE
var/base_active_power_usage = 50 // Power usage when the computer is open (screen is active) and can be interacted with. Remember hardware can use power too.
var/base_idle_power_usage = 5 // Power usage when the computer is idle and screen is off (currently only applies to laptops)
// Modular computers can run on various devices. Each DEVICE (Laptop, Console, Tablet,..)
// must have it's own DMI file. Icon states must be called exactly the same in all files, but may look differently
// If you create a program which is limited to Laptops and Consoles you don't have to add it's icon_state overlay for Tablets too, for example.
icon = 'icons/obj/computer.dmi'
icon_state = "laptop-open"
var/icon_state_unpowered = null // Icon state when the computer is turned off
var/icon_state_menu = "menu" // Icon state overlay when the computer is turned on, but no program is loaded that would override the screen.
var/max_hardware_size = 0 // Maximal hardware size. Currently, tablets have 1, laptops 2 and consoles 3. Limits what hardware types can be installed.
var/steel_sheet_cost = 5 // Amount of steel sheets refunded when disassembling an empty frame of this computer.
var/light_strength = 0
// Damage of the chassis. If the chassis takes too much damage it will break apart.
var/damage = 0 // Current damage level
var/broken_damage = 50 // Damage level at which the computer ceases to operate
var/max_damage = 100 // Damage level at which the computer breaks apart.
// Important hardware (must be installed for computer to work)
var/obj/item/weapon/computer_hardware/processor_unit/processor_unit // CPU. Without it the computer won't run. Better CPUs can run more programs at once.
var/obj/item/weapon/computer_hardware/network_card/network_card // Network Card component of this computer. Allows connection to NTNet
var/obj/item/weapon/computer_hardware/hard_drive/hard_drive // Hard Drive component of this computer. Stores programs and files.
// Optional hardware (improves functionality, but is not critical for computer to work)
var/obj/item/weapon/computer_hardware/battery_module/battery_module // An internal power source for this computer. Can be recharged.
var/obj/item/weapon/computer_hardware/card_slot/card_slot // ID Card slot component of this computer. Mostly for HoP modification console that needs ID slot for modification.
var/obj/item/weapon/computer_hardware/nano_printer/nano_printer // Nano Printer component of this computer, for your everyday paperwork needs.
var/obj/item/weapon/computer_hardware/hard_drive/portable/portable_drive // Portable data storage
var/obj/item/weapon/computer_hardware/tesla_link/tesla_link // Tesla Link, Allows remote charging from nearest APC.
var/list/idle_threads = list() // Idle programs on background. They still receive process calls but can't be interacted with.
// Eject ID card from computer, if it has ID slot with card inside.
/obj/item/modular_computer/verb/eject_id()
set name = "Eject ID"
set category = "Object"
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
return
proc_eject_id(usr)
// Eject ID card from computer, if it has ID slot with card inside.
/obj/item/modular_computer/verb/eject_usb()
set name = "Eject Portable Storage"
set category = "Object"
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
return
proc_eject_usb(usr)
/obj/item/modular_computer/proc/proc_eject_id(mob/user)
if(!user)
user = usr
if(!card_slot)
to_chat(user, "\The [src] does not have an ID card slot")
return
if(!card_slot.stored_card)
to_chat(user, "There is no card in \the [src]")
return
if(active_program)
active_program.event_idremoved(0)
for(var/datum/computer_file/program/P in idle_threads)
P.event_idremoved(1)
card_slot.stored_card.forceMove(get_turf(src))
card_slot.stored_card = null
update_uis()
to_chat(user, "You remove the card from \the [src]")
/obj/item/modular_computer/proc/proc_eject_usb(mob/user)
if(!user)
user = usr
if(!portable_drive)
to_chat(user, "There is no portable device connected to \the [src].")
return
uninstall_component(user, portable_drive)
update_uis()
/obj/item/modular_computer/attack_ghost(var/mob/observer/dead/user)
if(enabled)
ui_interact(user)
else if(check_rights(R_ADMIN, 0, user))
var/response = alert(user, "This computer is turned off. Would you like to turn it on?", "Admin Override", "Yes", "No")
if(response == "Yes")
turn_on(user)
/obj/item/modular_computer/emag_act(var/remaining_charges, var/mob/user)
if(computer_emagged)
to_chat(user, "\The [src] was already emagged.")
return
else
computer_emagged = 1
to_chat(user, "You emag \the [src]. It's screen briefly shows a \"OVERRIDE ACCEPTED: New software downloads available.\" message.")
return 1
/obj/item/modular_computer/examine(var/mob/user)
..()
if(damage > broken_damage)
to_chat(user, "<span class='danger'>It is heavily damaged!</span>")
else if(damage)
to_chat(user, "It is damaged.")
/obj/item/modular_computer/New()
START_PROCESSING(SSobj, src)
update_icon()
..()
/obj/item/modular_computer/Destroy()
kill_program(1)
STOP_PROCESSING(SSobj, src)
for(var/obj/item/weapon/computer_hardware/CH in src.get_all_components())
uninstall_component(null, CH)
qdel(CH)
return ..()
/obj/item/modular_computer/update_icon()
icon_state = icon_state_unpowered
overlays.Cut()
if(!enabled)
set_light(0)
return
set_light(light_strength)
if(active_program)
overlays.Add(active_program.program_icon_state ? active_program.program_icon_state : icon_state_menu)
else
overlays.Add(icon_state_menu)
// Operates NanoUI
/obj/item/modular_computer/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
if(!screen_on || !enabled)
if(ui)
ui.close()
return 0
if(!apc_power(0) && !battery_power(0))
if(ui)
ui.close()
return 0
// If we have an active program switch to it now.
if(active_program)
if(ui) // This is the main laptop screen. Since we are switching to program's UI close it for now.
ui.close()
active_program.ui_interact(user)
return
// We are still here, that means there is no program loaded. Load the BIOS/ROM/OS/whatever you want to call it.
// This screen simply lists available programs and user may select them.
if(!hard_drive || !hard_drive.stored_files || !hard_drive.stored_files.len)
visible_message("\The [src] beeps three times, it's screen displaying \"DISK ERROR\" warning.")
return // No HDD, No HDD files list or no stored files. Something is very broken.
var/list/data = get_header_data()
var/list/programs = list()
for(var/datum/computer_file/program/P in hard_drive.stored_files)
var/list/program = list()
program["name"] = P.filename
program["desc"] = P.filedesc
if(P in idle_threads)
program["running"] = 1
programs.Add(list(program))
data["programs"] = programs
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "laptop_mainscreen.tmpl", "NTOS Main Menu", 400, 500)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
// On-click handling. Turns on the computer if it's off and opens the GUI.
/obj/item/modular_computer/attack_self(mob/user)
if(enabled)
ui_interact(user)
else
turn_on(user)
/obj/item/modular_computer/proc/break_apart()
visible_message("\The [src] breaks apart!")
var/turf/newloc = get_turf(src)
new /obj/item/stack/material/steel(newloc, round(steel_sheet_cost/2))
for(var/obj/item/weapon/computer_hardware/H in get_all_components())
uninstall_component(null, H)
H.forceMove(newloc)
if(prob(25))
H.take_damage(rand(10,30))
relay_qdel()
qdel()
/obj/item/modular_computer/proc/turn_on(var/mob/user)
if(tesla_link)
tesla_link.enabled = 1
var/issynth = issilicon(user) // Robots and AIs get different activation messages.
if(damage > broken_damage)
if(issynth)
to_chat(user, "You send an activation signal to \the [src], but it responds with an error code. It must be damaged.")
else
to_chat(user, "You press the power button, but the computer fails to boot up, displaying variety of errors before shutting down again.")
return
if(processor_unit && (apc_power(0) || battery_power(0))) // Battery-run and charged or non-battery but powered by APC.
if(issynth)
to_chat(user, "You send an activation signal to \the [src], turning it on")
else
to_chat(user, "You press the power button and start up \the [src]")
enabled = 1
update_icon()
ui_interact(user)
else // Unpowered
if(issynth)
to_chat(user, "You send an activation signal to \the [src] but it does not respond")
else
to_chat(user, "You press the power button but \the [src] does not respond")
// Process currently calls handle_power(), may be expanded in future if more things are added.
/obj/item/modular_computer/process()
if(!enabled) // The computer is turned off
last_power_usage = 0
return 0
if(damage > broken_damage)
shutdown_computer()
return 0
if(active_program && active_program.requires_ntnet && !get_ntnet_status(active_program.requires_ntnet_feature)) // Active program requires NTNet to run but we've just lost connection. Crash.
active_program.event_networkfailure(0)
for(var/datum/computer_file/program/P in idle_threads)
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature))
P.event_networkfailure(1)
if(active_program)
if(active_program.program_state != PROGRAM_STATE_KILLED)
active_program.ntnet_status = get_ntnet_status()
active_program.computer_emagged = computer_emagged
active_program.process_tick()
else
active_program = null
for(var/datum/computer_file/program/P in idle_threads)
if(P.program_state != PROGRAM_STATE_KILLED)
P.ntnet_status = get_ntnet_status()
P.computer_emagged = computer_emagged
P.process_tick()
else
idle_threads.Remove(P)
handle_power() // Handles all computer power interaction
check_update_ui_need()
// Function used by NanoUI's to obtain data for header. All relevant entries begin with "PC_"
/obj/item/modular_computer/proc/get_header_data()
var/list/data = list()
if(battery_module)
switch(battery_module.battery.percent())
if(80 to 200) // 100 should be maximal but just in case..
data["PC_batteryicon"] = "batt_100.gif"
if(60 to 80)
data["PC_batteryicon"] = "batt_80.gif"
if(40 to 60)
data["PC_batteryicon"] = "batt_60.gif"
if(20 to 40)
data["PC_batteryicon"] = "batt_40.gif"
if(5 to 20)
data["PC_batteryicon"] = "batt_20.gif"
else
data["PC_batteryicon"] = "batt_5.gif"
data["PC_batterypercent"] = "[round(battery_module.battery.percent())] %"
data["PC_showbatteryicon"] = 1
else
data["PC_batteryicon"] = "batt_5.gif"
data["PC_batterypercent"] = "N/C"
data["PC_showbatteryicon"] = battery_module ? 1 : 0
if(tesla_link && tesla_link.enabled && apc_powered)
data["PC_apclinkicon"] = "charging.gif"
switch(get_ntnet_status())
if(0)
data["PC_ntneticon"] = "sig_none.gif"
if(1)
data["PC_ntneticon"] = "sig_low.gif"
if(2)
data["PC_ntneticon"] = "sig_high.gif"
if(3)
data["PC_ntneticon"] = "sig_lan.gif"
if(idle_threads.len)
var/list/program_headers = list()
for(var/datum/computer_file/program/P in idle_threads)
if(!P.ui_header)
continue
program_headers.Add(list(list(
"icon" = P.ui_header
)))
data["PC_programheaders"] = program_headers
data["PC_stationtime"] = stationtime2text()
data["PC_hasheader"] = 1
data["PC_showexitprogram"] = active_program ? 1 : 0 // Hides "Exit Program" button on mainscreen
return data
// Relays kill program request to currently active program. Use this to quit current program.
/obj/item/modular_computer/proc/kill_program(var/forced = 0)
if(active_program)
active_program.kill_program(forced)
active_program = null
var/mob/user = usr
if(user && istype(user))
ui_interact(user) // Re-open the UI on this computer. It should show the main screen now.
update_icon()
// Returns 0 for No Signal, 1 for Low Signal and 2 for Good Signal. 3 is for wired connection (always-on)
/obj/item/modular_computer/proc/get_ntnet_status(var/specific_action = 0)
if(network_card)
return network_card.get_signal(specific_action)
else
return 0
/obj/item/modular_computer/proc/add_log(var/text)
if(!get_ntnet_status())
return 0
return ntnet_global.add_log(text, network_card)
/obj/item/modular_computer/proc/shutdown_computer(var/loud = 1)
kill_program(1)
for(var/datum/computer_file/program/P in idle_threads)
P.kill_program(1)
idle_threads.Remove(P)
if(loud)
visible_message("\The [src] shuts down.")
enabled = 0
update_icon()
return
// Handles user's GUI input
/obj/item/modular_computer/Topic(href, href_list)
if(..())
return 1
if( href_list["PC_exit"] )
kill_program()
return 1
if( href_list["PC_enable_component"] )
var/obj/item/weapon/computer_hardware/H = find_hardware_by_name(href_list["PC_enable_component"])
if(H && istype(H) && !H.enabled)
H.enabled = 1
. = 1
if( href_list["PC_disable_component"] )
var/obj/item/weapon/computer_hardware/H = find_hardware_by_name(href_list["PC_disable_component"])
if(H && istype(H) && H.enabled)
H.enabled = 0
. = 1
if( href_list["PC_shutdown"] )
shutdown_computer()
return 1
if( href_list["PC_minimize"] )
var/mob/user = usr
if(!active_program || !processor_unit)
return
idle_threads.Add(active_program)
active_program.program_state = PROGRAM_STATE_BACKGROUND // Should close any existing UIs
SSnanoui.close_uis(active_program.NM ? active_program.NM : active_program)
active_program = null
update_icon()
if(user && istype(user))
ui_interact(user) // Re-open the UI on this computer. It should show the main screen now.
if( href_list["PC_killprogram"] )
var/prog = href_list["PC_killprogram"]
var/datum/computer_file/program/P = null
var/mob/user = usr
if(hard_drive)
P = hard_drive.find_file_by_name(prog)
if(!istype(P) || P.program_state == PROGRAM_STATE_KILLED)
return
P.kill_program(1)
update_uis()
to_chat(user, "<span class='notice'>Program [P.filename].[P.filetype] with PID [rand(100,999)] has been killed.</span>")
if( href_list["PC_runprogram"] )
var/prog = href_list["PC_runprogram"]
var/datum/computer_file/program/P = null
var/mob/user = usr
if(hard_drive)
P = hard_drive.find_file_by_name(prog)
if(!P || !istype(P)) // Program not found or it's not executable program.
to_chat(user, "<span class='danger'>\The [src]'s screen shows \"I/O ERROR - Unable to run program\" warning.</span>")
return
P.computer = src
if(!P.is_supported_by_hardware(hardware_flag, 1, user))
return
// The program is already running. Resume it.
if(P in idle_threads)
P.program_state = PROGRAM_STATE_ACTIVE
active_program = P
idle_threads.Remove(P)
update_icon()
return
if(idle_threads.len >= processor_unit.max_idle_programs+1)
to_chat(user, "<span class='notice'>\The [src] displays a \"Maximal CPU load reached. Unable to run another program.\" error</span>")
return
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature)) // The program requires NTNet connection, but we are not connected to NTNet.
to_chat(user, "<span class='danger'>\The [src]'s screen shows \"NETWORK ERROR - Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning.</span>")
return
if(P.run_program(user))
active_program = P
update_icon()
return 1
if(.)
update_uis()
// Used in following function to reduce copypaste
/obj/item/modular_computer/proc/power_failure(var/malfunction = 0)
if(enabled) // Shut down the computer
visible_message("<span class='danger'>\The [src]'s screen flickers briefly and then goes dark.</span>")
if(active_program)
active_program.event_powerfailure(0)
for(var/datum/computer_file/program/PRG in idle_threads)
PRG.event_powerfailure(1)
shutdown_computer(0)
// Tries to use power from battery. Passing 0 as parameter results in this proc returning whether battery is functional or not.
/obj/item/modular_computer/proc/battery_power(var/power_usage = 0)
apc_powered = FALSE
if(!battery_module || !battery_module.check_functionality() || battery_module.battery.charge <= 0)
return FALSE
if(battery_module.battery.use(power_usage * CELLRATE) || ((power_usage == 0) && battery_module.battery.charge))
return TRUE
return FALSE
// Tries to use power from APC, if present.
/obj/item/modular_computer/proc/apc_power(var/power_usage = 0)
apc_powered = TRUE
// Tesla link was originally limited to machinery only, but this probably works too, and the benefit of being able to power all devices from an APC outweights
// the possible minor performance loss.
if(!tesla_link || !tesla_link.check_functionality())
return FALSE
var/area/A = get_area(src)
if(!istype(A) || !A.powered(EQUIP))
return FALSE
// At this point, we know that APC can power us for this tick. Check if we also need to charge our battery, and then actually use the power.
if(battery_module && (battery_module.battery.charge < battery_module.battery.maxcharge) && (power_usage > 0))
power_usage += tesla_link.passive_charging_rate
battery_module.battery.give(tesla_link.passive_charging_rate * CELLRATE)
A.use_power(power_usage, EQUIP)
return TRUE
// Handles power-related things, such as battery interaction, recharging, shutdown when it's discharged
/obj/item/modular_computer/proc/handle_power()
var/power_usage = screen_on ? base_active_power_usage : base_idle_power_usage
for(var/obj/item/weapon/computer_hardware/H in get_all_components())
if(H.enabled)
power_usage += H.power_usage
last_power_usage = power_usage
// First tries to charge from an APC, if APC is unavailable switches to battery power. If neither works the computer fails.
if(apc_power(power_usage))
return
if(battery_power(power_usage))
return
power_failure()
/obj/item/modular_computer/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if(istype(W, /obj/item/weapon/card/id)) // ID Card, try to insert it.
var/obj/item/weapon/card/id/I = W
if(!card_slot)
to_chat(user, "You try to insert \the [I] into \the [src], but it does not have an ID card slot installed.")
return
if(card_slot.stored_card)
to_chat(user, "You try to insert \the [I] into \the [src], but it's ID card slot is occupied.")
return
user.drop_from_inventory(I)
card_slot.stored_card = I
I.forceMove(src)
update_uis()
to_chat(user, "You insert \the [I] into \the [src].")
return
if(istype(W, /obj/item/weapon/paper))
if(!nano_printer)
return
nano_printer.attackby(W, user)
if(istype(W, /obj/item/weapon/computer_hardware))
var/obj/item/weapon/computer_hardware/C = W
if(C.hardware_size <= max_hardware_size)
try_install_component(user, C)
else
to_chat(user, "This component is too large for \the [src].")
if(W.is_wrench())
var/list/components = get_all_components()
if(components.len)
to_chat(user, "Remove all components from \the [src] before disassembling it.")
return
new /obj/item/stack/material/steel( get_turf(src.loc), steel_sheet_cost )
src.visible_message("\The [src] has been disassembled by [user].")
relay_qdel()
qdel(src)
return
if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
if(!WT.isOn())
to_chat(user, "\The [W] is off.")
return
if(!damage)
to_chat(user, "\The [src] does not require repairs.")
return
to_chat(user, "You begin repairing damage to \the [src]...")
if(WT.remove_fuel(round(damage/75)) && do_after(usr, damage/10))
damage = 0
to_chat(user, "You repair \the [src].")
return
if(W.is_screwdriver())
var/list/all_components = get_all_components()
if(!all_components.len)
to_chat(user, "This device doesn't have any components installed.")
return
var/list/component_names = list()
for(var/obj/item/weapon/computer_hardware/H in all_components)
component_names.Add(H.name)
var/choice = input(usr, "Which component do you want to uninstall?", "Computer maintenance", null) as null|anything in component_names
if(!choice)
return
if(!Adjacent(usr))
return
var/obj/item/weapon/computer_hardware/H = find_hardware_by_name(choice)
if(!H)
return
uninstall_component(user, H)
return
..()
// Used by processor to relay qdel() to machinery type.
/obj/item/modular_computer/proc/relay_qdel()
return
// Attempts to install the hardware into apropriate slot.
/obj/item/modular_computer/proc/try_install_component(var/mob/living/user, var/obj/item/weapon/computer_hardware/H, var/found = 0)
// "USB" flash drive.
if(istype(H, /obj/item/weapon/computer_hardware/hard_drive/portable))
if(portable_drive)
to_chat(user, "This computer's portable drive slot is already occupied by \the [portable_drive].")
return
found = 1
portable_drive = H
else if(istype(H, /obj/item/weapon/computer_hardware/hard_drive))
if(hard_drive)
to_chat(user, "This computer's hard drive slot is already occupied by \the [hard_drive].")
return
found = 1
hard_drive = H
else if(istype(H, /obj/item/weapon/computer_hardware/network_card))
if(network_card)
to_chat(user, "This computer's network card slot is already occupied by \the [network_card].")
return
found = 1
network_card = H
else if(istype(H, /obj/item/weapon/computer_hardware/nano_printer))
if(nano_printer)
to_chat(user, "This computer's nano printer slot is already occupied by \the [nano_printer].")
return
found = 1
nano_printer = H
else if(istype(H, /obj/item/weapon/computer_hardware/card_slot))
if(card_slot)
to_chat(user, "This computer's card slot is already occupied by \the [card_slot].")
return
found = 1
card_slot = H
else if(istype(H, /obj/item/weapon/computer_hardware/battery_module))
if(battery_module)
to_chat(user, "This computer's battery slot is already occupied by \the [battery_module].")
return
found = 1
battery_module = H
else if(istype(H, /obj/item/weapon/computer_hardware/processor_unit))
if(processor_unit)
to_chat(user, "This computer's processor slot is already occupied by \the [processor_unit].")
return
found = 1
processor_unit = H
else if(istype(H, /obj/item/weapon/computer_hardware/tesla_link))
if(tesla_link)
to_chat(user, "This computer's tesla link slot is already occupied by \the [tesla_link].")
return
found = 1
tesla_link = H
if(found)
to_chat(user, "You install \the [H] into \the [src]")
H.holder2 = src
user.drop_from_inventory(H)
H.forceMove(src)
// Uninstalls component. Found and Critical vars may be passed by parent types, if they have additional hardware.
/obj/item/modular_computer/proc/uninstall_component(var/mob/living/user, var/obj/item/weapon/computer_hardware/H, var/found = 0, var/critical = 0)
if(portable_drive == H)
portable_drive = null
found = 1
if(hard_drive == H)
hard_drive = null
found = 1
critical = 1
if(network_card == H)
network_card = null
found = 1
if(nano_printer == H)
nano_printer = null
found = 1
if(card_slot == H)
card_slot = null
found = 1
if(battery_module == H)
battery_module = null
found = 1
if(processor_unit == H)
processor_unit = null
found = 1
critical = 1
if(tesla_link == H)
tesla_link = null
found = 1
if(found)
if(user)
to_chat(user, "You remove \the [H] from \the [src].")
H.forceMove(get_turf(src))
H.holder2 = null
if(critical && enabled)
if(user)
to_chat(user, "<span class='danger'>\The [src]'s screen freezes for few seconds and then displays an \"HARDWARE ERROR: Critical component disconnected. Please verify component connection and reboot the device. If the problem persists contact technical support for assistance.\" warning.</span>")
shutdown_computer()
update_icon()
// Checks all hardware pieces to determine if name matches, if yes, returns the hardware piece, otherwise returns null
/obj/item/modular_computer/proc/find_hardware_by_name(var/name)
if(portable_drive && (portable_drive.name == name))
return portable_drive
if(hard_drive && (hard_drive.name == name))
return hard_drive
if(network_card && (network_card.name == name))
return network_card
if(nano_printer && (nano_printer.name == name))
return nano_printer
if(card_slot && (card_slot.name == name))
return card_slot
if(battery_module && (battery_module.name == name))
return battery_module
if(processor_unit && (processor_unit.name == name))
return processor_unit
if(tesla_link && (tesla_link.name == name))
return tesla_link
return null
// Returns list of all components
/obj/item/modular_computer/proc/get_all_components()
var/list/all_components = list()
if(hard_drive)
all_components.Add(hard_drive)
if(network_card)
all_components.Add(network_card)
if(portable_drive)
all_components.Add(portable_drive)
if(nano_printer)
all_components.Add(nano_printer)
if(card_slot)
all_components.Add(card_slot)
if(battery_module)
all_components.Add(battery_module)
if(processor_unit)
all_components.Add(processor_unit)
if(tesla_link)
all_components.Add(tesla_link)
return all_components
/obj/item/modular_computer/proc/update_uis()
if(active_program) //Should we update program ui or computer ui?
SSnanoui.update_uis(active_program)
if(active_program.NM)
SSnanoui.update_uis(active_program.NM)
else
SSnanoui.update_uis(src)
/obj/item/modular_computer/proc/check_update_ui_need()
var/ui_update_needed = 0
if(battery_module)
var/batery_percent = battery_module.battery.percent()
if(last_battery_percent != batery_percent) //Let's update UI on percent change
ui_update_needed = 1
last_battery_percent = batery_percent
if(stationtime2text() != last_world_time)
last_world_time = stationtime2text()
ui_update_needed = 1
if(idle_threads.len)
var/list/current_header_icons = list()
for(var/datum/computer_file/program/P in idle_threads)
if(!P.ui_header)
continue
current_header_icons[P.type] = P.ui_header
if(!last_header_icons)
last_header_icons = current_header_icons
else if(!listequal(last_header_icons, current_header_icons))
last_header_icons = current_header_icons
ui_update_needed = 1
else
for(var/x in last_header_icons|current_header_icons)
if(last_header_icons[x]!=current_header_icons[x])
last_header_icons = current_header_icons
ui_update_needed = 1
break
if(ui_update_needed)
update_uis()
/obj/item/modular_computer/proc/take_damage(var/amount, var/component_probability, var/damage_casing = 1, var/randomize = 1)
if(randomize)
// 75%-125%, rand() works with integers, apparently.
amount *= (rand(75, 125) / 100.0)
amount = round(amount)
if(damage_casing)
damage += amount
damage = between(0, damage, max_damage)
if(component_probability)
for(var/obj/item/weapon/computer_hardware/H in get_all_components())
if(prob(component_probability))
H.take_damage(round(amount / 2))
if(damage >= max_damage)
break_apart()
// Stronger explosions cause serious damage to internal components
// Minor explosions are mostly mitigitated by casing.
/obj/item/modular_computer/ex_act(var/severity)
take_damage(rand(100,200) / severity, 30 / severity)
// EMPs are similar to explosions, but don't cause physical damage to the casing. Instead they screw up the components
/obj/item/modular_computer/emp_act(var/severity)
take_damage(rand(100,200) / severity, 50 / severity, 0)
// "Stun" weapons can cause minor damage to components (short-circuits?)
// "Burn" damage is equally strong against internal components and exterior casing
// "Brute" damage mostly damages the casing.
/obj/item/modular_computer/bullet_act(var/obj/item/projectile/Proj)
switch(Proj.damage_type)
if(BRUTE)
take_damage(Proj.damage, Proj.damage / 2)
if(HALLOSS)
take_damage(Proj.damage, Proj.damage / 3, 0)
if(BURN)
take_damage(Proj.damage, Proj.damage / 1.5)
// Used by camera monitor program
/obj/item/modular_computer/check_eye(var/mob/user)
if(active_program)
return active_program.check_eye(user)
else
return ..()
@@ -1,75 +0,0 @@
// Held by /obj/machinery/modular_computer to reduce amount of copy-pasted code.
/obj/item/modular_computer/processor
name = "processing unit"
desc = "You shouldn't see this. If you do, report it."
icon = null
icon_state = null
icon_state_unpowered = null
icon_state_menu = null
hardware_flag = 0
var/obj/machinery/modular_computer/machinery_computer = null
/obj/item/modular_computer/processor/Destroy()
. = ..()
if(machinery_computer && (machinery_computer.cpu == src))
machinery_computer.cpu = null
machinery_computer = null
/obj/item/modular_computer/processor/nano_host()
return machinery_computer.nano_host()
// Due to how processes work, we'd receive two process calls - one from machinery type and one from our own type.
// Since we want this to be in-sync with machinery (as it's hidden type for machinery-based computers) we'll ignore
// non-relayed process calls.
/obj/item/modular_computer/processor/process(var/relayed = 0)
if(relayed)
..()
else
return
/obj/item/modular_computer/processor/examine(var/mob/user)
if(damage > broken_damage)
to_chat(user, "<span class='danger'>It is heavily damaged!</span>")
else if(damage)
to_chat(user, "It is damaged.")
/obj/item/modular_computer/processor/New(var/comp)
if(!comp || !istype(comp, /obj/machinery/modular_computer))
CRASH("Inapropriate type passed to obj/item/modular_computer/processor/New()! Aborting.")
return
// Obtain reference to machinery computer
machinery_computer = comp
machinery_computer.cpu = src
hardware_flag = machinery_computer.hardware_flag
max_hardware_size = machinery_computer.max_hardware_size
steel_sheet_cost = machinery_computer.steel_sheet_cost
max_damage = machinery_computer._max_damage
broken_damage = machinery_computer._break_damage
/obj/item/modular_computer/processor/relay_qdel()
qdel(machinery_computer)
/obj/item/modular_computer/processor/update_icon()
if(machinery_computer)
return machinery_computer.update_icon()
// This thing is not meant to be used on it's own, get topic data from our machinery owner.
/obj/item/modular_computer/processor/CanUseTopic(user, state)
if(!machinery_computer)
return 0
return machinery_computer.CanUseTopic(user, state)
/obj/item/modular_computer/processor/shutdown_computer()
if(!machinery_computer)
return
..()
machinery_computer.update_icon()
machinery_computer.use_power = 0
return
// Perform adjacency checks on our machinery counterpart, rather than on ourselves.
/obj/item/modular_computer/processor/Adjacent(var/atom/neighbor)
if(!machinery_computer)
return 0
return machinery_computer.Adjacent(neighbor)
@@ -1,112 +0,0 @@
/obj/machinery/modular_computer/console/preset/
// Can be changed to give devices specific hardware
var/_has_id_slot = 0
var/_has_printer = 0
var/_has_battery = 0
/obj/machinery/modular_computer/console/preset/New()
. = ..()
if(!cpu)
return
cpu.processor_unit = new/obj/item/weapon/computer_hardware/processor_unit(cpu)
if(_has_id_slot)
cpu.card_slot = new/obj/item/weapon/computer_hardware/card_slot(cpu)
if(_has_printer)
cpu.nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(cpu)
if(_has_battery)
cpu.battery_module = new/obj/item/weapon/computer_hardware/battery_module/super(cpu)
install_programs()
/obj/machinery/modular_computer/console/preset/proc/install_programs()
return
// ===== ENGINEERING CONSOLE =====
/obj/machinery/modular_computer/console/preset/engineering
console_department = "Engineering"
desc = "A stationary computer. This one comes preloaded with engineering programs."
/obj/machinery/modular_computer/console/preset/engineering/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/power_monitor())
cpu.hard_drive.store_file(new/datum/computer_file/program/alarm_monitor())
cpu.hard_drive.store_file(new/datum/computer_file/program/atmos_control())
cpu.hard_drive.store_file(new/datum/computer_file/program/rcon_console())
cpu.hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
// ===== MEDICAL CONSOLE =====
/obj/machinery/modular_computer/console/preset/medical
console_department = "Medbay"
desc = "A stationary computer. This one comes preloaded with medical programs."
/obj/machinery/modular_computer/console/preset/medical/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/suit_sensors())
cpu.hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
// ===== RESEARCH CONSOLE =====
/obj/machinery/modular_computer/console/preset/research
console_department = "Medbay"
desc = "A stationary computer. This one comes preloaded with research programs."
/obj/machinery/modular_computer/console/preset/research/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/ntnetmonitor())
cpu.hard_drive.store_file(new/datum/computer_file/program/nttransfer())
cpu.hard_drive.store_file(new/datum/computer_file/program/chatclient())
cpu.hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
// ===== COMMAND CONSOLE =====
/obj/machinery/modular_computer/console/preset/command
console_department = "Command"
desc = "A stationary computer. This one comes preloaded with command programs."
_has_id_slot = 1
_has_printer = 1
/obj/machinery/modular_computer/console/preset/command/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/chatclient())
cpu.hard_drive.store_file(new/datum/computer_file/program/card_mod())
cpu.hard_drive.store_file(new/datum/computer_file/program/comm())
cpu.hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
// ===== SECURITY CONSOLE =====
/obj/machinery/modular_computer/console/preset/security
console_department = "Security"
desc = "A stationary computer. This one comes preloaded with security programs."
/obj/machinery/modular_computer/console/preset/security/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
// ===== CIVILIAN CONSOLE =====
/obj/machinery/modular_computer/console/preset/civilian
console_department = "Civilian"
desc = "A stationary computer. This one comes preloaded with generic programs."
/obj/machinery/modular_computer/console/preset/civilian/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/chatclient())
cpu.hard_drive.store_file(new/datum/computer_file/program/nttransfer())
cpu.hard_drive.store_file(new/datum/computer_file/program/camera_monitor()) // Mainly for the entertainment channel, won't allow connection to other channels without access anyway
// ===== ERT CONSOLE =====
/obj/machinery/modular_computer/console/preset/ert
console_department = "Crescent"
desc = "A stationary computer. This one comes preloaded with various programs used by Nanotrasen response teams."
/obj/machinery/modular_computer/console/preset/ert/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/nttransfer())
cpu.hard_drive.store_file(new/datum/computer_file/program/camera_monitor/ert())
cpu.hard_drive.store_file(new/datum/computer_file/program/alarm_monitor())
cpu.hard_drive.store_file(new/datum/computer_file/program/comm())
// ===== MERCENARY CONSOLE =====
/obj/machinery/modular_computer/console/preset/mercenary
console_department = "Unset"
desc = "A stationary computer. This one comes preloaded with various programs used by shady organizations."
_has_printer = 1
_has_id_slot = 1
emagged = 1 // Allows download of other antag programs for free.
/obj/machinery/modular_computer/console/preset/ert/install_programs()
cpu.hard_drive.store_file(new/datum/computer_file/program/camera_monitor/hacked())
cpu.hard_drive.store_file(new/datum/computer_file/program/alarm_monitor())
@@ -1,129 +0,0 @@
// Global var to track modular computers
var/list/global_modular_computers = list()
// Modular Computer - device that runs various programs and operates with hardware
// DO NOT SPAWN THIS TYPE. Use /laptop/ or /console/ instead.
/obj/machinery/modular_computer/
name = "modular computer"
desc = "An advanced computer."
use_power = 0
var/hardware_flag = 0 // A flag that describes this device type
var/last_power_usage = 0 // Power usage during last tick
// Modular computers can run on various devices. Each DEVICE (Laptop, Console, Tablet,..)
// must have it's own DMI file. Icon states must be called exactly the same in all files, but may look differently
// If you create a program which is limited to Laptops and Consoles you don't have to add it's icon_state overlay for Tablets too, for example.
icon = null
icon_state = null
var/icon_state_unpowered = null // Icon state when the computer is turned off
var/screen_icon_state_menu = "menu" // Icon state overlay when the computer is turned on, but no program is loaded that would override the screen.
var/screen_icon_screensaver = "standby" // Icon state overlay when the computer is powered, but not 'switched on'.
var/max_hardware_size = 0 // Maximal hardware size. Currently, tablets have 1, laptops 2 and consoles 3. Limits what hardware types can be installed.
var/steel_sheet_cost = 10 // Amount of steel sheets refunded when disassembling an empty frame of this computer.
var/light_strength = 0 // Light luminosity when turned on
var/base_active_power_usage = 100 // Power usage when the computer is open (screen is active) and can be interacted with. Remember hardware can use power too.
var/base_idle_power_usage = 10 // Power usage when the computer is idle and screen is off (currently only applies to laptops)
var/_max_damage = 100
var/_break_damage = 50
var/obj/item/modular_computer/processor/cpu = null // CPU that handles most logic while this type only handles power and other specific things.
/obj/machinery/modular_computer/attack_ghost(var/mob/observer/dead/user)
if(cpu)
cpu.attack_ghost(user)
/obj/machinery/modular_computer/emag_act(var/remaining_charges, var/mob/user)
return //cpu ? cpu.emag_act(remaining_charges, user) : NO_EMAG_ACT
/obj/machinery/modular_computer/update_icon()
icon_state = icon_state_unpowered
overlays.Cut()
if(!cpu || !cpu.enabled)
if (!(stat & NOPOWER))
overlays.Add(screen_icon_screensaver)
set_light(0)
return
set_light(light_strength)
if(cpu.active_program)
overlays.Add(cpu.active_program.program_icon_state ? cpu.active_program.program_icon_state : screen_icon_state_menu)
else
overlays.Add(screen_icon_state_menu)
// Eject ID card from computer, if it has ID slot with card inside.
/obj/machinery/modular_computer/verb/eject_id()
set name = "Eject ID"
set category = "Object"
set src in view(1)
if(cpu)
cpu.eject_id()
// Eject ID card from computer, if it has ID slot with card inside.
/obj/machinery/modular_computer/verb/eject_usb()
set name = "Eject Portable Storage"
set category = "Object"
set src in view(1)
if(cpu)
cpu.eject_usb()
/obj/machinery/modular_computer/New()
..()
cpu = new(src)
global_modular_computers.Add(src)
/obj/machinery/modular_computer/Destroy()
if(cpu)
qdel(cpu)
cpu = null
return ..()
// On-click handling. Turns on the computer if it's off and opens the GUI.
/obj/machinery/modular_computer/attack_hand(mob/user)
if(cpu)
cpu.attack_self(user) // CPU is an item, that's why we route attack_hand to attack_self
/obj/machinery/modular_computer/examine(var/mob/user)
. = ..()
if(cpu)
cpu.examine(user)
// Process currently calls handle_power(), may be expanded in future if more things are added.
/obj/machinery/modular_computer/process()
if(cpu)
// Keep names in sync.
cpu.name = src.name
cpu.process(1)
/obj/machinery/modular_computer/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if(cpu)
return cpu.attackby(W, user)
return ..()
// Stronger explosions cause serious damage to internal components
// Minor explosions are mostly mitigitated by casing.
/obj/machinery/modular_computer/ex_act(var/severity)
if(cpu)
cpu.ex_act(severity)
// EMPs are similar to explosions, but don't cause physical damage to the casing. Instead they screw up the components
/obj/machinery/modular_computer/emp_act(var/severity)
if(cpu)
cpu.emp_act(severity)
// "Stun" weapons can cause minor damage to components (short-circuits?)
// "Burn" damage is equally strong against internal components and exterior casing
// "Brute" damage mostly damages the casing.
/obj/machinery/modular_computer/bullet_act(var/obj/item/projectile/Proj)
if(cpu)
cpu.bullet_act(Proj)
/obj/machinery/modular_computer/check_eye(var/mob/user)
if(cpu)
return cpu.check_eye(user)
return -1
@@ -1,45 +0,0 @@
/obj/machinery/modular_computer/console/
name = "console"
desc = "A stationary computer."
icon = 'icons/obj/modular_console.dmi'
icon_state = "console"
icon_state_unpowered = "console"
screen_icon_state_menu = "menu"
hardware_flag = PROGRAM_CONSOLE
var/console_department = "" // Used in New() to set network tag according to our area.
anchored = 1
density = 1
base_idle_power_usage = 100
base_active_power_usage = 500
max_hardware_size = 3
steel_sheet_cost = 20
light_strength = 4
_max_damage = 300
_break_damage = 150
/obj/machinery/modular_computer/console/buildable/New()
..()
// User-built consoles start as empty frames.
qdel(cpu.tesla_link)
qdel(cpu.network_card)
qdel(cpu.hard_drive)
/obj/machinery/modular_computer/console/New()
..()
cpu.network_card = new/obj/item/weapon/computer_hardware/network_card/wired(src)
cpu.tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
cpu.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/super(src) // Consoles generally have better HDDs due to lower space limitations
var/area/A = get_area(src)
// Attempts to set this console's tag according to our area. Since some areas have stuff like "XX - YY" in their names we try to remove that too.
if(A && console_department)
cpu.network_card.identification_string = replacetext(replacetext(replacetext("[A.name] [console_department] Console", " ", "_"), "-", ""), "__", "_") // Replace spaces with "_"
else if(A)
cpu.network_card.identification_string = replacetext(replacetext(replacetext("[A.name] Console", " ", "_"), "-", ""), "__", "_")
else if(console_department)
cpu.network_card.identification_string = replacetext(replacetext(replacetext("[console_department] Console", " ", "_"), "-", ""), "__", "_")
else
cpu.network_card.identification_string = "Unknown Console"
if(cpu)
cpu.screen_on = 1
update_icon()
@@ -1,110 +0,0 @@
// Laptop in it's item state, can be carried around.
/obj/item/laptop
name = "laptop computer"
desc = "A portable computer. It is closed."
icon = 'icons/obj/modular_laptop.dmi'
icon_state = "laptop-closed"
item_state = "laptop-inhand"
w_class = 3
var/obj/machinery/modular_computer/laptop/stored_computer = null
/obj/item/laptop/verb/open_computer()
set name = "Open Laptop"
set category = "Object"
set src in view(1)
if(usr.stat || usr.restrained() || usr.lying || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
return
if(!Adjacent(usr))
to_chat(usr, "You can't reach it.")
return
if(!istype(loc,/turf))
to_chat(usr, "[src] is too bulky! You'll have to set it down.")
return
if(!stored_computer)
if(contents.len)
for(var/obj/O in contents)
O.forceMove(src.loc)
to_chat(usr, "\The [src] crumbles to pieces.")
spawn(5)
qdel(src)
return
stored_computer.forceMove(src.loc)
stored_computer.stat &= ~MAINT
stored_computer.update_icon()
if(stored_computer.cpu)
stored_computer.cpu.screen_on = 1
loc = stored_computer
to_chat(usr, "You open \the [src].")
/obj/item/laptop/AltClick()
if(Adjacent(usr))
open_computer()
// The actual laptop
/obj/machinery/modular_computer/laptop
name = "laptop computer"
desc = "A portable computer."
var/obj/item/laptop/portable = null // Portable version of this computer, dropped on alt-click to allow transport. Used by laptops.
hardware_flag = PROGRAM_LAPTOP
icon_state_unpowered = "laptop-open" // Icon state when the computer is turned off
icon = 'icons/obj/modular_laptop.dmi'
icon_state = "laptop-open"
base_idle_power_usage = 25
base_active_power_usage = 200
max_hardware_size = 2
light_strength = 3
_max_damage = 200
_break_damage = 100
/obj/machinery/modular_computer/laptop/buildable/New()
..()
// User-built consoles start as empty frames.
qdel(cpu.tesla_link)
qdel(cpu.network_card)
qdel(cpu.hard_drive)
// Close the computer. collapsing it into movable item that can't be used.
/obj/machinery/modular_computer/laptop/verb/close_computer()
set name = "Close Laptop"
set category = "Object"
set src in view(1)
if(usr.stat || usr.restrained() || usr.lying || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
return
close_laptop(usr)
/obj/machinery/modular_computer/laptop/proc/close_laptop(mob/user = null)
if(istype(loc,/obj/item/laptop))
return
if(!istype(loc,/turf))
return
if(!portable)
portable=new
portable.stored_computer = src
portable.forceMove(src.loc)
src.forceMove(portable)
stat |= MAINT
if(user)
to_chat(user, "You close \the [src].")
if(cpu)
cpu.screen_on = 0
/obj/machinery/modular_computer/laptop/AltClick()
if(Adjacent(usr))
close_laptop()
@@ -0,0 +1,267 @@
/obj/item/modular_computer/process()
if(!enabled) // The computer is turned off
last_power_usage = 0
return 0
if(damage > broken_damage)
shutdown_computer()
return 0
if(active_program && active_program.requires_ntnet && !get_ntnet_status(active_program.requires_ntnet_feature)) // Active program requires NTNet to run but we've just lost connection. Crash.
active_program.event_networkfailure(0)
for(var/datum/computer_file/program/P in idle_threads)
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature))
P.event_networkfailure(1)
if(active_program)
if(active_program.program_state != PROGRAM_STATE_KILLED)
active_program.ntnet_status = get_ntnet_status()
active_program.computer_emagged = computer_emagged
active_program.process_tick()
else
active_program = null
for(var/datum/computer_file/program/P in idle_threads)
if(P.program_state != PROGRAM_STATE_KILLED)
P.ntnet_status = get_ntnet_status()
P.computer_emagged = computer_emagged
P.process_tick()
else
idle_threads.Remove(P)
handle_power() // Handles all computer power interaction
check_update_ui_need()
// Used to perform preset-specific hardware changes.
/obj/item/modular_computer/proc/install_default_hardware()
return 1
// Used to install preset-specific programs
/obj/item/modular_computer/proc/install_default_programs()
return 1
/obj/item/modular_computer/New()
START_PROCESSING(SSobj, src)
install_default_hardware()
if(hard_drive)
install_default_programs()
update_icon()
update_verbs()
..()
/obj/item/modular_computer/Destroy()
kill_program(1)
STOP_PROCESSING(SSobj, src)
for(var/obj/item/weapon/computer_hardware/CH in src.get_all_components())
uninstall_component(null, CH)
qdel(CH)
return ..()
/obj/item/modular_computer/emag_act(var/remaining_charges, var/mob/user)
if(computer_emagged)
to_chat(user, "\The [src] was already emagged.")
return //NO_EMAG_ACT
else
computer_emagged = 1
to_chat(user, "You emag \the [src]. It's screen briefly shows a \"OVERRIDE ACCEPTED: New software downloads available.\" message.")
return 1
/obj/item/modular_computer/update_icon()
icon_state = icon_state_unpowered
overlays.Cut()
if(bsod)
overlays.Add("bsod")
return
if(!enabled)
if(icon_state_screensaver)
overlays.Add(icon_state_screensaver)
set_light(0)
return
set_light(light_strength)
if(active_program)
overlays.Add(active_program.program_icon_state ? active_program.program_icon_state : icon_state_menu)
else
overlays.Add(icon_state_menu)
/obj/item/modular_computer/proc/turn_on(var/mob/user)
if(bsod)
return
if(tesla_link)
tesla_link.enabled = 1
var/issynth = issilicon(user) // Robots and AIs get different activation messages.
if(damage > broken_damage)
if(issynth)
to_chat(user, "You send an activation signal to \the [src], but it responds with an error code. It must be damaged.")
else
to_chat(user, "You press the power button, but the computer fails to boot up, displaying variety of errors before shutting down again.")
return
if(processor_unit && (apc_power(0) || battery_power(0))) // Battery-run and charged or non-battery but powered by APC.
if(issynth)
to_chat(user, "You send an activation signal to \the [src], turning it on")
else
to_chat(user, "You press the power button and start up \the [src]")
enable_computer(user)
else // Unpowered
if(issynth)
to_chat(user, "You send an activation signal to \the [src] but it does not respond")
else
to_chat(user, "You press the power button but \the [src] does not respond")
// Relays kill program request to currently active program. Use this to quit current program.
/obj/item/modular_computer/proc/kill_program(var/forced = 0)
if(active_program)
active_program.kill_program(forced)
active_program = null
var/mob/user = usr
if(user && istype(user))
ui_interact(user) // Re-open the UI on this computer. It should show the main screen now.
update_icon()
// Returns 0 for No Signal, 1 for Low Signal and 2 for Good Signal. 3 is for wired connection (always-on)
/obj/item/modular_computer/proc/get_ntnet_status(var/specific_action = 0)
if(network_card)
return network_card.get_signal(specific_action)
else
return 0
/obj/item/modular_computer/proc/add_log(var/text)
if(!get_ntnet_status())
return 0
return ntnet_global.add_log(text, network_card)
/obj/item/modular_computer/proc/shutdown_computer(var/loud = 1)
kill_program(1)
for(var/datum/computer_file/program/P in idle_threads)
P.kill_program(1)
idle_threads.Remove(P)
if(loud)
visible_message("\The [src] shuts down.")
enabled = 0
update_icon()
/obj/item/modular_computer/proc/enable_computer(var/mob/user = null)
enabled = 1
update_icon()
// Autorun feature
var/datum/computer_file/data/autorun = hard_drive ? hard_drive.find_file_by_name("autorun") : null
if(istype(autorun))
run_program(autorun.stored_data)
if(user)
ui_interact(user)
/obj/item/modular_computer/proc/minimize_program(mob/user)
if(!active_program || !processor_unit)
return
idle_threads.Add(active_program)
active_program.program_state = PROGRAM_STATE_BACKGROUND // Should close any existing UIs
SSnanoui.close_uis(active_program.NM ? active_program.NM : active_program)
active_program = null
update_icon()
if(istype(user))
ui_interact(user) // Re-open the UI on this computer. It should show the main screen now.
/obj/item/modular_computer/proc/run_program(prog)
var/datum/computer_file/program/P = null
var/mob/user = usr
if(hard_drive)
P = hard_drive.find_file_by_name(prog)
if(!P || !istype(P)) // Program not found or it's not executable program.
to_chat(user, "<span class='danger'>\The [src]'s screen shows \"I/O ERROR - Unable to run [prog]\" warning.</span>")
return
P.computer = src
if(!P.is_supported_by_hardware(hardware_flag, 1, user))
return
if(P in idle_threads)
P.program_state = PROGRAM_STATE_ACTIVE
active_program = P
idle_threads.Remove(P)
update_icon()
return
if(idle_threads.len >= processor_unit.max_idle_programs+1)
to_chat(user, "<span class='notice'>\The [src] displays a \"Maximal CPU load reached. Unable to run another program.\" error</span>")
return
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature)) // The program requires NTNet connection, but we are not connected to NTNet.
to_chat(user, "<span class='danger'>\The [src]'s screen shows \"NETWORK ERROR - Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning.</span>")
return
if(active_program)
minimize_program(user)
if(P.run_program(user))
active_program = P
update_icon()
return 1
/obj/item/modular_computer/proc/update_uis()
if(active_program) //Should we update program ui or computer ui?
SSnanoui.update_uis(active_program)
if(active_program.NM)
SSnanoui.update_uis(active_program.NM)
else
SSnanoui.update_uis(src)
/obj/item/modular_computer/proc/check_update_ui_need()
var/ui_update_needed = 0
if(battery_module)
var/batery_percent = battery_module.battery.percent()
if(last_battery_percent != batery_percent) //Let's update UI on percent change
ui_update_needed = 1
last_battery_percent = batery_percent
if(stationtime2text() != last_world_time)
last_world_time = stationtime2text()
ui_update_needed = 1
if(idle_threads.len)
var/list/current_header_icons = list()
for(var/datum/computer_file/program/P in idle_threads)
if(!P.ui_header)
continue
current_header_icons[P.type] = P.ui_header
if(!last_header_icons)
last_header_icons = current_header_icons
else if(!listequal(last_header_icons, current_header_icons))
last_header_icons = current_header_icons
ui_update_needed = 1
else
for(var/x in last_header_icons|current_header_icons)
if(last_header_icons[x]!=current_header_icons[x])
last_header_icons = current_header_icons
ui_update_needed = 1
break
if(ui_update_needed)
update_uis()
// Used by camera monitor program
/obj/item/modular_computer/check_eye(var/mob/user)
if(active_program)
return active_program.check_eye(user)
else
return ..()
/obj/item/modular_computer/proc/set_autorun(program)
if(!hard_drive)
return
var/datum/computer_file/data/autorun = hard_drive.find_file_by_name("autorun")
if(!istype(autorun))
autorun = new/datum/computer_file/data()
autorun.filename = "autorun"
hard_drive.store_file(autorun)
if(autorun.stored_data == program)
autorun.stored_data = null
else
autorun.stored_data = program
@@ -0,0 +1,55 @@
/obj/item/modular_computer/examine(var/mob/user)
. = ..()
if(damage > broken_damage)
to_chat(user, "<span class='danger'>It is heavily damaged!</span>")
else if(damage)
to_chat(user, "It is damaged.")
/obj/item/modular_computer/proc/break_apart()
visible_message("\The [src] breaks apart!")
var/turf/newloc = get_turf(src)
new /obj/item/stack/material/steel(newloc, round(steel_sheet_cost/2))
for(var/obj/item/weapon/computer_hardware/H in get_all_components())
uninstall_component(null, H)
H.forceMove(newloc)
if(prob(25))
H.take_damage(rand(10,30))
qdel()
/obj/item/modular_computer/proc/take_damage(var/amount, var/component_probability, var/damage_casing = 1, var/randomize = 1)
if(randomize)
// 75%-125%, rand() works with integers, apparently.
amount *= (rand(75, 125) / 100.0)
amount = round(amount)
if(damage_casing)
damage += amount
damage = between(0, damage, max_damage)
if(component_probability)
for(var/obj/item/weapon/computer_hardware/H in get_all_components())
if(prob(component_probability))
H.take_damage(round(amount / 2))
if(damage >= max_damage)
break_apart()
// Stronger explosions cause serious damage to internal components
// Minor explosions are mostly mitigitated by casing.
/obj/item/modular_computer/ex_act(var/severity)
take_damage(rand(100,200) / severity, 30 / severity)
// EMPs are similar to explosions, but don't cause physical damage to the casing. Instead they screw up the components
/obj/item/modular_computer/emp_act(var/severity)
take_damage(rand(100,200) / severity, 50 / severity, 0)
// "Stun" weapons can cause minor damage to components (short-circuits?)
// "Burn" damage is equally strong against internal components and exterior casing
// "Brute" damage mostly damages the casing.
/obj/item/modular_computer/bullet_act(var/obj/item/projectile/Proj)
switch(Proj.damage_type)
if(BRUTE)
take_damage(Proj.damage, Proj.damage / 2)
if(HALLOSS)
take_damage(Proj.damage, Proj.damage / 3, 0)
if(BURN)
take_damage(Proj.damage, Proj.damage / 1.5)
@@ -0,0 +1,139 @@
// Attempts to install the hardware into apropriate slot.
/obj/item/modular_computer/proc/try_install_component(var/mob/living/user, var/obj/item/weapon/computer_hardware/H, var/found = 0)
// "USB" flash drive.
if(istype(H, /obj/item/weapon/computer_hardware/hard_drive/portable))
if(portable_drive)
to_chat(user, "This computer's portable drive slot is already occupied by \the [portable_drive].")
return
found = 1
portable_drive = H
else if(istype(H, /obj/item/weapon/computer_hardware/hard_drive))
if(hard_drive)
to_chat(user, "This computer's hard drive slot is already occupied by \the [hard_drive].")
return
found = 1
hard_drive = H
else if(istype(H, /obj/item/weapon/computer_hardware/network_card))
if(network_card)
to_chat(user, "This computer's network card slot is already occupied by \the [network_card].")
return
found = 1
network_card = H
else if(istype(H, /obj/item/weapon/computer_hardware/nano_printer))
if(nano_printer)
to_chat(user, "This computer's nano printer slot is already occupied by \the [nano_printer].")
return
found = 1
nano_printer = H
else if(istype(H, /obj/item/weapon/computer_hardware/card_slot))
if(card_slot)
to_chat(user, "This computer's card slot is already occupied by \the [card_slot].")
return
found = 1
card_slot = H
else if(istype(H, /obj/item/weapon/computer_hardware/battery_module))
if(battery_module)
to_chat(user, "This computer's battery slot is already occupied by \the [battery_module].")
return
found = 1
battery_module = H
else if(istype(H, /obj/item/weapon/computer_hardware/processor_unit))
if(processor_unit)
to_chat(user, "This computer's processor slot is already occupied by \the [processor_unit].")
return
found = 1
processor_unit = H
else if(istype(H, /obj/item/weapon/computer_hardware/tesla_link))
if(tesla_link)
to_chat(user, "This computer's tesla link slot is already occupied by \the [tesla_link].")
return
found = 1
tesla_link = H
if(found)
to_chat(user, "You install \the [H] into \the [src]")
H.holder2 = src
user.drop_from_inventory(H)
H.forceMove(src)
update_verbs()
// Uninstalls component. Found and Critical vars may be passed by parent types, if they have additional hardware.
/obj/item/modular_computer/proc/uninstall_component(var/mob/living/user, var/obj/item/weapon/computer_hardware/H, var/found = 0, var/critical = 0)
if(portable_drive == H)
portable_drive = null
found = 1
if(hard_drive == H)
hard_drive = null
found = 1
critical = 1
if(network_card == H)
network_card = null
found = 1
if(nano_printer == H)
nano_printer = null
found = 1
if(card_slot == H)
card_slot = null
found = 1
if(battery_module == H)
battery_module = null
found = 1
if(processor_unit == H)
processor_unit = null
found = 1
critical = 1
if(tesla_link == H)
tesla_link = null
found = 1
if(found)
if(user)
to_chat(user, "You remove \the [H] from \the [src].")
H.forceMove(get_turf(src))
H.holder2 = null
update_verbs()
if(critical && enabled)
if(user)
to_chat(user, "<span class='danger'>\The [src]'s screen freezes for few seconds and then displays an \"HARDWARE ERROR: Critical component disconnected. Please verify component connection and reboot the device. If the problem persists contact technical support for assistance.\" warning.</span>")
shutdown_computer()
update_icon()
// Checks all hardware pieces to determine if name matches, if yes, returns the hardware piece, otherwise returns null
/obj/item/modular_computer/proc/find_hardware_by_name(var/name)
if(portable_drive && (portable_drive.name == name))
return portable_drive
if(hard_drive && (hard_drive.name == name))
return hard_drive
if(network_card && (network_card.name == name))
return network_card
if(nano_printer && (nano_printer.name == name))
return nano_printer
if(card_slot && (card_slot.name == name))
return card_slot
if(battery_module && (battery_module.name == name))
return battery_module
if(processor_unit && (processor_unit.name == name))
return processor_unit
if(tesla_link && (tesla_link.name == name))
return tesla_link
return null
// Returns list of all components
/obj/item/modular_computer/proc/get_all_components()
var/list/all_components = list()
if(hard_drive)
all_components.Add(hard_drive)
if(network_card)
all_components.Add(network_card)
if(portable_drive)
all_components.Add(portable_drive)
if(nano_printer)
all_components.Add(nano_printer)
if(card_slot)
all_components.Add(card_slot)
if(battery_module)
all_components.Add(battery_module)
if(processor_unit)
all_components.Add(processor_unit)
if(tesla_link)
all_components.Add(tesla_link)
return all_components
@@ -0,0 +1,200 @@
/obj/item/modular_computer/proc/update_verbs()
verbs.Cut()
if(portable_drive)
verbs |= /obj/item/modular_computer/verb/eject_usb
if(card_slot)
verbs |= /obj/item/modular_computer/verb/eject_id
verbs |= /obj/item/modular_computer/verb/emergency_shutdown
// Forcibly shut down the device. To be used when something bugs out and the UI is nonfunctional.
/obj/item/modular_computer/verb/emergency_shutdown()
set name = "Forced Shutdown"
set category = "Object"
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
return
if(enabled)
bsod = 1
update_icon()
shutdown_computer()
to_chat(usr, "You press a hard-reset button on \the [src]. It displays a brief debug screen before shutting down.")
spawn(2 SECONDS)
bsod = 0
update_icon()
// Eject ID card from computer, if it has ID slot with card inside.
/obj/item/modular_computer/verb/eject_id()
set name = "Eject ID"
set category = "Object"
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
return
proc_eject_id(usr)
// Eject ID card from computer, if it has ID slot with card inside.
/obj/item/modular_computer/verb/eject_usb()
set name = "Eject Portable Storage"
set category = "Object"
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
return
proc_eject_usb(usr)
/obj/item/modular_computer/proc/proc_eject_id(mob/user)
if(!user)
user = usr
if(!card_slot)
to_chat(user, "\The [src] does not have an ID card slot")
return
if(!card_slot.stored_card)
to_chat(user, "There is no card in \the [src]")
return
if(active_program)
active_program.event_idremoved(0)
for(var/datum/computer_file/program/P in idle_threads)
P.event_idremoved(1)
card_slot.stored_card.forceMove(get_turf(src))
card_slot.stored_card = null
update_uis()
to_chat(user, "You remove the card from \the [src]")
/obj/item/modular_computer/proc/proc_eject_usb(mob/user)
if(!user)
user = usr
if(!portable_drive)
to_chat(user, "There is no portable device connected to \the [src].")
return
uninstall_component(user, portable_drive)
update_uis()
/obj/item/modular_computer/attack_ghost(var/mob/observer/ghost/user)
if(enabled)
ui_interact(user)
else if(check_rights(R_ADMIN, 0, user))
var/response = alert(user, "This computer is turned off. Would you like to turn it on?", "Admin Override", "Yes", "No")
if(response == "Yes")
turn_on(user)
/obj/item/modular_computer/attack_ai(var/mob/user)
return attack_self(user)
/obj/item/modular_computer/attack_hand(var/mob/user)
if(anchored)
return attack_self(user)
return ..()
// On-click handling. Turns on the computer if it's off and opens the GUI.
/obj/item/modular_computer/attack_self(var/mob/user)
if(enabled && screen_on)
ui_interact(user)
else if(!enabled && screen_on)
turn_on(user)
/obj/item/modular_computer/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if(istype(W, /obj/item/weapon/card/id)) // ID Card, try to insert it.
var/obj/item/weapon/card/id/I = W
if(!card_slot)
to_chat(user, "You try to insert \the [I] into \the [src], but it does not have an ID card slot installed.")
return
if(card_slot.stored_card)
to_chat(user, "You try to insert \the [I] into \the [src], but it's ID card slot is occupied.")
return
user.drop_from_inventory(I)
card_slot.stored_card = I
I.forceMove(src)
update_uis()
to_chat(user, "You insert \the [I] into \the [src].")
return
if(istype(W, /obj/item/weapon/paper))
if(!nano_printer)
return
nano_printer.attackby(W, user)
if(istype(W, /obj/item/weapon/computer_hardware))
var/obj/item/weapon/computer_hardware/C = W
if(C.hardware_size <= max_hardware_size)
try_install_component(user, C)
else
to_chat(user, "This component is too large for \the [src].")
if(W.is_wrench())
var/list/components = get_all_components()
if(components.len)
to_chat(user, "Remove all components from \the [src] before disassembling it.")
return
new /obj/item/stack/material/steel( get_turf(src.loc), steel_sheet_cost )
src.visible_message("\The [src] has been disassembled by [user].")
qdel(src)
return
if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
if(!WT.isOn())
to_chat(user, "\The [W] is off.")
return
if(!damage)
to_chat(user, "\The [src] does not require repairs.")
return
to_chat(user, "You begin repairing damage to \the [src]...")
if(WT.remove_fuel(round(damage/75)) && do_after(usr, damage/10))
damage = 0
to_chat(user, "You repair \the [src].")
return
if(W.is_screwdriver())
var/list/all_components = get_all_components()
if(!all_components.len)
to_chat(user, "This device doesn't have any components installed.")
return
var/list/component_names = list()
for(var/obj/item/weapon/computer_hardware/H in all_components)
component_names.Add(H.name)
var/choice = input(usr, "Which component do you want to uninstall?", "Computer maintenance", null) as null|anything in component_names
if(!choice)
return
if(!Adjacent(usr))
return
var/obj/item/weapon/computer_hardware/H = find_hardware_by_name(choice)
if(!H)
return
uninstall_component(user, H)
return
..()
@@ -0,0 +1,51 @@
/obj/item/modular_computer/proc/power_failure(var/malfunction = 0)
if(enabled) // Shut down the computer
visible_message("<span class='danger'>\The [src]'s screen flickers briefly and then goes dark.</span>")
if(active_program)
active_program.event_powerfailure(0)
for(var/datum/computer_file/program/PRG in idle_threads)
PRG.event_powerfailure(1)
shutdown_computer(0)
// Tries to use power from battery. Passing 0 as parameter results in this proc returning whether battery is functional or not.
/obj/item/modular_computer/proc/battery_power(var/power_usage = 0)
apc_powered = FALSE
if(!battery_module || !battery_module.check_functionality() || battery_module.battery.charge <= 0)
return FALSE
if(battery_module.battery.use(power_usage * CELLRATE) || ((power_usage == 0) && battery_module.battery.charge))
return TRUE
return FALSE
// Tries to use power from APC, if present.
/obj/item/modular_computer/proc/apc_power(var/power_usage = 0)
apc_powered = TRUE
// Tesla link was originally limited to machinery only, but this probably works too, and the benefit of being able to power all devices from an APC outweights
// the possible minor performance loss.
if(!tesla_link || !tesla_link.check_functionality())
return FALSE
var/area/A = get_area(src)
if(!istype(A) || !A.powered(EQUIP))
return FALSE
// At this point, we know that APC can power us for this tick. Check if we also need to charge our battery, and then actually use the power.
if(battery_module && (battery_module.battery.charge < battery_module.battery.maxcharge) && (power_usage > 0))
power_usage += tesla_link.passive_charging_rate
battery_module.battery.give(tesla_link.passive_charging_rate * CELLRATE)
A.use_power(power_usage, EQUIP)
return TRUE
// Handles power-related things, such as battery interaction, recharging, shutdown when it's discharged
/obj/item/modular_computer/proc/handle_power()
var/power_usage = screen_on ? base_active_power_usage : base_idle_power_usage
for(var/obj/item/weapon/computer_hardware/H in get_all_components())
if(H.enabled)
power_usage += H.power_usage
last_power_usage = power_usage
// First tries to charge from an APC, if APC is unavailable switches to battery power. If neither works the computer fails.
if(apc_power(power_usage))
return
if(battery_power(power_usage))
return
power_failure()
@@ -0,0 +1,151 @@
// Operates NanoUI
/obj/item/modular_computer/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
if(!screen_on || !enabled)
if(ui)
ui.close()
return 0
if(!apc_power(0) && !battery_power(0))
if(ui)
ui.close()
return 0
// If we have an active program switch to it now.
if(active_program)
if(ui) // This is the main laptop screen. Since we are switching to program's UI close it for now.
ui.close()
active_program.ui_interact(user)
return
// We are still here, that means there is no program loaded. Load the BIOS/ROM/OS/whatever you want to call it.
// This screen simply lists available programs and user may select them.
if(!hard_drive || !hard_drive.stored_files || !hard_drive.stored_files.len)
visible_message("\The [src] beeps three times, it's screen displaying \"DISK ERROR\" warning.")
return // No HDD, No HDD files list or no stored files. Something is very broken.
var/datum/computer_file/data/autorun = hard_drive.find_file_by_name("autorun")
var/list/data = get_header_data()
var/list/programs = list()
for(var/datum/computer_file/program/P in hard_drive.stored_files)
var/list/program = list()
program["name"] = P.filename
program["desc"] = P.filedesc
program["autorun"] = (istype(autorun) && (autorun.stored_data == P.filename)) ? 1 : 0
if(P in idle_threads)
program["running"] = 1
programs.Add(list(program))
data["programs"] = programs
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "laptop_mainscreen.tmpl", "NTOS Main Menu", 400, 500)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
// Handles user's GUI input
/obj/item/modular_computer/Topic(href, href_list)
if(..())
return 1
if( href_list["PC_exit"] )
kill_program()
return 1
if( href_list["PC_enable_component"] )
var/obj/item/weapon/computer_hardware/H = find_hardware_by_name(href_list["PC_enable_component"])
if(H && istype(H) && !H.enabled)
H.enabled = 1
. = 1
if( href_list["PC_disable_component"] )
var/obj/item/weapon/computer_hardware/H = find_hardware_by_name(href_list["PC_disable_component"])
if(H && istype(H) && H.enabled)
H.enabled = 0
. = 1
if( href_list["PC_shutdown"] )
shutdown_computer()
return 1
if( href_list["PC_minimize"] )
var/mob/user = usr
minimize_program(user)
if( href_list["PC_killprogram"] )
var/prog = href_list["PC_killprogram"]
var/datum/computer_file/program/P = null
var/mob/user = usr
if(hard_drive)
P = hard_drive.find_file_by_name(prog)
if(!istype(P) || P.program_state == PROGRAM_STATE_KILLED)
return
P.kill_program(1)
update_uis()
to_chat(user, "<span class='notice'>Program [P.filename].[P.filetype] with PID [rand(100,999)] has been killed.</span>")
if( href_list["PC_runprogram"] )
return run_program(href_list["PC_runprogram"])
if( href_list["PC_setautorun"] )
if(!hard_drive)
return
set_autorun(href_list["PC_setautorun"])
if(.)
update_uis()
// Function used by NanoUI's to obtain data for header. All relevant entries begin with "PC_"
/obj/item/modular_computer/proc/get_header_data()
var/list/data = list()
if(battery_module)
switch(battery_module.battery.percent())
if(80 to 200) // 100 should be maximal but just in case..
data["PC_batteryicon"] = "batt_100.gif"
if(60 to 80)
data["PC_batteryicon"] = "batt_80.gif"
if(40 to 60)
data["PC_batteryicon"] = "batt_60.gif"
if(20 to 40)
data["PC_batteryicon"] = "batt_40.gif"
if(5 to 20)
data["PC_batteryicon"] = "batt_20.gif"
else
data["PC_batteryicon"] = "batt_5.gif"
data["PC_batterypercent"] = "[round(battery_module.battery.percent())] %"
data["PC_showbatteryicon"] = 1
else
data["PC_batteryicon"] = "batt_5.gif"
data["PC_batterypercent"] = "N/C"
data["PC_showbatteryicon"] = battery_module ? 1 : 0
if(tesla_link && tesla_link.enabled && apc_powered)
data["PC_apclinkicon"] = "charging.gif"
switch(get_ntnet_status())
if(0)
data["PC_ntneticon"] = "sig_none.gif"
if(1)
data["PC_ntneticon"] = "sig_low.gif"
if(2)
data["PC_ntneticon"] = "sig_high.gif"
if(3)
data["PC_ntneticon"] = "sig_lan.gif"
var/list/program_headers = list()
for(var/datum/computer_file/program/P in idle_threads)
if(!P.ui_header)
continue
program_headers.Add(list(list(
"icon" = P.ui_header
)))
if(active_program && active_program.ui_header)
program_headers.Add(list(list(
"icon" = active_program.ui_header
)))
data["PC_programheaders"] = program_headers
data["PC_stationtime"] = stationtime2text()
data["PC_hasheader"] = 1
data["PC_showexitprogram"] = active_program ? 1 : 0 // Hides "Exit Program" button on mainscreen
return data
@@ -0,0 +1,53 @@
// This is the base type that handles everything. Subtypes can be easily created by tweaking variables in this file to your liking.
/obj/item/modular_computer
name = "Modular Computer"
desc = "A modular computer. You shouldn't see this."
var/enabled = 0 // Whether the computer is turned on.
var/screen_on = 1 // Whether the computer is active/opened/it's screen is on.
var/datum/computer_file/program/active_program = null // A currently active program running on the computer.
var/hardware_flag = 0 // A flag that describes this device type
var/last_power_usage = 0 // Last tick power usage of this computer
var/last_battery_percent = 0 // Used for deciding if battery percentage has chandged
var/last_world_time = "00:00"
var/list/last_header_icons
var/computer_emagged = FALSE // Whether the computer is emagged.
var/apc_powered = FALSE // Set automatically. Whether the computer used APC power last tick.
var/base_active_power_usage = 50 // Power usage when the computer is open (screen is active) and can be interacted with. Remember hardware can use power too.
var/base_idle_power_usage = 5 // Power usage when the computer is idle and screen is off (currently only applies to laptops)
var/bsod = FALSE // Error screen displayed
// Modular computers can run on various devices. Each DEVICE (Laptop, Console, Tablet,..)
// must have it's own DMI file. Icon states must be called exactly the same in all files, but may look differently
// If you create a program which is limited to Laptops and Consoles you don't have to add it's icon_state overlay for Tablets too, for example.
icon = null // This thing isn't meant to be used on it's own. Subtypes should supply their own icon.
icon_state = null
//center_of_mass = null // No pixelshifting by placing on tables, etc.
//randpixel = 0 // And no random pixelshifting on-creation either.
var/icon_state_unpowered = null // Icon state when the computer is turned off
var/icon_state_menu = "menu" // Icon state overlay when the computer is turned on, but no program is loaded that would override the screen.
var/icon_state_screensaver = null
var/max_hardware_size = 0 // Maximal hardware size. Currently, tablets have 1, laptops 2 and consoles 3. Limits what hardware types can be installed.
var/steel_sheet_cost = 5 // Amount of steel sheets refunded when disassembling an empty frame of this computer.
var/light_strength = 0 // Intensity of light this computer emits. Comparable to numbers light fixtures use.
var/list/idle_threads = list() // Idle programs on background. They still receive process calls but can't be interacted with.
// Damage of the chassis. If the chassis takes too much damage it will break apart.
var/damage = 0 // Current damage level
var/broken_damage = 50 // Damage level at which the computer ceases to operate
var/max_damage = 100 // Damage level at which the computer breaks apart.
// Important hardware (must be installed for computer to work)
var/obj/item/weapon/computer_hardware/processor_unit/processor_unit // CPU. Without it the computer won't run. Better CPUs can run more programs at once.
var/obj/item/weapon/computer_hardware/network_card/network_card // Network Card component of this computer. Allows connection to NTNet
var/obj/item/weapon/computer_hardware/hard_drive/hard_drive // Hard Drive component of this computer. Stores programs and files.
// Optional hardware (improves functionality, but is not critical for computer to work in most cases)
var/obj/item/weapon/computer_hardware/battery_module/battery_module // An internal power source for this computer. Can be recharged.
var/obj/item/weapon/computer_hardware/card_slot/card_slot // ID Card slot component of this computer. Mostly for HoP modification console that needs ID slot for modification.
var/obj/item/weapon/computer_hardware/nano_printer/nano_printer // Nano Printer component of this computer, for your everyday paperwork needs.
var/obj/item/weapon/computer_hardware/hard_drive/portable/portable_drive // Portable data storage
var/obj/item/weapon/computer_hardware/ai_slot/ai_slot // AI slot, an intellicard housing that allows modifications of AIs.
var/obj/item/weapon/computer_hardware/tesla_link/tesla_link // Tesla Link, Allows remote charging from nearest APC.
@@ -0,0 +1,18 @@
/obj/item/modular_computer/console
name = "console"
desc = "A stationary computer."
icon = 'icons/obj/modular_console.dmi'
icon_state = "console"
icon_state_unpowered = "console"
icon_state_screensaver = "standby"
icon_state_menu = "menu"
hardware_flag = PROGRAM_CONSOLE
anchored = TRUE
density = 1
base_idle_power_usage = 100
base_active_power_usage = 500
max_hardware_size = 3
steel_sheet_cost = 20
light_strength = 4
max_damage = 300
broken_damage = 150
@@ -0,0 +1,37 @@
/obj/item/modular_computer/laptop
anchored = TRUE
name = "laptop computer"
desc = "A portable computer."
hardware_flag = PROGRAM_LAPTOP
icon_state_unpowered = "laptop-open"
icon = 'icons/obj/modular_laptop.dmi'
icon_state = "laptop-open"
icon_state_screensaver = "standby"
base_idle_power_usage = 25
base_active_power_usage = 200
max_hardware_size = 2
light_strength = 3
max_damage = 200
broken_damage = 100
w_class = ITEMSIZE_NORMAL
var/icon_state_closed = "laptop-closed"
/obj/item/modular_computer/laptop/AltClick()
// Prevents carrying of open laptops inhand.
// While they work inhand, i feel it'd make tablets lose some of their high-mobility advantage they have over laptops now.
if(!istype(loc, /turf/))
to_chat(usr, "\The [src] has to be on a stable surface first!")
return
anchored = !anchored
screen_on = anchored
update_icon()
/obj/item/modular_computer/laptop/update_icon()
if(anchored)
..()
else
overlays.Cut()
icon_state = icon_state_closed
/obj/item/modular_computer/laptop/preset
anchored = FALSE
@@ -1,5 +1,6 @@
/obj/item/modular_computer/tablet
name = "tablet computer"
desc = "A small portable microcomputer"
icon = 'icons/obj/modular_tablet.dmi'
icon_state = "tablet"
icon_state_unpowered = "tablet"
@@ -0,0 +1,59 @@
/obj/item/modular_computer/telescreen
name = "telescreen"
desc = "A stationary wall-mounted touchscreen"
icon = 'icons/obj/modular_telescreen.dmi'
icon_state = "telescreen"
icon_state_unpowered = "telescreen"
icon_state_menu = "menu"
icon_state_screensaver = "standby"
hardware_flag = PROGRAM_TELESCREEN
anchored = TRUE
density = 0
base_idle_power_usage = 75
base_active_power_usage = 300
max_hardware_size = 2
steel_sheet_cost = 10
light_strength = 4
max_damage = 300
broken_damage = 150
w_class = ITEMSIZE_HUGE
/obj/item/modular_computer/telescreen/New()
..()
// Allows us to create "north bump" "south bump" etc. named objects, for more comfortable mapping.
name = "telescreen"
/obj/item/modular_computer/telescreen/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
if(W.is_crowbar())
if(anchored)
shutdown_computer()
anchored = FALSE
screen_on = FALSE
pixel_x = 0
pixel_y = 0
to_chat(user, "You unsecure \the [src].")
else
var/choice = input(user, "Where do you want to place \the [src]?", "Offset selection") in list("North", "South", "West", "East", "This tile", "Cancel")
var/valid = FALSE
switch(choice)
if("North")
valid = TRUE
pixel_y = 32
if("South")
valid = TRUE
pixel_y = -32
if("West")
valid = TRUE
pixel_x = -32
if("East")
valid = TRUE
pixel_x = 32
if("This tile")
valid = TRUE
if(valid)
anchored = 1
screen_on = TRUE
to_chat(user, "You secure \the [src].")
return
..()
@@ -0,0 +1,117 @@
/obj/item/modular_computer/console/preset/install_default_hardware()
..()
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit(src)
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/super(src)
network_card = new/obj/item/weapon/computer_hardware/network_card/wired(src)
// Engineering
/obj/item/modular_computer/console/preset/engineering/install_default_programs()
..()
hard_drive.store_file(new/datum/computer_file/program/power_monitor())
hard_drive.store_file(new/datum/computer_file/program/supermatter_monitor())
hard_drive.store_file(new/datum/computer_file/program/alarm_monitor())
hard_drive.store_file(new/datum/computer_file/program/atmos_control())
hard_drive.store_file(new/datum/computer_file/program/rcon_console())
hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
// Medical
/obj/item/modular_computer/console/preset/medical/install_default_programs()
..()
hard_drive.store_file(new/datum/computer_file/program/suit_sensors())
hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
set_autorun("sensormonitor")
// Research
/obj/item/modular_computer/console/preset/research/install_default_hardware()
..()
//ai_slot = new/obj/item/weapon/computer_hardware/ai_slot(src)
/obj/item/modular_computer/console/preset/research/install_default_programs()
..()
hard_drive.store_file(new/datum/computer_file/program/ntnetmonitor())
hard_drive.store_file(new/datum/computer_file/program/nttransfer())
hard_drive.store_file(new/datum/computer_file/program/chatclient())
hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
//hard_drive.store_file(new/datum/computer_file/program/aidiag())
hard_drive.store_file(new/datum/computer_file/program/email_client())
// Administrator
/obj/item/modular_computer/console/preset/sysadmin/install_default_hardware()
..()
//ai_slot = new/obj/item/weapon/computer_hardware/ai_slot(src)
/obj/item/modular_computer/console/preset/sysadmin/install_default_programs()
..()
hard_drive.store_file(new/datum/computer_file/program/ntnetmonitor())
hard_drive.store_file(new/datum/computer_file/program/nttransfer())
hard_drive.store_file(new/datum/computer_file/program/chatclient())
hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
//hard_drive.store_file(new/datum/computer_file/program/aidiag())
hard_drive.store_file(new/datum/computer_file/program/email_client())
hard_drive.store_file(new/datum/computer_file/program/email_administration())
// Command
/obj/item/modular_computer/console/preset/command/install_default_hardware()
..()
nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(src)
card_slot = new/obj/item/weapon/computer_hardware/card_slot(src)
/obj/item/modular_computer/console/preset/command/install_default_programs()
..()
hard_drive.store_file(new/datum/computer_file/program/chatclient())
hard_drive.store_file(new/datum/computer_file/program/card_mod())
hard_drive.store_file(new/datum/computer_file/program/comm())
hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
hard_drive.store_file(new/datum/computer_file/program/email_client())
// Security
/obj/item/modular_computer/console/preset/security/install_default_programs()
..()
hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
hard_drive.store_file(new/datum/computer_file/program/digitalwarrant())
// Civilian
/obj/item/modular_computer/console/preset/civilian/install_default_programs()
..()
hard_drive.store_file(new/datum/computer_file/program/chatclient())
hard_drive.store_file(new/datum/computer_file/program/nttransfer())
hard_drive.store_file(new/datum/computer_file/program/newsbrowser())
hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
hard_drive.store_file(new/datum/computer_file/program/email_client())
// ERT
/obj/item/modular_computer/console/preset/ert/install_default_hardware()
..()
//ai_slot = new/obj/item/weapon/computer_hardware/ai_slot(src)
nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(src)
card_slot = new/obj/item/weapon/computer_hardware/card_slot(src)
/obj/item/modular_computer/console/preset/ert/install_default_programs()
..()
hard_drive.store_file(new/datum/computer_file/program/nttransfer())
hard_drive.store_file(new/datum/computer_file/program/camera_monitor/ert())
hard_drive.store_file(new/datum/computer_file/program/alarm_monitor())
hard_drive.store_file(new/datum/computer_file/program/comm())
//hard_drive.store_file(new/datum/computer_file/program/aidiag())
// Mercenary
/obj/item/modular_computer/console/preset/mercenary/
computer_emagged = TRUE
/obj/item/modular_computer/console/preset/mercenary/install_default_hardware()
..()
//ai_slot = new/obj/item/weapon/computer_hardware/ai_slot(src)
nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(src)
card_slot = new/obj/item/weapon/computer_hardware/card_slot(src)
/obj/item/modular_computer/console/preset/mercenary/install_default_programs()
..()
hard_drive.store_file(new/datum/computer_file/program/camera_monitor/hacked())
hard_drive.store_file(new/datum/computer_file/program/alarm_monitor())
//hard_drive.store_file(new/datum/computer_file/program/aidiag())
// Merchant
/obj/item/modular_computer/console/preset/merchant/install_default_programs()
..()
//hard_drive.store_file(new/datum/computer_file/program/merchant())
@@ -0,0 +1,32 @@
/obj/item/modular_computer/laptop/preset/custom_loadout/cheap/install_default_hardware()
..()
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(src)
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/(src)
network_card = new/obj/item/weapon/computer_hardware/network_card/(src)
nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(src)
card_slot = new/obj/item/weapon/computer_hardware/card_slot(src)
battery_module = new/obj/item/weapon/computer_hardware/battery_module/advanced(src)
battery_module.charge_to_full()
/obj/item/modular_computer/laptop/preset/custom_loadout/advanced/install_default_hardware()
..()
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit(src)
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/advanced(src)
network_card = new/obj/item/weapon/computer_hardware/network_card/advanced(src)
nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(src)
card_slot = new/obj/item/weapon/computer_hardware/card_slot(src)
battery_module = new/obj/item/weapon/computer_hardware/battery_module/advanced(src)
battery_module.charge_to_full()
/obj/item/modular_computer/laptop/preset/custom_loadout/standard/install_default_hardware()
..()
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit(src)
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/(src)
network_card = new/obj/item/weapon/computer_hardware/network_card/(src)
nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(src)
card_slot = new/obj/item/weapon/computer_hardware/card_slot(src)
battery_module = new/obj/item/weapon/computer_hardware/battery_module/advanced(src)
battery_module.charge_to_full()
@@ -1,23 +1,28 @@
// Available as custom loadout item, this is literally the worst possible cheap tablet
/obj/item/modular_computer/tablet/preset/custom_loadout/cheap/New()
. = ..()
desc = "A low-end tablet often seen among low ranked station personnel."
/obj/item/modular_computer/tablet/preset/custom_loadout/cheap/install_default_hardware()
..()
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(src)
battery_module = new/obj/item/weapon/computer_hardware/battery_module/nano(src)
battery_module.charge_to_full()
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/micro(src)
network_card = new/obj/item/weapon/computer_hardware/network_card(src)
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
// Alternative version, an average one, for higher ranked positions mostly
/obj/item/modular_computer/tablet/preset/custom_loadout/advanced/New()
. = ..()
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(src)
battery_module = new/obj/item/weapon/computer_hardware/battery_module(src)
battery_module = new/obj/item/weapon/computer_hardware/battery_module/nano(src)
battery_module.charge_to_full()
/obj/item/modular_computer/tablet/preset/custom_loadout/advanced/install_default_hardware()
..()
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(src)
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/small(src)
network_card = new/obj/item/weapon/computer_hardware/network_card(src)
network_card = new/obj/item/weapon/computer_hardware/network_card/advanced(src)
nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(src)
card_slot = new/obj/item/weapon/computer_hardware/card_slot(src)
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
battery_module = new/obj/item/weapon/computer_hardware/battery_module(src)
battery_module.charge_to_full()
/obj/item/modular_computer/tablet/preset/custom_loadout/standard/install_default_hardware()
..()
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(src)
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/small(src)
network_card = new/obj/item/weapon/computer_hardware/network_card(src)
battery_module = new/obj/item/weapon/computer_hardware/battery_module/micro(src)
battery_module.charge_to_full()
@@ -0,0 +1,14 @@
/obj/item/modular_computer/telescreen/preset/install_default_hardware()
..()
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit(src)
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive(src)
network_card = new/obj/item/weapon/computer_hardware/network_card(src)
/obj/item/modular_computer/telescreen/preset/generic/install_default_programs()
..()
hard_drive.store_file(new/datum/computer_file/program/chatclient())
hard_drive.store_file(new/datum/computer_file/program/alarm_monitor())
hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
hard_drive.store_file(new/datum/computer_file/program/email_client())
set_autorun("cammon")
@@ -3,9 +3,11 @@
/datum/computer_file/data/news_article
filetype = "XNML"
filename = "Unknown News Entry"
block_size = 1000 // Results in smaller files
block_size = 5000 // Results in smaller files
do_not_edit = 1 // Editing the file breaks most formatting due to some HTML tags not being accepted as input from average user.
var/server_file_path // File path to HTML file that will be loaded on server start. Example: '/news_articles/space_magazine_1.html'. Use the /news_articles/ folder!
var/archived // Set to 1 for older stuff
var/cover //filename of cover.
/datum/computer_file/data/news_article/New(var/load_from_file = 0)
..()
@@ -21,6 +21,7 @@
var/available_on_syndinet = 0 // Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to 1 to enable.
var/computer_emagged = 0 // Set to 1 if computer that's running us was emagged. Computer updates this every Process() tick
var/ui_header = null // Example: "something.gif" - a header image that will be rendered in computer's UI when this program is running at background. Images are taken from /nano/images/status_icons. Be careful not to use too large images!
var/ntnet_speed = 0 // GQ/s - current network connectivity transfer rate
/datum/computer_file/program/New(var/obj/item/modular_computer/comp = null)
..()
@@ -59,7 +60,7 @@
/datum/computer_file/program/proc/is_supported_by_hardware(var/hardware_flag = 0, var/loud = 0, var/mob/user = null)
if(!(hardware_flag & usage_flags))
if(loud && computer && user)
to_chat(user, "<span class='danger'>\The [computer] flashes an \"Hardware Error - Incompatible software\" warning.</span>")
to_chat(user, "<span class='warning'>\The [computer] flashes: \"Hardware Error - Incompatible software\".</span>")
return 0
return 1
@@ -70,8 +71,19 @@
// Called by Process() on device that runs us, once every tick.
/datum/computer_file/program/proc/process_tick()
update_netspeed()
return 1
/datum/computer_file/program/proc/update_netspeed()
ntnet_speed = 0
switch(ntnet_status)
if(1)
ntnet_speed = NTNETSPEED_LOWSIGNAL
if(2)
ntnet_speed = NTNETSPEED_HIGHSIGNAL
if(3)
ntnet_speed = NTNETSPEED_ETHERNET
// Check if the user can run program. Only humans can operate computer. Automatically called in run_program()
// User has to wear their ID or have it inhand for ID Scan to work.
// Can also be called manually, with optional parameter being access_to_check to scan the user's ID
@@ -82,19 +94,23 @@
if(!access_to_check) // No required_access, allow it.
return 1
// Admin override - allows operation of any computer as aghosted admin, as if you had any required access.
if(istype(user, /mob/observer/dead) && check_rights(R_ADMIN, 0, user))
return 1
if(!istype(user))
return 0
var/obj/item/weapon/card/id/I = user.GetIdCard()
if(!I)
if(loud)
to_chat(user, "<span class='danger'>\The [computer] flashes an \"RFID Error - Unable to scan ID\" warning.</span>")
to_chat(user, "<span class='notice'>\The [computer] flashes an \"RFID Error - Unable to scan ID\" warning.</span>")
return 0
if(access_to_check in I.access)
return 1
else if(loud)
to_chat(user, "<span class='danger'>\The [computer] flashes an \"Access Denied\" warning.</span>")
to_chat(user, "<span class='notice'>\The [computer] flashes an \"Access Denied\" warning.</span>")
// This attempts to retrieve header data for NanoUIs. If implementing completely new device of different type than existing ones
// always include the device here in this proc. This proc basically relays the request to whatever is running the program.
@@ -155,3 +171,37 @@
return NM.check_eye(user)
else
return -1
/obj/item/modular_computer/initial_data()
return get_header_data()
/obj/item/modular_computer/update_layout()
return TRUE
/datum/nano_module/program
//available_to_ai = FALSE
var/datum/computer_file/program/program = null // Program-Based computer program that runs this nano module. Defaults to null.
/datum/nano_module/program/New(var/host, var/topic_manager, var/program)
..()
src.program = program
/datum/topic_manager/program
var/datum/program
/datum/topic_manager/program/New(var/datum/program)
..()
src.program = program
// Calls forwarded to PROGRAM itself should begin with "PRG_"
// Calls forwarded to COMPUTER running the program should begin with "PC_"
/datum/topic_manager/program/Topic(href, href_list)
return program && program.Topic(href, href_list)
/datum/computer_file/program/apply_visual(mob/M)
if(NM)
NM.apply_visual(M)
/datum/computer_file/program/remove_visual(mob/M)
if(NM)
NM.remove_visual(M)
@@ -13,6 +13,6 @@
/datum/computer_file/program/proc/event_networkfailure(var/background)
kill_program(1)
if(background)
computer.visible_message("<span class='danger'>\The [computer]'s screen displays an \"Process [filename].[filetype] (PID [rand(100,999)]) terminated - Network Error\" error</span>")
computer.visible_message("<span class='warning'>\The [computer]'s screen displays an error: \"Network connectivity lost - process [filename].[filetype] (PID [rand(100,999)]) terminated.\"</span>", range = 1)
else
computer.visible_message("<span class='danger'>\The [computer]'s screen briefly freezes and then shows \"NETWORK ERROR - NTNet connection lost. Please retry. If problem persists contact your system administrator.\" error.</span>")
computer.visible_message("<span class='warning'>\The [computer]'s screen briefly freezes and then shows: \"FATAL NETWORK ERROR - NTNet connection lost. Please try again later. If problem persists, please contact your system administrator.\"</span>", range = 1)
@@ -1,85 +0,0 @@
// These programs are associated with engineering.
/datum/computer_file/program/power_monitor
filename = "powermonitor"
filedesc = "Power Monitoring"
nanomodule_path = /datum/nano_module/power_monitor/
program_icon_state = "power_monitor"
extended_desc = "This program connects to sensors around the station to provide information about electrical systems"
ui_header = "power_norm.gif"
required_access = access_engine
requires_ntnet = 1
network_destination = "power monitoring system"
size = 9
var/has_alert = 0
/datum/computer_file/program/power_monitor/process_tick()
..()
var/datum/nano_module/power_monitor/NMA = NM
if(istype(NMA) && NMA.has_alarm())
if(!has_alert)
program_icon_state = "power_monitor_warn"
ui_header = "power_warn.gif"
update_computer_icon()
has_alert = 1
else
if(has_alert)
program_icon_state = "power_monitor"
ui_header = "power_norm.gif"
update_computer_icon()
has_alert = 0
/datum/computer_file/program/alarm_monitor
filename = "alarmmonitor"
filedesc = "Alarm Monitoring"
nanomodule_path = /datum/nano_module/alarm_monitor/engineering
ui_header = "alarm_green.gif"
program_icon_state = "alert-green"
extended_desc = "This program provides visual interface for station's alarm system."
requires_ntnet = 1
network_destination = "alarm monitoring network"
size = 5
var/has_alert = 0
/datum/computer_file/program/alarm_monitor/process_tick()
..()
var/datum/nano_module/alarm_monitor/NMA = NM
if(istype(NMA) && NMA.has_major_alarms())
if(!has_alert)
program_icon_state = "alert-red"
ui_header = "alarm_red.gif"
update_computer_icon()
has_alert = 1
else
if(has_alert)
program_icon_state = "alert-green"
ui_header = "alarm_green.gif"
update_computer_icon()
has_alert = 0
return 1
/datum/computer_file/program/atmos_control
filename = "atmoscontrol"
filedesc = "Atmosphere Control"
nanomodule_path = /datum/nano_module/atmos_control
program_icon_state = "atmos_control"
extended_desc = "This program allows remote control of air alarms around the station. This program can not be run on tablet computers."
required_access = access_atmospherics
requires_ntnet = 1
network_destination = "atmospheric control system"
requires_ntnet_feature = NTNET_SYSTEMCONTROL
usage_flags = PROGRAM_LAPTOP | PROGRAM_CONSOLE
size = 17
/datum/computer_file/program/rcon_console
filename = "rconconsole"
filedesc = "RCON Remote Control"
nanomodule_path = /datum/nano_module/rcon
program_icon_state = "generic"
extended_desc = "This program allows remote control of power distribution systems around the station. This program can not be run on tablet computers."
required_access = access_engine
requires_ntnet = 1
network_destination = "RCON remote control system"
requires_ntnet_feature = NTNET_SYSTEMCONTROL
usage_flags = PROGRAM_LAPTOP | PROGRAM_CONSOLE
size = 19
@@ -1,10 +0,0 @@
/datum/computer_file/program/suit_sensors
filename = "sensormonitor"
filedesc = "Suit Sensors Monitoring"
nanomodule_path = /datum/nano_module/crew_monitor
program_icon_state = "crew"
extended_desc = "This program connects to life signs monitoring system to provide basic information on crew health."
required_access = access_medical
requires_ntnet = 1
network_destination = "crew lifesigns monitoring system"
size = 11
@@ -1,31 +0,0 @@
/obj/machinery/modular_computer/initial_data()
return cpu ? cpu.get_header_data() : ..()
/obj/machinery/modular_computer/update_layout()
return TRUE
/obj/item/modular_computer/initial_data()
return get_header_data()
/obj/machinery/modular_computer/update_layout()
return TRUE
/datum/nano_module/program
//available_to_ai = FALSE
var/datum/computer_file/program/program = null // Program-Based computer program that runs this nano module. Defaults to null.
/datum/nano_module/program/New(var/host, var/topic_manager, var/program)
..()
src.program = program
/datum/topic_manager/program
var/datum/program
/datum/topic_manager/program/New(var/datum/program)
..()
src.program = program
// Calls forwarded to PROGRAM itself should begin with "PRG_"
// Calls forwarded to COMPUTER running the program should begin with "PC_"
/datum/topic_manager/program/Topic(href, href_list)
return program && program.Topic(href, href_list)
@@ -16,7 +16,7 @@
var/datum/nano_module/camera_monitor/hacked/HNM = NM
// The program is active and connected to one of the station's networks. Has a very small chance to trigger IDS alarm every tick.
if(HNM.current_network && (HNM.current_network in using_map.station_networks) && prob(0.1))
if(HNM && HNM.current_network && (HNM.current_network in using_map.station_networks) && prob(0.1))
if(ntnet_global.intrusion_detection_enabled)
ntnet_global.add_log("IDS WARNING - Unauthorised access detected to camera network [HNM.current_network] by device with NID [computer.network_card.get_network_tag()]")
ntnet_global.intrusion_detection_alarm = 1
@@ -16,25 +16,24 @@
activate()
/datum/computer_file/program/revelation/proc/activate()
if(computer)
computer.visible_message("<span class='notice'>\The [computer]'s screen brightly flashes and loud electrical buzzing is heard.</span>")
computer.enabled = 0
computer.update_icon()
if(!computer)
return
computer.visible_message("<span class='notice'>\The [computer]'s screen brightly flashes and loud electrical buzzing is heard.</span>")
computer.enabled = 0
computer.update_icon()
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(10, 1, computer.loc)
s.start()
if(computer.hard_drive)
qdel(computer.hard_drive)
if(computer.battery_module && prob(25))
qdel(computer.battery_module)
computer.visible_message("<span class='notice'>\The [computer]'s battery explodes in rain of sparks.</span>")
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(10, 1, computer.loc)
s.start()
if(istype(computer, /obj/item/modular_computer/processor))
var/obj/item/modular_computer/processor/P = computer
if(P.tesla_link && prob(50))
qdel(P.tesla_link)
computer.visible_message("<span class='notice'>\The [computer]'s tesla link explodes in rain of sparks.</span>")
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(10, 1, computer.loc)
s.start()
if(computer.battery_module && prob(25))
qdel(computer.battery_module)
if(computer.tesla_link && prob(50))
qdel(computer.tesla_link)
/datum/computer_file/program/revelation/Topic(href, href_list)
if(..())
@@ -42,7 +42,7 @@
data["id_owner"] = id_card && id_card.registered_name ? id_card.registered_name : "-----"
data["id_name"] = id_card ? id_card.name : "-----"
data["command_jobs"] = format_jobs(command_positions)
data["engineering_jobs"] = format_jobs(engineering_positions)
data["medical_jobs"] = format_jobs(medical_positions)
data["science_jobs"] = format_jobs(science_positions)
@@ -54,7 +54,7 @@
data["all_centcom_access"] = is_centcom ? get_accesses(1) : null
data["regions"] = get_accesses()
if(program.computer.card_slot.stored_card)
if(program.computer.card_slot && program.computer.card_slot.stored_card)
var/obj/item/weapon/card/id/id_card = program.computer.card_slot.stored_card
if(is_centcom)
var/list/all_centcom_access = list()
@@ -88,7 +88,7 @@
ui.open()
/datum/nano_module/program/card_mod/proc/format_jobs(list/jobs)
var/obj/item/weapon/card/id/id_card = program.computer.card_slot.stored_card
var/obj/item/weapon/card/id/id_card = program.computer.card_slot ? program.computer.card_slot.stored_card : null
var/list/formatted = list()
for(var/job in jobs)
formatted.Add(list(list(
@@ -108,7 +108,10 @@
var/mob/user = usr
var/obj/item/weapon/card/id/user_id_card = user.GetIdCard()
var/obj/item/weapon/card/id/id_card = computer.card_slot.stored_card
var/obj/item/weapon/card/id/id_card
if (computer.card_slot)
id_card = computer.card_slot.stored_card
var/datum/nano_module/program/card_mod/module = NM
switch(href_list["action"])
if("switchm")
@@ -168,7 +171,7 @@
if("edit")
if(computer && can_run(user, 1))
if(href_list["name"])
var/temp_name = sanitizeName(input("Enter name.", "Name", id_card.registered_name))
var/temp_name = sanitizeName(input("Enter name.", "Name", id_card.registered_name),allow_numbers=TRUE)
if(temp_name)
id_card.registered_name = temp_name
else
@@ -0,0 +1,132 @@
/datum/computer_file/program/alarm_monitor
filename = "alarmmonitor"
filedesc = "Alarm Monitoring"
nanomodule_path = /datum/nano_module/alarm_monitor/engineering
ui_header = "alarm_green.gif"
program_icon_state = "alert-green"
extended_desc = "This program provides visual interface for the alarm system."
requires_ntnet = 1
network_destination = "alarm monitoring network"
size = 5
var/has_alert = 0
/datum/computer_file/program/alarm_monitor/process_tick()
..()
var/datum/nano_module/alarm_monitor/NMA = NM
if(istype(NMA) && NMA.has_major_alarms())
if(!has_alert)
program_icon_state = "alert-red"
ui_header = "alarm_red.gif"
update_computer_icon()
has_alert = 1
else
if(has_alert)
program_icon_state = "alert-green"
ui_header = "alarm_green.gif"
update_computer_icon()
has_alert = 0
return 1
/datum/nano_module/alarm_monitor
name = "Alarm monitor"
var/list_cameras = 0 // Whether or not to list camera references. A future goal would be to merge this with the enginering/security camera console. Currently really only for AI-use.
var/list/datum/alarm_handler/alarm_handlers // The particular list of alarm handlers this alarm monitor should present to the user.
//available_to_ai = FALSE
/datum/nano_module/alarm_monitor/New()
..()
alarm_handlers = list()
/datum/nano_module/alarm_monitor/all/New()
..()
alarm_handlers = alarm_manager.all_handlers
/datum/nano_module/alarm_monitor/engineering/New()
..()
alarm_handlers = list(atmosphere_alarm, fire_alarm, power_alarm)
/datum/nano_module/alarm_monitor/security/New()
..()
alarm_handlers = list(camera_alarm, motion_alarm)
/datum/nano_module/alarm_monitor/proc/register_alarm(var/object, var/procName)
for(var/datum/alarm_handler/AH in alarm_handlers)
AH.register_alarm(object, procName)
/datum/nano_module/alarm_monitor/proc/unregister_alarm(var/object)
for(var/datum/alarm_handler/AH in alarm_handlers)
AH.unregister_alarm(object)
/datum/nano_module/alarm_monitor/proc/all_alarms()
var/list/all_alarms = new()
for(var/datum/alarm_handler/AH in alarm_handlers)
all_alarms += AH.visible_alarms()
return all_alarms
/datum/nano_module/alarm_monitor/proc/major_alarms()
var/list/all_alarms = new()
for(var/datum/alarm_handler/AH in alarm_handlers)
all_alarms += AH.major_alarms()
return all_alarms
// Modified version of above proc that uses slightly less resources, returns 1 if there is a major alarm, 0 otherwise.
/datum/nano_module/alarm_monitor/proc/has_major_alarms()
for(var/datum/alarm_handler/AH in alarm_handlers)
if(AH.has_major_alarms())
return 1
return 0
/datum/nano_module/alarm_monitor/proc/minor_alarms()
var/list/all_alarms = new()
for(var/datum/alarm_handler/AH in alarm_handlers)
all_alarms += AH.minor_alarms()
return all_alarms
/datum/nano_module/alarm_monitor/Topic(ref, href_list)
if(..())
return 1
if(href_list["switchTo"])
var/obj/machinery/camera/C = locate(href_list["switchTo"]) in cameranet.cameras
if(!C)
return
usr.switch_to_camera(C)
return 1
/datum/nano_module/alarm_monitor/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()
var/categories[0]
for(var/datum/alarm_handler/AH in alarm_handlers)
categories[++categories.len] = list("category" = AH.category, "alarms" = list())
for(var/datum/alarm/A in AH.major_alarms())
var/cameras[0]
var/lost_sources[0]
if(isAI(user))
for(var/obj/machinery/camera/C in A.cameras())
cameras[++cameras.len] = C.nano_structure()
for(var/datum/alarm_source/AS in A.sources)
if(!AS.source)
lost_sources[++lost_sources.len] = AS.source_name
categories[categories.len]["alarms"] += list(list(
"name" = sanitize(A.alarm_name()),
"origin_lost" = A.origin == null,
"has_cameras" = cameras.len,
"cameras" = cameras,
"lost_sources" = lost_sources.len ? sanitize(english_list(lost_sources, nothing_text = "", and_text = ", ")) : ""))
data["categories"] = categories
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "alarm_monitor.tmpl", "Alarm Monitoring Console", 800, 800, state = state)
if(host.update_layout()) // This is necessary to ensure the status bar remains updated along with rest of the UI.
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
@@ -0,0 +1,101 @@
/datum/computer_file/program/atmos_control
filename = "atmoscontrol"
filedesc = "Atmosphere Control"
nanomodule_path = /datum/nano_module/atmos_control
program_icon_state = "atmos_control"
extended_desc = "This program allows remote control of air alarms. This program can not be run on tablet computers."
required_access = access_atmospherics
requires_ntnet = 1
network_destination = "atmospheric control system"
requires_ntnet_feature = NTNET_SYSTEMCONTROL
usage_flags = PROGRAM_LAPTOP | PROGRAM_CONSOLE
size = 17
/datum/nano_module/atmos_control
name = "Atmospherics Control"
var/obj/access = new()
var/emagged = 0
var/ui_ref
var/list/monitored_alarms = list()
/datum/nano_module/atmos_control/New(atmos_computer, req_access, req_one_access, monitored_alarm_ids)
..()
access.req_access = req_access
access.req_one_access = req_one_access
if(monitored_alarm_ids)
for(var/obj/machinery/alarm/alarm in machines)
if(alarm.alarm_id && alarm.alarm_id in monitored_alarm_ids)
monitored_alarms += alarm
// machines may not yet be ordered at this point
monitored_alarms = dd_sortedObjectList(monitored_alarms)
/datum/nano_module/atmos_control/Topic(href, href_list)
if(..())
return 1
if(href_list["alarm"])
if(ui_ref)
var/obj/machinery/alarm/alarm = locate(href_list["alarm"]) in (monitored_alarms.len ? monitored_alarms : machines)
if(alarm)
var/datum/topic_state/TS = generate_state(alarm)
alarm.ui_interact(usr, master_ui = ui_ref, state = TS)
return 1
/datum/nano_module/atmos_control/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/master_ui = null, var/datum/topic_state/state = default_state)
var/list/data = host.initial_data()
var/alarms[0]
var/turf/T = get_turf(nano_host())
// TODO: Move these to a cache, similar to cameras
for(var/obj/machinery/alarm/alarm in (monitored_alarms.len ? monitored_alarms : machines))
if(!monitored_alarms.len && alarm.alarms_hidden)
continue
alarms[++alarms.len] = list(
"name" = sanitize(alarm.name),
"ref"= "\ref[alarm]",
"danger" = max(alarm.danger_level, alarm.alarm_area.atmosalm),
"x" = alarm.x,
"y" = alarm.y,
"z" = alarm.z)
data["alarms"] = alarms
data["map_levels"] = using_map.get_map_levels(T.z)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_control.tmpl", src.name, 625, 625, state = state)
if(host.update_layout()) // This is necessary to ensure the status bar remains updated along with rest of the UI.
ui.auto_update_layout = 1
// adding a template with the key "mapContent" enables the map ui functionality
ui.add_template("mapContent", "atmos_control_map_content.tmpl")
// adding a template with the key "mapHeader" replaces the map header content
ui.add_template("mapHeader", "atmos_control_map_header.tmpl")
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(0)
ui_ref = ui
/datum/nano_module/atmos_control/proc/generate_state(air_alarm)
var/datum/topic_state/air_alarm/state = new()
state.atmos_control = src
state.air_alarm = air_alarm
return state
/datum/topic_state/air_alarm
var/datum/nano_module/atmos_control/atmos_control = null
var/obj/machinery/alarm/air_alarm = null
/datum/topic_state/air_alarm/can_use_topic(var/src_object, var/mob/user)
if(has_access(user))
return STATUS_INTERACTIVE
return STATUS_UPDATE
/datum/topic_state/air_alarm/href_list(var/mob/user)
var/list/extra_href = list()
extra_href["remote_connection"] = 1
extra_href["remote_access"] = has_access(user)
return extra_href
/datum/topic_state/air_alarm/proc/has_access(var/mob/user)
return user && (isAI(user) || atmos_control.access.allowed(user) || atmos_control.emagged || air_alarm.rcon_setting == RCON_YES || (air_alarm.alarm_area.atmosalm && air_alarm.rcon_setting == RCON_AUTO))
@@ -0,0 +1,111 @@
/datum/computer_file/program/power_monitor
filename = "powermonitor"
filedesc = "Power Monitoring"
nanomodule_path = /datum/nano_module/power_monitor/
program_icon_state = "power_monitor"
extended_desc = "This program connects to sensors to provide information about electrical systems"
ui_header = "power_norm.gif"
required_access = access_engine
requires_ntnet = 1
network_destination = "power monitoring system"
size = 9
var/has_alert = 0
/datum/computer_file/program/power_monitor/process_tick()
..()
var/datum/nano_module/power_monitor/NMA = NM
if(istype(NMA) && NMA.has_alarm())
if(!has_alert)
program_icon_state = "power_monitor_warn"
ui_header = "power_warn.gif"
update_computer_icon()
has_alert = 1
else
if(has_alert)
program_icon_state = "power_monitor"
ui_header = "power_norm.gif"
update_computer_icon()
has_alert = 0
/datum/nano_module/power_monitor
name = "Power monitor"
var/list/grid_sensors
var/active_sensor = null //name_tag of the currently selected sensor
/datum/nano_module/power_monitor/New()
..()
refresh_sensors()
// Checks whether there is an active alarm, if yes, returns 1, otherwise returns 0.
/datum/nano_module/power_monitor/proc/has_alarm()
for(var/obj/machinery/power/sensor/S in grid_sensors)
if(S.check_grid_warning())
return 1
return 0
// If PC is not null header template is loaded. Use PC.get_header_data() to get relevant nanoui data from it. All data entries begin with "PC_...."
// In future it may be expanded to other modular computer devices.
/datum/nano_module/power_monitor/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()
var/list/sensors = list()
// Focus: If it remains null if no sensor is selected and UI will display sensor list, otherwise it will display sensor reading.
var/obj/machinery/power/sensor/focus = null
var/turf/T = get_turf(nano_host())
// Build list of data from sensor readings.
for(var/obj/machinery/power/sensor/S in grid_sensors)
sensors.Add(list(list(
"name" = S.name_tag,
"alarm" = S.check_grid_warning()
)))
if(S.name_tag == active_sensor)
focus = S
data["all_sensors"] = sensors
if(focus)
data["focus"] = focus.return_reading_data()
data["map_levels"] = using_map.get_map_levels(T.z)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "power_monitor.tmpl", "Power Monitoring Console", 800, 500, state = state)
if(host.update_layout()) // This is necessary to ensure the status bar remains updated along with rest of the UI.
ui.auto_update_layout = 1
// adding a template with the key "mapContent" enables the map ui functionality
ui.add_template("mapContent", "power_monitor_map_content.tmpl")
// adding a template with the key "mapHeader" replaces the map header content
ui.add_template("mapHeader", "power_monitor_map_header.tmpl")
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
// Refreshes list of active sensors kept on this computer.
/datum/nano_module/power_monitor/proc/refresh_sensors()
grid_sensors = list()
var/turf/T = get_turf(nano_host())
var/list/levels = list()
if(!T) // Safety check
return
if(T)
levels += using_map.get_map_levels(T.z, FALSE)
for(var/obj/machinery/power/sensor/S in machines)
if(T && (S.loc.z == T.z) || (S.loc.z in levels) || (S.long_range)) // Consoles have range on their Z-Level. Sensors with long_range var will work between Z levels.
if(S.name_tag == "#UNKN#") // Default name. Shouldn't happen!
warning("Powernet sensor with unset ID Tag! [S.x]X [S.y]Y [S.z]Z")
else
grid_sensors += S
// Allows us to process UI clicks, which are relayed in form of hrefs.
/datum/nano_module/power_monitor/Topic(href, href_list)
if(..())
return 1
if( href_list["clear"] )
active_sensor = null
. = 1
if( href_list["refresh"] )
refresh_sensors()
. = 1
else if( href_list["setsensor"] )
active_sensor = href_list["setsensor"]
. = 1
@@ -0,0 +1,130 @@
/datum/computer_file/program/rcon_console
filename = "rconconsole"
filedesc = "RCON Remote Control"
nanomodule_path = /datum/nano_module/rcon
program_icon_state = "generic"
extended_desc = "This program allows remote control of power distribution systems. This program can not be run on tablet computers."
required_access = access_engine
requires_ntnet = 1
network_destination = "RCON remote control system"
requires_ntnet_feature = NTNET_SYSTEMCONTROL
usage_flags = PROGRAM_LAPTOP | PROGRAM_CONSOLE
size = 19
/datum/nano_module/rcon
name = "Power RCON"
var/list/known_SMESs = null
var/list/known_breakers = null
// Allows you to hide specific parts of the UI
var/hide_SMES = 0
var/hide_SMES_details = 0
var/hide_breakers = 0
/datum/nano_module/rcon/ui_interact(mob/user, ui_key = "rcon", datum/nanoui/ui=null, force_open=1, var/datum/topic_state/state = default_state)
FindDevices() // Update our devices list
var/list/data = host.initial_data()
// SMES DATA (simplified view)
var/list/smeslist[0]
for(var/obj/machinery/power/smes/buildable/SMES in known_SMESs)
smeslist.Add(list(list(
"charge" = round(SMES.Percentage()),
"input_set" = SMES.input_attempt,
"input_val" = round(SMES.input_level/1000, 0.1),
"output_set" = SMES.output_attempt,
"output_val" = round(SMES.output_level/1000, 0.1),
"output_load" = round(SMES.output_used/1000, 0.1),
"RCON_tag" = SMES.RCon_tag
)))
data["smes_info"] = sortByKey(smeslist, "RCON_tag")
// BREAKER DATA (simplified view)
var/list/breakerlist[0]
for(var/obj/machinery/power/breakerbox/BR in known_breakers)
breakerlist.Add(list(list(
"RCON_tag" = BR.RCon_tag,
"enabled" = BR.on
)))
data["breaker_info"] = breakerlist
data["hide_smes"] = hide_SMES
data["hide_smes_details"] = hide_SMES_details
data["hide_breakers"] = hide_breakers
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "rcon.tmpl", "RCON Console", 600, 400, state = state)
if(host.update_layout()) // This is necessary to ensure the status bar remains updated along with rest of the UI.
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
// Proc: Topic()
// Parameters: 2 (href, href_list - allows us to process UI clicks)
// Description: Allows us to process UI clicks, which are relayed in form of hrefs.
/datum/nano_module/rcon/Topic(href, href_list)
if(..())
return
if(href_list["smes_in_toggle"])
var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(href_list["smes_in_toggle"])
if(SMES)
SMES.toggle_input()
if(href_list["smes_out_toggle"])
var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(href_list["smes_out_toggle"])
if(SMES)
SMES.toggle_output()
if(href_list["smes_in_set"])
var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(href_list["smes_in_set"])
if(SMES)
var/inputset = (input(usr, "Enter new input level (0-[SMES.input_level_max/1000] kW)", "SMES Input Power Control", SMES.input_level/1000) as num) * 1000
SMES.set_input(inputset)
if(href_list["smes_out_set"])
var/obj/machinery/power/smes/buildable/SMES = GetSMESByTag(href_list["smes_out_set"])
if(SMES)
var/outputset = (input(usr, "Enter new output level (0-[SMES.output_level_max/1000] kW)", "SMES Output Power Control", SMES.output_level/1000) as num) * 1000
SMES.set_output(outputset)
if(href_list["toggle_breaker"])
var/obj/machinery/power/breakerbox/toggle = null
for(var/obj/machinery/power/breakerbox/breaker in known_breakers)
if(breaker.RCon_tag == href_list["toggle_breaker"])
toggle = breaker
if(toggle)
if(toggle.update_locked)
to_chat(usr, "The breaker box was recently toggled. Please wait before toggling it again.")
else
toggle.auto_toggle()
if(href_list["hide_smes"])
hide_SMES = !hide_SMES
if(href_list["hide_smes_details"])
hide_SMES_details = !hide_SMES_details
if(href_list["hide_breakers"])
hide_breakers = !hide_breakers
// Proc: GetSMESByTag()
// Parameters: 1 (tag - RCON tag of SMES we want to look up)
// Description: Looks up and returns SMES which has matching RCON tag
/datum/nano_module/rcon/proc/GetSMESByTag(var/tag)
if(!tag)
return
for(var/obj/machinery/power/smes/buildable/S in known_SMESs)
if(S.RCon_tag == tag)
return S
// Proc: FindDevices()
// Parameters: None
// Description: Refreshes local list of known devices.
/datum/nano_module/rcon/proc/FindDevices()
known_SMESs = new /list()
for(var/obj/machinery/power/smes/buildable/SMES in machines)
if(SMES.RCon_tag && (SMES.RCon_tag != "NO_TAG") && SMES.RCon)
known_SMESs.Add(SMES)
known_breakers = new /list()
for(var/obj/machinery/power/breakerbox/breaker in machines)
if(breaker.RCon_tag != "NO_TAG")
known_breakers.Add(breaker)
@@ -0,0 +1,130 @@
/datum/computer_file/program/supermatter_monitor
filename = "supmon"
filedesc = "Supermatter Monitoring"
nanomodule_path = /datum/nano_module/supermatter_monitor/
program_icon_state = "smmon_0"
extended_desc = "This program connects to specially calibrated supermatter sensors to provide information on the status of supermatter-based engines."
ui_header = "smmon_0.gif"
required_access = access_engine
requires_ntnet = 1
network_destination = "supermatter monitoring system"
size = 5
var/last_status = 0
/datum/computer_file/program/supermatter_monitor/process_tick()
..()
var/datum/nano_module/supermatter_monitor/NMS = NM
var/new_status = istype(NMS) ? NMS.get_status() : 0
if(last_status != new_status)
last_status = new_status
ui_header = "smmon_[last_status].gif"
program_icon_state = "smmon_[last_status]"
if(istype(computer))
computer.update_icon()
/datum/nano_module/supermatter_monitor
name = "Supermatter monitor"
var/list/supermatters
var/obj/machinery/power/supermatter/active = null // Currently selected supermatter crystal.
/datum/nano_module/supermatter_monitor/Destroy()
. = ..()
active = null
supermatters = null
/datum/nano_module/supermatter_monitor/New()
..()
refresh()
// Refreshes list of active supermatter crystals
/datum/nano_module/supermatter_monitor/proc/refresh()
supermatters = list()
var/turf/T = get_turf(nano_host())
if(!T)
return
var/valid_z_levels = (GetConnectedZlevels(T.z) & using_map.station_levels)
for(var/obj/machinery/power/supermatter/S in machines)
// Delaminating, not within coverage, not on a tile.
if(S.grav_pulling || S.exploded || !(S.z in valid_z_levels) || !istype(S.loc, /turf/))
continue
supermatters.Add(S)
if(!(active in supermatters))
active = null
/datum/nano_module/supermatter_monitor/proc/get_status()
. = SUPERMATTER_INACTIVE
for(var/obj/machinery/power/supermatter/S in supermatters)
. = max(., S.get_status())
/datum/nano_module/supermatter_monitor/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()
if(istype(active))
var/turf/T = get_turf(active)
if(!T)
active = null
return
var/datum/gas_mixture/air = T.return_air()
if(!istype(air))
active = null
return
data["active"] = 1
data["SM_integrity"] = active.get_integrity()
data["SM_power"] = active.power
data["SM_ambienttemp"] = air.temperature
data["SM_ambientpressure"] = air.return_pressure()
//data["SM_EPR"] = active.get_epr()
if(air.total_moles)
data["SM_gas_O2"] = round(100*air.gas["oxygen"]/air.total_moles,0.01)
data["SM_gas_CO2"] = round(100*air.gas["carbon_dioxide"]/air.total_moles,0.01)
data["SM_gas_N2"] = round(100*air.gas["nitrogen"]/air.total_moles,0.01)
data["SM_gas_PH"] = round(100*air.gas["phoron"]/air.total_moles,0.01)
data["SM_gas_N2O"] = round(100*air.gas["sleeping_agent"]/air.total_moles,0.01)
else
data["SM_gas_O2"] = 0
data["SM_gas_CO2"] = 0
data["SM_gas_N2"] = 0
data["SM_gas_PH"] = 0
data["SM_gas_N2O"] = 0
else
var/list/SMS = list()
for(var/obj/machinery/power/supermatter/S in supermatters)
var/area/A = get_area(S)
if(!A)
continue
SMS.Add(list(list(
"area_name" = A.name,
"integrity" = S.get_integrity(),
"uid" = S.uid
)))
data["active"] = 0
data["supermatters"] = SMS
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "supermatter_monitor.tmpl", "Supermatter Monitoring", 600, 400, state = state)
if(host.update_layout())
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
/datum/nano_module/supermatter_monitor/Topic(href, href_list)
if(..())
return 1
if( href_list["clear"] )
active = null
return 1
if( href_list["refresh"] )
refresh()
return 1
if( href_list["set"] )
var/newuid = text2num(href_list["set"])
for(var/obj/machinery/power/supermatter/S in supermatters)
if(S.uid == newuid)
active = S
return 1
@@ -2,6 +2,9 @@
/proc/get_camera_access(var/network)
if(!network)
return 0
. = using_map.get_network_access(network)
if(.)
return
switch(network)
if(NETWORK_THUNDER)
@@ -25,8 +28,8 @@
filename = "cammon"
filedesc = "Camera Monitoring"
nanomodule_path = /datum/nano_module/camera_monitor
program_icon_state = "generic"
extended_desc = "This program allows remote access to station's camera system. Some camera networks may have additional access requirements."
program_icon_state = "cameras"
extended_desc = "This program allows remote access to the camera system. Some camera networks may have additional access requirements."
size = 12
available_on_ntnet = 1
requires_ntnet = 1
@@ -154,7 +157,7 @@
/datum/computer_file/program/camera_monitor/ert
filename = "ntcammon"
filedesc = "Advanced Camera Monitoring"
extended_desc = "This program allows remote access to station's camera system. Some camera networks may have additional access requirements. This version has an integrated database with additional encrypted keys."
extended_desc = "This program allows remote access to the camera system. Some camera networks may have additional access requirements. This version has an integrated database with additional encrypted keys."
size = 14
nanomodule_path = /datum/nano_module/camera_monitor/ert
available_on_ntnet = 0
@@ -168,4 +171,14 @@
..()
networks.Add(list(list("tag" = NETWORK_ERT, "has_access" = 1)))
networks.Add(list(list("tag" = NETWORK_CRESCENT, "has_access" = 1)))
return networks
return networks
/datum/nano_module/camera_monitor/apply_visual(mob/M)
if(current_camera)
current_camera.apply_visual(M)
else
remove_visual(M)
/datum/nano_module/camera_monitor/remove_visual(mob/M)
if(current_camera)
current_camera.remove_visual(M)
@@ -0,0 +1,497 @@
/datum/computer_file/program/email_client
filename = "emailc"
filedesc = "Email Client"
extended_desc = "This program may be used to log in into your email account."
program_icon_state = "generic"
size = 7
requires_ntnet = 1
available_on_ntnet = 1
var/stored_login = ""
var/stored_password = ""
nanomodule_path = /datum/nano_module/email_client
// Persistency. Unless you log out, or unless your password changes, this will pre-fill the login data when restarting the program
/datum/computer_file/program/email_client/kill_program()
if(NM)
var/datum/nano_module/email_client/NME = NM
if(NME.current_account)
stored_login = NME.stored_login
stored_password = NME.stored_password
else
stored_login = ""
stored_password = ""
. = ..()
/datum/computer_file/program/email_client/run_program()
. = ..()
if(NM)
var/datum/nano_module/email_client/NME = NM
NME.stored_login = stored_login
NME.stored_password = stored_password
NME.log_in()
NME.error = ""
NME.check_for_new_messages(1)
/datum/computer_file/program/email_client/proc/new_mail_notify()
computer.visible_message("\The [computer] beeps softly, indicating a new email has been received.", 1)
/datum/computer_file/program/email_client/process_tick()
..()
var/datum/nano_module/email_client/NME = NM
if(!istype(NME))
return
NME.relayed_process(ntnet_speed)
var/check_count = NME.check_for_new_messages()
if(check_count)
if(check_count == 2)
new_mail_notify()
ui_header = "ntnrc_new.gif"
else
ui_header = "ntnrc_idle.gif"
/datum/nano_module/email_client/
name = "Email Client"
var/stored_login = ""
var/stored_password = ""
var/error = ""
var/msg_title = ""
var/msg_body = ""
var/msg_recipient = ""
var/datum/computer_file/msg_attachment = null
var/folder = "Inbox"
var/addressbook = FALSE
var/new_message = FALSE
var/last_message_count = 0 // How many messages were there during last check.
var/read_message_count = 0 // How many messages were there when user has last accessed the UI.
var/datum/computer_file/downloading = null
var/download_progress = 0
var/download_speed = 0
var/datum/computer_file/data/email_account/current_account = null
var/datum/computer_file/data/email_message/current_message = null
/datum/nano_module/email_client/proc/log_in()
for(var/datum/computer_file/data/email_account/account in ntnet_global.email_accounts)
if(!account.can_login)
continue
if(account.login == stored_login)
if(account.password == stored_password)
if(account.suspended)
error = "This account has been suspended. Please contact the system administrator for assistance."
return 0
current_account = account
return 1
else
error = "Invalid Password"
return 0
error = "Invalid Login"
return 0
// Returns 0 if no new messages were received, 1 if there is an unread message but notification has already been sent.
// and 2 if there is a new message that appeared in this tick (and therefore notification should be sent by the program).
/datum/nano_module/email_client/proc/check_for_new_messages(var/messages_read = FALSE)
if(!current_account)
return 0
var/list/allmails = current_account.all_emails()
if(allmails.len > last_message_count)
. = 2
else if(allmails.len > read_message_count)
. = 1
else
. = 0
last_message_count = allmails.len
if(messages_read)
read_message_count = allmails.len
/datum/nano_module/email_client/proc/log_out()
current_account = null
downloading = null
download_progress = 0
last_message_count = 0
read_message_count = 0
/datum/nano_module/email_client/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()
// Password has been changed by other client connected to this email account
if(current_account)
if(current_account.password != stored_password)
log_out()
error = "Invalid Password"
// Banned.
if(current_account.suspended)
log_out()
error = "This account has been suspended. Please contact the system administrator for assistance."
if(error)
data["error"] = error
else if(downloading)
data["downloading"] = 1
data["down_filename"] = "[downloading.filename].[downloading.filetype]"
data["down_progress"] = download_progress
data["down_size"] = downloading.size
data["down_speed"] = download_speed
else if(istype(current_account))
data["current_account"] = current_account.login
if(addressbook)
var/list/all_accounts = list()
for(var/datum/computer_file/data/email_account/account in ntnet_global.email_accounts)
if(!account.can_login)
continue
all_accounts.Add(list(list(
"login" = account.login
)))
data["addressbook"] = 1
data["accounts"] = all_accounts
else if(new_message)
data["new_message"] = 1
data["msg_title"] = msg_title
data["msg_body"] = pencode2html(msg_body)
data["msg_recipient"] = msg_recipient
if(msg_attachment)
data["msg_hasattachment"] = 1
data["msg_attachment_filename"] = "[msg_attachment.filename].[msg_attachment.filetype]"
data["msg_attachment_size"] = msg_attachment.size
else if (current_message)
data["cur_title"] = current_message.title
data["cur_body"] = pencode2html(current_message.stored_data)
data["cur_timestamp"] = current_message.timestamp
data["cur_source"] = current_message.source
data["cur_uid"] = current_message.uid
if(istype(current_message.attachment))
data["cur_hasattachment"] = 1
data["cur_attachment_filename"] = "[current_message.attachment.filename].[current_message.attachment.filetype]"
data["cur_attachment_size"] = current_message.attachment.size
else
data["label_inbox"] = "Inbox ([current_account.inbox.len])"
data["label_spam"] = "Spam ([current_account.spam.len])"
data["label_deleted"] = "Deleted ([current_account.deleted.len])"
var/list/message_source
if(folder == "Inbox")
message_source = current_account.inbox
else if(folder == "Spam")
message_source = current_account.spam
else if(folder == "Deleted")
message_source = current_account.deleted
if(message_source)
data["folder"] = folder
var/list/all_messages = list()
for(var/datum/computer_file/data/email_message/message in message_source)
all_messages.Add(list(list(
"title" = message.title,
"body" = pencode2html(message.stored_data),
"source" = message.source,
"timestamp" = message.timestamp,
"uid" = message.uid
)))
data["messages"] = all_messages
data["messagecount"] = all_messages.len
else
data["stored_login"] = stored_login
data["stored_password"] = stars(stored_password, 0)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "email_client.tmpl", "Email Client", 600, 450, state = state)
if(host.update_layout())
ui.auto_update_layout = 1
ui.set_auto_update(1)
ui.set_initial_data(data)
ui.open()
/datum/nano_module/email_client/proc/find_message_by_fuid(var/fuid)
if(!istype(current_account))
return
// href_list works with strings, so this makes it a bit easier for us
if(istext(fuid))
fuid = text2num(fuid)
for(var/datum/computer_file/data/email_message/message in current_account.all_emails())
if(message.uid == fuid)
return message
/datum/nano_module/email_client/proc/clear_message()
new_message = FALSE
msg_title = ""
msg_body = ""
msg_recipient = ""
msg_attachment = null
current_message = null
/datum/nano_module/email_client/proc/relayed_process(var/netspeed)
download_speed = netspeed
if(!downloading)
return
download_progress = min(download_progress + netspeed, downloading.size)
if(download_progress >= downloading.size)
var/obj/item/modular_computer/MC = nano_host()
if(!istype(MC) || !MC.hard_drive || !MC.hard_drive.check_functionality())
error = "Error uploading file. Are you using a functional and NTOSv2-compliant device?"
downloading = null
download_progress = 0
return 1
if(MC.hard_drive.store_file(downloading))
error = "File successfully downloaded to local device."
else
error = "Error saving file: I/O Error: The hard drive may be full or nonfunctional."
downloading = null
download_progress = 0
return 1
/datum/nano_module/email_client/Topic(href, href_list)
if(..())
return 1
var/mob/living/user = usr
check_for_new_messages(1) // Any actual interaction (button pressing) is considered as acknowledging received message, for the purpose of notification icons.
if(href_list["login"])
log_in()
return 1
if(href_list["logout"])
log_out()
return 1
if(href_list["reset"])
error = ""
return 1
if(href_list["new_message"])
new_message = TRUE
return 1
if(href_list["cancel"])
if(addressbook)
addressbook = FALSE
else
clear_message()
return 1
if(href_list["addressbook"])
addressbook = TRUE
return 1
if(href_list["set_recipient"])
msg_recipient = sanitize(href_list["set_recipient"])
addressbook = FALSE
return 1
if(href_list["edit_title"])
var/newtitle = sanitize(input(user,"Enter title for your message:", "Message title", msg_title), 100)
if(newtitle)
msg_title = newtitle
return 1
// This uses similar editing mechanism as the FileManager program, therefore it supports various paper tags and remembers formatting.
if(href_list["edit_body"])
var/oldtext = html_decode(msg_body)
oldtext = replacetext(oldtext, "\[editorbr\]", "\n")
var/newtext = sanitize(replacetext(input(usr, "Enter your message. You may use most tags from paper formatting", "Message Editor", oldtext) as message|null, "\n", "\[editorbr\]"), 20000)
if(newtext)
msg_body = newtext
return 1
if(href_list["edit_recipient"])
var/newrecipient = sanitize(input(user,"Enter recipient's email address:", "Recipient", msg_recipient), 100)
if(newrecipient)
msg_recipient = newrecipient
return 1
if(href_list["edit_login"])
var/newlogin = sanitize(input(user,"Enter login", "Login", stored_login), 100)
if(newlogin)
stored_login = newlogin
return 1
if(href_list["edit_password"])
var/newpass = sanitize(input(user,"Enter password", "Password"), 100)
if(newpass)
stored_password = newpass
return 1
if(href_list["delete"])
if(!istype(current_account))
return 1
var/datum/computer_file/data/email_message/M = find_message_by_fuid(href_list["delete"])
if(!istype(M))
return 1
if(folder == "Deleted")
current_account.deleted.Remove(M)
qdel(M)
else
current_account.deleted.Add(M)
current_account.inbox.Remove(M)
current_account.spam.Remove(M)
if(current_message == M)
current_message = null
return 1
if(href_list["send"])
if(!current_account)
return 1
if((msg_title == "") || (msg_body == "") || (msg_recipient == ""))
error = "Error sending mail: Title or message body is empty!"
return 1
var/datum/computer_file/data/email_message/message = new()
message.title = msg_title
message.stored_data = msg_body
message.source = current_account.login
message.attachment = msg_attachment
if(!current_account.send_mail(msg_recipient, message))
error = "Error sending email: this address doesn't exist."
return 1
else
error = "Email successfully sent."
clear_message()
return 1
if(href_list["set_folder"])
folder = href_list["set_folder"]
return 1
if(href_list["reply"])
var/datum/computer_file/data/email_message/M = find_message_by_fuid(href_list["reply"])
if(!istype(M))
return 1
new_message = TRUE
msg_recipient = M.source
msg_title = "Re: [M.title]"
msg_body = "\[editorbr\]\[editorbr\]\[editorbr\]\[br\]==============================\[br\]\[editorbr\]"
msg_body += "Received by [current_account.login] at [M.timestamp]\[br\]\[editorbr\][M.stored_data]"
return 1
if(href_list["view"])
var/datum/computer_file/data/email_message/M = find_message_by_fuid(href_list["view"])
if(istype(M))
current_message = M
return 1
if(href_list["changepassword"])
var/oldpassword = sanitize(input(user,"Please enter your old password:", "Password Change"), 100)
if(!oldpassword)
return 1
var/newpassword1 = sanitize(input(user,"Please enter your new password:", "Password Change"), 100)
if(!newpassword1)
return 1
var/newpassword2 = sanitize(input(user,"Please re-enter your new password:", "Password Change"), 100)
if(!newpassword2)
return 1
if(!istype(current_account))
error = "Please log in before proceeding."
return 1
if(current_account.password != oldpassword)
error = "Incorrect original password"
return 1
if(newpassword1 != newpassword2)
error = "The entered passwords do not match."
return 1
current_account.password = newpassword1
stored_password = newpassword1
error = "Your password has been successfully changed!"
return 1
// The following entries are Modular Computer framework only, and therefore won't do anything in other cases (like AI View)
if(href_list["save"])
// Fully dependant on modular computers here.
var/obj/item/modular_computer/MC = nano_host()
if(!istype(MC) || !MC.hard_drive || !MC.hard_drive.check_functionality())
error = "Error exporting file. Are you using a functional and NTOS-compliant device?"
return 1
var/filename = sanitize(input(user,"Please specify file name:", "Message export"), 100)
if(!filename)
return 1
var/datum/computer_file/data/email_message/M = find_message_by_fuid(href_list["save"])
var/datum/computer_file/data/mail = istype(M) ? M.export() : null
if(!istype(mail))
return 1
mail.filename = filename
if(!MC.hard_drive || !MC.hard_drive.store_file(mail))
error = "Internal I/O error when writing file, the hard drive may be full."
else
error = "Email exported successfully"
return 1
if(href_list["addattachment"])
var/obj/item/modular_computer/MC = nano_host()
msg_attachment = null
if(!istype(MC) || !MC.hard_drive || !MC.hard_drive.check_functionality())
error = "Error uploading file. Are you using a functional and NTOSv2-compliant device?"
return 1
var/list/filenames = list()
for(var/datum/computer_file/CF in MC.hard_drive.stored_files)
if(CF.unsendable)
continue
filenames.Add(CF.filename)
var/picked_file = input(user, "Please pick a file to send as attachment (max 32GQ)") as null|anything in filenames
if(!picked_file)
return 1
if(!istype(MC) || !MC.hard_drive || !MC.hard_drive.check_functionality())
error = "Error uploading file. Are you using a functional and NTOSv2-compliant device?"
return 1
for(var/datum/computer_file/CF in MC.hard_drive.stored_files)
if(CF.unsendable)
continue
if(CF.filename == picked_file)
msg_attachment = CF.clone()
break
if(!istype(msg_attachment))
msg_attachment = null
error = "Unknown error when uploading attachment."
return 1
if(msg_attachment.size > 32)
error = "Error uploading attachment: File exceeds maximal permitted file size of 32GQ."
msg_attachment = null
else
error = "File [msg_attachment.filename].[msg_attachment.filetype] has been successfully uploaded."
return 1
if(href_list["downloadattachment"])
if(!current_account || !current_message || !current_message.attachment)
return 1
var/obj/item/modular_computer/MC = nano_host()
if(!istype(MC) || !MC.hard_drive || !MC.hard_drive.check_functionality())
error = "Error downloading file. Are you using a functional and NTOSv2-compliant device?"
return 1
downloading = current_message.attachment.clone()
download_progress = 0
return 1
if(href_list["canceldownload"])
downloading = null
download_progress = 0
return 1
if(href_list["remove_attachment"])
msg_attachment = null
return 1
@@ -104,7 +104,7 @@
// This is mostly intended to prevent people from losing texts they spent lot of time working on due to running out of space.
// They will be able to copy-paste the text from error screen and store it in notepad or something.
if(!HDD.store_file(F))
error = "I/O error: Unable to overwrite file. Hard drive is probably full. You may want to backup your changes before closing this window:<br><br>[F.stored_data]<br><br>"
error = "I/O error: Unable to overwrite file. Hard drive is probably full. You may want to backup your changes before closing this window:<br><br>[html_decode(F.stored_data)]<br><br>"
HDD.store_file(backup)
if(href_list["PRG_printfile"])
. = 1
@@ -119,7 +119,7 @@
if(!computer.nano_printer)
error = "Missing Hardware: Your computer does not have required hardware to complete this operation."
return 1
if(!computer.nano_printer.print_text(parse_tags(F.stored_data)))
if(!computer.nano_printer.print_text(pencode2html(F.stored_data)))
error = "Hardware error: Printer was unable to print the file. It may be out of paper."
return 1
if(href_list["PRG_copytousb"])
@@ -147,44 +147,6 @@
if(.)
SSnanoui.update_uis(NM)
/datum/computer_file/program/filemanager/proc/parse_tags(var/t)
t = replacetext(t, "\[center\]", "<center>")
t = replacetext(t, "\[/center\]", "</center>")
t = replacetext(t, "\[br\]", "<BR>")
t = replacetext(t, "\[b\]", "<B>")
t = replacetext(t, "\[/b\]", "</B>")
t = replacetext(t, "\[i\]", "<I>")
t = replacetext(t, "\[/i\]", "</I>")
t = replacetext(t, "\[u\]", "<U>")
t = replacetext(t, "\[/u\]", "</U>")
t = replacetext(t, "\[time\]", "[stationtime2text()]")
t = replacetext(t, "\[date\]", "[stationdate2text()]")
t = replacetext(t, "\[large\]", "<font size=\"4\">")
t = replacetext(t, "\[/large\]", "</font>")
t = replacetext(t, "\[h1\]", "<H1>")
t = replacetext(t, "\[/h1\]", "</H1>")
t = replacetext(t, "\[h2\]", "<H2>")
t = replacetext(t, "\[/h2\]", "</H2>")
t = replacetext(t, "\[h3\]", "<H3>")
t = replacetext(t, "\[/h3\]", "</H3>")
t = replacetext(t, "\[*\]", "<li>")
t = replacetext(t, "\[hr\]", "<HR>")
t = replacetext(t, "\[small\]", "<font size = \"1\">")
t = replacetext(t, "\[/small\]", "</font>")
t = replacetext(t, "\[list\]", "<ul>")
t = replacetext(t, "\[/list\]", "</ul>")
t = replacetext(t, "\[table\]", "<table border=1 cellspacing=0 cellpadding=3 style='border: 1px solid black;'>")
t = replacetext(t, "\[/table\]", "</td></tr></table>")
t = replacetext(t, "\[grid\]", "<table>")
t = replacetext(t, "\[/grid\]", "</td></tr></table>")
t = replacetext(t, "\[row\]", "</td><tr>")
t = replacetext(t, "\[tr\]", "</td><tr>")
t = replacetext(t, "\[td\]", "<td>")
t = replacetext(t, "\[cell\]", "<td>")
t = replacetext(t, "\[logo\]", "<img src = ntlogo.png>")
return t
/datum/nano_module/program/computer_filemanager
name = "NTOS File Manager"
@@ -208,7 +170,7 @@
if(!istype(file))
data["error"] = "I/O ERROR: Unable to open file."
else
data["filedata"] = PRG.parse_tags(file.stored_data)
data["filedata"] = pencode2html(file.stored_data)
data["filename"] = "[file.filename].[file.filetype]"
else
if(!PRG.computer || !PRG.computer.hard_drive)
@@ -3,7 +3,7 @@
filedesc = "NTNet/ExoNet News Browser"
extended_desc = "This program may be used to view and download news articles from the network."
program_icon_state = "generic"
size = 8
size = 4
requires_ntnet = 1
available_on_ntnet = 1
@@ -13,6 +13,7 @@
var/download_netspeed = 0
var/downloading = 0
var/message = ""
var/show_archived = 0
/datum/computer_file/program/newsbrowser/process_tick()
if(!downloading)
@@ -38,6 +39,7 @@
loaded_article = null
download_progress = 0
downloading = 0
show_archived = 0
/datum/computer_file/program/newsbrowser/Topic(href, href_list)
if(..())
@@ -75,6 +77,9 @@
var/datum/computer_file/data/news_article/N = loaded_article.clone()
N.filename = savename
HDD.store_file(N)
if(href_list["PRG_toggle_archived"])
. = 1
show_archived = !show_archived
if(.)
SSnanoui.update_uis(NM)
@@ -95,6 +100,7 @@
data["message"] = PRG.message
if(PRG.loaded_article && !PRG.downloading) // Viewing an article.
data["title"] = PRG.loaded_article.filename
data["cover"] = PRG.loaded_article.cover
data["article"] = PRG.loaded_article.stored_data
else if(PRG.downloading) // Downloading an article.
data["download_running"] = 1
@@ -104,16 +110,20 @@
else // Viewing list of articles
var/list/all_articles[0]
for(var/datum/computer_file/data/news_article/F in ntnet_global.available_news)
if(!PRG.show_archived && F.archived)
continue
all_articles.Add(list(list(
"name" = F.filename,
"size" = F.size,
"uid" = F.uid
"uid" = F.uid,
"archived" = F.archived
)))
data["all_articles"] = all_articles
data["showing_archived"] = PRG.show_archived
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "news_browser.tmpl", "NTNet/ExoNet News Browser", 575, 700, state = state)
ui = new(user, src, ui_key, "news_browser.tmpl", "NTNet/ExoNet News Browser", 575, 750, state = state)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
@@ -17,6 +17,14 @@
var/download_netspeed = 0
var/downloaderror = ""
/datum/computer_file/program/ntnetdownload/kill_program()
..()
downloaded_file = null
download_completion = 0
download_netspeed = 0
downloaderror = ""
ui_header = "downloader_finished.gif"
/datum/computer_file/program/ntnetdownload/proc/begin_file_download(var/filename)
if(downloaded_file)
return 0
@@ -28,7 +28,7 @@
if(!channel)
return 1
var/mob/living/user = usr
var/message = sanitize(input(user, "Enter message or leave blank to cancel: "))
var/message = sanitize(input(user, "Enter message or leave blank to cancel: "), 512)
if(!message || !channel)
return
channel.add_message(message, username)
@@ -65,7 +65,7 @@
if(href_list["PRG_newchannel"])
. = 1
var/mob/living/user = usr
var/channel_title = sanitize(input(user,"Enter channel name or leave blank to cancel:"))
var/channel_title = sanitizeSafe(input(user,"Enter channel name or leave blank to cancel:"), 64)
if(!channel_title)
return
var/datum/ntnet_conversation/C = new/datum/ntnet_conversation()
@@ -95,7 +95,7 @@
if(href_list["PRG_changename"])
. = 1
var/mob/living/user = usr
var/newname = sanitize(input(user,"Enter new nickname or leave blank to cancel:"))
var/newname = sanitize(input(user,"Enter new nickname or leave blank to cancel:"), 20)
if(!newname)
return 1
if(channel)
@@ -132,7 +132,7 @@
if(!operator_mode || !channel)
return 1
var/mob/living/user = usr
var/newname = sanitize(input(user, "Enter new channel name or leave blank to cancel:"))
var/newname = sanitize(input(user, "Enter new channel name or leave blank to cancel:"), 64)
if(!newname || !channel)
return
channel.add_status_message("Channel renamed from [channel.title] to [newname] by operator.")
@@ -19,7 +19,6 @@ var/global/nttransfer_uid = 0
var/list/connected_clients = list() // List of connected clients.
var/datum/computer_file/program/nttransfer/remote // Client var, specifies who are we downloading from.
var/download_completion = 0 // Download progress in GQ
var/download_netspeed = 0 // Our connectivity speed in GQ/s
var/actual_netspeed = 0 // Displayed in the UI, this is the actual transfer speed.
var/unique_token // UID of this program
var/upload_menu = 0 // Whether we show the program list and upload menu
@@ -31,13 +30,12 @@ var/global/nttransfer_uid = 0
/datum/computer_file/program/nttransfer/process_tick()
// Server mode
update_netspeed()
if(provided_file)
for(var/datum/computer_file/program/nttransfer/C in connected_clients)
// Transfer speed is limited by device which uses slower connectivity.
// We can have multiple clients downloading at same time, but let's assume we use some sort of multicast transfer
// so they can all run on same speed.
C.actual_netspeed = min(C.download_netspeed, download_netspeed)
C.actual_netspeed = min(C.ntnet_speed, ntnet_speed)
C.download_completion += C.actual_netspeed
if(C.download_completion >= provided_file.size)
C.finish_download()
@@ -55,18 +53,6 @@ var/global/nttransfer_uid = 0
downloaded_file = null
..(forced)
/datum/computer_file/program/nttransfer/proc/update_netspeed()
download_netspeed = 0
switch(ntnet_status)
if(1)
download_netspeed = NTNETSPEED_LOWSIGNAL
if(2)
download_netspeed = NTNETSPEED_HIGHSIGNAL
if(3)
download_netspeed = NTNETSPEED_ETHERNET
// Finishes download and attempts to store the file on HDD
/datum/computer_file/program/nttransfer/proc/finish_download()
if(!computer || !computer.hard_drive || !computer.hard_drive.store_file(downloaded_file))
@@ -125,6 +111,8 @@ var/global/nttransfer_uid = 0
else
var/list/all_servers[0]
for(var/datum/computer_file/program/nttransfer/P in ntnet_global.fileservers)
if(!P.provided_file)
continue
all_servers.Add(list(list(
"uid" = P.unique_token,
"filename" = "[P.provided_file.filename].[P.provided_file.filetype]",
@@ -0,0 +1,63 @@
/datum/computer_file/program/suit_sensors
filename = "sensormonitor"
filedesc = "Suit Sensors Monitoring"
nanomodule_path = /datum/nano_module/crew_monitor
program_icon_state = "crew"
extended_desc = "This program connects to life signs monitoring system to provide basic information on crew health."
required_access = access_medical
requires_ntnet = 1
network_destination = "crew lifesigns monitoring system"
size = 11
/datum/nano_module/crew_monitor
name = "Crew monitor"
/datum/nano_module/crew_monitor/Topic(href, href_list)
if(..()) return 1
var/turf/T = get_turf(nano_host()) // TODO: Allow setting any using_map.contact_levels from the interface.
if (!T || !(T.z in using_map.player_levels))
usr << "<span class='warning'>Unable to establish a connection</span>: You're too far away from the station!"
return 0
if(href_list["track"])
if(isAI(usr))
var/mob/living/silicon/ai/AI = usr
var/mob/living/carbon/human/H = locate(href_list["track"]) in mob_list
if(hassensorlevel(H, SUIT_SENSOR_TRACKING))
AI.ai_actual_track(H)
return 1
/datum/nano_module/crew_monitor/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()
var/turf/T = get_turf(nano_host())
data["isAI"] = isAI(user)
data["map_levels"] = using_map.get_map_levels(T.z, FALSE)
data["crewmembers"] = list()
for(var/z in (data["map_levels"] | T.z)) // Always show crew from the current Z even if we can't show a map
data["crewmembers"] += crew_repository.health_data(z)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, src, ui_key, "crew_monitor.tmpl", "Crew Monitoring Computer", 900, 800, state = state)
// adding a template with the key "mapContent" enables the map ui functionality
ui.add_template("mapContent", "crew_monitor_map_content.tmpl")
// adding a template with the key "mapHeader" replaces the map header content
ui.add_template("mapHeader", "crew_monitor_map_header.tmpl")
if(!(ui.map_z_level in data["map_levels"]))
ui.set_map_z_level(data["map_levels"][1])
ui.set_initial_data(data)
ui.open()
// should make the UI auto-update; doesn't seem to?
ui.set_auto_update(1)
/*/datum/nano_module/crew_monitor/proc/scan()
for(var/mob/living/carbon/human/H in mob_list)
if(istype(H.w_uniform, /obj/item/clothing/under))
var/obj/item/clothing/under/C = H.w_uniform
if (C.has_sensor)
tracked |= C
return 1
*/
@@ -0,0 +1,142 @@
/datum/computer_file/program/email_administration
filename = "emailadmin"
filedesc = "Email Administration Utility"
extended_desc = "This program may be used to administrate NTNet's emailing service."
program_icon_state = "comm_monitor"
size = 12
requires_ntnet = 1
available_on_ntnet = 1
nanomodule_path = /datum/nano_module/email_administration
required_access = access_network
/datum/nano_module/email_administration/
name = "Email Client"
var/datum/computer_file/data/email_account/current_account = null
var/datum/computer_file/data/email_message/current_message = null
var/error = ""
/datum/nano_module/email_administration/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()
if(error)
data["error"] = error
else if(istype(current_message))
data["msg_title"] = current_message.title
data["msg_body"] = pencode2html(current_message.stored_data)
data["msg_timestamp"] = current_message.timestamp
data["msg_source"] = current_message.source
else if(istype(current_account))
data["current_account"] = current_account.login
data["cur_suspended"] = current_account.suspended
var/list/all_messages = list()
for(var/datum/computer_file/data/email_message/message in (current_account.inbox | current_account.spam | current_account.deleted))
all_messages.Add(list(list(
"title" = message.title,
"source" = message.source,
"timestamp" = message.timestamp,
"uid" = message.uid
)))
data["messages"] = all_messages
data["messagecount"] = all_messages.len
else
var/list/all_accounts = list()
for(var/datum/computer_file/data/email_account/account in ntnet_global.email_accounts)
if(!account.can_login)
continue
all_accounts.Add(list(list(
"login" = account.login,
"uid" = account.uid
)))
data["accounts"] = all_accounts
data["accountcount"] = all_accounts.len
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "email_administration.tmpl", "Email Administration Utility", 600, 450, state = state)
if(host.update_layout())
ui.auto_update_layout = 1
ui.set_auto_update(1)
ui.set_initial_data(data)
ui.open()
/datum/nano_module/email_administration/Topic(href, href_list)
if(..())
return 1
var/mob/user = usr
if(!istype(user))
return 1
// High security - can only be operated when the user has an ID with access on them.
var/obj/item/weapon/card/id/I = user.GetIdCard()
if(!istype(I) || !(access_network in I.access))
return 1
if(href_list["back"])
if(error)
error = ""
else if(current_message)
current_message = null
else
current_account = null
return 1
if(href_list["ban"])
if(!current_account)
return 1
current_account.suspended = !current_account.suspended
ntnet_global.add_log_with_ids_check("EMAIL LOG: SA-EDIT Account [current_account.login] has been [current_account.suspended ? "" : "un" ]suspended by SA [I.registered_name] ([I.assignment]).")
error = "Account [current_account.login] has been [current_account.suspended ? "" : "un" ]suspended."
return 1
if(href_list["changepass"])
if(!current_account)
return 1
var/newpass = sanitize(input(user,"Enter new password for account [current_account.login]", "Password"), 100)
if(!newpass)
return 1
current_account.password = newpass
ntnet_global.add_log_with_ids_check("EMAIL LOG: SA-EDIT Password for account [current_account.login] has been changed by SA [I.registered_name] ([I.assignment]).")
return 1
if(href_list["viewmail"])
if(!current_account)
return 1
for(var/datum/computer_file/data/email_message/received_message in (current_account.inbox | current_account.spam | current_account.deleted))
if(received_message.uid == text2num(href_list["viewmail"]))
current_message = received_message
break
return 1
if(href_list["viewaccount"])
for(var/datum/computer_file/data/email_account/email_account in ntnet_global.email_accounts)
if(email_account.uid == text2num(href_list["viewaccount"]))
current_account = email_account
break
return 1
if(href_list["newaccount"])
var/newdomain = sanitize(input(user,"Pick domain:", "Domain name") as null|anything in using_map.usable_email_tlds)
if(!newdomain)
return 1
var/newlogin = sanitize(input(user,"Pick account name (@[newdomain]):", "Account name"), 100)
if(!newlogin)
return 1
var/complete_login = "[newlogin]@[newdomain]"
if(ntnet_global.does_email_exist(complete_login))
error = "Error creating account: An account with same address already exists."
return 1
var/datum/computer_file/data/email_account/new_account = new/datum/computer_file/data/email_account()
new_account.login = complete_login
new_account.password = GenerateKey()
error = "Email [new_account.login] has been created, with generated password [new_account.password]"
return 1
@@ -2,7 +2,7 @@
filename = "ntmonitor"
filedesc = "NTNet Diagnostics and Monitoring"
program_icon_state = "comm_monitor"
extended_desc = "This program monitors stationwide NTNet network, provides access to logging systems, and allows for configuration changes"
extended_desc = "This program monitors the local NTNet network, provides access to logging systems, and allows for configuration changes"
size = 12
requires_ntnet = 1
required_access = access_network
@@ -0,0 +1,141 @@
var/warrant_uid = 0
/datum/datacore/var/list/warrants[] = list()
/datum/data/record/warrant
var/warrant_id
/datum/data/record/warrant/New()
..()
warrant_id = warrant_uid++
/datum/computer_file/program/digitalwarrant
filename = "digitalwarrant"
filedesc = "Warrant Assistant"
extended_desc = "Official NTsec program for creation and handling of warrants."
size = 8
program_icon_state = "warrant"
requires_ntnet = 1
available_on_ntnet = 1
required_access = access_security
usage_flags = PROGRAM_ALL
nanomodule_path = /datum/nano_module/program/digitalwarrant/
/datum/nano_module/program/digitalwarrant/
name = "Warrant Assistant"
var/datum/data/record/warrant/activewarrant
/datum/nano_module/program/digitalwarrant/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()
if(activewarrant)
data["warrantname"] = activewarrant.fields["namewarrant"]
data["warrantcharges"] = activewarrant.fields["charges"]
data["warrantauth"] = activewarrant.fields["auth"]
data["type"] = activewarrant.fields["arrestsearch"]
else
var/list/allwarrants = list()
for(var/datum/data/record/warrant/W in data_core.warrants)
allwarrants.Add(list(list(
"warrantname" = W.fields["namewarrant"],
"charges" = "[copytext(W.fields["charges"],1,min(length(W.fields["charges"]) + 1, 50))]...",
"auth" = W.fields["auth"],
"id" = W.warrant_id,
"arrestsearch" = W.fields["arrestsearch"]
)))
data["allwarrants"] = allwarrants
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
ui = new(user, src, ui_key, "digitalwarrant.tmpl", name, 500, 350, state = state)
ui.auto_update_layout = 1
ui.set_initial_data(data)
ui.open()
/datum/nano_module/program/digitalwarrant/Topic(href, href_list)
if(..())
return 1
if(href_list["sw_menu"])
activewarrant = null
if(href_list["editwarrant"])
. = 1
for(var/datum/data/record/warrant/W in data_core.warrants)
if(W.warrant_id == text2num(href_list["editwarrant"]))
activewarrant = W
break
// The following actions will only be possible if the user has an ID with security access equipped. This is in line with modular computer framework's authentication methods,
// which also use RFID scanning to allow or disallow access to some functions. Anyone can view warrants, editing requires ID. This also prevents situations where you show a tablet
// to someone who is to be arrested, which allows them to change the stuff there.
var/mob/user = usr
if(!istype(user))
return
var/obj/item/weapon/card/id/I = user.GetIdCard()
if(!istype(I) || !I.registered_name || !(access_security in I.access))
to_chat(user, "Authentication error: Unable to locate ID with apropriate access to allow this operation.")
return
if(href_list["addwarrant"])
. = 1
var/datum/data/record/warrant/W = new()
var/temp = sanitize(input(usr, "Do you want to create a search-, or an arrest warrant?") as null|anything in list("search","arrest"))
if(CanInteract(user, default_state))
if(temp == "arrest")
W.fields["namewarrant"] = "Unknown"
W.fields["charges"] = "No charges present"
W.fields["auth"] = "Unauthorized"
W.fields["arrestsearch"] = "arrest"
if(temp == "search")
W.fields["namewarrant"] = "No location given"
W.fields["charges"] = "No reason given"
W.fields["auth"] = "Unauthorized"
W.fields["arrestsearch"] = "search"
activewarrant = W
if(href_list["savewarrant"])
. = 1
data_core.warrants |= activewarrant
activewarrant = null
if(href_list["deletewarrant"])
. = 1
data_core.warrants -= activewarrant
activewarrant = null
if(href_list["editwarrantname"])
. = 1
var/namelist = list()
for(var/datum/data/record/t in data_core.general)
namelist += t.fields["name"]
var/new_name = sanitize(input(usr, "Please input name") as null|anything in namelist)
if(CanInteract(user, default_state))
if (!new_name)
return
activewarrant.fields["namewarrant"] = new_name
if(href_list["editwarrantnamecustom"])
. = 1
var/new_name = sanitize(input("Please input name") as null|text)
if(CanInteract(user, default_state))
if (!new_name)
return
activewarrant.fields["namewarrant"] = new_name
if(href_list["editwarrantcharges"])
. = 1
var/new_charges = sanitize(input("Please input charges", "Charges", activewarrant.fields["charges"]) as null|text)
if(CanInteract(user, default_state))
if (!new_charges)
return
activewarrant.fields["charges"] = new_charges
if(href_list["editwarrantauth"])
. = 1
activewarrant.fields["auth"] = "[I.registered_name] - [I.assignment ? I.assignment : "(Unknown)"]"
if(href_list["back"])
. = 1
activewarrant = null
@@ -48,11 +48,6 @@
/obj/item/weapon/computer_hardware/New(var/obj/L)
w_class = hardware_size
if(istype(L, /obj/machinery/modular_computer))
var/obj/machinery/modular_computer/C = L
if(C.cpu)
holder2 = C.cpu
return
if(istype(L, /obj/item/modular_computer))
holder2 = L
return
@@ -70,6 +70,10 @@
battery.charge = 0
..()
/obj/item/weapon/computer_hardware/battery_module/Destroy()
qdel_null(battery)
return ..()
/obj/item/weapon/computer_hardware/battery_module/proc/charge_to_full()
if(battery)
battery.charge = battery.maxcharge
@@ -15,4 +15,4 @@
if(stored_card)
stored_card.forceMove(get_turf(holder2))
holder2 = null
..()
return ..()
@@ -160,7 +160,7 @@
if(holder2 && (holder2.hard_drive == src))
holder2.hard_drive = null
stored_files = null
..()
return ..()
/obj/item/weapon/computer_hardware/hard_drive/New()
install_default_programs()
@@ -43,4 +43,4 @@
if(holder2 && (holder2.nano_printer == src))
holder2.nano_printer = null
holder2 = null
..()
return ..()
@@ -32,7 +32,7 @@ var/global/ntnet_card_uid = 1
/obj/item/weapon/computer_hardware/network_card/advanced
name = "advanced NTNet network card"
desc = "An advanced network card for usage with standard NTNet frequencies. It's transmitter is strong enough to connect even off-station."
desc = "An advanced network card for usage with standard NTNet frequencies. It's transmitter is strong enough to connect even when far away."
long_range = 1
origin_tech = list(TECH_DATA = 4, TECH_ENGINEERING = 2)
power_usage = 100 // Better range but higher power usage.
@@ -52,7 +52,7 @@ var/global/ntnet_card_uid = 1
if(holder2 && (holder2.network_card == src))
holder2.network_card = null
holder2 = null
..()
return ..()
// Returns a string identifier of this network card
/obj/item/weapon/computer_hardware/network_card/proc/get_network_tag()
@@ -77,19 +77,21 @@ var/global/ntnet_card_uid = 1
if(holder2)
var/turf/T = get_turf(holder2)
if((T && istype(T)) && T.z in using_map.station_levels)
if(!istype(T)) //no reception in nullspace
return 0
if(T.z in using_map.station_levels)
// Computer is on station. Low/High signal depending on what type of network card you have
if(long_range)
return 2
else
return 1
if(long_range) // Computer is not on station, but it has upgraded network card. Low signal.
return 1
if(T.z in using_map.contact_levels) //not on station, but close enough for radio signal to travel
if(long_range) // Computer is not on station, but it has upgraded network card. Low signal.
return 1
return 0 // Computer is not on station and does not have upgraded network card. No signal.
/obj/item/weapon/computer_hardware/network_card/Destroy()
if(holder2 && (holder2.network_card == src))
holder2.network_card = null
..()
..()
@@ -29,4 +29,9 @@
/obj/item/weapon/computer_hardware/hard_drive/portable/New()
..()
stored_files = list()
recalculate_size()
recalculate_size()
/obj/item/weapon/computer_hardware/hard_drive/portable/Destroy()
if(holder2 && (holder2.portable_drive == src))
holder2.portable_drive = null
return ..()
@@ -38,4 +38,9 @@
hardware_size = 1
power_usage = 75
max_idle_programs = 2
origin_tech = list(TECH_DATA = 4, TECH_ENGINEERING = 3)
origin_tech = list(TECH_DATA = 4, TECH_ENGINEERING = 3)
/obj/item/weapon/computer_hardware/processor_unit/Destroy()
if(holder2 && (holder2.processor_unit == src))
holder2.processor_unit = null
return ..()
@@ -6,16 +6,9 @@
icon_state = "teslalink"
hardware_size = 1
origin_tech = list(TECH_DATA = 2, TECH_POWER = 3, TECH_ENGINEERING = 2)
var/obj/machinery/modular_computer/holder
var/passive_charging_rate = 250 // W
/obj/item/weapon/computer_hardware/tesla_link/New(var/obj/L)
if(istype(L, /obj/machinery/modular_computer))
holder = L
return
..(L)
/obj/item/weapon/computer_hardware/tesla_link/Destroy()
if(holder2 && (holder2.tesla_link == src))
holder2.tesla_link = null
..()
return ..()
+24 -18
View File
@@ -2,7 +2,7 @@
/obj/machinery/lapvend
name = "computer vendor"
desc = "A vending machine with microfabricator capable of dispensing various NT-branded computers"
desc = "A vending machine with a built-in microfabricator, capable of dispensing various NT-branded computers."
icon = 'icons/obj/vending.dmi'
icon_state = "robotics"
layer = OBJ_LAYER - 0.1
@@ -10,7 +10,7 @@
density = 1
// The actual laptop/tablet
var/obj/machinery/modular_computer/laptop/fabricated_laptop = null
var/obj/item/modular_computer/laptop/fabricated_laptop = null
var/obj/item/modular_computer/tablet/fabricated_tablet = null
// Utility vars
@@ -55,56 +55,56 @@
switch(dev_cpu)
if(1)
if(fabricate)
fabricated_laptop.cpu.processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(fabricated_laptop.cpu)
fabricated_laptop.processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(fabricated_laptop)
if(2)
if(fabricate)
fabricated_laptop.cpu.processor_unit = new/obj/item/weapon/computer_hardware/processor_unit(fabricated_laptop.cpu)
fabricated_laptop.processor_unit = new/obj/item/weapon/computer_hardware/processor_unit(fabricated_laptop)
total_price += 299
switch(dev_battery)
if(1) // Basic(750C)
if(fabricate)
fabricated_laptop.cpu.battery_module = new/obj/item/weapon/computer_hardware/battery_module(fabricated_laptop.cpu)
fabricated_laptop.battery_module = new/obj/item/weapon/computer_hardware/battery_module(fabricated_laptop)
if(2) // Upgraded(1100C)
if(fabricate)
fabricated_laptop.cpu.battery_module = new/obj/item/weapon/computer_hardware/battery_module/advanced(fabricated_laptop.cpu)
fabricated_laptop.battery_module = new/obj/item/weapon/computer_hardware/battery_module/advanced(fabricated_laptop)
total_price += 199
if(3) // Advanced(1500C)
if(fabricate)
fabricated_laptop.cpu.battery_module = new/obj/item/weapon/computer_hardware/battery_module/super(fabricated_laptop.cpu)
fabricated_laptop.battery_module = new/obj/item/weapon/computer_hardware/battery_module/super(fabricated_laptop)
total_price += 499
switch(dev_disk)
if(1) // Basic(128GQ)
if(fabricate)
fabricated_laptop.cpu.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive(fabricated_laptop.cpu)
fabricated_laptop.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive(fabricated_laptop)
if(2) // Upgraded(256GQ)
if(fabricate)
fabricated_laptop.cpu.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/advanced(fabricated_laptop.cpu)
fabricated_laptop.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/advanced(fabricated_laptop)
total_price += 99
if(3) // Advanced(512GQ)
if(fabricate)
fabricated_laptop.cpu.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/super(fabricated_laptop.cpu)
fabricated_laptop.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/super(fabricated_laptop)
total_price += 299
switch(dev_netcard)
if(1) // Basic(Short-Range)
if(fabricate)
fabricated_laptop.cpu.network_card = new/obj/item/weapon/computer_hardware/network_card(fabricated_laptop.cpu)
fabricated_laptop.network_card = new/obj/item/weapon/computer_hardware/network_card(fabricated_laptop)
total_price += 99
if(2) // Advanced (Long Range)
if(fabricate)
fabricated_laptop.cpu.network_card = new/obj/item/weapon/computer_hardware/network_card/advanced(fabricated_laptop.cpu)
fabricated_laptop.network_card = new/obj/item/weapon/computer_hardware/network_card/advanced(fabricated_laptop)
total_price += 299
if(dev_tesla)
total_price += 399
if(fabricate)
fabricated_laptop.cpu.tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(fabricated_laptop.cpu)
fabricated_laptop.tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(fabricated_laptop)
if(dev_nanoprint)
total_price += 99
if(fabricate)
fabricated_laptop.cpu.nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(fabricated_laptop.cpu)
fabricated_laptop.nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(fabricated_laptop)
if(dev_card)
total_price += 199
if(fabricate)
fabricated_laptop.cpu.card_slot = new/obj/item/weapon/computer_hardware/card_slot(fabricated_laptop.cpu)
fabricated_laptop.card_slot = new/obj/item/weapon/computer_hardware/card_slot(fabricated_laptop)
return total_price
else if(devtype == 2) // Tablet, more expensive, not everyone could probably afford this.
@@ -252,13 +252,19 @@ obj/machinery/lapvend/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(process_payment(I,W))
fabricate_and_recalc_price(1)
if((devtype == 1) && fabricated_laptop)
fabricated_laptop.cpu.battery_module.charge_to_full()
if(fabricated_laptop.battery_module)
fabricated_laptop.battery_module.charge_to_full()
fabricated_laptop.forceMove(src.loc)
fabricated_laptop.close_laptop()
fabricated_laptop.screen_on = 0
fabricated_laptop.anchored = 0
fabricated_laptop.update_icon()
fabricated_laptop.update_verbs()
fabricated_laptop = null
else if((devtype == 2) && fabricated_tablet)
fabricated_tablet.battery_module.charge_to_full()
if(fabricated_tablet.battery_module)
fabricated_tablet.battery_module.charge_to_full()
fabricated_tablet.forceMove(src.loc)
fabricated_tablet.update_verbs()
fabricated_tablet = null
ping("Enjoy your new product!")
state = 3