diff --git a/code/game/objects/items/weapons/tools.dm b/code/game/objects/items/weapons/tools.dm index 43904d27359..08a6a3e168c 100644 --- a/code/game/objects/items/weapons/tools.dm +++ b/code/game/objects/items/weapons/tools.dm @@ -1,3 +1,5 @@ +#define HEALPERWELD 15 + /* Tools! * Note: Multitools are in devices * @@ -407,24 +409,47 @@ to_chat(user, "Turn on [src] before attempting repairs!") return 1 - if(S.brute_dam) - if(S.brute_dam < ROBOLIMB_SELF_REPAIR_CAP) - if(get_fuel() >= 1) - if(H == user) - if(!do_mob(user, H, 10)) - return 1 - if(remove_fuel(1,null)) - playsound(src.loc, usesound, 50, 1) - S.heal_damage(15,0,0,1) - user.visible_message("\The [user] patches some dents on \the [M]'s [S.name] with \the [src].") - else if(S.open != 2) - to_chat(user, "Need more welding fuel!") - return 1 - else - to_chat(user, "The damage is far too severe to patch over externally.") - return 1 - else if(S.open != 2) + if(S.brute_dam > ROBOLIMB_SELF_REPAIR_CAP) + to_chat(user, "The damage is far too severe to patch over externally.") + return + + if(!S.brute_dam) to_chat(user, "Nothing to fix!") + return + + if(get_fuel() >= 1) + if(H == user) + if(!do_mob(user, H, 10)) + return 1 + if(!remove_fuel(1,null)) + to_chat(user, "Need more welding fuel!") + var/rembrute = HEALPERWELD + var/nrembrute = 0 + var/childlist + if(!isnull(S.children)) + childlist = S.children.Copy() + var/parenthealed = FALSE + while(rembrute > 0) + var/obj/item/organ/external/E + if(S.brute_dam) + E = S + else if(LAZYLEN(childlist)) + E = pick_n_take(childlist) + if(!E.brute_dam || !E.is_robotic()) + continue + else if(S.parent && !parenthealed) + E = S.parent + parenthealed = TRUE + if(!E.brute_dam || !E.is_robotic()) + break + else + break + playsound(src.loc, usesound, 50, 1) + nrembrute = max(rembrute - E.brute_dam, 0) + E.heal_damage(rembrute,0,0,1) + rembrute = nrembrute + user.visible_message("\The [user] patches some dents on \the [M]'s [E.name] with \the [src].") + return 1 else return ..() diff --git a/code/modules/power/cable.dm b/code/modules/power/cable.dm index ae64d5d4d6e..e9190835b35 100644 --- a/code/modules/power/cable.dm +++ b/code/modules/power/cable.dm @@ -1,3 +1,5 @@ +#define HEALPERCABLE 3 +#define MAXCABLEPERHEAL 8 /////////////////////////////// //CABLE STRUCTURE /////////////////////////////// @@ -531,23 +533,44 @@ var/global/list/datum/stack_recipe/cable_coil_recipes = list( if(!S.is_robotic() || user.a_intent != INTENT_HELP || S.open == 2) return ..() - if(S.burn_dam) - if(S.burn_dam < ROBOLIMB_SELF_REPAIR_CAP) - if(H == user) - if(!do_mob(user, H, 10)) - return 1 - var/cable_to_use = 0 - for(cable_to_use in 1 to 5) - if(cable_to_use == amount || (cable_to_use * 3) >= S.burn_dam) - break - use(cable_to_use) - S.heal_damage(0, (cable_to_use * 3), 0, 1) - user.visible_message("\The [user] repairs some burn damage on \the [M]'s [S.name] with \the [src].") - else if(S.open != 2) - to_chat(user, "The damage is far too severe to patch over externally.") - return 1 - else if(S.open != 2) + if(S.burn_dam > ROBOLIMB_SELF_REPAIR_CAP) + to_chat(user, "The damage is far too severe to patch over externally.") + return + + if(!S.burn_dam) to_chat(user, "Nothing to fix!") + return + + if(H == user) + if(!do_mob(user, H, 10)) + return 0 + var/cable_used = 0 + var/childlist + if(!isnull(S.children)) + childlist = S.children.Copy() + var/parenthealed = FALSE + while(cable_used <= MAXCABLEPERHEAL && amount >= 1) + var/obj/item/organ/external/E + if(S.burn_dam) + E = S + else if(LAZYLEN(childlist)) + E = pick_n_take(childlist) + if(!E.burn_dam || !E.is_robotic()) + continue + else if(S.parent && !parenthealed) + E = S.parent + parenthealed = TRUE + if(!E.burn_dam || !E.is_robotic()) + break + else + break + while(cable_used <= MAXCABLEPERHEAL && E.burn_dam && amount >= 1) + use(1) + cable_used += 1 + E.heal_damage(0, HEALPERCABLE, 0, 1) + user.visible_message("\The [user] repairs some burn damage on \the [M]'s [E.name] with \the [src].") + return 1 + else return ..() @@ -820,3 +843,6 @@ var/global/list/datum/stack_recipe/cable_coil_recipes = list( var/cablecolor = input(user,"Pick a cable color.","Cable Color") in list("red","yellow","green","blue","pink","orange","cyan","white") color = cablecolor update_icon() + +#undef MAXCABLEPERHEAL +#undef HEALPERCABLE