Skip to content
This repository has been archived by the owner on Dec 18, 2018. It is now read-only.

Commit

Permalink
Motion Detector Auto-Deactivates If User Dead (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
Surrealaser authored and Rohesie committed Nov 21, 2018
1 parent e5fbd08 commit a8ec4e4
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions code/game/objects/items/devices/motion_detector.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
var/detect_revivable = TRUE
var/detect_fubar = TRUE
var/ping = TRUE
var/mob/living/carbon/human/operator

/obj/item/device/motiondetector/examine(mob/user as mob)
if(get_dist(user,src) > 2)
Expand All @@ -71,26 +72,43 @@
blip_pool = list()
..()

/obj/item/device/motiondetector/dropped(mob/user)
. = ..()
operator = null


/obj/item/device/motiondetector/update_icon()
if(active)
icon_state = "detector_on_[detector_mode]"
else
icon_state = "detector_off"
return ..()

/obj/item/device/motiondetector/proc/deactivate()
active = FALSE
operator = null
update_icon()
processing_objects.Remove(src)

/obj/item/device/motiondetector/process()
if(!active)
update_icon()
processing_objects.Remove(src)
deactivate()
return

var/mob/living/carbon/human/human_user
if(ishuman(loc))
human_user = loc
else
active = FALSE
update_icon()
processing_objects.Remove(src)
if(!operator)
deactivate()
return

if(get_turf(src) != get_turf(operator))
deactivate()
return

if(operator.stat == DEAD)
deactivate()
return

if(!operator.client)
deactivate()
return

recycletime--
Expand All @@ -111,7 +129,7 @@

var/detected
var/status
for(var/mob/living/M in orange(detector_range, human_user))
for(var/mob/living/M in orange(detector_range, operator))
if(!isturf(M.loc))
continue
if(isrobot(M))
Expand Down Expand Up @@ -141,8 +159,7 @@

detected = TRUE

if(human_user)
show_blip(human_user, M, status)
show_blip(operator, M, status)

if(detected && ping)
playsound(loc, 'sound/items/tick.ogg', 50, 0, 7, 2)
Expand Down Expand Up @@ -229,6 +246,7 @@
active = !active
if(active)
to_chat(usr, "<span class='notice'>You activate [src].</span>")
operator = usr
processing_objects.Add(src)
else
to_chat(usr, "<span class='notice'>You deactivate [src].</span>")
Expand Down

0 comments on commit a8ec4e4

Please sign in to comment.