Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shuttle landing lights. #5222

Closed
Closed
76 changes: 26 additions & 50 deletions code/modules/power/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,8 @@
/obj/structure/machinery/landinglight
name = "landing light"
icon = 'icons/obj/structures/props/landinglights.dmi'
icon_state = "landingstripe"
icon_state = "landingstripe0"
desc = "A landing light, if it's flashing stay clear!"
var/id = "" // ID for landing zone
anchored = TRUE
density = FALSE
layer = BELOW_TABLE_LAYER
Expand All @@ -756,7 +755,10 @@
power_channel = POWER_CHANNEL_LIGHT //Lights are calc'd via area so they dont need to be in the machine list
unslashable = TRUE
unacidable = TRUE
var/obj/docking_port/stationary/marine_dropship/linked_port = null
var/obj/docking_port/stationary/linked_port = null
var/icon_on = "landingstripe0_on"
var/icon_off = "landingstripe_off"
var/light_strength = 2

//Don't allow blowing those up, so Marine nades don't fuck them
/obj/structure/machinery/landinglight/ex_act(severity)
Expand All @@ -773,53 +775,27 @@
linked_port = null

/obj/structure/machinery/landinglight/proc/turn_off()
icon_state = initial(icon_state)
icon_state = icon_off
set_light(0)

/obj/structure/machinery/landinglight/ds1
id = "USS Almayer Dropship 1" // ID for landing zone

/obj/structure/machinery/landinglight/ds2
id = "USS Almayer Dropship 2" // ID for landing zone

/obj/structure/machinery/landinglight/proc/turn_on()
icon_state = initial(icon_state) + "0"
set_light(2)

/obj/structure/machinery/landinglight/ds1/delayone/turn_on()
icon_state = initial(icon_state) + "1"
set_light(2)

/obj/structure/machinery/landinglight/ds1/delaytwo/turn_on()
icon_state = initial(icon_state) + "2"
set_light(2)

/obj/structure/machinery/landinglight/ds1/delaythree/turn_on()
icon_state = initial(icon_state) + "3"
set_light(2)

/obj/structure/machinery/landinglight/ds2/delayone/turn_on()
icon_state = initial(icon_state) + "1"
set_light(2)

/obj/structure/machinery/landinglight/ds2/delaytwo/turn_on()
icon_state = initial(icon_state) + "2"
set_light(2)

/obj/structure/machinery/landinglight/ds2/delaythree/turn_on()
icon_state = initial(icon_state) + "3"
set_light(2)

/obj/structure/machinery/landinglight/ds1/spoke
icon_state = "lz_spoke_light"

/obj/structure/machinery/landinglight/ds1/spoke/turn_on()
icon_state = initial(icon_state) + "1"
set_light(3)

/obj/structure/machinery/landinglight/ds2/spoke
icon_state = "lz_spoke_light"

/obj/structure/machinery/landinglight/ds2/spoke/turn_on()
icon_state = initial(icon_state) + "1"
set_light(3)
icon_state = icon_on
set_light(light_strength)

/obj/structure/machinery/landinglight/delayone
icon_state = "landingstripe1"
icon_on = "landingstripe1_on"

/obj/structure/machinery/landinglight/delaytwo
icon_state = "landingstripe2"
icon_on = "landingstripe2_on"

/obj/structure/machinery/landinglight/delaythree
icon_state = "landingstripe3"
icon_on = "landingstripe3_on"

/obj/structure/machinery/landinglight/spoke
icon_state = "lz_spoke_light_off"
icon_on = "lz_spoke_light_on"
icon_off = "lz_spoke_light_off"
light_strength = 3
52 changes: 50 additions & 2 deletions code/modules/shuttle/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@

var/datum/map_template/shuttle/roundstart_template
var/json_key
var/list/landing_lights = list()
var/landing_lights_on = FALSE

/obj/docking_port/stationary/register(replace = FALSE)
. = ..()
Expand Down Expand Up @@ -244,6 +246,7 @@
#ifdef DOCKING_PORT_HIGHLIGHT
highlight("#f00")
#endif
link_landing_lights()

