mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-01-05 15:11:38 +00:00
tgshuttles unfinished
This commit is contained in:
192
code/controllers/Processes/shuttles.dm
Normal file
192
code/controllers/Processes/shuttles.dm
Normal file
@@ -0,0 +1,192 @@
|
||||
var/datum/controller/process/shuttle/shuttle_master
|
||||
|
||||
var/const/CALL_SHUTTLE_REASON_LENGTH = 12
|
||||
|
||||
/datum/controller/process/shuttle
|
||||
var/list/mobile = list()
|
||||
var/list/stationary = list()
|
||||
var/list/transit = list()
|
||||
|
||||
//emergency shuttle stuff
|
||||
var/obj/docking_port/mobile/emergency/emergency
|
||||
var/emergencyCallTime = 6000 //time taken for emergency shuttle to reach the station when called (in deciseconds)
|
||||
var/emergencyDockTime = 1800 //time taken for emergency shuttle to leave again once it has docked (in deciseconds)
|
||||
var/emergencyEscapeTime = 1200 //time taken for emergency shuttle to reach a safe distance after leaving station (in deciseconds)
|
||||
var/area/emergencyLastCallLoc
|
||||
var/emergencyNoEscape
|
||||
|
||||
//supply shuttle stuff
|
||||
var/obj/docking_port/mobile/supply/supply
|
||||
var/ordernum = 1 //order number given to next order
|
||||
var/points = 50 //number of trade-points we have
|
||||
var/points_per_decisecond = 0.005 //points gained every decisecond
|
||||
var/points_per_slip = 2 //points gained per slip returned
|
||||
var/points_per_crate = 5 //points gained per crate returned
|
||||
var/points_per_intel = 250 //points gained per intel returned
|
||||
var/points_per_plasma = 5 //points gained per plasma returned
|
||||
var/points_per_design = 25 //points gained per max reliability research design returned (only for initilally unreliable designs)
|
||||
var/centcom_message = "" //Remarks from Centcom on how well you checked the last order.
|
||||
var/list/discoveredPlants = list() //Typepaths for unusual plants we've already sent CentComm, associated with their potencies
|
||||
var/list/techLevels = list()
|
||||
var/list/researchDesigns = list()
|
||||
var/list/shoppinglist = list()
|
||||
var/list/requestlist = list()
|
||||
var/list/supply_packs = list()
|
||||
var/datum/round_event/shuttle_loan/shuttle_loan
|
||||
var/sold_atoms = ""
|
||||
|
||||
/datum/controller/process/shuttle/setup()
|
||||
name = "shuttle"
|
||||
schedule_interval = 20
|
||||
|
||||
shuttle_master = src
|
||||
|
||||
/datum/controller/process/shuttle/doWork()
|
||||
points += points_per_decisecond * schedule_interval
|
||||
for(var/thing in mobile)
|
||||
if(thing)
|
||||
var/obj/docking_port/mobile/P = thing
|
||||
P.check()
|
||||
continue
|
||||
mobile.Remove(thing)
|
||||
|
||||
|
||||
|
||||
/datum/controller/process/shuttle/proc/getShuttle(id)
|
||||
for(var/obj/docking_port/mobile/M in mobile)
|
||||
if(M.id == id)
|
||||
return M
|
||||
WARNING("couldn't find shuttle with id: [id]")
|
||||
|
||||
/datum/controller/process/shuttle/proc/getDock(id)
|
||||
for(var/obj/docking_port/stationary/S in stationary)
|
||||
if(S.id == id)
|
||||
return S
|
||||
WARNING("couldn't find dock with id: [id]")
|
||||
|
||||
/datum/controller/process/shuttle/proc/requestEvac(mob/user, call_reason)
|
||||
if(!emergency)
|
||||
throw EXCEPTION("requestEvac(): There is no emergency shuttle! The game will be unresolvable. This is likely due to a mapping error")
|
||||
return
|
||||
|
||||
|
||||
switch(emergency.mode)
|
||||
if(SHUTTLE_RECALL)
|
||||
user << "The emergency shuttle may not be called while returning to Centcom."
|
||||
return
|
||||
if(SHUTTLE_CALL)
|
||||
user << "The emergency shuttle is already on its way."
|
||||
return
|
||||
if(SHUTTLE_DOCKED)
|
||||
user << "The emergency shuttle is already here."
|
||||
return
|
||||
if(SHUTTLE_ESCAPE)
|
||||
user << "The emergency shuttle is moving away to a safe distance."
|
||||
return
|
||||
if(SHUTTLE_STRANDED)
|
||||
user << "The emergency shuttle has been disabled by Centcom."
|
||||
return
|
||||
|
||||
call_reason = trim(html_encode(call_reason))
|
||||
|
||||
if(length(call_reason) < CALL_SHUTTLE_REASON_LENGTH)
|
||||
user << "You must provide a reason."
|
||||
return
|
||||
|
||||
var/area/signal_origin = get_area(user)
|
||||
var/emergency_reason = "\nNature of emergency:\n\n[call_reason]"
|
||||
if(seclevel2num(get_security_level()) == SEC_LEVEL_RED) // There is a serious threat we gotta move no time to give them five minutes.
|
||||
emergency.request(null, 0.5, signal_origin, html_decode(emergency_reason), 1)
|
||||
else
|
||||
emergency.request(null, 1, signal_origin, html_decode(emergency_reason), 0)
|
||||
|
||||
log_game("[key_name(user)] has called the shuttle.")
|
||||
message_admins("[key_name_admin(user)] has called the shuttle.")
|
||||
|
||||
return
|
||||
|
||||
/datum/controller/process/shuttle/proc/cancelEvac(mob/user)
|
||||
if(canRecall())
|
||||
emergency.cancel(get_area(user))
|
||||
log_game("[key_name(user)] has recalled the shuttle.")
|
||||
message_admins("[key_name_admin(user)] has recalled the shuttle.")
|
||||
return 1
|
||||
|
||||
/datum/controller/process/shuttle/proc/canRecall()
|
||||
if(emergency.mode != SHUTTLE_CALL)
|
||||
return
|
||||
if(ticker.mode.name == "meteor")
|
||||
return
|
||||
if(seclevel2num(get_security_level()) == SEC_LEVEL_RED)
|
||||
if(emergency.timeLeft(1) < emergencyCallTime * 0.25)
|
||||
return
|
||||
else
|
||||
if(emergency.timeLeft(1) < emergencyCallTime * 0.5)
|
||||
return
|
||||
return 1
|
||||
|
||||
/datum/controller/process/shuttle/proc/autoEvac()
|
||||
var/callShuttle = 1
|
||||
|
||||
for(var/thing in shuttle_caller_list)
|
||||
if(istype(thing, /mob/living/silicon/ai))
|
||||
var/mob/living/silicon/ai/AI = thing
|
||||
if(AI.stat || !AI.client)
|
||||
continue
|
||||
else if(istype(thing, /obj/machinery/computer/communications))
|
||||
var/obj/machinery/computer/communications/C = thing
|
||||
if(C.stat & BROKEN)
|
||||
continue
|
||||
|
||||
var/turf/T = get_turf(thing)
|
||||
if(T && T.z == ZLEVEL_STATION)
|
||||
callShuttle = 0
|
||||
break
|
||||
|
||||
if(callShuttle)
|
||||
if(emergency.mode < SHUTTLE_CALL)
|
||||
emergency.request(null, 2.5)
|
||||
log_game("There is no means of calling the shuttle anymore. Shuttle automatically called.")
|
||||
message_admins("All the communications consoles were destroyed and all AIs are inactive. Shuttle called.")
|
||||
|
||||
//try to move/request to dockHome if possible, otherwise dockAway. Mainly used for admin buttons
|
||||
/datum/controller/process/shuttle/proc/toggleShuttle(shuttleId, dockHome, dockAway, timed)
|
||||
var/obj/docking_port/mobile/M = getShuttle(shuttleId)
|
||||
if(!M)
|
||||
return 1
|
||||
var/obj/docking_port/stationary/dockedAt = M.get_docked()
|
||||
var/destination = dockHome
|
||||
if(dockedAt && dockedAt.id == dockHome)
|
||||
destination = dockAway
|
||||
if(timed)
|
||||
if(M.request(getDock(destination)))
|
||||
return 2
|
||||
else
|
||||
if(M.dock(getDock(destination)))
|
||||
return 2
|
||||
return 0 //dock successful
|
||||
|
||||
|
||||
/datum/controller/process/shuttle/proc/moveShuttle(shuttleId, dockId, timed)
|
||||
var/obj/docking_port/mobile/M = getShuttle(shuttleId)
|
||||
if(!M)
|
||||
return 1
|
||||
if(timed)
|
||||
if(M.request(getDock(dockId)))
|
||||
return 2
|
||||
else
|
||||
if(M.dock(getDock(dockId)))
|
||||
return 2
|
||||
return 0 //dock successful
|
||||
|
||||
/datum/controller/process/shuttle/proc/initial_move()
|
||||
for(var/obj/docking_port/mobile/M in mobile)
|
||||
if(!M.roundstart_move)
|
||||
continue
|
||||
for(var/obj/docking_port/stationary/S in stationary)
|
||||
if(S.z != ZLEVEL_STATION && findtext(S.id, M.id))
|
||||
S.width = M.width
|
||||
S.height = M.height
|
||||
S.dwidth = M.dwidth
|
||||
S.dheight = M.dheight
|
||||
moveShuttle(M.id, "[M.roundstart_move]", 0)
|
||||
207
code/controllers/Processes/shuttles/emergency.dm
Normal file
207
code/controllers/Processes/shuttles/emergency.dm
Normal file
@@ -0,0 +1,207 @@
|
||||
/obj/docking_port/mobile/emergency
|
||||
name = "emergency shuttle"
|
||||
id = "emergency"
|
||||
|
||||
dwidth = 9
|
||||
width = 22
|
||||
height = 11
|
||||
dir = 4
|
||||
travelDir = 0
|
||||
roundstart_move = "emergency_away"
|
||||
var/sound_played = 0 //If the launch sound has been sent to all players on the shuttle itself
|
||||
|
||||
var/datum/announcement/priority/emergency_shuttle_docked = new(0, new_sound = sound('sound/AI/shuttledock.ogg'))
|
||||
var/datum/announcement/priority/emergency_shuttle_called = new(0, new_sound = sound('sound/AI/shuttlecalled.ogg'))
|
||||
var/datum/announcement/priority/emergency_shuttle_recalled = new(0, new_sound = sound('sound/AI/shuttlerecalled.ogg'))
|
||||
|
||||
|
||||
/obj/docking_port/mobile/emergency/New()
|
||||
..()
|
||||
spawn(0)
|
||||
if(!shuttle_master)
|
||||
sleep(50)
|
||||
if(!shuttle_master)
|
||||
sleep(50)
|
||||
if(!shuttle_master)
|
||||
throw EXCEPTION("docking port [src] could not initialize")
|
||||
return 0 //give up
|
||||
|
||||
shuttle_master.emergency = src
|
||||
|
||||
/obj/docking_port/mobile/emergency/timeLeft(divisor)
|
||||
if(divisor <= 0)
|
||||
divisor = 10
|
||||
if(!timer)
|
||||
return round(shuttle_master.emergencyCallTime/divisor, 1)
|
||||
|
||||
var/dtime = world.time - timer
|
||||
switch(mode)
|
||||
if(SHUTTLE_ESCAPE)
|
||||
dtime = max(shuttle_master.emergencyEscapeTime - dtime, 0)
|
||||
if(SHUTTLE_DOCKED)
|
||||
dtime = max(shuttle_master.emergencyDockTime - dtime, 0)
|
||||
else
|
||||
|
||||
dtime = max(shuttle_master.emergencyCallTime - dtime, 0)
|
||||
return round(dtime/divisor, 1)
|
||||
|
||||
/obj/docking_port/mobile/emergency/request(obj/docking_port/stationary/S, coefficient=1, area/signalOrigin, reason, redAlert)
|
||||
shuttle_master.emergencyCallTime = initial(shuttle_master.emergencyCallTime) * coefficient
|
||||
switch(mode)
|
||||
if(SHUTTLE_RECALL)
|
||||
mode = SHUTTLE_CALL
|
||||
timer = world.time - timeLeft(1)
|
||||
if(SHUTTLE_IDLE)
|
||||
mode = SHUTTLE_CALL
|
||||
timer = world.time
|
||||
if(SHUTTLE_CALL)
|
||||
if(world.time < timer) //this is just failsafe
|
||||
timer = world.time
|
||||
else
|
||||
return
|
||||
|
||||
if(prob(70))
|
||||
shuttle_master.emergencyLastCallLoc = signalOrigin
|
||||
else
|
||||
shuttle_master.emergencyLastCallLoc = null
|
||||
|
||||
emergency_shuttle_called.Announce("The emergency shuttle has been called. [redAlert ? "Red Alert state confirmed: Dispatching priority shuttle. " : "" ]It will arrive in [timeLeft(600)] minutes.[reason][shuttle_master.emergencyLastCallLoc ? "\n\nCall signal traced. Results can be viewed on any communications console." : "" ]")
|
||||
|
||||
/obj/docking_port/mobile/emergency/cancel(area/signalOrigin)
|
||||
if(mode != SHUTTLE_CALL)
|
||||
return
|
||||
|
||||
timer = world.time - timeLeft(1)
|
||||
mode = SHUTTLE_RECALL
|
||||
|
||||
if(prob(70))
|
||||
shuttle_master.emergencyLastCallLoc = signalOrigin
|
||||
else
|
||||
shuttle_master.emergencyLastCallLoc = null
|
||||
emergency_shuttle_recalled.Announce("The emergency shuttle has been recalled.[shuttle_master.emergencyLastCallLoc ? " Recall signal traced. Results can be viewed on any communications console." : "" ]")
|
||||
|
||||
/*
|
||||
/obj/docking_port/mobile/emergency/findTransitDock()
|
||||
. = shuttle_master.getDock("emergency_transit")
|
||||
if(.) return .
|
||||
return ..()
|
||||
*/
|
||||
|
||||
|
||||
/obj/docking_port/mobile/emergency/check()
|
||||
if(!timer)
|
||||
return
|
||||
|
||||
var/time_left = timeLeft(1)
|
||||
switch(mode)
|
||||
if(SHUTTLE_RECALL)
|
||||
if(time_left <= 0)
|
||||
mode = SHUTTLE_IDLE
|
||||
timer = 0
|
||||
if(SHUTTLE_CALL)
|
||||
if(time_left <= 0)
|
||||
//move emergency shuttle to station
|
||||
if(dock(shuttle_master.getDock("emergency_home")))
|
||||
setTimer(20)
|
||||
return
|
||||
mode = SHUTTLE_DOCKED
|
||||
timer = world.time
|
||||
send2irc("Server", "The Emergency Shuttle has docked with the station.")
|
||||
emergency_shuttle_docked.Announce("The Emergency Shuttle has docked with the station. You have [timeLeft(600)] minutes to board the Emergency Shuttle.")
|
||||
|
||||
/*
|
||||
//Gangs only have one attempt left if the shuttle has docked with the station to prevent suffering from dominator delays
|
||||
for(var/datum/gang/G in ticker.mode.gangs)
|
||||
if(isnum(G.dom_timer))
|
||||
G.dom_attempts = 0
|
||||
else
|
||||
G.dom_attempts = min(1,G.dom_attempts)
|
||||
*/
|
||||
if(SHUTTLE_DOCKED)
|
||||
if(time_left <= 0 && shuttle_master.emergencyNoEscape)
|
||||
priority_announcement.Announce("Hostile environment detected. Departure has been postponed indefinitely pending conflict resolution.")
|
||||
sound_played = 0
|
||||
mode = SHUTTLE_STRANDED
|
||||
if(time_left <= 50 && !sound_played) //4 seconds left - should sync up with the launch
|
||||
sound_played = 1
|
||||
for(var/area/shuttle/escape/E in world)
|
||||
E << 'sound/effects/hyperspace_begin.ogg'
|
||||
if(time_left <= 0 && !shuttle_master.emergencyNoEscape)
|
||||
//move each escape pod to its corresponding transit dock
|
||||
for(var/obj/docking_port/mobile/pod/M in shuttle_master.mobile)
|
||||
if(M.z == ZLEVEL_STATION) //Will not launch from the mine/planet
|
||||
M.enterTransit()
|
||||
//now move the actual emergency shuttle to its transit dock
|
||||
for(var/area/shuttle/escape/E in world)
|
||||
E << 'sound/effects/hyperspace_progress.ogg'
|
||||
enterTransit()
|
||||
mode = SHUTTLE_ESCAPE
|
||||
timer = world.time
|
||||
priority_announcement.Announce("The Emergency Shuttle has left the station. Estimate [timeLeft(600)] minutes until the shuttle docks at Central Command.")
|
||||
if(SHUTTLE_ESCAPE)
|
||||
if(time_left <= 0)
|
||||
//move each escape pod to its corresponding escape dock
|
||||
for(var/obj/docking_port/mobile/pod/M in shuttle_master.mobile)
|
||||
M.dock(shuttle_master.getDock("[M.id]_away"))
|
||||
//now move the actual emergency shuttle to centcomm
|
||||
for(var/area/shuttle/escape/E in world)
|
||||
E << 'sound/effects/hyperspace_end.ogg'
|
||||
dock(shuttle_master.getDock("emergency_away"))
|
||||
mode = SHUTTLE_ENDGAME
|
||||
timer = 0
|
||||
open_dock()
|
||||
|
||||
/obj/docking_port/mobile/emergency/proc/open_dock();
|
||||
/*
|
||||
for(var/obj/machinery/door/poddoor/shuttledock/D in airlocks)
|
||||
var/turf/T = get_step(D, D.checkdir)
|
||||
if(!istype(T,/turf/space))
|
||||
spawn(0)
|
||||
D.open()
|
||||
*/ //SHUTTLE-WIP: INVESTIGATE
|
||||
/obj/docking_port/mobile/pod
|
||||
name = "escape pod"
|
||||
id = "pod"
|
||||
|
||||
dwidth = 1
|
||||
width = 3
|
||||
height = 4
|
||||
|
||||
/obj/docking_port/mobile/pod/New()
|
||||
if(id == "pod")
|
||||
WARNING("[type] id has not been changed from the default. Use the id convention \"pod1\" \"pod2\" etc.")
|
||||
..()
|
||||
|
||||
/obj/docking_port/mobile/pod/cancel()
|
||||
return
|
||||
|
||||
/*
|
||||
findTransitDock()
|
||||
. = shuttle_master.getDock("[id]_transit")
|
||||
if(.) return .
|
||||
return ..()
|
||||
*/
|
||||
|
||||
/obj/machinery/computer/shuttle/pod
|
||||
name = "pod control computer"
|
||||
admin_controlled = 1
|
||||
shuttleId = "pod"
|
||||
possible_destinations = "pod_asteroid"
|
||||
icon = 'icons/obj/terminals.dmi'
|
||||
icon_state = "dorm_available"
|
||||
density = 0
|
||||
|
||||
/obj/machinery/computer/shuttle/pod/update_icon()
|
||||
return
|
||||
|
||||
/obj/machinery/computer/shuttle/pod/emag_act(mob/user as mob)
|
||||
user << "<span class='warning'> Access requirements overridden. The pod may now be launched manually at any time.</span>"
|
||||
admin_controlled = 0
|
||||
icon_state = "dorm_emag"
|
||||
|
||||
/obj/docking_port/stationary/random/initialize()
|
||||
..()
|
||||
var/target_area = /area/mine/unexplored
|
||||
var/turfs = get_area_turfs(target_area)
|
||||
var/T=pick(turfs)
|
||||
src.loc = T
|
||||
Reference in New Issue
Block a user