From aa6d82f37efa1d5e34e5f906bd149a3a6eebc256 Mon Sep 17 00:00:00 2001 From: moocowswag <62126254+moocowswag@users.noreply.github.com> Date: Thu, 25 May 2023 14:09:37 -0400 Subject: [PATCH] Apc covers can now be repaired and replaced (#75129) You can now weld an unbroken but damaged Apc cover in order to repair its integrity. If an Apc cover is broken you can crowbar it off and replace it with a new one using an Apc frame (but you'll need to weld its integrity back up to reinforce the haphazard connections you've made) I also went ahead and added comments to some of the code because Apc code is a little daunting. --- code/game/objects/items/apc_frame.dm | 13 +++++++++++ code/modules/power/apc/apc_attack.dm | 4 +++- code/modules/power/apc/apc_main.dm | 5 ++++ code/modules/power/apc/apc_tool_act.dm | 32 ++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/code/game/objects/items/apc_frame.dm b/code/game/objects/items/apc_frame.dm index 97770c2fff5..9edeca9411e 100644 --- a/code/game/objects/items/apc_frame.dm +++ b/code/game/objects/items/apc_frame.dm @@ -25,3 +25,16 @@ to_chat(user, span_notice("You cut the cables and disassemble the unused power terminal.")) qdel(E) return TRUE + +/obj/item/wallframe/apc/screwdriver_act(mob/living/user, obj/item/tool) + //overriding the wallframe parent screwdriver act with this one which allows applying to existing apc frames. + + var/turf/T = get_step(get_turf(user), user.dir) + if(iswallturf(T)) + if(locate(/obj/machinery/power/apc) in get_turf(user)) + var/obj/machinery/power/apc/mounted_apc = locate(/obj/machinery/power/apc) in get_turf(user) + mounted_apc.attackby(src, user) + return TOOL_ACT_TOOLTYPE_SUCCESS + T.attackby(src, user) + return TOOL_ACT_TOOLTYPE_SUCCESS + diff --git a/code/modules/power/apc/apc_attack.dm b/code/modules/power/apc/apc_attack.dm index 79ef84cac4d..178d3fecac5 100644 --- a/code/modules/power/apc/apc_attack.dm +++ b/code/modules/power/apc/apc_attack.dm @@ -139,12 +139,14 @@ if(!(machine_stat & BROKEN || opened == APC_COVER_REMOVED || atom_integrity < max_integrity)) // There is nothing to repair balloon_alert(user, "no reason for repairs!") return - if(!(machine_stat & BROKEN) && opened == APC_COVER_REMOVED) // Cover is the only thing broken, we do not need to remove elctronicks to replace cover + if((machine_stat & BROKEN) && opened == APC_COVER_REMOVED && has_electronics && terminal) // Cover is the only thing broken, we do not need to remove elctronicks to replace cover user.visible_message(span_notice("[user.name] replaces missing APC's cover.")) balloon_alert(user, "replacing APC's cover...") if(do_after(user, 20, target = src)) // replacing cover is quicker than replacing whole frame balloon_alert(user, "cover replaced") qdel(attacking_object) + update_integrity(30) //needs to be welded to fully repair but can work without + set_machine_stat(machine_stat & ~(BROKEN|MAINT)) opened = APC_COVER_OPENED update_appearance() return diff --git a/code/modules/power/apc/apc_main.dm b/code/modules/power/apc/apc_main.dm index 322792d7aa3..59fa92aba32 100644 --- a/code/modules/power/apc/apc_main.dm +++ b/code/modules/power/apc/apc_main.dm @@ -264,6 +264,11 @@ /obj/machinery/power/apc/examine(mob/user) . = ..() if(machine_stat & BROKEN) + if(opened != APC_COVER_REMOVED) + . += "The cover is broken and can probably be pried off with enough force." + return + if(terminal && has_electronics) + . += "The cover is missing but can be replaced using a new frame." return if(opened) if(has_electronics && terminal) diff --git a/code/modules/power/apc/apc_tool_act.dm b/code/modules/power/apc/apc_tool_act.dm index 0c1cf6652a2..1a645c4ebe2 100644 --- a/code/modules/power/apc/apc_tool_act.dm +++ b/code/modules/power/apc/apc_tool_act.dm @@ -1,6 +1,19 @@ //attack with an item - open/close cover, insert cell, or (un)lock interface /obj/machinery/power/apc/crowbar_act(mob/user, obj/item/crowbar) . = TRUE + + //Prying off broken cover + if((opened == APC_COVER_CLOSED || opened == APC_COVER_OPENED) && (machine_stat & BROKEN)) + crowbar.play_tool_sound(src) + balloon_alert(user, "prying...") + if(!crowbar.use_tool(src, user, 5 SECONDS)) + return + opened = APC_COVER_REMOVED + balloon_alert(user, "cover removed") + update_appearance() + return + + //Opening and closing cover if((!opened && opened != APC_COVER_REMOVED) && !(machine_stat & BROKEN)) if(coverlocked && !(machine_stat & MAINT)) // locked... balloon_alert(user, "cover is locked!") @@ -20,6 +33,7 @@ update_appearance() return + //Taking out the electronics if(!opened || has_electronics != APC_ELECTRONICS_INSTALLED) return if(terminal) @@ -101,6 +115,24 @@ /obj/machinery/power/apc/welder_act(mob/living/user, obj/item/welder) . = ..() + + //repairing the cover + if((atom_integrity < max_integrity) && has_electronics) + if(opened == APC_COVER_REMOVED) + balloon_alert(user, "no cover to repair!") + return + if (machine_stat & BROKEN) + balloon_alert(user, "too damaged to repair!") + return + if(!welder.tool_start_check(user, amount=0)) + return + balloon_alert(user, "repairing...") + if(welder.use_tool(src, user, 4 SECONDS, volume = 50)) + update_integrity(min(atom_integrity += 50,max_integrity)) + balloon_alert(user, "repaired") + return TOOL_ACT_TOOLTYPE_SUCCESS + + //disassembling the frame if(!opened || has_electronics || terminal) return if(!welder.tool_start_check(user, amount=3))