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

@@ -100,4 +100,35 @@
body_parts_covered = HEAD|FACE|EYES body_parts_covered = HEAD|FACE|EYES
w_class = 2 w_class = 2
var/voicechange = 0 var/voicechange = 0
siemens_coefficient = 0.9 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 = 'icons/mob/eye.dmi'
icon_state = "default-eye" icon_state = "default-eye"
alpha = 127 alpha = 127
var/list/visibleChunks = list()
var/mob/living/owner = null var/sprint = 10
density = 0 var/cooldown = 0
status_flags = GODMODE // You can't damage it. var/acceleration = 1
see_in_dark = 7 see_in_dark = 7
status_flags = GODMODE
invisibility = INVISIBILITY_EYE invisibility = INVISIBILITY_EYE
var/mob/owner = null
var/list/visibleChunks = list()
var/ghostimage = null var/ghostimage = null
var/datum/visualnet/visualnet var/datum/visualnet/visualnet
@@ -63,8 +69,35 @@ mob/eye/Del()
return 1 return 1
return 0 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() /mob/eye/proc/getLoc()
if(owner) if(owner)
if(!isturf(owner.loc) || !owner.client) if(!isturf(owner.loc) || !owner.client)
return return
return loc 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)
if(!machine.check_eye(src)) if(!machine.check_eye(src))
reset_view(null) reset_view(null)
else if(eyeobj)
if(eyeobj.owner != src)
reset_view(null)
else
src.sight |= SEE_TURFS|SEE_MOBS|SEE_OBJS
else else
var/isRemoteObserve = 0 var/isRemoteObserve = 0
if((mRemote in mutations) && remoteview_target) if((mRemote in mutations) && remoteview_target)

View File

@@ -6,7 +6,6 @@
/mob/eye/aiEye /mob/eye/aiEye
name = "Inactive AI Eye" name = "Inactive AI Eye"
icon_state = "AI-eye" icon_state = "AI-eye"
var/mob/living/silicon/ai/ai = null
/mob/eye/aiEye/New() /mob/eye/aiEye/New()
..() ..()
@@ -14,6 +13,7 @@
/mob/eye/aiEye/setLoc(var/T, var/cancel_tracking = 1) /mob/eye/aiEye/setLoc(var/T, var/cancel_tracking = 1)
if(..()) if(..())
var/mob/living/silicon/ai/ai = owner
if(cancel_tracking) if(cancel_tracking)
ai.ai_cancel_tracking() ai.ai_cancel_tracking()
@@ -27,23 +27,19 @@
// The AI's "eye". Described on the top of the page. // The AI's "eye". Described on the top of the page.
/mob/living/silicon/ai /mob/living/silicon/ai
var/mob/eye/aiEye/eyeobj = new() eyeobj = new /mob/eye/aiEye()
var/sprint = 10
var/cooldown = 0
var/acceleration = 1
var/obj/machinery/hologram/holopad/holo = null 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. // Intiliaze the eye by assigning it's "ai" variable to us. Then set it's loc to us.
/mob/living/silicon/ai/New() /mob/living/silicon/ai/New()
..() ..()
eyeobj.ai = src
eyeobj.owner = src eyeobj.owner = src
eyeobj.name = "[src.name] (AI Eye)" // Give it a name eyeobj.name = "[src.name] (AI Eye)" // Give it a name
spawn(5) spawn(5)
eyeobj.loc = src.loc eyeobj.loc = src.loc
/mob/living/silicon/ai/Del() /mob/living/silicon/ai/Del()
eyeobj.ai = null eyeobj.owner = null
del(eyeobj) // No AI, no Eye del(eyeobj) // No AI, no Eye
..() ..()
@@ -53,32 +49,6 @@
if(AI.eyeobj && AI.client.eye == AI.eyeobj) if(AI.eyeobj && AI.client.eye == AI.eyeobj)
AI.eyeobj.setLoc(src) 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. // Return to the Core.
/mob/living/silicon/ai/proc/core() /mob/living/silicon/ai/proc/core()
@@ -95,7 +65,7 @@
if(!src.eyeobj) if(!src.eyeobj)
src << "ERROR: Eyeobj not found. Creating new eye..." src << "ERROR: Eyeobj not found. Creating new eye..."
src.eyeobj = new(src.loc) src.eyeobj = new(src.loc)
src.eyeobj.ai = src src.eyeobj.owner = src
src.SetName(src.name) src.SetName(src.name)
if(client && client.eye) if(client && client.eye)
@@ -108,5 +78,8 @@
set category = "AI Commands" set category = "AI Commands"
set name = "Toggle Camera Acceleration" set name = "Toggle Camera Acceleration"
acceleration = !acceleration if(!eyeobj)
usr << "Camera acceleration has been toggled [acceleration ? "on" : "off"]." 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 if(mob.stat==2) return
// handle possible AI movement // handle possible Eye movement
if(isAI(mob)) if(mob.eyeobj)
return AIMove(n,direct,mob) return mob.EyeMove(n,direct)
if(mob.monkeyizing) return//This is sota the goto stop mobs from moving var if(mob.monkeyizing) return//This is sota the goto stop mobs from moving var
@@ -457,12 +457,12 @@
var/area/A = turf.loc var/area/A = turf.loc
if(istype(A) && A.has_gravity == 0) if(istype(A) && A.has_gravity == 0)
var/can_walk = 0 var/can_walk = 0
if(ishuman(src)) // Only humans can wear magboots, so we give them a chance to. if(ishuman(src)) // Only humans can wear magboots, so we give them a chance to.
var/mob/living/carbon/human/H = src var/mob/living/carbon/human/H = src
if(istype(H.shoes, /obj/item/clothing/shoes/magboots) && (H.shoes.flags & NOSLIP)) if(istype(H.shoes, /obj/item/clothing/shoes/magboots) && (H.shoes.flags & NOSLIP))
can_walk = 1 can_walk = 1
if(!can_walk) if(!can_walk)
continue continue

Binary file not shown.

Before

Width:  |  Height:  |  Size: 855 B

After

Width:  |  Height:  |  Size: 845 B