diff --git a/aurorastation.dme b/aurorastation.dme index 1e134ff5ce5..2a979b0ddc0 100644 --- a/aurorastation.dme +++ b/aurorastation.dme @@ -1034,6 +1034,7 @@ #include "code\game\objects\items\devices\magnetic_lock.dm" #include "code\game\objects\items\devices\megaphone.dm" #include "code\game\objects\items\devices\memorywiper.dm" +#include "code\game\objects\items\devices\minedetector.dm" #include "code\game\objects\items\devices\modkit.dm" #include "code\game\objects\items\devices\multitool.dm" #include "code\game\objects\items\devices\oxycandle.dm" diff --git a/code/game/objects/items/devices/minedetector.dm b/code/game/objects/items/devices/minedetector.dm new file mode 100644 index 00000000000..09727fd564b --- /dev/null +++ b/code/game/objects/items/devices/minedetector.dm @@ -0,0 +1,102 @@ +/obj/item/device/mine_detector + name = "mine detector" + desc = "A device capable of detecting mines and traps in a range." + + ///The types that are detected by this device + var/list/detectable_types = list(/obj/item/landmine, /obj/item/trap) + + ///The range in which the detection happens + var/detection_range = 4 + + ///The angle from the center in which the detection happens + var/detection_angle = 30 + + ///The last time this was activated, to avoid spamming it. In `world.time` + var/last_use = null + + ///How much to wait before allowing a new scan + var/delay_between_scans = 3 SECONDS + + ///If this detector is able to perform scans automatically, instead of having to trigger them manually + var/can_scan_automatically = FALSE + + ///The timer ID for the automatic rescans + var/timer_id = null + +/obj/item/device/mine_detector/attack_self(mob/user) + . = ..() + + //Apply the delay and check it is passed, so a new scan can be done + if((last_use + delay_between_scans) > world.time) + return + + last_use = world.time + + if(!can_scan_automatically) + perform_scan(user) + + else + + //If there's no timer, start a new one, otherwise stop the callbacks (aka stop the automatic scanning) + if(!timer_id) + to_chat(user, SPAN_NOTICE("You power on the automatic mine detection system, which shows a loading screen with a progress bar.")) + timer_id = addtimer(CALLBACK(src, PROC_REF(perform_scan), user), delay_between_scans, TIMER_UNIQUE|TIMER_STOPPABLE) + else + to_chat(user, SPAN_NOTICE("You power off the automatic mine detection system.")) + deltimer(timer_id) + timer_id = null + + +/obj/item/device/mine_detector/proc/perform_scan(mob/user) + + var/list/turfs_scanned = get_turfs_in_cone(get_turf(src), dir2angle(user.dir), detection_range, detection_angle) + + //This will contain the distance of the closest detected object + var/minimum_distance_detected = null + + var/obj/effect/overlay/teleport_pulse/scanned = new() //This goes in nullspace because we want to project the image to the user only + + //Search across the content of the turfs we got in the cone + for(var/turf/turf as anything in turfs_scanned) + + //Show the effect on every turf that was scanned, to the user + user.client.images += image(scanned, turf) + + for(var/item in turf.contents) + + //If it's a type we can detect + if(is_type_in_list(item, detectable_types)) + + //Set it as the minimum distance mine if it's either not set, or closer than the previous detection + var/distance = get_dist(src, item) + if(isnull(minimum_distance_detected) || (distance < minimum_distance_detected)) + minimum_distance_detected = distance + + //Select the appropriate sound to play based on the distance, but only if something was detected + if(!isnull(minimum_distance_detected)) + var/sound = null + + //Pick the audio based on the distance + if(minimum_distance_detected < 2) + sound = 'sound/items/devices/minedetector/minedetector_close.ogg' + else if(minimum_distance_detected <= (detection_range / 2)) + sound = 'sound/items/devices/minedetector/minedetector_medium.ogg' + else + sound = 'sound/items/devices/minedetector/minedetector_far.ogg' + + //Play it + playsound(src, sound, 75, FALSE) + + //Reregister the next callback timer if we're running automatic scans + if(can_scan_automatically && timer_id) + timer_id = addtimer(CALLBACK(src, PROC_REF(perform_scan), user), delay_between_scans, TIMER_UNIQUE|TIMER_STOPPABLE) + +/*############# + Subtypes +#############*/ + +/obj/item/device/mine_detector/advanced + name = "advanced mine detector" + desc = "A device capable of detecting mines and traps in a range. This one is more advanced, featuring automatic scanning as well as a broader detection angle." + detection_angle = 45 + can_scan_automatically = TRUE diff --git a/code/game/objects/structures/crates_lockers/closets/utility_closets.dm b/code/game/objects/structures/crates_lockers/closets/utility_closets.dm index c322c808cf0..7309f1ac6cf 100644 --- a/code/game/objects/structures/crates_lockers/closets/utility_closets.dm +++ b/code/game/objects/structures/crates_lockers/closets/utility_closets.dm @@ -232,3 +232,4 @@ new /obj/item/clothing/shoes/sneakers/brown(src) new /obj/item/clothing/head/bomb_hood/security(src) new /obj/item/wirecutters/bomb(src) + new /obj/item/device/mine_detector(src) diff --git a/html/changelogs/fluffyghost-minedetector.yml b/html/changelogs/fluffyghost-minedetector.yml new file mode 100644 index 00000000000..42df7903557 --- /dev/null +++ b/html/changelogs/fluffyghost-minedetector.yml @@ -0,0 +1,43 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: FluffyGhost + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Added a mine detector, it is able to beep with different sounds depending on the distance of the closest mine or trap, scans in a cone up to a range for them." + - rscadd: "Added the mine detector to the security closet." + - soundadd: "Added sounds for the mine detector." diff --git a/sound/attributions.txt b/sound/attributions.txt index d1e33c12672..50a08b25efa 100644 --- a/sound/attributions.txt +++ b/sound/attributions.txt @@ -75,4 +75,10 @@ ATTRIBUTIONS SECTION END ATTRIBUTIONS SECTION START sound/items/typewriter.ogg - "Typewriter Sound Effect" licensed under CC0, by No Copyright Creator Sounds. Obtained and edited from https://www.youtube.com/watch?v=HYvJtImzoNI&ab_channel=NoCopyrightCreator-Sounds sound/items/camerabulb.ogg - "Vintage Camera Flash Bulb Pops Sound Design" licensed under CC0, by Adilbek Sounds. Obainted and edited from https://freesound.org/people/adilbek_sounds/sounds/595044/ -ATTRIBUTIONS SECTION END \ No newline at end of file +ATTRIBUTIONS SECTION END + +ATTRIBUTIONS SECTION START +/sound/items/devices/minedetector/minedetector_close.ogg - Part of "Detector", licensed under CC0. Obtained from https://freesound.org/people/fennelliott/sounds/426404/ +/sound/items/devices/minedetector/minedetector_medium.ogg - Part of "Detector", licensed under CC0. Obtained from https://freesound.org/people/fennelliott/sounds/426404/ +/sound/items/devices/minedetector/minedetector_far.ogg - Part of "Detector", licensed under CC0. Obtained from https://freesound.org/people/fennelliott/sounds/426404/ +ATTRIBUTIONS SECTION END diff --git a/sound/items/devices/minedetector/minedetector_close.ogg b/sound/items/devices/minedetector/minedetector_close.ogg new file mode 100644 index 00000000000..7d7008f3b19 Binary files /dev/null and b/sound/items/devices/minedetector/minedetector_close.ogg differ diff --git a/sound/items/devices/minedetector/minedetector_far.ogg b/sound/items/devices/minedetector/minedetector_far.ogg new file mode 100644 index 00000000000..97a44dad2ca Binary files /dev/null and b/sound/items/devices/minedetector/minedetector_far.ogg differ diff --git a/sound/items/devices/minedetector/minedetector_medium.ogg b/sound/items/devices/minedetector/minedetector_medium.ogg new file mode 100644 index 00000000000..8d917c31372 Binary files /dev/null and b/sound/items/devices/minedetector/minedetector_medium.ogg differ