Skip to content

Commit

Permalink
Floodlight rework (#4535)
Browse files Browse the repository at this point in the history
# About the pull request

Alright so this expanded in scope rapidly once I saw what the hell was
going on in this file.

Normal floodlights are now:
Slashable
Acidable
Require power and turn off appropriately
Wrenchable

Landing lights (and some special floodlights on maps):
Unslashable
Unacidable
Unwrenchable
Do not require power or ever turn off

# Explain why it's good for the game

Old and goofy code BAD

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog

:cl: Morrow
fix: Fixed floodlight stacking to make mostly invincible walls
refactor: Refactored 90% of the floodlight code
/:cl:
  • Loading branch information
morrowwolf committed Oct 4, 2023
1 parent 8369fde commit abded50
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 117 deletions.
139 changes: 44 additions & 95 deletions code/game/machinery/floodlight.dm
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
//these are probably broken

/obj/structure/machinery/floodlight
name = "Emergency Floodlight"
name = "emergency floodlight"
desc = "A powerful light usually stationed near landing zones to provide better visibility."
icon = 'icons/obj/structures/machinery/floodlight.dmi'
icon_state = "flood00"
density = TRUE
anchored = TRUE
var/obj/item/cell/cell = null
var/use = 0
var/unlocked = 0
var/open = 0
light_power = 2
unslashable = TRUE
unacidable = TRUE
wrenchable = TRUE
use_power = USE_POWER_IDLE
idle_power_usage = 0
active_power_usage = 100

var/on_light_range = 6

///Whether or not the floodlight can be toggled on or off
var/toggleable = TRUE

///Whether or not the floodlight is turned on, disconnected from whether it has power or is lit
var/turned_on = FALSE

/obj/structure/machinery/floodlight/Initialize(mapload, ...)
. = ..()
cell = new /obj/item/cell(src)
if(light_on)
set_light(on_light_range)

/obj/structure/machinery/floodlight/Destroy()
QDEL_NULL(cell)
return ..()
turn_light(toggle_on = (operable() && turned_on))

/obj/structure/machinery/floodlight/turn_light(mob/user, toggle_on)
. = ..()
Expand All @@ -36,100 +34,51 @@
else
set_light(0)

update_icon()

/obj/structure/machinery/floodlight/proc/updateicon()
icon_state = "flood[open ? "o" : ""][open && cell ? "b" : ""]0[light_on]"

/obj/structure/machinery/floodlight/attack_hand(mob/user as mob)
if(open && cell)
if(ishuman(user))
if(!user.get_active_hand())
user.put_in_hands(cell)
cell.forceMove(user.loc)
else
cell.forceMove(loc)
/obj/structure/machinery/floodlight/attack_hand(mob/user)
if(!toggleable)
to_chat(user, SPAN_NOTICE("[src] doesn't seem to have a switch to toggle the light."))
return

cell.add_fingerprint(user)
cell.update_icon()
if(user.lying || user.stat)
return

src.cell = null
to_chat(user, "You remove the power cell.")
updateicon()
if(!is_valid_user(user))
to_chat(user, SPAN_NOTICE("You don't have the dexterity to do this."))
return

if(light_on)
to_chat(user, SPAN_NOTICE("You turn off the light."))
turn_light(user, toggle_on = FALSE)
unslashable = TRUE
unacidable = TRUE
else
if(!cell)
return
if(cell.charge <= 0)
return
to_chat(user, SPAN_NOTICE("You turn on the light."))
turn_light(user, toggle_on = TRUE)
unacidable = FALSE
turned_on = !turned_on

updateicon()
if(inoperable())
to_chat(user, SPAN_NOTICE("You turn [turned_on ? "on" : "off"] the floodlight. It seems to be inoperable."))
return

to_chat(user, SPAN_NOTICE("You turn [turned_on ? "on" : "off"] the light."))
turn_light(user, toggle_on = turned_on)
update_use_power(turned_on ? USE_POWER_ACTIVE : USE_POWER_IDLE)

/obj/structure/machinery/floodlight/attackby(obj/item/W as obj, mob/user as mob)
if(!ishuman(user))
return
/obj/structure/machinery/floodlight/update_icon()
. = ..()
icon_state = "flood0[light_on]"

/obj/structure/machinery/floodlight/power_change(area/master_area = null)
. = ..()

if (HAS_TRAIT(W, TRAIT_TOOL_WRENCH))
if (!anchored)
anchored = TRUE
to_chat(user, "You anchor the [src] in place.")
else
anchored = FALSE
to_chat(user, "You remove the bolts from the [src].")

if (HAS_TRAIT(W, TRAIT_TOOL_SCREWDRIVER))
if (!open)
if(unlocked)
unlocked = 0
to_chat(user, "You screw the battery panel in place.")
else
unlocked = 1
to_chat(user, "You unscrew the battery panel.")

if (HAS_TRAIT(W, TRAIT_TOOL_CROWBAR))
if(unlocked)
if(open)
open = 0
overlays = null
to_chat(user, "You crowbar the battery panel in place.")
else
if(unlocked)
open = 1
to_chat(user, "You remove the battery panel.")

if (istype(W, /obj/item/cell))
if(open)
if(cell)
to_chat(user, "There is a power cell already installed.")
else
if(user.drop_inv_item_to_loc(W, src))
cell = W
to_chat(user, "You insert the power cell.")
updateicon()
turn_light(toggle_on = (!(stat & NOPOWER) && turned_on))

//Magical floodlight that cannot be destroyed or interacted with.
/obj/structure/machinery/floodlight/landing
name = "Landing Light"
desc = "A powerful light stationed near landing zones to provide better visibility."
name = "landing light"
desc = "A powerful light usually stationed near landing zones to provide better visibility. This one seems to have been bolted down and is unable to be moved."
icon_state = "flood01"
light_on = TRUE
in_use = 1
use_power = USE_POWER_NONE

/obj/structure/machinery/floodlight/landing/attack_hand()
return

/obj/structure/machinery/floodlight/landing/attackby()
return
needs_power = FALSE
unslashable = TRUE
unacidable = TRUE
wrenchable = FALSE
toggleable = FALSE
turned_on = TRUE

/obj/structure/machinery/floodlight/landing/floor
icon_state = "floor_flood01"
Expand Down
37 changes: 19 additions & 18 deletions maps/map_files/LV624/LV624.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -1119,8 +1119,10 @@
},
/area/lv624/ground/barrens/containers)
"afu" = (
/obj/structure/machinery/floodlight,
/obj/item/ammo_casing,
/obj/structure/machinery/floodlight/landing{
name = "bolted floodlight"
},
/turf/open/floor/plating{
dir = 9;
icon_state = "warnplate"
Expand Down Expand Up @@ -1154,7 +1156,9 @@
},
/area/lv624/ground/barrens/central_barrens)
"afy" = (
/obj/structure/machinery/floodlight,
/obj/structure/machinery/floodlight/landing{
name = "bolted floodlight"
},
/turf/open/floor/plating{
dir = 5;
icon_state = "warnplate"
Expand Down Expand Up @@ -1205,11 +1209,6 @@
/obj/item/ammo_casing,
/turf/open/floor/plating,
/area/lv624/ground/barrens/central_barrens)
"afM" = (
/obj/structure/machinery/floodlight,
/obj/effect/decal/cleanable/blood,
/turf/open/floor/plating,
/area/lv624/ground/barrens/central_barrens)
"afN" = (
/obj/item/ammo_casing,
/turf/open/floor/plating,
Expand Down Expand Up @@ -1389,10 +1388,6 @@
"agA" = (
/turf/open/floor/sandstone/runed,
/area/lv624/ground/caves/south_east_caves)
"agC" = (
/obj/structure/machinery/floodlight,
/turf/open/floor/plating,
/area/lv624/ground/barrens/central_barrens)
"agD" = (
/obj/structure/surface/table/reinforced{
dir = 8;
Expand All @@ -1407,8 +1402,10 @@
/turf/open/floor/plating,
/area/lv624/ground/barrens/central_barrens)
"agF" = (
/obj/structure/machinery/floodlight,
/obj/item/ammo_casing,
/obj/structure/machinery/floodlight/landing{
name = "bolted floodlight"
},
/turf/open/floor/plating,
/area/lv624/ground/barrens/central_barrens)
"agG" = (
Expand Down Expand Up @@ -1585,7 +1582,9 @@
},
/area/lv624/ground/barrens/west_barrens/ceiling)
"ahM" = (
/obj/structure/machinery/floodlight,
/obj/structure/machinery/floodlight/landing{
name = "bolted floodlight"
},
/turf/open/floor/plating{
dir = 10;
icon_state = "warnplate"
Expand Down Expand Up @@ -1625,7 +1624,9 @@
},
/area/lv624/ground/barrens/central_barrens)
"ahT" = (
/obj/structure/machinery/floodlight,
/obj/structure/machinery/floodlight/landing{
name = "bolted floodlight"
},
/turf/open/floor/plating{
dir = 6;
icon_state = "warnplate"
Expand Down Expand Up @@ -41057,7 +41058,7 @@ ajW
afI
ajW
ajW
agC
ajW
afN
ajW
ajW
Expand Down Expand Up @@ -42192,7 +42193,7 @@ jaa
wVk
wVk
afx
afM
agf
ajW
agi
ajW
Expand All @@ -42202,7 +42203,7 @@ agT
ahh
ahl
afN
agC
ajW
ahS
afk
wVk
Expand Down Expand Up @@ -43337,7 +43338,7 @@ ajW
agl
ajW
ajW
agC
ajW
ajW
afN
eah
Expand Down
16 changes: 12 additions & 4 deletions maps/map_files/USS_Almayer/USS_Almayer.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -5852,7 +5852,9 @@
},
/area/almayer/medical/morgue)
"asV" = (
/obj/structure/machinery/floodlight/landing,
/obj/structure/machinery/floodlight/landing{
name = "bolted floodlight"
},
/turf/open/floor/almayer{
icon_state = "mono"
},
Expand Down Expand Up @@ -6629,7 +6631,9 @@
},
/area/almayer/engineering/engineering_workshop/hangar)
"auJ" = (
/obj/structure/machinery/floodlight/landing,
/obj/structure/machinery/floodlight/landing{
name = "bolted floodlight"
},
/turf/open/floor/almayer{
icon_state = "mono"
},
Expand Down Expand Up @@ -49266,7 +49270,9 @@
},
/area/almayer/living/port_emb)
"lqZ" = (
/obj/structure/machinery/floodlight/landing,
/obj/structure/machinery/floodlight/landing{
name = "bolted floodlight"
},
/turf/open/floor/almayer{
icon_state = "mono"
},
Expand Down Expand Up @@ -52574,7 +52580,9 @@
},
/area/almayer/hallways/stern_hallway)
"mMu" = (
/obj/structure/machinery/floodlight/landing,
/obj/structure/machinery/floodlight/landing{
name = "bolted floodlight"
},
/turf/open/floor/almayer{
icon_state = "mono"
},
Expand Down

0 comments on commit abded50

Please sign in to comment.