Absolute paths for shuttle controller

This commit is contained in:
Kilakk
2013-08-04 00:19:37 -04:00
parent 603fa03826
commit 2eae729426

View File

@@ -45,383 +45,382 @@ datum/shuttle_controller
if(istype(A, /area/hallway)) if(istype(A, /area/hallway))
A.readyalert() A.readyalert()
proc/shuttlealert(var/X) datum/shuttle_controller/proc/shuttlealert(var/X)
alert = X alert = X
proc/recall() datum/shuttle_controller/proc/recall()
if(direction == 1) if(direction == 1)
var/timeleft = timeleft() var/timeleft = timeleft()
if(alert == 0) if(alert == 0)
if(timeleft >= 600) if(timeleft >= 600)
return
captain_announce("The emergency shuttle has been recalled.")
world << sound('sound/AI/shuttlerecalled.ogg')
setdirection(-1)
online = 1
for(var/area/A in world)
if(istype(A, /area/hallway))
A.readyreset()
return
else //makes it possible to send shuttle back.
captain_announce("The shuttle has been recalled.")
setdirection(-1)
online = 1
alert = 0 // set alert back to 0 after an admin recall
return return
captain_announce("The emergency shuttle has been recalled.")
world << sound('sound/AI/shuttlerecalled.ogg')
setdirection(-1)
online = 1
for(var/area/A in world)
if(istype(A, /area/hallway))
A.readyreset()
return
else //makes it possible to send shuttle back.
captain_announce("The shuttle has been recalled.")
setdirection(-1)
online = 1
alert = 0 // set alert back to 0 after an admin recall
return
// returns the time (in seconds) before shuttle arrival // returns the time (in seconds) before shuttle arrival
// note if direction = -1, gives a count-up to SHUTTLEARRIVETIME // note if direction = -1, gives a count-up to SHUTTLEARRIVETIME
proc/timeleft() datum/shuttle_controller/proc/timeleft()
if(online) if(online)
var/timeleft = round((endtime - world.timeofday)/10 ,1) var/timeleft = round((endtime - world.timeofday)/10 ,1)
if(direction == 1 || direction == 2) if(direction == 1 || direction == 2)
return timeleft return timeleft
else
return SHUTTLEARRIVETIME-timeleft
else else
return SHUTTLEARRIVETIME return SHUTTLEARRIVETIME-timeleft
else
return SHUTTLEARRIVETIME
// sets the time left to a given delay (in seconds) // sets the time left to a given delay (in seconds)
proc/settimeleft(var/delay) datum/shuttle_controller/proc/settimeleft(var/delay)
endtime = world.timeofday + delay * 10 endtime = world.timeofday + delay * 10
timelimit = delay timelimit = delay
// sets the shuttle direction // sets the shuttle direction
// 1 = towards SS13, -1 = back to centcom // 1 = towards SS13, -1 = back to centcom
proc/setdirection(var/dirn) datum/shuttle_controller/proc/setdirection(var/dirn)
if(direction == dirn) if(direction == dirn)
return
direction = dirn
// if changing direction, flip the timeleft by SHUTTLEARRIVETIME
var/ticksleft = endtime - world.timeofday
endtime = world.timeofday + (SHUTTLEARRIVETIME*10 - ticksleft)
return return
direction = dirn
// if changing direction, flip the timeleft by SHUTTLEARRIVETIME
var/ticksleft = endtime - world.timeofday
endtime = world.timeofday + (SHUTTLEARRIVETIME*10 - ticksleft)
return
proc/process() datum/shuttle_controller/proc/process()
emergency_shuttle datum/shuttle_controller/emergency_shuttle/process()
process() if(!online)
if(!online) return
return var/timeleft = timeleft()
var/timeleft = timeleft() if(timeleft > 1e5) // midnight rollover protection
if(timeleft > 1e5) // midnight rollover protection timeleft = 0
timeleft = 0 switch(location)
switch(location) if(0)
if(0)
/* --- Shuttle is in transit to Central Command from SS13 --- */ /* --- Shuttle is in transit to Central Command from SS13 --- */
if(direction == 2) if(direction == 2)
if(timeleft>0) if(timeleft>0)
return 0 return 0
/* --- Shuttle has arrived at Centrcal Command --- */ /* --- Shuttle has arrived at Centrcal Command --- */
else else
// turn off the star spawners // turn off the star spawners
/* /*
for(var/obj/effect/starspawner/S in world) for(var/obj/effect/starspawner/S in world)
S.spawning = 0 S.spawning = 0
*/ */
location = 2 location = 2
//main shuttle //main shuttle
var/area/start_location = locate(/area/shuttle/escape/transit) var/area/start_location = locate(/area/shuttle/escape/transit)
var/area/end_location = locate(/area/shuttle/escape/centcom) var/area/end_location = locate(/area/shuttle/escape/centcom)
start_location.move_contents_to(end_location, null, NORTH) start_location.move_contents_to(end_location, null, NORTH)
for(var/obj/machinery/door/unpowered/D in machines) for(var/obj/machinery/door/unpowered/shuttle/D in end_location)
if( get_area(D) == end_location ) spawn(0)
spawn(0) D.locked = 0
D.locked = 0 D.open()
D.open()
for(var/mob/M in end_location) for(var/mob/M in end_location)
if(M.client) if(M.client)
spawn(0) spawn(0)
if(M.buckled) if(M.buckled)
shake_camera(M, 4, 1) // buckled, not a lot of shaking shake_camera(M, 4, 1) // buckled, not a lot of shaking
else else
shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM
if(istype(M, /mob/living/carbon)) if(istype(M, /mob/living/carbon))
if(!M.buckled) if(!M.buckled)
M.Weaken(5) M.Weaken(5)
//pods //pods
start_location = locate(/area/shuttle/escape_pod1/transit) start_location = locate(/area/shuttle/escape_pod1/transit)
end_location = locate(/area/shuttle/escape_pod1/centcom) end_location = locate(/area/shuttle/escape_pod1/centcom)
start_location.move_contents_to(end_location, null, NORTH) start_location.move_contents_to(end_location, null, NORTH)
for(var/obj/machinery/door/D in machines) for(var/obj/machinery/door/D in machines)
if( get_area(D) == end_location ) if( get_area(D) == end_location )
spawn(0) spawn(0)
D.open() D.open()
for(var/mob/M in end_location) for(var/mob/M in end_location)
if(M.client) if(M.client)
spawn(0) spawn(0)
if(M.buckled) if(M.buckled)
shake_camera(M, 4, 1) // buckled, not a lot of shaking shake_camera(M, 4, 1) // buckled, not a lot of shaking
else else
shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM
if(istype(M, /mob/living/carbon)) if(istype(M, /mob/living/carbon))
if(!M.buckled) if(!M.buckled)
M.Weaken(5) M.Weaken(5)
start_location = locate(/area/shuttle/escape_pod2/transit) start_location = locate(/area/shuttle/escape_pod2/transit)
end_location = locate(/area/shuttle/escape_pod2/centcom) end_location = locate(/area/shuttle/escape_pod2/centcom)
start_location.move_contents_to(end_location, null, NORTH) start_location.move_contents_to(end_location, null, NORTH)
for(var/obj/machinery/door/D in machines) for(var/obj/machinery/door/D in machines)
if( get_area(D) == end_location ) if( get_area(D) == end_location )
spawn(0) spawn(0)
D.open() D.open()
for(var/mob/M in end_location) for(var/mob/M in end_location)
if(M.client) if(M.client)
spawn(0) spawn(0)
if(M.buckled) if(M.buckled)
shake_camera(M, 4, 1) // buckled, not a lot of shaking shake_camera(M, 4, 1) // buckled, not a lot of shaking
else else
shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM
if(istype(M, /mob/living/carbon)) if(istype(M, /mob/living/carbon))
if(!M.buckled) if(!M.buckled)
M.Weaken(5) M.Weaken(5)
start_location = locate(/area/shuttle/escape_pod3/transit) start_location = locate(/area/shuttle/escape_pod3/transit)
end_location = locate(/area/shuttle/escape_pod3/centcom) end_location = locate(/area/shuttle/escape_pod3/centcom)
start_location.move_contents_to(end_location, null, NORTH) start_location.move_contents_to(end_location, null, NORTH)
for(var/obj/machinery/door/D in machines) for(var/obj/machinery/door/D in machines)
if( get_area(D) == end_location ) if( get_area(D) == end_location )
spawn(0) spawn(0)
D.open() D.open()
for(var/mob/M in end_location) for(var/mob/M in end_location)
if(M.client) if(M.client)
spawn(0) spawn(0)
if(M.buckled) if(M.buckled)
shake_camera(M, 4, 1) // buckled, not a lot of shaking shake_camera(M, 4, 1) // buckled, not a lot of shaking
else else
shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM
if(istype(M, /mob/living/carbon)) if(istype(M, /mob/living/carbon))
if(!M.buckled) if(!M.buckled)
M.Weaken(5) M.Weaken(5)
start_location = locate(/area/shuttle/escape_pod5/transit) start_location = locate(/area/shuttle/escape_pod5/transit)
end_location = locate(/area/shuttle/escape_pod5/centcom) end_location = locate(/area/shuttle/escape_pod5/centcom)
start_location.move_contents_to(end_location, null, EAST) start_location.move_contents_to(end_location, null, EAST)
for(var/obj/machinery/door/D in machines) for(var/obj/machinery/door/D in machines)
if( get_area(D) == end_location ) if( get_area(D) == end_location )
spawn(0) spawn(0)
D.open() D.open()
for(var/mob/M in end_location) for(var/mob/M in end_location)
if(M.client) if(M.client)
spawn(0) spawn(0)
if(M.buckled) if(M.buckled)
shake_camera(M, 4, 1) // buckled, not a lot of shaking shake_camera(M, 4, 1) // buckled, not a lot of shaking
else else
shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM
if(istype(M, /mob/living/carbon)) if(istype(M, /mob/living/carbon))
if(!M.buckled) if(!M.buckled)
M.Weaken(5) M.Weaken(5)
online = 0 online = 0
return 1 return 1
/* --- Shuttle has docked centcom after being recalled --- */ /* --- Shuttle has docked centcom after being recalled --- */
if(timeleft>timelimit) if(timeleft>timelimit)
online = 0 online = 0
direction = 1 direction = 1
endtime = null endtime = null
return 0 return 0
else if((fake_recall != 0) && (timeleft <= fake_recall)) else if((fake_recall != 0) && (timeleft <= fake_recall))
recall() recall()
fake_recall = 0 fake_recall = 0
return 0 return 0
/* --- Shuttle has docked with the station - begin countdown to transit --- */ /* --- Shuttle has docked with the station - begin countdown to transit --- */
else if(timeleft <= 0) else if(timeleft <= 0)
location = 1 location = 1
var/area/start_location = locate(/area/shuttle/escape/centcom) var/area/start_location = locate(/area/shuttle/escape/centcom)
var/area/end_location = locate(/area/shuttle/escape/station) var/area/end_location = locate(/area/shuttle/escape/station)
var/list/dstturfs = list() var/list/dstturfs = list()
var/throwy = world.maxy var/throwy = world.maxy
for(var/turf/T in end_location) for(var/turf/T in end_location)
dstturfs += T dstturfs += T
if(T.y < throwy) if(T.y < throwy)
throwy = T.y throwy = T.y
// hey you, get out of the way! // hey you, get out of the way!
for(var/turf/T in dstturfs) for(var/turf/T in dstturfs)
// find the turf to move things to // find the turf to move things to
var/turf/D = locate(T.x, throwy - 1, 1) var/turf/D = locate(T.x, throwy - 1, 1)
//var/turf/E = get_step(D, SOUTH) //var/turf/E = get_step(D, SOUTH)
for(var/atom/movable/AM as mob|obj in T) for(var/atom/movable/AM as mob|obj in T)
AM.Move(D) AM.Move(D)
// NOTE: Commenting this out to avoid recreating mass driver glitch // NOTE: Commenting this out to avoid recreating mass driver glitch
/* /*
spawn(0) spawn(0)
AM.throw_at(E, 1, 1) AM.throw_at(E, 1, 1)
return return
*/
if(istype(T, /turf/simulated))
del(T)
for(var/mob/living/carbon/bug in end_location) // If someone somehow is still in the shuttle's docking area...
bug.gib()
for(var/mob/living/simple_animal/pest in end_location) // And for the other kind of bug...
pest.gib()
start_location.move_contents_to(end_location)
settimeleft(SHUTTLELEAVETIME)
//send2irc("Server", "The Emergency Shuttle has docked with the station.")
captain_announce("The Emergency Shuttle has docked with the station. You have [round(timeleft()/60,1)] minutes to board the Emergency Shuttle.")
world << sound('sound/AI/shuttledock.ogg')
return 1
if(1)
// Just before it leaves, close the damn doors!
if(timeleft == 2 || timeleft == 1)
var/area/start_location = locate(/area/shuttle/escape/station)
for(var/obj/machinery/door/unpowered/shuttle/D in start_location)
spawn(0)
D.close()
D.locked = 1
if(timeleft>0)
return 0
/* --- Shuttle leaves the station, enters transit --- */
else
// Turn on the star effects
/* // kinda buggy atm, i'll fix this later
for(var/obj/effect/starspawner/S in world)
if(!S.spawning)
spawn() S.startspawn()
*/ */
departed = 1 // It's going! if(istype(T, /turf/simulated))
location = 0 // in deep space del(T)
direction = 2 // heading to centcom
//main shuttle for(var/mob/living/carbon/bug in end_location) // If someone somehow is still in the shuttle's docking area...
var/area/start_location = locate(/area/shuttle/escape/station) bug.gib()
var/area/end_location = locate(/area/shuttle/escape/transit)
settimeleft(SHUTTLETRANSITTIME) for(var/mob/living/simple_animal/pest in end_location) // And for the other kind of bug...
start_location.move_contents_to(end_location, null, NORTH) pest.gib()
for(var/obj/machinery/door/unpowered/shuttle/D in end_location) start_location.move_contents_to(end_location)
spawn(0) settimeleft(SHUTTLELEAVETIME)
D.close() //send2irc("Server", "The Emergency Shuttle has docked with the station.")
D.locked = 1 captain_announce("The Emergency Shuttle has docked with the station. You have [round(timeleft()/60,1)] minutes to board the Emergency Shuttle.")
world << sound('sound/AI/shuttledock.ogg')
return 1
if(1)
// Just before it leaves, close the damn doors!
if(timeleft == 2 || timeleft == 1)
var/area/start_location = locate(/area/shuttle/escape/station)
for(var/obj/machinery/door/unpowered/shuttle/D in start_location)
spawn(0)
D.close()
D.locked = 1
if(timeleft>0)
return 0
/* --- Shuttle leaves the station, enters transit --- */
else
// Turn on the star effects
/* // kinda buggy atm, i'll fix this later
for(var/obj/effect/starspawner/S in world)
if(!S.spawning)
spawn() S.startspawn()
*/
departed = 1 // It's going!
location = 0 // in deep space
direction = 2 // heading to centcom
//main shuttle
var/area/start_location = locate(/area/shuttle/escape/station)
var/area/end_location = locate(/area/shuttle/escape/transit)
settimeleft(SHUTTLETRANSITTIME)
start_location.move_contents_to(end_location, null, NORTH)
// Close shuttle doors, lock
for(var/obj/machinery/door/unpowered/shuttle/D in end_location)
spawn(0)
D.close()
D.locked = 1
// Some aesthetic turbulance shaking // Some aesthetic turbulance shaking
for(var/mob/M in end_location) for(var/mob/M in end_location)
if(M.client) if(M.client)
spawn(0) spawn(0)
if(M.buckled) if(M.buckled)
shake_camera(M, 4, 1) // buckled, not a lot of shaking shake_camera(M, 4, 1) // buckled, not a lot of shaking
else else
shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM
if(istype(M, /mob/living/carbon)) if(istype(M, /mob/living/carbon))
if(!M.buckled) if(!M.buckled)
M.Weaken(5) M.Weaken(5)
//pods //pods
start_location = locate(/area/shuttle/escape_pod1/station) start_location = locate(/area/shuttle/escape_pod1/station)
end_location = locate(/area/shuttle/escape_pod1/transit) end_location = locate(/area/shuttle/escape_pod1/transit)
start_location.move_contents_to(end_location, null, NORTH) start_location.move_contents_to(end_location, null, NORTH)
for(var/obj/machinery/door/D in end_location) for(var/obj/machinery/door/D in end_location)
spawn(0) spawn(0)
D.close() D.close()
for(var/mob/M in end_location) for(var/mob/M in end_location)
if(M.client) if(M.client)
spawn(0) spawn(0)
if(M.buckled) if(M.buckled)
shake_camera(M, 4, 1) // buckled, not a lot of shaking shake_camera(M, 4, 1) // buckled, not a lot of shaking
else else
shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM
if(istype(M, /mob/living/carbon)) if(istype(M, /mob/living/carbon))
if(!M.buckled) if(!M.buckled)
M.Weaken(5) M.Weaken(5)
start_location = locate(/area/shuttle/escape_pod2/station) start_location = locate(/area/shuttle/escape_pod2/station)
end_location = locate(/area/shuttle/escape_pod2/transit) end_location = locate(/area/shuttle/escape_pod2/transit)
start_location.move_contents_to(end_location, null, NORTH) start_location.move_contents_to(end_location, null, NORTH)
for(var/obj/machinery/door/D in end_location) for(var/obj/machinery/door/D in end_location)
spawn(0) spawn(0)
D.close() D.close()
for(var/mob/M in end_location) for(var/mob/M in end_location)
if(M.client) if(M.client)
spawn(0) spawn(0)
if(M.buckled) if(M.buckled)
shake_camera(M, 4, 1) // buckled, not a lot of shaking shake_camera(M, 4, 1) // buckled, not a lot of shaking
else else
shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM
if(istype(M, /mob/living/carbon)) if(istype(M, /mob/living/carbon))
if(!M.buckled) if(!M.buckled)
M.Weaken(5) M.Weaken(5)
start_location = locate(/area/shuttle/escape_pod3/station) start_location = locate(/area/shuttle/escape_pod3/station)
end_location = locate(/area/shuttle/escape_pod3/transit) end_location = locate(/area/shuttle/escape_pod3/transit)
start_location.move_contents_to(end_location, null, NORTH) start_location.move_contents_to(end_location, null, NORTH)
for(var/obj/machinery/door/D in end_location) for(var/obj/machinery/door/D in end_location)
spawn(0) spawn(0)
D.close() D.close()
for(var/mob/M in end_location) for(var/mob/M in end_location)
if(M.client) if(M.client)
spawn(0) spawn(0)
if(M.buckled) if(M.buckled)
shake_camera(M, 4, 1) // buckled, not a lot of shaking shake_camera(M, 4, 1) // buckled, not a lot of shaking
else else
shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM
if(istype(M, /mob/living/carbon)) if(istype(M, /mob/living/carbon))
if(!M.buckled) if(!M.buckled)
M.Weaken(5) M.Weaken(5)
start_location = locate(/area/shuttle/escape_pod5/station) start_location = locate(/area/shuttle/escape_pod5/station)
end_location = locate(/area/shuttle/escape_pod5/transit) end_location = locate(/area/shuttle/escape_pod5/transit)
start_location.move_contents_to(end_location, null, EAST) start_location.move_contents_to(end_location, null, EAST)
for(var/obj/machinery/door/D in end_location) for(var/obj/machinery/door/D in end_location)
spawn(0) spawn(0)
D.close() D.close()
for(var/mob/M in end_location) for(var/mob/M in end_location)
if(M.client) if(M.client)
spawn(0) spawn(0)
if(M.buckled) if(M.buckled)
shake_camera(M, 4, 1) // buckled, not a lot of shaking shake_camera(M, 4, 1) // buckled, not a lot of shaking
else else
shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM shake_camera(M, 10, 2) // unbuckled, HOLY SHIT SHAKE THE ROOM
if(istype(M, /mob/living/carbon)) if(istype(M, /mob/living/carbon))
if(!M.buckled) if(!M.buckled)
M.Weaken(5) M.Weaken(5)
captain_announce("The Emergency Shuttle has left the station. Estimate [round(timeleft()/60,1)] minutes until the shuttle docks at Central Command.") captain_announce("The Emergency Shuttle has left the station. Estimate [round(timeleft()/60,1)] minutes until the shuttle docks at Central Command.")
return 1 return 1
else else
return 1 return 1
/* /*
@@ -436,23 +435,23 @@ datum/shuttle_controller
var/direction = SOUTH var/direction = SOUTH
layer = 2 // TURF_LAYER layer = 2 // TURF_LAYER
New() /obj/effect/bgstar/New()
..() ..()
pixel_x += rand(-2,30) pixel_x += rand(-2,30)
pixel_y += rand(-2,30) pixel_y += rand(-2,30)
var/starnum = pick("1", "1", "1", "2", "3", "4") var/starnum = pick("1", "1", "1", "2", "3", "4")
icon_state = "star"+starnum icon_state = "star"+starnum
speed = rand(2, 5) speed = rand(2, 5)
proc/startmove() /obj/effect/bgstar/proc/startmove()
while(src) while(src)
sleep(speed) sleep(speed)
step(src, direction) step(src, direction)
for(var/obj/effect/starender/E in loc) for(var/obj/effect/starender/E in loc)
del(src) del(src)
/obj/effect/starender /obj/effect/starender
@@ -463,16 +462,16 @@ datum/shuttle_controller
var/spawndir = SOUTH var/spawndir = SOUTH
var/spawning = 0 var/spawning = 0
West /obj/effect/starspawner/West
spawndir = WEST spawndir = WEST
proc/startspawn() /obj/effect/starspawner/proc/startspawn()
spawning = 1 spawning = 1
while(spawning) while(spawning)
sleep(rand(2, 30)) sleep(rand(2, 30))
var/obj/effect/bgstar/S = new/obj/effect/bgstar(locate(x,y,z)) var/obj/effect/bgstar/S = new/obj/effect/bgstar(locate(x,y,z))
S.direction = spawndir S.direction = spawndir
spawn() spawn()
S.startmove() S.startmove()