mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Turbolifts, and shuttles. Please behave. Shuttles throw everything to z1 regardless of actual shuttle destination z-level, which is silly. Secondly they literally throw it using Move which is silly. Thirdly, they do it to every atom/movable, which is unacceptable. Especially since that tries to squash lighting overlays out of the way, making weird lighting problems on shuttles. Turbolifts qdel any 'simulated' atom/movable when they run into it, which is also stupid. This includes things like the AI Eye, which permanently deletes it. A little unfortunate, if you ask me.
122 lines
4.0 KiB
Plaintext
122 lines
4.0 KiB
Plaintext
// Lift master datum. One per turbolift.
|
|
/datum/turbolift
|
|
var/datum/turbolift_floor/target_floor // Where are we going?
|
|
var/datum/turbolift_floor/current_floor // Where is the lift currently?
|
|
var/list/doors = list() // Doors inside the lift structure.
|
|
var/list/queued_floors = list() // Where are we moving to next?
|
|
var/list/floors = list() // All floors in this system.
|
|
var/move_delay = 30 // Time between floor changes.
|
|
var/floor_wait_delay = 85 // Time to wait at floor stops.
|
|
var/obj/structure/lift/panel/control_panel_interior // Lift control panel.
|
|
var/doors_closing = 0 // Whether doors are in the process of closing
|
|
|
|
var/tmp/moving_upwards
|
|
var/tmp/busy
|
|
|
|
/datum/turbolift/proc/emergency_stop()
|
|
queued_floors.Cut()
|
|
target_floor = null
|
|
open_doors()
|
|
|
|
/datum/turbolift/proc/doors_are_open(var/datum/turbolift_floor/use_floor = current_floor)
|
|
for(var/obj/machinery/door/airlock/door in (use_floor ? (doors + use_floor.doors) : doors))
|
|
if(!door.density)
|
|
return 1
|
|
return 0
|
|
|
|
/datum/turbolift/proc/open_doors(var/datum/turbolift_floor/use_floor = current_floor)
|
|
for(var/obj/machinery/door/airlock/door in (use_floor ? (doors + use_floor.doors) : doors))
|
|
//door.command("open")
|
|
spawn(0)
|
|
door.open()
|
|
return
|
|
|
|
/datum/turbolift/proc/close_doors(var/datum/turbolift_floor/use_floor = current_floor)
|
|
for(var/obj/machinery/door/airlock/door in (use_floor ? (doors + use_floor.doors) : doors))
|
|
//door.command("close")
|
|
spawn(0)
|
|
door.close()
|
|
return
|
|
|
|
/datum/turbolift/proc/do_move()
|
|
|
|
var/current_floor_index = floors.Find(current_floor)
|
|
|
|
if(!target_floor)
|
|
if(!queued_floors || !queued_floors.len)
|
|
return 0
|
|
target_floor = queued_floors[1]
|
|
queued_floors -= target_floor
|
|
if(current_floor_index < floors.Find(target_floor))
|
|
moving_upwards = 1
|
|
else
|
|
moving_upwards = 0
|
|
|
|
if(doors_are_open())
|
|
if(!doors_closing)
|
|
close_doors()
|
|
doors_closing = 1
|
|
return 1
|
|
else // We failed to close the doors - probably, someone is blocking them; stop trying to move
|
|
doors_closing = 0
|
|
open_doors()
|
|
control_panel_interior.audible_message("\The [current_floor.ext_panel] buzzes loudly.")
|
|
playsound(control_panel_interior.loc, "sound/machines/buzz-two.ogg", 50, 1)
|
|
return 0
|
|
|
|
doors_closing = 0 // The doors weren't open, so they are done closing
|
|
|
|
var/area/turbolift/origin = locate(current_floor.area_ref)
|
|
|
|
if(target_floor == current_floor)
|
|
|
|
playsound(control_panel_interior.loc, origin.arrival_sound, 50, 1)
|
|
target_floor.arrived(src)
|
|
target_floor = null
|
|
|
|
sleep(15)
|
|
control_panel_interior.visible_message("<b>The elevator</b> announces, \"[origin.lift_announce_str]\"")
|
|
sleep(floor_wait_delay)
|
|
|
|
return 1
|
|
|
|
// Work out where we're headed.
|
|
var/datum/turbolift_floor/next_floor
|
|
if(moving_upwards)
|
|
next_floor = floors[current_floor_index+1]
|
|
else
|
|
next_floor = floors[current_floor_index-1]
|
|
|
|
var/area/turbolift/destination = locate(next_floor.area_ref)
|
|
|
|
if(!istype(origin) || !istype(destination) || (origin == destination))
|
|
return 0
|
|
|
|
for(var/turf/T in destination)
|
|
for(var/I in T)
|
|
if(istype(I, /mob/living))
|
|
var/mob/living/L = I
|
|
L.gib()
|
|
else if(istype(I,/obj))
|
|
qdel(I)
|
|
|
|
origin.move_contents_to(destination)
|
|
|
|
if((locate(/obj/machinery/power) in destination) || (locate(/obj/structure/cable) in destination))
|
|
makepowernets()
|
|
|
|
current_floor = next_floor
|
|
control_panel_interior.visible_message("The elevator [moving_upwards ? "rises" : "descends"] smoothly.")
|
|
|
|
return (next_floor.delay_time || move_delay || 30)
|
|
|
|
/datum/turbolift/proc/queue_move_to(var/datum/turbolift_floor/floor)
|
|
if(!floor || !(floor in floors) || (floor in queued_floors))
|
|
return // STOP PRESSING THE BUTTON.
|
|
floor.pending_move(src)
|
|
queued_floors |= floor
|
|
turbolift_controller.lift_is_moving(src)
|
|
|
|
// TODO: dummy machine ('lift mechanism') in powered area for functionality/blackout checks.
|
|
/datum/turbolift/proc/is_functional()
|
|
return 1 |