From ed461afed5b6e3a0035e84d40b57adc292652e63 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Tue, 3 Jan 2017 14:09:34 -0500 Subject: [PATCH] Fixes AIs being able to see cult runes (#22577) * Remove this shit so fast * Runes are now stored in a global list * Readd this shit to properly work * Refactor rune invisification into a proc * Fixes #17426 * Use the blood decals * Less garbage + removal * COMPILE BEFORE PUSH YOU SPERGLORD * Refactor into a datum * Added to crayon runes * Refactor AI's vision to a slightly lower level * Actually make the shit invisible to ais * Nevermind, fixed it * Fixes it being on the wrong layer --- code/__DEFINES/sight.dm | 3 ++ code/game/gamemodes/cult/runes.dm | 37 +++++++++++++++++++-- code/game/objects/effects/decals/crayon.dm | 8 +++++ code/modules/mob/living/silicon/ai/ai.dm | 13 +++++++- code/modules/mob/living/silicon/ai/login.dm | 6 ++-- 5 files changed, 60 insertions(+), 7 deletions(-) diff --git a/code/__DEFINES/sight.dm b/code/__DEFINES/sight.dm index bd7af5a9e0a6..fed22b083cc2 100644 --- a/code/__DEFINES/sight.dm +++ b/code/__DEFINES/sight.dm @@ -5,7 +5,10 @@ #define INVISIBILITY_LIGHTING 20 +#define SEE_INVISIBLE_AI 24 + #define SEE_INVISIBLE_LIVING 25 +#define INVISIBILITY_AI 25 #define SEE_INVISIBLE_LEVEL_ONE 35 //currently unused #define INVISIBILITY_LEVEL_ONE 35 //currently unused diff --git a/code/game/gamemodes/cult/runes.dm b/code/game/gamemodes/cult/runes.dm index 2ef3dd16999d..12761dd22a18 100644 --- a/code/game/gamemodes/cult/runes.dm +++ b/code/game/gamemodes/cult/runes.dm @@ -1,5 +1,6 @@ -/var/list/sacrificed = list() //a mixed list of minds and mobs +var/list/sacrificed = list() //a mixed list of minds and mobs var/list/non_revealed_runes = (subtypesof(/obj/effect/rune) - /obj/effect/rune/malformed) +var/list/ai_hidden_runes = list() /* @@ -13,6 +14,30 @@ To draw a rune, use an arcane tome. */ +//for hiding from the ai +/datum/ai_fake_rune + var/image/ai_image + +/datum/ai_fake_rune/New(_loc) + . = ..() + ai_hidden_runes += src + + var/obj/effect/decal/cleanable/blood/splatter/s = new(_loc) + ai_image = image(s.icon, icon_state = s.icon_state, loc = _loc, layer = TURF_LAYER) + qdel(s) + + for(var/a in ai_list) + var/mob/living/silicon/ai/AI = a + AI.invisify_rune(src) + +/datum/ai_fake_rune/Destroy() + ai_hidden_runes -= src + for(var/a in ai_list) + var/mob/living/silicon/ai/AI = a + AI.uninvisify_rune(src) + qdel(ai_image) + return ..() + /obj/effect/rune name = "rune" var/cultist_name = "basic rune" @@ -25,6 +50,8 @@ To draw a rune, use an arcane tome. layer = ABOVE_NORMAL_TURF_LAYER color = "#FF0000" + invisibility = INVISIBILITY_AI + var/invocation = "Aiy ele-mayo!" //This is said by cultists when the rune is invoked. var/req_cultists = 1 //The amount of cultists required around the rune to invoke it. If only 1, any cultist can invoke it. var/req_cultists_text //if we have a description override for required cultists to invoke @@ -38,12 +65,18 @@ To draw a rune, use an arcane tome. var/req_keyword = 0 //If the rune requires a keyword - go figure amirite var/keyword //The actual keyword for the rune + var/datum/ai_fake_rune/ai_hidden /obj/effect/rune/New(loc, set_keyword) - ..() + . = ..() + ai_hidden = new(loc) if(set_keyword) keyword = set_keyword +/obj/effect/rune/Destroy() + qdel(ai_hidden) + return ..() + /obj/effect/rune/examine(mob/user) ..() if(iscultist(user) || user.stat == DEAD) //If they're a cultist or a ghost, tell them the effects diff --git a/code/game/objects/effects/decals/crayon.dm b/code/game/objects/effects/decals/crayon.dm index e7cea3cbab6c..be913227c6db 100644 --- a/code/game/objects/effects/decals/crayon.dm +++ b/code/game/objects/effects/decals/crayon.dm @@ -5,8 +5,13 @@ icon_state = "rune1" gender = NEUTER var/do_icon_rotate = TRUE + var/datum/ai_fake_rune/ai_hidden = null /obj/effect/decal/cleanable/crayon/New(location, main = "#FFFFFF", var/type = "rune1", var/e_name = "rune", var/rotation = 0, var/alt_icon = null) + if(name == "rune") + ai_hidden = new(location) + invisibility = INVISIBILITY_AI + ..() loc = location @@ -26,6 +31,9 @@ add_atom_colour(main, FIXED_COLOUR_PRIORITY) +/obj/effect/decal/cleanable/crayon/Destroy() + qdel(ai_hidden) + return ..() /obj/effect/decal/cleanable/crayon/gang layer = HIGH_OBJ_LAYER //Harder to hide diff --git a/code/modules/mob/living/silicon/ai/ai.dm b/code/modules/mob/living/silicon/ai/ai.dm index 840743da0bee..11db8740b866 100644 --- a/code/modules/mob/living/silicon/ai/ai.dm +++ b/code/modules/mob/living/silicon/ai/ai.dm @@ -28,6 +28,9 @@ var/list/ai_list = list() med_hud = DATA_HUD_MEDICAL_BASIC sec_hud = DATA_HUD_SECURITY_BASIC mob_size = MOB_SIZE_LARGE + + see_invisible = SEE_INVISIBLE_AI + var/list/network = list("SS13") var/obj/machinery/camera/current = null var/list/connected_robots = list() @@ -498,7 +501,7 @@ var/list/ai_list = list() call_bot_cooldown = world.time + CALL_BOT_COOLDOWN Bot.call_bot(src, waypoint) call_bot_cooldown = 0 - + /mob/living/silicon/ai/triggerAlarm(class, area/A, O, obj/alarmsource) if(alarmsource.z != z) @@ -869,6 +872,14 @@ var/list/ai_list = list() exclusive control." apc.update_icon() +/mob/living/silicon/ai/proc/invisify_rune(datum/ai_fake_rune/rune) + if(client) + client.images += rune.ai_image + +/mob/living/silicon/ai/proc/uninvisify_rune(datum/ai_fake_rune/rune) + if(client) + client.images -= rune.ai_image + /mob/living/silicon/ai/spawned/New(loc, datum/ai_laws/L, mob/target_ai) if(!target_ai) target_ai = src //cheat! just give... ourselves as the spawned AI, because that's technically correct diff --git a/code/modules/mob/living/silicon/ai/login.dm b/code/modules/mob/living/silicon/ai/login.dm index 21f12ab915d7..02ce350fd38a 100644 --- a/code/modules/mob/living/silicon/ai/login.dm +++ b/code/modules/mob/living/silicon/ai/login.dm @@ -1,9 +1,7 @@ /mob/living/silicon/ai/Login() ..() - for(var/obj/effect/rune/rune in world) - var/image/blood = image(loc = rune) - blood.override = 1 - client.images += blood + for(var/r in ai_hidden_runes) + invisify_rune(r) if(stat != DEAD) for(var/obj/machinery/ai_status_display/O in machines) //change status