Files
Bubberstation/code/modules/modular_computers/computers/item/computer_damage.dm
SkyratBot 04302a770a [MIRROR] moves obj_integrity and associated procs to the atom level (#8016)
* moves obj_integrity and associated procs to the atom level

* Feex good

* Whoops forgot the maps

Co-authored-by: Kylerace <kylerlumpkin1@gmail.com>
Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com>
Co-authored-by: Gandalf <jzo123@hotmail.com>
2021-09-10 16:47:01 +01:00

34 lines
1.1 KiB
Plaintext

/obj/item/modular_computer/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1)
. = ..()
var/component_probability = min(50, max(damage_amount*0.1, 1 - atom_integrity/max_integrity))
switch(damage_flag)
if(BULLET)
component_probability = damage_amount * 0.5
if(LASER)
component_probability = damage_amount * 0.66
if(component_probability)
for(var/I in all_components)
var/obj/item/computer_hardware/H = all_components[I]
if(prob(component_probability))
H.take_damage(round(damage_amount*0.5), damage_type, damage_flag, 0)
/obj/item/modular_computer/deconstruct(disassembled = TRUE)
break_apart()
/obj/item/modular_computer/proc/break_apart()
if(!(flags_1 & NODECONSTRUCT_1))
physical.visible_message(span_notice("\The [src] breaks apart!"))
var/turf/newloc = get_turf(src)
new /obj/item/stack/sheet/iron(newloc, round(steel_sheet_cost/2))
for(var/C in all_components)
var/obj/item/computer_hardware/H = all_components[C]
if(QDELETED(H))
continue
uninstall_component(H)
H.forceMove(newloc)
if(prob(25))
H.take_damage(rand(10,30), BRUTE, 0, 0)
relay_qdel()
qdel(src)