From 9b7834ff7ad37dce7da5a8f1882c0654219ff30b Mon Sep 17 00:00:00 2001 From: PsiOmega Date: Wed, 25 Mar 2015 17:08:56 +0100 Subject: [PATCH] Refactors the AI eye. Relocates eye movement to the eye code itself. Adds a mask that allows any mob able of wearing it direct access to the camera network, as a proof of concept and adminbus. --- code/modules/clothing/masks/miscellaneous.dm | 33 ++++++++++++- code/modules/mob/freelook/eye.dm | 41 ++++++++++++++-- code/modules/mob/living/carbon/human/life.dm | 6 +++ .../mob/living/silicon/ai/freelook/eye.dm | 45 ++++-------------- code/modules/mob/mob_movement.dm | 10 ++-- icons/mob/eye.dmi | Bin 855 -> 845 bytes 6 files changed, 89 insertions(+), 46 deletions(-) diff --git a/code/modules/clothing/masks/miscellaneous.dm b/code/modules/clothing/masks/miscellaneous.dm index 412f69bda6..3d3db7c736 100644 --- a/code/modules/clothing/masks/miscellaneous.dm +++ b/code/modules/clothing/masks/miscellaneous.dm @@ -100,4 +100,35 @@ body_parts_covered = HEAD|FACE|EYES w_class = 2 var/voicechange = 0 - siemens_coefficient = 0.9 \ No newline at end of file + siemens_coefficient = 0.9 + +/obj/item/clothing/mask/ai + name = "camera MIU" + desc = "Allows for direct mental connection to accessible camera networks." + icon_state = "s-ninja" + item_state = "s-ninja" + flags_inv = HIDEFACE + body_parts_covered = 0 + var/mob/eye/aiEye/eye + +/obj/item/clothing/mask/ai/New() + eye = new(src) + +/obj/item/clothing/mask/ai/equipped(var/mob/user, var/slot) + ..(user, slot) + if(slot == slot_wear_mask) + eye.owner = user + user.eyeobj = eye + + for(var/datum/chunk/c in eye.visibleChunks) + c.remove(eye) + eye.setLoc(user) + +/obj/item/clothing/mask/ai/dropped(var/mob/user) + ..() + if(eye.owner == user) + for(var/datum/chunk/c in eye.visibleChunks) + c.remove(eye) + + eye.owner.eyeobj = null + eye.owner = null diff --git a/code/modules/mob/freelook/eye.dm b/code/modules/mob/freelook/eye.dm index e83f209028..70ae8cb700 100644 --- a/code/modules/mob/freelook/eye.dm +++ b/code/modules/mob/freelook/eye.dm @@ -8,12 +8,18 @@ icon = 'icons/mob/eye.dmi' icon_state = "default-eye" alpha = 127 - var/list/visibleChunks = list() - var/mob/living/owner = null - density = 0 - status_flags = GODMODE // You can't damage it. + + var/sprint = 10 + var/cooldown = 0 + var/acceleration = 1 + see_in_dark = 7 + status_flags = GODMODE invisibility = INVISIBILITY_EYE + + var/mob/owner = null + var/list/visibleChunks = list() + var/ghostimage = null var/datum/visualnet/visualnet @@ -63,8 +69,35 @@ mob/eye/Del() return 1 return 0 +/mob/eye/EyeMove(n, direct) + var/initial = initial(sprint) + var/max_sprint = 50 + + if(cooldown && cooldown < world.timeofday) + sprint = initial + + for(var/i = 0; i < max(sprint, initial); i += 20) + var/turf/step = get_turf(get_step(src, direct)) + if(step) + setLoc(step) + + cooldown = world.timeofday + 5 + if(acceleration) + sprint = min(sprint + 0.5, max_sprint) + else + sprint = initial + /mob/eye/proc/getLoc() if(owner) if(!isturf(owner.loc) || !owner.client) return return loc + +/mob + var/mob/eye/eyeobj + +/mob/proc/EyeMove(n, direct) + if(!eyeobj) + return + + return eyeobj.EyeMove(n, direct) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 29a1d067cb..e8cfda4c93 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1342,6 +1342,12 @@ if(machine) if(!machine.check_eye(src)) reset_view(null) + else if(eyeobj) + if(eyeobj.owner != src) + + reset_view(null) + else + src.sight |= SEE_TURFS|SEE_MOBS|SEE_OBJS else var/isRemoteObserve = 0 if((mRemote in mutations) && remoteview_target) diff --git a/code/modules/mob/living/silicon/ai/freelook/eye.dm b/code/modules/mob/living/silicon/ai/freelook/eye.dm index b7dce613f8..8bc60b819d 100644 --- a/code/modules/mob/living/silicon/ai/freelook/eye.dm +++ b/code/modules/mob/living/silicon/ai/freelook/eye.dm @@ -6,7 +6,6 @@ /mob/eye/aiEye name = "Inactive AI Eye" icon_state = "AI-eye" - var/mob/living/silicon/ai/ai = null /mob/eye/aiEye/New() ..() @@ -14,6 +13,7 @@ /mob/eye/aiEye/setLoc(var/T, var/cancel_tracking = 1) if(..()) + var/mob/living/silicon/ai/ai = owner if(cancel_tracking) ai.ai_cancel_tracking() @@ -27,23 +27,19 @@ // The AI's "eye". Described on the top of the page. /mob/living/silicon/ai - var/mob/eye/aiEye/eyeobj = new() - var/sprint = 10 - var/cooldown = 0 - var/acceleration = 1 + eyeobj = new /mob/eye/aiEye() var/obj/machinery/hologram/holopad/holo = null // Intiliaze the eye by assigning it's "ai" variable to us. Then set it's loc to us. /mob/living/silicon/ai/New() ..() - eyeobj.ai = src eyeobj.owner = src eyeobj.name = "[src.name] (AI Eye)" // Give it a name spawn(5) eyeobj.loc = src.loc /mob/living/silicon/ai/Del() - eyeobj.ai = null + eyeobj.owner = null del(eyeobj) // No AI, no Eye ..() @@ -53,32 +49,6 @@ if(AI.eyeobj && AI.client.eye == AI.eyeobj) AI.eyeobj.setLoc(src) -// This will move the AIEye. It will also cause lights near the eye to light up, if toggled. -// This is handled in the proc below this one. - -/client/proc/AIMove(n, direct, var/mob/living/silicon/ai/user) - - var/initial = initial(user.sprint) - var/max_sprint = 50 - - if(user.cooldown && user.cooldown < world.timeofday) // 3 seconds - user.sprint = initial - - for(var/i = 0; i < max(user.sprint, initial); i += 20) - var/turf/step = get_turf(get_step(user.eyeobj, direct)) - if(step) - user.eyeobj.setLoc(step) - - user.cooldown = world.timeofday + 5 - if(user.acceleration) - user.sprint = min(user.sprint + 0.5, max_sprint) - else - user.sprint = initial - - //user.unset_machine() //Uncomment this if it causes problems. - //user.lightNearbyCamera() - - // Return to the Core. /mob/living/silicon/ai/proc/core() @@ -95,7 +65,7 @@ if(!src.eyeobj) src << "ERROR: Eyeobj not found. Creating new eye..." src.eyeobj = new(src.loc) - src.eyeobj.ai = src + src.eyeobj.owner = src src.SetName(src.name) if(client && client.eye) @@ -108,5 +78,8 @@ set category = "AI Commands" set name = "Toggle Camera Acceleration" - acceleration = !acceleration - usr << "Camera acceleration has been toggled [acceleration ? "on" : "off"]." + if(!eyeobj) + return + + eyeobj.acceleration = !eyeobj.acceleration + usr << "Camera acceleration has been toggled [eyeobj.acceleration ? "on" : "off"]." diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index efd2c52740..bd00faf953 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -188,9 +188,9 @@ if(mob.stat==2) return - // handle possible AI movement - if(isAI(mob)) - return AIMove(n,direct,mob) + // handle possible Eye movement + if(mob.eyeobj) + return mob.EyeMove(n,direct) if(mob.monkeyizing) return//This is sota the goto stop mobs from moving var @@ -457,12 +457,12 @@ var/area/A = turf.loc if(istype(A) && A.has_gravity == 0) var/can_walk = 0 - + if(ishuman(src)) // Only humans can wear magboots, so we give them a chance to. var/mob/living/carbon/human/H = src if(istype(H.shoes, /obj/item/clothing/shoes/magboots) && (H.shoes.flags & NOSLIP)) can_walk = 1 - + if(!can_walk) continue diff --git a/icons/mob/eye.dmi b/icons/mob/eye.dmi index 3bcd9971658395a0d58106409f420cfc03bddb77..64ca1b100e3a095c26e9deb751f6114c9a9d617b 100644 GIT binary patch delta 562 zcmV-20?qx`2F(VrCjoyENkl7|NnRH;3b-PVX19_ z^nE_qCU6QuvCBD25&!^z>qvWR?Wz}Oyqehh__ZN?$ERtQWlut0mU<|a=lQdcm!%PW z$0rBd{vvFT!$Q0L{8wQ|cndJTYkx0Rdi0oD6RmA3;FU)=z+ zJ@y?h-@)k?Eqw>4TfFog_8i}K7!Ju&2bGP7Y;6Fa@kvq?S+6LT+wOJ}7y z_;vsQ00000PpA)2AD})!eSrD^^#SSw)CT|n0002Md?U}t~3|NQ>m_FL!ox9@Oo`_1$FX}Z0Hd)sfH-=8kvJYK2oC3eN%Jip&( z&xiPVd%C^Eu6Y0XedihQT^~pt@y;_4L49C!NqpizzfXMt00000*64xniCjp358}K7 zU5=u>gK+~Q-2x*kf9!X__@2zN&HTGLjvMfE4Dk*e`FDR~%;|KJ)t9Thzx(u@9Ql7^ zN>lw-y3}%&_u<`vBmZwtfR>9qi;NEO6u9#L!!t;S`W$lQ|A$`z-9L+hy8&nZUDtNu zD_z-_I=uP2|3AO3?GBvnrLONjy?=1!-y`@X-p;?br$C={w0{fPEjY_h*g4n@aB9l3 zs^kzfz9%Yjv8Fu$@y@^9gNWDPYMQv`4**y82Ob?#9c8;2p#T5?07*qoM6N<$f@?<| A5C8xG delta 572 zcmV-C0>k~y2G<6#CjoyONkleYQq5VyS9jb)?7i{(tJo2&vK>aZe zaIwd!P%KEJP?fzhJT7Kb$w%tD4!lmm{Pv#n#e-rD5Q{av+)BlCOK(^o{ zUty=6Zh$oCo2G5$5cH`ha;0000< KMNUMnLSTZ);4SF@