a small addition

This commit is contained in:
Geevies
2020-04-15 19:58:18 +02:00
parent 21deec90c3
commit 94579a73bf
65 changed files with 1200 additions and 1223 deletions

View File

@@ -8,14 +8,14 @@
if(damage > broken_damage)
shutdown_computer()
return 0
return FALSE
if(active_program && active_program.requires_ntnet && !get_ntnet_status(active_program.requires_ntnet_feature)) // Active program requires NTNet to run but we've just lost connection. Crash.
active_program.event_networkfailure(0)
if(active_program?.requires_ntnet && !get_ntnet_status(active_program.requires_ntnet_feature)) // Active program requires NTNet to run but we've just lost connection. Crash.
active_program.event_networkfailure(FALSE)
for(var/datum/computer_file/program/P in idle_threads)
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature))
P.event_networkfailure(1)
P.event_networkfailure(TRUE)
if(active_program)
if(active_program.program_state != PROGRAM_STATE_KILLED)
@@ -36,24 +36,24 @@
working = hard_drive && processor_unit && damage < broken_damage && computer_use_power()
check_update_ui_need()
if (working && enabled && world.time > ambience_last_played + 30 SECONDS && prob(3))
playsound(loc, "computerbeep", 30, 1, 10, required_preferences = SOUND_AMBIENCE)
if(working && enabled && world.time > ambience_last_played + 30 SECONDS && prob(3))
playsound(get_turf(src), "computerbeep", 30, 1, 10, required_preferences = SOUND_AMBIENCE)
ambience_last_played = world.time
/obj/item/modular_computer/proc/get_preset_programs(preset_type)
for (var/datum/modular_computer_app_presets/prs in ntnet_global.available_software_presets)
for(var/datum/modular_computer_app_presets/prs in ntnet_global.available_software_presets)
if(prs.type == preset_type)
return prs.return_install_programs()
// Used to perform preset-specific hardware changes.
/obj/item/modular_computer/proc/install_default_hardware()
return 1
return TRUE
// Used to install preset-specific programs
/obj/item/modular_computer/proc/install_default_programs()
if(enrolled)
var/programs = get_preset_programs(_app_preset_type)
for (var/datum/computer_file/program/prog in programs)
for(var/datum/computer_file/program/prog in programs)
hard_drive.store_file(prog)
/obj/item/modular_computer/Initialize()
@@ -66,7 +66,7 @@
update_icon()
/obj/item/modular_computer/Destroy()
kill_program(1)
kill_program(TRUE)
for(var/obj/item/computer_hardware/CH in src.get_all_components())
uninstall_component(null, CH)
qdel(CH)
@@ -76,12 +76,12 @@
/obj/item/modular_computer/emag_act(var/remaining_charges, var/mob/user)
if(computer_emagged)
to_chat(user, "\The [src] has already been emagged.")
to_chat(user, SPAN_WARNING("\The [src] has already been emagged."))
return NO_EMAG_ACT
else
computer_emagged = 1
to_chat(user, "You emag \the [src]. Its screen briefly displays a \"OVERRIDE ACCEPTED: New software downloads available.\" message.")
return 1
computer_emagged = TRUE
to_chat(user, SPAN_WARNING("You emag \the [src]. Its screen briefly displays, \"OVERRIDE ACCEPTED: New software downloads available.\"."))
return TRUE
/obj/item/modular_computer/update_icon()
icon_state = icon_state_unpowered
@@ -119,29 +119,29 @@
/obj/item/modular_computer/proc/turn_on(var/mob/user)
if(tesla_link)
tesla_link.enabled = 1
tesla_link.enabled = TRUE
var/issynth = issilicon(user) // Robots and AIs get different activation messages.
if(damage > broken_damage)
if(issynth)
to_chat(user, "You send an activation signal to \the [src], but it responds with an error code. It must be damaged.")
to_chat(user, SPAN_WARNING("You send an activation signal to \the [src], but it responds with an error code. It must be damaged."))
else
to_chat(user, "You press the power button, but the computer fails to boot up, displaying variety of errors before shutting down again.")
to_chat(user, SPAN_WARNING("You press the power button, but the computer fails to boot up, displaying a variety of errors before shutting down again."))
return
if(processor_unit && computer_use_power()) // Battery-run and charged or non-battery but powered by APC.
if(issynth)
to_chat(user, "You send an activation signal to \the [src], turning it on")
to_chat(user, SPAN_NOTICE("You send an activation signal to \the [src], turning it on."))
else
to_chat(user, "You press the power button and start up \the [src]")
to_chat(user, SPAN_NOTICE("You press the power button and start up \the [src]."))
enable_computer(user)
else // Unpowered
if(issynth)
to_chat(user, "You send an activation signal to \the [src] but it does not respond")
to_chat(user, SPAN_WARNING("You send an activation signal to \the [src], but it does not respond."))
else
to_chat(user, "You press the power button but \the [src] does not respond")
to_chat(user, SPAN_WARNING("You press the power button, but \the [src] does not respond."))
// Relays kill program request to currently active program. Use this to quit current program.
/obj/item/modular_computer/proc/kill_program(var/forced = 0)
/obj/item/modular_computer/proc/kill_program(var/forced = FALSE)
if(active_program)
active_program.kill_program(forced)
src.vueui_transfer(active_program)
@@ -160,23 +160,23 @@
/obj/item/modular_computer/proc/add_log(var/text)
if(!get_ntnet_status())
return 0
return FALSE
return ntnet_global.add_log(text, network_card)
/obj/item/modular_computer/proc/shutdown_computer(var/loud = 1)
/obj/item/modular_computer/proc/shutdown_computer(var/loud = TRUE)
SSvueui.close_uis(active_program)
kill_program(1)
kill_program(TRUE)
for(var/datum/computer_file/program/P in idle_threads)
P.kill_program(1)
P.kill_program(TRUE)
idle_threads.Remove(P)
if(loud)
visible_message("\The [src] shuts down.")
visible_message(SPAN_NOTICE("\The [src] shuts down."))
SSvueui.close_uis(src)
enabled = 0
enabled = FALSE
update_icon()
/obj/item/modular_computer/proc/enable_computer(var/mob/user = null)
enabled = 1
/obj/item/modular_computer/proc/enable_computer(var/mob/user)
enabled = TRUE
update_icon()
// Autorun feature
@@ -208,12 +208,12 @@
P = hard_drive.find_file_by_name(prog)
if(!P || !istype(P)) // Program not found or it's not executable program.
to_chat(user, "<span class='danger'>\The [src]'s screen shows \"I/O ERROR - Unable to run [prog]\" warning.</span>")
to_chat(user, SPAN_WARNING("\The [src]'s screen displays, \"I/O ERROR - Unable to run [prog]\"."))
return
P.computer = src
if(!P.is_supported_by_hardware(hardware_flag, 1, user))
if(!P.is_supported_by_hardware(hardware_flag, TRUE, user))
return
if(P in idle_threads)
P.program_state = PROGRAM_STATE_ACTIVE
@@ -225,11 +225,11 @@
return
if(idle_threads.len >= processor_unit.max_idle_programs+1)
to_chat(user, "<span class='notice'>\The [src] displays a \"Maximal CPU load reached. Unable to run another program.\" error</span>")
to_chat(user, SPAN_WARNING("\The [src] displays, \"Maximal CPU load reached. Unable to run another program.\"."))
return
if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature)) // The program requires NTNet connection, but we are not connected to NTNet.
to_chat(user, "<span class='danger'>\The [src]'s screen shows \"NETWORK ERROR - Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\" warning.</span>")
to_chat(user, FONT_SMALL(SPAN_WARNING("\The [src] displays, \"NETWORK ERROR - Unable to connect to NTNet. Please retry. If problem persists contact your system administrator.\".")))
return
if(active_program)
@@ -240,7 +240,7 @@
if(!P.vueui_transfer(src))
SSvueui.close_uis(src)
update_icon()
return 1
return TRUE
/obj/item/modular_computer/proc/update_uis()
if(active_program) //Should we update program ui or computer ui?
@@ -251,16 +251,16 @@
SSnanoui.update_uis(src)
/obj/item/modular_computer/proc/check_update_ui_need()
var/ui_update_needed = 0
var/ui_update_needed = FALSE
if(battery_module)
var/batery_percent = battery_module.battery.percent()
if(last_battery_percent != batery_percent) //Let's update UI on percent change
ui_update_needed = 1
last_battery_percent = batery_percent
var/battery_percent = battery_module.battery.percent()
if(last_battery_percent != battery_percent) //Let's update UI on percent change
ui_update_needed = TRUE
last_battery_percent = battery_percent
if(worldtime2text() != last_world_time)
last_world_time = worldtime2text()
ui_update_needed = 1
ui_update_needed = TRUE
if(idle_threads.len)
var/list/current_header_icons = list()
@@ -273,12 +273,12 @@
else if(!listequal(last_header_icons, current_header_icons))
last_header_icons = current_header_icons
ui_update_needed = 1
ui_update_needed = TRUE
else
for(var/x in last_header_icons|current_header_icons)
if(last_header_icons[x]!=current_header_icons[x])
last_header_icons = current_header_icons
ui_update_needed = 1
ui_update_needed = TRUE
break
if(ui_update_needed)
@@ -293,3 +293,12 @@
/obj/item/modular_computer/get_cell()
return battery_module ? battery_module.get_cell() : DEVICE_NO_CELL
/obj/item/modular_computer/proc/output_message(var/message, var/message_range)
message_range += message_output_range
if(message_range == 0)
var/mob/user = loc
if(istype(user))
to_chat(user, message)
return
visible_message(message, range = message_range)

