From 1ff14a5fcf2ade9d690b8a86edd01a857e6d354a Mon Sep 17 00:00:00 2001 From: Robson Richards Date: Tue, 21 Jan 2014 07:38:46 +0000 Subject: [PATCH] Adds item_heal_robotic() - a way for items to trigger robotic limb heal procs without copy-paste --- code/game/objects/items/weapons/tools.dm | 15 ++++----------- code/modules/power/cable.dm | 17 ++++------------- code/modules/surgery/organs/organ.dm | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/code/game/objects/items/weapons/tools.dm b/code/game/objects/items/weapons/tools.dm index e75d6e7b3fb..a8b70bc0b53 100644 --- a/code/game/objects/items/weapons/tools.dm +++ b/code/game/objects/items/weapons/tools.dm @@ -163,26 +163,19 @@ /obj/item/weapon/weldingtool/attack(mob/living/carbon/human/H, mob/user) + var/obj/item/organ/limb/affecting = H.get_organ(check_zone(user.zone_sel.selecting)) if(istype(H)) - var/obj/item/organ/limb/affecting = H.get_organ(check_zone(user.zone_sel.selecting)) if(affecting.status == ORGAN_ROBOTIC) if(src.remove_fuel(0)) - if(affecting.brute_dam > 0) - affecting.heal_damage(30,0,1) - H.update_damage_overlays(0) - H.updatehealth() - for(var/mob/O in viewers(user, null)) - O.show_message(text("[user] has fixed some of the dents on [H]'s [affecting.getDisplayName()]!"), 1) - return - else - user << "[H]'s [affecting.getDisplayName()] is already in good condition" - return + src.item_heal_robotic(H, user, 30, 0) + return else user << "Need more welding fuel!" return else return ..() + else return ..() diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm index 06de1d8020a..be06d93f9cc 100644 --- a/code/modules/power/cable.dm +++ b/code/modules/power/cable.dm @@ -221,21 +221,12 @@ /obj/item/weapon/cable_coil/attack(mob/living/carbon/human/H, mob/user) - + var/obj/item/organ/limb/affecting = H.get_organ(check_zone(user.zone_sel.selecting)) if(istype(H)) - var/obj/item/organ/limb/affecting = H.get_organ(check_zone(user.zone_sel.selecting)) - if(affecting.status == ORGAN_ROBOTIC) - if(affecting.burn_dam > 0) - affecting.heal_damage(0,30,1) - H.updatehealth() - for(var/mob/O in viewers(user, null)) - O.show_message(text("[user] has fixed some of the burnt wires on [H]'s [affecting.getDisplayName()]!"), 1) - src.use(1) - return - else - user << "[H]'s [affecting.getDisplayName()] is already in good condition" - return + src.item_heal_robotic(H, user, 0, 30) + src.use(1) + return else return ..() else diff --git a/code/modules/surgery/organs/organ.dm b/code/modules/surgery/organs/organ.dm index 6fbc2f55fbd..f55f2888677 100644 --- a/code/modules/surgery/organs/organ.dm +++ b/code/modules/surgery/organs/organ.dm @@ -151,6 +151,30 @@ return update_organ_icon() +/obj/item/proc/item_heal_robotic(var/mob/living/carbon/human/H, var/mob/user, var/brute, var/burn) + var/obj/item/organ/limb/affecting = H.get_organ(check_zone(user.zone_sel.selecting)) + + var/dam //changes repair text based on how much brute/burn was supplied + + if(brute > burn) + dam = 1 + else + dam = 0 + + if(affecting.status == ORGAN_ROBOTIC) + if(brute > 0 && affecting.brute_dam > 0 || burn > 0 && affecting.burn_dam > 0) + affecting.heal_damage(brute,burn,1) + H.update_damage_overlays(0) + H.updatehealth() + for(var/mob/O in viewers(user, null)) + O.show_message(text("[user] has fixed some of the [dam ? "dents on" : "burnt wires in"] [H]'s [affecting.getDisplayName()]!"), 1) + return + else + user << "[H]'s [affecting.getDisplayName()] is already in good condition" + return + else + return + //Returns total damage...kinda pointless really /obj/item/organ/limb/proc/get_damage() return brute_dam + burn_dam