diff --git a/code/datums/components/crafting/equipment.dm b/code/datums/components/crafting/equipment.dm index 4e57287dba8..f7149d56ec9 100644 --- a/code/datums/components/crafting/equipment.dm +++ b/code/datums/components/crafting/equipment.dm @@ -142,6 +142,17 @@ result = /obj/item/ore_sensor category = CAT_EQUIPMENT +/datum/crafting_recipe/material_sniffer + name = "Material Sniffer" + time = 3 SECONDS + reqs = list( + /obj/item/analyzer = 1, + /obj/item/stack/cable_coil = 5, + ) + tool_behaviors = list(TOOL_SCREWDRIVER, TOOL_WIRECUTTER) + result = /obj/item/pinpointer/material_sniffer + category = CAT_EQUIPMENT + /datum/crafting_recipe/pressureplate name = "Pressure Plate" result = /obj/item/pressure_plate diff --git a/code/game/objects/items/pinpointer.dm b/code/game/objects/items/pinpointer.dm index 82fe4ffae96..e671fe94c41 100644 --- a/code/game/objects/items/pinpointer.dm +++ b/code/game/objects/items/pinpointer.dm @@ -216,3 +216,38 @@ /obj/item/pinpointer/shuttle/Destroy() shuttleport = null . = ..() + +///list of all sheets with sniffable = TRUE for the sniffer to locate +GLOBAL_LIST_EMPTY(sniffable_sheets) + +/obj/item/pinpointer/material_sniffer + name = "material sniffer" + desc = "A handheld tracking device that locates sheets of glass and iron." + icon_state = "pinpointer_sniffer" + worn_icon_state = "pinpointer_black" + +/obj/item/pinpointer/material_sniffer/scan_for_target() + if(target) + return + var/obj/item/stack/sheet/new_sheet_target + var/closest_distance = INFINITY + for(var/obj/item/stack/sheet/potential_sheet as anything in GLOB.sniffable_sheets) + // not enough for lag reasons, and shouldn't even be on this + if(potential_sheet.amount < 10) + GLOB.sniffable_sheets -= potential_sheet + continue + //held by someone + if(isliving(potential_sheet.loc)) + continue + //not on scanner's z + if(potential_sheet.z != z) + continue + var/distance_from_sniffer = get_dist(src, potential_sheet) + if(distance_from_sniffer < closest_distance) + closest_distance = distance_from_sniffer + new_sheet_target = potential_sheet + if(!new_sheet_target) + target = null + return + say("Located [new_sheet_target.amount] [new_sheet_target.singular_name]s!") + target = new_sheet_target diff --git a/code/game/objects/items/stacks/sheets/glass.dm b/code/game/objects/items/stacks/sheets/glass.dm index 537cad9c5b7..2f23e3c83c0 100644 --- a/code/game/objects/items/stacks/sheets/glass.dm +++ b/code/game/objects/items/stacks/sheets/glass.dm @@ -32,6 +32,7 @@ GLOBAL_LIST_INIT(glass_recipes, list ( \ matter_amount = 4 cost = 500 source = /datum/robot_energy_storage/glass + sniffable = TRUE /datum/armor/sheet_glass fire = 50 diff --git a/code/game/objects/items/stacks/sheets/sheet_types.dm b/code/game/objects/items/stacks/sheets/sheet_types.dm index 87168ba8244..d74c9e922bc 100644 --- a/code/game/objects/items/stacks/sheets/sheet_types.dm +++ b/code/game/objects/items/stacks/sheets/sheet_types.dm @@ -152,6 +152,7 @@ GLOBAL_LIST_INIT(metal_recipes, list ( \ cost = 500 source = /datum/robot_energy_storage/iron stairs_type = /obj/structure/stairs + sniffable = TRUE /obj/item/stack/sheet/iron/Initialize(mapload) . = ..() diff --git a/code/game/objects/items/stacks/sheets/sheets.dm b/code/game/objects/items/stacks/sheets/sheets.dm index 2d6ab81b64f..a09def859aa 100644 --- a/code/game/objects/items/stacks/sheets/sheets.dm +++ b/code/game/objects/items/stacks/sheets/sheets.dm @@ -17,11 +17,27 @@ var/point_value = 0 //turn-in value for the gulag stacker - loosely relative to its rarity. ///What type of wall does this sheet spawn var/walltype + /// whether this sheet can be sniffed by the material sniffer + var/sniffable = FALSE /obj/item/stack/sheet/Initialize(mapload, new_amount, merge = TRUE, list/mat_override=null, mat_amt=1) . = ..() pixel_x = rand(-4, 4) pixel_y = rand(-4, 4) + if(sniffable && is_station_level(z) && amount < 10) + GLOB.sniffable_sheets += src + +/obj/item/stack/sheet/Destroy(force) + if(sniffable) + GLOB.sniffable_sheets -= src + return ..() + +/obj/item/stack/sheet/add(_amount) + . = ..() + if(sniffable && is_station_level(z) && amount > 10) + GLOB.sniffable_sheets += src + +/// removing from sniffable handled by the sniffer itself when it checks for targets /** * Facilitates sheets being smacked on the floor diff --git a/icons/obj/device.dmi b/icons/obj/device.dmi index 41c767e0b1f..3cf10e9039b 100644 Binary files a/icons/obj/device.dmi and b/icons/obj/device.dmi differ