View File

@@ -1,23 +1,25 @@
/obj/item/modular_computer/examine(var/mob/user)
/obj/item/modular_computer/examine(mob/user)
..()
if(Adjacent(user))
to_chat(user, FONT_SMALL(SPAN_NOTICE("It contains the following hardware:")))
for(var/CH in get_all_components())
to_chat(user, FONT_SMALL(SPAN_NOTICE(" - [capitalize_first_letters(CH)]")))
if(damage > broken_damage)
to_chat(user, "<span class='danger'>It is heavily damaged!</span>")
to_chat(user, SPAN_DANGER("It is heavily damaged!"))
else if(damage)
to_chat(user, "It is damaged.")
to_chat(user, SPAN_WARNING("It is damaged."))
/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))
visible_message(SPAN_WARNING("\The [src] breaks apart!"))
new /obj/item/stack/material/steel(get_turf(src), round(steel_sheet_cost/2))
for(var/obj/item/computer_hardware/H in get_all_components())
uninstall_component(null, H)
H.forceMove(newloc)
H.forceMove(get_turf(src))
if(prob(25))
H.take_damage(rand(10,30))
H.take_damage(rand(10, 30))
qdel(src)
/obj/item/modular_computer/proc/take_damage(var/amount, var/component_probability, var/damage_casing = 1, var/randomize = 1)
/obj/item/modular_computer/proc/take_damage(var/amount, var/component_probability, var/damage_casing = TRUE, var/randomize = TRUE)
if(randomize)
// 75%-125%, rand() works with integers, apparently.
amount *= (rand(75, 125) / 100.0)
@@ -42,7 +44,7 @@
// 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)
take_damage(rand(100, 200) / severity, 50 / severity, FALSE)
// "Stun" weapons can cause minor damage to components (short-circuits?)
// "Burn" damage is equally strong against internal components and exterior casing
@@ -54,4 +56,4 @@
if(PAIN)
take_damage(Proj.damage, Proj.damage / 3, 0)
if(BURN)
take_damage(Proj.damage, Proj.damage / 1.5)
take_damage(Proj.damage, Proj.damage / 1.5)

