Files
GhomandGitHub 6eb2d1674a Implementing materials checks for techweb designs. (#96257)
## About The Pull Request
In similar fashion to what was done with crafting recipes last year,
this year it's time for techweb designs and printed items to be audited.
This is mostly just about consistency, we've a lot of items that can be
printed by protolathes, autolathes, circuit printers and techfab etc.
However they almost all (except most stacks, mainly) have custom
materials that do not match in one way or another with the materials
used by the design, which is what this PR is for.

"But items printed from lathes etc. already get the mats used to make
them." Yes, they do, however that isn't the case for items of the same
type that were spawned in some other way (cargo shuttle, space/maints
loot, mapped, admins), this create a subtle discrepancy. It isn't a huge
deal (in spite of the size of this PR, ton of designs), but given that I
have done something similar with crafting recipes before, I may as well
give it a second arc of some sort and bring things to completion. And
fix a few possible oversights.

TL;DR consistency and stuff

## Why It's Good For The Game
Consistency, unit test checks to make it harder not to be consistent in
the future. Still has a few TODOs like:

- [x] Fixed newly printed, fully charged RCDs costing less than the RCD
cartridges required to fully charge one. EDIT: I had to tweak the newly
added RDD as well because it suffered from the same fundamental issue.
- [x] Fixed plates being made of iron and yet shattering like ceramic
ones. A new subtype for metallic ones has been made.

## Changelog

🆑
refactor: Refactored a few things with techweb designs (the ones for
autolathes, protolathes, circuit printers, mechfabs etc.) to make sure
that the materials of items that can be made from these designs more
closely match the materials used to make them.
fix: Lizard fries no longer need a plate to be made, like all other
treats that used to require plates in a distant past.
balance: Tweaked the materials cost of RCD, RDD and RCD cartridges.
image: Oven trays now have a more metallic hue.
balance: Plates printed printed from lathes won't shatter like ceramic
ones, in virtue of them being made out of iron instead.
/🆑
2026-07-06 00:13:02 -07:00

163 lines
5.8 KiB
Plaintext

///Energy used to say an error message.
#define ENERGY_TO_SPEAK (0.001 * STANDARD_CELL_CHARGE)
/**
* # N-spect scanner
*
* Determines if an item or its contents are contraband.
*/
/obj/item/inspector
name = "\improper N-spect scanner"
desc = "Central Command standard issue inspection device. \
Used for precision scans to determine if an item contains, or is itself, contraband."
icon = 'icons/obj/devices/scanner.dmi'
icon_state = "inspector"
worn_icon_state = "salestagger"
inhand_icon_state = "electronic"
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
throwforce = 0
w_class = WEIGHT_CLASS_TINY
interaction_flags_click = NEED_DEXTERITY
throw_range = 1
throw_speed = 1
sound_vary = TRUE
pickup_sound = SFX_GENERIC_DEVICE_PICKUP
drop_sound = SFX_GENERIC_DEVICE_DROP
custom_materials = list(/datum/material/iron = SHEET_MATERIAL_AMOUNT * 2.5, /datum/material/uranium = SHEET_MATERIAL_AMOUNT, /datum/material/glass = SMALL_MATERIAL_AMOUNT * 4.6, /datum/material/gold = HALF_SHEET_MATERIAL_AMOUNT)
///Power cell used to power the scanner. Paths g
var/obj/item/stock_parts/power_store/cell = /obj/item/stock_parts/power_store/cell/crap
///Cell cover status
var/cell_cover_open = FALSE
///Does this item scan for contraband correctly? If not, will provide a flipped response.
var/scans_correctly = TRUE
/obj/item/inspector/Initialize(mapload)
. = ..()
if(ispath(cell))
cell = new cell(src)
register_context()
register_item_context()
// Clean up the cell on destroy
/obj/item/inspector/Exited(atom/movable/gone, direction)
. = ..()
if(gone == cell)
cell = null
// support for items that interact with the cell
/obj/item/inspector/get_cell()
return cell
/obj/item/inspector/crowbar_act(mob/living/user, obj/item/tool)
cell_cover_open = !cell_cover_open
balloon_alert(user, "[cell_cover_open ? "opened" : "closed"] cell cover")
return ITEM_INTERACT_SUCCESS
/obj/item/inspector/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(cell_cover_open && istype(tool, /obj/item/stock_parts/power_store/cell))
if(cell)
to_chat(user, span_warning("[src] already has a cell installed."))
return ITEM_INTERACT_BLOCKING
if(user.transferItemToLoc(tool, src))
cell = tool
to_chat(user, span_notice("You successfully install \the [cell] into [src]."))
return ITEM_INTERACT_SUCCESS
return ITEM_INTERACT_BLOCKING
return NONE
/obj/item/inspector/item_ctrl_click(mob/user)
if(!cell_cover_open || !cell)
return CLICK_ACTION_BLOCKING
user.visible_message(span_notice("[user] removes \the [cell] from [src]!"), \
span_notice("You remove [cell]."))
cell.add_fingerprint(user)
user.put_in_hands(cell)
cell = null
return CLICK_ACTION_SUCCESS
/obj/item/inspector/examine(mob/user)
. = ..()
. += span_info("Use on an item to scan if it contains, or is, contraband.")
if(!cell_cover_open)
. += span_notice("Its cell cover is closed. It looks like it could be <strong>pried</strong> out, but doing so would require an appropriate tool.")
return
. += span_notice("Its cell cover is open, exposing the cell slot. It looks like it could be <strong>pried</strong> in, but doing so would require an appropriate tool.")
if(!cell)
. += span_notice("The slot for a cell is empty.")
else
. += span_notice("\The [cell] is firmly in place. Ctrl-click with an empty hand to remove it.")
/obj/item/inspector/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
if(!user.Adjacent(interacting_with))
return ITEM_INTERACT_BLOCKING
if(cell_cover_open)
balloon_alert(user, "close cover first!")
return ITEM_INTERACT_BLOCKING
if(!cell || !cell.use(0.001 * STANDARD_CELL_CHARGE))
balloon_alert(user, "check cell!")
return ITEM_INTERACT_BLOCKING
if(iscarbon(interacting_with)) // Prevents scanning people
return ITEM_INTERACT_BLOCKING
if(contraband_scan(interacting_with, user))
playsound(src, 'sound/machines/uplink/uplinkerror.ogg', 40)
balloon_alert(user, "contraband detected!")
return ITEM_INTERACT_SUCCESS
playsound(src, 'sound/machines/ping.ogg', 20)
balloon_alert(user, "clear")
return ITEM_INTERACT_SUCCESS
/obj/item/inspector/add_context(atom/source, list/context, obj/item/held_item, mob/user)
var/update_context = FALSE
if(cell_cover_open && cell)
context[SCREENTIP_CONTEXT_CTRL_LMB] = "Remove cell"
update_context = TRUE
if(cell_cover_open && !cell && istype(held_item, /obj/item/stock_parts/power_store/cell))
context[SCREENTIP_CONTEXT_LMB] = "Install cell"
update_context = TRUE
if(held_item?.tool_behaviour == TOOL_CROWBAR)
context[SCREENTIP_CONTEXT_LMB] = "[cell_cover_open ? "close" : "open"] battery panel"
update_context = TRUE
if(update_context)
return CONTEXTUAL_SCREENTIP_SET
return NONE
/obj/item/inspector/add_item_context(obj/item/source, list/context, atom/target, mob/living/user)
if(cell_cover_open || !cell)
return NONE
if(isitem(target))
context[SCREENTIP_CONTEXT_LMB] = "Contraband Scan"
return CONTEXTUAL_SCREENTIP_SET
return NONE
/**
* Scans the carbon or item for contraband.
*
* Arguments:
* - scanned - what or who is scanned?
* - user - who is performing the scanning?
*/
/obj/item/inspector/proc/contraband_scan(scanned, user)
if(iscarbon(scanned))
var/mob/living/carbon/scanned_carbon = scanned
for(var/obj/item/content in scanned_carbon.get_all_contents_skipping_traits(TRAIT_CONTRABAND_BLOCKER))
var/contraband_content = content.is_contraband()
if((contraband_content && scans_correctly) || (!contraband_content && !scans_correctly))
return TRUE
if(isitem(scanned))
var/obj/item/contraband_item = scanned
var/contraband_status = contraband_item.is_contraband()
if((contraband_status && scans_correctly) || (!contraband_status && !scans_correctly))
return TRUE
return FALSE
#undef ENERGY_TO_SPEAK