From 69ef67dd7904bf36300f4a3f30b9a4ff4f831f85 Mon Sep 17 00:00:00 2001 From: Qwertytoforty <52090703+Qwertytoforty@users.noreply.github.com> Date: Wed, 25 Nov 2020 23:56:58 -0500 Subject: [PATCH] Allows nanopaste to repair machinery (#14977) * Allows nanopaste to repair machinery * Apply suggestions from code review Co-authored-by: Farie82 * Henks other requests * Apply suggestions from code review Co-authored-by: Farie82 * Henks other other request * more nanopaste requests Co-authored-by: Farie82 --- code/game/machinery/machinery.dm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index b9eb3f5dd70..a0f9aa18a2c 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -126,6 +126,8 @@ Class Procs: var/frequency = NONE /// A reference to a `datum/radio_frequency`. Gives the machine the ability to interact with things using radio signals. var/datum/radio_frequency/radio_connection + /// This is if the machinery is being repaired + var/being_repaired = FALSE /* * reimp, attempts to flicker this machinery if the behavior is supported. @@ -476,6 +478,34 @@ Class Procs: if(.) power_change() +/obj/machinery/attackby(obj/item/O, mob/user, params) + if(istype(O, /obj/item/stack/nanopaste)) + var/obj/item/stack/nanopaste/N = O + if(stat & BROKEN) + to_chat(user, "[src] is too damaged to be fixed with nanopaste!") + return + if(obj_integrity == max_integrity) + to_chat(user, "[src] is fully intact.") + return + if(being_repaired) + return + if(N.get_amount() < 1) + to_chat(user, "You don't have enough to complete this task!") + return + to_chat(user, "You start applying [O] to [src].") + being_repaired = TRUE + var/result = do_after(user, 3 SECONDS, target = src) + being_repaired = FALSE + if(!result) + return + if(!N.use(1)) + to_chat(user, "You don't have enough to complete this task!") // this is here, as we don't want to use nanopaste until you finish applying + return + obj_integrity = min(obj_integrity + 50, max_integrity) + user.visible_message("[user] applied some [O] at [src]'s damaged areas.",\ + "You apply some [O] at [src]'s damaged areas.") + else + return ..() /obj/machinery/proc/exchange_parts(mob/user, obj/item/storage/part_replacer/W) var/shouldplaysound = 0 if((flags & NODECONSTRUCT))