Files
Paradise/code/game/area/ai_monitored.dm
elly1989@rocketmail.com 48088b79d9 ugh...this was horrible. I'm really sorry if I fucked anything up, I was literally going braindead towards the end.
Replaced every l_hand = and r_hand = and all that if(hand) crap to use standardised procs. This means we can use procs like Dropped() reliably as they will always be called when things are dropped.

Thorough documentation to come. But generally, if you want a mob's icons to update after deleting something in the inventory...use drop_from_inventory(the_thing_you_wanna_drop) just before deleting it. If you wanna put something in a mob's hands use put_in_hands() (or one of the variants). It'll try putting it in active hand first, then inactive, then the floor. They handle layers, overlays, screenlocs calling various procs such as dropped() etc for you. Easy

mob.equipped() is now mob.get_active_hand() because there was another totally unrelated proc named equipped() and stuff was confusing.

Weakening was made instantaneous.

Minor optimisations for human/handle_regular_status_updates(). I'll port these changes over to the other mobs next. Basically it should stop it constantly incrementing every status effect even after death.

umm... bunch of overlays related fixes... I think that's everything. :/

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3900 316c924e-a436-60f5-8080-3fe189b3f50e
2012-06-23 21:24:45 +00:00

87 lines
2.7 KiB
Plaintext

/area/ai_monitored
name = "AI Monitored Area"
var/obj/machinery/camera/motion/motioncamera = null
/area/ai_monitored/New()
..()
// locate and store the motioncamera
spawn (20) // spawn on a delay to let turfs/objs load
for (var/obj/machinery/camera/motion/M in src)
motioncamera = M
return
return
/area/ai_monitored/Entered(atom/movable/O)
..()
if (istype(O, /mob) && motioncamera)
motioncamera.newTarget(O)
/area/ai_monitored/Exited(atom/movable/O)
if (istype(O, /mob) && motioncamera)
motioncamera.lostTarget(O)
/obj/machinery/camera/motion
name = "Motion Security Camera"
var/list/motionTargets = list()
var/detectTime = 0
var/locked = 1
/obj/machinery/camera/motion/process()
// motion camera event loop
if (detectTime > 0)
var/elapsed = world.time - detectTime
if (elapsed > 300)
triggerAlarm()
else if (detectTime == -1)
for (var/mob/target in motionTargets)
if (target.stat == 2) lostTarget(target)
/obj/machinery/camera/motion/proc/newTarget(var/mob/target)
if (istype(target, /mob/living/silicon/ai)) return 0
if (detectTime == 0)
detectTime = world.time // start the clock
if (!(target in motionTargets))
motionTargets += target
return 1
/obj/machinery/camera/motion/proc/lostTarget(var/mob/target)
if (target in motionTargets)
motionTargets -= target
if (motionTargets.len == 0)
cancelAlarm()
/obj/machinery/camera/motion/proc/cancelAlarm()
if (detectTime == -1)
for (var/mob/living/silicon/aiPlayer in world)
if (status) aiPlayer.cancelAlarm("Motion", src.loc.loc)
detectTime = 0
return 1
/obj/machinery/camera/motion/proc/triggerAlarm()
if (!detectTime) return 0
for (var/mob/living/silicon/aiPlayer in world)
if (status) aiPlayer.triggerAlarm("Motion", src.loc.loc, src)
detectTime = -1
return 1
/obj/machinery/camera/motion/attackby(W as obj, mob/user as mob)
if (istype(W, /obj/item/weapon/wirecutters) && locked == 1) return
if (istype(W, /obj/item/weapon/screwdriver))
var/turf/T = user.loc
user << text("\blue []ing the access hatch... (this is a long process)", (locked) ? "Open" : "Clos")
sleep(100)
if ((user.loc == T && user.get_active_hand() == W && !( user.stat )))
src.locked ^= 1
user << text("\blue The access hatch is now [].", (locked) ? "closed" : "open")
..() // call the parent to (de|re)activate
if (istype(W, /obj/item/weapon/wirecutters)) // now handle alarm on/off...
if (status) // ok we've just been reconnected... send an alarm!
detectTime = world.time - 301
triggerAlarm()
else
for (var/mob/living/silicon/aiPlayer in world) // manually cancel, to not disturb internal state
aiPlayer.cancelAlarm("Motion", src.loc.loc)