// TODO: remove the robot.mmi and robot.cell variables and completely rely on the robot component system /datum/robot_component var/name = "Component" var/installed = 0 var/powered = 1 var/toggled = 1 var/brute_damage = 0 var/electronics_damage = 0 var/energy_consumption = 0 var/max_damage = 30 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) qdel(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, edge) 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 = 100 /datum/robot_component/actuator name = "actuator" energy_consumption = 1 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() // Returns component by it's string name /mob/living/silicon/robot/proc/get_component(var/component_name) var/datum/robot_component/C = components[component_name] return C /obj/item/broken_device name = "broken component" icon = 'icons/obj/robot_component.dmi' icon_state = "broken" /obj/item/robot_parts/robot_component icon = 'icons/obj/robot_component.dmi' icon_state = "working" var/brute = 0 var/burn = 0 /obj/item/robot_parts/robot_component/binary_communication_device name = "binary communication device" icon_state = "binary_translator" /obj/item/robot_parts/robot_component/actuator name = "actuator" icon_state = "actuator" /obj/item/robot_parts/robot_component/armour name = "armour plating" icon_state = "armor_plating" /obj/item/robot_parts/robot_component/camera name = "camera" icon_state = "camera" /obj/item/robot_parts/robot_component/diagnosis_unit name = "diagnosis unit" icon_state = "diagnosis_unit" /obj/item/robot_parts/robot_component/radio name = "radio" icon_state = "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 = CONDUCT slot_flags = SLOT_BELT throwforce = 3 w_class = 2.0 throw_speed = 5 throw_range = 10 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.visible_message("[user] has analyzed the floor's vitals!", "You try to analyze the floor's vitals!") to_chat(user, "Analyzing Results for The floor:\n\t Overall Status: Healthy") to_chat(user, "\t Damage Specifics: [0]-[0]-[0]-[0]") to_chat(user, "Key: Suffocation/Toxin/Burns/Brute") to_chat(user, "Body Temperature: ???") return var/scan_type if(istype(M, /mob/living/silicon/robot)) scan_type = "robot" else if(istype(M, /mob/living/carbon/human)) scan_type = "prosthetics" else to_chat(user, "You can't analyze non-robotic things!") return user.visible_message("[user] has analyzed [M]'s components.","You have analyzed [M]'s components.") switch(scan_type) if("robot") var/BU = M.getFireLoss() > 50 ? "[M.getFireLoss()]" : M.getFireLoss() var/BR = M.getBruteLoss() > 50 ? "[M.getBruteLoss()]" : M.getBruteLoss() to_chat(user, "Analyzing Results for [M]:\n\t Overall Status: [M.stat > 1 ? "fully disabled" : "[M.health]% functional"]") to_chat(user, "\t Key: Electronics/Brute") to_chat(user, "\t Damage Specifics: [BU] - [BR]") if(M.timeofdeath && M.stat == DEAD) to_chat(user, "Time of Disable: [M.timeofdeath]") var/mob/living/silicon/robot/H = M var/list/damaged = H.get_damaged_components(1,1,1) to_chat(user, "Localized Damage:") if(length(damaged)>0) for(var/datum/robot_component/org in damaged) user.show_message(text("\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 to_chat(user, "\t Components are OK.") if(H.emagged && prob(5)) to_chat(user, "\t ERROR: INTERNAL SYSTEMS COMPROMISED") if("prosthetics") var/mob/living/carbon/human/H = M to_chat(user, "Analyzing Results for \the [H]:") to_chat(user, "Key: Electronics/Brute") to_chat(user, "External prosthetics:") var/organ_found if(H.internal_organs.len) for(var/obj/item/organ/external/E in H.organs) if(!(E.status & ORGAN_ROBOT)) continue organ_found = 1 to_chat(user, "[E.name]: [round(E.brute_dam)] [round(E.burn_dam)]") if(!organ_found) to_chat(user, "No prosthetics located.") to_chat(user, "