Files
Bubberstation/code/game/objects/items/blueprints.dm
Y0SH1M4S73R 013de1fb80 Custom Shuttle QOL tweaks (and a fix to a mild shuttle engine exploit) (#89774)
## About The Pull Request

This PR adds some tweaks to make custom shuttles a bit easier to use,
and more useful.

- The station blueprints can be used to allow/forbid custom shuttle
docking in station/custom areas. Custom areas allow shuttle docking by
default, while station areas (apart from the asteroid) forbid it.
- A station area that allows shuttle docking can have a shuttle
built/expanded in it, as long as the area's APC isn't contained within
the frame used to construct/expand the shuttle.
- A shuttle frame does not need to contain the entirety of a custom
area, unless that frame contains the area's APC. If the frame doesn't
contain the entirety of the custom area, that section of the frame
becomes part of the default area, instead of a separate area.
- Custom shuttles will go off into the sunset at the end of the round,
as long as they have a welded engine.
- I think I saw a bug that caused engines to contribute twice the
intended power to the attached shuttle, possibly creating an exploit in
the case where the engine was broken while welded. I fixed that.
- Custom shuttle docking computers can cross over to any z-level
adjacent to the shuttle's z-level (or vertically-connected z-levels,
because docking computers can traverse stacked z-levels freely). This is
based on the new `zlink_range` var on all shuttle docking consoles,
which can be var-edited to provide the same functionality.
- Shuttle engines constructed from circuits now link to shuttles without
needing to be unanchored and reanchored.

## Why It's Good For The Game

The tweaks to shuttle construction and docking serve to address several
gripes I heard about players not being able to build/dock custom
shuttles in station areas. The means to do this have been locked behind
possession of the station blueprints.

I don't see what problem there would be with allowing custom shuttles to
leave the station at the end of the round, but I could lock it behind a
particular action (antag-exclusive or otherwise).

Custom shuttles don't quite have as much utility if you have to manually
travel to z-levels to drop off gigabeacons. Jumping to adjacent z-levels
one at a time is a bit more useful for space exploration.

## Changelog
🆑
add: The station blueprints can be used to toggle whether custom
shuttles can be built/expanded/docked within station areas.
qol: Custom areas do not have to be completely contained within shuttle
frames, as long as the APC isn't attached to the frame.
add: Custom shuttles with functioning engines will fly off into the
sunset when the emergency shuttle leaves.
add: Custom shuttle navigation computers can view space levels adjacent
to the one the shuttle is currently docked at.
fix: Constructed shuttle engines no longer contribute twice as much
engine power to shuttles, nor can they be used to add unlimited shuttle
power.
fix: Constructed shuttle engines now connect to shuttles when build,
rather than needing to be unachored and then reanchored.
/🆑
2025-03-13 12:25:09 +11:00

263 lines
9.0 KiB
Plaintext

