Updates Part Five

This commit is contained in:
Unknown
2019-04-09 14:37:33 -04:00
parent 677f91fdce
commit 0d0d4e02db
13 changed files with 348 additions and 73 deletions

View File

@@ -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.
@@ -59,6 +64,22 @@
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 Device"
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/proc/proc_eject_id(mob/user)
if(!user)
user = usr
@@ -82,6 +103,17 @@
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/attack_ghost(var/mob/observer/dead/user)
if(enabled)
ui_interact(user)
@@ -99,6 +131,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()
START_PROCESSING(SSobj, src)
update_icon()
@@ -108,7 +147,7 @@
kill_program(1)
STOP_PROCESSING(SSobj, src)
for(var/obj/item/weapon/computer_hardware/CH in src.get_all_components())
qdel(CH)
uninstall_component(null, CH)
return ..()
/obj/item/modular_computer/update_icon()
@@ -116,7 +155,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
@@ -175,9 +216,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
@@ -197,6 +256,10 @@
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.
active_program.event_networkfailure(0)
@@ -350,12 +413,13 @@
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
@@ -378,9 +442,9 @@
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)
@@ -400,6 +464,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
@@ -421,10 +488,9 @@
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/computer_hardware))
var/obj/item/weapon/computer_hardware/C = W
if(C.hardware_size <= max_hardware_size)
@@ -441,6 +507,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(W.is_screwdriver())
var/list/all_components = get_all_components()
@@ -551,13 +632,14 @@
found = 1
critical = 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()
@@ -607,16 +689,16 @@
SSnanoui.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(stationtime2text() != last_world_time)
last_world_time = stationtime2text()
ui_updated_needed = 1
ui_update_needed = 1
if(idle_threads.len)
var/list/current_header_icons = list()
@@ -629,13 +711,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)

View File

@@ -11,10 +11,10 @@
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 ..()
// 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
@@ -25,6 +25,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 +46,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)
@@ -110,7 +118,7 @@
/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

View File

@@ -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

View File

@@ -20,10 +20,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,7 +45,9 @@
if(!cpu || !cpu.enabled)
if (!(stat & NOPOWER) || battery_powered)
overlays.Add(screen_icon_screensaver)
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
@@ -57,15 +62,35 @@
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 Device"
set category = "Object"
set src in view(1)
if(cpu)
cpu.eject_usb()
/obj/machinery/modular_computer/New()
..()
cpu = new(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)
@@ -80,9 +105,9 @@
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
@@ -94,7 +119,7 @@
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)
@@ -111,7 +136,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
@@ -127,6 +152,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
@@ -141,4 +169,25 @@
/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 ..()
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)

View File

@@ -14,6 +14,9 @@
base_active_power_usage = 500
max_hardware_size = 3
steel_sheet_cost = 20
light_strength = 4
_max_damage = 300
_break_damage = 150
/obj/machinery/modular_computer/console/buildable/New()
..()

View File

@@ -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()
..()