From ce084c2877e486089d312c64f0559492801079d5 Mon Sep 17 00:00:00 2001 From: Lucy Date: Sun, 6 Mar 2022 16:46:45 -0500 Subject: [PATCH 1/3] RPEDs now work on APCs --- code/game/machinery/_machinery.dm | 1 + code/modules/power/apc.dm | 28 +++++++++++++++++++++++++++- code/modules/research/stock_parts.dm | 4 ++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/code/game/machinery/_machinery.dm b/code/game/machinery/_machinery.dm index 8b02fea64e09..59c1d762a422 100644 --- a/code/game/machinery/_machinery.dm +++ b/code/game/machinery/_machinery.dm @@ -108,6 +108,7 @@ Class Procs: var/wire_compatible = FALSE var/list/component_parts = null //list of all the parts used to build it, if made from certain kinds of frames. + var/works_with_rped_anyways = FALSE //whether it has special RPED behavior despite not having component parts var/panel_open = FALSE var/state_open = FALSE var/critical_machine = FALSE //If this machine is critical to station operation and should have the area be excempted from power failures. diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index ee1423af4898..05eb24a32d96 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -56,6 +56,7 @@ integrity_failure = 50 resistance_flags = FIRE_PROOF interaction_flags_machine = INTERACT_MACHINE_WIRES_IF_OPEN | INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OPEN_SILICON + works_with_rped_anyways = TRUE FASTDMM_PROP(\ set_instance_vars(\ pixel_x = dir == EAST ? 24 : (dir == WEST ? -25 : INSTANCE_VAR_DEFAULT),\ @@ -291,6 +292,31 @@ if(issilicon(user)) . += span_notice("Ctrl-Click the APC to switch the breaker [ operating ? "off" : "on"].") +/obj/machinery/power/apc/exchange_parts(mob/user, obj/item/storage/part_replacer/W) + if(!istype(W)) + return FALSE + if(!opened && !W.works_from_distance) + return FALSE + var/current_cell_rating = cell ? cell.get_part_rating() : -1 + var/best_cell_rating = current_cell_rating + var/obj/item/stock_parts/cell/best_cell + for(var/C in W.contents) + var/obj/item/stock_parts/cell/cell = C + if (!cell || !istype(cell)) + continue + var/cell_rating = cell.get_part_rating() + if (cell_rating > best_cell_rating || (cell_rating == best_cell_rating && cell.charge > best_cell.charge)) + best_cell_rating = cell_rating + best_cell = cell + if (best_cell) + if (cell) + SEND_SIGNAL(W, COMSIG_TRY_STORAGE_INSERT, cell, null, null, TRUE) + to_chat(user, span_notice("[capitalize(cell.name)] replaced with [best_cell.name].")) + best_cell.forceMove(src) + cell = best_cell + W.play_rped_sound() + + // update the APC icon to show the three base states // also add overlays for indicator lights /obj/machinery/power/apc/update_icon() @@ -299,7 +325,7 @@ // 2 if we need to update the overlays if(!update) icon_update_needed = FALSE - return + returnd if(update & 1) // Updating the icon state if(update_state & UPSTATE_ALLGOOD) diff --git a/code/modules/research/stock_parts.dm b/code/modules/research/stock_parts.dm index 8cf1fb8f6bef..c3f925588bba 100644 --- a/code/modules/research/stock_parts.dm +++ b/code/modules/research/stock_parts.dm @@ -15,7 +15,7 @@ If you create T5+ please take a pass at gene_modder.dm [L40]. Max_values MUST fi var/alt_sound = null /obj/item/storage/part_replacer/pre_attack(obj/machinery/T, mob/living/user, params) - if(!istype(T) || !T.component_parts) + if(!istype(T) || (!T.component_parts && !T.works_with_rped_anyways)) return ..() if(user.Adjacent(T)) // no TK upgrading. if(works_from_distance) @@ -25,7 +25,7 @@ If you create T5+ please take a pass at gene_modder.dm [L40]. Max_values MUST fi return ..() /obj/item/storage/part_replacer/afterattack(obj/machinery/T, mob/living/user, adjacent, params) - if(adjacent || !istype(T) || !T.component_parts) + if(adjacent || !istype(T) || (!T.component_parts && !T.works_with_rped_anyways)) return ..() if(works_from_distance) user.Beam(T, icon_state = "rped_upgrade", time = 5) From 933804dfdbe08bfb61fc7eb2737ec8f07b989744 Mon Sep 17 00:00:00 2001 From: Lucy Date: Sun, 6 Mar 2022 16:50:45 -0500 Subject: [PATCH 2/3] The new cell is now recharged by the old cell --- code/modules/power/apc.dm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 05eb24a32d96..9791de6473f5 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -313,6 +313,9 @@ SEND_SIGNAL(W, COMSIG_TRY_STORAGE_INSERT, cell, null, null, TRUE) to_chat(user, span_notice("[capitalize(cell.name)] replaced with [best_cell.name].")) best_cell.forceMove(src) + var/amount_to_charge = min(best_cell.maxcharge - best_cell.charge, cell.charge) + if (cell.use(amount_to_charge)) + best_cell.give(amount_to_charge) cell = best_cell W.play_rped_sound() From 9bcb350648a96863a9b62c27687212d6fe8680a4 Mon Sep 17 00:00:00 2001 From: Lucy Date: Sun, 6 Mar 2022 16:52:36 -0500 Subject: [PATCH 3/3] Fix weird typo --- code/modules/power/apc.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 9791de6473f5..152788c3e433 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -328,7 +328,7 @@ // 2 if we need to update the overlays if(!update) icon_update_needed = FALSE - returnd + return if(update & 1) // Updating the icon state if(update_state & UPSTATE_ALLGOOD)