diff --git a/baystation12.dme b/baystation12.dme index e5f44afd9ef..806edf91683 100644 --- a/baystation12.dme +++ b/baystation12.dme @@ -1436,6 +1436,7 @@ #include "code\modules\shuttles\antagonist.dm" #include "code\modules\shuttles\departmental.dm" #include "code\modules\shuttles\shuttle.dm" +#include "code\modules\shuttles\shuttle_console.dm" #include "code\modules\shuttles\shuttles_multi.dm" #include "code\modules\store\items.dm" #include "code\modules\store\store.dm" diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 4b28083530c..7b231be1901 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2055,7 +2055,7 @@ var/shuttle_tag = input("Which shuttle do you want to call?") as null|anything in shuttles.locations if(shuttle_tag && !shuttles.moving[shuttle_tag]) - shuttles.move_shuttle(shuttle_tag) + shuttles.jump_shuttle(shuttle_tag) message_admins("\blue [key_name_admin(usr)] moved the [shuttle_tag] shuttle", 1) log_admin("[key_name(usr)] moved the [shuttle_tag] shuttle") diff --git a/code/modules/shuttles/shuttle.dm b/code/modules/shuttles/shuttle.dm index ac50f4c36de..d9556df317e 100644 --- a/code/modules/shuttles/shuttle.dm +++ b/code/modules/shuttles/shuttle.dm @@ -1,11 +1,15 @@ //These lists are populated in /datum/shuttle_controller/New() //Shuttle controller is instantiated in master_controller.dm. +#define STATUS_IDLE +#define STATUS_WARMUP +#define STATUS_INTRANSIT + var/global/datum/shuttle_controller/shuttles /datum/shuttle_controller //This isn't really a controller... var/list/locations = list() - var/list/delays = list() + var/list/warmup = list() var/list/moving = list() var/list/areas_offsite = list() var/list/areas_station = list() @@ -23,52 +27,52 @@ var/global/datum/shuttle_controller/shuttles //Supply and escape shuttles. locations["Supply"] = 1 - delays["Supply"] = 0 - moving["Supply"] = 0 + warmup["Supply"] = 0 + moving["Supply"] = STATUS_IDLE areas_offsite["Supply"] = locate(/area/supply/dock) areas_station["Supply"] = locate(/area/supply/station) docking_targets["Supply"] = list(null, null) // Admin shuttles. locations["Centcom"] = 1 - delays["Centcom"] = 0 - moving["Centcom"] = 0 + warmup["Centcom"] = 0 + moving["Centcom"] = STATUS_IDLE areas_offsite["Centcom"] = locate(/area/shuttle/transport1/centcom) areas_station["Centcom"] = locate(/area/shuttle/transport1/station) docking_targets["Centcom"] = list(null, null) locations["Administration"] = 1 - delays["Administration"] = 0 - moving["Administration"] = 0 + warmup["Administration"] = 0 + moving["Administration"] = STATUS_IDLE areas_offsite["Administration"] = locate(/area/shuttle/administration/centcom) areas_station["Administration"] = locate(/area/shuttle/administration/station) docking_targets["Administration"] = list(null, null) locations["Alien"] = 0 - delays["Alien"] = 0 - moving["Alien"] = 0 + warmup["Alien"] = 0 + moving["Alien"] = STATUS_IDLE areas_offsite["Alien"] = locate(/area/shuttle/alien/base) areas_station["Alien"] = locate(/area/shuttle/alien/mine) docking_targets["Alien"] = list(null, null) // Public shuttles. locations["Engineering"] = 1 - delays["Engineering"] = 10 - moving["Engineering"] = 0 + warmup["Engineering"] = 10 + moving["Engineering"] = STATUS_IDLE areas_offsite["Engineering"] = locate(/area/shuttle/constructionsite/site) areas_station["Engineering"] = locate(/area/shuttle/constructionsite/station) docking_targets["Engineering"] = list(null, null) locations["Mining"] = 0 - delays["Mining"] = 10 - moving["Mining"] = 0 + warmup["Mining"] = 10 + moving["Mining"] = STATUS_IDLE areas_offsite["Mining"] = locate(/area/shuttle/mining/outpost) areas_station["Mining"] = locate(/area/shuttle/mining/station) docking_targets["Mining"] = list(null, null) locations["Research"] = 0 - delays["Research"] = 10 - moving["Research"] = 0 + warmup["Research"] = 10 + moving["Research"] = STATUS_IDLE areas_offsite["Research"] = locate(/area/shuttle/research/outpost) areas_station["Research"] = locate(/area/shuttle/research/station) docking_targets["Research"] = list("research_dock_airlock", "research_dock_airlock") @@ -88,8 +92,8 @@ var/global/datum/shuttle_controller/shuttles multi_shuttles["Vox Skipjack"] = VS locations["Vox Skipjack"] = 1 - delays["Vox Skipjack"] = 10 - moving["Vox Skipjack"] = 0 + warmup["Vox Skipjack"] = 10 + moving["Vox Skipjack"] = STATUS_IDLE //Nuke Ops shuttle. var/datum/multi_shuttle/MS = new @@ -113,174 +117,104 @@ var/global/datum/shuttle_controller/shuttles multi_shuttles["Syndicate"] = MS locations["Syndicate"] = 1 - delays["Syndicate"] = 10 - moving["Syndicate"] = 0 + warmup["Syndicate"] = 10 + moving["Syndicate"] = STATUS_IDLE + +/datum/shuttle_controller/proc/jump_shuttle(var/shuttle_tag,var/area/origin,var/area/destination) + if(moving[shuttle_tag] != STATUS_IDLE) return + + moving[shuttle_tag] = STATUS_WARMUP + spawn(warmup[shuttle_tag]*10) + move_shuttle(shuttle_tag, origin, destination) + moving[shuttle_tag] = STATUS_IDLE + +//This is for shuttles with a timer before arrival such as the vox skipjack and the escape shuttle. +/datum/shuttle_controller/proc/jump_shuttle_long(var/shuttle_tag,var/area/departing,var/area/destination,var/area/interim,var/travel_time) + if(moving[shuttle_tag] != STATUS_IDLE) return + + moving[shuttle_tag] = STATUS_WARMUP + + spawn(warmup[shuttle_tag]*10) + move_shuttle(shuttle_tag,locate(departing),locate(interim)) + + sleep(travel_time) + + move_shuttle(shuttle_tag,locate(interim),locate(destination)) + + moving[shuttle_tag] = STATUS_IDLE + + return + + +//just moves the shuttle from A to B, if it can be moved /datum/shuttle_controller/proc/move_shuttle(var/shuttle_tag,var/area/origin,var/area/destination) //world << "move_shuttle() called for [shuttle_tag] leaving [origin] en route to [destination]." if(!shuttle_tag || isnull(locations[shuttle_tag])) return - if(moving[shuttle_tag] == 1) return - moving[shuttle_tag] = 1 - - spawn(delays[shuttle_tag]*10) - - var/area/area_going_to - if(destination) - //world << "Using supplied destination [destination]." - area_going_to = destination - else - //world << "Using controller value [(locations[shuttle_tag] == 1 ? areas_station[shuttle_tag] : areas_offsite[shuttle_tag])]." - area_going_to = (locations[shuttle_tag] == 1 ? areas_station[shuttle_tag] : areas_offsite[shuttle_tag]) - - var/area/area_coming_from - if(origin) - //world << "Using supplied origin [origin]." - area_coming_from = origin - else - //world << "Using controller value [(locations[shuttle_tag] == 1 ? areas_offsite[shuttle_tag] : areas_station[shuttle_tag])]." - area_coming_from = (locations[shuttle_tag] == 1 ? areas_offsite[shuttle_tag] : areas_station[shuttle_tag]) - - //world << "area_coming_from: [area_coming_from]" - //world << "area_going_to: [area_going_to]" - - if(area_coming_from == area_going_to) - //world << "cancelling move, shuttle will overlap." - moving[shuttle_tag] = 0 - return - - var/list/dstturfs = list() - var/throwy = world.maxy - - for(var/turf/T in area_going_to) - dstturfs += T - if(T.y < throwy) - throwy = T.y - - for(var/turf/T in dstturfs) - var/turf/D = locate(T.x, throwy - 1, 1) - for(var/atom/movable/AM as mob|obj in T) - AM.Move(D) - if(istype(T, /turf/simulated)) - del(T) - - for(var/mob/living/carbon/bug in area_going_to) - bug.gib() - - for(var/mob/living/simple_animal/pest in area_going_to) - pest.gib() - - area_coming_from.move_contents_to(area_going_to) - - locations[shuttle_tag] = !locations[shuttle_tag] - - for(var/mob/M in area_going_to) - if(M.client) - spawn(0) - if(M.buckled) - M << "\red Sudden acceleration presses you into your chair!" - shake_camera(M, 3, 1) - else - M << "\red The floor lurches beneath you!" - shake_camera(M, 10, 1) - if(istype(M, /mob/living/carbon)) - if(!M.buckled) - M.Weaken(3) - - moving[shuttle_tag] = 0 - return - -//This is for shuttles with a timer before arrival such as the vox skipjack and the escape shuttle. -/datum/shuttle_controller/proc/move_shuttle_long(var/shuttle_tag,var/area/departing,var/area/destination,var/area/interim,var/delay) - - move_shuttle(shuttle_tag,locate(departing),locate(interim)) - - spawn(1) - moving[shuttle_tag] = 1 //So they can't jump out by messing with the console. - - sleep(delay) - - moving[shuttle_tag] = 0 - move_shuttle(shuttle_tag,locate(interim),locate(destination)) - - return - -/obj/machinery/computer/shuttle_control - name = "shuttle console" - icon = 'icons/obj/computer.dmi' - icon_state = "shuttle" - req_access = list(access_engine) - circuit = "/obj/item/weapon/circuitboard/engineering_shuttle" - - //for mapping - var/shuttle_tag // Used to coordinate data in shuttle controller. - var/docking_controller_tag //tag of the controller used to coordinate docking - - var/datum/computer/file/embedded_program/docking/docking_controller //the controller itself - var/hacked = 0 // Has been emagged, no access restrictions. - -/obj/machinery/computer/shuttle_control/initialize() - //search for our controller, if we have one. - if (docking_controller_tag) - for (var/obj/machinery/embedded_controller/radio/C in machines) //only radio controllers are supported, for now... - if (C.id_tag == docking_controller_tag && istype(C.program, /datum/computer/file/embedded_program/docking)) - docking_controller = C.program - -/obj/machinery/computer/shuttle_control/attack_hand(user as mob) - - if(..(user)) - return - src.add_fingerprint(user) - var/dat - - dat = "