Files
Batrachophreno 4ecb0bc21c Repath obj/machinery to obj/structure/machinery [MDB Ignore] (#22500)
Repaths obj/machinery to obj/structure/machinery. **Note for
reviewers:** the only meaningful changed code exists within
**code/game/objects/structures.dm** and
**code/game/objects/structures/_machinery.dm**, largely concerning
damage procs. With the exception of moving airlock defines to their own
file, ALL OTHER CHANGES ARE STRICTLY PATH CHANGES.

Objects, _categorically_, are largely divided between those you can hold
in your hand/inventory and those you can't. Machinery objects are
already subtypes of Structures behaviorally, this PR just makes their
pathing reflect that, and allows for future work (tool actions, more
health/destruction functionality) to be developed without unnecessary
code duplication.

I have tested this PR by loading up the Horizon and dismantling various
machines and structures with tools, shooting guns of various types
throughout the ship, and detonating a bunch of explosions throughout the
ship.
2026-05-26 19:35:48 +00:00

118 lines
3.8 KiB
Plaintext

/obj/structure/machinery/power/tesla_coil
name = "tesla coil"
desc = "For the union!"
icon = 'icons/obj/tesla_engine/tesla_coil.dmi'
icon_state = "coil"
anchored = 0
density = 1
var/power_loss = 2
var/input_power_multiplier = 1
component_types = list(
/obj/item/circuitboard/tesla_coil,
/obj/item/stock_parts/capacitor
)
/obj/structure/machinery/power/tesla_coil/update_icon()
ClearOverlays()
if(anchored)
AddOverlays("[icon_state]+bolts")
var/image/lights_image = image(icon, null, "[icon_state]+lights")
lights_image.plane = ABOVE_LIGHTING_PLANE
AddOverlays(lights_image)
/obj/structure/machinery/power/tesla_coil/RefreshParts()
var/power_multiplier = 0
for(var/obj/item/stock_parts/capacitor/C in component_parts)
power_multiplier += C.rating
input_power_multiplier = power_multiplier
/obj/structure/machinery/power/tesla_coil/attackby(obj/item/attacking_item, mob/user)
if(default_deconstruction_screwdriver(user, attacking_item))
return
if(default_deconstruction_crowbar(user, attacking_item))
return
if(default_part_replacement(user, attacking_item))
return
if(attacking_item.tool_behaviour == TOOL_WRENCH)
attacking_item.play_tool_sound(get_turf(src), 50)
to_chat(user, SPAN_NOTICE("You [anchored ? "unfasten" : "fasten"] [src] to the flooring."))
anchored = !anchored
update_icon()
if(!anchored)
disconnect_from_network()
else
connect_to_network()
return
/obj/structure/machinery/power/tesla_coil/tesla_act(var/power, var/melt = FALSE)
if(anchored && !melt)
being_shocked = 1
//don't lose arc power when it's not connected to anything
//please place tesla coils all around the station to maximize effectiveness
var/power_produced = powernet ? power / power_loss : power
ADD_TO_POWERNET(src, power_produced*input_power_multiplier)
flick("coilhit", src)
playsound(src.loc, 'sound/magic/LightningShock.ogg', 100, 1, extrarange = 5)
tesla_zap(src, 5, power_produced)
addtimer(CALLBACK(src, PROC_REF(reset_shocked)), 10)
else
..()
/obj/structure/machinery/power/grounding_rod
name = "grounding rod"
desc = "Keep an area from being fried from Edison's Bane."
icon = 'icons/obj/tesla_engine/tesla_coil.dmi'
icon_state = "grounding_rod"
anchored = 0
density = 1
component_types = list(
/obj/item/circuitboard/grounding_rod,
/obj/item/stock_parts/capacitor
)
/obj/structure/machinery/power/grounding_rod/update_icon()
ClearOverlays()
if(anchored)
AddOverlays("[icon_state]+bolts")
var/image/lights_image = image(icon, null, "[icon_state]+lights")
lights_image.plane = ABOVE_LIGHTING_PLANE
AddOverlays(lights_image)
/obj/structure/machinery/power/grounding_rod/attackby(obj/item/attacking_item, mob/user)
if(default_deconstruction_screwdriver(user, attacking_item))
return
if(default_deconstruction_crowbar(user, attacking_item))
return
if(default_part_replacement(user, attacking_item))
return
if(attacking_item.tool_behaviour == TOOL_WRENCH)
attacking_item.play_tool_sound(get_turf(src), 50)
to_chat(user, SPAN_NOTICE("You [anchored ? "unfasten" : "fasten"] [src] to the flooring."))
anchored = !anchored
update_icon()
return
/obj/structure/machinery/power/grounding_rod/tesla_act(var/power, var/melt = FALSE)
flick("coil_shock_1", src)
/obj/item/circuitboard/tesla_coil
name = "tesla coil circuitry"
desc = "The circuitboard for a tesla coil."
build_path = /obj/structure/machinery/power/tesla_coil
origin_tech = list(TECH_MAGNET = 2, TECH_ENGINEERING = 2)
req_components = list("/obj/item/stock_parts/capacitor" = 1)
board_type = BOARD_MACHINE
/obj/item/circuitboard/grounding_rod
name = "grounding rod circuitry"
desc = "The circuitboard for a grounding rod."
build_path = /obj/structure/machinery/power/grounding_rod
origin_tech = list(TECH_MAGNET = 2, TECH_ENGINEERING = 2)
req_components = list("/obj/item/stock_parts/capacitor" = 1)
board_type = BOARD_MACHINE