Adds supply shuttle datum

This commit is contained in:
mwerezak
2014-06-18 12:37:09 -04:00
parent ed9600ce43
commit 462593f0b5
8 changed files with 210 additions and 83 deletions

View File

@@ -1293,6 +1293,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\supermatter\supermatter.dm"
#include "code\modules\surgery\appendix.dm"

View File

@@ -110,13 +110,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 = ""
@@ -162,8 +171,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)]"

View File

@@ -411,9 +411,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)

View File

@@ -142,15 +142,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,31 +172,12 @@ var/list/mechtoys = list(
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))
@@ -207,11 +196,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/phoron_count = 0
@@ -259,11 +247,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()
@@ -290,7 +277,7 @@ var/list/mechtoys = list(
slip.info = "<h3>[command_name()] Shipping Manifest</h3><hr><br>"
slip.info +="Order #[SO.ordernum]<br>"
slip.info +="Destination: [station_name]<br>"
slip.info +="[supply_shuttle.shoppinglist.len] PACKAGES IN THIS SHIPMENT<br>"
slip.info +="[shoppinglist.len] PACKAGES IN THIS SHIPMENT<br>"
slip.info +="CONTENTS:<br><ul>"
//spawn the stuff, finish generating the manifest while you're at it
@@ -319,7 +306,7 @@ var/list/mechtoys = list(
slip.info += "CHECK CONTENTS AND STAMP BELOW THE LINE TO CONFIRM RECEIPT OF GOODS<hr>"
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
@@ -346,9 +333,11 @@ var/list/mechtoys = list(
if(temp)
dat = temp
else
dat += {"<BR><B>Supply shuttle</B><HR>
Location: [supply_shuttle.moving ? "Moving to station ([supply_shuttle.eta] Mins.)":supply_shuttle.at_station ? "Station":"Dock"]<BR>
<HR>Supply points: [supply_shuttle.points]<BR>
var/datum/shuttle/ferry/supply/shuttle = supply_shuttle.get_shuttle()
if (shuttle)
dat += {"<BR><B>Supply shuttle</B><HR>
Location: [shuttle.has_eta() ? "Moving to station ([shuttle.eta_minutes()] Mins.)":shuttle.at_station() ? "Docked":"Away"]<BR>
<HR>Supply points: [supply_shuttle.points]<BR>
<BR>\n<A href='?src=\ref[src];order=categories'>Request items</A><BR><BR>
<A href='?src=\ref[src];vieworders=1'>View approved orders</A><BR><BR>
<A href='?src=\ref[src];viewrequests=1'>View requests</A><BR><BR>
@@ -471,15 +460,49 @@ var/list/mechtoys = list(
if (temp)
dat = temp
else
dat += {"<BR><B>Supply shuttle</B><HR>
\nLocation: [supply_shuttle.moving ? "Moving to station ([supply_shuttle.eta] Mins.)":supply_shuttle.at_station ? "Station":"Away"]<BR>
<HR>\nSupply points: [supply_shuttle.points]<BR>\n<BR>
[supply_shuttle.moving ? "\n*Must be away to order items*<BR>\n<BR>":supply_shuttle.at_station ? "\n*Must be away to order items*<BR>\n<BR>":"\n<A href='?src=\ref[src];order=categories'>Order items</A><BR>\n<BR>"]
[supply_shuttle.moving ? "\n*Shuttle already called*<BR>\n<BR>":supply_shuttle.at_station ? "\n<A href='?src=\ref[src];send=1'>Send away</A><BR>\n<BR>":"\n<A href='?src=\ref[src];send=1'>Send to station</A><BR>\n<BR>"]
var/datum/shuttle/ferry/supply/shuttle = supply_shuttle.get_shuttle()
if (shuttle)
dat += "<BR><B>Supply shuttle</B><HR>"
dat += "\nLocation: "
if (shuttle.has_eta())
dat += "In transit ([shuttle.eta_minutes()] Mins.)<BR>"
else
if (shuttle.at_station())
if (shuttle.docking_controller)
switch(shuttle.docking_controller.get_docking_status())
if ("docked") dat += "Docked at station<BR>"
if ("undocked") dat += "Undocked from station<BR>"
if ("docking") dat += "Docking with station [shuttle.can_force()? "<span class='warning'><A href='?src=\ref[src];force_send=1'>OVERRIDE</A></span>" : ""]<BR>"
if ("undocking") dat += "Undocking from station [shuttle.can_force()? "<span class='warning'><A href='?src=\ref[src];force_send=1'>OVERRIDE</A></span>" : ""]<BR>"
else
dat += "Station<BR>"
if (shuttle.can_launch())
dat += "<A href='?src=\ref[src];send=1'>Send away</A>"
else if (shuttle.can_cancel())
dat += "<A href='?src=\ref[src];cancel_send=1'>Cancel launch</A>"
else
dat += "*Shuttle is busy*"
dat += "<BR>\n<BR>"
else
dat += "Away<BR>"
if (shuttle.can_launch())
dat += "<A href='?src=\ref[src];send=1'>Request supply shuttle</A>"
else if (shuttle.can_cancel())
dat += "<A href='?src=\ref[src];cancel_send=1'>Cancel request</A>"
else
dat += "*Shuttle is busy*"
dat += "<BR>\n<BR>"
dat += {"<HR>\nSupply points: [supply_shuttle.points]<BR>\n<BR>
// [shuttle.at_station() ? "\n*Must be away to order items*<BR>\n<BR>":"\n<A href='?src=\ref[src];order=categories'>Order items</A><BR>\n<BR>"]
\n<A href='?src=\ref[src];order=categories'>Order items</A><BR>\n<BR>
\n<A href='?src=\ref[src];viewrequests=1'>View requests</A><BR>\n<BR>
\n<A href='?src=\ref[src];vieworders=1'>View orders</A><BR>\n<BR>
\n<A href='?src=\ref[user];mach_close=computer'>Close</A>"}
user << browse(dat, "window=computer;size=575x450")
onclose(user, "computer")
return
@@ -497,6 +520,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
@@ -505,28 +532,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.<BR><BR><A href='?src=\ref[src];mainmenu=1'>OK</A>"
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.<BR><BR><A href='?src=\ref[src];mainmenu=1'>OK</A>"
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.<BR><BR><A href='?src=\ref[src];mainmenu=1'>OK</A>"
else
shuttle.launch(src)
temp = "Initiating launch sequence.<BR><BR><A href='?src=\ref[src];mainmenu=1'>OK</A>"
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.<BR><BR><A href='?src=\ref[src];mainmenu=1'>OK</A>"
shuttle.launch(src)
temp = "The supply shuttle has been called and will arrive in approximately [round(supply_shuttle.movetime/600,1)] minutes.<BR><BR><A href='?src=\ref[src];mainmenu=1'>OK</A>"
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?
@@ -651,7 +675,7 @@ var/list/mechtoys = list(
temp = "Current requests: <BR><BR>"
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 ? "":"<A href='?src=\ref[src];confirmorder=[SO.ordernum]'>Approve</A> <A href='?src=\ref[src];rreq=[SO.ordernum]'>Remove</A>"]<BR>"
temp += "#[SO.ordernum] - [SO.object.name] requested by [SO.orderedby] [shuttle.idle() ? "":shuttle.at_station() ? "":"<A href='?src=\ref[src];confirmorder=[SO.ordernum]'>Approve</A> <A href='?src=\ref[src];rreq=[SO.ordernum]'>Remove</A>"]<BR>"
temp += "<BR><A href='?src=\ref[src];clearreq=1'>Clear list</A>"
temp += "<BR><A href='?src=\ref[src];mainmenu=1'>OK</A>"

View File

@@ -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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -761,3 +761,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