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

70 lines
1.7 KiB
Plaintext

/obj/structure/machinery/containment_field
name = "containment field"
desc = "An energy field."
icon = 'icons/effects/effects.dmi'
icon_state = "contain_f"
anchored = 1
density = 0
unacidable = 1
use_power = POWER_USE_OFF
light_range = 4
movable_flags = MOVABLE_FLAG_PROXMOVE
var/obj/structure/machinery/field_generator/FG1 = null
var/obj/structure/machinery/field_generator/FG2 = null
var/has_shocked = 0 //Used to add a delay between shocks. In some cases this used to crash servers by spawning hundreds of sparks every second.
/obj/structure/machinery/containment_field/Destroy()
if(FG1 && !FG1.clean_up)
FG1.cleanup()
if(FG2 && !FG2.clean_up)
FG2.cleanup()
return ..()
/obj/structure/machinery/containment_field/attack_hand(mob/user as mob)
if(get_dist(src, user) > 1)
return 0
else
shock(user)
return 1
/obj/structure/machinery/containment_field/ex_act(severity)
return 0
/obj/structure/machinery/containment_field/HasProximity(atom/movable/AM as mob|obj)
if(istype(AM,/mob/living/silicon) && prob(40))
shock(AM)
return 1
if(istype(AM,/mob/living/carbon) && prob(50))
shock(AM)
return 1
return 0
/obj/structure/machinery/containment_field/shock(mob/living/user as mob)
if(has_shocked)
return 0
if(!FG1 || !FG2)
qdel(src)
return 0
if(isliving(user))
has_shocked = 1
var/shock_damage = min(rand(30,40),rand(30,40))
user.electrocute_act(shock_damage, src)
var/atom/target = get_edge_target_turf(user, get_dir(src, get_step_away(user, src)))
user.throw_at(target, 200, 4)
sleep(20)
has_shocked = 0
return
/obj/structure/machinery/containment_field/proc/set_master(var/master1,var/master2)
if(!master1 || !master2)
return 0
FG1 = master1
FG2 = master2
return 1