[REVIEW] Ports Modular Computers from Baystation

This commit is contained in:
Neerti
2019-04-28 22:06:27 -04:00
committed by VirgoBot
parent 96669c91f0
commit 16b3b58259
242 changed files with 13200 additions and 6636 deletions

View File

@@ -0,0 +1,87 @@
/obj/item/weapon/computer_hardware/
name = "Hardware"
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)
// Multitool. Runs diagnostics
if(istype(W, /obj/item/device/multitool))
to_chat(user, "***** DIAGNOSTICS REPORT *****")
diagnostics(user)
to_chat(user, "******************************")
return 1
// 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
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
// 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
if(S.use(1))
to_chat(user, "You patch up \the [src] with a bit of \the [W].")
take_damage(-10)
return 1
return ..()
// Called on multitool click, prints diagnostic information to the user.
/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"]")
/obj/item/weapon/computer_hardware/New(var/obj/L)
w_class = hardware_size
if(istype(L, /obj/item/modular_computer))
holder2 = L
return
/obj/item/weapon/computer_hardware/Destroy()
holder2 = null
return ..()
// Handles damage checks
/obj/item/weapon/computer_hardware/proc/check_functionality()
// Turned off
if(!enabled)
return 0
// Too damaged to work at all.
if(damage > damage_failure)
return 0
// Still working. Well, sometimes...
if(damage > damage_malfunction)
if(prob(malfunction_probability))
return 0
// Good to go.
return 1
/obj/item/weapon/computer_hardware/examine(var/mob/user)
. = ..()
if(damage > damage_failure)
to_chat(user, "<span class='danger'>It seems to be severely damaged!</span>")
else if(damage > damage_malfunction)
to_chat(user, "<span class='notice'>It seems to be damaged!</span>")
else if(damage)
to_chat(user, "It seems to be slightly damaged.")
// Damages the component. Contains necessary checks. Negative damage "heals" the component.
/obj/item/weapon/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.

View File

@@ -0,0 +1,79 @@
// This device is wrapper for actual power cell. I have decided to not use power cells directly as even low-end cells available on station
// have tremendeous capacity in comparsion. Higher tier cells would provide your device with nearly infinite battery life, which is something i want to avoid.
/obj/item/weapon/computer_hardware/battery_module
name = "standard battery"
desc = "A standard power cell, commonly seen in high-end portable microcomputers or low-end laptops. It's rating is 750."
icon_state = "battery_normal"
critical = 1
malfunction_probability = 1
origin_tech = list(TECH_POWER = 1, TECH_ENGINEERING = 1)
var/battery_rating = 750
var/obj/item/weapon/cell/battery = null
/obj/item/weapon/computer_hardware/battery_module/advanced
name = "advanced battery"
desc = "An advanced power cell, often used in most laptops. It is too large to be fitted into smaller devices. It's rating is 1100."
icon_state = "battery_advanced"
origin_tech = list(TECH_POWER = 2, TECH_ENGINEERING = 2)
hardware_size = 2
battery_rating = 1100
/obj/item/weapon/computer_hardware/battery_module/super
name = "super battery"
desc = "A very advanced power cell, often used in high-end devices, or as uninterruptable power supply for important consoles or servers. It's rating is 1500."
icon_state = "battery_super"
origin_tech = list(TECH_POWER = 3, TECH_ENGINEERING = 3)
hardware_size = 2
battery_rating = 1500
/obj/item/weapon/computer_hardware/battery_module/ultra
name = "ultra battery"
desc = "A very advanced large power cell. It's often used as uninterruptable power supply for critical consoles or servers. It's rating is 2000."
icon_state = "battery_ultra"
origin_tech = list(TECH_POWER = 5, TECH_ENGINEERING = 4)
hardware_size = 3
battery_rating = 2000
/obj/item/weapon/computer_hardware/battery_module/micro
name = "micro battery"
desc = "A small power cell, commonly seen in most portable microcomputers. It's rating is 500."
icon_state = "battery_micro"
origin_tech = list(TECH_POWER = 2, TECH_ENGINEERING = 2)
battery_rating = 500
/obj/item/weapon/computer_hardware/battery_module/nano
name = "nano battery"
desc = "A tiny power cell, commonly seen in low-end portable microcomputers. It's rating is 300."
icon_state = "battery_nano"
origin_tech = list(TECH_POWER = 1, TECH_ENGINEERING = 1)
battery_rating = 300
// This is not intended to be obtainable in-game. Intended for adminbus and debugging purposes.
/obj/item/weapon/computer_hardware/battery_module/lambda
name = "lambda coil"
desc = "A very complex power source compatible with various computers. It is capable of providing power for nearly unlimited duration."
icon_state = "battery_lambda"
hardware_size = 1
battery_rating = 30000
/obj/item/weapon/computer_hardware/battery_module/lambda/New()
..()
battery = new/obj/item/weapon/cell/infinite(src)
/obj/item/weapon/computer_hardware/battery_module/diagnostics(var/mob/user)
..()
to_chat(user, "Internal battery charge: [battery.charge]/[battery.maxcharge] CU")
/obj/item/weapon/computer_hardware/battery_module/New()
battery = new/obj/item/weapon/cell(src)
battery.maxcharge = battery_rating
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

