PCUs and SR Connected Computers (#4040)

* PCU and Connected Consoles

* Clean this up
This commit is contained in:
Zandario
2022-05-14 06:45:56 -07:00
committed by GitHub
parent 843e7e15fe
commit 03aacd017e
39 changed files with 617 additions and 462 deletions
@@ -1,13 +1,14 @@
/obj/item/modular_computer/process(delta_time)
if(!enabled) // The computer is turned off
last_power_usage = 0
return 0
return FALSE
if(damage > broken_damage)
shutdown_computer()
return 0
return FALSE
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 requires NTNet to run but we've just lost connection. Crash.
if(active_program && active_program.requires_ntnet && !get_ntnet_status(active_program.requires_ntnet_feature))
active_program.event_networkfailure(0)
for(var/datum/computer_file/program/P in idle_threads)
@@ -33,13 +34,13 @@
handle_power() // Handles all computer power interaction
check_update_ui_need()
// Used to perform preset-specific hardware changes.
/// Used to perform preset-specific hardware changes.
/obj/item/modular_computer/proc/install_default_hardware()
return 1
return TRUE
// Used to install preset-specific programs
/// Used to install preset-specific programs
/obj/item/modular_computer/proc/install_default_programs()
return 1
return TRUE
/obj/item/modular_computer/Initialize(mapload)
. = ..()
@@ -63,9 +64,9 @@
to_chat(user, "\The [src] was already emagged.")
return //NO_EMAG_ACT
else
computer_emagged = 1
computer_emagged = TRUE
to_chat(user, "You emag \the [src]. It's screen briefly shows a \"OVERRIDE ACCEPTED: New software downloads available.\" message.")
return 1
return TRUE
/obj/item/modular_computer/update_icon()
icon_state = icon_state_unpowered
@@ -87,11 +88,11 @@
else
overlays.Add(icon_state_menu)
/obj/item/modular_computer/proc/turn_on(var/mob/user)
/obj/item/modular_computer/proc/turn_on(mob/user)
if(bsod)
return
if(tesla_link)
tesla_link.enabled = 1
tesla_link.enabled = TRUE
var/issynth = issilicon(user) // Robots and AIs get different activation messages.
if(damage > broken_damage)
if(issynth)
@@ -112,8 +113,8 @@
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)
/// Relays kill program request to currently active program. Use this to quit current program.
/obj/item/modular_computer/proc/kill_program(forced = FALSE)
if(active_program)
active_program.kill_program(forced)
active_program = null
@@ -123,28 +124,28 @@
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)
/obj/item/modular_computer/proc/get_ntnet_status(specific_action = 0)
if(network_card)
return network_card.get_signal(specific_action)
else
return 0
return FALSE
/obj/item/modular_computer/proc/add_log(var/text)
/obj/item/modular_computer/proc/add_log(text)
if(!get_ntnet_status())
return 0
return FALSE
return ntnet_global.add_log(text, network_card)
/obj/item/modular_computer/proc/shutdown_computer(var/loud = 1)
/obj/item/modular_computer/proc/shutdown_computer(loud = TRUE)
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
enabled = FALSE
update_icon()
/obj/item/modular_computer/proc/enable_computer(var/mob/user = null)
/obj/item/modular_computer/proc/enable_computer(mob/user = null)
enabled = 1
update_icon()
@@ -169,7 +170,6 @@
if(istype(user))
nano_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
@@ -177,7 +177,7 @@
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>")
to_chat(user, SPAN_DANGER("\The [src]'s screen shows \"I/O ERROR - Unable to run [prog]\" warning."))
return
P.computer = src
@@ -192,11 +192,11 @@
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>")
to_chat(user, SPAN_NOTICE("\The [src] displays a \"Maximal CPU load reached. Unable to run another program.\" error"))
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>")
to_chat(user, SPAN_DANGER("\The [src]'s screen shows \"NETWORK ERROR - Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning."))
return
if(active_program)
@@ -204,7 +204,7 @@
if(P.run_program(user))
update_icon()
return 1
return TRUE
/obj/item/modular_computer/proc/update_uis()
if(active_program) //Should we update program ui or computer ui?
@@ -215,16 +215,16 @@
SSnanoui.update_uis(src)
/obj/item/modular_computer/proc/check_update_ui_need()
var/ui_update_needed = 0
var/ui_update_needed = FALSE
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
ui_update_needed = TRUE
last_battery_percent = batery_percent
if(stationtime2text() != last_world_time)
last_world_time = stationtime2text()
ui_update_needed = 1
ui_update_needed = TRUE
if(idle_threads.len)
var/list/current_header_icons = list()
@@ -237,25 +237,25 @@
else if(!(last_header_icons ~= current_header_icons))
last_header_icons = current_header_icons
ui_update_needed = 1
ui_update_needed = TRUE
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
ui_update_needed = TRUE
break
if(ui_update_needed)
update_uis()
// Used by camera monitor program
/obj/item/modular_computer/check_eye(var/mob/user)
/obj/item/modular_computer/check_eye(mob/user)
if(active_program)
return active_program.check_eye(user)
else
return ..()
/obj/item/modular_computer/relaymove(var/mob/user, direction)
/obj/item/modular_computer/relaymove(mob/user, direction)
if(active_program)
return active_program.relaymove(user, direction)
@@ -1,7 +1,7 @@
/obj/item/modular_computer/examine(mob/user)
. = ..()
if(damage > broken_damage)
. += "<span class='danger'>It is heavily damaged!</span>"
. += SPAN_DANGER("It is heavily damaged!")
else if(damage)
. += "It is damaged."
@@ -16,7 +16,7 @@
H.take_damage(rand(10,30))
qdel()
/obj/item/modular_computer/take_damage(var/amount, var/component_probability, var/damage_casing = 1, var/randomize = 1)
/obj/item/modular_computer/take_damage(amount, component_probability, damage_casing = TRUE, randomize = TRUE)
if(randomize)
// 75%-125%, rand() works with integers, apparently.
amount *= (rand(75, 125) / 100.0)
@@ -33,19 +33,23 @@
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)
/**
* Stronger explosions cause serious damage to internal components
* Minor explosions are mostly mitigitated by casing.
*/
/obj/item/modular_computer/ex_act(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)
/// 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(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)
/**
* "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(obj/item/projectile/Proj)
switch(Proj.damage_type)
if(BRUTE)
take_damage(Proj.damage, Proj.damage / 2)
@@ -1,53 +1,53 @@
// Attempts to install the hardware into apropriate slot.
/obj/item/modular_computer/proc/try_install_component(var/mob/living/user, var/obj/item/computer_hardware/H, var/found = 0)
/// Attempts to install the hardware into apropriate slot.
/obj/item/modular_computer/proc/try_install_component(mob/living/user, obj/item/computer_hardware/H, found = FALSE)
// "USB" flash drive.
if(istype(H, /obj/item/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
found = TRUE
portable_drive = H
else if(istype(H, /obj/item/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
found = TRUE
hard_drive = H
else if(istype(H, /obj/item/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
found = TRUE
network_card = H
else if(istype(H, /obj/item/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
found = TRUE
nano_printer = H
else if(istype(H, /obj/item/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
found = TRUE
card_slot = H
else if(istype(H, /obj/item/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
found = TRUE
battery_module = H
else if(istype(H, /obj/item/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
found = TRUE
processor_unit = H
else if(istype(H, /obj/item/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
found = TRUE
tesla_link = H
if(found)
to_chat(user, "You install \the [H] into \the [src]")
@@ -56,34 +56,34 @@
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/computer_hardware/H, var/found = 0, var/critical = 0)
/// Uninstalls component. Found and Critical vars may be passed by parent types, if they have additional hardware.
/obj/item/modular_computer/proc/uninstall_component(mob/living/user, obj/item/computer_hardware/H, found = FALSE, critical = FALSE)
if(portable_drive == H)
portable_drive = null
found = 1
found = TRUE
if(hard_drive == H)
hard_drive = null
found = 1
critical = 1
found = TRUE
critical = TRUE
if(network_card == H)
network_card = null
found = 1
found = TRUE
if(nano_printer == H)
nano_printer = null
found = 1
found = TRUE
if(card_slot == H)
card_slot = null
found = 1
found = TRUE
if(battery_module == H)
battery_module = null
found = 1
found = TRUE
if(processor_unit == H)
processor_unit = null
found = 1
critical = 1
found = TRUE
critical = TRUE
if(tesla_link == H)
tesla_link = null
found = 1
found = TRUE
if(found)
if(user)
to_chat(user, "You remove \the [H] from \the [src].")
@@ -92,13 +92,13 @@
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>")
to_chat(user, SPAN_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."))
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)
/// 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(name)
if(portable_drive && (portable_drive.name == name))
return portable_drive
if(hard_drive && (hard_drive.name == name))
@@ -117,7 +117,7 @@
return tesla_link
return null
// Returns list of all components
/// Returns list of all components.
/obj/item/modular_computer/proc/get_all_components()
var/list/all_components = list()
if(hard_drive)
@@ -13,20 +13,20 @@
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
to_chat(usr, SPAN_WARNING("You can't do that."))
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
to_chat(usr, SPAN_WARNING("You can't reach it."))
return
if(enabled)
bsod = 1
bsod = TRUE
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
bsod = FALSE
update_icon()
@@ -37,11 +37,11 @@
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
to_chat(usr, SPAN_WARNING("You can't do that."))
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
to_chat(usr, SPAN_WARNING("You can't reach it."))
return
proc_eject_id(usr)
@@ -53,11 +53,11 @@
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
to_chat(usr, SPAN_WARNING("You can't do that."))
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
to_chat(usr, SPAN_WARNING("You can't reach it."))
return
proc_eject_usb(usr)
@@ -97,31 +97,31 @@
uninstall_component(user, portable_drive)
update_uis()
/obj/item/modular_computer/attack_ghost(var/mob/observer/ghost/user)
/obj/item/modular_computer/attack_ghost(mob/observer/ghost/user)
. = ..()
if(enabled)
nano_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")
var/response = tgui_alert(user, "This computer is turned off. Would you like to turn it on?", "Admin Override", list("Yes", "No"))
if(response == "Yes")
turn_on(user)
/obj/item/modular_computer/attack_ai(var/mob/user)
/obj/item/modular_computer/attack_ai(mob/user)
return attack_self(user)
/obj/item/modular_computer/attack_hand(var/mob/user)
/obj/item/modular_computer/attack_hand(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)
/// 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 && screen_on)
nano_ui_interact(user)
else if(!enabled && screen_on)
turn_on(user)
/obj/item/modular_computer/attackby(var/obj/item/W as obj, var/mob/user as mob)
/obj/item/modular_computer/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/card/id)) // ID Card, try to insert it.
var/obj/item/card/id/I = W
if(!card_slot)
@@ -181,7 +181,7 @@
for(var/obj/item/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
var/choice = tgui_input_list(user, "Which component do you want to uninstall?", "Computer maintenance", component_names)
if(!choice)
return
@@ -1,14 +1,14 @@
/obj/item/modular_computer/proc/power_failure(var/malfunction = 0)
/obj/item/modular_computer/proc/power_failure(malfunction = FALSE)
if(enabled) // Shut down the computer
visible_message("<span class='danger'>\The [src]'s screen flickers briefly and then goes dark.</span>")
visible_message(SPAN_DANGER("\The [src]'s screen flickers briefly and then goes dark."))
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)
/// 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(power_usage = 0)
apc_powered = FALSE
if(!battery_module || !battery_module.check_functionality() || battery_module.battery.charge <= 0)
return FALSE
@@ -16,8 +16,8 @@
return TRUE
return FALSE
// Tries to use power from APC, if present.
/obj/item/modular_computer/proc/apc_power(var/power_usage = 0)
/// Tries to use power from APC, if present.
/obj/item/modular_computer/proc/apc_power(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.
@@ -35,7 +35,7 @@
A.use_power_oneoff(power_usage, EQUIP)
return TRUE
// Handles power-related things, such as battery interaction, recharging, shutdown when it's discharged
/// 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/computer_hardware/H in get_all_components())
@@ -1,5 +1,5 @@
// Operates NanoUI
/obj/item/modular_computer/nano_ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
/obj/item/modular_computer/nano_ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
if(!screen_on || !enabled)
if(ui)
ui.close()
@@ -4,50 +4,83 @@
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
/// Whether the computer is turned on.
var/enabled = FALSE
/// Whether the computer is active/opened/it's screen is on.
var/screen_on = TRUE
/// A currently active program running on the computer.
var/datum/computer_file/program/active_program = null
/// A flag that describes this device type.
var/hardware_flag = 0
/// Last tick power usage of this computer.
var/last_power_usage = 0
/// Used for deciding if battery percentage has chandged.
var/last_battery_percent = 0
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
/// Whether the computer is emagged.
var/computer_emagged = FALSE
/// Set automatically. Whether the computer used APC power last tick.
var/apc_powered = FALSE
/// Power usage when the computer is open (screen is active) and can be interacted with. Remember hardware can use power too.
var/base_active_power_usage = 50
/// Power usage when the computer is idle and screen is off. (currently only applies to laptops)
var/base_idle_power_usage = 5
/// Error screen displayed.
var/bsod = FALSE
// 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.
/// This thing isn't meant to be used on it's own. Subtypes should supply their own icon.
icon = null
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.
/// No pixelshifting by placing on tables, etc.
//center_of_mass = null
/// And no random pixelshifting on-creation either.
//randpixel = 0
/// Icon state when the computer is turned off.
var/icon_state_unpowered = null
/// Icon state overlay when the computer is turned on, but no program is loaded that would override the screen.
var/icon_state_menu = "menu"
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.
/// Maximal hardware size. Currently, tablets have 1, laptops 2 and consoles 3. Limits what hardware types can be installed.
var/max_hardware_size = 0
/// Amount of steel sheets refunded when disassembling an empty frame of this computer.
var/steel_sheet_cost = 5
/// Intensity of light this computer emits. Comparable to numbers light fixtures use.
var/light_strength = 0
/// Idle programs on background. They still receive process calls but can't be interacted with.
var/list/idle_threads = list()
// 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.
//! Damage of the chassis. If the chassis takes too much damage it will break apart.
/// Current damage level.
var/damage = 0
/// Damage level at which the computer ceases to operate.
var/broken_damage = 50
/// Damage level at which the computer breaks apart.
var/max_damage = 100
// Important hardware (must be installed for computer to work)
var/obj/item/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/computer_hardware/network_card/network_card // Network Card component of this computer. Allows connection to NTNet
var/obj/item/computer_hardware/hard_drive/hard_drive // Hard Drive component of this computer. Stores programs and files.
//! Important hardware (must be installed for computer to work)
/// CPU. Without it the computer won't run. Better CPUs can run more programs at once.
var/obj/item/computer_hardware/processor_unit/processor_unit
/// Network Card component of this computer. Allows connection to NTNet.
var/obj/item/computer_hardware/network_card/network_card
/// Hard Drive component of this computer. Stores programs and files.
var/obj/item/computer_hardware/hard_drive/hard_drive
// Optional hardware (improves functionality, but is not critical for computer to work in most cases)
var/obj/item/computer_hardware/battery_module/battery_module // An internal power source for this computer. Can be recharged.
var/obj/item/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/computer_hardware/nano_printer/nano_printer // Nano Printer component of this computer, for your everyday paperwork needs.
var/obj/item/computer_hardware/hard_drive/portable/portable_drive // Portable data storage
var/obj/item/computer_hardware/ai_slot/ai_slot // AI slot, an intellicard housing that allows modifications of AIs.
var/obj/item/computer_hardware/tesla_link/tesla_link // Tesla Link, Allows remote charging from nearest APC.
//! Optional hardware (improves functionality, but is not critical for computer to work in most cases)
/// An internal power source for this computer. Can be recharged.
var/obj/item/computer_hardware/battery_module/battery_module
/// ID Card slot component of this computer. Mostly for HoP modification console that needs ID slot for modification.
var/obj/item/computer_hardware/card_slot/card_slot
/// Nano Printer component of this computer, for your everyday paperwork needs.
var/obj/item/computer_hardware/nano_printer/nano_printer
/// Portable data storage.
var/obj/item/computer_hardware/hard_drive/portable/portable_drive
/// AI slot, an intellicard housing that allows modifications of AIs.
var/obj/item/computer_hardware/ai_slot/ai_slot
/// Tesla Link, Allows remote charging from nearest APC.
var/obj/item/computer_hardware/tesla_link/tesla_link
@@ -1,14 +1,14 @@
/obj/item/modular_computer/console
name = "console"
desc = "A stationary computer."
icon = 'icons/obj/modular_console_vr.dmi' //VOREStation Edit
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
density = TRUE
base_idle_power_usage = 100
base_active_power_usage = 500
max_hardware_size = 3
@@ -16,3 +16,21 @@
light_strength = 4
max_damage = 300
broken_damage = 150
/obj/item/modular_computer/console/update_icon()
. = ..()
// Connecty //TODO: Use TG Smoothing.
if(initial(icon_state) == "console")
var/append_string = ""
var/left = turn(dir, -90)
var/right = turn(dir, 90)
var/turf/L = get_step(src, left)
var/turf/R = get_step(src, right)
var/obj/item/modular_computer/console/LC = locate() in L
var/obj/item/modular_computer/console/RC = locate() in R
if(LC && LC.dir == dir && initial(LC.icon_state) == "console")
append_string += "_L"
if(RC && RC.dir == dir && initial(RC.icon_state) == "console")
append_string += "_R"
icon_state = "console[append_string]"
@@ -8,7 +8,7 @@
hardware_flag = PROGRAM_TABLET
max_hardware_size = 1
w_class = ITEMSIZE_SMALL
light_strength = 2 // Same as PDAs
light_strength = 2 // Same as PDAs
/obj/item/modular_computer/tablet/lease
desc = "A small portable microcomputer. This one has a gold and blue stripe, and a serial number stamped into the case."
@@ -1,13 +1,20 @@
var/global/file_uid = 0
/datum/computer_file/
var/filename = "NewFile" // Placeholder. No spacebars
var/filetype = "XXX" // File full names are [filename].[filetype] so like NewFile.XXX in this case
var/size = 1 // File size in GQ. Integers only!
var/obj/item/computer_hardware/hard_drive/holder // Holder that contains this file.
var/unsendable = 0 // Whether the file may be sent to someone via NTNet transfer or other means.
var/undeletable = 0 // Whether the file may be deleted. Setting to 1 prevents deletion/renaming/etc.
var/uid // UID of this file
/datum/computer_file
/// Placeholder. No spacebars
var/filename = "NewFile"
/// File full names are [filename].[filetype] so like NewFile.XXX in this case.
var/filetype = "XXX"
/// File size in GQ. Integers only!
var/size = 1
/// Holder that contains this file.
var/obj/item/computer_hardware/hard_drive/holder
/// Whether the file may be sent to someone via NTNet transfer or other means.
var/unsendable = FALSE
/// Whether the file may be deleted. Setting to 1 prevents deletion/renaming/etc.
var/undeletable = FALSE
/// UID of this file.
var/uid
/datum/computer_file/New()
..()
@@ -25,7 +32,7 @@ var/global/file_uid = 0
holder = null
..()
// Returns independent copy of this file.
/// Returns independent copy of this file.
/datum/computer_file/proc/clone(var/rename = 0)
var/datum/computer_file/temp = new type
temp.unsendable = unsendable
@@ -36,4 +43,4 @@ var/global/file_uid = 0
else
temp.filename = filename
temp.filetype = filetype
return temp
return temp
@@ -1,17 +1,22 @@
// /data/ files store data in string format.
// They don't contain other logic for now.
/**
* /data/ files store data in string format.
* They don't contain other logic for now.
*/
/datum/computer_file/data
var/stored_data = "" // Stored data in string format.
filetype = "DAT"
/// Whether the user will be reminded that the file probably shouldn't be edited.
var/do_not_edit = 0
/// Stored data in string format.
var/stored_data = ""
/// The file size of this bit of data.
var/block_size = 250
var/do_not_edit = 0 // Whether the user will be reminded that the file probably shouldn't be edited.
/datum/computer_file/data/clone()
var/datum/computer_file/data/temp = ..()
temp.stored_data = stored_data
return temp
// Calculates file size from amount of characters in saved string
/// Calculates file size from amount of characters in saved string
/datum/computer_file/data/proc/calculate_size()
size = max(1, round(length(stored_data) / block_size))
@@ -1,13 +1,20 @@
// /data/ files store data in string format.
// They don't contain other logic for now.
/**
* /data/ files store data in string format.
* They don't contain other logic for now.
*/
/datum/computer_file/data/news_article
filetype = "XNML"
filename = "Unknown News Entry"
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.
/// Results in smaller files.
block_size = 5000
/// Editing the file breaks most formatting due to some HTML tags not being accepted as input from average user.
do_not_edit = 1
/// 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/server_file_path
/// Set to 1 for older stuff.
var/archived
/// Filename of cover.
var/cover
/datum/computer_file/data/news_article/New(var/load_from_file = 0)
..()
@@ -16,7 +23,7 @@
calculate_size()
// NEWS DEFINITIONS BELOW THIS LINE
//! ## NEWS DEFINITIONS BELOW THIS LINE
/* KEPT HERE AS AN EXAMPLE
/datum/computer_file/data/news_article/space/vol_one
filename = "SPACE Magazine vol. 1"
@@ -1,36 +1,64 @@
// /program/ files are executable programs that do things.
/datum/computer_file/program
filetype = "PRG"
filename = "UnknownProgram" // File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NTNET!
var/required_access = null // List of required accesses to run/download the program.
var/requires_access_to_run = 1 // Whether the program checks for required_access when run.
var/requires_access_to_download = 1 // Whether the program checks for required_access when downloading.
//nanoui
var/datum/nano_module/NM = null // If the program uses NanoModule, put it here and it will be automagically opened. Otherwise implement nano_ui_interact.
var/nanomodule_path = null // Path to nanomodule, make sure to set this if implementing new program.
// t gui
var/datum/tgui_module/TM = null // If the program uses TGUIModule, put it here and it will be automagically opened. Otherwise implement ui_interact.
var/tguimodule_path = null // Path to tguimodule, make sure to set this if implementing new program.
// misc program stuff
var/program_state = PROGRAM_STATE_KILLED// PROGRAM_STATE_KILLED or PROGRAM_STATE_BACKGROUND or PROGRAM_STATE_ACTIVE - specifies whether this program is running.
var/obj/item/modular_computer/computer // Device that runs this program.
var/filedesc = "Unknown Program" // User-friendly name of this program.
var/extended_desc = "N/A" // Short description of this program's function.
var/program_icon_state = null // Program-specific screen icon state
var/program_key_state = "standby_key" // Program-specific keyboard icon state
var/program_menu_icon = "newwin" // Icon to use for program's link in main menu
var/requires_ntnet = 0 // Set to 1 for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes.
var/requires_ntnet_feature = 0 // Optional, if above is set to 1 checks for specific function of NTNet (currently NTNET_SOFTWAREDOWNLOAD, NTNET_PEERTOPEER, NTNET_SYSTEMCONTROL and NTNET_COMMUNICATION)
var/ntnet_status = 1 // NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc.
var/usage_flags = PROGRAM_ALL // Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_TABLET combination) or PROGRAM_ALL
var/network_destination = null // Optional string that describes what NTNet server/system this program connects to. Used in default logging.
var/available_on_ntnet = 1 // Whether the program can be downloaded from NTNet. Set to 0 to disable.
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
//! File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NTNET!
filename = "UnknownProgram"
/// List of required accesses to run/download the program.
var/required_access = null
/// Whether the program checks for required_access when run.
var/requires_access_to_run = TRUE
/// Whether the program checks for required_access when downloading.
var/requires_access_to_download = TRUE
/datum/computer_file/program/New(var/obj/item/modular_computer/comp = null)
//! ## Nanoui
/// If the program uses NanoModule, put it here and it will be automagically opened. Otherwise implement nano_ui_interact.
var/datum/nano_module/NM = null
/// Path to nanomodule, make sure to set this if implementing new program.
var/nanomodule_path = null
//! ## TGUI
/// If the program uses TGUIModule, put it here and it will be automagically opened. Otherwise implement ui_interact.
var/datum/tgui_module/TM = null
/// Path to tguimodule, make sure to set this if implementing new program.
var/tguimodule_path = null
//! ## Misc Program Stuff
/// PROGRAM_STATE_KILLED or PROGRAM_STATE_BACKGROUND or PROGRAM_STATE_ACTIVE - specifies whether this program is running.
var/program_state = PROGRAM_STATE_KILLED
/// Device that runs this program.
var/obj/item/modular_computer/computer
/// User-friendly name of this program.
var/filedesc = "Unknown Program"
/// Short description of this program's function.
var/extended_desc = "N/A"
/// Program-specific screen icon state.
var/program_icon_state = null
/// Program-specific keyboard icon state.
var/program_key_state = "standby_key"
/// Icon to use for program's link in main menu.
var/program_menu_icon = "newwin"
/// Set to TRUE for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes.
var/requires_ntnet = FALSE
/// Optional, if above is set to TRUE checks for specific function of NTNet (currently NTNET_SOFTWAREDOWNLOAD, NTNET_PEERTOPEER, NTNET_SYSTEMCONTROL and NTNET_COMMUNICATION)
var/requires_ntnet_feature = FALSE
/// NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc.
var/ntnet_status = 1
/// Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_TABLET combination) or PROGRAM_ALL
var/usage_flags = PROGRAM_ALL
/// Optional string that describes what NTNet server/system this program connects to. Used in default logging.
var/network_destination = null
/// Whether the program can be downloaded from NTNet. Set to FALSE to disable.
var/available_on_ntnet = TRUE
/// Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to TRUE to enable.
var/available_on_syndinet = FALSE
/// Set to TRUE if computer that's running us was emagged. Computer updates this every Process() tick
var/computer_emagged = FALSE
/// 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/ui_header = null
/// GQ/s - current network connectivity transfer rate.
var/ntnet_speed = 0
/datum/computer_file/program/New(obj/item/modular_computer/comp = null)
..()
if(comp && istype(comp))
computer = comp
@@ -53,33 +81,33 @@
temp.usage_flags = usage_flags
return temp
// Relays icon update to the computer.
/// Relays icon update to the computer.
/datum/computer_file/program/proc/update_computer_icon()
if(computer)
computer.update_icon()
// Attempts to create a log in global ntnet datum. Returns 1 on success, 0 on fail.
/datum/computer_file/program/proc/generate_network_log(var/text)
/// Attempts to create a log in global ntnet datum. Returns TRUE on success, FALSE on fail.
/datum/computer_file/program/proc/generate_network_log(text)
if(computer)
return computer.add_log(text)
return 0
return FALSE
/datum/computer_file/program/proc/is_supported_by_hardware(var/hardware_flag = 0, var/loud = 0, var/mob/user = null)
/datum/computer_file/program/proc/is_supported_by_hardware(hardware_flag = 0, loud = FALSE, mob/user = null)
if(!(hardware_flag & usage_flags))
if(loud && computer && user)
to_chat(user, "<span class='warning'>\The [computer] flashes: \"Hardware Error - Incompatible software\".</span>")
return 0
return 1
to_chat(user, SPAN_WARNING("\The [computer] flashes: \"Hardware Error - Incompatible software\"."))
return FALSE
return TRUE
/datum/computer_file/program/proc/get_signal(var/specific_action = 0)
/datum/computer_file/program/proc/get_signal(specific_action = 0)
if(computer)
return computer.get_ntnet_status(specific_action)
return 0
return FALSE
// Called by Process() on device that runs us, once every tick.
/// Called by Process() on device that runs us, once every tick.
/datum/computer_file/program/proc/process_tick()
update_netspeed()
return 1
return TRUE
/datum/computer_file/program/proc/update_netspeed()
ntnet_speed = 0
@@ -91,44 +119,50 @@
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
/datum/computer_file/program/proc/can_run(var/mob/living/user, var/loud = 0, var/access_to_check)
/**
* 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
*/
/datum/computer_file/program/proc/can_run(mob/living/user, loud = FALSE, access_to_check)
// Defaults to required_access
if(!access_to_check)
access_to_check = required_access
if(!access_to_check) // No required_access, allow it.
return 1
return TRUE
// 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
return TRUE
if(!istype(user))
return 0
return FALSE
var/obj/item/card/id/I = user.GetIdCard()
if(!I)
if(loud)
to_chat(user, "<span class='notice'>\The [computer] flashes an \"RFID Error - Unable to scan ID\" warning.</span>")
return 0
to_chat(user, SPAN_NOTICE("\The [computer] flashes an \"RFID Error - Unable to scan ID\" warning."))
return FALSE
if(access_to_check in I.access)
return 1
return TRUE
else if(loud)
to_chat(user, "<span class='notice'>\The [computer] flashes an \"Access Denied\" warning.</span>")
to_chat(user, SPAN_NOTICE("\The [computer] flashes an \"Access Denied\" warning."))
// 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.
/**
* 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.
*/
/datum/computer_file/program/proc/get_header_data()
if(computer)
return computer.get_header_data()
return list()
// This is performed on program startup. May be overriden to add extra logic. Remember to include ..() call. Return 1 on success, 0 on failure.
// When implementing new program based device, use this to run the program.
/datum/computer_file/program/proc/run_program(var/mob/living/user)
/**
* This is performed on program startup. May be overriden to add extra logic. Remember to include ..() call. Return 1 on success, 0 on failure.
* When implementing new program based device, use this to run the program.
*/
/datum/computer_file/program/proc/run_program(mob/living/user)
if(can_run(user, 1) || !requires_access_to_run)
computer.active_program = src
if(nanomodule_path)
@@ -141,11 +175,11 @@
if(requires_ntnet && network_destination)
generate_network_log("Connection opened to [network_destination].")
program_state = PROGRAM_STATE_ACTIVE
return 1
return 0
return TRUE
return FALSE
// Use this proc to kill the program. Designed to be implemented by each program if it requires on-quit logic, such as the NTNRC client.
/datum/computer_file/program/proc/kill_program(var/forced = 0)
/// Use this proc to kill the program. Designed to be implemented by each program if it requires on-quit logic, such as the NTNRC client.
/datum/computer_file/program/proc/kill_program(forced = FALSE)
program_state = PROGRAM_STATE_KILLED
if(network_destination)
generate_network_log("Connection to [network_destination] closed.")
@@ -154,37 +188,42 @@
SStgui.close_uis(TM)
qdel(TM)
TM = null
return 1
return TRUE
// This is called every tick when the program is enabled. Ensure you do parent call if you override it. If parent returns 1 continue with UI initialisation.
// It returns 0 if it can't run or if NanoModule was used instead. I suggest using NanoModules where applicable.
/datum/computer_file/program/nano_ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
/**
* This is called every tick when the program is enabled. Ensure you do parent call if you override it. If parent returns TRUE continue with UI initialisation.
* It returns FALSE if it can't run or if NanoModule was used instead. I suggest using NanoModules where applicable.
*/
/datum/computer_file/program/nano_ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, force_open = TRUE)
if(program_state != PROGRAM_STATE_ACTIVE) // Our program was closed. Close the ui if it exists.
if(ui)
ui.close()
return computer.nano_ui_interact(user)
if(istype(NM))
NM.nano_ui_interact(user, ui_key, null, force_open)
return 0
return FALSE
if(istype(TM))
TM.ui_interact(user)
return 0
return 1
return FALSE
return TRUE
// CONVENTIONS, READ THIS WHEN CREATING NEW PROGRAM AND OVERRIDING THIS PROC:
// Topic calls are automagically forwarded from NanoModule this program contains.
// Calls beginning with "PRG_" are reserved for programs handling.
// Calls beginning with "PC_" are reserved for computer handling (by whatever runs the program)
// ALWAYS INCLUDE PARENT CALL ..() OR DIE IN FIRE.
/**
*! CONVENTIONS, READ THIS WHEN CREATING NEW PROGRAM AND OVERRIDING THIS PROC:
*
* Topic calls are automagically forwarded from NanoModule this program contains.
* Calls beginning with "PRG_" are reserved for programs handling.
* Calls beginning with "PC_" are reserved for computer handling (by whatever runs the program)
*
*! ALWAYS INCLUDE PARENT CALL ..() OR DIE IN FIRE.
*/
/datum/computer_file/program/Topic(href, href_list)
if(..())
return 1
if(computer)
return computer.Topic(href, href_list)
// Relays the call to nano module, if we have one
/datum/computer_file/program/proc/check_eye(var/mob/user)
/// Relays the call to nano module, if we have one
/datum/computer_file/program/proc/check_eye(mob/user)
if(NM)
return NM.check_eye(user)
else
@@ -197,25 +236,28 @@
return TRUE
/datum/nano_module/program
/// Program-Based computer program that runs this nano module. Defaults to null.
var/datum/computer_file/program/program = null
//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)
/datum/nano_module/program/New(host, topic_manager, program)
..()
src.program = program
/datum/topic_manager/program
var/datum/program
/datum/topic_manager/program/New(var/datum/program)
/datum/topic_manager/program/New(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_"
/**
* 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/proc/relaymove(var/mob/M, direction)
/datum/computer_file/program/proc/relaymove(mob/M, direction)
if(NM)
return NM.relaymove(M, direction)
@@ -1,18 +1,20 @@
// Events are sent to the program by the computer.
// Always include a parent call when overriding an event.
/**
* Events are sent to the program by the computer.
* Always include a parent call when overriding an event.
*/
// Called when the ID card is removed from computer. ID is removed AFTER this proc.
/datum/computer_file/program/proc/event_idremoved(var/background)
/// Called when the ID card is removed from computer. ID is removed AFTER this proc.
/datum/computer_file/program/proc/event_idremoved(background)
return
// Called when the computer fails due to power loss. Override when program wants to specifically react to power loss.
/datum/computer_file/program/proc/event_powerfailure(var/background)
/// Called when the computer fails due to power loss. Override when program wants to specifically react to power loss.
/datum/computer_file/program/proc/event_powerfailure(background)
kill_program(1)
// Called when the network connectivity fails. Computer does necessary checks and only calls this when requires_ntnet_feature and similar variables are not met.
/datum/computer_file/program/proc/event_networkfailure(var/background)
/// Called when the network connectivity fails. Computer does necessary checks and only calls this when requires_ntnet_feature and similar variables are not met.
/datum/computer_file/program/proc/event_networkfailure(background)
kill_program(1)
if(background)
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>")
computer.visible_message(SPAN_WARNING("\The [computer]'s screen displays an error: \"Network connectivity lost - process [filename].[filetype] (PID [rand(100,999)]) terminated.\""))
else
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>")
computer.visible_message(SPAN_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.\""))
@@ -3,15 +3,24 @@
desc = "Unknown Hardware."
icon = 'icons/obj/modular_components.dmi'
var/obj/item/modular_computer/holder2 = null
var/power_usage = 0 // If the hardware uses extra power, change this.
var/enabled = 1 // If the hardware is turned off set this to 0.
var/critical = 1 // Prevent disabling for important component, like the HDD.
var/hardware_size = 1 // Limits which devices can contain this component. 1: Tablets/Laptops/Consoles, 2: Laptops/Consoles, 3: Consoles only
var/damage = 0 // Current damage level
var/max_damage = 100 // Maximal damage level.
var/damage_malfunction = 20 // "Malfunction" threshold. When damage exceeds this value the hardware piece will semi-randomly fail and do !!FUN!! things
var/damage_failure = 50 // "Failure" threshold. When damage exceeds this value the hardware piece will not work at all.
var/malfunction_probability = 10// Chance of malfunction when the component is damaged
/// If the hardware uses extra power, change this.
var/power_usage = 0
/// If the hardware is turned off set this to FALSE.
var/enabled = TRUE
/// Prevent disabling for important component, like the HDD.
var/critical = 1
/// Limits which devices can contain this component. 1: Tablets/Laptops/Consoles, 2: Laptops/Consoles, 3: Consoles only.
var/hardware_size = 1
/// Current damage level.
var/damage = 0
/// Maximal damage level.
var/max_damage = 100
/// "Malfunction" threshold. When damage exceeds this value the hardware piece will semi-randomly fail and do !!FUN!! things.
var/damage_malfunction = 20
/// "Failure" threshold. When damage exceeds this value the hardware piece will not work at all.
var/damage_failure = 50
/// Chance of malfunction when the component is damaged.
var/malfunction_probability = 10
/obj/item/computer_hardware/attackby(var/obj/item/W as obj, var/mob/living/user as mob)
// Multitool. Runs diagnostics
@@ -19,30 +28,30 @@
to_chat(user, "***** DIAGNOSTICS REPORT *****")
diagnostics(user)
to_chat(user, "******************************")
return 1
return TRUE
// Nanopaste. Repair all damage if present for a single unit.
var/obj/item/stack/S = W
if(istype(S, /obj/item/stack/nanopaste))
if(!damage)
to_chat(user, "\The [src] doesn't seem to require repairs.")
return 1
return TRUE
if(S.use(1))
to_chat(user, "You apply a bit of \the [W] to \the [src]. It immediately repairs all damage.")
damage = 0
return 1
return TRUE
// Cable coil. Works as repair method, but will probably require multiple applications and more cable.
if(istype(S, /obj/item/stack/cable_coil))
if(!damage)
to_chat(user, "\The [src] doesn't seem to require repairs.")
return 1
return TRUE
if(S.use(1))
to_chat(user, "You patch up \the [src] with a bit of \the [W].")
take_damage(-10)
return 1
return TRUE
return ..()
// Called on multitool click, prints diagnostic information to the user.
/// Called on multitool click, prints diagnostic information to the user.
/obj/item/computer_hardware/proc/diagnostics(var/mob/user)
to_chat(user, "Hardware Integrity Test... (Corruption: [damage]/[max_damage]) [damage > damage_failure ? "FAIL" : damage > damage_malfunction ? "WARN" : "PASS"]")
@@ -56,31 +65,31 @@
holder2 = null
return ..()
// Handles damage checks
/// Handles damage checks.
/obj/item/computer_hardware/proc/check_functionality()
// Turned off
if(!enabled)
return 0
return FALSE
// Too damaged to work at all.
if(damage > damage_failure)
return 0
return FALSE
// Still working. Well, sometimes...
if(damage > damage_malfunction)
if(prob(malfunction_probability))
return 0
return FALSE
// Good to go.
return 1
return TRUE
/obj/item/computer_hardware/examine(mob/user)
. = ..()
if(damage > damage_failure)
. += "<span class='danger'>It seems to be severely damaged!</span>"
. += SPAN_DANGER("It seems to be severely damaged!")
else if(damage > damage_malfunction)
. += "<span class='notice'>It seems to be damaged!</span>"
. += SPAN_NOTICE("It seems to be damaged!")
else if(damage)
. += "It seems to be slightly damaged."
// Damages the component. Contains necessary checks. Negative damage "heals" the component.
/obj/item/computer_hardware/take_damage(var/amount)
damage += round(amount) // We want nice rounded numbers here.
damage = between(0, damage, max_damage) // Clamp the value.
/obj/item/computer_hardware/take_damage(amount)
damage += round(amount) // We want nice rounded numbers here.
damage = between(0, damage, max_damage) // Clamp the value.