mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-22 04:22:39 +01:00
Landmark Shuttles (#8512)
The lifeless live again. Or in this case, what never actually lived here. Ports Baystation12/Baystation12#17460 probably for real this time. What this allows us to do is create shuttles on runtime and make shuttles easier by just making landmarks and a shuttle instead of areas and shuttles. Also allows runtime landmark creation via flares or whatever AND allows shuttles to use different landmarks at will. I removed most of the overmap stuff, I think. It shouldn't be hard to slam it in whenever we need to. Changes: "Shuttle code has been completely reworked." "Shuttles can now be modified to have more than one destination." "Shuttles now have a takeoff sound." "You can now throw mobs against walls to damage them. A lot." "You now need a neckgrab to throw mobs." "BEING UNBUCKLED DURING SHUTTLE LAUNCH IS DANGEROUS! Don't do it." "Adminghosts can now interact with all shuttles."
This commit is contained in:
@@ -1,101 +0,0 @@
|
||||
//Engine control and monitoring console
|
||||
|
||||
/obj/machinery/computer/engines
|
||||
name = "engine control console"
|
||||
|
||||
icon_screen = "id"
|
||||
var/state = "status"
|
||||
var/list/engines = list()
|
||||
var/obj/effect/map/ship/linked
|
||||
|
||||
/obj/machinery/computer/engines/Initialize()
|
||||
. = ..()
|
||||
linked = map_sectors["[z]"]
|
||||
if (linked)
|
||||
if (!linked.eng_control)
|
||||
linked.eng_control = src
|
||||
testing("Engines console at level [z] found a corresponding overmap object '[linked.name]'.")
|
||||
else
|
||||
testing("Engines console at level [z] was unable to find a corresponding overmap object.")
|
||||
|
||||
for(var/datum/ship_engine/E in engines)
|
||||
if (E.zlevel == z && !(E in engines))
|
||||
engines += E
|
||||
|
||||
/obj/machinery/computer/engines/attack_hand(var/mob/user as mob)
|
||||
if(..())
|
||||
user.unset_machine()
|
||||
return
|
||||
|
||||
if(!isAI(user))
|
||||
user.set_machine(src)
|
||||
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/computer/engines/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(!linked)
|
||||
return
|
||||
|
||||
var/data[0]
|
||||
data["state"] = state
|
||||
|
||||
var/list/enginfo[0]
|
||||
for(var/datum/ship_engine/E in engines)
|
||||
var/list/rdata[0]
|
||||
rdata["eng_type"] = E.name
|
||||
rdata["eng_on"] = E.is_on()
|
||||
rdata["eng_thrust"] = E.get_thrust()
|
||||
rdata["eng_thrust_limiter"] = round(E.get_thrust_limit()*100)
|
||||
rdata["eng_status"] = E.get_status()
|
||||
rdata["eng_reference"] = "\ref[E]"
|
||||
enginfo.Add(list(rdata))
|
||||
|
||||
data["engines_info"] = enginfo
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "engines_control.tmpl", "[linked.name] Engines Control", 380, 530)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/computer/engines/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if(href_list["state"])
|
||||
state = href_list["state"]
|
||||
|
||||
if(href_list["engine"])
|
||||
if(href_list["set_limit"])
|
||||
var/datum/ship_engine/E = locate(href_list["engine"])
|
||||
var/newlim = input("Input new thrust limit (0..100)", "Thrust limit", E.get_thrust_limit()) as num
|
||||
var/limit = Clamp(newlim/100, 0, 1)
|
||||
if(E)
|
||||
E.set_thrust_limit(limit)
|
||||
|
||||
if(href_list["limit"])
|
||||
var/datum/ship_engine/E = locate(href_list["engine"])
|
||||
var/limit = Clamp(E.get_thrust_limit() + text2num(href_list["limit"]), 0, 1)
|
||||
if(E)
|
||||
E.set_thrust_limit(limit)
|
||||
|
||||
if(href_list["toggle"])
|
||||
var/datum/ship_engine/E = locate(href_list["engine"])
|
||||
if(E)
|
||||
E.toggle()
|
||||
|
||||
add_fingerprint(usr)
|
||||
updateUsrDialog()
|
||||
|
||||
/obj/machinery/computer/engines/proc/burn()
|
||||
if(engines.len == 0)
|
||||
return 0
|
||||
var/res = 0
|
||||
for(var/datum/ship_engine/E in engines)
|
||||
res |= E.burn()
|
||||
return res
|
||||
|
||||
/obj/machinery/computer/engines/proc/get_total_thrust()
|
||||
for(var/datum/ship_engine/E in engines)
|
||||
. += E.get_thrust()
|
||||
@@ -1,176 +0,0 @@
|
||||
/obj/machinery/computer/helm
|
||||
name = "helm control console"
|
||||
|
||||
icon_screen = "id"
|
||||
var/state = "status"
|
||||
var/obj/effect/map/ship/linked //connected overmap object
|
||||
var/autopilot = 0
|
||||
var/manual_control = 0
|
||||
var/list/known_sectors = list()
|
||||
var/dx //desitnation
|
||||
var/dy //coordinates
|
||||
|
||||
/obj/machinery/computer/helm/Initialize()
|
||||
. = ..()
|
||||
linked = map_sectors["[z]"]
|
||||
if (linked)
|
||||
if(!linked.nav_control)
|
||||
linked.nav_control = src
|
||||
testing("Helm console at level [z] found a corresponding overmap object '[linked.name]'.")
|
||||
else
|
||||
testing("Helm console at level [z] was unable to find a corresponding overmap object.")
|
||||
|
||||
for(var/level in map_sectors)
|
||||
var/obj/effect/map/sector/S = map_sectors["[level]"]
|
||||
if (istype(S) && S.always_known)
|
||||
var/list/R = list()
|
||||
R["name"] = S.name
|
||||
R["x"] = S.x
|
||||
R["y"] = S.y
|
||||
known_sectors += list(R)
|
||||
|
||||
/obj/machinery/computer/helm/machinery_process()
|
||||
if (autopilot && dx && dy)
|
||||
var/turf/T = locate(dx,dy,1)
|
||||
if(linked.loc == T)
|
||||
if(linked.is_still())
|
||||
autopilot = 0
|
||||
else
|
||||
linked.decelerate()
|
||||
|
||||
var/brake_path = linked.get_brake_path()
|
||||
|
||||
if(get_dist(linked.loc, T) > brake_path)
|
||||
linked.accelerate(get_dir(linked.loc, T))
|
||||
else
|
||||
linked.decelerate()
|
||||
|
||||
return
|
||||
|
||||
/obj/machinery/computer/helm/relaymove(var/mob/user, direction)
|
||||
if(manual_control && linked)
|
||||
linked.relaymove(user,direction)
|
||||
return 1
|
||||
|
||||
/obj/machinery/computer/helm/check_eye(var/mob/user as mob)
|
||||
if (!manual_control)
|
||||
return -1
|
||||
if (!get_dist(user, src) > 1 || user.blinded || !linked )
|
||||
return -1
|
||||
return 0
|
||||
|
||||
/obj/machinery/computer/helm/attack_hand(var/mob/user as mob)
|
||||
if(..())
|
||||
user.unset_machine()
|
||||
manual_control = 0
|
||||
return
|
||||
|
||||
if(!isAI(user))
|
||||
user.set_machine(src)
|
||||
if(linked)
|
||||
user.reset_view(linked)
|
||||
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/computer/helm/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(!linked)
|
||||
return
|
||||
|
||||
var/data[0]
|
||||
data["state"] = state
|
||||
|
||||
data["sector"] = linked.current_sector ? linked.current_sector.name : "Deep Space"
|
||||
data["sector_info"] = linked.current_sector ? linked.current_sector.desc : "Not Available"
|
||||
data["s_x"] = linked.x
|
||||
data["s_y"] = linked.y
|
||||
data["dest"] = dy && dx
|
||||
data["d_x"] = dx
|
||||
data["d_y"] = dy
|
||||
data["speed"] = linked.get_speed()
|
||||
data["accel"] = round(linked.get_acceleration())
|
||||
data["heading"] = linked.get_heading() ? dir2angle(linked.get_heading()) : 0
|
||||
data["autopilot"] = autopilot
|
||||
data["manual_control"] = manual_control
|
||||
|
||||
var/list/locations[0]
|
||||
for (var/list/R in known_sectors)
|
||||
var/list/rdata[0]
|
||||
rdata["name"] = R["name"]
|
||||
rdata["x"] = R["x"]
|
||||
rdata["y"] = R["y"]
|
||||
rdata["reference"] = "\ref[R]"
|
||||
locations.Add(list(rdata))
|
||||
|
||||
data["locations"] = locations
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "helm.tmpl", "[linked.name] Helm Control", 380, 530)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/computer/helm/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
if (!linked)
|
||||
return
|
||||
|
||||
if (href_list["add"])
|
||||
var/list/R = new()
|
||||
var/sec_name = input("Input naviation entry name", "New navigation entry", "Sector #[known_sectors.len]") as text
|
||||
if(!sec_name)
|
||||
sec_name = "Sector #[known_sectors.len]"
|
||||
R["name"] = sec_name
|
||||
switch(href_list["add"])
|
||||
if("current")
|
||||
R["x"] = linked.x
|
||||
R["y"] = linked.y
|
||||
if("new")
|
||||
var/newx = input("Input new entry x coordinate", "Coordinate input", linked.x) as num
|
||||
R["x"] = Clamp(newx, 1, world.maxx)
|
||||
var/newy = input("Input new entry y coordinate", "Coordinate input", linked.y) as num
|
||||
R["y"] = Clamp(newy, 1, world.maxy)
|
||||
known_sectors += list(R)
|
||||
|
||||
if (href_list["remove"])
|
||||
var/list/R = locate(href_list["remove"])
|
||||
known_sectors.Remove(R)
|
||||
|
||||
if (href_list["setx"])
|
||||
var/newx = input("Input new destiniation x coordinate", "Coordinate input", dx) as num|null
|
||||
if (newx)
|
||||
dx = Clamp(newx, 1, world.maxx)
|
||||
|
||||
if (href_list["sety"])
|
||||
var/newy = input("Input new destiniation y coordinate", "Coordinate input", dy) as num|null
|
||||
if (newy)
|
||||
dy = Clamp(newy, 1, world.maxy)
|
||||
|
||||
if (href_list["x"] && href_list["y"])
|
||||
dx = text2num(href_list["x"])
|
||||
dy = text2num(href_list["y"])
|
||||
|
||||
if (href_list["reset"])
|
||||
dx = 0
|
||||
dy = 0
|
||||
|
||||
if (href_list["move"])
|
||||
var/ndir = text2num(href_list["move"])
|
||||
linked.relaymove(usr, ndir)
|
||||
|
||||
if (href_list["brake"])
|
||||
linked.decelerate()
|
||||
|
||||
if (href_list["apilot"])
|
||||
autopilot = !autopilot
|
||||
|
||||
if (href_list["manual"])
|
||||
manual_control = !manual_control
|
||||
|
||||
if (href_list["state"])
|
||||
state = href_list["state"]
|
||||
add_fingerprint(usr)
|
||||
updateUsrDialog()
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
//Shuttle controller computer for shuttles going between sectors
|
||||
/datum/shuttle/ferry/var/range = 0 //how many overmap tiles can shuttle go, for picking destinatiosn and returning.
|
||||
/obj/machinery/computer/shuttle_control/explore
|
||||
name = "exploration shuttle console"
|
||||
shuttle_tag = "Exploration"
|
||||
req_access = list()
|
||||
var/landing_type //area for shuttle ship-side
|
||||
var/obj/effect/map/destination //current destination
|
||||
var/obj/effect/map/home //current destination
|
||||
|
||||
/obj/machinery/computer/shuttle_control/explore/Initialize()
|
||||
. = ..()
|
||||
home = map_sectors["[z]"]
|
||||
shuttle_tag = "[shuttle_tag]-[z]"
|
||||
if(!shuttle_controller.shuttles[shuttle_tag])
|
||||
var/datum/shuttle/ferry/shuttle = new()
|
||||
shuttle.warmup_time = 10
|
||||
shuttle.area_station = locate(landing_type)
|
||||
shuttle.area_offsite = shuttle.area_station
|
||||
shuttle_controller.shuttles[shuttle_tag] = shuttle
|
||||
START_PROCESSING(shuttle_controller, shuttle)
|
||||
testing("Exploration shuttle '[shuttle_tag]' at zlevel [z] successfully added.")
|
||||
|
||||
//Sets destination to new sector. Can be null.
|
||||
/obj/machinery/computer/shuttle_control/explore/proc/update_destination(var/obj/effect/map/D)
|
||||
destination = D
|
||||
if(destination && shuttle_controller.shuttles[shuttle_tag])
|
||||
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
shuttle.area_offsite = destination.shuttle_landing
|
||||
testing("Shuttle controller [shuttle_tag] now sends shuttle to [destination]")
|
||||
shuttle_controller.shuttles[shuttle_tag] = shuttle
|
||||
|
||||
//Gets all sectors with landing zones in shuttle's range
|
||||
/obj/machinery/computer/shuttle_control/explore/proc/get_possible_destinations()
|
||||
var/list/res = list()
|
||||
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
for (var/obj/effect/map/S in orange(shuttle.range, home))
|
||||
if(S.shuttle_landing)
|
||||
res += S
|
||||
return res
|
||||
|
||||
//Checks if current destination is still reachable
|
||||
/obj/machinery/computer/shuttle_control/explore/proc/check_destination()
|
||||
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
return shuttle && destination && get_dist(home, destination) <= shuttle.range
|
||||
|
||||
/obj/machinery/computer/shuttle_control/explore/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
var/data[0]
|
||||
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
if (!istype(shuttle))
|
||||
return
|
||||
|
||||
//If we are already there, or can't reach place anymore, reset destination
|
||||
if(!shuttle.location && !check_destination())
|
||||
destination = null
|
||||
|
||||
//check if shuttle can fly at all
|
||||
var/can_go = !isnull(destination)
|
||||
var/current_destination = destination ? destination.name : "None"
|
||||
//shuttle doesn't need destination set to return home, as long as it's in range.
|
||||
if(shuttle.location)
|
||||
current_destination = "Return"
|
||||
var/area/offsite = shuttle.area_offsite
|
||||
var/obj/effect/map/cur_loc = map_sectors["[offsite.z]"]
|
||||
can_go = (get_dist(home,cur_loc) <= shuttle.range)
|
||||
|
||||
//disable picking locations if there are none, or shuttle is already off-site
|
||||
var/list/possible_d = get_possible_destinations()
|
||||
var/can_pick = !shuttle.location && possible_d.len
|
||||
|
||||
var/shuttle_state
|
||||
switch(shuttle.moving_status)
|
||||
if(SHUTTLE_IDLE) shuttle_state = "idle"
|
||||
if(SHUTTLE_WARMUP) shuttle_state = "warmup"
|
||||
if(SHUTTLE_INTRANSIT) shuttle_state = "in_transit"
|
||||
if(SHUTTLE_HALT) shuttle_state = "halt"
|
||||
|
||||
var/shuttle_status
|
||||
switch (shuttle.process_state)
|
||||
if(IDLE_STATE)
|
||||
if (shuttle.in_use)
|
||||
shuttle_status = "Busy."
|
||||
else if (!shuttle.location)
|
||||
shuttle_status = "Standing-by at station."
|
||||
else
|
||||
shuttle_status = "Standing-by at offsite location."
|
||||
if(WAIT_LAUNCH, FORCE_LAUNCH)
|
||||
shuttle_status = "Shuttle has received command and will depart shortly."
|
||||
if(WAIT_ARRIVE)
|
||||
shuttle_status = "Proceeding to destination."
|
||||
if(WAIT_FINISH)
|
||||
shuttle_status = "Arriving at destination now."
|
||||
|
||||
data = list(
|
||||
"destination_name" = current_destination,
|
||||
"can_pick" = can_pick,
|
||||
"shuttle_status" = shuttle_status,
|
||||
"shuttle_state" = shuttle_state,
|
||||
"has_docking" = shuttle.docking_controller? 1 : 0,
|
||||
"docking_status" = shuttle.docking_controller? shuttle.docking_controller.get_docking_status() : null,
|
||||
"docking_override" = shuttle.docking_controller? shuttle.docking_controller.override_enabled : null,
|
||||
"can_launch" = can_go && shuttle.can_launch(),
|
||||
"can_cancel" = can_go && shuttle.can_cancel(),
|
||||
"can_force" = can_go && shuttle.can_force()
|
||||
)
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "shuttle_control_console_exploration.tmpl", "[shuttle_tag] Shuttle Control", 470, 310)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/computer/shuttle_control/explore/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
usr.set_machine(src)
|
||||
src.add_fingerprint(usr)
|
||||
|
||||
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
if (!istype(shuttle))
|
||||
return
|
||||
|
||||
if(href_list["pick"])
|
||||
var/obj/effect/map/self = map_sectors["[z]"]
|
||||
if(self)
|
||||
var/list/possible_d = get_possible_destinations()
|
||||
var/obj/effect/map/D
|
||||
if(possible_d.len)
|
||||
D = input("Choose shuttle destination", "Shuttle Destination") as null|anything in possible_d
|
||||
update_destination(D)
|
||||
|
||||
if(href_list["move"])
|
||||
shuttle.launch(src)
|
||||
if(href_list["force"])
|
||||
shuttle.force_launch(src)
|
||||
else if(href_list["cancel"])
|
||||
shuttle.cancel_launch(src)
|
||||
Reference in New Issue
Block a user