View File

@@ -0,0 +1,18 @@
/obj/item/weapon/computer_hardware/card_slot
name = "RFID card slot"
desc = "Slot that allows this computer to write data on RFID cards. Necessary for some programs to run properly."
power_usage = 10 //W
critical = 0
icon_state = "cardreader"
hardware_size = 1
origin_tech = list(TECH_DATA = 2)
var/obj/item/weapon/card/id/stored_card = null
/obj/item/weapon/computer_hardware/card_slot/Destroy()
if(holder2 && (holder2.card_slot == src))
holder2.card_slot = null
if(stored_card)
stored_card.forceMove(get_turf(holder2))
holder2 = null
return ..()

View File

@@ -0,0 +1,167 @@
/obj/item/weapon/computer_hardware/hard_drive/
name = "basic hard drive"
desc = "A small power efficient solid state drive, with 128GQ of storage capacity for use in basic computers where power efficiency is desired."
power_usage = 25 // SSD or something with low power usage
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!
/obj/item/weapon/computer_hardware/hard_drive/advanced
name = "advanced hard drive"
desc = "A small hybrid hard drive with 256GQ of storage capacity for use in higher grade computers where balance between power efficiency and capacity is desired."
max_capacity = 256
origin_tech = list(TECH_DATA = 2, TECH_ENGINEERING = 2)
power_usage = 50 // Hybrid, medium capacity and medium power storage
icon_state = "hdd_advanced"
hardware_size = 2
/obj/item/weapon/computer_hardware/hard_drive/super
name = "super hard drive"
desc = "A small hard drive with 512GQ of storage capacity for use in cluster storage solutions where capacity is more important than power efficiency."
max_capacity = 512
origin_tech = list(TECH_DATA = 3, TECH_ENGINEERING = 3)
power_usage = 100 // High-capacity but uses lots of power, shortening battery life. Best used with APC link.
icon_state = "hdd_super"
hardware_size = 2
/obj/item/weapon/computer_hardware/hard_drive/cluster
name = "cluster hard drive"
desc = "A large storage cluster consisting of multiple hard drives for usage in high capacity storage systems. Has capacity of 2048 GQ."
power_usage = 500
origin_tech = list(TECH_DATA = 4, TECH_ENGINEERING = 4)
max_capacity = 2048
icon_state = "hdd_cluster"
hardware_size = 3
// For tablets, etc. - highly power efficient.
/obj/item/weapon/computer_hardware/hard_drive/small
name = "small hard drive"
desc = "A small highly efficient solid state drive for portable devices."
power_usage = 10
origin_tech = list(TECH_DATA = 2, TECH_ENGINEERING = 2)
max_capacity = 64
icon_state = "hdd_small"
hardware_size = 1
/obj/item/weapon/computer_hardware/hard_drive/micro
name = "micro hard drive"
desc = "A small micro hard drive for portable devices."
power_usage = 2
origin_tech = list(TECH_DATA = 1, TECH_ENGINEERING = 1)
max_capacity = 32
icon_state = "hdd_micro"
hardware_size = 1
/obj/item/weapon/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.
to_chat(user, "NT-NFS File Table Status: [stored_files.len]/999")
to_chat(user, "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.
/obj/item/weapon/computer_hardware/hard_drive/proc/store_file(var/datum/computer_file/F)
if(!F || !istype(F))
return 0
if(!can_store_file(F.size))
return 0
if(!check_functionality())
return 0
if(!stored_files)
return 0
// This file is already stored. Don't store it again.
if(F in stored_files)
return 0
F.holder = src
stored_files.Add(F)
recalculate_size()
return 1
// 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/install_default_programs()
store_file(new/datum/computer_file/program/computerconfig(src)) // Computer configuration utility, allows hardware control and displays more info than status bar
store_file(new/datum/computer_file/program/ntnetdownload(src)) // NTNet Downloader Utility, allows users to download more software from NTNet repository
store_file(new/datum/computer_file/program/filemanager(src)) // File manager, allows text editor functions and basic file manipulation.
// Use this proc to remove file from the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
/obj/item/weapon/computer_hardware/hard_drive/proc/remove_file(var/datum/computer_file/F)
if(!F || !istype(F))
return 0
if(!stored_files)
return 0
if(!check_functionality())
return 0
if(F in stored_files)
stored_files -= F
recalculate_size()
return 1
else
return 0
// Loops through all stored files and recalculates used_capacity of this drive
/obj/item/weapon/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.
/obj/item/weapon/computer_hardware/hard_drive/proc/can_store_file(var/size = 1)
// In the unlikely event someone manages to create that many files.
// BYOND is acting weird with numbers above 999 in loops (infinite loop prevention)
if(stored_files.len >= 999)
return 0
if(used_capacity + size > max_capacity)
return 0
else
return 1
// 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/weapon/computer_hardware/hard_drive/proc/try_store_file(var/datum/computer_file/F)
if(!F || !istype(F))
return 0
var/name = F.filename + "." + F.filetype
for(var/datum/computer_file/file in stored_files)
if((file.filename + "." + file.filetype) == name)
return 0
return can_store_file(F.size)
// Tries to find the file by filename. Returns null on failure
/obj/item/weapon/computer_hardware/hard_drive/proc/find_file_by_name(var/filename)
if(!check_functionality())
return null
if(!filename)
return null
if(!stored_files)
return null
for(var/datum/computer_file/F in stored_files)
if(F.filename == filename)
return F
return null
/obj/item/weapon/computer_hardware/hard_drive/Destroy()
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()
..()

View File

@@ -0,0 +1,77 @@
/obj/item/weapon/computer_hardware/nano_printer
name = "nano printer"
desc = "Small integrated printer with paper recycling module."
power_usage = 50
origin_tech = list(TECH_DATA = 2, TECH_ENGINEERING = 2)
critical = 0
icon_state = "printer"
hardware_size = 1
var/stored_paper = 5
var/max_paper = 10
/obj/item/weapon/computer_hardware/nano_printer/diagnostics(var/mob/user)
..()
to_chat(user, "Paper buffer level: [stored_paper]/[max_paper]")
/obj/item/weapon/computer_hardware/nano_printer/proc/print_text(var/text_to_print, var/paper_title = null)
if(!stored_paper)
return 0
if(!enabled)
return 0
if(!check_functionality())
return 0
var/obj/item/weapon/paper/P = new/obj/item/weapon/paper(get_turf(holder2))
// Damaged printer causes the resulting paper to be somewhat harder to read.
if(damage > damage_malfunction)
P.info = stars(text_to_print, 100-malfunction_probability)
else
P.info = text_to_print
if(paper_title)
P.name = paper_title
P.update_icon()
stored_paper--
return 1
/obj/item/weapon/computer_hardware/nano_printer/attackby(obj/item/W as obj, mob/user as mob)
if(istype(W, /obj/item/weapon/paper))
if(stored_paper >= max_paper)
to_chat(user, "You try to add \the [W] into \the [src], but its paper bin is full.")
return
to_chat(user, "You insert \the [W] into [src].")
qdel(W)
stored_paper++
else if(istype(W, /obj/item/weapon/paper_bundle))
var/obj/item/weapon/paper_bundle/B = W
var/num_of_pages_added = 0
if(stored_paper >= max_paper)
to_chat(user, "You try to add \the [W] into \the [src], but its paper bin is full.")
return
for(var/obj/item/weapon/bundleitem in B) //loop through items in bundle
if(istype(bundleitem, /obj/item/weapon/paper)) //if item is paper (and not photo), add into the bin
B.pages.Remove(bundleitem)
qdel(bundleitem)
num_of_pages_added++
stored_paper++
if(stored_paper >= max_paper) //check if the printer is full yet
to_chat(user, "The printer has been filled to full capacity.")
break
if(B.pages.len == 0) //if all its papers have been put into the printer, delete bundle
qdel(W)
else if(B.pages.len == 1) //if only one item left, extract item and delete the one-item bundle
user.drop_from_inventory(B)
user.put_in_hands(B[1])
qdel(B)
else //if at least two items remain, just update the bundle icon
B.update_icon()
to_chat(user, "You add [num_of_pages_added] papers from \the [W] into \the [src].")
return
/obj/item/weapon/computer_hardware/nano_printer/Destroy()
if(holder2 && (holder2.nano_printer == src))
holder2.nano_printer = null
holder2 = null
return ..()

View File

@@ -0,0 +1,100 @@
var/global/ntnet_card_uid = 1
/obj/item/weapon/computer_hardware/network_card/
name = "basic NTNet network card"
desc = "A basic network card for usage with standard NTNet frequencies."
power_usage = 50
origin_tech = list(TECH_DATA = 2, TECH_ENGINEERING = 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
/obj/item/weapon/computer_hardware/network_card/diagnostics(var/mob/user)
..()
to_chat(user, "NIX Unique ID: [identification_id]")
to_chat(user, "NIX User Tag: [identification_string]")
to_chat(user, "Supported protocols:")
to_chat(user, "511.m SFS (Subspace) - Standard Frequency Spread")
if(long_range)
to_chat(user, "511.n WFS/HB (Subspace) - Wide Frequency Spread/High Bandiwdth")
if(ethernet)
to_chat(user, "OpenEth (Physical Connection) - Physical network connection port")
/obj/item/weapon/computer_hardware/network_card/New(var/l)
..(l)
identification_id = ntnet_card_uid
ntnet_card_uid++
/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 when far away."
long_range = 1
origin_tech = list(TECH_DATA = 4, TECH_ENGINEERING = 2)
power_usage = 100 // Better range but higher power usage.
icon_state = "netcard_advanced"
hardware_size = 1
/obj/item/weapon/computer_hardware/network_card/wired
name = "wired NTNet network card"
desc = "An advanced network card for usage with standard NTNet frequencies. This one also supports wired connection."
ethernet = 1
origin_tech = list(TECH_DATA = 5, TECH_ENGINEERING = 3)
power_usage = 100 // Better range but higher power usage.
icon_state = "netcard_ethernet"
hardware_size = 3
/obj/item/weapon/computer_hardware/network_card/Destroy()
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()
return "[identification_string] (NID [identification_id])"
/obj/item/weapon/computer_hardware/network_card/proc/is_banned()
return ntnet_global.check_banned(identification_id)
// 0 - No signal, 1 - Low signal, 2 - High signal. 3 - Wired Connection
/obj/item/weapon/computer_hardware/network_card/proc/get_signal(var/specific_action = 0)
if(!holder2) // Hardware is not installed in anything. No signal. How did this even get called?
return 0
if(!enabled)
return 0
if(!check_functionality() || !ntnet_global || is_banned())
return 0
if(ethernet) // Computer is connected via wired connection.
return 3
if(!ntnet_global.check_function(specific_action)) // NTNet is down and we are not connected via wired connection. No signal.
return 0
if(holder2)
var/turf/T = get_turf(holder2)
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(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
..()

View File

@@ -0,0 +1,37 @@
// These are basically USB data sticks and may be used to transfer files between devices
/obj/item/weapon/computer_hardware/hard_drive/portable/
name = "basic data crystal"
desc = "Small crystal with imprinted photonic circuits that can be used to store data. Its capacity is 16 GQ."
power_usage = 10
icon_state = "flashdrive_basic"
hardware_size = 1
max_capacity = 16
origin_tech = list(TECH_DATA = 1)
/obj/item/weapon/computer_hardware/hard_drive/portable/advanced
name = "advanced data crystal"
desc = "Small crystal with imprinted high-density photonic circuits that can be used to store data. Its capacity is 64 GQ."
power_usage = 20
icon_state = "flashdrive_advanced"
hardware_size = 1
max_capacity = 64
origin_tech = list(TECH_DATA = 2)
/obj/item/weapon/computer_hardware/hard_drive/portable/super
name = "super data crystal"
desc = "Small crystal with imprinted ultra-density photonic circuits that can be used to store data. Its capacity is 256 GQ."
power_usage = 40
icon_state = "flashdrive_super"
hardware_size = 1
max_capacity = 256
origin_tech = list(TECH_DATA = 4)
/obj/item/weapon/computer_hardware/hard_drive/portable/New()
..()
stored_files = list()
recalculate_size()
/obj/item/weapon/computer_hardware/hard_drive/portable/Destroy()
if(holder2 && (holder2.portable_drive == src))
holder2.portable_drive = null
return ..()

View File

@@ -0,0 +1,46 @@
// CPU that allows the computer to run programs.
// Better CPUs are obtainable via research and can run more programs on background.
/obj/item/weapon/computer_hardware/processor_unit
name = "standard processor"
desc = "A standard CPU used in most computers. It can run up to three programs simultaneously."
icon_state = "cpu_normal"
hardware_size = 2
power_usage = 50
critical = 1
malfunction_probability = 1
origin_tech = list(TECH_DATA = 3, TECH_ENGINEERING = 2)
var/max_idle_programs = 2 // 2 idle, + 1 active = 3 as said in description.
/obj/item/weapon/computer_hardware/processor_unit/small
name = "standard microprocessor"
desc = "A standard miniaturised CPU used in portable devices. It can run up to two programs simultaneously."
icon_state = "cpu_small"
hardware_size = 1
power_usage = 25
max_idle_programs = 1
origin_tech = list(TECH_DATA = 2, TECH_ENGINEERING = 2)
/obj/item/weapon/computer_hardware/processor_unit/photonic
name = "photonic processor"
desc = "An advanced experimental CPU that uses photonic core instead of regular circuitry. It can run up to five programs simultaneously, but uses a lot of power."
icon_state = "cpu_normal_photonic"
hardware_size = 2
power_usage = 250
max_idle_programs = 4
origin_tech = list(TECH_DATA = 5, TECH_ENGINEERING = 4)
/obj/item/weapon/computer_hardware/processor_unit/photonic/small
name = "photonic microprocessor"
desc = "An advanced miniaturised CPU for use in portable devices. It uses photonic core instead of regular circuitry. It can run up to three programs simultaneously."
icon_state = "cpu_small_photonic"
hardware_size = 1
power_usage = 75
max_idle_programs = 2
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 ..()

View File

@@ -0,0 +1,14 @@
/obj/item/weapon/computer_hardware/tesla_link
name = "tesla link"
desc = "An advanced tesla link that wirelessly recharges connected device from nearby area power controller."
critical = 0
enabled = 1
icon_state = "teslalink"
hardware_size = 1
origin_tech = list(TECH_DATA = 2, TECH_POWER = 3, TECH_ENGINEERING = 2)
var/passive_charging_rate = 250 // W
/obj/item/weapon/computer_hardware/tesla_link/Destroy()
if(holder2 && (holder2.tesla_link == src))
holder2.tesla_link = null
return ..()