View File

@@ -1,131 +1,128 @@
// Attempts to install the hardware into appropriate slot.
/obj/item/modular_computer/proc/try_install_component(var/mob/living/user, var/obj/item/computer_hardware/H, var/found = 0)
/obj/item/modular_computer/proc/try_install_component(var/mob/living/user, var/obj/item/computer_hardware/H, var/found = FALSE)
// "USB" flash drive.
if(istype(H, /obj/item/computer_hardware/hard_drive/portable))
if(enrolled == 1 && !computer_emagged)
to_chat(user, "The client management software on this computer rejects \the [portable_drive].")
return
if(portable_drive)
to_chat(user, "This computer's portable drive slot is already occupied by \the [portable_drive].")
to_chat(user, SPAN_WARNING("\The [src]'s portable drive slot is already occupied by \the [portable_drive]."))
return
found = 1
found = TRUE
portable_drive = H
else if(istype(H, /obj/item/computer_hardware/hard_drive))
if(hard_drive)
to_chat(user, "This computer's hard drive slot is already occupied by \the [hard_drive].")
to_chat(user, SPAN_WARNING("\The [src]'s hard drive slot is already occupied by \the [hard_drive]."))
return
found = 1
found = TRUE
hard_drive = H
else if(istype(H, /obj/item/computer_hardware/network_card))
if(network_card)
to_chat(user, "This computer's network card slot is already occupied by \the [network_card].")
to_chat(user, SPAN_WARNING("\The [src]'s network card slot is already occupied by \the [network_card]."))
return
found = 1
found = TRUE
network_card = H
else if(istype(H, /obj/item/computer_hardware/nano_printer))
if(nano_printer)
to_chat(user, "This computer's nano printer slot is already occupied by \the [nano_printer].")
to_chat(user, SPAN_WARNING("\The [src]'s nano printer slot is already occupied by \the [nano_printer]."))
return
found = 1
found = TRUE
nano_printer = H
else if(istype(H, /obj/item/computer_hardware/card_slot))
if(card_slot)
to_chat(user, "This computer's card slot is already occupied by \the [card_slot].")
to_chat(user, SPAN_WARNING("\The [src]'s card slot is already occupied by \the [card_slot]."))
return
found = 1
found = TRUE
card_slot = H
else if(istype(H, /obj/item/computer_hardware/battery_module))
if(battery_module)
to_chat(user, "This computer's battery slot is already occupied by \the [battery_module].")
to_chat(user, SPAN_WARNING("\The [src]'s battery slot is already occupied by \the [battery_module]."))
return
found = 1
found = TRUE
battery_module = H
else if(istype(H, /obj/item/computer_hardware/processor_unit))
if(processor_unit)
to_chat(user, "This computer's processor slot is already occupied by \the [processor_unit].")
to_chat(user, SPAN_WARNING("\The [src]'s processor slot is already occupied by \the [processor_unit]."))
return
found = 1
found = TRUE
processor_unit = H
else if(istype(H, /obj/item/computer_hardware/ai_slot))
if(ai_slot)
to_chat(user, "This computer's intellicard slot is already occupied by \the [ai_slot].")
to_chat(user, SPAN_WARNING("\The [src]'s intellicard slot is already occupied by \the [ai_slot]."))
return
found = 1
found = TRUE
ai_slot = H
else if(istype(H, /obj/item/computer_hardware/tesla_link))
if(tesla_link)
to_chat(user, "This computer's tesla link slot is already occupied by \the [tesla_link].")
to_chat(user, SPAN_WARNING("\The [src]'s tesla link slot is already occupied by \the [tesla_link]."))
return
found = 1
found = TRUE
tesla_link = H
if(found)
to_chat(user, "You install \the [H] into \the [src]")
H.holder2 = src
user.drop_from_inventory(H,src)
to_chat(user, SPAN_NOTICE("You install \the [H] into \the [src]."))
H.parent_computer = src
user.drop_from_inventory(H, src)
update_icon()
// Uninstalls component. Found and Critical vars may be passed by parent types, if they have additional hardware.
/obj/item/modular_computer/proc/uninstall_component(var/mob/living/user, var/obj/item/computer_hardware/H, var/found = 0, var/critical = 0)
/obj/item/modular_computer/proc/uninstall_component(var/mob/living/user, var/obj/item/computer_hardware/H, var/found = FALSE, var/critical = FALSE)
if(portable_drive == H)
portable_drive = null
found = 1
found = TRUE
else if(hard_drive == H)
hard_drive = null
found = 1
critical = 1
found = TRUE
critical = TRUE
else if(network_card == H)
network_card = null
found = 1
found = TRUE
else if(nano_printer == H)
nano_printer = null
found = 1
found = TRUE
else if(card_slot == H)
card_slot = null
found = 1
found = TRUE
else if(battery_module == H)
battery_module = null
found = 1
found = TRUE
else if(processor_unit == H)
processor_unit = null
found = 1
found = TRUE
critical = 1
else if(ai_slot == H)
ai_slot = null
found = 1
found = TRUE
else if(tesla_link == H)
tesla_link = null
found = 1
found = TRUE
if(found)
if(user)
to_chat(user, "You remove \the [H] from \the [src].")
to_chat(user, SPAN_NOTICE("You remove \the [H] from \the [src]."))
H.forceMove(get_turf(src))
H.holder2 = null
H.parent_computer = null
update_icon()
if(critical && enabled)
to_chat(user, "<span class='danger'>\The [src]'s screen freezes for few seconds and then displays an \"HARDWARE ERROR: Critical component disconnected. Please verify component connection and reboot the device. If the problem persists contact technical support for assistance.\" warning.</span>")
to_chat(user, SPAN_WARNING("\The [src]'s screen freezes for few seconds and then displays, \"HARDWARE ERROR: Critical component disconnected. Please verify component connection and reboot the device. If the problem persists contact technical support for assistance.\"."))
shutdown_computer()
// Checks all hardware pieces to determine if name matches, if yes, returns the hardware piece, otherwise returns null
/obj/item/modular_computer/proc/find_hardware_by_name(var/name)
if(portable_drive && (portable_drive.name == name))
if(portable_drive && (initial(portable_drive.name) == name))
return portable_drive
if(hard_drive && (hard_drive.name == name))
if(hard_drive && (initial(hard_drive.name) == name))
return hard_drive
if(network_card && (network_card.name == name))
if(network_card && (initial(network_card.name) == name))
return network_card
if(nano_printer && (nano_printer.name == name))
if(nano_printer && (initial(nano_printer.name) == name))
return nano_printer
if(card_slot && (card_slot.name == name))
if(card_slot && (initial(card_slot.name) == name))
return card_slot
if(battery_module && (battery_module.name == name))
if(battery_module && (initial(battery_module.name) == name))
return battery_module
if(processor_unit && (processor_unit.name == name))
if(processor_unit && (initial(processor_unit.name) == name))
return processor_unit
if(ai_slot && (ai_slot.name == name))
if(ai_slot && (initial(ai_slot.name) == name))
return ai_slot
if(tesla_link && (tesla_link.name == name))
if(tesla_link && (initial(tesla_link.name) == name))
return tesla_link
return null
@@ -150,4 +147,4 @@
all_components.Add(ai_slot)
if(tesla_link)
all_components.Add(tesla_link)
return all_components
return all_components

