Skip to content

Commit

Permalink
some changes to MDs
Browse files Browse the repository at this point in the history
  • Loading branch information
morrowwolf committed Oct 27, 2023
1 parent 85820ec commit 36d6060
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions code/game/objects/items/devices/motion_detector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#define MOTION_DETECTOR_RANGE_LONG 14
#define MOTION_DETECTOR_RANGE_SHORT 7

#define MOTION_DETECTOR_BASE_COOLDOWN (1 SECONDS)
#define MOTION_DETECTOR_RANGE_LONG_MULTIPLIER 2.5

/obj/effect/detector_blip
icon = 'icons/obj/items/marine-items.dmi'
icon_state = "detector_blip"
Expand All @@ -30,7 +33,6 @@
w_class = SIZE_MEDIUM
var/active = 0
var/recycletime = 120
var/long_range_cooldown = 2
var/blip_type = "detector"
var/iff_signal = FACTION_MARINE
actions_types = list(/datum/action/item_action)
Expand All @@ -39,6 +41,9 @@
var/long_range_locked = FALSE //only long-range MD
var/ping_overlay

/// Handles our cooldowns regarding pings
COOLDOWN_DECLARE(ping_cooldown)

/obj/item/device/motiondetector/proc/get_help_text()
. = "Blue bubble-like indicators on your HUD will show pings locations or direction to them. The device screen will show the amount of unidentified movements detected (up to 9). Has two modes: slow long-range [SPAN_HELPFUL("([MOTION_DETECTOR_RANGE_LONG] tiles)")] and fast short-range [SPAN_HELPFUL("([MOTION_DETECTOR_RANGE_SHORT] tiles)")]. Use [SPAN_HELPFUL("Alt + Click")] on the device to switch between modes. Using the device on the adjacent multitile vehicle will start the process of recalibrating and scanning vehicle interior for unidentified movements inside."

Expand Down Expand Up @@ -136,7 +141,7 @@
else if(user)
to_chat(user, SPAN_NOTICE("You activate \the [src]."))
playsound(loc, 'sound/items/detector_turn_on.ogg', 30, FALSE, 5, 2)
START_PROCESSING(SSobj, src)
START_PROCESSING(SSfastobj, src)

/obj/item/device/motiondetector/proc/turn_off(mob/user, forced = FALSE)
if(forced)
Expand All @@ -146,34 +151,37 @@
scanning = FALSE // safety if MD runtimes in scan and stops scanning
icon_state = "[initial(icon_state)]"
playsound(loc, 'sound/items/detector_turn_off.ogg', 30, FALSE, 5, 2)
STOP_PROCESSING(SSobj, src)
STOP_PROCESSING(SSfastobj, src)

/obj/item/device/motiondetector/Destroy()
STOP_PROCESSING(SSobj, src)
STOP_PROCESSING(SSfastobj, src)
for(var/to_delete in blip_pool)
qdel(blip_pool[to_delete])
blip_pool.Remove(to_delete)
blip_pool = null
return ..()

/obj/item/device/motiondetector/process()
/obj/item/device/motiondetector/process(delta_time)
if(isturf(loc))
toggle_active(null, TRUE)

if(!active)
STOP_PROCESSING(SSobj, src)
STOP_PROCESSING(SSfastobj, src)
return

recycletime--
if(!recycletime)
recycletime = initial(recycletime)
refresh_blip_pool()

if(!detector_mode)
long_range_cooldown--
if(long_range_cooldown) return
else long_range_cooldown = initial(long_range_cooldown)
if(!COOLDOWN_FINISHED(src, ping_cooldown))
return

scan()

var/next_ping_cooldown = MOTION_DETECTOR_BASE_COOLDOWN * (detector_mode ? 1 : MOTION_DETECTOR_RANGE_LONG_MULTIPLIER)
COOLDOWN_START(src, ping_cooldown, next_ping_cooldown)

/obj/item/device/motiondetector/proc/refresh_blip_pool()
for(var/X in blip_pool) //we dump and remake the blip pool every few minutes
if(blip_pool[X]) //to clear blips assigned to mobs that are long gone.
Expand Down

0 comments on commit 36d6060

Please sign in to comment.