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.
This commit is contained in:
PsiOmega
2015-03-25 17:08:56 +01:00
parent bbe5d67e44
commit 9b7834ff7a
6 changed files with 89 additions and 46 deletions

View File

@@ -101,3 +101,34 @@
w_class = 2
var/voicechange = 0
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

View File

@@ -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)

View File

@@ -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)

View File

@@ -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"]."

View File

@@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 855 B

After

Width:  |  Height:  |  Size: 845 B