Reworks shuttles to be more extensible

Kudos to Zuhayr for laying the groundwork for this.
This commit is contained in:
mwerezak
2014-06-08 18:26:09 -04:00
parent 0319c96502
commit b4bb8ab31d
7 changed files with 186 additions and 197 deletions

View File

@@ -65,7 +65,7 @@ datum/controller/game_controller/proc/setup()
if(!ticker)
ticker = new /datum/controller/gameticker()
if(!shuttles) shuttles = new /datum/shuttle_controller()
if(!shuttles) setup_shuttles()
setup_objects()
setupgenetics()

View File

@@ -14,7 +14,7 @@ var/global/datum/shuttle_controller/emergency_shuttle/emergency_shuttle
datum/shuttle_controller/emergency_shuttle
var/alert = 0 //0 = emergency, 1 = crew cycle
location = 0 //0 = somewhere far away (in spess), 1 = at SS13, 2 = returned from SS13
var/location = 0 //0 = somewhere far away (in spess), 1 = at SS13, 2 = returned from SS13
var/online = 0
var/direction = 1 //-1 = going back to central command, 1 = going to SS13, 2 = in transit to centcom (not recalled)

View File

@@ -169,7 +169,8 @@ var/list/mechtoys = list(
eta = round(ticksleft/600,1)
else
eta = 0
shuttles.move_shuttle("Supply")
var/datum/shuttle/S = shuttles["Supply"]
if (istype(S)) S.move()
moving = 0
at_station = !at_station
@@ -502,7 +503,8 @@ var/list/mechtoys = list(
supply_shuttle.moving = 0
supply_shuttle.at_station = !supply_shuttle.at_station
shuttles.move_shuttle("Supply")
var/datum/shuttle/S = shuttles["Supply"]
if (istype(S)) S.move()
temp = "The supply shuttle has departed.<BR><BR><A href='?src=\ref[src];mainmenu=1'>OK</A>"
else

View File

@@ -1923,15 +1923,17 @@
if("moveshuttle")
if(!shuttles) return // Something is very wrong, the shuttle controller has not been created.
if(!shuttles) return // Something is very wrong, the global shuttle list has not been created.
feedback_inc("admin_secrets_fun_used",1)
feedback_add_details("admin_secrets_fun_used","ShA")
var/shuttle_tag = input("Which shuttle do you want to call?") as null|anything in shuttles.location
var/shuttle_tag = input("Which shuttle do you want to call?") as null|anything in shuttles
if(shuttle_tag && !shuttles.moving[shuttle_tag])
shuttles.jump_shuttle(shuttle_tag)
if(shuttle_tag)
var/datum/shuttle/S = shuttles[shuttle_tag]
if(istype(S) && S.moving_status == 0)
S.move()
message_admins("\blue [key_name_admin(usr)] moved the [shuttle_tag] shuttle", 1)
log_admin("[key_name(usr)] moved the [shuttle_tag] shuttle")

View File

@@ -5,157 +5,46 @@
#define SHUTTLE_WARMUP 1
#define SHUTTLE_INTRANSIT 2
var/global/datum/shuttle_controller/shuttles
var/global/list/shuttles
/datum/shuttle_controller //This isn't really a controller...
var/list/location = list()
var/list/warmup = list()
var/list/moving = list()
var/list/areas_offsite = list()
var/list/areas_station = list()
/datum/shuttle
var/location = 0 //0 = at area_station, 1 = at area_offsite
var/warmup_time = 0
var/moving_status = SHUTTLE_IDLE //prevents people from doing things they shouldn't when the shuttle is in transit
var/in_use = 0 //prevents people from controlling the shuttle from different consoles at the same time
var/area_station
var/area_offsite
//Shuttles with multiple destinations don't quite behave in the same way as ferries.
var/list/multi_shuttles = list()
//docking stuff
var/list/docking_controller = list()
var/docking_controller = null
var/list/docking_targets = list()
/datum/shuttle_controller/New()
/datum/shuttle/proc/short_jump(var/datum/shuttle/shuttle,var/area/origin,var/area/destination)
if(moving_status != SHUTTLE_IDLE) return
..()
moving_status = SHUTTLE_WARMUP
spawn(warmup_time*10)
move(origin, destination)
moving_status = SHUTTLE_IDLE
//Supply and escape shuttles.
location["Supply"] = 1
warmup["Supply"] = 0
moving["Supply"] = SHUTTLE_IDLE
areas_offsite["Supply"] = locate(/area/supply/dock)
areas_station["Supply"] = locate(/area/supply/station)
docking_targets["Supply"] = list(null, null)
/datum/shuttle/proc/long_jump(var/shuttle_tag,var/area/departing,var/area/destination,var/area/interim,var/travel_time)
if(moving_status != SHUTTLE_IDLE) return
// Admin shuttles.
location["Centcom"] = 1
warmup["Centcom"] = 0
moving["Centcom"] = SHUTTLE_IDLE
areas_offsite["Centcom"] = locate(/area/shuttle/transport1/centcom)
areas_station["Centcom"] = locate(/area/shuttle/transport1/station)
docking_targets["Centcom"] = list(null, null)
moving_status = SHUTTLE_WARMUP
location["Administration"] = 1
warmup["Administration"] = 0
moving["Administration"] = SHUTTLE_IDLE
areas_offsite["Administration"] = locate(/area/shuttle/administration/centcom)
areas_station["Administration"] = locate(/area/shuttle/administration/station)
docking_targets["Administration"] = list(null, null)
location["Alien"] = 0
warmup["Alien"] = 0
moving["Alien"] = SHUTTLE_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.
location["Engineering"] = 1
warmup["Engineering"] = 10
moving["Engineering"] = SHUTTLE_IDLE
areas_offsite["Engineering"] = locate(/area/shuttle/constructionsite/site)
areas_station["Engineering"] = locate(/area/shuttle/constructionsite/station)
docking_targets["Engineering"] = list(null, null)
location["Mining"] = 0
warmup["Mining"] = 10
moving["Mining"] = SHUTTLE_IDLE
areas_offsite["Mining"] = locate(/area/shuttle/mining/outpost)
areas_station["Mining"] = locate(/area/shuttle/mining/station)
docking_targets["Mining"] = list(null, null)
location["Research"] = 0
warmup["Research"] = 10
moving["Research"] = SHUTTLE_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")
//Vox Shuttle.
var/datum/multi_shuttle/VS = new
VS.origin = /area/shuttle/vox/station
VS.destinations = list(
"Fore Starboard Solars" = /area/vox_station/northeast_solars,
"Fore Port Solars" = /area/vox_station/northwest_solars,
"Aft Starboard Solars" = /area/vox_station/southeast_solars,
"Aft Port Solars" = /area/vox_station/southwest_solars,
"Mining asteroid" = /area/vox_station/mining
)
VS.announcer = "NSV Icarus"
VS.arrival_message = "Attention, Exodus, we just tracked a small target bypassing our defensive perimeter. Can't fire on it without hitting the station - you've got incoming visitors, like it or not."
VS.departure_message = "Your guests are pulling away, Exodus - moving too fast for us to draw a bead on them. Looks like they're heading out of the system at a rapid clip."
VS.interim = /area/vox_station/transit
multi_shuttles["Vox Skipjack"] = VS
location["Vox Skipjack"] = 1
warmup["Vox Skipjack"] = 10
moving["Vox Skipjack"] = SHUTTLE_IDLE
//Nuke Ops shuttle.
var/datum/multi_shuttle/MS = new
MS.origin = /area/syndicate_station/start
MS.destinations = list(
"Northwest of the station" = /area/syndicate_station/northwest,
"North of the station" = /area/syndicate_station/north,
"Northeast of the station" = /area/syndicate_station/northeast,
"Southwest of the station" = /area/syndicate_station/southwest,
"South of the station" = /area/syndicate_station/south,
"Southeast of the station" = /area/syndicate_station/southeast,
"Telecomms Satellite" = /area/syndicate_station/commssat,
"Mining Asteroid" = /area/syndicate_station/mining
)
MS.announcer = "NSV Icarus"
MS.arrival_message = "Attention, Exodus, you have a large signature approaching the station - looks unarmed to surface scans. We're too far out to intercept - brace for visitors."
MS.departure_message = "Your visitors are on their way out of the system, Exodus, burning delta-v like it's nothing. Good riddance."
MS.interim = /area/syndicate_station/transit
multi_shuttles["Syndicate"] = MS
location["Syndicate"] = 1
warmup["Syndicate"] = 10
moving["Syndicate"] = SHUTTLE_IDLE
/datum/shuttle_controller/proc/jump_shuttle(var/shuttle_tag,var/area/origin,var/area/destination)
if(moving[shuttle_tag] != SHUTTLE_IDLE) return
moving[shuttle_tag] = SHUTTLE_WARMUP
spawn(warmup[shuttle_tag]*10)
move_shuttle(shuttle_tag, origin, destination)
moving[shuttle_tag] = SHUTTLE_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] != SHUTTLE_IDLE) return
moving[shuttle_tag] = SHUTTLE_WARMUP
spawn(warmup[shuttle_tag]*10)
move_shuttle(shuttle_tag,locate(departing),locate(interim))
spawn(warmup_time*10)
move(locate(departing),locate(interim))
sleep(travel_time)
move_shuttle(shuttle_tag,locate(interim),locate(destination))
moving[shuttle_tag] = SHUTTLE_IDLE
return
move(locate(interim),locate(destination))
moving_status = SHUTTLE_IDLE
//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)
/datum/shuttle/proc/move(var/area/origin,var/area/destination)
//world << "move_shuttle() called for [shuttle_tag] leaving [origin] en route to [destination]."
if(!shuttle_tag || isnull(location[shuttle_tag]))
if(isnull(location))
return
var/area/area_going_to
@@ -163,16 +52,16 @@ var/global/datum/shuttle_controller/shuttles
//world << "Using supplied destination [destination]."
area_going_to = destination
else
//world << "Using controller value [(location[shuttle_tag] == 1 ? areas_station[shuttle_tag] : areas_offsite[shuttle_tag])]."
area_going_to = (location[shuttle_tag] == 1 ? areas_station[shuttle_tag] : areas_offsite[shuttle_tag])
//world << "Using controller value [(cur_location[shuttle_tag] == 1 ? areas_station[shuttle_tag] : areas_offsite[shuttle_tag])]."
area_going_to = (location == 1 ? area_station : area_offsite)
var/area/area_coming_from
if(origin)
//world << "Using supplied origin [origin]."
area_coming_from = origin
else
//world << "Using controller value [(location[shuttle_tag] == 1 ? areas_offsite[shuttle_tag] : areas_station[shuttle_tag])]."
area_coming_from = (location[shuttle_tag] == 1 ? areas_offsite[shuttle_tag] : areas_station[shuttle_tag])
//world << "Using controller value [(cur_location[shuttle_tag] == 1 ? areas_offsite[shuttle_tag] : areas_station[shuttle_tag])]."
area_coming_from = (location == 1 ? area_offsite : area_station)
//world << "area_coming_from: [area_coming_from]"
//world << "area_going_to: [area_going_to]"
@@ -181,7 +70,7 @@ var/global/datum/shuttle_controller/shuttles
//world << "cancelling move, shuttle will overlap."
return
moving[shuttle_tag] = SHUTTLE_INTRANSIT
moving_status = SHUTTLE_INTRANSIT
var/list/dstturfs = list()
var/throwy = world.maxy
@@ -206,7 +95,7 @@ var/global/datum/shuttle_controller/shuttles
area_coming_from.move_contents_to(area_going_to)
location[shuttle_tag] = !location[shuttle_tag]
location = !location //this needs to change.
for(var/mob/M in area_going_to)
if(M.client)
@@ -222,3 +111,106 @@ var/global/datum/shuttle_controller/shuttles
M.Weaken(3)
return
/proc/setup_shuttles()
var/datum/shuttle/shuttle
//Supply and escape shuttles.
shuttle = new/datum/shuttle()
shuttle.location = 1
shuttle.area_offsite = locate(/area/supply/dock)
shuttle.area_station = locate(/area/supply/station)
shuttle.docking_targets = list(null, null)
shuttles["Supply"] = shuttle
// Admin shuttles.
shuttle = new/datum/shuttle()
shuttle.location = 1
shuttle.area_offsite = locate(/area/shuttle/transport1/centcom)
shuttle.area_station = locate(/area/shuttle/transport1/station)
shuttle.docking_targets = list(null, null)
shuttles["Centcom"] = shuttle
shuttle = new/datum/shuttle()
shuttle.location = 1
shuttle.area_offsite = locate(/area/shuttle/administration/centcom)
shuttle.area_station = locate(/area/shuttle/administration/station)
shuttle.docking_targets = list(null, null)
shuttles["Administration"] = shuttle
shuttle = new/datum/shuttle()
shuttle.area_offsite = locate(/area/shuttle/alien/base)
shuttle.area_station = locate(/area/shuttle/alien/mine)
shuttle.docking_targets = list(null, null)
shuttles["Alien"] = shuttle
// Public shuttles
shuttle = new/datum/shuttle()
shuttle.location = 1
shuttle.warmup_time = 10
shuttle.area_offsite = locate(/area/shuttle/constructionsite/site)
shuttle.area_station = locate(/area/shuttle/constructionsite/station)
shuttle.docking_targets = list(null, null)
shuttles["Engineering"] = shuttle
shuttle = new/datum/shuttle()
shuttle.warmup_time = 10
shuttle.area_offsite = locate(/area/shuttle/mining/outpost)
shuttle.area_station = locate(/area/shuttle/mining/station)
shuttle.docking_targets = list(null, null)
shuttles["Mining"] = shuttle
shuttle = new/datum/shuttle()
shuttle.warmup_time = 10
shuttle.area_offsite = locate(/area/shuttle/research/outpost)
shuttle.area_station = locate(/area/shuttle/research/station)
shuttle.docking_targets = list(null, null)
shuttles["Research"] = shuttle
//Vox Shuttle.
var/datum/shuttle/multi_shuttle/VS = new/datum/shuttle/multi_shuttle()
VS.origin = /area/shuttle/vox/station
VS.destinations = list(
"Fore Starboard Solars" = /area/vox_station/northeast_solars,
"Fore Port Solars" = /area/vox_station/northwest_solars,
"Aft Starboard Solars" = /area/vox_station/southeast_solars,
"Aft Port Solars" = /area/vox_station/southwest_solars,
"Mining asteroid" = /area/vox_station/mining
)
VS.announcer = "NSV Icarus"
VS.arrival_message = "Attention, Exodus, we just tracked a small target bypassing our defensive perimeter. Can't fire on it without hitting the station - you've got incoming visitors, like it or not."
VS.departure_message = "Your guests are pulling away, Exodus - moving too fast for us to draw a bead on them. Looks like they're heading out of the system at a rapid clip."
VS.interim = /area/vox_station/transit
VS.location = 1
VS.warmup_time = 10
shuttles["Vox Skipjack"] = VS
//Nuke Ops shuttle.
var/datum/shuttle/multi_shuttle/MS = new/datum/shuttle/multi_shuttle()
MS.origin = /area/syndicate_station/start
MS.destinations = list(
"Northwest of the station" = /area/syndicate_station/northwest,
"North of the station" = /area/syndicate_station/north,
"Northeast of the station" = /area/syndicate_station/northeast,
"Southwest of the station" = /area/syndicate_station/southwest,
"South of the station" = /area/syndicate_station/south,
"Southeast of the station" = /area/syndicate_station/southeast,
"Telecomms Satellite" = /area/syndicate_station/commssat,
"Mining Asteroid" = /area/syndicate_station/mining
)
MS.announcer = "NSV Icarus"
MS.arrival_message = "Attention, Exodus, you have a large signature approaching the station - looks unarmed to surface scans. We're too far out to intercept - brace for visitors."
MS.departure_message = "Your visitors are on their way out of the system, Exodus, burning delta-v like it's nothing. Good riddance."
MS.interim = /area/syndicate_station/transit
MS.location = 1
MS.warmup_time = 10
shuttles["Syndicate"] = MS