/obj/docking_port/stationary/unregister()
. = ..()
Expand All @@ -252,6 +255,11 @@
/obj/docking_port/stationary/Destroy(force)
if(force)
unregister()
for(var/obj/structure/machinery/landinglight/light in landing_lights)
light.linked_port = null
if(landing_lights)
landing_lights.Cut()
landing_lights = null // We didn't make them, so lets leave them
realforest2001 marked this conversation as resolved.
Show resolved Hide resolved
. = ..()

/obj/docking_port/stationary/Moved(atom/oldloc, dir, forced)
Expand Down Expand Up @@ -280,24 +288,58 @@

/// Called when a new shuttle arrives
/obj/docking_port/stationary/proc/on_arrival(obj/docking_port/mobile/arriving_shuttle)
turn_off_landing_lights()
return

/// Called when a new shuttle is about to arrive
/obj/docking_port/stationary/proc/on_prearrival(obj/docking_port/mobile/arriving_shuttle)
/obj/docking_port/stationary/proc/on_prearrival(obj/docking_port/mobile/arriving_shuttle, landing_sound)
if(!landing_lights_on)
turn_on_landing_lights()
if(landing_sound)
playsound(return_center_turf(), landing_sound, 60, 0, falloff=4)

log_debug("SHUTTLE DEBUG: [name] static prearrival called!")
fira marked this conversation as resolved.
Show resolved Hide resolved
return

/// Called when the docked shuttle ignites
/obj/docking_port/stationary/proc/on_dock_ignition(obj/docking_port/mobile/departing_shuttle)
turn_on_landing_lights()
return

/// Called when a shuttle is about to complete undocking from this stationary dock (already physically gone)
/obj/docking_port/stationary/proc/on_departure(obj/docking_port/mobile/departing_shuttle)
turn_off_landing_lights()
return

//returns first-found touching shuttleport
/obj/docking_port/stationary/get_docked()
. = locate(/obj/docking_port/mobile) in loc

/obj/docking_port/stationary/proc/link_landing_lights()
var/list/coords = return_coords()
var/scan_range = 3
var/x0 = coords[1] - scan_range
var/y0 = coords[2] - scan_range
var/x1 = coords[3] + scan_range
var/y1 = coords[4] + scan_range

for(var/xscan = x0; xscan < x1; xscan++)
for(var/yscan = y0; yscan < y1; yscan++)
var/turf/searchspot = locate(xscan, yscan, src.z)
for(var/obj/structure/machinery/landinglight/light in searchspot)
landing_lights += light
light.linked_port = src

/obj/docking_port/stationary/proc/turn_on_landing_lights()
for(var/obj/structure/machinery/landinglight/light in landing_lights)
light.turn_on()
landing_lights_on = TRUE

/obj/docking_port/stationary/proc/turn_off_landing_lights()
for(var/obj/structure/machinery/landinglight/light in landing_lights)
light.turn_off()
landing_lights_on = FALSE

/obj/docking_port/stationary/transit
name = "In Transit"
var/datum/turf_reservation/reserved_area
Expand Down Expand Up @@ -556,8 +598,12 @@
return

/obj/docking_port/mobile/proc/on_prearrival()
log_debug("SHUTTLE DEBUG: [name] prearrival called!")
if(destination)
destination.on_prearrival(src)
destination.on_prearrival(src, landing_sound)
log_debug("SHUTTLE DEBUG: destination is '[destination.name]'")
else
log_debug("SHUTTLE DEBUG: No destination found.")
realforest2001 marked this conversation as resolved.
Show resolved Hide resolved
playsound(return_center_turf(), landing_sound, 60, 0)
return

Expand Down Expand Up @@ -704,6 +750,8 @@
if(prearrivalTime && mode != SHUTTLE_PREARRIVAL)
set_mode(SHUTTLE_PREARRIVAL)
realforest2001 marked this conversation as resolved.
Show resolved Hide resolved
setTimer(prearrivalTime)
log_debug("SHUTTLE DEBUG: shuttle on approach failed check!")
realforest2001 marked this conversation as resolved.
Show resolved Hide resolved
on_prearrival()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All assumptions prior to this PR have expected on_prearrival to occur below on line 708.

As I said before, this needs to be a new proc e.g. on_start_prearrival. Alternatively you do something similar inside of set_mode(SHUTTLE_PREARRIVAL)

Then move all landing light handling that is on_prearrival to the new on_start_prearrival

