From 18725f0380d920997bb373782dd12913448d3007 Mon Sep 17 00:00:00 2001 From: Drulikar Date: Sat, 25 May 2024 06:24:39 -0700 Subject: [PATCH] Refactor/Fix colony_floodlight_switches, colony lights/electric fences, etc. --- code/game/machinery/bio-dome_floodlights.dm | 139 ++++---------- code/game/machinery/camera/presets.dm | 2 +- code/game/machinery/colony_floodlights.dm | 146 ++++----------- code/game/machinery/doors/runed_sandstone.dm | 2 +- code/game/machinery/fusion_engine.dm | 2 - code/game/machinery/hybrisa_lights.dm | 176 ++++-------------- code/game/machinery/machinery.dm | 22 ++- code/game/machinery/status_display.dm | 2 +- code/game/objects/structures/fence.dm | 145 ++++++--------- .../desert_dam/motion_sensor/sensortower.dm | 2 +- .../living/carbon/xenomorph/attack_alien.dm | 27 ++- .../chemistry_machinery/acid_harness.dm | 2 +- 12 files changed, 214 insertions(+), 453 deletions(-) diff --git a/code/game/machinery/bio-dome_floodlights.dm b/code/game/machinery/bio-dome_floodlights.dm index e23dbcc023f4..b0822044fadf 100644 --- a/code/game/machinery/bio-dome_floodlights.dm +++ b/code/game/machinery/bio-dome_floodlights.dm @@ -1,154 +1,89 @@ -/obj/structure/machinery/hydro_floodlight_switch +/obj/structure/machinery/colony_floodlight_switch/hydro_floodlight_switch name = "Biodome Floodlight Switch" icon = 'icons/obj/structures/machinery/power.dmi' icon_state = "panelnopower" desc = "This switch controls the floodlights surrounding the archaeology complex. It only functions when there is power." - density = FALSE - anchored = TRUE - var/ispowered = FALSE - var/turned_on = 0 //has to be toggled in engineering - use_power = USE_POWER_IDLE - unslashable = TRUE - unacidable = TRUE - var/list/floodlist = list() // This will save our list of floodlights on the map - -/obj/structure/machinery/hydro_floodlight_switch/Initialize(mapload, ...) - . = ..() - for(var/obj/structure/machinery/hydro_floodlight/F in GLOB.machines) - floodlist += F - F.fswitch = src - start_processing() - -/obj/structure/machinery/hydro_floodlight_switch/Destroy() - for(var/obj/structure/machinery/hydro_floodlight/floodlight as anything in floodlist) - floodlight.fswitch = null - floodlist = null - return ..() + machinery_type_to_control = /obj/structure/machinery/hydro_floodlight - -/obj/structure/machinery/hydro_floodlight_switch/process() - var/lightpower = 0 - for(var/obj/structure/machinery/hydro_floodlight/H in floodlist) - if(!H.is_lit) - continue - lightpower += H.power_tick - use_power(lightpower) - -/obj/structure/machinery/hydro_floodlight_switch/update_icon() +/obj/structure/machinery/colony_floodlight_switch/hydro_floodlight_switch/update_icon() if(!ispowered) icon_state = "panelnopower" - else if(turned_on) + else if(is_on) icon_state = "panelon" else icon_state = "paneloff" -/obj/structure/machinery/hydro_floodlight_switch/power_change() - ..() - if((stat & NOPOWER)) - if(ispowered && turned_on) - toggle_lights() - ispowered = FALSE - turned_on = 0 - update_icon() - else - ispowered = TRUE - update_icon() - -/obj/structure/machinery/hydro_floodlight_switch/proc/toggle_lights() - for(var/obj/structure/machinery/hydro_floodlight/F in floodlist) - if(!istype(F) || QDELETED(F) || F.damaged) continue //Missing or damaged, skip it - - spawn(rand(0,50)) - if(F.is_lit) //Shut it down - F.set_light(0) - else - F.set_light(F.lum_value) - F.is_lit = !(F.is_lit) - F.update_icon() - return 0 - -/obj/structure/machinery/hydro_floodlight_switch/attack_hand(mob/user as mob) - if(!ishuman(user)) - to_chat(user, "Nice try.") - return 0 - if(!ispowered) - to_chat(user, "Nothing happens.") - return 0 - playsound(src,'sound/machines/click.ogg', 15, 1) - use_power(5) - toggle_lights() - turned_on = !(src.turned_on) - update_icon() - return 1 - -/obj/structure/machinery/hydro_floodlight +/obj/structure/machinery/hydro_floodlight // TODO: Repath under /obj/structure/machinery/colony_floodlight name = "Biodome Floodlight" icon = 'icons/obj/structures/machinery/big_floodlight.dmi' icon_state = "flood_s_off" density = TRUE anchored = TRUE layer = WINDOW_LAYER - var/damaged = 0 //Can be smashed by xenos - var/is_lit = 0 unslashable = TRUE unacidable = TRUE - var/power_tick = 800 // power each floodlight takes up per process use_power = USE_POWER_NONE //It's the switch that uses the actual power, not the lights - var/obj/structure/machinery/hydro_floodlight_switch/fswitch = null //Reverse lookup for power grabbing in area + needs_power = FALSE + is_on = FALSE + active_power_usage = 800 //The power each floodlight takes up per process + ///Whether it has been smashed by xenos + var/damaged = FALSE var/lum_value = 7 -/obj/structure/machinery/hydro_floodlight/Destroy() - if(fswitch?.floodlist) - fswitch.floodlist -= src - fswitch = null - return ..() - /obj/structure/machinery/hydro_floodlight/update_icon() if(damaged) icon_state = "flood_s_dmg" - else if(is_lit) + else if(is_on) icon_state = "flood_s_on" else icon_state = "flood_s_off" +/obj/structure/machinery/hydro_floodlight/proc/set_damaged() + playsound(src, "glassbreak", 70, 1) + damaged = TRUE + if(is_on) + set_light(0) + update_icon() + /obj/structure/machinery/hydro_floodlight/attackby(obj/item/W as obj, mob/user as mob) - var/obj/item/tool/weldingtool/WT = W - if(istype(WT)) - if(!damaged) return - if(!HAS_TRAIT(WT, TRAIT_TOOL_BLOWTORCH)) + var/obj/item/tool/weldingtool/welder = W + if(istype(welder)) + if(!damaged) + return + if(!HAS_TRAIT(welder, TRAIT_TOOL_BLOWTORCH)) to_chat(user, SPAN_WARNING("You need a stronger blowtorch!")) return - if(WT.remove_fuel(0, user)) + if(welder.remove_fuel(0, user)) playsound(src.loc, 'sound/items/weldingtool_weld.ogg', 25) user.visible_message(SPAN_NOTICE("[user] starts welding [src]'s damage."), \ SPAN_NOTICE("You start welding [src]'s damage.")) if(do_after(user, 200 * user.get_skill_duration_multiplier(SKILL_ENGINEER), INTERRUPT_ALL|BEHAVIOR_IMMOBILE, BUSY_ICON_BUILD)) playsound(get_turf(src), 'sound/items/Welder2.ogg', 25, 1) - if(!src || !WT.isOn()) return - damaged = 0 + if(!src || !welder.isOn()) return + damaged = FALSE user.visible_message(SPAN_NOTICE("[user] finishes welding [src]'s damage."), \ SPAN_NOTICE("You finish welding [src]'s damage.")) - if(is_lit) + if(is_on) set_light(lum_value) update_icon() - return 1 + return TRUE else to_chat(user, SPAN_WARNING("You need more welding fuel to complete this task.")) - return 0 + return FALSE ..() - return 0 + return FALSE /obj/structure/machinery/hydro_floodlight/attack_hand(mob/user as mob) if(ishuman(user)) to_chat(user, SPAN_WARNING("Nothing happens. Looks like it's powered elsewhere.")) - return 0 - else if(!is_lit) + return FALSE + else if(!is_on) to_chat(user, SPAN_WARNING("Why bother? It's just some weird metal thing.")) - return 0 + return FALSE else if(damaged) to_chat(user, SPAN_WARNING("It's already damaged.")) - return 0 + return FALSE else if(islarva(user)) return //Larvae can't do shit @@ -158,12 +93,12 @@ user.visible_message(SPAN_DANGER("[user] starts to slash and claw away at [src]!"), SPAN_DANGER("You start slashing and clawing at [src]!")) if(do_after(user, 50, INTERRUPT_ALL, BUSY_ICON_HOSTILE) && !damaged) //Not when it's already damaged. - if(!src) return 0 - damaged = 1 + if(!src) return FALSE + damaged = TRUE set_light(0) user.visible_message(SPAN_DANGER("[user] slashes up [src]!"), SPAN_DANGER("You slash up [src]!")) playsound(src, 'sound/weapons/blade1.ogg', 25, 1) update_icon() - return 0 + return FALSE ..() diff --git a/code/game/machinery/camera/presets.dm b/code/game/machinery/camera/presets.dm index a1d7f00cf94a..1377cf8d7275 100644 --- a/code/game/machinery/camera/presets.dm +++ b/code/game/machinery/camera/presets.dm @@ -160,5 +160,5 @@ network = list(CAMERA_NET_SIMULATION) invuln = TRUE view_range = 14 - use_power = FALSE + use_power = USE_POWER_NONE invisibility = INVISIBILITY_MAXIMUM diff --git a/code/game/machinery/colony_floodlights.dm b/code/game/machinery/colony_floodlights.dm index 12eb00bd0442..695c470b5b9a 100644 --- a/code/game/machinery/colony_floodlights.dm +++ b/code/game/machinery/colony_floodlights.dm @@ -1,5 +1,5 @@ //Putting these here since it's power-related -/obj/structure/machinery/colony_floodlight_switch +/obj/structure/machinery/colony_floodlight_switch // TODO: Repath to just breaker_switch name = "colony floodlight switch" icon = 'icons/obj/structures/machinery/power.dmi' icon_state = "panelnopower" @@ -10,10 +10,12 @@ unslashable = TRUE unacidable = TRUE power_machine = TRUE + idle_power_usage = 0 var/ispowered = FALSE - var/turned_on = FALSE //has to be toggled in engineering - ///All floodlights under our control - var/list/floodlist = list() + ///All machinery under our control + var/list/machinery_list = list() + ///The strict type of machinery we control + var/machinery_type_to_control = /obj/structure/machinery/colony_floodlight /obj/structure/machinery/colony_floodlight_switch/Initialize(mapload, ...) . = ..() @@ -21,48 +23,50 @@ /obj/structure/machinery/colony_floodlight_switch/LateInitialize() . = ..() - for(var/obj/structure/machinery/colony_floodlight/floodlight in GLOB.machines) - floodlist += floodlight - floodlight.fswitch = src + if(machinery_type_to_control) + for(var/obj/structure/machinery/machine as anything in GLOB.machines) + if(machine.breaker_switch == null && istypestrict(machine, machinery_type_to_control)) + machinery_list += machine + machine.breaker_switch = src start_processing() /obj/structure/machinery/colony_floodlight_switch/Destroy() - for(var/obj/structure/machinery/colony_floodlight/floodlight as anything in floodlist) - floodlight.fswitch = null - floodlist = null + for(var/obj/structure/machinery/machine as anything in machinery_list) + if(machine.breaker_switch == src) + machine.breaker_switch = null + machinery_list = null return ..() /obj/structure/machinery/colony_floodlight_switch/update_icon() if(!ispowered) icon_state = "panelnopower" - else if(turned_on) + else if(is_on) icon_state = "panelon" else icon_state = "paneloff" /obj/structure/machinery/colony_floodlight_switch/process() - var/lightpower = 0 - for(var/obj/structure/machinery/colony_floodlight/floodlight as anything in floodlist) - if(!floodlight.is_lit) + var/machinepower = calculate_current_power_usage() + for(var/obj/structure/machinery/machine as anything in machinery_list) + if(!machine.is_on) continue - lightpower += floodlight.power_tick - use_power(lightpower) + machinepower += machine.active_power_usage + use_power(machinepower) /obj/structure/machinery/colony_floodlight_switch/power_change() ..() if((stat & NOPOWER)) - if(ispowered && turned_on) - toggle_lights() + if(ispowered && is_on) + toggle_machines() ispowered = FALSE - turned_on = FALSE - update_icon() + set_is_on(FALSE) else ispowered = TRUE update_icon() -/obj/structure/machinery/colony_floodlight_switch/proc/toggle_lights() - for(var/obj/structure/machinery/colony_floodlight/floodlight as anything in floodlist) - addtimer(CALLBACK(floodlight, TYPE_PROC_REF(/obj/structure/machinery/colony_floodlight, toggle_light)), rand(0, 5 SECONDS)) +/obj/structure/machinery/colony_floodlight_switch/proc/toggle_machines() + for(var/obj/structure/machinery/machine as anything in machinery_list) + addtimer(CALLBACK(machine, TYPE_PROC_REF(/obj/structure/machinery, toggle_is_on)), rand(0, 5 SECONDS)) /obj/structure/machinery/colony_floodlight_switch/attack_hand(mob/user as mob) if(!ishuman(user)) @@ -73,9 +77,8 @@ return FALSE playsound(src,'sound/items/Deconstruct.ogg', 30, 1) use_power(5) - toggle_lights() - turned_on = !turned_on - update_icon() + toggle_is_on() + toggle_machines() return TRUE @@ -96,28 +99,18 @@ unacidable = TRUE use_power = USE_POWER_NONE //It's the switch that uses the actual power, not the lights needs_power = FALSE + is_on = FALSE //Whether the floodlight is switched to on or off. Does not necessarily mean it emits light. + health = 150 + active_power_usage = 50 //The power each floodlight takes up per process ///Whether it has been smashed by xenos var/damaged = FALSE - ///Whether the floodlight is switched to on or off. Does not necessarily mean it emits light. - var/is_lit = FALSE - ///The power each floodlight takes up per process - var/power_tick = 50 - ///Reverse lookup for power grabbing in area - var/obj/structure/machinery/colony_floodlight_switch/fswitch = null var/lum_value = 7 var/repair_state = FLOODLIGHT_REPAIR_UNSCREW - health = 150 - -/obj/structure/machinery/colony_floodlight/Destroy() - if(fswitch) - fswitch.floodlist -= src - fswitch = null - . = ..() /obj/structure/machinery/colony_floodlight/update_icon() if(damaged) icon_state = "flood_s_dmg" - else if(is_lit) + else if(is_on) icon_state = "flood_s_on" else icon_state = "flood_s_off" @@ -154,7 +147,7 @@ health = initial(health) user.visible_message(SPAN_NOTICE("[user] screws [src]'s maintenance hatch closed."), \ SPAN_NOTICE("You screw [src]'s maintenance hatch closed.")) - if(is_lit) + if(is_on) set_light(lum_value) update_icon() return TRUE @@ -261,7 +254,7 @@ if(ishuman(user)) if(damaged) to_chat(user, SPAN_WARNING("[src] is damaged.")) - else if(!is_lit) + else if(!is_on) to_chat(user, SPAN_WARNING("Nothing happens. Looks like it's powered elsewhere.")) return FALSE return ..() @@ -278,7 +271,7 @@ if(FLOODLIGHT_REPAIR_WELD) . += SPAN_INFO("You must weld the damage to it.") if(FLOODLIGHT_REPAIR_CABLE) . += SPAN_INFO("You must replace its damaged cables.") if(FLOODLIGHT_REPAIR_SCREW) . += SPAN_INFO("You must screw its maintenance hatch closed.") - else if(!is_lit) + else if(!is_on) . += SPAN_INFO("It doesn't seem powered.") /obj/structure/machinery/colony_floodlight/ex_act(severity) @@ -298,72 +291,15 @@ /obj/structure/machinery/colony_floodlight/proc/set_damaged() playsound(src, "glassbreak", 70, 1) damaged = TRUE - if(is_lit) + if(is_on) set_light(0) update_icon() -/obj/structure/machinery/colony_floodlight/proc/toggle_light() - is_lit = !is_lit +/obj/structure/machinery/colony_floodlight/toggle_is_on() + . = ..() if(!damaged) - set_light(is_lit ? lum_value : 0) - update_icon() - return is_lit - -// Hybrisa Streetlights -/obj/structure/machinery/colony_floodlight/street - name = "Colony Streetlight" - icon = 'icons/obj/structures/props/64x64_hybrisarandomprops.dmi' - icon_state = "street_off" - layer = ABOVE_XENO_LAYER - -/obj/structure/machinery/colony_floodlight/street/update_icon() - if(damaged) - icon_state = "street_dmg" - else if(is_lit) - icon_state = "street_on" - else - icon_state = "street_off" - -// Traffic -/obj/structure/machinery/colony_floodlight/traffic - lum_value = 0 - name = "traffic light" - desc = "A traffic light" - icon = 'icons/obj/structures/props/64x64_hybrisarandomprops.dmi' - icon_state = "trafficlight" - bound_width = 32 - bound_height = 32 - density = TRUE - health = 200 - layer = ABOVE_XENO_LAYER - -/obj/structure/machinery/colony_floodlight/traffic/update_icon() - if(damaged) - icon_state = "trafficlight_damaged" - else if(is_lit) - icon_state = "trafficlight_on" - else - icon_state = "trafficlight" - -/obj/structure/machinery/colony_floodlight/traffic_alt - lum_value = 0 - name = "traffic light" - desc = "A traffic light" - icon = 'icons/obj/structures/props/64x64_hybrisarandomprops.dmi' - icon_state = "trafficlight_alt" - bound_width = 32 - bound_height = 32 - density = TRUE - health = 200 - layer = ABOVE_XENO_LAYER - -/obj/structure/machinery/colony_floodlight/traffic_alt/update_icon() - if(damaged) - icon_state = "trafficlight_alt_damaged" - else if(is_lit) - icon_state = "trafficlight_alt_on" - else - icon_state = "trafficlight_alt" + set_light(is_on ? lum_value : 0) + return . #undef FLOODLIGHT_REPAIR_UNSCREW #undef FLOODLIGHT_REPAIR_CROWBAR diff --git a/code/game/machinery/doors/runed_sandstone.dm b/code/game/machinery/doors/runed_sandstone.dm index a6de7348dd7f..c5dea990de5f 100644 --- a/code/game/machinery/doors/runed_sandstone.dm +++ b/code/game/machinery/doors/runed_sandstone.dm @@ -4,7 +4,7 @@ mineral = "runed sandstone" no_panel = TRUE not_weldable = TRUE - use_power = FALSE + use_power = USE_POWER_NONE autoclose = FALSE locked = TRUE icon_state = "door_locked" diff --git a/code/game/machinery/fusion_engine.dm b/code/game/machinery/fusion_engine.dm index 72f836717b0f..f7df6356501d 100644 --- a/code/game/machinery/fusion_engine.dm +++ b/code/game/machinery/fusion_engine.dm @@ -20,8 +20,6 @@ power_machine = TRUE throwpass = FALSE - ///Whether the reactor is functional - var/is_on = TRUE ///Whether the reactor is on the ship var/is_ship_reactor = FALSE ///If the generator is overloaded diff --git a/code/game/machinery/hybrisa_lights.dm b/code/game/machinery/hybrisa_lights.dm index d0852e9553dd..a762b80a64e7 100644 --- a/code/game/machinery/hybrisa_lights.dm +++ b/code/game/machinery/hybrisa_lights.dm @@ -1,76 +1,47 @@ // Hybrisa Electrical Stuff -/obj/structure/machinery/colony_electrified_fence_switch +/obj/structure/machinery/colony_floodlight_switch/electrified_fence_switch name = "Colony Electrified Fence Switch" icon = 'icons/obj/structures/props/hybrisarandomprops.dmi' icon_state = "panelnopower" desc = "This switch controls the electrified fences. It only functions when there is power." - density = FALSE - anchored = TRUE - var/ispowered = FALSE - var/turned_on = FALSE //has to be toggled in SOMEWHERE - use_power = USE_POWER_IDLE - unslashable = TRUE - unacidable = TRUE - var/list/fencelist = list() // This will save our list of electrified fences on the map - power_machine = TRUE - -/obj/structure/machinery/colony_electrified_fence_switch/Initialize(mapload, ...) - . = ..() - return INITIALIZE_HINT_LATELOAD + machinery_type_to_control = null + /// The power each fence takes up per process + var/power_usage_per_fence = 5 -/obj/structure/machinery/colony_electrified_fence_switch/LateInitialize() +/obj/structure/machinery/colony_floodlight_switch/electrified_fence_switch/LateInitialize() . = ..() - for(var/obj/structure/fence/electrified/fence in GLOB.all_fences) - fencelist += fence - fence.fswitch = src - start_processing() + for(var/obj/structure/fence/electrified/fence as anything in GLOB.all_electric_fences) + fence.breaker_switch = src -/obj/structure/machinery/colony_electrified_fence_switch/Destroy() - for(var/obj/structure/fence/electrified/fence as anything in fencelist) - fence.fswitch = null - fencelist = null +/obj/structure/machinery/colony_floodlight_switch/electrified_fence_switch/Destroy() + for(var/obj/structure/fence/electrified/fence as anything in GLOB.all_electric_fences) + if(fence.breaker_switch == src) + fence.breaker_switch = null return ..() -/obj/structure/machinery/colony_electrified_fence_switch/update_icon() +/obj/structure/machinery/colony_floodlight_switch/electrified_fence_switch/process() + var/machinepower = calculate_current_power_usage() + if(is_on) + machinepower += length(GLOB.all_electric_fences) + use_power(machinepower) + +/obj/structure/machinery/colony_floodlight_switch/electrified_fence_switch/update_icon() if(!ispowered) icon_state = "panelnopower" - else if(turned_on) + else if(is_on) icon_state = "panelon" else icon_state = "paneloff" -/obj/structure/machinery/colony_electrified_fence_switch/process() - return - -/obj/structure/machinery/colony_electrified_fence_switch/power_change() - ..() - if((stat & NOPOWER)) - if(ispowered && turned_on) - toggle_fences() - ispowered = FALSE - turned_on = FALSE - update_icon() - else - ispowered = TRUE - update_icon() - -/obj/structure/machinery/colony_electrified_fence_switch/proc/toggle_fences() - for(var/obj/structure/fence/electrified/fence as anything in fencelist) +/obj/structure/machinery/colony_floodlight_switch/electrified_fence_switch/proc/toggle_fences() + for(var/obj/structure/fence/electrified/fence as anything in GLOB.all_electric_fences) fence.toggle_power() -/obj/structure/machinery/colony_electrified_fence_switch/attack_hand(mob/user as mob) - if(!ishuman(user)) - to_chat(user, "Nice try.") - return FALSE - if(!ispowered) - to_chat(user, "Nothing happens.") - return FALSE - playsound(src,'sound/items/Deconstruct.ogg', 30, 1) - use_power(5) - toggle_fences() - turned_on = !turned_on - update_icon() - return TRUE +/obj/structure/machinery/colony_floodlight_switch/electrified_fence_switch/attack_hand(mob/user as mob) + if(..()) + toggle_fences() + return TRUE + return FALSE // Hybrisa Streetlights /obj/structure/machinery/colony_floodlight/street @@ -82,13 +53,12 @@ /obj/structure/machinery/colony_floodlight/street/update_icon() if(damaged) icon_state = "street_dmg" - else if(is_lit) + else if(is_on) icon_state = "street_on" else icon_state = "street_off" // Traffic - /obj/structure/machinery/colony_floodlight/traffic lum_value = 0 name = "traffic light" @@ -104,7 +74,7 @@ /obj/structure/machinery/colony_floodlight/traffic/update_icon() if(damaged) icon_state = "trafficlight_damaged" - else if(is_lit) + else if(is_on) icon_state = "trafficlight_on" else icon_state = "trafficlight" @@ -124,94 +94,20 @@ /obj/structure/machinery/colony_floodlight/traffic_alt/update_icon() if(damaged) icon_state = "trafficlight_alt_damaged" - else if(is_lit) + else if(is_on) icon_state = "trafficlight_alt_on" else icon_state = "trafficlight_alt" // Engineer Floor lights - -/obj/structure/machinery/engineerconsole_switch +/obj/structure/machinery/colony_floodlight_switch/engineerconsole_switch name = "Giant Alien Console" icon = 'icons/obj/structures/props/64x64_hybrisarandomprops.dmi' icon_state = "engineerconsole" desc = "A Giant Alien console of some kind, unlike anything you've ever seen before. Who knows the purpose of this strange technology..." - bound_height = 32 - bound_width = 32 - unslashable = TRUE - unacidable = TRUE - indestructible = TRUE - density = TRUE - anchored = TRUE - var/ispowered = TRUE - var/turned_on = 0 //has to be toggled in engineering use_power = USE_POWER_NONE - var/list/floodlist = list() // This will save our list of floodlights on the map - power_machine = TRUE + machinery_type_to_control = /obj/structure/machinery/colony_floodlight/engineer_circular -/obj/structure/machinery/engineerconsole_switch/Initialize(mapload, ...) - . = ..() - return INITIALIZE_HINT_LATELOAD - -/obj/structure/machinery/engineerconsole_switch/LateInitialize() - . = ..() - for(var/obj/structure/machinery/colony_floodlight/engineer_circular/floodlight in GLOB.ship_floodlights) - floodlist += floodlight - floodlight.fswitch = src - start_processing() - -/obj/structure/machinery/engineerconsole_switch/Destroy() - for(var/obj/structure/machinery/colony_floodlight/engineer_circular/floodlight as anything in floodlist) - floodlight.fswitch = null - floodlist = null - return ..() - -/obj/structure/machinery/engineerconsole_switch/process() - var/lightpower = 0 - for(var/obj/structure/machinery/colony_floodlight/engineer_circular/colony_floodlight in floodlist) - if(!colony_floodlight.is_lit) - continue - lightpower += colony_floodlight.power_tick - use_power(lightpower) - -/obj/structure/machinery/engineerconsole_switch/power_change() - ..() - if((stat & NOPOWER)) - if(ispowered && turned_on) - toggle_lights() - ispowered = FALSE - turned_on = FALSE - update_icon() - else - ispowered = TRUE - update_icon() - -/obj/structure/machinery/engineerconsole_switch/proc/toggle_lights() - for(var/obj/structure/machinery/colony_floodlight/engineer_circular/floodlight in floodlist) - spawn(rand(10,60)) - floodlight.is_lit = !floodlight.is_lit - if(!floodlight.damaged) - if(floodlight.is_lit) //Shut it down - floodlight.set_light(l_range = floodlight.lum_value,l_power = floodlight.light_power , l_color = floodlight.light_color) - else - floodlight.set_light(0) - floodlight.update_icon() - return FALSE - -/obj/structure/machinery/engineerconsole_switch/attack_hand(mob/user as mob) - if(!ishuman(user)) - to_chat(user, "Nice try.") - return FALSE - if(!ispowered) - to_chat(user, "Nothing happens.") - return FALSE - playsound(src,'sound/effects/EMPulse.ogg', 30, 1) - toggle_lights() - turned_on = !turned_on - update_icon() - return TRUE - -GLOBAL_LIST_INIT(ship_floodlights, list()) /obj/structure/machinery/colony_floodlight/engineer_circular name = "circular light" icon_state = "engineerlight_off" @@ -229,15 +125,7 @@ GLOBAL_LIST_INIT(ship_floodlights, list()) /obj/structure/machinery/colony_floodlight/engineer_circular/update_icon() if(damaged) icon_state = "engineerlight_off" - else if(is_lit) + else if(is_on) icon_state = "engineerlight_on" else icon_state = "engineerlight_off" - -/obj/structure/machinery/colony_floodlight/engineer_circular/Initialize() - . = ..() - GLOB.ship_floodlights += src - -/obj/structure/machinery/colony_floodlight/engineer_circular/Destroy() - . = ..() - GLOB.ship_floodlights -= src diff --git a/code/game/machinery/machinery.dm b/code/game/machinery/machinery.dm index f835ecaa424c..ee13dc69679a 100644 --- a/code/game/machinery/machinery.dm +++ b/code/game/machinery/machinery.dm @@ -103,12 +103,15 @@ Class Procs: var/mob/living/carbon/human/operator = null //Had no idea where to put this so I put this here. Used for operating machines with RELAY_CLICK //EQUIP,ENVIRON or LIGHT var/list/component_parts //list of all the parts used to build it, if made from certain kinds of frames. - var/manual = 0 layer = OBJ_LAYER var/machine_processing = 0 // whether the machine is busy and requires process() calls in scheduler. // Please replace this by DF_ISPROCESSING in another refactor --fira - throwpass = 1 + throwpass = TRUE projectile_coverage = PROJECTILE_COVERAGE_MEDIUM var/power_machine = FALSE //Whether the machine should process on power, or normal processor + /// Reverse lookup for a breaker_switch that if specified is controlling us + var/obj/structure/machinery/colony_floodlight_switch/breaker_switch + /// Whether this is toggled on + var/is_on = TRUE /obj/structure/machinery/vv_get_dropdown() . = ..() @@ -140,6 +143,9 @@ Class Procs: var/area/A = get_area(src) if(A) A.remove_machine(src) //takes care of removing machine from power usage + if(breaker_switch) + breaker_switch.machinery_list -= src + breaker_switch = null . = ..() /obj/structure/machinery/initialize_pass_flags(datum/pass_flags_container/PF) @@ -321,6 +327,16 @@ Class Procs: /obj/structure/machinery/proc/get_repair_move_text(include_name = TRUE) return +/obj/structure/machinery/proc/set_is_on(is_on) + if(src.is_on == is_on) + return + src.is_on = is_on + update_icon() + +/obj/structure/machinery/proc/toggle_is_on() + set_is_on(!is_on) + return is_on + // UI related procs \\ /obj/structure/machinery/ui_state(mob/user) @@ -369,7 +385,7 @@ Class Procs: unslashable = TRUE unacidable = TRUE wrenchable = FALSE - + /obj/structure/machinery/fuelpump/ex_act(severity) return diff --git a/code/game/machinery/status_display.dm b/code/game/machinery/status_display.dm index 547dbba68e4f..00f251126628 100644 --- a/code/game/machinery/status_display.dm +++ b/code/game/machinery/status_display.dm @@ -20,7 +20,7 @@ desc = "A monitor depicting the ship's current status. It flickers every so often." anchored = TRUE density = FALSE - use_power = FALSE + use_power = USE_POWER_NONE idle_power_usage = 10 var/mode = 0 // 0 = Blank // 1 = Shuttle timer diff --git a/code/game/objects/structures/fence.dm b/code/game/objects/structures/fence.dm index 6f4905e01e56..d497799997b5 100644 --- a/code/game/objects/structures/fence.dm +++ b/code/game/objects/structures/fence.dm @@ -14,6 +14,7 @@ var/cut = 0 //Cut fences can be passed through var/junction = 0 //Because everything is terrible, I'm making this a fence-level var var/basestate = "fence" + var/forms_junctions = TRUE /obj/structure/fence/initialize_pass_flags(datum/pass_flags_container/PF) ..() @@ -68,9 +69,9 @@ /obj/structure/fence/attack_hand(mob/user as mob) if(ishuman(user) && user.a_intent == INTENT_HARM) - var/mob/living/carbon/human/H = user - if(H.species.can_shred(H)) - attack_generic(H, 25) + var/mob/living/carbon/human/human = user + if(human.species.can_shred(human)) + attack_generic(human, 25) //Used by attack_animal /obj/structure/fence/proc/attack_generic(mob/living/user, damage = 0) @@ -80,10 +81,12 @@ healthcheck(1, 1, user) /obj/structure/fence/attack_animal(mob/user as mob) - if(!isanimal(user)) return - var/mob/living/simple_animal/M = user - if(M.melee_damage_upper <= 0) return - attack_generic(M, M.melee_damage_upper) + if(!isanimal(user)) + return + var/mob/living/simple_animal/simple = user + if(simple.melee_damage_upper <= 0) + return + attack_generic(simple, simple.melee_damage_upper) /obj/structure/fence/attackby(obj/item/W, mob/user) @@ -91,26 +94,26 @@ if(!skillcheck(user, SKILL_CONSTRUCTION, SKILL_CONSTRUCTION_ENGI)) to_chat(user, SPAN_WARNING("You don't have the skill needed to fix [src]'s wiring.")) return - var/obj/item/stack/barbed_wire/R = W + var/obj/item/stack/barbed_wire/wire = W var/amount_needed = 2 if(health) amount_needed = 1 - if(R.amount >= amount_needed) - user.visible_message(SPAN_NOTICE("[user] starts repairing [src] with [R]."), - SPAN_NOTICE("You start repairing [src] with [R].")) + if(wire.amount >= amount_needed) + user.visible_message(SPAN_NOTICE("[user] starts repairing [src] with [wire]."), + SPAN_NOTICE("You start repairing [src] with [wire].")) playsound(src.loc, 'sound/items/Wirecutter.ogg', 25, 1) if(do_after(user, 30 * user.get_skill_duration_multiplier(SKILL_CONSTRUCTION), INTERRUPT_ALL, BUSY_ICON_FRIENDLY)) - if(R.amount < amount_needed) + if(wire.amount < amount_needed) to_chat(user, SPAN_WARNING("You need more barbed wire to repair [src].")) return - R.use(amount_needed) + wire.use(amount_needed) health = health_max - cut = 0 + cut = FALSE density = TRUE update_icon() playsound(loc, 'sound/items/Wirecutter.ogg', 25, 1) - user.visible_message(SPAN_NOTICE("[user] repairs [src] with [R]."), - SPAN_NOTICE("You repair [src] with [R].")) + user.visible_message(SPAN_NOTICE("[user] repairs [src] with [wire]."), + SPAN_NOTICE("You repair [src] with [wire].")) return else to_chat(user, SPAN_WARNING("You need more barbed wire to repair [src].")) @@ -131,32 +134,33 @@ return if(istype(W, /obj/item/grab) && get_dist(src, user) < 2) - var/obj/item/grab/G = W - if(istype(G.grabbed_thing, /mob/living)) - var/mob/living/M = G.grabbed_thing + var/obj/item/grab/grabby = W + if(istype(grabby.grabbed_thing, /mob/living)) + var/mob/living/grabbed_mob = grabby.grabbed_thing var/state = user.grab_level user.drop_held_item() switch(state) if(GRAB_PASSIVE) - M.visible_message(SPAN_WARNING("[user] slams [M] against \the [src]!")) - M.apply_damage(7) + grabbed_mob.visible_message(SPAN_WARNING("[user] slams [grabbed_mob] against \the [src]!")) + grabbed_mob.apply_damage(7) health -= 10 if(GRAB_AGGRESSIVE) - M.visible_message(SPAN_DANGER("[user] bashes [M] against \the [src]!")) + grabbed_mob.visible_message(SPAN_DANGER("[user] bashes [grabbed_mob] against \the [src]!")) if(prob(50)) - M.apply_effect(1, WEAKEN) - M.apply_damage(10) + grabbed_mob.apply_effect(1, WEAKEN) + grabbed_mob.apply_damage(10) health -= 25 if(GRAB_CHOKE) - M.visible_message(SPAN_DANGER("[user] crushes [M] against \the [src]!")) - M.apply_effect(5, WEAKEN) - M.apply_damage(20) + grabbed_mob.visible_message(SPAN_DANGER("[user] crushes [grabbed_mob] against \the [src]!")) + grabbed_mob.apply_effect(5, WEAKEN) + grabbed_mob.apply_damage(20) health -= 50 - healthcheck(1, 1, M) //The person thrown into the window literally shattered it + healthcheck(1, 1, grabbed_mob) //The person thrown into the window literally shattered it return - if(W.flags_item & NOBLUDGEON) return + if(W.flags_item & NOBLUDGEON) + return if(HAS_TRAIT(W, TRAIT_TOOL_WIRECUTTERS)) user.visible_message(SPAN_NOTICE("[user] starts cutting through [src] with [W]."), @@ -184,7 +188,7 @@ /obj/structure/fence/proc/cut_grille() health = 0 - cut = 1 + cut = TRUE density = FALSE update_icon() //Make it appear cut through! @@ -211,8 +215,9 @@ /obj/structure/fence/proc/update_nearby_icons() update_icon() for(var/direction in GLOB.cardinals) - for(var/obj/structure/fence/W in get_step(src, direction)) - W.update_icon() + for(var/obj/structure/fence/fence in get_step(src, direction)) + if(fence.forms_junctions) + fence.update_icon() //merges adjacent full-tile windows into one (blatant ripoff from game/smoothwall.dm) /obj/structure/fence/update_icon() @@ -220,11 +225,13 @@ //this way it will only update full-tile ones //This spawn is here so windows get properly updated when one gets deleted. spawn(2) - if(!src) return - for(var/obj/structure/fence/W in orange(src, 1)) - if(istypestrict(W,/obj/structure/fence )) - if(abs(x - W.x) - abs(y - W.y)) //Doesn't count grilles, placed diagonally to src - junction |= get_dir(src, W) + if(!src) + return + for(var/obj/structure/fence/fence in orange(src, 1)) + if(!fence.forms_junctions) + continue + if(abs(x - fence.x) - abs(y - fence.y)) //Doesn't count grilles, placed diagonally to src + junction |= get_dir(src, fence) if(cut) icon_state = "broken[basestate][junction]" else @@ -236,34 +243,31 @@ healthcheck(0) //Don't make hit sounds, it's dumb with fire/heat ..() -GLOBAL_LIST_INIT(all_fences, list()) - +GLOBAL_LIST_INIT(all_electric_fences, list()) // Hybrisa Electric Fence /obj/structure/fence/electrified - name = "electrified fence " + name = "electrified fence" icon = 'icons/obj/structures/props/hybrisarandomprops.dmi' icon_state = "highvoltagegrille_off" basestate = "highvoltagegrille" - var/electrified = FALSE - var/fswitch throwpass = TRUE unacidable = TRUE + forms_junctions = FALSE + var/electrified = FALSE + var/obj/structure/machinery/colony_floodlight_switch/electrified_fence_switch/breaker_switch = null /obj/structure/fence/electrified/hitby(atom/movable/AM) visible_message(SPAN_DANGER("[src] was hit by [AM].")) var/tforce = 0 if(ismob(AM)) if(electrified && !cut) - if(istype(AM,/mob/living/carbon/human)) - electrocute_human(AM) - if(istype(AM,/mob/living/carbon/xenomorph)) - electrocute_xenomorph(AM) + electrocute_mob(AM) else tforce = 40 else if(isobj(AM)) - var/obj/item/I = AM - tforce = I.throwforce + var/obj/item/zapped_item = AM + tforce = zapped_item.throwforce health = max(0, health - tforce) healthcheck() @@ -280,55 +284,22 @@ GLOBAL_LIST_INIT(all_fences, list()) icon_state = "[basestate]_off" /obj/structure/fence/electrified/proc/toggle_power() - if(electrified) - electrified = FALSE - else - electrified = TRUE + electrified = !electrified update_icon() /obj/structure/fence/electrified/Initialize() . = ..() - GLOB.all_fences += src + GLOB.all_electric_fences += src /obj/structure/fence/electrified/Destroy() - GLOB.all_fences -= src + GLOB.all_electric_fences -= src return ..() -/obj/structure/fence/electrified/proc/electrocute_human(mob/living/carbon/human/electrocuted) - var/mob/living/carbon/human/human = electrocuted - human.apply_effect(1,STUN) - human.apply_effect(1,PARALYZE) - var/datum/effect_system/spark_spread/spark_system = new - spark_system.set_up(5, 0, src) - spark_system.attach(src) - spark_system.start(src) - -/obj/structure/fence/electrified/proc/electrocute_xenomorph(mob/living/carbon/xenomorph/electrocuted) - electrocuted.apply_damage(100,BURN) - electrocuted.apply_effect(1,STUN) - electrocuted.apply_effect(1,PARALYZE) - var/datum/effect_system/spark_spread/spark_system = new - spark_system.set_up(5, 0, src) - spark_system.attach(src) - spark_system.start(src) - /obj/structure/fence/electrified/attackby(obj/item/W, mob/user) if(electrified && !cut) - if(istype(user, /mob/living/carbon/human)) - var/mob/living/carbon/human/human = user - if(human.gloves) - var/obj/item/clothing/gloves/worn_gloves = human.gloves - if(worn_gloves.siemens_coefficient != 0) - electrocute_human(human) - else - electrocute_human(human) - . = ..() + electrocute_mob(user, get_area(src), src, 0.3) + return ..() /obj/structure/fence/electrified/ex_act(severity) health -= severity/2 - healthcheck(0, 1) - - - - - + healthcheck(make_hit_sound = FALSE, create_debris = TRUE) diff --git a/code/modules/desert_dam/motion_sensor/sensortower.dm b/code/modules/desert_dam/motion_sensor/sensortower.dm index a3f33d4da078..e476ed565f87 100644 --- a/code/modules/desert_dam/motion_sensor/sensortower.dm +++ b/code/modules/desert_dam/motion_sensor/sensortower.dm @@ -16,8 +16,8 @@ unacidable = TRUE //NOPE.jpg needs_power = FALSE idle_power_usage = 1000 + is_on = FALSE //Is this damn thing on or what? var/buildstate = SENSORTOWER_BUILDSTATE_BLOWTORCH //What state of building it are we on, 0-3, 1 is "broken", the default - var/is_on = FALSE //Is this damn thing on or what? var/fail_rate = 15 //% chance of failure each fail_tick check var/fail_check_ticks = 50 //Check for failure every this many ticks //The sensor tower fails more often since it is experimental. diff --git a/code/modules/mob/living/carbon/xenomorph/attack_alien.dm b/code/modules/mob/living/carbon/xenomorph/attack_alien.dm index c610ba2742ea..81218ade2771 100644 --- a/code/modules/mob/living/carbon/xenomorph/attack_alien.dm +++ b/code/modules/mob/living/carbon/xenomorph/attack_alien.dm @@ -514,9 +514,9 @@ return XENO_ATTACK_ACTION /obj/structure/fence/electrified/attack_alien(mob/living/carbon/xenomorph/M) - if(electrified && !cut) //this is placeholder, needs to be updated - electrocute_xenomorph(M) - . = ..() + if(electrified && !cut) + electrocute_mob(M) + return ..() //Slashin mirrors @@ -860,7 +860,7 @@ return attack_hand(M) /obj/structure/machinery/colony_floodlight/attack_alien(mob/living/carbon/xenomorph/M) - if(!is_lit) + if(!is_on) to_chat(M, "Why bother? It's just some weird metal thing.") return XENO_NO_DELAY_ACTION if(damaged) @@ -875,10 +875,27 @@ playsound(loc, 'sound/effects/Glasshit.ogg', 25, 1) return XENO_ATTACK_ACTION -/obj/structure/machinery/colony_floodlight/attack_larva(mob/living/carbon/xenomorph/larva/M) +/obj/structure/machinery/hydro_floodlight/attack_larva(mob/living/carbon/xenomorph/larva/M) M.visible_message("[M] starts biting [src]!","In a rage, we start biting [src], but with no effect!", null, 5, CHAT_TYPE_XENO_COMBAT) +/obj/structure/machinery/hydro_floodlight/attack_alien(mob/living/carbon/xenomorph/M) + if(!is_on) + to_chat(M, "Why bother? It's just some weird metal thing.") + return XENO_NO_DELAY_ACTION + if(damaged) + to_chat(M, "It's already damaged.") + return XENO_NO_DELAY_ACTION + M.animation_attack_on(src) + M.visible_message("[M] slashes away at [src]!","We slash and claw at the bright light!", max_distance = 5, message_flags = CHAT_TYPE_XENO_COMBAT) + health = max(health - rand(M.melee_damage_lower, M.melee_damage_upper), 0) + if(!health) + set_damaged() + else + playsound(loc, 'sound/effects/Glasshit.ogg', 25, 1) + return XENO_ATTACK_ACTION +/obj/structure/machinery/colony_floodlight/attack_larva(mob/living/carbon/xenomorph/larva/M) + M.visible_message("[M] starts biting [src]!","In a rage, we start biting [src], but with no effect!", null, 5, CHAT_TYPE_XENO_COMBAT) //Digging up snow /turf/open/snow/attack_alien(mob/living/carbon/xenomorph/M) diff --git a/code/modules/reagents/chemistry_machinery/acid_harness.dm b/code/modules/reagents/chemistry_machinery/acid_harness.dm index 4fa087efc54f..42cb80db024b 100644 --- a/code/modules/reagents/chemistry_machinery/acid_harness.dm +++ b/code/modules/reagents/chemistry_machinery/acid_harness.dm @@ -198,7 +198,7 @@ /obj/structure/machinery/acid_core name = "A.C.I.D. CORE" - use_power = FALSE + use_power = USE_POWER_NONE var/obj/item/clothing/accessory/storage/black_vest/acid_harness/acid_harness var/mob/living/carbon/human/user