From 657d6fe275135fc41a9be186e05c884185dc447d Mon Sep 17 00:00:00 2001 From: Ansari Date: Sun, 20 May 2018 19:40:52 +0800 Subject: [PATCH 1/8] Leftover healing is now split onto logical limbs --- code/game/objects/items/stacks/medical.dm | 41 +++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index 3ffdfaaf751..b4d5a66ca39 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -104,7 +104,27 @@ 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)) + 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." ) H.UpdateDamageIcon() use(1) else @@ -143,9 +163,26 @@ if(affecting.open == 0) affecting.germ_level = 0 - user.visible_message("[user] salves the wounds on [H]'s [affecting.name].", \ - "You salve 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)) + 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 From ca1784d39431a2118054642e458c97a15e0240a3 Mon Sep 17 00:00:00 2001 From: Ansari Date: Sun, 20 May 2018 20:05:22 +0800 Subject: [PATCH 2/8] Fixes missing message for burn kit --- code/game/objects/items/stacks/medical.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index b4d5a66ca39..235e94fe05f 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -163,6 +163,9 @@ 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]." ) + var/rembrute = max(0, heal_brute - affecting.brute_dam) var/remburn = max(0, heal_burn - affecting.burn_dam) var/nrembrute = rembrute From 43cefbcf715041baa17446fbe51dfad26cd09245 Mon Sep 17 00:00:00 2001 From: Ansari Date: Sun, 20 May 2018 20:51:52 +0800 Subject: [PATCH 3/8] No longer discriminates against the lower body --- code/game/objects/items/stacks/medical.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index 235e94fe05f..d7ef2969bf6 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -110,7 +110,7 @@ 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)) + 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 @@ -171,7 +171,7 @@ 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)) + 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 From 1cc1e30c54c080aef45791759b6ce01af88fa401 Mon Sep 17 00:00:00 2001 From: Ansari Date: Mon, 21 May 2018 08:01:57 +0800 Subject: [PATCH 4/8] 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 From 25dd0feda24c0da8a6f9a7cf9549a85d4bf942e7 Mon Sep 17 00:00:00 2001 From: Ansari Date: Mon, 21 May 2018 08:02:36 +0800 Subject: [PATCH 5/8] Use !E.brutedam instead of == 0 --- code/game/objects/items/stacks/medical.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index 00388d7e40b..846da0b61aa 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -95,7 +95,7 @@ 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 + else if(!E.brute_dam && !E.burn_dam) // Ignore undamaged limb continue nrembrute = rembrute - E.brute_dam // Deduct the healed damage from the remain nremburn = remburn - E.burn_dam From b6272b50fc2f1f4977589266d7435412651b2c3b Mon Sep 17 00:00:00 2001 From: Anasari <13087574+Anasari@users.noreply.github.com> Date: Wed, 13 Jun 2018 13:41:27 +0800 Subject: [PATCH 6/8] Changes the code to work more flexibly --- code/game/objects/items/stacks/medical.dm | 38 ++++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index 846da0b61aa..c8852dd2d3a 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -89,21 +89,29 @@ 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 && !E.burn_dam) // 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." ) + var/list/achildlist = affecting.children.Copy() + var/parenthealed = 0 + while(rembrute + remburn > 0): // Don't bother if there's not enough leftover heal + var/obj/item/organ/external/E + if(achildlist.len): + E = pick(achildlist) // Pick a random children + achildlist -= E + else if(affecting.parent && !parenthealed): // If there's a parent and no healing attempt was made on it + E = affecting.parent + parenthealed = 1 + else: + break // If the organ have no child left and no parent / parent healed, break + if(E.status & ORGAN_ROBOT || E.open) // Ignore robotic or open limb + continue + else if(!E.brute_dam && !E.burn_dam) // 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// From 1beb0c275ed32645c16a5f6332fad9c734fe4268 Mon Sep 17 00:00:00 2001 From: Anasari <13087574+Anasari@users.noreply.github.com> Date: Sun, 1 Jul 2018 15:38:05 +0800 Subject: [PATCH 7/8] Fixes colons and other things --- code/game/objects/items/stacks/medical.dm | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index c8852dd2d3a..856e2c9a0eb 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -84,22 +84,21 @@ 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/rembrute = max(0, heal_brute - affecting.brute_dam) // Maxed with 0 since heal_damage let you pass in a negative value + var/remburn = max(0, heal_burn - affecting.burn_dam) // And deduct it from their health (aka deal damage) var/nrembrute = rembrute - var/nremburn = remburn + var/nremburn = remburn affecting.heal_damage(heal_brute, heal_burn) var/list/achildlist = affecting.children.Copy() - var/parenthealed = 0 - while(rembrute + remburn > 0): // Don't bother if there's not enough leftover heal + var/parenthealed = FALSE + while(rembrute + remburn > 0) // Don't bother if there's not enough leftover heal var/obj/item/organ/external/E - if(achildlist.len): - E = pick(achildlist) // Pick a random children - achildlist -= E - else if(affecting.parent && !parenthealed): // If there's a parent and no healing attempt was made on it + if(achildlist.len) + E = pick_n_take(achildlist) // Pick a random children and then remove it from the list + else if(affecting.parent && !parenthealed) // If there's a parent and no healing attempt was made on it E = affecting.parent - parenthealed = 1 - else: + parenthealed = TRUE + else break // If the organ have no child left and no parent / parent healed, break if(E.status & ORGAN_ROBOT || E.open) // Ignore robotic or open limb continue From 0fbec396c84183cd23b56142f990a9fd7d0f3904 Mon Sep 17 00:00:00 2001 From: Anasari <13087574+Anasari@users.noreply.github.com> Date: Sun, 1 Jul 2018 16:54:06 +0800 Subject: [PATCH 8/8] Fixes --- code/game/objects/items/stacks/medical.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index 856e2c9a0eb..92faa5cebfb 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -104,8 +104,8 @@ continue else if(!E.brute_dam && !E.burn_dam) // Ignore undamaged limb continue - nrembrute = rembrute - E.brute_dam // Deduct the healed damage from the remain - nremburn = remburn - E.burn_dam + nrembrute = max(0, rembrute - E.brute_dam) // Deduct the healed damage from the remain + nremburn = max(0, remburn - E.burn_dam) E.heal_damage(rembrute, remburn) rembrute = nrembrute remburn = nremburn