Minor lift tweaks (#3321)

changes:

Lift delays are now saner and seem to work better.
Lifts will no longer squish mobs if they are travelling upwards and not at the top floor.
This commit is contained in:
Lohikar
2017-08-29 23:22:12 +03:00
committed by Erki
parent c80d893e71
commit f52c16038d
+28 -27
View File
@@ -17,31 +17,32 @@
/datum/turbolift/proc/emergency_stop()
deltimer(move_timer)
move_timer = null
queued_floors.Cut()
target_floor = null
open_doors()
/datum/turbolift/proc/doors_are_open(var/datum/turbolift_floor/use_floor = current_floor)
/datum/turbolift/proc/doors_are_open(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)
/datum/turbolift/proc/open_doors(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")
/datum/turbolift/proc/close_doors(var/datum/turbolift_floor/use_floor = current_floor)
/datum/turbolift/proc/close_doors(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")
/datum/turbolift/proc/do_move()
/datum/turbolift/proc/do_work()
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))
@@ -53,7 +54,9 @@
if(!doors_closing)
close_doors()
doors_closing = 1
queue_movement()
return 1
else // We failed to close the doors - probably, someone is blocking them; stop trying to move
doors_closing = 0
open_doors()
@@ -63,48 +66,49 @@
doors_closing = 0 // The doors weren't open, so they are done closing
var/area/turbolift/origin = locate(current_floor.area_ref)
var/area/turbolift/origin = locate(current_floor.area_ref) in all_areas
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)
queue_movement(floor_wait_delay + move_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]
next_floor = floors[current_floor_index + 1]
else
next_floor = floors[current_floor_index-1]
next_floor = floors[current_floor_index - 1]
var/area/turbolift/destination = locate(next_floor.area_ref)
var/area/turbolift/destination = locate(next_floor.area_ref) in all_areas
if(!istype(origin) || !istype(destination) || (origin == destination))
return 0
for(var/turf/T in destination)
for(var/atom/movable/AM in T)
if(istype(AM, /mob/living))
var/mob/living/M = AM
M.gib()
else if(AM.simulated && !istype(AM, /mob/eye))
qdel(AM)
if (!moving_upwards || next_floor == floors[floors.len]) // If moving down or moving to the top floor, squish.
for(var/turf/T in destination)
for(var/atom/movable/AM in T)
if(istype(AM, /mob/living))
var/mob/living/M = AM
M.gib()
else if(AM.simulated && !istype(AM, /mob/eye))
qdel(AM)
origin.move_contents_to(destination)
current_floor = next_floor
control_panel_interior.visible_message("The elevator [moving_upwards ? "rises" : "descends"] smoothly.")
queue_movement()
return 1
/datum/turbolift/proc/queue_move_to(var/datum/turbolift_floor/floor)
/datum/turbolift/proc/queue_move_to(datum/turbolift_floor/floor)
if(!floor || !(floor in floors) || (floor in queued_floors))
return // STOP PRESSING THE BUTTON.
floor.pending_move(src)
@@ -116,16 +120,13 @@
return 1
/datum/turbolift/proc/handle_movement()
busy = TRUE
if (!do_move())
if (!do_work())
if (target_floor)
target_floor.ext_panel.reset()
target_floor = null
else
queue_movement()
busy = FALSE
/datum/turbolift/proc/queue_movement(delay = move_delay)
if (!delay)
delay = move_delay
/datum/turbolift/proc/queue_movement()
move_timer = addtimer(CALLBACK(src, .proc/handle_movement), move_delay, TIMER_STOPPABLE)
move_timer = addtimer(CALLBACK(src, .proc/handle_movement), delay, TIMER_STOPPABLE | TIMER_UNIQUE)