View File

@@ -4,12 +4,7 @@
set category = "Object"
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
if(use_check_and_message(usr))
return
proc_eject_id(usr)
@@ -20,12 +15,7 @@
set category = "Object"
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
if(use_check_and_message(usr))
return
proc_eject_usb(usr)
@@ -35,12 +25,7 @@
set category = "Object"
set src in view(1)
if(usr.incapacitated() || !istype(usr, /mob/living))
to_chat(usr, "<span class='warning'>You can't do that.</span>")
return
if(!Adjacent(usr))
to_chat(usr, "<span class='warning'>You can't reach it.</span>")
if(use_check_and_message(usr))
return
proc_eject_ai(usr)
@@ -50,25 +35,25 @@
user = usr
if(!card_slot)
to_chat(user, "\The [src] does not have an ID card slot")
to_chat(user, SPAN_WARNING("\The [src] does not have an ID card slot."))
return
if(!card_slot.stored_card)
to_chat(user, "There is no card in \the [src]")
to_chat(user, SPAN_WARNING("There is no card in \the [src]."))
return
if(active_program)
active_program.event_idremoved(0)
active_program.event_idremoved(FALSE)
for(var/datum/computer_file/program/P in idle_threads)
P.event_idremoved(1)
P.event_idremoved(TRUE)
if(ishuman(user))
user.put_in_hands(card_slot.stored_card)
else
card_slot.stored_card.forceMove(get_turf(src))
card_slot.stored_card = null
update_uis()
to_chat(user, "You remove the card from \the [src]")
to_chat(user, SPAN_NOTICE("You remove the card from \the [src]."))
/obj/item/modular_computer/proc/proc_eject_usb(mob/user)
@@ -76,7 +61,7 @@
user = usr
if(!portable_drive)
to_chat(user, "There is no portable device connected to \the [src].")
to_chat(user, SPAN_WARNING("There is no portable drive connected to \the [src]."))
return
uninstall_component(user, portable_drive)
@@ -86,8 +71,12 @@
if(!user)
user = usr
if(!ai_slot || !ai_slot.stored_card)
to_chat(user, "There is no intellicard connected to \the [src].")
if(!ai_slot)
to_chat(user, SPAN_WARNING("\The [src] doesn't have an intellicard slot."))
return
if(!ai_slot.stored_card)
to_chat(user, SPAN_WARNING("There is no intellicard connected to \the [src]."))
return
if(ishuman(user))
@@ -123,33 +112,33 @@
else if(!enabled && screen_on)
turn_on(user)
/obj/item/modular_computer/attackby(var/obj/item/W as obj, var/mob/user as mob)
/obj/item/modular_computer/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/card/tech_support))
if(!can_reset)
to_chat(user, span("notice", "You cannot reset this type of device."))
to_chat(user, SPAN_WARNING("You cannot reset this type of device."))
return
if(!enabled)
to_chat(user, span("notice", "You cannot reset the device if it isn't powered on."))
to_chat(user, SPAN_WARNING("You cannot reset the device if it isn't powered on."))
return
if(!hard_drive)
to_chat(user, span("notice", "You cannot reset a device that has no hard drive."))
to_chat(user, SPAN_WARNING("You cannot reset a device that has no hard drive."))
return
enrolled = 0
enrolled = FALSE
hard_drive.reset_drive()
visible_message("\icon[src.icon] <b>[src]</b> pings, <span class='notice'>\"Enrollment status reset! Have a NanoTrasen day.\"</span>")
if(istype(W, /obj/item/card/id)) // ID Card, try to insert it.
var/obj/item/card/id/I = W
if(!card_slot)
to_chat(user, "You try to insert \the [I] into \the [src], but it does not have an ID card slot installed.")
to_chat(user, SPAN_WARNING("You try to insert \the [I] into \the [src], but it does not have an ID card slot installed."))
return
if(card_slot.stored_card)
to_chat(user, SPAN_WARNING("You try to insert \the [I] into \the [src], but its ID card slot is occupied."))
return
if(card_slot.stored_card)
to_chat(user, "You try to insert \the [I] into \the [src], but it's ID card slot is occupied.")
return
user.drop_from_inventory(I,src)
user.drop_from_inventory(I, src)
card_slot.stored_card = I
update_uis()
to_chat(user, "You insert \the [I] into \the [src].")
to_chat(user, SPAN_NOTICE("You insert \the [I] into \the [src]."))
return
if(istype(W, /obj/item/paper))
if(!nano_printer)
@@ -164,63 +153,59 @@
if(C.hardware_size <= max_hardware_size)
try_install_component(user, C)
else
to_chat(user, "This component is too large for \the [src].")
to_chat(user, SPAN_WARNING("This component is too large for \the [src]."))
if(W.iswrench())
var/list/components = get_all_components()
if(components.len)
to_chat(user, "Remove all components from \the [src] before disassembling it.")
to_chat(user, SPAN_WARNING("You have to remove all the components from \the [src] before disassembling it."))
return
to_chat(user, span("notice", "You begin to disassemble \the [src]."))
playsound(user, W.usesound, 100, 1)
to_chat(user, SPAN_NOTICE("You begin to disassemble \the [src]."))
playsound(get_turf(src), W.usesound, 100, TRUE)
if (do_after(user, 20/W.toolspeed))
new /obj/item/stack/material/steel(get_turf(src.loc), steel_sheet_cost)
src.visible_message("\The [user] disassembles \the [src].",
"You disassemble \the [src].",
"You hear a ratchet.")
new /obj/item/stack/material/steel(get_turf(src), steel_sheet_cost)
user.visible_message(SPAN_NOTICE("\The [user] disassembles \the [src]."), SPAN_NOTICE("You disassemble \the [src]."), SPAN_NOTICE("You hear a ratcheting noise."))
qdel(src)
return
if(W.iswelder())
var/obj/item/weldingtool/WT = W
if(!WT.isOn())
to_chat(user, "\The [W] is off.")
to_chat(user, SPAN_WARNING("\The [W] is off."))
return
if(!damage)
to_chat(user, "\The [src] does not require repairs.")
to_chat(user, SPAN_WARNING("\The [src] does not require repairs."))
return
to_chat(user, "You begin repairing damage to \the [src]...")
playsound(src, 'sound/items/Welder.ogg', 100, 1)
if(WT.remove_fuel(round(damage/75)) && do_after(usr, damage/10))
to_chat(user, SPAN_NOTICE("You begin repairing the damage to \the [src]..."))
playsound(get_turf(src), 'sound/items/Welder.ogg', 100, 1)
if(WT.remove_fuel(round(damage / 75)) && do_after(user, damage / 10))
damage = 0
to_chat(user, "You repair \the [src].")
to_chat(user, SPAN_NOTICE("You fully repair \the [src]."))
update_icon()
return
if(W.isscrewdriver())
var/list/all_components = get_all_components()
if(!all_components.len)
to_chat(user, "This device doesn't have any components installed.")
to_chat(user, SPAN_WARNING("This device doesn't have any components installed."))
return
var/list/component_names = list()
for(var/obj/item/computer_hardware/H in all_components)
component_names.Add(H.name)
var/choice = input(usr, "Which component do you want to uninstall?", "Computer maintenance", null) as null|anything in component_names
var/obj/item/computer_hardware/choice = input(user, "Which component do you want to uninstall?", "Hardware Removal") as null|anything in all_components
if(!choice)
return
if(!Adjacent(usr))
return
var/obj/item/computer_hardware/H = find_hardware_by_name(choice)
var/obj/item/computer_hardware/H = find_hardware_by_name(initial(choice.name))
if(!H)
return
uninstall_component(user, H)
return
..()
/obj/item/modular_computer/MouseDrop(atom/over_object)
var/mob/M = usr
if(use_check_and_message(M))
return
if(!istype(over_object, /obj/screen) && !(over_object == src))
return attack_self(M)

