more whiteship signaller features (#28896)

* more whiteship signaller features

* don't vanish anymore when out of dock quota
This commit is contained in:
warriorstar-orion
2025-04-08 09:10:57 -04:00
committed by GitHub
parent b68e881eb6
commit 2d9ffe8ff9
3 changed files with 99 additions and 19 deletions
+90 -11
View File
@@ -3,17 +3,26 @@
desc = "A signaling device for the NT expeditionary vessel, used to designate new docking areas."
icon = 'icons/obj/device.dmi'
icon_state = "gangtool-white"
new_attack_chain = TRUE
var/list/placed_docks = list()
var/max_docks = 3
var/max_docks = 6
var/shuttleId = "whiteship"
var/possible_destinations
/obj/item/whiteship_port_generator/examine(mob/user)
. = ..()
var/count = max_docks - length(placed_docks)
var/plural = count > 1
. += "There [plural ? "are" : "is"] [count] use[plural ? "s" : ""] left."
. += "<span class='notice'>There [plural ? "are" : "is"] [count] use[plural ? "s" : ""] left.</span>"
. += "<span class='notice'><b>Alt-Click</b> to call the ship to an existing docking area.</span>"
/obj/item/whiteship_port_generator/activate_self(mob/user)
. = FINISH_ATTACK
if(..())
return
/obj/item/whiteship_port_generator/attack_self__legacy__attackchain(mob/living/user)
if(is_station_level(user.z))
log_admin("[key_name(user)] attempted to create a whiteship dock in the station's sector at [COORD(user)].")
to_chat(user, "<span class='notice'>New docking areas cannot be designated within the station's sector!</span>")
@@ -29,10 +38,15 @@
to_chat(user, "<span class='notice'>New docking areas cannot be designated planet side!</span>")
return
var/list/docks_per_z = list()
for(var/obj/placed_dock in placed_docks)
if(placed_dock.z == user.z)
to_chat(user, "<span class='notice'>A docking area has already been placed in this sector!</span>")
return
if(!("[placed_dock.z]" in docks_per_z))
docks_per_z["[placed_dock.z]"] = 0
docks_per_z["[placed_dock.z]"]++
if(docks_per_z["[user.z]"] >= 3)
to_chat(user, "<span class='notice'>This sector cannot support any more docking areas!</span>")
return
var/list/dir_choices = list("North" = NORTH, "East" = EAST, "South" = SOUTH, "West" = WEST)
var/dir_choice = tgui_input_list(user, "Select the new docking area orientation.", "Dock Orientation", dir_choices)
@@ -99,11 +113,76 @@
for(var/obj/machinery/computer/shuttle/white_ship/S in GLOB.machines)
S.possible_destinations = null
S.connect()
possible_destinations = S.possible_destinations
log_admin("[key_name(user)] created a whiteship dock named '[name]' at [COORD(port)].")
to_chat(user, "<span class='notice'>Landing zone set.</span>")
if(dock_count < max_docks)
to_chat(user, "<span class='notice'>Landing zone set.</span>")
else
to_chat(user, "<span class='notice'>Landing zone set. The signaller vanishes!</span>")
qdel(src)
/obj/item/whiteship_port_generator/AltClick(mob/user, modifiers)
for(var/obj/machinery/computer/shuttle/white_ship/S in GLOB.machines)
possible_destinations = S.possible_destinations
break
ui_interact(user)
/obj/item/whiteship_port_generator/ui_state(mob/user)
return GLOB.default_state
/obj/item/whiteship_port_generator/ui_interact(mob/user, datum/tgui/ui = null)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "ShuttleConsole", name)
ui.open()
/// Pretty much a straight copy-paste of [/obj/machinery/computer/shuttle/proc/ui_data].
/// Yes it could be refactored but tearing all of the "make the shuttle move" code out of
/// the console whose job it is to exclusively do that is unsurprisingly messy.
/obj/item/whiteship_port_generator/ui_data(mob/user)
var/list/data = list()
var/obj/docking_port/mobile/M = SSshuttle.getShuttle(shuttleId)
data["status"] = M ? M.getStatusText() : null
if(M)
data["shuttle"] = TRUE //this should just be boolean, right?
var/list/docking_ports = list()
data["docking_ports"] = docking_ports
var/list/options = params2list(possible_destinations)
for(var/obj/docking_port/stationary/S in SSshuttle.stationary_docking_ports)
if(!options.Find(S.id))
continue
if(!M.check_dock(S))
continue
docking_ports[++docking_ports.len] = list("name" = S.name, "id" = S.id)
data["docking_ports_len"] = length(docking_ports)
return data
/// Pretty much a straight copy-paste of [/obj/machinery/computer/shuttle/proc/ui_act].
/// Yes it could be refactored but tearing all of the "make the shuttle move" code out of
/// the console whose job it is to exclusively do that is unsurprisingly messy.
/obj/item/whiteship_port_generator/ui_act(action, params)
if(..()) //we can't actually interact, so no action
return TRUE
if(!allowed(usr))
to_chat(usr, "<span class='danger'>Access denied.</span>")
return TRUE
var/list/options = params2list(possible_destinations)
if(action == "move")
var/destination = params["move"]
if(!options.Find(destination))//figure out if this translation works
message_admins("<span class='boldannounceooc'>EXPLOIT:</span> [ADMIN_LOOKUPFLW(usr)] attempted to move [src] to an invalid location! [ADMIN_COORDJMP(src)]")
return
switch(SSshuttle.moveShuttle(shuttleId, destination, TRUE, usr))
if(0)
atom_say("Shuttle en route.")
usr.create_log(MISC_LOG, "used [src] to call the [shuttleId] shuttle")
add_fingerprint(usr)
return TRUE
if(1)
to_chat(usr, "<span class='warning'>Invalid shuttle requested.</span>")
if(2)
to_chat(usr, "<span class='notice'>Unable to comply.</span>")
if(3)
atom_say("Shuttle is regenerating fuel. Please wait...")
if(4)
atom_say("Shuttle is currently en-route. The shuttle cannot be rerouted at this time.")
if(5)
atom_say("Shuttle is currently departing. Please wait...")
+5 -8
View File
@@ -939,8 +939,8 @@
var/admin_controlled
var/max_connect_range = 7
var/moved = FALSE //workaround for nukie shuttle, hope I find a better way to do this...
/// Do we want to search for shuttle destinations as part of Initialize (fixed) or LateInitialize (variable)
var/find_destinations_in_late_init = FALSE
/// Do we want to search for shuttle destinations as part of Initialize (fixed) or when SSlate_mapping fires (variable)
var/find_destinations_in_late_mapping = FALSE
/obj/machinery/computer/shuttle/New(location, obj/item/circuitboard/shuttle/C)
..()
@@ -950,14 +950,11 @@
/obj/machinery/computer/shuttle/Initialize(mapload)
. = ..()
if(find_destinations_in_late_init && mapload) // We only care about this in mapload, if its mid round its fine
return INITIALIZE_HINT_LATELOAD
if(find_destinations_in_late_mapping && mapload) // We only care about this in mapload, if its mid round its fine
return
connect()
/obj/machinery/computer/shuttle/LateInitialize()
connect()
/obj/machinery/computer/shuttle/proc/connect()
var/obj/docking_port/mobile/M
if(!shuttleId)
@@ -1094,7 +1091,7 @@
circuit = /obj/item/circuitboard/white_ship
shuttleId = "whiteship"
possible_destinations = null // Set at runtime
find_destinations_in_late_init = TRUE
find_destinations_in_late_mapping = TRUE
/obj/machinery/computer/shuttle/admin
name = "admin shuttle console"