From dbedb0b414c83820bae430bfbf3c062ef08e9c21 Mon Sep 17 00:00:00 2001 From: PsiOmegaDelta Date: Sun, 15 Nov 2015 10:51:13 +0100 Subject: [PATCH] Corrects AI sight. Fixes #11450. --- code/modules/mob/living/life.dm | 22 +++++----- code/modules/mob/living/silicon/ai/life.dm | 51 ++++++++++------------ 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index 0815dac4364..fd9dd7b4bfa 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -136,7 +136,6 @@ /mob/living/proc/handle_vision() client.screen.Remove(global_hud.blurry, global_hud.druggy, global_hud.vimpaired, global_hud.darkMask, global_hud.nvg, global_hud.thermal, global_hud.meson, global_hud.science) - update_sight() if(stat == DEAD) @@ -159,24 +158,27 @@ reset_view(null, 0) else if(viewflags) sight |= viewflags - else if(eyeobj && eyeobj.owner != src) - reset_view(null) - else - if(!client.adminobs) + else if(eyeobj) + if(eyeobj.owner != src) reset_view(null) + else if(!client.adminobs) + reset_view(null) /mob/living/proc/update_sight() if(stat == DEAD) - sight |= SEE_TURFS - sight |= SEE_MOBS - sight |= SEE_OBJS - see_in_dark = 8 - see_invisible = SEE_INVISIBLE_LEVEL_TWO + update_dead_sight() else sight &= ~(SEE_TURFS|SEE_MOBS|SEE_OBJS) see_in_dark = 2 see_invisible = SEE_INVISIBLE_LIVING +/mob/living/proc/update_dead_sight() + sight |= SEE_TURFS + sight |= SEE_MOBS + sight |= SEE_OBJS + see_in_dark = 8 + see_invisible = SEE_INVISIBLE_LEVEL_TWO + /mob/living/proc/handle_hud_icons() handle_hud_icons_health() handle_hud_glasses() diff --git a/code/modules/mob/living/silicon/ai/life.dm b/code/modules/mob/living/silicon/ai/life.dm index b5ddfcedd91..6879284cb7a 100644 --- a/code/modules/mob/living/silicon/ai/life.dm +++ b/code/modules/mob/living/silicon/ai/life.dm @@ -38,21 +38,7 @@ src << "APU GENERATOR FAILURE! (System Damaged)" stop_apu(1) - var/blind = 0 - var/area/loc = null - if (istype(T, /turf)) - loc = T.loc - if (istype(loc, /area)) - if (!loc.power_equip && !istype(src.loc,/obj/item) && !APU_power) - blind = 1 - - if (!blind) - src.sight |= SEE_TURFS - src.sight |= SEE_MOBS - src.sight |= SEE_OBJS - src.see_in_dark = 8 - src.see_invisible = SEE_INVISIBLE_LIVING - + if (!is_blinded()) if (aiRestorePowerRoutine==2) src << "Alert cancelled. Power has been restored without our assistance." aiRestorePowerRoutine = 0 @@ -77,25 +63,13 @@ if (aiRestorePowerRoutine==0) aiRestorePowerRoutine = 1 - //Blind the AI - updateicon() - src.blind.screen_loc = ui_entire_screen - if (src.blind.layer!=18) - src.blind.layer = 18 - src.sight = src.sight&~SEE_TURFS - src.sight = src.sight&~SEE_MOBS - src.sight = src.sight&~SEE_OBJS - src.see_in_dark = 0 - src.see_invisible = SEE_INVISIBLE_LIVING - //Now to tell the AI why they're blind and dying slowly. - src << "You've lost power!" spawn(20) src << "Backup battery online. Scanners, camera, and radio interface offline. Beginning fault-detection." sleep(50) - if (loc.power_equip) + if (current_area.power_equip) if (!istype(T, /turf/space)) src << "Alert cancelled. Power has been restored without our assistance." aiRestorePowerRoutine = 0 @@ -125,7 +99,7 @@ else src << "Lost connection with the APC!" src:aiRestorePowerRoutine = 2 return - if (loc.power_equip) + if (current_area.power_equip) if (!istype(T, /turf/space)) src << "Alert cancelled. Power has been restored without our assistance." aiRestorePowerRoutine = 0 @@ -177,3 +151,22 @@ ..() add_ai_verbs(src) +/mob/living/silicon/ai/update_sight() + if(is_blinded()) + updateicon() + src.blind.screen_loc = ui_entire_screen + if (src.blind.layer!=18) + src.blind.layer = 18 + src.sight = src.sight&~SEE_TURFS + src.sight = src.sight&~SEE_MOBS + src.sight = src.sight&~SEE_OBJS + src.see_in_dark = 0 + src.see_invisible = SEE_INVISIBLE_LIVING + else + update_dead_sight() + +/mob/living/silicon/ai/proc/is_blinded() + var/area/A = get_area(src) + if (A && !A.power_equip && !istype(src.loc,/obj/item) && !APU_power) + return 1 + return 0