Skip to content

Commit

Permalink
Fixes plasma constrictors not rotating and misc additions (#2509)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bokkiewokkie committed Aug 25, 2023
1 parent f30c0fa commit efec038
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 121 deletions.
1 change: 1 addition & 0 deletions nsv13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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, "<span class='notice'>You turn on \the [src].</span>")
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, "<span class='notice'>You must turn off [src] before opening the panel.</span>")
return FALSE
panel_open = !panel_open
I.play_tool_sound(src)
to_chat(user, "<span class='notice'>You [panel_open?"open":"close"] the panel on [src].</span>")
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, "<span class='notice'>You overload [src]'s hydraulics.</span>")
audible_message("<span class='warning'>\The [src] makes a mechanical sound.</span>")
visible_message("<span class='warning'>Some bolts fall off \the [src]!</span>")
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, "<span class='notice'>You change the circuitboard to layer [pipe_layer].</span>")

/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
125 changes: 4 additions & 121 deletions nsv13/code/modules/power/stormdrive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<span class='notice'>You must turn close the panel on [src] before turning it on.</span>")
return
to_chat(user, "<span class='notice'>You press [src]'s power button.</span>")
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, "<span class='notice'>You must turn off [src] before opening the panel.</span>")
return FALSE
panel_open = !panel_open
I.play_tool_sound(src)
to_chat(user, "<span class='notice'>You [panel_open?"open":"close"] the panel on [src].</span>")
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, "<span class='notice'>You change the circuitboard to layer [pipe_layer].</span>")
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

Expand Down

0 comments on commit efec038

Please sign in to comment.