mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-20 12:29:23 +01:00
Misc Modular Computer Fixes/Cleanup (#21092)
Prompted by [this](https://github.com/Aurorastation/Aurora.3/issues/21090) (Atmos control app not reliably updating all alarms from SSmachinery.processing). Did what I could but barring a larger refactor of how computer programs are initialized, didn't want to burn Too much time so implemented a Refresh button in the application interface as an in-game fallback option. Also fixes the bug with Loadout-spawned laptops not booting; their hard drives were being initialized with default software due to accidental codeblock removal [here](https://github.com/Aurorastation/Aurora.3/pull/20660/files#diff-40a75a936400e3c347fd8c3d4c804190a63ac9be980912f6a9995efd1b296a1e). Restored the affecting code. Updated several other files I discovered in passing while working on this with proper DMdocs formatting.
This commit is contained in:
@@ -5,45 +5,71 @@
|
||||
desc = DESC_PARENT
|
||||
|
||||
var/lexical_name = "computer"
|
||||
var/enabled = FALSE // Whether the computer is turned on.
|
||||
var/screen_on = TRUE // Whether the computer is active/opened/it's screen is on.
|
||||
var/working = TRUE // Whether the computer is working.
|
||||
var/can_reset = FALSE // Whether you can reset this device with the tech support card.
|
||||
var/datum/computer_file/program/active_program // 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
|
||||
/// Whether the computer is working.
|
||||
var/working = TRUE
|
||||
/// Whether you can reset this device with the tech support card.
|
||||
var/can_reset = FALSE
|
||||
/// A currently active program running on the computer.
|
||||
var/datum/computer_file/program/active_program
|
||||
/// 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/datum/looping_sound/computer/soundloop // Looping sound for when the computer is on
|
||||
var/looping_sound = TRUE // Whether or not this modular computer uses the looping sound. Also handles ambience beeps.
|
||||
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/enrolled = DEVICE_UNSET // Weather the computer is enrolled in the company device management or not. 0 - unconfigured 1 - enrolled (work device) 2 - unenrolled (private device)
|
||||
var/_app_preset_type // Used for specifying the software preset of the console
|
||||
var/ambience_last_played_time // Last time sound was played
|
||||
var/pAI_lock = FALSE // Toggles whether pAI can interact with the modular computer while installed in it
|
||||
var/obj/item/card/id/registered_id = null // ID used for chat client registering
|
||||
var/scan_mode = null // Mode used for health/reagent scanners
|
||||
var/last_scan = 0 // Used for the PDA analyser spam detection
|
||||
/// Looping sound for when the computer is on
|
||||
var/datum/looping_sound/computer/soundloop
|
||||
/// Whether or not this modular computer uses the looping sound. Also handles ambience beeps.
|
||||
var/looping_sound = TRUE
|
||||
/// 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
|
||||
/// Whether the computer is enrolled in the company device management or not. 0 - unconfigured 1 - enrolled (work device) 2 - unenrolled (private device)
|
||||
var/enrolled = DEVICE_UNSET
|
||||
/// Used for specifying the software preset of the console
|
||||
var/_app_preset_type
|
||||
/// Last time sound was played
|
||||
var/ambience_last_played_time
|
||||
/// Toggles whether pAI can interact with the modular computer while installed in it
|
||||
var/pAI_lock = FALSE
|
||||
/// ID used for chat client registering
|
||||
var/obj/item/card/id/registered_id = null
|
||||
/// Mode used for health/reagent scanners
|
||||
var/scan_mode = null
|
||||
/// Used for the PDA analyser spam detection
|
||||
var/last_scan = 0
|
||||
var/silent = FALSE
|
||||
var/doorcode = "smindicate"
|
||||
var/hidden = FALSE
|
||||
var/initial_name
|
||||
var/obj/effect/overmap/visitable/linked // overmap sector the computer is linked to
|
||||
/// overmap sector the computer is linked to
|
||||
var/obj/effect/overmap/visitable/linked
|
||||
|
||||
// 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.
|
||||
/// 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 // And no random pixelshifting on-creation either.
|
||||
/// This isn't meant to be used on it's own. Subtypes should supply their own icon.
|
||||
icon = null
|
||||
/// And no random pixelshifting on-creation either.
|
||||
icon_state = null
|
||||
randpixel = 0
|
||||
center_of_mass = null
|
||||
var/icon_state_unpowered // 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.
|
||||
/// Icon state when the computer is turned off
|
||||
var/icon_state_unpowered
|
||||
/// 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_menu_key = "black_key"
|
||||
var/icon_state_screensaver
|
||||
var/icon_state_screensaver_key
|
||||
@@ -51,34 +77,54 @@
|
||||
var/screensaver_light_range = 0
|
||||
var/screensaver_light_color
|
||||
var/menu_light_color
|
||||
var/message_output_range = 0 // Adds onto the output_message proc's range
|
||||
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.
|
||||
light_range = 0 // Tile range of lighting emitted by the computer.
|
||||
light_power = 0 // Intensity of lighting emitted by the computer. Valid range between 0 and 1.
|
||||
var/list/idle_threads = list() // Idle programs on background. They still receive process calls but can't be interacted with.
|
||||
var/list/enabled_services = list() // Enabled services that run in background and handle things pasively. Supported on all CPUs.
|
||||
/// Adds onto the output_message proc's range
|
||||
var/message_output_range = 0
|
||||
/// 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
|
||||
/// Tile range of lighting emitted by the computer.
|
||||
light_range = 0
|
||||
/// Intensity of lighting emitted by the computer. Valid range between 0 and 1.
|
||||
light_power = 0
|
||||
/// Idle programs on background. They still receive process calls but can't be interacted with.
|
||||
var/list/idle_threads = list()
|
||||
/// Enabled services that run in background and handle things pasively. Supported on all CPUs.
|
||||
var/list/enabled_services = list()
|
||||
var/power_has_failed = FALSE
|
||||
var/is_holographic = FALSE
|
||||
|
||||
// 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.
|
||||
var/obj/item/device/paicard/personal_ai // Personal AI, can control the device via a verb when installed
|
||||
/// 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
|
||||
/// Personal AI, can control the device via a verb when installed
|
||||
var/obj/item/device/paicard/personal_ai
|
||||
var/obj/item/computer_hardware/flashlight/flashlight
|
||||
var/listener/listener
|
||||
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
GLOBAL_VAR_INIT(file_uid, 0)
|
||||
|
||||
/datum/computer_file
|
||||
var/filename = "NewFile" // Placehard_drive. No spacebars
|
||||
var/filetype = "XXX" // File full names are [filename].[filetype] so like NewFile.XXX in this case
|
||||
/// Placehard_drive. No spacebars
|
||||
var/filename = "NewFile"
|
||||
/// File full names are [filename].[filetype] so like NewFile.XXX in this case
|
||||
var/filetype = "XXX"
|
||||
var/filedesc = null
|
||||
var/size = 1 // File size in GQ. Integers only!
|
||||
var/obj/item/computer_hardware/hard_drive/hard_drive // Harddrive that contains this file.
|
||||
var/unsendable = FALSE // Whether the file may be sent to someone via NTNet transfer or other means.
|
||||
var/undeletable = FALSE // Whether the file may be deleted. Setting to 1 prevents deletion/renaming/etc.
|
||||
var/password = "" // Placeholder for password protected files.
|
||||
var/uid // UID of this file
|
||||
/// File size in GQ. Integers only!
|
||||
var/size = 1
|
||||
/// Harddrive that contains this file.
|
||||
var/obj/item/computer_hardware/hard_drive/hard_drive
|
||||
/// 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
|
||||
/// Placeholder for password protected files.
|
||||
var/password = ""
|
||||
/// UID of this file
|
||||
var/uid
|
||||
|
||||
/datum/computer_file/New()
|
||||
..()
|
||||
|
||||
@@ -32,23 +32,30 @@
|
||||
if(monitored_alarm_ids)
|
||||
for(var/obj/machinery/alarm/alarm in SSmachinery.processing)
|
||||
if(alarm.alarm_id && (alarm.alarm_id in monitored_alarm_ids) && AreConnectedZLevels(computer.z, alarm.z))
|
||||
monitored_alarms += alarm
|
||||
monitored_alarms |= alarm
|
||||
else
|
||||
/// The computer of a silicon has null Z, so...
|
||||
var/turf/T = get_turf(computer)
|
||||
for(var/obj/machinery/alarm/alarm in SSmachinery.processing)
|
||||
var/turf/T = get_turf(computer) /// The computer of a silicon has null Z, so...
|
||||
if(AreConnectedZLevels(T.z, alarm.z))
|
||||
monitored_alarms += alarm
|
||||
monitored_alarms |= alarm
|
||||
|
||||
/datum/computer_file/program/atmos_control/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(action == "alarm")
|
||||
var/obj/machinery/alarm/alarm = locate(params["alarm"]) in (monitored_alarms.len ? monitored_alarms : SSmachinery.processing)
|
||||
if(alarm)
|
||||
var/datum/ui_state/TS = generate_state(alarm)
|
||||
alarm.ui_interact(usr, state = TS) //what the fuck?
|
||||
return TRUE
|
||||
switch(action)
|
||||
// Opens the interface for the given air alarm.
|
||||
if("alarm")
|
||||
var/obj/machinery/alarm/alarm = locate(params["alarm"]) in (monitored_alarms.len ? monitored_alarms : SSmachinery.processing)
|
||||
if(alarm)
|
||||
var/datum/ui_state/TS = generate_state(alarm)
|
||||
alarm.ui_interact(usr, state = TS) //what the fuck?
|
||||
return TRUE
|
||||
// Manually clear and repopulate the alarm list.
|
||||
if("refresh")
|
||||
monitored_alarms = list()
|
||||
get_alarms()
|
||||
|
||||
/datum/computer_file/program/atmos_control/ui_data(mob/user)
|
||||
var/list/data = initial_data()
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
icon_state = "hdd_cluster"
|
||||
hardware_size = 3
|
||||
|
||||
// For tablets, etc. - highly power efficient.
|
||||
/// For tablets, etc. - highly power efficient.
|
||||
/obj/item/computer_hardware/hard_drive/small
|
||||
name = "small hard drive"
|
||||
desc = "A small highly efficient solid state drive for portable devices."
|
||||
@@ -56,13 +56,19 @@
|
||||
icon_state = "hdd_micro"
|
||||
hardware_size = 1
|
||||
|
||||
|
||||
/**
|
||||
* Returns number of stored files and storage usage/capacity.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/diagnostics(var/mob/user)
|
||||
..()
|
||||
// 999 is a byond limit that is in place. It's unlikely someone will reach that many files anyway, since you would sooner run out of space.
|
||||
/// 999 is a byond limit that is in place. It's unlikely someone will reach that many files anyway, since you would sooner run out of space.
|
||||
to_chat(user, SPAN_NOTICE("NT-NFS File Table Status: [stored_files.len]/999"))
|
||||
to_chat(user, SPAN_NOTICE("Storage capacity: [used_capacity]/[max_capacity]GQ"))
|
||||
|
||||
// Use this proc to add file to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
/**
|
||||
* Use this proc to add file to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/store_file(var/datum/computer_file/F)
|
||||
if(!F || !istype(F))
|
||||
return FALSE
|
||||
@@ -82,14 +88,18 @@
|
||||
recalculate_size()
|
||||
return TRUE
|
||||
|
||||
// Use this proc to add file to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
/**
|
||||
* Use this proc to add all basic functionality software to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/install_default_programs()
|
||||
if(parent_computer)
|
||||
store_file(new /datum/computer_file/program/computerconfig(parent_computer)) // Computer configuration utility, allows hardware control and displays more info than status bar
|
||||
store_file(new /datum/computer_file/program/clientmanager(parent_computer)) // Client Manager to Enroll the Device
|
||||
store_file(new /datum/computer_file/program/pai_access_lock(parent_computer)) // pAI access control, to stop pesky pAI from messing with computers
|
||||
|
||||
// Use this proc to remove file from the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
/**
|
||||
* Use this proc to remove files to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/remove_file(var/datum/computer_file/F)
|
||||
if(!F || !istype(F))
|
||||
return FALSE
|
||||
@@ -104,14 +114,18 @@
|
||||
else
|
||||
return FALSE
|
||||
|
||||
// Loops through all stored files and recalculates used_capacity of this drive
|
||||
/**
|
||||
* Loops through all stored files and recalculates used_capacity of this drive
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/recalculate_size()
|
||||
var/total_size = 0
|
||||
for(var/datum/computer_file/F in stored_files)
|
||||
total_size += F.size
|
||||
used_capacity = total_size
|
||||
|
||||
// Checks whether file can be stored on the hard drive.
|
||||
/**
|
||||
* Checks whether file can be stored on the hard drive.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/can_store_file(var/size = TRUE)
|
||||
// In the unlikely event someone manages to create that many files.
|
||||
// BYOND is acting weird with numbers above 999 in loops (infinite loop prevention)
|
||||
@@ -124,7 +138,9 @@
|
||||
else
|
||||
return TRUE
|
||||
|
||||
// Checks whether we can store the file. We can only store unique files, so this checks whether we wouldn't get a duplicity by adding a file.
|
||||
/**
|
||||
* Checks whether we can store the file. We can only store unique files, so this checks whether we wouldn't get a duplicity by adding a file.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/try_store_file(var/datum/computer_file/F)
|
||||
if(!F || !istype(F))
|
||||
return FALSE
|
||||
@@ -134,7 +150,9 @@
|
||||
return FALSE
|
||||
return can_store_file(F.size)
|
||||
|
||||
// Tries to find the file by filename. Returns null on failure
|
||||
/**
|
||||
* Tries to find the file by filename. Returns null on failure.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/find_file_by_name(var/filename)
|
||||
if(!check_functionality())
|
||||
return null
|
||||
@@ -159,6 +177,10 @@
|
||||
QDEL_LIST(stored_files)
|
||||
return ..()
|
||||
|
||||
/obj/item/computer_hardware/hard_drive/Initialize(mapload)
|
||||
. = ..()
|
||||
install_default_programs()
|
||||
|
||||
/obj/item/computer_hardware/hard_drive/proc/reset_drive()
|
||||
for(var/datum/computer_file/F in stored_files)
|
||||
remove_file(F)
|
||||
|
||||
@@ -3,37 +3,53 @@
|
||||
desc = "Unknown Hardware."
|
||||
icon = 'icons/obj/modular_components.dmi'
|
||||
var/obj/item/modular_computer/parent_computer
|
||||
var/power_usage = 0 // If the hardware uses extra power, change this.
|
||||
var/enabled = TRUE // If the hardware is turned off set this to 0.
|
||||
var/critical = TRUE // 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
|
||||
|
||||
// Default handling of hardware enable/disable. Override for specific functionality.
|
||||
/// If the hardware uses extra power, change this.
|
||||
var/power_usage = 0
|
||||
/// If the hardware is turned off set this to 0.
|
||||
var/enabled = TRUE
|
||||
/// Prevent disabling for important component, like the HDD.
|
||||
var/critical = TRUE
|
||||
/// 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
|
||||
|
||||
/**
|
||||
* Default handling of hardware enable/disable. Override for specific functionality.
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/enable()
|
||||
. = enabled = TRUE
|
||||
|
||||
/**
|
||||
* Default handling of hardware enable/disable. Override for specific functionality.
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/disable()
|
||||
. = enabled = FALSE
|
||||
|
||||
/**
|
||||
* Default handling of hardware enable/disable. Override for specific functionality.
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/toggle()
|
||||
if(enabled)
|
||||
return disable()
|
||||
return enable()
|
||||
|
||||
/obj/item/computer_hardware/attackby(obj/item/attacking_item, mob/user)
|
||||
// Multitool. Runs diagnostics
|
||||
/// Multitool. Runs diagnostics
|
||||
if(attacking_item.ismultitool())
|
||||
to_chat(user, SPAN_NOTICE("***** DIAGNOSTICS REPORT *****"))
|
||||
diagnostics(user)
|
||||
to_chat(user, SPAN_NOTICE("******************************"))
|
||||
return 1
|
||||
// Nanopaste. Repair all damage if present for a single unit.
|
||||
/// Nanopaste. Repair all damage if present for a single unit.
|
||||
var/obj/item/stack/S = attacking_item
|
||||
if(istype(S, /obj/item/stack/nanopaste))
|
||||
if(!damage)
|
||||
@@ -43,7 +59,7 @@
|
||||
to_chat(user, SPAN_NOTICE("You apply a bit of \the [attacking_item] to \the [src], repairing it fully."))
|
||||
damage = 0
|
||||
return TRUE
|
||||
// Cable coil. Works as repair method, but will probably require multiple applications and more cable.
|
||||
/// Cable coil. Works as repair method, but will probably require multiple applications and more cable.
|
||||
if(S.iscoil())
|
||||
if(!damage)
|
||||
to_chat(user, SPAN_WARNING("\The [src] doesn't seem to require repairs."))
|
||||
@@ -54,7 +70,9 @@
|
||||
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, SPAN_NOTICE("Hardware Integrity Test... (Physical Damage: [damage]/[max_damage]) [damage > damage_failure ? "FAIL" : damage > damage_malfunction ? "WARN" : "PASS"]"))
|
||||
|
||||
@@ -69,19 +87,21 @@
|
||||
parent_computer = null
|
||||
return ..()
|
||||
|
||||
// Handles damage checks
|
||||
/**
|
||||
* Handles damage checks
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/check_functionality()
|
||||
// Turned off
|
||||
/// Turned off
|
||||
if(!enabled)
|
||||
return FALSE
|
||||
// Too damaged to work at all.
|
||||
/// Too damaged to work at all.
|
||||
if(damage > damage_failure)
|
||||
return FALSE
|
||||
// Still working. Well, sometimes...
|
||||
/// Still working. Well, sometimes...
|
||||
if(damage > damage_malfunction)
|
||||
if(prob(malfunction_probability))
|
||||
return FALSE
|
||||
// Good to go.
|
||||
/// Good to go.
|
||||
return TRUE
|
||||
|
||||
/obj/item/computer_hardware/get_examine_text(mob/user, distance, is_adjacent, infix, suffix)
|
||||
@@ -93,7 +113,9 @@
|
||||
else if(damage)
|
||||
. += SPAN_WARNING("It seems to be slightly damaged.")
|
||||
|
||||
// Damages the component. Contains necessary checks. Negative damage "heals" the component.
|
||||
/**
|
||||
* Damages the component. Contains necessary checks. Negative damage "heals" the component.
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/take_damage(var/amount)
|
||||
damage += round(amount) // We want nice rounded numbers here.
|
||||
damage = between(0, damage, max_damage) // Clamp the value.
|
||||
damage += round(amount) /// We want nice rounded numbers here.
|
||||
damage = between(0, damage, max_damage) /// Clamp the value.
|
||||
|
||||
Reference in New Issue
Block a user