From 1cc1e30c54c080aef45791759b6ce01af88fa401 Mon Sep 17 00:00:00 2001 From: Ansari Date: Mon, 21 May 2018 08:01:57 +0800 Subject: [PATCH] Woot, refactored code. Added "healverb" --- code/game/objects/items/stacks/medical.dm | 77 ++++++++++------------- 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index d7ef2969bf6..00388d7e40b 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -12,6 +12,7 @@ var/self_delay = 20 var/unique_handling = 0 //some things give a special prompt, do we want to bypass some checks in parent? var/stop_bleeding = 0 + var/healverb = "bandage" /obj/item/stack/medical/attack(mob/living/M, mob/user) if(!iscarbon(M) && !isanimal(M)) @@ -77,6 +78,33 @@ "You apply [src] on [M].") use(1) +/obj/item/stack/medical/proc/heal(mob/living/M, mob/user) + var/mob/living/carbon/human/H = M + var/obj/item/organ/external/affecting = H.get_organ(user.zone_sel.selecting) + user.visible_message("[user] [healverb]s the wounds on [H]'s [affecting.name].", \ + "You [healverb] the wounds on [H]'s [affecting.name]." ) + + var/rembrute = max(0, heal_brute - affecting.brute_dam) + var/remburn = max(0, heal_burn - affecting.burn_dam) + var/nrembrute = rembrute + var/nremburn = remburn + affecting.heal_damage(heal_brute, heal_burn) + if(affecting.body_part in list(ARM_LEFT, ARM_RIGHT, LEG_LEFT, LEG_RIGHT, UPPER_TORSO, LOWER_TORSO)) + for(var/obj/item/organ/external/E in affecting.children) + if(rembrute <= 0 && remburn <= 0) // Make sure there's actually overheal left and the organ is damaged before bothering + break + else if(E.status && ORGAN_ROBOT || E.open) // Ignore robotic or open limb + continue + else if(E.brute_dam == 0 && E.burn_dam == 0) // Ignore undamaged limb + continue + nrembrute = rembrute - E.brute_dam // Deduct the healed damage from the remain + nremburn = remburn - E.burn_dam + E.heal_damage(rembrute, remburn) + rembrute = nrembrute + remburn = nremburn + user.visible_message("[user] [healverb]s the wounds on [H]'s [E.name] with the remaining medication.", \ + "You [healverb] the wounds on [H]'s [E.name] with the remaining medication." ) + //Bruise Packs// /obj/item/stack/medical/bruise_pack @@ -98,33 +126,12 @@ if(affecting.open == 0) affecting.germ_level = 0 - user.visible_message("[user] bandages the wounds on [H]'s [affecting.name].", \ - "You bandage the wounds on [H]'s [affecting.name]." ) - if(stop_bleeding) if(!H.bleedsuppress) //so you can't stack bleed suppression H.suppress_bloodloss(stop_bleeding) - var/rembrute = max(0, heal_brute - affecting.brute_dam) - var/remburn = max(0, heal_burn - affecting.burn_dam) - var/nrembrute = rembrute - var/nremburn = remburn - affecting.heal_damage(heal_brute, heal_burn) - if(affecting.body_part in list(ARM_LEFT, ARM_RIGHT, LEG_LEFT, LEG_RIGHT, UPPER_TORSO, LOWER_TORSO)) - for(var/obj/item/organ/external/E in affecting.children) - if(rembrute <= 0 && remburn <= 0) // Make sure there's actually overheal left and the organ is damaged before bothering - break - else if(E.status && ORGAN_ROBOT || E.open == 1) // Ignore robotic or open limb - continue - else if(E.brute_dam == 0 && E.burn_dam == 0) // Ignore undamaged limb - continue - nrembrute = rembrute - E.brute_dam // Deduct the healed damage from the remain - nremburn = remburn - E.burn_dam - E.heal_damage(rembrute, remburn) - rembrute = nrembrute - remburn = nremburn - user.visible_message("[user] bandages the wounds on [H]'s [E.name] with the remaining bandages.", \ - "You bandages the wounds on [H]'s [E.name] with the remaining bandages." ) + heal(H, user) + H.UpdateDamageIcon() use(1) else @@ -151,6 +158,7 @@ singular_name = "ointment" icon_state = "ointment" origin_tech = "biotech=2" + healverb = "salve" /obj/item/stack/medical/ointment/attack(mob/living/M, mob/user) if(..()) @@ -163,29 +171,8 @@ if(affecting.open == 0) affecting.germ_level = 0 - user.visible_message("[user] salves the wounds on [H]'s [affecting.name].", \ - "You salves the wounds on [H]'s [affecting.name]." ) + heal(H, user) - var/rembrute = max(0, heal_brute - affecting.brute_dam) - var/remburn = max(0, heal_burn - affecting.burn_dam) - var/nrembrute = rembrute - var/nremburn = remburn - affecting.heal_damage(heal_brute, heal_burn) - if(affecting.body_part in list(ARM_LEFT, ARM_RIGHT, LEG_LEFT, LEG_RIGHT, UPPER_TORSO, LOWER_TORSO)) - for(var/obj/item/organ/external/E in affecting.children) - if(rembrute <= 0 && remburn <= 0) // Make sure there's actually overheal left and the organ is damaged before bothering - break - else if(E.status && ORGAN_ROBOT || E.open == 1) // Ignore robotic or open limb - continue - else if(E.brute_dam == 0 && E.burn_dam == 0) // Ignore undamaged limb - continue - nrembrute = rembrute - E.brute_dam // Deduct the healed damage from the remain - nremburn = remburn - E.burn_dam - E.heal_damage(rembrute, remburn) - rembrute = nrembrute - remburn = nremburn - user.visible_message("[user] salves the wounds on [H]'s [E.name] with the remaining ointment.", \ - "You salve the wounds on [H]'s [E.name] with the remaining ointment." ) H.UpdateDamageIcon() use(1) else