From efec038554ca76954374d4be23818dbc1b070ca4 Mon Sep 17 00:00:00 2001 From: Bokkiewokkie <43698041+Bokkiewokkie@users.noreply.github.com> Date: Fri, 25 Aug 2023 18:52:29 +0200 Subject: [PATCH] Fixes plasma constrictors not rotating and misc additions (#2509) --- nsv13.dme | 1 + .../components/binary_devices/constrictor.dm | 163 ++++++++++++++++++ nsv13/code/modules/power/stormdrive.dm | 125 +------------- 3 files changed, 168 insertions(+), 121 deletions(-) create mode 100644 nsv13/code/modules/atmospherics/machinery/components/binary_devices/constrictor.dm diff --git a/nsv13.dme b/nsv13.dme index 7cc3e96c69a..fb2582598ce 100644 --- a/nsv13.dme +++ b/nsv13.dme @@ -3839,6 +3839,7 @@ #include "nsv13\code\modules\antagonists\boarders\boarders.dm" #include "nsv13\code\modules\antagonists\boarders\pirate_boarders.dm" #include "nsv13\code\modules\atmospherics\gasmixtures\reactions.dm" +#include "nsv13\code\modules\atmospherics\machinery\components\binary_devices\constrictor.dm" #include "nsv13\code\modules\atmospherics\machinery\components\unary_devices\tank.dm" #include "nsv13\code\modules\cargo\mission_rewards.dm" #include "nsv13\code\modules\cargo\objective_cargo.dm" diff --git a/nsv13/code/modules/atmospherics/machinery/components/binary_devices/constrictor.dm b/nsv13/code/modules/atmospherics/machinery/components/binary_devices/constrictor.dm new file mode 100644 index 00000000000..0894c99c5e3 --- /dev/null +++ b/nsv13/code/modules/atmospherics/machinery/components/binary_devices/constrictor.dm @@ -0,0 +1,163 @@ + +////// Magnetic Constrictors////// + +/obj/machinery/atmospherics/components/binary/magnetic_constrictor //This heats the plasma up to acceptable levels for use in the reactor. + name = "magnetic constrictor" + desc = "A large magnet which is capable of pressurizing plasma into a more energetic state. It is able to self-regulate its plasma input valve, as long as plasma is supplied to it." + icon = 'nsv13/icons/obj/machinery/reactor_parts.dmi' + icon_state = "constrictor" + density = TRUE + circuit = /obj/item/circuitboard/machine/magnetic_constrictor + layer = OBJ_LAYER + pipe_flags = PIPING_ONE_PER_TURF + active_power_usage = 200 + interaction_flags_atom = INTERACT_ATOM_ATTACK_HAND | INTERACT_ATOM_UI_INTERACT | INTERACT_MACHINE_ALLOW_SILICON + var/emagged = FALSE + var/constriction_rate = 0 //SSAtmos is 4x faster than SSMachines aka the reactor + var/max_output_pressure = 0 + +/obj/machinery/atmospherics/components/binary/magnetic_constrictor/on_construction() + var/obj/item/circuitboard/machine/thermomachine/board = circuit + if(board) + piping_layer = board.pipe_layer + ..(dir, piping_layer) + +/obj/machinery/atmospherics/components/binary/magnetic_constrictor/RefreshParts() + var/A + for(var/obj/item/stock_parts/capacitor/C in component_parts) + A += C.rating + constriction_rate = 0.9 + (0.1 * A) + var/B + for(var/obj/item/stock_parts/manipulator/M in component_parts) + B += M.rating + max_output_pressure = 100 + (100 * B) + +/obj/machinery/atmospherics/components/binary/magnetic_constrictor/interact(mob/user) + if(!can_interact(user)) + return + to_chat(user, "You turn on \the [src].") + on = !on + update_icon() + +/obj/machinery/atmospherics/components/binary/magnetic_constrictor/process_atmos() + ..() + if(!on) + return + var/datum/gas_mixture/air1 = airs[1] + var/datum/gas_mixture/air2 = airs[2] + var/output_starting_pressure = air2.return_pressure() + if(output_starting_pressure >= max_output_pressure) + return + var/plasma_moles = air1.get_moles(GAS_PLASMA) + var/plasma_transfer_moles = min(constriction_rate, plasma_moles) + var/plasma_temperature = air1.return_temperature() + if(!plasma_moles) + return + + var/plasma_threshold + if(emagged) //Something's not right... + plasma_transfer_moles -= 0.1 + if(plasma_transfer_moles > 0) + var/turf/open/T = isopenturf(get_turf(src)) ? get_turf(src) : null + if(T) + plasma_threshold = TRUE + T.air.adjust_moles_temp(GAS_CONSTRICTED_PLASMA, 0.1, plasma_temperature) + else + plasma_transfer_moles += 0.1 + else + plasma_transfer_moles += 0.1 + + air2.adjust_moles_temp(GAS_CONSTRICTED_PLASMA, plasma_transfer_moles, plasma_temperature) + + if(emagged && plasma_threshold) //Still remove the proper amount of plasma + plasma_transfer_moles += 0.1 + plasma_threshold = FALSE + + air1.adjust_moles(GAS_PLASMA, -plasma_transfer_moles) + update_parents() + +/obj/machinery/atmospherics/components/binary/magnetic_constrictor/crowbar_act(mob/user, obj/item/I) + default_deconstruction_crowbar(I) + return TRUE + +/obj/machinery/atmospherics/components/binary/magnetic_constrictor/screwdriver_act(mob/user, obj/item/I) + if(..()) + return TRUE + if(on) + to_chat(user, "You must turn off [src] before opening the panel.") + return FALSE + panel_open = !panel_open + I.play_tool_sound(src) + to_chat(user, "You [panel_open?"open":"close"] the panel on [src].") + update_icon() + return TRUE + +/obj/machinery/atmospherics/components/binary/magnetic_constrictor/wrench_act(mob/user, obj/item/I) + if(default_change_direction_wrench(user, I) && panel_open) + I.play_tool_sound(src) + var/obj/machinery/atmospherics/node1 = nodes[1] + var/obj/machinery/atmospherics/node2 = nodes[2] + if(node2) + node2.disconnect(src) + nodes[2] = null + nullifyPipenet(parents[2]) + if(node1) + node1.disconnect(src) + nodes[1] = null + nullifyPipenet(parents[1]) + + SetInitDirections() + atmosinit() + node1 = nodes[1] + if(node1) + node1.atmosinit() + node1.addMember(src) + node2 = nodes[2] + if(node2) + node2.atmosinit() + node2.addMember(src) + SSair.add_to_rebuild_queue(src) + update_icon(TRUE) + return TRUE + +/obj/machinery/atmospherics/components/binary/magnetic_constrictor/update_icon() + cut_overlays() + if(panel_open) + icon_state = "constrictor_screw" + else if(on) + icon_state = "constrictor_active" + else + icon_state = "constrictor" + pixel_y = 0 + pixel_x = 0 + PIPING_LAYER_SHIFT(src, piping_layer) + +/obj/machinery/atmospherics/components/binary/magnetic_constrictor/emag_act(mob/user) + obj_flags |= EMAGGED + emagged = TRUE + to_chat(user, "You overload [src]'s hydraulics.") + audible_message("\The [src] makes a mechanical sound.") + visible_message("Some bolts fall off \the [src]!") + log_combat(user, src, "emagged") + +/obj/item/circuitboard/machine/magnetic_constrictor + name = "Magnetic Constrictor (Machine Board)" + build_path = /obj/machinery/atmospherics/components/binary/magnetic_constrictor + var/pipe_layer = PIPING_LAYER_DEFAULT + req_components = list( + /obj/item/stock_parts/capacitor = 1, + /obj/item/stock_parts/manipulator = 1) + +/obj/item/circuitboard/machine/magnetic_constrictor/multitool_act(mob/living/user, obj/item/I) + . = ..() + if(I.tool_behaviour == TOOL_MULTITOOL) + pipe_layer = (pipe_layer >= PIPING_LAYER_MAX) ? PIPING_LAYER_MIN : (pipe_layer + 1) + to_chat(user, "You change the circuitboard to layer [pipe_layer].") + +/datum/design/board/magnetic_constrictor + name = "Machine Design (Magnetic Constrictor Board)" + desc = "The circuit board for a Magnetic Constrictor." + id = "mag_cons" + build_path = /obj/item/circuitboard/machine/magnetic_constrictor + category = list("Engineering Machinery") + departmental_flags = DEPARTMENTAL_FLAG_ENGINEERING diff --git a/nsv13/code/modules/power/stormdrive.dm b/nsv13/code/modules/power/stormdrive.dm index dcf3ee6933c..4d35c16cfca 100644 --- a/nsv13/code/modules/power/stormdrive.dm +++ b/nsv13/code/modules/power/stormdrive.dm @@ -1416,128 +1416,11 @@ Control Rods departmental_flags = DEPARTMENTAL_FLAG_ENGINEERING /datum/techweb_node/stormdrive_reactor_control - id = "sd_r_c_c" - display_name = "Seegson RBMK RCC" - description = "Seegson's latest and greatest (within your budget range) reactor control design!" - prereq_ids = list("adv_engi", "adv_power") - design_ids = list("sd_r_c_c") - research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 2500) - export_price = 5000 - -////// Magnetic Constrictors////// - -/obj/machinery/atmospherics/components/binary/magnetic_constrictor //This heats the plasma up to acceptable levels for use in the reactor. - name = "magnetic constrictor" - desc = "A large magnet which is capable of pressurizing plasma into a more energetic state. It is able to self-regulate its plasma input valve, as long as plasma is supplied to it." - icon = 'nsv13/icons/obj/machinery/reactor_parts.dmi' - icon_state = "constrictor" - density = TRUE - circuit = /obj/item/circuitboard/machine/magnetic_constrictor - layer = OBJ_LAYER - pipe_flags = PIPING_ONE_PER_TURF - active_power_usage = 200 - var/constriction_rate = 0 //SSAtmos is 4x faster than SSMachines aka the reactor - var/max_output_pressure = 0 - -/obj/machinery/atmospherics/components/binary/magnetic_constrictor/on_construction() - var/obj/item/circuitboard/machine/thermomachine/board = circuit - if(board) - piping_layer = board.pipe_layer - ..(dir, piping_layer) - -/obj/machinery/atmospherics/components/binary/magnetic_constrictor/RefreshParts() - var/A - for(var/obj/item/stock_parts/capacitor/C in component_parts) - A += C.rating - constriction_rate = 0.9 + (0.1 * A) - var/B - for(var/obj/item/stock_parts/manipulator/M in component_parts) - B += M.rating - max_output_pressure = 100 + (100 * B) - -/obj/machinery/atmospherics/components/binary/magnetic_constrictor/attack_hand(mob/user) - . = ..() - if(panel_open) - to_chat(user, "You must turn close the panel on [src] before turning it on.") - return - to_chat(user, "You press [src]'s power button.") - on = !on - update_icon() - -/obj/machinery/atmospherics/components/binary/magnetic_constrictor/ComponentInitialize() - . = ..() - AddComponent(/datum/component/simple_rotation,ROTATION_ALTCLICK | ROTATION_CLOCKWISE | ROTATION_COUNTERCLOCKWISE | ROTATION_VERBS ) - -/obj/machinery/atmospherics/components/binary/magnetic_constrictor/process_atmos() - ..() - if(!on) - return - var/datum/gas_mixture/air1 = airs[1] - var/datum/gas_mixture/air2 = airs[2] - var/output_starting_pressure = air2.return_pressure() - if(output_starting_pressure >= max_output_pressure) - return - var/plasma_moles = air1.get_moles(GAS_PLASMA) - var/plasma_transfer_moles = min(constriction_rate, plasma_moles) - air2.adjust_moles(GAS_CONSTRICTED_PLASMA, plasma_transfer_moles) - air2.set_temperature(air1.return_temperature()) - air1.adjust_moles(GAS_PLASMA, -plasma_transfer_moles) - update_parents() - -/obj/machinery/atmospherics/components/binary/magnetic_constrictor/crowbar_act(mob/user, obj/item/I) - default_deconstruction_crowbar(I) - return TRUE - -/obj/machinery/atmospherics/components/binary/magnetic_constrictor/screwdriver_act(mob/user, obj/item/I) - if(..()) - return TRUE - if(on) - to_chat(user, "You must turn off [src] before opening the panel.") - return FALSE - panel_open = !panel_open - I.play_tool_sound(src) - to_chat(user, "You [panel_open?"open":"close"] the panel on [src].") - update_icon() - return TRUE - -/obj/machinery/atmospherics/components/binary/magnetic_constrictor/update_icon() - cut_overlays() - if(panel_open) - icon_state = "constrictor_screw" - else if(on) - icon_state = "constrictor_active" - else - icon_state = "constrictor" - -/obj/item/circuitboard/machine/magnetic_constrictor - name = "Magnetic Constrictor (Machine Board)" - build_path = /obj/machinery/atmospherics/components/binary/magnetic_constrictor - var/pipe_layer = PIPING_LAYER_DEFAULT - req_components = list( - /obj/item/stock_parts/capacitor = 1, - /obj/item/stock_parts/manipulator = 1) - -/obj/item/circuitboard/machine/magnetic_constrictor/attackby(obj/item/I, mob/user, params) - if(I.tool_behaviour == TOOL_MULTITOOL) - pipe_layer = (pipe_layer >= PIPING_LAYER_MAX) ? PIPING_LAYER_MIN : (pipe_layer + 1) - to_chat(user, "You change the circuitboard to layer [pipe_layer].") - return - . = ..() - -/datum/design/board/magnetic_constrictor - name = "Machine Design (Magnetic Constrictor Board)" - desc = "The circuit board for a Magnetic Constrictor." - id = "mag_cons" - build_path = /obj/item/circuitboard/machine/magnetic_constrictor - category = list("Engineering Machinery") - departmental_flags = DEPARTMENTAL_FLAG_ENGINEERING - -/datum/techweb_node/magnetic_constrictor - id = "mag_cons" - display_name = "Magnetic Constriction of Plasma" - description = "Beating plasma into submission - a guide." + id = "sd_rcc+cons" + display_name = "Seegson Storm Drive Machinery" + description = "Seegson's latest and greatest (within your budget range) reactor control and plasma constriction designs!" prereq_ids = list("adv_engi", "adv_power") - design_ids = list("mag_cons") + design_ids = list("sd_r_c_c", "mag_cons") research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 2500) export_price = 5000