return
on_prearrival()
Comment on lines +749 to 751
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in prearrival being called twice for a single landing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is the second calling is at the same time as on_arrival and I don't know why it does it. It was doing it prior to my change, it's why the sounds were playing when I was testing but the lights weren't working

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document modifications from upstream code clearly please, this avoids things getting reverted on update

var/error = initiate_docking(destination, preferred_direction)
Expand Down
56 changes: 0 additions & 56 deletions code/modules/shuttle/shuttles/dropship.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,6 @@
if(mode == SHUTTLE_CRASHED)
return

var/obj/docking_port/stationary/marine_dropship/dropzone = destination
if(mode == SHUTTLE_PREARRIVAL && !dropzone.landing_lights_on)
if(istype(destination, /obj/docking_port/stationary/marine_dropship))
dropzone.turn_on_landing_lights()
playsound(dropzone.return_center_turf(), landing_sound, 60, 0)
playsound(return_center_turf(), landing_sound, 60, 0)

automated_check()

hijack?.check()
Expand Down Expand Up @@ -164,55 +157,11 @@
dwidth = 5
dheight = 10

var/list/landing_lights = list()
var/auto_open = FALSE
var/landing_lights_on = FALSE
var/xeno_announce = FALSE

/obj/docking_port/stationary/marine_dropship/Initialize(mapload)
. = ..()
link_landing_lights()

/obj/docking_port/stationary/marine_dropship/Destroy()
. = ..()
for(var/obj/structure/machinery/landinglight/light in landing_lights)
light.linked_port = null
if(landing_lights)
landing_lights.Cut()
landing_lights = null // We didn't make them, so lets leave them

/obj/docking_port/stationary/marine_dropship/proc/link_landing_lights()
var/list/coords = return_coords()
var/scan_range = 5
var/x0 = coords[1] - scan_range
var/y0 = coords[2] - scan_range
var/x1 = coords[3] + scan_range
var/y1 = coords[4] + scan_range

for(var/xscan = x0; xscan < x1; xscan++)
for(var/yscan = y0; yscan < y1; yscan++)
var/turf/searchspot = locate(xscan, yscan, src.z)
for(var/obj/structure/machinery/landinglight/light in searchspot)
landing_lights += light
light.linked_port = src

/obj/docking_port/stationary/marine_dropship/proc/turn_on_landing_lights()
for(var/obj/structure/machinery/landinglight/light in landing_lights)
light.turn_on()
landing_lights_on = TRUE

/obj/docking_port/stationary/marine_dropship/proc/turn_off_landing_lights()
for(var/obj/structure/machinery/landinglight/light in landing_lights)
light.turn_off()
landing_lights_on = FALSE

/obj/docking_port/stationary/marine_dropship/on_prearrival(obj/docking_port/mobile/arriving_shuttle)
. = ..()
turn_on_landing_lights()

/obj/docking_port/stationary/marine_dropship/on_arrival(obj/docking_port/mobile/arriving_shuttle)
. = ..()
turn_off_landing_lights()
if(auto_open && istype(arriving_shuttle, /obj/docking_port/mobile/marine_dropship))
var/obj/docking_port/mobile/marine_dropship/dropship = arriving_shuttle
dropship.in_flyby = FALSE
Expand All @@ -227,13 +176,8 @@
xeno_announcement(SPAN_XENOANNOUNCE("The dropship has landed."), "everything")
xeno_announce = FALSE

/obj/docking_port/stationary/marine_dropship/on_dock_ignition(obj/docking_port/mobile/departing_shuttle)
. = ..()
turn_on_landing_lights()

/obj/docking_port/stationary/marine_dropship/on_departure(obj/docking_port/mobile/departing_shuttle)
. = ..()
turn_off_landing_lights()
var/obj/docking_port/mobile/marine_dropship/dropship = departing_shuttle
for(var/obj/structure/dropship_equipment/eq as anything in dropship.equipments)
eq.on_launch()
Expand Down
1 change: 1 addition & 0 deletions code/modules/shuttle/shuttles/ert.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/obj/docking_port/mobile/emergency_response
name = "ERT Shuttle"
ignitionTime = DROPSHIP_WARMUP_TIME
prearrivalTime = DROPSHIP_WARMUP_TIME
area_type = /area/shuttle/ert
width = 7
height = 13
Expand Down
Binary file modified icons/obj/structures/props/landinglights.dmi
Binary file not shown.
Loading