View File

@@ -1,3 +1,7 @@
#define STATUS_IDLE
#define STATUS_LAUNCH
#define STATUS_ARRIVE
/obj/machinery/computer/shuttle_control
name = "shuttle control console"
icon = 'icons/obj/computer.dmi'
@@ -7,54 +11,46 @@
//for mapping
var/shuttle_tag // Used to coordinate data in shuttle controller.
var/datum/shuttle/shuttle
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.
var/wait_for_launch = 0
/obj/machinery/computer/shuttle_control/initialize()
shuttle = shuttles[shuttle_tag]
//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/process()
/*
switch (launch_status)
if (wait_for_launch)
if (docking_controller && docking_controller.can_launch())
shuttles.jump_shuttle(shuttle_tag)
wait_for_launch = 0
*/
/*
/obj/machinery/computer/shuttle_control/attack_hand(user as mob)
if(..(user))
return
src.add_fingerprint(user)
//src.add_fingerprint(user) //shouldn't need fingerprints just for looking at it.
//ui_interact()
ui_interact(user)
var/dat
dat = "<center>[shuttle_tag] Shuttle Control<hr>"
if(waiting || shuttles.moving[shuttle_tag])
dat += "Location: <font color='red'>Moving</font> <br>"
else
dat += "Location: [shuttles.location[shuttle_tag] ? "Offsite" : "Station"] <br>"
dat += "<b><A href='?src=\ref[src];move=[1]'>Send</A></b></center>"
user << browse("[dat]", "window=[shuttle_tag]shuttlecontrol;size=200x150")
*/
/obj/machinery/computer/shuttle_control/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null)
var/data[0]
var/shuttle_state
switch(shuttles.moving[shuttle_tag])
switch(shuttle.moving_status)
if(SHUTTLE_IDLE) shuttle_state = "idle"
if(SHUTTLE_WARMUP) shuttle_state = "warmup"
if(SHUTTLE_INTRANSIT) shuttle_state = "in_transit"
@@ -62,7 +58,7 @@
if (docking_controller)
data = list(
"shuttle_state" = shuttle_state,
"shuttle_loc" = shuttles.location[shuttle_tag],
"shuttle_loc" = shuttle.location,
"has_docking" = 1,
"docking_status" = docking_controller.get_docking_status(),
"override_enabled" = docking_controller.override_enabled,
@@ -70,7 +66,7 @@
else
data = list(
"shuttle_state" = shuttle_state,
"shuttle_loc" = shuttles.location[shuttle_tag],
"shuttle_loc" = shuttle.location,
"has_docking" = 0,
"docking_status" = null,
"override_enabled" = null,
@@ -84,6 +80,7 @@
ui.open()
ui.set_auto_update(1)
//TODO: Canceling launches
/obj/machinery/computer/shuttle_control/Topic(href, href_list)
if(..())
return
@@ -91,9 +88,9 @@
src.add_fingerprint(usr)
if(href_list["move"])
if (!shuttles.moving[shuttle_tag])
if (shuttle.moving_status == SHUTTLE_IDLE)
usr << "\blue [shuttle_tag] Shuttle recieved message and will be sent shortly."
wait_for_launch = 1
shuttle.short_jump()
else
usr << "\blue [shuttle_tag] Shuttle is already moving."
@@ -114,10 +111,9 @@
/proc/setup_shuttle_docks()
var/list/setup_complete = list() //so we dont setup the same shuttle repeatedly
for (var/obj/machinery/computer/shuttle_control/S in machines)
var/location = shuttles.location[S.shuttle_tag]
var/dock_target = shuttles.docking_targets[S.shuttle_tag][location+1] //damned byond is 1-indexed - don't forget
for (var/obj/machinery/computer/shuttle_control/SC in machines)
var/dock_target = SC.shuttle.docking_targets[SC.shuttle.location+1] //damned byond is 1-indexed - don't forget
if (!(S.shuttle_tag in setup_complete) && S.docking_controller && dock_target)
S.docking_controller.initiate_docking(dock_target)
setup_complete += S.shuttle_tag
if (!(SC.shuttle_tag in setup_complete) && SC.docking_controller && dock_target)
SC.docking_controller.initiate_docking(dock_target)
setup_complete += SC.shuttle_tag

View File

@@ -1,5 +1,5 @@
//This is a holder for things like the Vox and Nuke shuttle.
/datum/multi_shuttle
/datum/shuttle/multi_shuttle
var/cloaked = 1
var/at_origin = 1
@@ -17,18 +17,18 @@
var/area/origin
var/return_warning = 0
/datum/multi_shuttle/New()
/datum/shuttle/multi_shuttle/New()
..()
if(origin) last_departed = origin
/datum/multi_shuttle/proc/announce_departure()
/datum/shuttle/multi_shuttle/proc/announce_departure()
if(cloaked || isnull(departure_message))
return
command_alert(departure_message,(announcer ? announcer : "Central Command"))
/datum/multi_shuttle/proc/announce_arrival()
/datum/shuttle/multi_shuttle/proc/announce_arrival()
if(cloaked || isnull(arrival_message))
return
@@ -44,14 +44,14 @@
return
src.add_fingerprint(user)
var/datum/multi_shuttle/MS = shuttles.multi_shuttles[shuttle_tag]
var/datum/shuttle/multi_shuttle/MS = shuttles[shuttle_tag]
if(!istype(MS)) return
var/dat
dat = "<center>[shuttle_tag] Ship Control<hr>"
if(shuttles.moving[shuttle_tag])
if(MS.moving_status != SHUTTLE_IDLE)
dat += "Location: <font color='red'>Moving</font> <br>"
else
var/area/areacheck = get_area(src)
@@ -76,10 +76,10 @@
usr.set_machine(src)
src.add_fingerprint(usr)
var/datum/multi_shuttle/MS = shuttles.multi_shuttles[shuttle_tag]
var/datum/shuttle/multi_shuttle/MS = shuttles[shuttle_tag]
if(!istype(MS)) return
if (shuttles.moving[shuttle_tag])
if (MS.moving_status != SHUTTLE_IDLE)
usr << "\blue [shuttle_tag] vessel is moving."
return
@@ -99,21 +99,17 @@
MS.return_warning = 1
return
shuttles.jump_shuttle_long(shuttle_tag,MS.last_departed,MS.origin,MS.interim,MS.move_time)
MS.long_jump(MS.last_departed,MS.origin,MS.interim,MS.move_time)
MS.last_departed = MS.origin
MS.at_origin = 1
if(href_list["toggle_cloak"])
if(!shuttles.multi_shuttles) return
MS.cloaked = !MS.cloaked
usr << "\red Ship stealth systems have been [(MS.cloaked ? "activated. The station will not" : "deactivated. The station will")] be warned of our arrival."
if(href_list["move_multi"])
if(!shuttles.multi_shuttles) return
var/choice = input("Select a destination.") as null|anything in MS.destinations
if(!choice) return
@@ -124,7 +120,8 @@
MS.last_departed = MS.origin
MS.at_origin = 0
shuttles.jump_shuttle_long(shuttle_tag,MS.last_departed,MS.destinations[choice],MS.interim,MS.move_time)
MS.long_jump(MS.last_departed,MS.destinations[choice],MS.interim,MS.move_time)
MS.last_departed = MS.destinations[choice]
return
@@ -132,7 +129,7 @@
MS.announce_departure()
shuttles.jump_shuttle(shuttle_tag,locate(MS.last_departed),locate(MS.destinations[choice]))
MS.short_jump(locate(MS.last_departed),locate(MS.destinations[choice]))
MS.last_departed = MS.destinations[choice]
updateUsrDialog()