View File

@@ -1,17 +1,16 @@
/obj/item/modular_computer/proc/power_failure(var/malfunction = 0)
/obj/item/modular_computer/proc/power_failure(var/malfunction = FALSE)
if(enabled) // Shut down the computer
visible_message("<span class='danger'>\The [src]'s screen flickers briefly and then goes dark.</span>")
visible_message(SPAN_WARNING("\The [src]'s screen flickers briefly and then goes dark."))
if(active_program)
active_program.event_powerfailure(0)
active_program.event_powerfailure(FALSE)
for(var/datum/computer_file/program/PRG in idle_threads)
PRG.event_powerfailure(1)
shutdown_computer(0)
PRG.event_powerfailure(TRUE)
shutdown_computer(FALSE)
power_has_failed = TRUE
update_icon()
// Tries to use power from battery. Passing 0 as parameter results in this proc returning whether battery is functional or not.
/obj/item/modular_computer/proc/battery_power(var/power_usage = 0)
// Tries to use power from battery. Passing false as parameter results in this proc returning whether battery is functional or not.
/obj/item/modular_computer/proc/battery_power(var/power_usage = FALSE)
apc_powered = FALSE
if(!battery_module || !battery_module.check_functionality() || battery_module.battery.charge <= 0)
return FALSE
@@ -51,16 +50,15 @@
// Handles power-related things, such as battery interaction, recharging, shutdown when it's discharged
/obj/item/modular_computer/proc/handle_power()
var/power_usage = screen_on ? base_active_power_usage : base_idle_power_usage
if (enabled)
if(enabled)
for(var/obj/item/computer_hardware/H in get_all_components())
if(H.enabled)
power_usage += H.power_usage
last_power_usage = power_usage
if(computer_use_power(power_usage))
if (power_has_failed)
if(power_has_failed)
power_has_failed = FALSE
update_icon()
return
power_failure()
power_failure()

