From d690e5b4fd48d0b4992efce017e23eb13493ee3a Mon Sep 17 00:00:00 2001 From: Harcourt1 Date: Tue, 2 Oct 2018 11:13:03 -0400 Subject: [PATCH] Fixes runtime when trying to work on missing limbs --- code/game/objects/items/stacks/medical.dm | 89 ++++++++++++----------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index 70c34824..3687d32a 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -172,52 +172,53 @@ if (istype(M, /mob/living/carbon/human)) var/mob/living/carbon/human/H = M var/obj/item/organ/external/affecting = H.get_organ(user.targeted_organ) - - if (affecting.open == FALSE) - if (affecting.is_bandaged() && affecting.is_disinfected()) - user << "The wounds on [M]'s [affecting.name] have already been treated." - return TRUE - else - user.visible_message("\The [user] starts treating [M]'s [affecting.name].", \ - "You start treating [M]'s [affecting.name]." ) - var/used = 0 - for (var/datum/wound/W in affecting.wounds) - if (W.internal) - continue - if (W.bandaged && W.disinfected) - continue + if (affecting == null) + if (affecting.open == FALSE) + if (affecting.is_bandaged() && affecting.is_disinfected()) + user << "The wounds on [M]'s [affecting.name] have already been treated." + return TRUE + else + user.visible_message("\The [user] starts treating [M]'s [affecting.name].", \ + "You start treating [M]'s [affecting.name]." ) + var/used = 0 + for (var/datum/wound/W in affecting.wounds) + if (W.internal) + continue + if (W.bandaged && W.disinfected) + continue + if (used == amount) + break + if (!do_mob(user, M, W.damage/5)) + user << "You must stand still to bandage wounds." + break + if (W.current_stage <= W.max_bleeding_stage) + user.visible_message("\The [user] cleans \a [W.desc] on [M]'s [affecting.name] and seals the edges with bioglue.", \ + "You clean and seal \a [W.desc] on [M]'s [affecting.name]." ) + else if (W.damage_type == BRUISE) + user.visible_message("\The [user] places a medical patch over \a [W.desc] on [M]'s [affecting.name].", \ + "You place a medical patch over \a [W.desc] on [M]'s [affecting.name]." ) + else + user.visible_message("\The [user] smears some bioglue over \a [W.desc] on [M]'s [affecting.name].", \ + "You smear some bioglue over \a [W.desc] on [M]'s [affecting.name]." ) + W.bandage() + W.disinfect() + W.heal_damage(heal_brute) + used++ + affecting.update_damages() if (used == amount) - break - if (!do_mob(user, M, W.damage/5)) - user << "You must stand still to bandage wounds." - break - if (W.current_stage <= W.max_bleeding_stage) - user.visible_message("\The [user] cleans \a [W.desc] on [M]'s [affecting.name] and seals the edges with bioglue.", \ - "You clean and seal \a [W.desc] on [M]'s [affecting.name]." ) - else if (W.damage_type == BRUISE) - user.visible_message("\The [user] places a medical patch over \a [W.desc] on [M]'s [affecting.name].", \ - "You place a medical patch over \a [W.desc] on [M]'s [affecting.name]." ) - else - user.visible_message("\The [user] smears some bioglue over \a [W.desc] on [M]'s [affecting.name].", \ - "You smear some bioglue over \a [W.desc] on [M]'s [affecting.name]." ) - W.bandage() - W.disinfect() - W.heal_damage(heal_brute) - used++ - affecting.update_damages() - if (used == amount) - if (affecting.is_bandaged()) - user << "\The [src] is used up." - else - user << "\The [src] is used up, but there are more wounds to treat on \the [affecting.name]." - use(used) - else - if (can_operate(H)) //Checks if mob is lying down on table for surgery - if (do_surgery(H,user,src)) - return + if (affecting.is_bandaged()) + user << "\The [src] is used up." + else + user << "\The [src] is used up, but there are more wounds to treat on \the [affecting.name]." + use(used) else - user << "The [affecting.name] is cut open, you'll need more than a bandage!" - + if (can_operate(H)) //Checks if mob is lying down on table for surgery + if (do_surgery(H,user,src)) + return + else + user << "The [affecting.name] is cut open, you'll need more than a bandage!" + else + user << "They dont have this limb!" var/mob/living/carbon/human/H_user = user if (istype(H_user) && H_user.getStatCoeff("medical") >= GET_MIN_STAT_COEFF(STAT_VERY_HIGH)) if (affecting.open == FALSE)