///The area is a "Station" area, showing no special text.
#define AREA_STATION 1
///The area is in outdoors (lavaland/icemoon/jungle/space), therefore unclaimed territories.
#define AREA_OUTDOORS 2
///The area is special (shuttles/centcom), therefore can't be claimed.
#define AREA_SPECIAL 3
///The blueprints are currently reading the list of all wire datums.
#define LEGEND_VIEWING_LIST "watching_list"
///The blueprints are on the main page.
#define LEGEND_OFF "off"
/**
* Blueprints
* Used to see the wires of machines on the station, the roundstart layout of pipes/cables/tubes,
* as well as allowing you to rename existing areas and create new ones.
* Used by the station, cyborgs, and golems.
*/
/obj/item/blueprints
name = "station blueprints"
desc = "Blueprints of the station. There is a \"Classified\" stamp and several coffee stains on it."
icon = 'icons/obj/scrolls.dmi'
icon_state = "blueprints"
inhand_icon_state = "blueprints"
attack_verb_continuous = list("attacks", "baps", "hits")
attack_verb_simple = list("attack", "bap", "hit")
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF
interaction_flags_atom = parent_type::interaction_flags_atom | INTERACT_ATOM_ALLOW_USER_LOCATION | INTERACT_ATOM_IGNORE_MOBILITY
///A string of flavortext to be displayed at the top of the UI, related to the type of blueprints we are.
var/fluffnotice = "Property of Nanotrasen. For heads of staff only. Store in high-secure storage."
///Boolean on whether the blueprints are currently being used, which prevents double-using them to rename/create areas.
var/in_use = FALSE
///The type of area we'll create when we make a new area. This is a typepath.
var/area/new_area_type = /area
///The legend type the blueprints are currently looking at, which is either modularly
///set by wires datums, the main page, or an overview of them all.
var/legend_viewing = LEGEND_OFF
///List of images that we're showing to a client, used for showing blueprint data.
var/list/image/showing = list()
///The client that is being shown the list of 'showing' images of blueprint data.
var/client/viewing
/obj/item/blueprints/Destroy()
clear_viewer()
return ..()
/obj/item/blueprints/dropped(mob/user)
. = ..()
clear_viewer()
legend_viewing = LEGEND_OFF
/obj/item/blueprints/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Blueprints", name)
ui.open()
/obj/item/blueprints/ui_state(mob/user)
return GLOB.inventory_state
/obj/item/blueprints/ui_data(mob/user)
var/list/data = list()
switch(get_area_type(user))
if(AREA_OUTDOORS)
data["area_notice"] = "You are in unclaimed territory."
if(AREA_SPECIAL)
data["area_notice"] = "This area has no notes."
else
var/area/current_area = get_area(user)
data["area_notice"] = "You are now in \the [current_area.name]"
var/area/area_inside_of = get_area(user)
data["area_name"] = html_encode(area_inside_of.name)
data["area_allows_shuttle_docking"] = area_inside_of.allow_shuttle_docking
data["legend"] = legend_viewing
data["viewing"] = !!viewing
data["wire_data"] = list()
if(legend_viewing != LEGEND_VIEWING_LIST && legend_viewing != LEGEND_OFF)
for(var/device in GLOB.wire_color_directory)
if("[device]" != legend_viewing)
continue
data["wires_name"] = GLOB.wire_name_directory[device]
for(var/individual_color in GLOB.wire_color_directory[device])
var/wire_name = GLOB.wire_color_directory[device][individual_color]
if(findtext(wire_name, WIRE_DUD_PREFIX)) //don't show duds
continue
data["wire_data"] += list(list(
"color" = individual_color,
"message" = wire_name,
))
return data
/obj/item/blueprints/ui_static_data(mob/user)
var/list/data = list()
data["legend_viewing_list"] = LEGEND_VIEWING_LIST
data["legend_off"] = LEGEND_OFF
data["fluff_notice"] = fluffnotice
data["station_name"] = station_name()
data["wire_devices"] = list()
for(var/wireset in GLOB.wire_color_directory)
data["wire_devices"] += list(list(
"name" = GLOB.wire_name_directory[wireset],
"ref" = wireset,
))
return data
/obj/item/blueprints/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
var/mob/user = ui.user
if(!user.can_perform_action(src, NEED_LITERACY|NEED_DEXTERITY|NEED_HANDS|ALLOW_RESTING))
return TRUE
switch(action)
if("create_area")
if(in_use)
return
in_use = TRUE
create_area(user, new_area_type)
in_use = FALSE
if("edit_area")
if(get_area_type(user) != AREA_STATION)
return
if(in_use)
return
in_use = TRUE
edit_area(user)
in_use = FALSE
if("toggle_allow_shuttle_docking")
if(get_area_type(user) != AREA_STATION)
return
var/area/area = get_area(src)
area.allow_shuttle_docking = !area.allow_shuttle_docking
if("exit_legend")
legend_viewing = LEGEND_OFF
if("view_legend")
legend_viewing = LEGEND_VIEWING_LIST
if("view_wireset")
var/setting_wireset = params["view_wireset"]
for(var/device in GLOB.wire_color_directory)
if("[device]" == setting_wireset) //I know... don't change it...
legend_viewing = setting_wireset
return TRUE
if("view_blueprints")
playsound(src, 'sound/items/paper_flip.ogg', 40, TRUE)
user.balloon_alert_to_viewers("flips blueprints over")
set_viewer(user)
if("hide_blueprints")
playsound(src, 'sound/items/paper_flip.ogg', 40, TRUE)
user.balloon_alert_to_viewers("flips blueprints over")
clear_viewer()
if("refresh")
playsound(src, 'sound/items/paper_flip.ogg', 40, TRUE)
clear_viewer()
set_viewer(user)
return TRUE
/**
* Sets the user's client as the person viewing blueprint data, and builds blueprint data
* around the user.
* Args:
* - user: The person who's client we're giving images to.
*/
/obj/item/blueprints/proc/set_viewer(mob/user)
if(!user || !user.client)
return
if(viewing)
clear_viewer()
viewing = user.client
showing = get_blueprint_data(get_turf(viewing.eye || user), viewing.view)
viewing.images |= showing
/**
* Clears the client we're showig images to and deletes the images of blueprint data
* we made to show them.
*/
/obj/item/blueprints/proc/clear_viewer()
if(viewing)
viewing.images -= showing
viewing = null
showing.Cut()
/**
* Gets the area type the user is currently standing in.
* Returns: AREA_STATION, AREA_OUTDOORS, or AREA_SPECIAL
* Args:
* - user: The person we're getting the area of to check if it's a special area.
*/
/obj/item/blueprints/proc/get_area_type(mob/user)
var/area/area_checking = get_area(user)
if(area_checking.outdoors)
return AREA_OUTDOORS
var/static/list/special_areas = typecacheof(list(
/area/shuttle,
/area/centcom,
/area/centcom/asteroid,
/area/centcom/tdome,
/area/centcom/wizard_station,
/area/misc/hilbertshotel,
/area/misc/hilbertshotelstorage,
))
if(area_checking.type in special_areas)
return AREA_SPECIAL
return AREA_STATION
/**
* edit_area
* Takes input from the player and renames the area the blueprints are currently in.
*/
/obj/item/blueprints/proc/edit_area(mob/user)
var/area/area_editing = get_area(src)
var/prevname = "[area_editing.name]"
var/new_name = tgui_input_text(user, "New area name", "Area Creation", max_length = MAX_NAME_LEN)
if(isnull(new_name) || !length(new_name) || new_name == prevname)
return
rename_area(area_editing, new_name)
user.balloon_alert(user, "area renamed to [new_name]")
user.log_message("has renamed [prevname] to [new_name]", LOG_GAME)
return TRUE
///Cyborg blueprints - The same as regular but with a different fluff text.
/obj/item/blueprints/cyborg
name = "station schematics"
desc = "A digital copy of the station blueprints stored in your memory."
fluffnotice = "Intellectual Property of Nanotrasen. For use in engineering cyborgs only. Wipe from memory upon departure from the station."
///Golem blueprints - Used to make golem areas that won't give the hazardous area debuffs.
/obj/item/blueprints/golem
name = "land claim"
desc = "Use it to build new structures in the wastes."
fluffnotice = "In memory of the Liberator's brother, Delaminator, and his Scarlet Macaw-iathan, from which this artifact was stolen."
new_area_type = /area/golem
///Slime blueprints - Makes areas colored and compatible with xenobiology camera consoles, one time use.
/obj/item/blueprints/slime
name = "cerulean prints"
desc = "A one use yet of blueprints made of jelly like organic material. Extends the reach of the management console."
fluffnotice = "Copyright by Science Inc. Renaming areas will allow for management consoles to traverse them."
color = "#2956B2"
/obj/item/blueprints/slime/edit_area(mob/user)
. = ..()
var/area/area = get_area(src)
var/list/turf_matrix = color_transition_filter("#2956B2")
for(var/list/zlevel_turfs as anything in area.get_zlevel_turf_lists())
for(var/turf/area_turf as anything in zlevel_turfs)
area_turf.remove_atom_colour(WASHABLE_COLOUR_PRIORITY)
area_turf.add_atom_colour(turf_matrix, FIXED_COLOUR_PRIORITY)
area.area_flags |= XENOBIOLOGY_COMPATIBLE
qdel(src)
#undef LEGEND_VIEWING_LIST
#undef LEGEND_OFF
#undef AREA_STATION
#undef AREA_OUTDOORS
#undef AREA_SPECIAL