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..152788c3e433 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,34 @@ 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) + 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() + + // update the APC icon to show the three base states // also add overlays for indicator lights /obj/machinery/power/apc/update_icon() 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)