View File

@@ -18,10 +18,10 @@
// We are still here, that means there is no program loaded. Load the BIOS/ROM/OS/whatever you want to call it.
// This screen simply lists available programs and user may select them.
if(!hard_drive || !hard_drive.stored_files || !hard_drive.stored_files.len)
visible_message("\The [src] beeps three times, it's screen displaying \"DISK ERROR\" warning.")
visible_message(SPAN_WARNING("\The [src] beeps three times, its screen displaying, \"DISK ERROR!\"."))
return // No HDD, No HDD files list or no stored files. Something is very broken.
if (!ui)
if(!ui)
ui = new /datum/vueui/modularcomputer(user, src, "mcomputer-system-main", 400, 500, "NTOS Main Menu")
ui.header = "modular-computer"
ui.open()
@@ -55,30 +55,30 @@
// Handles user's GUI input
/obj/item/modular_computer/Topic(href, href_list)
if(..())
return 1
if( href_list["PC_exit"] )
return TRUE
if(href_list["PC_exit"])
kill_program()
return 1
if( href_list["PC_enable_component"] )
return TRUE
if(href_list["PC_enable_component"])
var/obj/item/computer_hardware/H = find_hardware_by_name(href_list["PC_enable_component"])
if(H && istype(H) && !H.enabled)
H.enabled = 1
. = 1
if( href_list["PC_disable_component"] )
H.enabled = TRUE
. = TRUE
if(href_list["PC_disable_component"])
var/obj/item/computer_hardware/H = find_hardware_by_name(href_list["PC_disable_component"])
if(H && istype(H) && H.enabled)
H.enabled = 0
. = 1
if( href_list["PC_shutdown"] )
. = TRUE
if(href_list["PC_shutdown"])
shutdown_computer()
return 1
if( href_list["PC_minimize"] )
return TRUE
if(href_list["PC_minimize"])
var/mob/user = usr
minimize_program(user)
if( href_list["PC_killprogram"] )
if(href_list["PC_killprogram"])
var/prog = href_list["PC_killprogram"]
var/datum/computer_file/program/P = null
var/datum/computer_file/program/P
var/mob/user = usr
if(hard_drive)
P = hard_drive.find_file_by_name(prog)
@@ -86,20 +86,20 @@
if(!istype(P) || P.program_state == PROGRAM_STATE_KILLED)
return
P.kill_program(1)
P.kill_program(TRUE)
update_uis()
to_chat(user, "<span class='notice'>Program [P.filename].[P.filetype] with PID [rand(100,999)] has been killed.</span>")
to_chat(user, SPAN_NOTICE("Program [P.filename].[P.filetype] with PID [rand(100,999)] has been killed."))
if( href_list["PC_runprogram"] )
if(href_list["PC_runprogram"])
. = run_program(href_list["PC_runprogram"])
ui_interact(usr)
if( href_list["PC_setautorun"] )
if(href_list["PC_setautorun"])
if(!hard_drive)
return
var/datum/computer_file/data/autorun = hard_drive.find_file_by_name("autorun")
if(!istype(autorun))
autorun = new/datum/computer_file/data()
autorun = new /datum/computer_file/data()
autorun.filename = "autorun"
hard_drive.store_file(autorun)
if(autorun.stored_data == href_list["PC_setautorun"])
@@ -163,4 +163,4 @@
continue
VUEUI_SET_CHECK(data["programheaders"][P.filename], P.ui_header, ., data)
VUEUI_SET_CHECK(data["showexitprogram"], !!active_program, ., data) // Hides "Exit Program" button on mainscreen
VUEUI_SET_CHECK(data["showexitprogram"], !!active_program, ., data) // Hides "Exit Program" button on mainscreen

