// TODO: remove the robot.mmi and robot.cell variables and completely rely on the robot component system /datum/robot_component/var/name /datum/robot_component/var/installed = 0 /datum/robot_component/var/powered = 0 /datum/robot_component/var/toggled = 1 /datum/robot_component/var/brute_damage = 0 /datum/robot_component/var/electronics_damage = 0 /datum/robot_component/var/energy_consumption = 0 /datum/robot_component/var/max_damage = 30 /datum/robot_component/var/mob/living/silicon/robot/owner // The actual device object that has to be installed for this. /datum/robot_component/var/external_type = null // The wrapped device(e.g. radio), only set if external_type isn't null /datum/robot_component/var/obj/item/wrapped = null /datum/robot_component/New(mob/living/silicon/robot/R) src.owner = R /datum/robot_component/proc/install() /datum/robot_component/proc/uninstall() /datum/robot_component/proc/destroy() if(wrapped) del wrapped wrapped = new/obj/item/broken_device // The thing itself isn't there anymore, but some fried remains are. installed = -1 uninstall() /datum/robot_component/proc/take_damage(brute, electronics, sharp) if(installed != 1) return brute_damage += brute electronics_damage += electronics if(brute_damage + electronics_damage >= max_damage) destroy() /datum/robot_component/proc/heal_damage(brute, electronics) if(installed != 1) // If it's not installed, can't repair it. return 0 brute_damage = max(0, brute_damage - brute) electronics_damage = max(0, electronics_damage - electronics) /datum/robot_component/proc/is_powered() return (installed == 1) && (brute_damage + electronics_damage < max_damage) && (!energy_consumption || powered) /datum/robot_component/proc/consume_power() if(toggled == 0) powered = 0 return if(owner.cell.charge >= energy_consumption) owner.cell.use(energy_consumption) powered = 1 else powered = 0 /datum/robot_component/armour name = "armour plating" energy_consumption = 0 external_type = /obj/item/robot_parts/robot_component/armour max_damage = 60 /datum/robot_component/actuator name = "actuator" energy_consumption = 2 external_type = /obj/item/robot_parts/robot_component/actuator max_damage = 50 /datum/robot_component/cell name = "power cell" max_damage = 50 /datum/robot_component/cell/destroy() ..() owner.cell = null /datum/robot_component/radio name = "radio" external_type = /obj/item/robot_parts/robot_component/radio energy_consumption = 1 max_damage = 40 /datum/robot_component/binary_communication name = "binary communication device" external_type = /obj/item/robot_parts/robot_component/binary_communication_device energy_consumption = 0 max_damage = 30 /datum/robot_component/camera name = "camera" external_type = /obj/item/robot_parts/robot_component/camera energy_consumption = 1 max_damage = 40 /datum/robot_component/diagnosis_unit name = "self-diagnosis unit" energy_consumption = 1 external_type = /obj/item/robot_parts/robot_component/diagnosis_unit max_damage = 30 /mob/living/silicon/robot/proc/initialize_components() // This only initializes the components, it doesn't set them to installed. components["actuator"] = new/datum/robot_component/actuator(src) components["radio"] = new/datum/robot_component/radio(src) components["power cell"] = new/datum/robot_component/cell(src) components["diagnosis unit"] = new/datum/robot_component/diagnosis_unit(src) components["camera"] = new/datum/robot_component/camera(src) components["comms"] = new/datum/robot_component/binary_communication(src) components["armour"] = new/datum/robot_component/armour(src) /mob/living/silicon/robot/proc/is_component_functioning(module_name) var/datum/robot_component/C = components[module_name] return C && C.installed == 1 && C.toggled && C.is_powered() /obj/item/broken_device name = "broken component" icon = 'icons/robot_component.dmi' icon_state = "broken" /obj/item/robot_parts/robot_component icon = 'icons/robot_component.dmi' icon_state = "working" construction_time = 200 construction_cost = list("metal"=5000) // TODO: actual icons ;) /obj/item/robot_parts/robot_component/binary_communication_device name = "binary communication device" /obj/item/robot_parts/robot_component/actuator name = "actuator" /obj/item/robot_parts/robot_component/armour name = "armour plating" /obj/item/robot_parts/robot_component/camera name = "camera" /obj/item/robot_parts/robot_component/diagnosis_unit name = "diagnosis unit" /obj/item/robot_parts/robot_component/radio name = "radio" // //Robotic Component Analyser, basically a health analyser for robots // /obj/item/device/robotanalyzer name = "cyborg analyzer" icon_state = "robotanalyzer" item_state = "analyzer" desc = "A hand-held scanner able to diagnose robotic injuries." flags = FPRINT | TABLEPASS | CONDUCT slot_flags = SLOT_BELT throwforce = 3 w_class = 1.0 throw_speed = 5 throw_range = 10 m_amt = 200 origin_tech = "magnets=1;biotech=1" var/mode = 1; /obj/item/device/robotanalyzer/attack(mob/living/M as mob, mob/living/user as mob) if(( (CLUMSY in user.mutations) || user.getBrainLoss() >= 60) && prob(50)) user << text("\red You try to analyze the floor's vitals!") for(var/mob/O in viewers(M, null)) O.show_message(text("\red [user] has analyzed the floor's vitals!"), 1) user.show_message(text("\blue Analyzing Results for The floor:\n\t Overall Status: Healthy"), 1) user.show_message(text("\blue \t Damage Specifics: [0]-[0]-[0]-[0]"), 1) user.show_message("\blue Key: Suffocation/Toxin/Burns/Brute", 1) user.show_message("\blue Body Temperature: ???", 1) return if(!(istype(user, /mob/living/carbon/human) || ticker) && ticker.mode.name != "monkey") user << "\red You don't have the dexterity to do this!" return if(!istype(M, /mob/living/silicon/robot)) user << "\red You can't analyze non-robotic things!" return user.visible_message(" [user] has analyzed [M]'s components."," You have analyzed [M]'s components.") var/BU = M.getFireLoss() > 50 ? "[M.getFireLoss()]" : M.getFireLoss() var/BR = M.getBruteLoss() > 50 ? "[M.getBruteLoss()]" : M.getBruteLoss() user.show_message("\blue Analyzing Results for [M]:\n\t Overall Status: [M.stat > 1 ? "fully disabled" : "[M.health - M.halloss]% functional"]") user.show_message("\t Key: Electronics/Brute", 1) user.show_message("\t Damage Specifics: [BU] - [BR]") if(M.tod && M.stat == DEAD) user.show_message("\blue Time of Disable: [M.tod]") var/mob/living/silicon/robot/H = M var/list/damaged = H.get_damaged_components(1,1,1) user.show_message("\blue Localized Damage:",1) if(length(damaged)>0) for(var/datum/robot_component/org in damaged) user.show_message(text("\blue \t []: [][] - [] - [] - []", \ capitalize(org.name), \ (org.installed == -1) ? "DESTROYED " :"",\ (org.electronics_damage > 0) ? "[org.electronics_damage]" :0, \ (org.brute_damage > 0) ? "[org.brute_damage]" :0, \ (org.toggled) ? "Toggled ON" : "Toggled OFF",\ (org.powered) ? "Power ON" : "Power OFF"),1) else user.show_message("\blue \t Components are OK.",1) if(H.emagged && prob(5)) user.show_message("\red \t ERROR: INTERNAL SYSTEMS COMPROMISED",1) src.add_fingerprint(user) return