Ported some modular computer stuff from baystation

This commit is contained in:
ItsSelis
2022-06-30 20:46:25 +02:00
parent 7da0085b4c
commit 7d2bfaa7f8
41 changed files with 458 additions and 103 deletions
@@ -3,33 +3,46 @@
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
/obj/item/weapon/computer_hardware/attackby(var/obj/item/W as obj, var/mob/living/user as mob)
/// 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: All, 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
var/usage_flags = PROGRAM_ALL
/// Whether attackby will be passed on it even with a closed panel
var/external_slot
/obj/item/weapon/computer_hardware/attackby(obj/item/W as obj, mob/living/user as mob)
// Multitool. Runs diagnostics
if(istype(W, /obj/item/device/multitool))
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)
@@ -38,11 +51,11 @@
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.
/// Returns a list of lines containing diagnostic information for display.
/obj/item/weapon/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"]")
@@ -57,20 +70,20 @@
holder2 = null
return ..()
// Handles damage checks
/// Handles damage checks
/obj/item/weapon/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/weapon/computer_hardware/examine(var/mob/user)
. = ..()
@@ -81,8 +94,7 @@
else if(damage)
. += "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/weapon/computer_hardware/take_damage(var/amount)
damage += round(amount) // We want nice rounded numbers here.
damage = between(0, damage, max_damage) // Clamp the value.
@@ -5,9 +5,13 @@
icon_state = "hdd_normal"
hardware_size = 1
origin_tech = list(TECH_DATA = 1, TECH_ENGINEERING = 1)
var/max_capacity = 128
var/used_capacity = 0
var/list/stored_files = list() // List of stored files on this drive. DO NOT MODIFY DIRECTLY!
/// List of stored files on this drive. DO NOT MODIFY DIRECTLY!
var/list/stored_files = list()
/// Whether drive is protected against changes
var/read_only = FALSE
/obj/item/weapon/computer_hardware/hard_drive/advanced
name = "advanced hard drive"
@@ -60,6 +64,7 @@
// 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, "NT-NFS File Table Status: [stored_files.len]/999")
to_chat(user, "Storage capacity: [used_capacity]/[max_capacity]GQ")
to_chat(user, "Read-only mode: [(read_only ? "ON" : "OFF")]")
// Use this proc to add file to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
/obj/item/weapon/computer_hardware/hard_drive/proc/store_file(var/datum/computer_file/F)
@@ -164,4 +169,4 @@
/obj/item/weapon/computer_hardware/hard_drive/New()
install_default_programs()
..()
..()
@@ -8,12 +8,20 @@ var/global/ntnet_card_uid = 1
critical = 0
icon_state = "netcard_basic"
hardware_size = 1
var/identification_id = null // Identification ID. Technically MAC address of this device. Can't be changed by user.
var/identification_string = "" // Identification string, technically nickname seen in the network. Can be set by user.
var/long_range = 0
var/ethernet = 0 // Hard-wired, therefore always on, ignores NTNet wireless checks.
malfunction_probability = 1
/// Identification ID. Technically MAC address of this device. Can't be changed by user.
var/identification_id = null
/// Identification string, technically nickname seen in the network. Can be set by user.
var/identification_string = ""
/// Long-range cards have stronger connections, letting them reach relays from connected Z-levels.
var/long_range = 0
/// Hard-wired, therefore always on, ignores NTNet wireless checks.
var/ethernet = 0
/// If set, uses the value to funnel connections through another network card.
var/proxy_id
/obj/item/weapon/computer_hardware/network_card/diagnostics(var/mob/user)
..()
to_chat(user, "NIX Unique ID: [identification_id]")