mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-18 19:39:42 +01:00
@@ -28,7 +28,12 @@
|
||||
var/icon_state_menu = "menu" // Icon state overlay when the computer is turned on, but no program is loaded that would override the screen.
|
||||
var/max_hardware_size = 0 // Maximal hardware size. Currently, tablets have 1, laptops 2 and consoles 3. Limits what hardware types can be installed.
|
||||
var/steel_sheet_cost = 5 // Amount of steel sheets refunded when disassembling an empty frame of this computer.
|
||||
var/light_strength = 0
|
||||
|
||||
// Damage of the chassis. If the chassis takes too much damage it will break apart.
|
||||
var/damage = 0 // Current damage level
|
||||
var/broken_damage = 50 // Damage level at which the computer ceases to operate
|
||||
var/max_damage = 100 // Damage level at which the computer breaks apart.
|
||||
|
||||
// Important hardware (must be installed for computer to work)
|
||||
var/obj/item/weapon/computer_hardware/processor_unit/processor_unit // CPU. Without it the computer won't run. Better CPUs can run more programs at once.
|
||||
@@ -39,6 +44,7 @@
|
||||
var/obj/item/weapon/computer_hardware/card_slot/card_slot // ID Card slot component of this computer. Mostly for HoP modification console that needs ID slot for modification.
|
||||
var/obj/item/weapon/computer_hardware/nano_printer/nano_printer // Nano Printer component of this computer, for your everyday paperwork needs.
|
||||
var/obj/item/weapon/computer_hardware/hard_drive/portable/portable_drive // Portable data storage
|
||||
var/obj/item/weapon/computer_hardware/ai_slot/ai_slot // AI slot, an intellicard housing that allows modifications of AIs.
|
||||
|
||||
var/list/idle_threads = list() // Idle programs on background. They still receive process calls but can't be interacted with.
|
||||
|
||||
@@ -59,6 +65,37 @@
|
||||
|
||||
proc_eject_id(usr)
|
||||
|
||||
// Eject ID card from computer, if it has ID slot with card inside.
|
||||
/obj/item/modular_computer/verb/eject_usb()
|
||||
set name = "Eject Portable Storage"
|
||||
set category = "Object"
|
||||
set src in view(1)
|
||||
|
||||
if(usr.incapacitated() || !istype(usr, /mob/living))
|
||||
usr << "<span class='warning'>You can't do that.</span>"
|
||||
return
|
||||
|
||||
if(!Adjacent(usr))
|
||||
usr << "<span class='warning'>You can't reach it.</span>"
|
||||
return
|
||||
|
||||
proc_eject_usb(usr)
|
||||
|
||||
/obj/item/modular_computer/verb/eject_ai()
|
||||
set name = "Eject Portable Storage"
|
||||
set category = "Object"
|
||||
set src in view(1)
|
||||
|
||||
if(usr.incapacitated() || !istype(usr, /mob/living))
|
||||
usr << "<span class='warning'>You can't do that.</span>"
|
||||
return
|
||||
|
||||
if(!Adjacent(usr))
|
||||
usr << "<span class='warning'>You can't reach it.</span>"
|
||||
return
|
||||
|
||||
proc_eject_ai(usr)
|
||||
|
||||
/obj/item/modular_computer/proc/proc_eject_id(mob/user)
|
||||
if(!user)
|
||||
user = usr
|
||||
@@ -71,11 +108,42 @@
|
||||
user << "There is no card in \the [src]"
|
||||
return
|
||||
|
||||
if(active_program)
|
||||
active_program.event_idremoved(0)
|
||||
|
||||
for(var/datum/computer_file/program/P in idle_threads)
|
||||
P.event_idremoved(1)
|
||||
|
||||
card_slot.stored_card.forceMove(get_turf(src))
|
||||
card_slot.stored_card = null
|
||||
update_uis()
|
||||
user << "You remove the card from \the [src]"
|
||||
|
||||
|
||||
/obj/item/modular_computer/proc/proc_eject_usb(mob/user)
|
||||
if(!user)
|
||||
user = usr
|
||||
|
||||
if(!portable_drive)
|
||||
user << "There is no portable device connected to \the [src]."
|
||||
return
|
||||
|
||||
uninstall_component(user, portable_drive)
|
||||
update_uis()
|
||||
|
||||
/obj/item/modular_computer/proc/proc_eject_ai(mob/user)
|
||||
if(!user)
|
||||
user = usr
|
||||
|
||||
if(!ai_slot || !ai_slot.stored_card)
|
||||
user << "There is no intellicard connected to \the [src]."
|
||||
return
|
||||
|
||||
ai_slot.stored_card.forceMove(get_turf(src))
|
||||
ai_slot.stored_card = null
|
||||
ai_slot.update_power_usage()
|
||||
update_uis()
|
||||
|
||||
/obj/item/modular_computer/attack_ghost(var/mob/dead/observer/user)
|
||||
if(enabled)
|
||||
ui_interact(user)
|
||||
@@ -93,6 +161,13 @@
|
||||
user << "You emag \the [src]. It's screen briefly shows a \"OVERRIDE ACCEPTED: New software downloads available.\" message."
|
||||
return 1
|
||||
|
||||
/obj/item/modular_computer/examine(var/mob/user)
|
||||
..()
|
||||
if(damage > broken_damage)
|
||||
user << "<span class='danger'>It is heavily damaged!</span>"
|
||||
else if(damage)
|
||||
user << "It is damaged."
|
||||
|
||||
/obj/item/modular_computer/New()
|
||||
processing_objects.Add(src)
|
||||
update_icon()
|
||||
@@ -102,6 +177,7 @@
|
||||
kill_program(1)
|
||||
processing_objects.Remove(src)
|
||||
for(var/obj/item/weapon/computer_hardware/CH in src.get_all_components())
|
||||
uninstall_component(null, CH)
|
||||
qdel(CH)
|
||||
return ..()
|
||||
|
||||
@@ -110,7 +186,9 @@
|
||||
|
||||
overlays.Cut()
|
||||
if(!enabled)
|
||||
set_light(0)
|
||||
return
|
||||
set_light(light_strength)
|
||||
if(active_program)
|
||||
overlays.Add(active_program.program_icon_state ? active_program.program_icon_state : icon_state_menu)
|
||||
else
|
||||
@@ -151,6 +229,8 @@
|
||||
var/list/program = list()
|
||||
program["name"] = P.filename
|
||||
program["desc"] = P.filedesc
|
||||
if(P in idle_threads)
|
||||
program["running"] = 1
|
||||
programs.Add(list(program))
|
||||
|
||||
data["programs"] = programs
|
||||
@@ -169,9 +249,27 @@
|
||||
else
|
||||
turn_on(user)
|
||||
|
||||
/obj/item/modular_computer/proc/break_apart()
|
||||
visible_message("\The [src] breaks apart!")
|
||||
var/turf/newloc = get_turf(src)
|
||||
new /obj/item/stack/material/steel(newloc, round(steel_sheet_cost/2))
|
||||
for(var/obj/item/weapon/computer_hardware/H in get_all_components())
|
||||
uninstall_component(null, H)
|
||||
H.forceMove(newloc)
|
||||
if(prob(25))
|
||||
H.take_damage(rand(10,30))
|
||||
relay_qdel()
|
||||
qdel()
|
||||
|
||||
/obj/item/modular_computer/proc/turn_on(var/mob/user)
|
||||
var/issynth = issilicon(user) // Robots and AIs get different activation messages.
|
||||
if(processor_unit && ((battery_module && battery_module.battery.charge) || check_power_override())) // Battery-run and charged or non-battery but powered by APC.
|
||||
if(damage > broken_damage)
|
||||
if(issynth)
|
||||
user << "You send an activation signal to \the [src], but it responds with an error code. It must be damaged."
|
||||
else
|
||||
user << "You press the power button, but the computer fails to boot up, displaying variety of errors before shutting down again."
|
||||
return
|
||||
if(processor_unit && ((battery_module && battery_module.battery.charge && battery_module.check_functionality()) || check_power_override())) // Battery-run and charged or non-battery but powered by APC.
|
||||
if(issynth)
|
||||
user << "You send an activation signal to \the [src], turning it on"
|
||||
else
|
||||
@@ -191,26 +289,32 @@
|
||||
last_power_usage = 0
|
||||
return 0
|
||||
|
||||
if(damage > broken_damage)
|
||||
shutdown_computer()
|
||||
return 0
|
||||
|
||||
if(active_program && active_program.requires_ntnet && !get_ntnet_status(active_program.requires_ntnet_feature)) // Active program requires NTNet to run but we've just lost connection. Crash.
|
||||
kill_program(1)
|
||||
visible_message("<span class='danger'>\The [src]'s screen briefly freezes and then shows \"NETWORK ERROR - NTNet connection lost. Please retry. If problem persists contact your system administrator.\" error.</span>")
|
||||
active_program.event_networkfailure(0)
|
||||
|
||||
for(var/datum/computer_file/program/P in idle_threads)
|
||||
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature))
|
||||
P.kill_program(1)
|
||||
idle_threads.Remove(P)
|
||||
visible_message("<span class='danger'>\The [src] screen displays an \"Process [P.filename].[P.filetype] (PID [rand(100,999)]) terminated - Network Error\" error</span>")
|
||||
P.event_networkfailure(1)
|
||||
|
||||
if(active_program)
|
||||
active_program.process_tick()
|
||||
active_program.ntnet_status = get_ntnet_status()
|
||||
active_program.computer_emagged = computer_emagged
|
||||
if(active_program.program_state != PROGRAM_STATE_KILLED)
|
||||
active_program.process_tick()
|
||||
active_program.ntnet_status = get_ntnet_status()
|
||||
active_program.computer_emagged = computer_emagged
|
||||
else
|
||||
active_program = null
|
||||
|
||||
for(var/datum/computer_file/program/P in idle_threads)
|
||||
P.process_tick()
|
||||
P.ntnet_status = get_ntnet_status()
|
||||
P.computer_emagged = computer_emagged
|
||||
|
||||
if(P.program_state != PROGRAM_STATE_KILLED)
|
||||
P.process_tick()
|
||||
P.ntnet_status = get_ntnet_status()
|
||||
P.computer_emagged = computer_emagged
|
||||
else
|
||||
idle_threads.Remove(P)
|
||||
|
||||
handle_power() // Handles all computer power interaction
|
||||
check_update_ui_need()
|
||||
@@ -324,44 +428,60 @@
|
||||
if(!active_program || !processor_unit)
|
||||
return
|
||||
|
||||
if(idle_threads.len >= processor_unit.max_idle_programs)
|
||||
user << "<span class='notice'>\The [src] displays a \"Maximal CPU load reached. Unable to minimize another program.\" error</span>"
|
||||
return
|
||||
|
||||
idle_threads.Add(active_program)
|
||||
active_program.running = 0 // Should close any existing UIs
|
||||
active_program.program_state = PROGRAM_STATE_BACKGROUND // Should close any existing UIs
|
||||
nanomanager.close_uis(active_program.NM ? active_program.NM : active_program)
|
||||
active_program = null
|
||||
update_icon()
|
||||
if(user && istype(user))
|
||||
ui_interact(user) // Re-open the UI on this computer. It should show the main screen now.
|
||||
|
||||
if( href_list["PC_killprogram"] )
|
||||
var/prog = href_list["PC_killprogram"]
|
||||
var/datum/computer_file/program/P = null
|
||||
var/mob/user = usr
|
||||
if(hard_drive)
|
||||
P = hard_drive.find_file_by_name(prog)
|
||||
|
||||
if(!istype(P) || P.program_state == PROGRAM_STATE_KILLED)
|
||||
return
|
||||
|
||||
P.kill_program(1)
|
||||
update_uis()
|
||||
user << "<span class='notice'>Program [P.filename].[P.filetype] with PID [rand(100,999)] has been killed.</span>"
|
||||
|
||||
if( href_list["PC_runprogram"] )
|
||||
var/prog = href_list["PC_runprogram"]
|
||||
var/datum/computer_file/program/P = null
|
||||
var/mob/user = usr
|
||||
if(hard_drive)
|
||||
P = hard_drive.find_file_by_name(prog)
|
||||
P.computer = src
|
||||
|
||||
if(!P || !istype(P)) // Program not found or it's not executable program.
|
||||
user << "<span class='danger'>\The [src]'s screen shows \"I/O ERROR - Unable to run program\" warning.</span>"
|
||||
return
|
||||
|
||||
P.computer = src
|
||||
|
||||
if(!P.is_supported_by_hardware(hardware_flag, 1, user))
|
||||
return
|
||||
|
||||
// The program is already running. Resume it.
|
||||
if(P in idle_threads)
|
||||
P.running = 1
|
||||
P.program_state = PROGRAM_STATE_ACTIVE
|
||||
active_program = P
|
||||
idle_threads.Remove(P)
|
||||
update_icon()
|
||||
return
|
||||
|
||||
if(idle_threads.len >= processor_unit.max_idle_programs+1)
|
||||
user << "<span class='notice'>\The [src] displays a \"Maximal CPU load reached. Unable to run another program.\" error</span>"
|
||||
return
|
||||
|
||||
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature)) // The program requires NTNet connection, but we are not connected to NTNet.
|
||||
user << "<span class='danger'>\The [src]'s screen shows \"NETWORK ERROR - Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning.</span>"
|
||||
return
|
||||
|
||||
if(P.run_program(user))
|
||||
active_program = P
|
||||
update_icon()
|
||||
@@ -370,9 +490,13 @@
|
||||
update_uis()
|
||||
|
||||
// Used in following function to reduce copypaste
|
||||
/obj/item/modular_computer/proc/power_failure()
|
||||
/obj/item/modular_computer/proc/power_failure(var/malfunction = 0)
|
||||
if(enabled) // Shut down the computer
|
||||
visible_message("<span class='danger'>\The [src]'s screen flickers \"BATTERY CRITICAL\" warning as it shuts down unexpectedly.</span>")
|
||||
visible_message("<span class='danger'>\The [src]'s screen flickers \"BATTERY [malfunction ? "MALFUNCTION" : "CRITICAL"]\" warning as it shuts down unexpectedly.</span>")
|
||||
if(active_program)
|
||||
active_program.event_powerfailure(0)
|
||||
for(var/datum/computer_file/program/PRG in idle_threads)
|
||||
PRG.event_powerfailure(1)
|
||||
shutdown_computer(0)
|
||||
|
||||
// Handles power-related things, such as battery interaction, recharging, shutdown when it's discharged
|
||||
@@ -388,6 +512,9 @@
|
||||
power_usage += H.power_usage
|
||||
|
||||
if(battery_module)
|
||||
if(!battery_module.check_functionality())
|
||||
power_failure(1)
|
||||
return
|
||||
battery_module.battery.use(power_usage * CELLRATE)
|
||||
|
||||
last_power_usage = power_usage
|
||||
@@ -409,10 +536,13 @@
|
||||
user << "You insert \the [I] into \the [src]."
|
||||
return
|
||||
if(istype(W, /obj/item/weapon/paper))
|
||||
var/obj/item/weapon/paper/P = W
|
||||
if(!nano_printer)
|
||||
return
|
||||
nano_printer.load_paper(P)
|
||||
nano_printer.attackby(W, user)
|
||||
if(istype(W, /obj/item/weapon/aicard))
|
||||
if(!ai_slot)
|
||||
return
|
||||
ai_slot.attackby(W, user)
|
||||
if(istype(W, /obj/item/weapon/computer_hardware))
|
||||
var/obj/item/weapon/computer_hardware/C = W
|
||||
if(C.hardware_size <= max_hardware_size)
|
||||
@@ -429,6 +559,21 @@
|
||||
relay_qdel()
|
||||
qdel(src)
|
||||
return
|
||||
if(istype(W, /obj/item/weapon/weldingtool))
|
||||
var/obj/item/weapon/weldingtool/WT = W
|
||||
if(!WT.isOn())
|
||||
user << "\The [W] is off."
|
||||
return
|
||||
|
||||
if(!damage)
|
||||
user << "\The [src] does not require repairs."
|
||||
return
|
||||
|
||||
user << "You begin repairing damage to \the [src]..."
|
||||
if(WT.remove_fuel(round(damage/75)) && do_after(usr, damage/10))
|
||||
damage = 0
|
||||
user << "You repair \the [src]."
|
||||
return
|
||||
|
||||
if(istype(W, /obj/item/weapon/screwdriver))
|
||||
var/list/all_components = get_all_components()
|
||||
@@ -507,6 +652,12 @@
|
||||
return
|
||||
found = 1
|
||||
processor_unit = H
|
||||
else if(istype(H, /obj/item/weapon/computer_hardware/ai_slot))
|
||||
if(ai_slot)
|
||||
user << "This computer's intellicard slot is already occupied by \the [ai_slot]."
|
||||
return
|
||||
found = 1
|
||||
ai_slot = H
|
||||
if(found)
|
||||
user << "You install \the [H] into \the [src]"
|
||||
H.holder2 = src
|
||||
@@ -538,14 +689,18 @@
|
||||
processor_unit = null
|
||||
found = 1
|
||||
critical = 1
|
||||
if(ai_slot == H)
|
||||
ai_slot = null
|
||||
found = 1
|
||||
if(found)
|
||||
user << "You remove \the [H] from \the [src]."
|
||||
if(user)
|
||||
user << "You remove \the [H] from \the [src]."
|
||||
H.forceMove(get_turf(src))
|
||||
H.holder2 = null
|
||||
if(critical && enabled)
|
||||
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>"
|
||||
kill_program(1)
|
||||
enabled = 0
|
||||
if(user)
|
||||
user << "<span class='danger'>\The [src]'s screen freezes for few seconds and then displays an \"HARDWARE ERROR: Critical component disconnected. Please verify component connection and reboot the device. If the problem persists contact technical support for assistance.\" warning.</span>"
|
||||
shutdown_computer()
|
||||
update_icon()
|
||||
|
||||
|
||||
@@ -565,6 +720,8 @@
|
||||
return battery_module
|
||||
if(processor_unit && (processor_unit.name == name))
|
||||
return processor_unit
|
||||
if(ai_slot && (ai_slot.name == name))
|
||||
return ai_slot
|
||||
return null
|
||||
|
||||
// Returns list of all components
|
||||
@@ -584,6 +741,8 @@
|
||||
all_components.Add(battery_module)
|
||||
if(processor_unit)
|
||||
all_components.Add(processor_unit)
|
||||
if(ai_slot)
|
||||
all_components.Add(ai_slot)
|
||||
return all_components
|
||||
|
||||
/obj/item/modular_computer/proc/update_uis()
|
||||
@@ -595,16 +754,16 @@
|
||||
nanomanager.update_uis(src)
|
||||
|
||||
/obj/item/modular_computer/proc/check_update_ui_need()
|
||||
var/ui_updated_needed = 0
|
||||
var/ui_update_needed = 0
|
||||
if(battery_module)
|
||||
var/batery_percent = battery_module.battery.percent()
|
||||
if(last_battery_percent != batery_percent) //Let's update UI on percent chandge
|
||||
ui_updated_needed = 1
|
||||
if(last_battery_percent != batery_percent) //Let's update UI on percent change
|
||||
ui_update_needed = 1
|
||||
last_battery_percent = batery_percent
|
||||
|
||||
if(worldtime2text() != last_world_time)
|
||||
last_world_time = worldtime2text()
|
||||
ui_updated_needed = 1
|
||||
ui_update_needed = 1
|
||||
|
||||
if(idle_threads.len)
|
||||
var/list/current_header_icons = list()
|
||||
@@ -617,13 +776,51 @@
|
||||
|
||||
else if(!listequal(last_header_icons, current_header_icons))
|
||||
last_header_icons = current_header_icons
|
||||
ui_updated_needed = 1
|
||||
ui_update_needed = 1
|
||||
else
|
||||
for(var/x in last_header_icons|current_header_icons)
|
||||
if(last_header_icons[x]!=current_header_icons[x])
|
||||
last_header_icons = current_header_icons
|
||||
ui_updated_needed = 1
|
||||
ui_update_needed = 1
|
||||
break
|
||||
|
||||
if(ui_updated_needed)
|
||||
update_uis()
|
||||
if(ui_update_needed)
|
||||
update_uis()
|
||||
|
||||
/obj/item/modular_computer/proc/take_damage(var/amount, var/component_probability, var/damage_casing = 1, var/randomize = 1)
|
||||
if(randomize)
|
||||
// 75%-125%, rand() works with integers, apparently.
|
||||
amount *= (rand(75, 125) / 100.0)
|
||||
amount = round(amount)
|
||||
if(damage_casing)
|
||||
damage += amount
|
||||
damage = between(0, damage, max_damage)
|
||||
|
||||
if(component_probability)
|
||||
for(var/obj/item/weapon/computer_hardware/H in get_all_components())
|
||||
if(prob(component_probability))
|
||||
H.take_damage(round(amount / 2))
|
||||
|
||||
if(damage >= max_damage)
|
||||
break_apart()
|
||||
|
||||
// Stronger explosions cause serious damage to internal components
|
||||
// Minor explosions are mostly mitigitated by casing.
|
||||
/obj/item/modular_computer/ex_act(var/severity)
|
||||
take_damage(rand(100,200) / severity, 30 / severity)
|
||||
|
||||
// EMPs are similar to explosions, but don't cause physical damage to the casing. Instead they screw up the components
|
||||
/obj/item/modular_computer/emp_act(var/severity)
|
||||
take_damage(rand(100,200) / severity, 50 / severity, 0)
|
||||
|
||||
// "Stun" weapons can cause minor damage to components (short-circuits?)
|
||||
// "Burn" damage is equally strong against internal components and exterior casing
|
||||
// "Brute" damage mostly damages the casing.
|
||||
/obj/item/modular_computer/bullet_act(var/obj/item/projectile/Proj)
|
||||
switch(Proj.damage_type)
|
||||
if(BRUTE)
|
||||
take_damage(Proj.damage, Proj.damage / 2)
|
||||
if(HALLOSS)
|
||||
take_damage(Proj.damage, Proj.damage / 3, 0)
|
||||
if(BURN)
|
||||
take_damage(Proj.damage, Proj.damage / 1.5)
|
||||
|
||||
@@ -11,11 +11,13 @@
|
||||
var/obj/machinery/modular_computer/machinery_computer = null
|
||||
|
||||
/obj/item/modular_computer/processor/Destroy()
|
||||
. = ..()
|
||||
if(machinery_computer && (machinery_computer.cpu == src))
|
||||
machinery_computer.cpu = null
|
||||
machinery_computer = null
|
||||
return ..()
|
||||
|
||||
/obj/item/modular_computer/processor/nano_host()
|
||||
return machinery_computer.nano_host()
|
||||
// Due to how processes work, we'd receive two process calls - one from machinery type and one from our own type.
|
||||
// Since we want this to be in-sync with machinery (as it's hidden type for machinery-based computers) we'll ignore
|
||||
// non-relayed process calls.
|
||||
@@ -25,6 +27,12 @@
|
||||
else
|
||||
return
|
||||
|
||||
/obj/item/modular_computer/processor/examine(var/mob/user)
|
||||
if(damage > broken_damage)
|
||||
user << "<span class='danger'>It is heavily damaged!</span>"
|
||||
else if(damage)
|
||||
user << "It is damaged."
|
||||
|
||||
// Power interaction is handled by our machinery part, due to machinery having APC connection.
|
||||
/obj/item/modular_computer/processor/handle_power()
|
||||
if(machinery_computer)
|
||||
@@ -40,6 +48,8 @@
|
||||
hardware_flag = machinery_computer.hardware_flag
|
||||
max_hardware_size = machinery_computer.max_hardware_size
|
||||
steel_sheet_cost = machinery_computer.steel_sheet_cost
|
||||
max_damage = machinery_computer._max_damage
|
||||
broken_damage = machinery_computer._break_damage
|
||||
|
||||
/obj/item/modular_computer/processor/relay_qdel()
|
||||
qdel(machinery_computer)
|
||||
@@ -92,10 +102,6 @@
|
||||
var/obj/item/weapon/computer_hardware/tesla_link/L = H
|
||||
L.holder = machinery_computer
|
||||
machinery_computer.tesla_link = L
|
||||
// Consoles don't usually have internal power source, so we can't disable tesla link in them.
|
||||
if(istype(machinery_computer, /obj/machinery/modular_computer/console))
|
||||
L.critical = 1
|
||||
L.enabled = 1
|
||||
found = 1
|
||||
..(user, H, found)
|
||||
|
||||
@@ -103,14 +109,13 @@
|
||||
if(machinery_computer.tesla_link == H)
|
||||
machinery_computer.tesla_link = null
|
||||
var/obj/item/weapon/computer_hardware/tesla_link/L = H
|
||||
L.critical = 0 // That way we can install tesla link from console to laptop and it will be possible to turn it off via config.
|
||||
L.holder = null
|
||||
found = 1
|
||||
..(user, H, found, critical)
|
||||
|
||||
/obj/item/modular_computer/processor/get_all_components()
|
||||
var/list/all_components = ..()
|
||||
if(machinery_computer.tesla_link)
|
||||
if(machinery_computer && machinery_computer.tesla_link)
|
||||
all_components.Add(machinery_computer.tesla_link)
|
||||
return all_components
|
||||
|
||||
@@ -118,4 +123,16 @@
|
||||
/obj/item/modular_computer/processor/Adjacent(var/atom/neighbor)
|
||||
if(!machinery_computer)
|
||||
return 0
|
||||
return machinery_computer.Adjacent(neighbor)
|
||||
return machinery_computer.Adjacent(neighbor)
|
||||
|
||||
/obj/item/modular_computer/processor/turn_on(var/mob/user)
|
||||
// If we have a tesla link on our machinery counterpart, enable it automatically. Lets computer without a battery work.
|
||||
if(machinery_computer && machinery_computer.tesla_link)
|
||||
machinery_computer.tesla_link.enabled = 1
|
||||
..()
|
||||
|
||||
/obj/item/modular_computer/processor/check_eye(var/mob/user)
|
||||
if (active_program)
|
||||
return active_program.check_eye(user)
|
||||
|
||||
return -1
|
||||
|
||||
@@ -6,4 +6,5 @@
|
||||
icon_state_menu = "menu"
|
||||
hardware_flag = PROGRAM_TABLET
|
||||
max_hardware_size = 1
|
||||
w_class = 2
|
||||
w_class = 2
|
||||
light_strength = 2 // Same as PDAs
|
||||
@@ -5,6 +5,7 @@
|
||||
desc = "A low-end tablet often seen among low ranked station personnel"
|
||||
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(src)
|
||||
battery_module = new/obj/item/weapon/computer_hardware/battery_module/nano(src)
|
||||
battery_module.charge_to_full()
|
||||
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/micro(src)
|
||||
network_card = new/obj/item/weapon/computer_hardware/network_card(src)
|
||||
|
||||
@@ -13,6 +14,7 @@
|
||||
. = ..()
|
||||
processor_unit = new/obj/item/weapon/computer_hardware/processor_unit/small(src)
|
||||
battery_module = new/obj/item/weapon/computer_hardware/battery_module(src)
|
||||
battery_module.charge_to_full()
|
||||
hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/small(src)
|
||||
network_card = new/obj/item/weapon/computer_hardware/network_card(src)
|
||||
nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(src)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
var/_has_id_slot = 0
|
||||
var/_has_printer = 0
|
||||
var/_has_battery = 0
|
||||
var/_has_aislot = 0
|
||||
|
||||
/obj/machinery/modular_computer/console/preset/New()
|
||||
. = ..()
|
||||
@@ -15,6 +16,8 @@
|
||||
cpu.nano_printer = new/obj/item/weapon/computer_hardware/nano_printer(cpu)
|
||||
if(_has_battery)
|
||||
cpu.battery_module = new/obj/item/weapon/computer_hardware/battery_module/super(cpu)
|
||||
if(_has_aislot)
|
||||
cpu.ai_slot = new/obj/item/weapon/computer_hardware/ai_slot(cpu)
|
||||
install_programs()
|
||||
|
||||
// Override in child types to install preset-specific programs.
|
||||
@@ -46,11 +49,13 @@
|
||||
/obj/machinery/modular_computer/console/preset/research
|
||||
console_department = "Research"
|
||||
desc = "A stationary computer. This one comes preloaded with research programs."
|
||||
_has_aislot = 1
|
||||
|
||||
/obj/machinery/modular_computer/console/preset/research/install_programs()
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/ntnetmonitor())
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/nttransfer())
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/chatclient())
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/aidiag())
|
||||
|
||||
|
||||
// ===== COMMAND CONSOLE =====
|
||||
@@ -58,11 +63,16 @@
|
||||
console_department = "Command"
|
||||
desc = "A stationary computer. This one comes preloaded with command programs."
|
||||
_has_id_slot = 1
|
||||
_has_printer = 1
|
||||
|
||||
/obj/machinery/modular_computer/console/preset/command/install_programs()
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/chatclient())
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/card_mod())
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/comm())
|
||||
|
||||
/obj/machinery/modular_computer/console/preset/command/main
|
||||
console_department = "Command"
|
||||
desc = "A stationary computer. This one comes preloaded with essential command programs."
|
||||
|
||||
// ===== SECURITY CONSOLE =====
|
||||
/obj/machinery/modular_computer/console/preset/security
|
||||
@@ -70,8 +80,7 @@
|
||||
desc = "A stationary computer. This one comes preloaded with security programs."
|
||||
|
||||
/obj/machinery/modular_computer/console/preset/security/install_programs()
|
||||
return // No security programs exist, yet, but the preset is ready so it may be mapped in.
|
||||
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/camera_monitor())
|
||||
|
||||
// ===== CIVILIAN CONSOLE =====
|
||||
/obj/machinery/modular_computer/console/preset/civilian
|
||||
@@ -81,4 +90,3 @@
|
||||
/obj/machinery/modular_computer/console/preset/civilian/install_programs()
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/chatclient())
|
||||
cpu.hard_drive.store_file(new/datum/computer_file/program/nttransfer())
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
// Global var to track modular computers
|
||||
var/list/global_modular_computers = list()
|
||||
|
||||
// Modular Computer - device that runs various programs and operates with hardware
|
||||
// DO NOT SPAWN THIS TYPE. Use /laptop/ or /console/ instead.
|
||||
/obj/machinery/modular_computer/
|
||||
name = "modular computer"
|
||||
desc = "An advanced computer"
|
||||
desc = "An advanced computer."
|
||||
|
||||
var/battery_powered = 0 // Whether computer should be battery powered. It is set automatically
|
||||
use_power = 0
|
||||
@@ -20,10 +23,13 @@
|
||||
var/screen_icon_screensaver = "standby" // Icon state overlay when the computer is powered, but not 'switched on'.
|
||||
var/max_hardware_size = 0 // Maximal hardware size. Currently, tablets have 1, laptops 2 and consoles 3. Limits what hardware types can be installed.
|
||||
var/steel_sheet_cost = 10 // Amount of steel sheets refunded when disassembling an empty frame of this computer.
|
||||
|
||||
var/light_strength = 0 // Light luminosity when turned on
|
||||
var/base_active_power_usage = 100 // Power usage when the computer is open (screen is active) and can be interacted with. Remember hardware can use power too.
|
||||
var/base_idle_power_usage = 10 // Power usage when the computer is idle and screen is off (currently only applies to laptops)
|
||||
|
||||
var/_max_damage = 100
|
||||
var/_break_damage = 50
|
||||
|
||||
var/obj/item/weapon/computer_hardware/tesla_link/tesla_link // Tesla Link component of this computer. Allows remote charging from nearest APC.
|
||||
|
||||
var/obj/item/modular_computer/processor/cpu = null // CPU that handles most logic while this type only handles power and other specific things.
|
||||
@@ -42,9 +48,9 @@
|
||||
if(!cpu || !cpu.enabled)
|
||||
if (!(stat & NOPOWER) || battery_powered)
|
||||
overlays.Add(screen_icon_screensaver)
|
||||
else
|
||||
icon_state = icon_state_unpowered
|
||||
set_light(0)
|
||||
return
|
||||
set_light(light_strength)
|
||||
if(cpu.active_program)
|
||||
overlays.Add(cpu.active_program.program_icon_state ? cpu.active_program.program_icon_state : screen_icon_state_menu)
|
||||
else
|
||||
@@ -59,15 +65,45 @@
|
||||
if(cpu)
|
||||
cpu.eject_id()
|
||||
|
||||
// Eject ID card from computer, if it has ID slot with card inside.
|
||||
/obj/machinery/modular_computer/verb/eject_usb()
|
||||
set name = "Eject Portable Storage"
|
||||
set category = "Object"
|
||||
set src in view(1)
|
||||
|
||||
if(cpu)
|
||||
cpu.eject_usb()
|
||||
|
||||
// Eject AI Card
|
||||
/obj/machinery/modular_computer/verb/eject_ai()
|
||||
set name = "Eject AI Storage"
|
||||
set category = "Object"
|
||||
set src in view(1)
|
||||
|
||||
if(cpu)
|
||||
cpu.eject_ai()
|
||||
|
||||
/obj/machinery/modular_computer/New()
|
||||
..()
|
||||
cpu = new(src)
|
||||
global_modular_computers.Add(src)
|
||||
|
||||
/obj/machinery/modular_computer/Destroy()
|
||||
if(cpu)
|
||||
qdel(cpu)
|
||||
cpu = null
|
||||
return ..()
|
||||
|
||||
// On-click handling. Turns on the computer if it's off and opens the GUI.
|
||||
/obj/machinery/modular_computer/attack_hand(mob/user)
|
||||
if(cpu)
|
||||
cpu.attack_self(user) // CPU is an item, that's why we route attack_hand to attack_self
|
||||
|
||||
/obj/machinery/modular_computer/examine(var/mob/user)
|
||||
. = ..()
|
||||
if(cpu)
|
||||
cpu.examine(user)
|
||||
|
||||
// Process currently calls handle_power(), may be expanded in future if more things are added.
|
||||
/obj/machinery/modular_computer/process()
|
||||
if(cpu)
|
||||
@@ -82,21 +118,22 @@
|
||||
return null
|
||||
|
||||
// Used in following function to reduce copypaste
|
||||
/obj/machinery/modular_computer/proc/power_failure()
|
||||
/obj/machinery/modular_computer/proc/power_failure(var/malfunction = 0)
|
||||
if(cpu && cpu.enabled) // Shut down the computer
|
||||
visible_message("<span class='danger'>\The [src]'s screen flickers [cpu.battery_module ? "\"BATTERY CRITICAL\"" : "\"EXTERNAL POWER LOSS\""] warning as it shuts down unexpectedly.</span>")
|
||||
visible_message("<span class='danger'>\The [src]'s screen flickers [cpu.battery_module ? "\"BATTERY [malfunction ? "MALFUNCTION" : "CRITICAL"]\"" : "\"EXTERNAL POWER LOSS\""] warning as it shuts down unexpectedly.</span>")
|
||||
if(cpu)
|
||||
cpu.shutdown_computer(0)
|
||||
battery_powered = 0
|
||||
update_icon()
|
||||
|
||||
stat |= NOPOWER
|
||||
update_icon()
|
||||
|
||||
// Called by cpu item's process() automatically, handles our power interaction.
|
||||
/obj/machinery/modular_computer/proc/handle_power()
|
||||
if(cpu.battery_module && cpu.battery_module.battery.charge <= 0) // Battery-run but battery is depleted.
|
||||
power_failure()
|
||||
return 0
|
||||
else if(!cpu.battery_module && (!powered() || !tesla_link || !tesla_link.enabled)) // Not battery run, but lacking APC connection.
|
||||
else if(!cpu.battery_module && (!powered() || !tesla_link || !tesla_link.enabled || !tesla_link.check_functionality())) // Not battery run, but lacking APC connection.
|
||||
power_failure()
|
||||
return 0
|
||||
else if(stat & NOPOWER)
|
||||
@@ -113,7 +150,7 @@
|
||||
power_usage += CH.power_usage
|
||||
|
||||
// Wireless APC connection exists.
|
||||
if(tesla_link && tesla_link.enabled)
|
||||
if(tesla_link && tesla_link.enabled && tesla_link.check_functionality())
|
||||
idle_power_usage = power_usage
|
||||
active_power_usage = idle_power_usage + 100 // APCLink only charges at 100W rate, but covers any power usage.
|
||||
use_power = 1
|
||||
@@ -129,6 +166,9 @@
|
||||
else // No wireless connection run only on battery.
|
||||
use_power = 0
|
||||
if (cpu.battery_module)
|
||||
if(!cpu.battery_module.check_functionality())
|
||||
power_failure(1)
|
||||
return
|
||||
cpu.battery_module.battery.use(power_usage * CELLRATE)
|
||||
cpu.last_power_usage = power_usage
|
||||
|
||||
@@ -136,10 +176,34 @@
|
||||
/obj/machinery/modular_computer/power_change()
|
||||
if(battery_powered)
|
||||
return
|
||||
else
|
||||
..()
|
||||
..()
|
||||
|
||||
|
||||
/obj/machinery/modular_computer/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
|
||||
if(cpu)
|
||||
return cpu.attackby(W, user)
|
||||
return ..()
|
||||
|
||||
|
||||
// Stronger explosions cause serious damage to internal components
|
||||
// Minor explosions are mostly mitigitated by casing.
|
||||
/obj/machinery/modular_computer/ex_act(var/severity)
|
||||
if(cpu)
|
||||
cpu.ex_act(severity)
|
||||
|
||||
// EMPs are similar to explosions, but don't cause physical damage to the casing. Instead they screw up the components
|
||||
/obj/machinery/modular_computer/emp_act(var/severity)
|
||||
if(cpu)
|
||||
cpu.emp_act(severity)
|
||||
|
||||
// "Stun" weapons can cause minor damage to components (short-circuits?)
|
||||
// "Burn" damage is equally strong against internal components and exterior casing
|
||||
// "Brute" damage mostly damages the casing.
|
||||
/obj/machinery/modular_computer/bullet_act(var/obj/item/projectile/Proj)
|
||||
if(cpu)
|
||||
cpu.bullet_act(Proj)
|
||||
|
||||
/obj/machinery/modular_computer/check_eye(var/mob/user)
|
||||
if(cpu)
|
||||
return cpu.check_eye(user)
|
||||
return -1
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
base_active_power_usage = 600
|
||||
max_hardware_size = 3
|
||||
steel_sheet_cost = 20
|
||||
light_strength = 4
|
||||
_max_damage = 300
|
||||
_break_damage = 150
|
||||
|
||||
/obj/machinery/modular_computer/console/buildable/New()
|
||||
..()
|
||||
@@ -27,8 +30,6 @@
|
||||
cpu.battery_module = null
|
||||
cpu.network_card = new/obj/item/weapon/computer_hardware/network_card/wired(src)
|
||||
tesla_link = new/obj/item/weapon/computer_hardware/tesla_link(src)
|
||||
tesla_link.enabled = 1
|
||||
tesla_link.critical = 1 // Consoles don't usually come with cells, and this prevents people from disabling their only power source, as they wouldn't be able to enable it again.
|
||||
cpu.hard_drive = new/obj/item/weapon/computer_hardware/hard_drive/super(src) // Consoles generally have better HDDs due to lower space limitations
|
||||
var/area/A = get_area(src)
|
||||
// Attempts to set this console's tag according to our area. Since some areas have stuff like "XX - YY" in their names we try to remove that too.
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
// The actual laptop
|
||||
/obj/machinery/modular_computer/laptop
|
||||
name = "laptop computer"
|
||||
desc = "A portable computer"
|
||||
desc = "A portable computer."
|
||||
var/obj/item/laptop/portable = null // Portable version of this computer, dropped on alt-click to allow transport. Used by laptops.
|
||||
hardware_flag = PROGRAM_LAPTOP
|
||||
icon_state_unpowered = "laptop-open" // Icon state when the computer is turned off
|
||||
@@ -60,6 +60,9 @@
|
||||
base_idle_power_usage = 25
|
||||
base_active_power_usage = 200
|
||||
max_hardware_size = 2
|
||||
light_strength = 3
|
||||
_max_damage = 200
|
||||
_break_damage = 100
|
||||
|
||||
/obj/machinery/modular_computer/laptop/buildable/New()
|
||||
..()
|
||||
|
||||
Reference in New Issue
Block a user