View File

@@ -1,14 +1,13 @@
// This is the base type that handles everything. Subtypes can be easily created by tweaking variables in this file to your liking.
/obj/item/modular_computer
name = "Modular Computer"
desc = "A modular computer. You shouldn't see this."
var/enabled = 0 // Whether the computer is turned on.
var/screen_on = 1 // Whether the computer is active/opened/it's screen is on.
var/working = 1 // Whether the computer is working.
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 = null // A currently active program running on the computer.
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
@@ -18,8 +17,8 @@
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 = 0 // 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 = null // Used for specifying the software preset of the console
var/enrolled = FALSE // 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 // Last time sound was played
// Modular computers can run on various devices. Each DEVICE (Laptop, Console, Tablet,..)
@@ -30,13 +29,14 @@
icon_state = null // And no random pixelshifting on-creation either.
randpixel = 0
center_of_mass = null
var/icon_state_unpowered = null // Icon state when the computer is turned off
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.
var/icon_state_screensaver = null
var/icon_state_broken = null
var/icon_state_screensaver
var/icon_state_broken
var/screensaver_light_range = 0
var/screensaver_light_color = null
var/menu_light_color = null
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.
var/light_strength = 0 // Intensity of light this computer emits. Comparable to numbers light fixtures use.
@@ -55,13 +55,13 @@
var/obj/item/computer_hardware/hard_drive/hard_drive // Hard Drive component of this computer. Stores programs and files.
// 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/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/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/computer_hardware/tesla_link/tesla_link // Tesla Link, Allows remote charging from nearest APC.
var/listener/listener //Listener needed for things
charge_failure_message = " does not have a battery installed."
charge_failure_message = " does not have a battery installed."