diff --git a/baystation12.dme b/baystation12.dme
index df67636edd9..1d586ffa8bc 100644
--- a/baystation12.dme
+++ b/baystation12.dme
@@ -1444,6 +1444,7 @@
#include "code\modules\shuttles\shuttle.dm"
#include "code\modules\shuttles\shuttle_console.dm"
#include "code\modules\shuttles\shuttle_specops.dm"
+#include "code\modules\shuttles\shuttle_supply.dm"
#include "code\modules\shuttles\shuttles_multi.dm"
#include "code\modules\store\items.dm"
#include "code\modules\store\store.dm"
diff --git a/code/game/machinery/status_display.dm b/code/game/machinery/status_display.dm
index 746f5a06996..254c4e465d3 100644
--- a/code/game/machinery/status_display.dm
+++ b/code/game/machinery/status_display.dm
@@ -115,13 +115,22 @@
update_display(line1, line2)
if(4) // supply shuttle timer
var/line1 = "SUPPLY"
- var/line2
- if(supply_shuttle.moving)
+ var/line2 = ""
+
+ var/datum/shuttle/ferry/supply/shuttle = supply_shuttle.get_shuttle()
+ if (!shuttle)
+ line2 = "Error"
+ else if(shuttle.has_eta())
line2 = get_supply_shuttle_timer()
if(lentext(line2) > CHARS_PER_LINE)
line2 = "Error"
+ else if (shuttle.moving_status == SHUTTLE_WARMUP)
+ if (shuttle.at_station())
+ line2 = "Launch"
+ else
+ line2 = "ETA"
else
- if(supply_shuttle.at_station)
+ if(shuttle.at_station())
line2 = "Docked"
else
line1 = ""
@@ -167,8 +176,12 @@
return ""
proc/get_supply_shuttle_timer()
- if(supply_shuttle.moving)
- var/timeleft = round((supply_shuttle.eta_timeofday - world.timeofday) / 10,1)
+ var/datum/shuttle/ferry/supply/shuttle = supply_shuttle.get_shuttle()
+ if (!shuttle)
+ return "Error"
+
+ if(shuttle.has_eta())
+ var/timeleft = round((shuttle.arrive_time - world.time) / 10,1)
if(timeleft < 0)
return "Late"
return "[add_zero(num2text((timeleft / 60) % 60),2)]:[add_zero(num2text(timeleft % 60), 2)]"
diff --git a/code/game/objects/items/devices/PDA/cart.dm b/code/game/objects/items/devices/PDA/cart.dm
index cbbf4bcda20..c23be68bbca 100644
--- a/code/game/objects/items/devices/PDA/cart.dm
+++ b/code/game/objects/items/devices/PDA/cart.dm
@@ -412,9 +412,11 @@
if(mode==47)
var/supplyData[0]
- supplyData["shuttle_moving"] = supply_shuttle.moving
- supplyData["shuttle_eta"] = supply_shuttle.eta
- supplyData["shuttle_loc"] = supply_shuttle.at_station ? "Station" : "Dock"
+ var/datum/shuttle/ferry/supply/shuttle = supply_shuttle.get_shuttle()
+ if (shuttle)
+ supplyData["shuttle_moving"] = shuttle.has_eta()
+ supplyData["shuttle_eta"] = shuttle.eta_minutes()
+ supplyData["shuttle_loc"] = shuttle.at_station() ? "Station" : "Dock"
var/supplyOrderCount = 0
var/supplyOrderData[0]
for(var/S in supply_shuttle.shoppinglist)
diff --git a/code/game/supplyshuttle.dm b/code/game/supplyshuttle.dm
index 2277e85a064..be919a87d9e 100644
--- a/code/game/supplyshuttle.dm
+++ b/code/game/supplyshuttle.dm
@@ -143,15 +143,23 @@ var/list/mechtoys = list(
var/list/requestlist = list()
var/list/supply_packs = list()
//shuttle movement
- var/at_station = 0
var/movetime = 1200
- var/moving = 0
- var/eta_timeofday
- var/eta
+ var/shuttle_tag = "Supply"
New()
ordernum = rand(1,9000)
+ proc/get_shuttle()
+ if (!shuttles || !(shuttle_tag in shuttles))
+ return null
+
+ var/datum/shuttle/ferry/supply/shuttle = shuttles[shuttle_tag]
+
+ if (!istype(shuttle))
+ return null
+
+ return shuttle
+
//Supply shuttle ticker - handles supply point regenertion and shuttle travelling between centcomm and the station
proc/process()
for(var/typepath in (typesof(/datum/supply_packs) - /datum/supply_packs))
@@ -164,32 +172,13 @@ var/list/mechtoys = list(
if(processing)
iteration++
points += points_per_process
-
- if(moving == 1)
- var/ticksleft = (eta_timeofday - world.timeofday)
- if(ticksleft > 0)
- eta = round(ticksleft/600,1)
- else
- eta = 0
- var/datum/shuttle/S = shuttles["Supply"]
- if (istype(S)) S.move()
- moving = 0
- at_station = !at_station
+
+ var/datum/shuttle/ferry/supply/shuttle = get_shuttle()
+ if (shuttle)
+ shuttle.process_shuttle()
sleep(processing_interval)
- //Check whether the shuttle is allowed to move
- proc/can_move()
- if(moving) return 0
-
- var/area/shuttle = locate(/area/supply/station)
- if(!shuttle) return 0
-
- if(forbidden_atoms_check(shuttle))
- return 0
-
- return 1
-
//To stop things being sent to centcomm which should not be sent to centcomm. Recursively checks for these types.
proc/forbidden_atoms_check(atom/A)
if(istype(A,/mob/living))
@@ -210,11 +199,10 @@ var/list/mechtoys = list(
//Sellin
proc/sell()
- var/shuttle_at
- if(at_station) shuttle_at = SUPPLY_STATION_AREATYPE
- else shuttle_at = SUPPLY_DOCK_AREATYPE
+ var/datum/shuttle/ferry/supply/shuttle_datum = get_shuttle()
+ if (!shuttle_datum) return
- var/area/shuttle = locate(shuttle_at)
+ var/area/shuttle = shuttle_datum.get_location_area()
if(!shuttle) return
var/plasma_count = 0
@@ -262,11 +250,10 @@ var/list/mechtoys = list(
proc/buy()
if(!shoppinglist.len) return
- var/shuttle_at
- if(at_station) shuttle_at = SUPPLY_STATION_AREATYPE
- else shuttle_at = SUPPLY_DOCK_AREATYPE
+ var/datum/shuttle/ferry/supply/shuttle_datum = get_shuttle()
+ if (!shuttle_datum) return
- var/area/shuttle = locate(shuttle_at)
+ var/area/shuttle = shuttle_datum.get_location_area()
if(!shuttle) return
var/list/clear_turfs = list()
@@ -293,7 +280,7 @@ var/list/mechtoys = list(
slip.info = "
[command_name()] Shipping Manifest
"
slip.info +="Order #[SO.ordernum]
"
slip.info +="Destination: [station_name]
"
- slip.info +="[supply_shuttle.shoppinglist.len] PACKAGES IN THIS SHIPMENT
"
+ slip.info +="[shoppinglist.len] PACKAGES IN THIS SHIPMENT
"
slip.info +="CONTENTS:
"
//spawn the stuff, finish generating the manifest while you're at it
@@ -322,7 +309,7 @@ var/list/mechtoys = list(
slip.info += "CHECK CONTENTS AND STAMP BELOW THE LINE TO CONFIRM RECEIPT OF GOODS
"
if (SP.contraband) slip.loc = null //we are out of blanks for Form #44-D Ordering Illicit Drugs.
- supply_shuttle.shoppinglist.Cut()
+ shoppinglist.Cut()
return
/obj/item/weapon/paper/manifest
@@ -349,9 +336,11 @@ var/list/mechtoys = list(
if(temp)
dat = temp
else
- dat += {"
Supply shuttle
- Location: [supply_shuttle.moving ? "Moving to station ([supply_shuttle.eta] Mins.)":supply_shuttle.at_station ? "Station":"Dock"]
-
Supply points: [supply_shuttle.points]
+ var/datum/shuttle/ferry/supply/shuttle = supply_shuttle.get_shuttle()
+ if (shuttle)
+ dat += {"
Supply shuttle
+ Location: [shuttle.has_eta() ? "Moving to station ([shuttle.eta_minutes()] Mins.)":shuttle.at_station() ? "Docked":"Away"]
+
Supply points: [supply_shuttle.points]
\nRequest items
View approved orders
View requests
@@ -474,14 +463,48 @@ var/list/mechtoys = list(
if (temp)
dat = temp
else
- dat += {"
Supply shuttle
- \nLocation: [supply_shuttle.moving ? "Moving to station ([supply_shuttle.eta] Mins.)":supply_shuttle.at_station ? "Station":"Away"]
-
\nSupply points: [supply_shuttle.points]
\n
- [supply_shuttle.moving ? "\n*Must be away to order items*
\n
":supply_shuttle.at_station ? "\n*Must be away to order items*
\n
":"\nOrder items
\n
"]
- [supply_shuttle.moving ? "\n*Shuttle already called*
\n
":supply_shuttle.at_station ? "\nSend away
\n
":"\nSend to station
\n
"]
+ var/datum/shuttle/ferry/supply/shuttle = supply_shuttle.get_shuttle()
+ if (shuttle)
+ dat += "
Supply shuttle
"
+ dat += "\nLocation: "
+ if (shuttle.has_eta())
+ dat += "In transit ([shuttle.eta_minutes()] Mins.)
"
+ else
+ if (shuttle.at_station())
+ if (shuttle.docking_controller)
+ switch(shuttle.docking_controller.get_docking_status())
+ if ("docked") dat += "Docked at station
"
+ if ("undocked") dat += "Undocked from station
"
+ if ("docking") dat += "Docking with station [shuttle.can_force()? "OVERRIDE" : ""]
"
+ if ("undocking") dat += "Undocking from station [shuttle.can_force()? "OVERRIDE" : ""]
"
+ else
+ dat += "Station
"
+
+ if (shuttle.can_launch())
+ dat += "Send away"
+ else if (shuttle.can_cancel())
+ dat += "Cancel launch"
+ else
+ dat += "*Shuttle is busy*"
+ dat += "
\n
"
+ else
+ dat += "Away
"
+ if (shuttle.can_launch())
+ dat += "Request supply shuttle"
+ else if (shuttle.can_cancel())
+ dat += "Cancel request"
+ else
+ dat += "*Shuttle is busy*"
+ dat += "
\n
"
+
+
+ dat += {"
\nSupply points: [supply_shuttle.points]
\n
+// [shuttle.at_station() ? "\n*Must be away to order items*
\n
":"\nOrder items
\n
"]
+ \nOrder items
\n
\nView requests
\n
\nView orders
\n
\nClose"}
+
user << browse(dat, "window=computer;size=575x450")
onclose(user, "computer")
@@ -500,6 +523,10 @@ var/list/mechtoys = list(
if(!supply_shuttle)
world.log << "## ERROR: Eek. The supply_shuttle controller datum is missing somehow."
return
+ var/datum/shuttle/ferry/supply/shuttle = supply_shuttle.get_shuttle()
+ if (!shuttle)
+ world.log << "## ERROR: Eek. The supply/shuttle datum is missing somehow."
+ return
if(..())
return
@@ -508,28 +535,25 @@ var/list/mechtoys = list(
//Calling the shuttle
if(href_list["send"])
- if(!supply_shuttle.can_move())
- temp = "For safety reasons the automated supply shuttle cannot transport live organisms, classified nuclear weaponry or homing beacons.
OK"
-
- else if(supply_shuttle.at_station)
- supply_shuttle.moving = -1
- supply_shuttle.sell()
- supply_shuttle.moving = 0
- supply_shuttle.at_station = !supply_shuttle.at_station
-
- var/datum/shuttle/S = shuttles["Supply"]
- if (istype(S)) S.move()
-
- temp = "The supply shuttle has departed.
OK"
+ if(shuttle.at_station())
+ if (shuttle.forbidden_atoms_check())
+ temp = "For safety reasons the automated supply shuttle cannot transport live organisms, classified nuclear weaponry or homing beacons.
OK"
+ else
+ shuttle.launch(src)
+ temp = "Initiating launch sequence.
OK"
else
- supply_shuttle.moving = 1
- supply_shuttle.buy()
- supply_shuttle.eta_timeofday = (world.timeofday + supply_shuttle.movetime) % 864000
- temp = "The supply shuttle has been called and will arrive in [round(supply_shuttle.movetime/600,1)] minutes.
OK"
+ shuttle.launch(src)
+ temp = "The supply shuttle has been called and will arrive in approximately [round(supply_shuttle.movetime/600,1)] minutes.
OK"
post_signal("supply")
+
+ if (href_list["force_send"])
+ shuttle.force_launch(src)
+ if (href_list["cancel_send"])
+ shuttle.cancel_launch(src)
+
else if (href_list["order"])
- if(supply_shuttle.moving) return
+ //if(!shuttle.idle()) return //this shouldn't be necessary it seems
if(href_list["order"] == "categories")
//all_supply_groups
//Request what?
@@ -654,7 +678,7 @@ var/list/mechtoys = list(
temp = "Current requests:
"
for(var/S in supply_shuttle.requestlist)
var/datum/supply_order/SO = S
- temp += "#[SO.ordernum] - [SO.object.name] requested by [SO.orderedby] [supply_shuttle.moving ? "":supply_shuttle.at_station ? "":"Approve Remove"]
"
+ temp += "#[SO.ordernum] - [SO.object.name] requested by [SO.orderedby] [shuttle.idle() ? "":shuttle.at_station() ? "":"Approve Remove"]
"
temp += "
Clear list"
temp += "
OK"
diff --git a/code/modules/shuttles/shuttle.dm b/code/modules/shuttles/shuttle.dm
index 42a7d0a8658..40a8a269a12 100644
--- a/code/modules/shuttles/shuttle.dm
+++ b/code/modules/shuttles/shuttle.dm
@@ -1,9 +1,7 @@
//These lists are populated in /datum/shuttle_controller/New()
//Shuttle controller is instantiated in master_controller.dm.
-#define SHUTTLE_IDLE 0
-#define SHUTTLE_WARMUP 1
-#define SHUTTLE_INTRANSIT 2
+//shuttle moving state defines are in setup.dm
var/global/list/shuttles
@@ -128,7 +126,7 @@ var/global/list/shuttles
var/datum/shuttle/ferry/shuttle
//Supply and escape shuttles.
- shuttle = new()
+ shuttle = new/datum/shuttle/ferry/supply()
shuttle.location = 1
shuttle.area_offsite = locate(/area/supply/dock)
shuttle.area_station = locate(/area/supply/station)
diff --git a/code/modules/shuttles/shuttle_console.dm b/code/modules/shuttles/shuttle_console.dm
index 4391982c085..13f8884be3b 100644
--- a/code/modules/shuttles/shuttle_console.dm
+++ b/code/modules/shuttles/shuttle_console.dm
@@ -22,9 +22,9 @@
return
if(!destination)
- destination = (location == 1 ? area_station : area_offsite)
+ destination = get_location_area(!location)
if(!origin)
- origin = (location == 1 ? area_offsite : area_station)
+ origin = get_location_area(location)
..(origin, destination)
@@ -33,23 +33,31 @@
return
if(!destination)
- destination = (location == 1 ? area_station : area_offsite)
+ destination = get_location_area(!location)
if(!departing)
- departing = (location == 1 ? area_offsite : area_station)
+ departing = get_location_area(location)
..(departing, destination, interim, travel_time)
/datum/shuttle/ferry/move(var/area/origin,var/area/destination)
if(!destination)
- destination = (location == 1 ? area_station : area_offsite)
+ destination = get_location_area(!location)
if(!origin)
- origin = (location == 1 ? area_offsite : area_station)
-
+ origin = get_location_area(location)
+
if (docking_controller && !docking_controller.undocked())
docking_controller.force_undock()
..(origin, destination)
location = !location
+/datum/shuttle/ferry/proc/get_location_area(location_id = null)
+ if (isnull(location_id))
+ location_id = location
+
+ if (!location_id)
+ return area_station
+ return area_offsite
+
/datum/shuttle/ferry/proc/process_shuttle()
switch(process_state)
if (WAIT_LAUNCH)
diff --git a/code/modules/shuttles/shuttle_supply.dm b/code/modules/shuttles/shuttle_supply.dm
new file mode 100644
index 00000000000..5f1ff015dbe
--- /dev/null
+++ b/code/modules/shuttles/shuttle_supply.dm
@@ -0,0 +1,76 @@
+
+
+
+
+
+/datum/shuttle/ferry/supply
+ var/away_location = 1 //the location to hide at while pretending to be in-transit
+ var/arrive_time = 0
+
+/datum/shuttle/ferry/supply/short_jump(var/area/origin,var/area/destination)
+ if(moving_status != SHUTTLE_IDLE)
+ return
+
+ if(isnull(location))
+ return
+
+ if(!destination)
+ destination = get_location_area(!location)
+ if(!origin)
+ origin = get_location_area(location)
+
+ if (!at_station()) //at centcom
+ supply_shuttle.buy()
+
+ //it would be cool to play a sound here
+ moving_status = SHUTTLE_WARMUP
+ spawn(warmup_time*10)
+ if (moving_status == SHUTTLE_IDLE)
+ return //someone cancelled the launch
+
+ if (at_station() && forbidden_atoms_check())
+ //cancel the launch because of forbidden atoms. announce over supply channel?
+ return
+
+ //We pretend it's a long_jump by making the shuttle stay at centcom for the "in-transit" period.
+ var/area/away_area = get_location_area(away_location)
+ if (origin == away_area)
+ moving_status = SHUTTLE_INTRANSIT //pretend
+ else
+ move(origin, away_area)
+
+ //wait ETA here.
+ arrive_time = world.time + supply_shuttle.movetime
+ while (world.time <= arrive_time)
+ sleep(5)
+
+ if (destination != away_area)
+ move(away_area, destination)
+
+ moving_status = SHUTTLE_IDLE
+
+ if (!at_station()) //at centcom
+ supply_shuttle.sell()
+
+// returns 1 if the supply shuttle should be prevented from moving because it contains forbidden atoms
+/datum/shuttle/ferry/supply/proc/forbidden_atoms_check()
+ if (!at_station())
+ return 0 //if badmins want to send mobs or a nuke on the supply shuttle from centcom we don't care
+
+ return supply_shuttle.forbidden_atoms_check(get_location_area())
+
+/datum/shuttle/ferry/supply/proc/at_station()
+ return (!location)
+
+//returns 1 if the shuttle is moving and we can show valid ETAs
+/datum/shuttle/ferry/supply/proc/has_eta()
+ return (moving_status == SHUTTLE_INTRANSIT)
+
+//returns 1 if the shuttle is idle and we can still mess with the cargo shopping list
+/datum/shuttle/ferry/supply/proc/idle()
+ return (moving_status == SHUTTLE_IDLE)
+
+//returns the ETA in minutes
+/datum/shuttle/ferry/supply/proc/eta_minutes()
+ var/ticksleft = arrive_time - world.time
+ return round(ticksleft/600,1)
\ No newline at end of file
diff --git a/code/setup.dm b/code/setup.dm
index f99614b69f0..871306e0284 100644
--- a/code/setup.dm
+++ b/code/setup.dm
@@ -857,3 +857,8 @@ var/list/RESTRICTED_CAMERA_NETWORKS = list( //Those networks can only be accesse
#define COLOR_YELLOW "#FFFF00"
#define COLOR_ORANGE "#FF9900"
#define COLOR_WHITE "#FFFFFF"
+
+//Shuttle moving status
+#define SHUTTLE_IDLE 0
+#define SHUTTLE_WARMUP 1
+#define SHUTTLE_INTRANSIT 2